Skip to content

Commit

Permalink
Move modal from container to the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Aug 27, 2017
1 parent c55a598 commit 1829fd0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
4 changes: 2 additions & 2 deletions dist/grapes.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ <h1 class="bdg-title">The team</h1>
},

assetManager: {
upload: 'https://grapedrop.dev/asset-upload/testpage',
upload: 'https://test.page',
params: {
_token: 'pCYrSwjuiV0t5NVtZpQDY41Gn5lNUwo3it1FIkAj',
},
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Free and Open Source Web Builder Framework",
"version": "0.9.26",
"version": "0.9.27",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",
Expand All @@ -11,7 +11,6 @@
"url": "https://github.com/artf/grapesjs.git"
},
"dependencies": {
"babel-preset-stage-3": "^6.24.1",
"backbone": "^1.3.3",
"backbone-undo": "^0.2.5",
"codemirror": "^5.21.0",
Expand Down Expand Up @@ -56,7 +55,10 @@
"editor"
],
"babel": {
"presets": [ "es2015", "stage-3"]
"presets": [
"es2015",
"stage-3"
]
},
"scripts": {
"lint": "eslint src",
Expand Down
2 changes: 1 addition & 1 deletion src/asset_manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ module.exports = () => {
},

postRender(editorView) {
fu.initDropzone(editorView);
c.dropzone && fu.initDropzone(editorView);
},

//-------
Expand Down
19 changes: 11 additions & 8 deletions src/asset_manager/view/FileUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,29 @@ module.exports = Backbone.View.extend({
* */
uploadFile(e) {
const files = e.dataTransfer ? e.dataTransfer.files : e.target.files;
const formData = new FormData();
const body = new FormData();
const config = this.config;
const params = config.params;

for (let i = 0; i < files.length; i++) {
formData.append('files[]', files[i]);
body.append('files[]', files[i]);
}

for (let param in params) {
formData.append(param, params[param]);
body.append(param, params[param]);
}

var target = this.target;
const url = config.upload;
const headers = config.headers;

if (url) {
this.onUploadStart();
return fetch(url, {
method: 'post',
credentials: 'include',
headers: config.headers,
body: formData,
headers,
body,
}).then(res => (res.status/200|0) == 1 ?
res.text() : res.text().then((text) =>
Promise.reject(text)
Expand Down Expand Up @@ -150,8 +152,9 @@ module.exports = Backbone.View.extend({
const c = this.config;
const em = ev.model;
const edEl = ev.el;
const editor = em && em.get('Editor');
const frameEl = ev.model.get('Canvas').getBody();
const editor = em.get('Editor');
const container = em.get('Config').el;
const frameEl = em.get('Canvas').getBody();
const ppfx = this.ppfx;
const updatedCls = `${ppfx}dropzone-active`;
const dropzoneCls = `${ppfx}dropzone`;
Expand Down Expand Up @@ -193,7 +196,7 @@ module.exports = Backbone.View.extend({
ev.$el.append(`<div class="${dropzoneCls}">${c.dropzoneContent}</div>`);
cleanEditorElCls();

if (c.dropzone && 'draggable' in edEl) {
if ('draggable' in edEl) {
[edEl, frameEl].forEach((item) => {
item.ondragover = onDragOver;
item.ondragleave = onDragLeave;
Expand Down
10 changes: 5 additions & 5 deletions src/modal_dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ module.exports = () => {
config: c,
});

if(c.em)
c.em.on('loaded', function(){
this.render().appendTo(c.em.config.el || 'body');
}, this);

return this;
},

postRender(editorView) {
// c.em.config.el || 'body'
this.render().appendTo(editorView.el);
},

/**
* Open the modal window
* @return {this}
Expand Down

0 comments on commit 1829fd0

Please sign in to comment.