mirror of https://github.com/artf/grapesjs.git
267 changed files with 12143 additions and 11934 deletions
@ -1,12 +1,11 @@ |
|||||
const Asset = require('./Asset'); |
const Asset = require('./Asset'); |
||||
|
|
||||
module.exports = Asset.extend({ |
module.exports = Asset.extend({ |
||||
|
defaults: { |
||||
defaults: { ...Asset.prototype.defaults, |
...Asset.prototype.defaults, |
||||
type: 'image', |
type: 'image', |
||||
unitDim: 'px', |
unitDim: 'px', |
||||
height: 0, |
height: 0, |
||||
width: 0, |
width: 0 |
||||
}, |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
@ -1,18 +1,22 @@ |
|||||
import TypeableCollection from 'domain_abstract/model/TypeableCollection'; |
import TypeableCollection from 'domain_abstract/model/TypeableCollection'; |
||||
|
|
||||
module.exports = require('backbone').Collection.extend(TypeableCollection).extend({ |
module.exports = require('backbone') |
||||
types: [{ |
.Collection.extend(TypeableCollection) |
||||
id: 'image', |
.extend({ |
||||
model: require('./AssetImage'), |
types: [ |
||||
view: require('./../view/AssetImageView'), |
{ |
||||
isType(value) { |
id: 'image', |
||||
if (typeof value == 'string') { |
model: require('./AssetImage'), |
||||
return { |
view: require('./../view/AssetImageView'), |
||||
type: 'image', |
isType(value) { |
||||
src: value, |
if (typeof value == 'string') { |
||||
|
return { |
||||
|
type: 'image', |
||||
|
src: value |
||||
|
}; |
||||
} |
} |
||||
|
return value; |
||||
} |
} |
||||
return value; |
|
||||
} |
} |
||||
}] |
] |
||||
}); |
}); |
||||
|
|||||
@ -1,7 +1,5 @@ |
|||||
module.exports = { |
module.exports = { |
||||
|
|
||||
blocks: [], |
blocks: [], |
||||
|
|
||||
appendTo: '', |
appendTo: '' |
||||
|
|
||||
}; |
}; |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
var Backbone = require('backbone'); |
var Backbone = require('backbone'); |
||||
|
|
||||
module.exports = Backbone.Collection.extend({ |
module.exports = Backbone.Collection.extend({ |
||||
model: require('./Category'), |
model: require('./Category') |
||||
}); |
}); |
||||
|
|||||
@ -1,12 +1,10 @@ |
|||||
var Backbone = require('backbone'); |
var Backbone = require('backbone'); |
||||
|
|
||||
module.exports = Backbone.Model.extend({ |
module.exports = Backbone.Model.extend({ |
||||
|
|
||||
defaults: { |
defaults: { |
||||
id: '', |
id: '', |
||||
label: '', |
label: '', |
||||
open: true, |
open: true, |
||||
attributes: {}, |
attributes: {} |
||||
}, |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
@ -1,12 +1,10 @@ |
|||||
var Backbone = require('backbone'); |
var Backbone = require('backbone'); |
||||
|
|
||||
module.exports = Backbone.Model.extend({ |
module.exports = Backbone.Model.extend({ |
||||
|
defaults: { |
||||
defaults :{ |
|
||||
wrapper: '', |
wrapper: '', |
||||
width: '', |
width: '', |
||||
height: '', |
height: '', |
||||
attributes: {}, |
attributes: {} |
||||
}, |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
@ -1,9 +1,7 @@ |
|||||
var Backbone = require('backbone'); |
var Backbone = require('backbone'); |
||||
|
|
||||
module.exports = Backbone.Model.extend({ |
module.exports = Backbone.Model.extend({ |
||||
|
defaults: { |
||||
defaults :{ |
id: '' |
||||
id: '', |
|
||||
} |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
@ -1,15 +1,13 @@ |
|||||
module.exports = { |
module.exports = { |
||||
|
|
||||
run(editor) { |
run(editor) { |
||||
const sel = editor.getSelected(); |
const sel = editor.getSelected(); |
||||
let comp = sel && sel.parent(); |
let comp = sel && sel.parent(); |
||||
|
|
||||
// Recurse through the parent() chain until a selectable parent is found
|
// Recurse through the parent() chain until a selectable parent is found
|
||||
while (comp && !comp.get("selectable")) { |
while (comp && !comp.get('selectable')) { |
||||
comp = comp.parent(); |
comp = comp.parent(); |
||||
} |
} |
||||
|
|
||||
comp && editor.select(comp); |
comp && editor.select(comp); |
||||
} |
} |
||||
|
|
||||
}; |
}; |
||||
|
|||||
@ -1,11 +1,9 @@ |
|||||
module.exports = { |
module.exports = { |
||||
|
|
||||
run(ed) { |
run(ed) { |
||||
ed.Canvas.getBody().className = this.ppfx + 'dashed'; |
ed.Canvas.getBody().className = this.ppfx + 'dashed'; |
||||
}, |
}, |
||||
|
|
||||
stop(ed) { |
stop(ed) { |
||||
ed.Canvas.getBody().className = ""; |
ed.Canvas.getBody().className = ''; |
||||
} |
} |
||||
|
|
||||
}; |
}; |
||||
|
|||||
@ -1,12 +1,10 @@ |
|||||
module.exports = { |
module.exports = { |
||||
|
|
||||
// Style prefix
|
// Style prefix
|
||||
stylePrefix: 'css-', |
stylePrefix: 'css-', |
||||
|
|
||||
// Custom CSS string to render on top
|
// Custom CSS string to render on top
|
||||
'staticRules': '', |
staticRules: '', |
||||
|
|
||||
// Default CSS style
|
// Default CSS style
|
||||
rules: [], |
rules: [] |
||||
|
|
||||
}; |
}; |
||||
|
|||||
@ -1,7 +1,5 @@ |
|||||
module.exports = { |
module.exports = { |
||||
|
|
||||
devices: [], |
devices: [], |
||||
|
|
||||
deviceLabel: 'Device', |
deviceLabel: 'Device' |
||||
|
|
||||
}; |
}; |
||||
|
|||||
File diff suppressed because it is too large
@ -1,103 +1,100 @@ |
|||||
var Component = require('./Component'); |
var Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
|
defaults: { |
||||
|
...Component.prototype.defaults, |
||||
|
type: 'image', |
||||
|
tagName: 'img', |
||||
|
src: '', |
||||
|
void: 1, |
||||
|
droppable: 0, |
||||
|
editable: 1, |
||||
|
highlightable: 0, |
||||
|
resizable: 1, |
||||
|
traits: ['alt'] |
||||
|
}, |
||||
|
|
||||
defaults: { ...Component.prototype.defaults, |
initialize(o, opt) { |
||||
type: 'image', |
Component.prototype.initialize.apply(this, arguments); |
||||
tagName: 'img', |
var attr = this.get('attributes'); |
||||
src: '', |
if (attr.src) this.set('src', attr.src); |
||||
void: 1, |
}, |
||||
droppable: 0, |
|
||||
editable: 1, |
|
||||
highlightable: 0, |
|
||||
resizable: 1, |
|
||||
traits: ['alt'] |
|
||||
}, |
|
||||
|
|
||||
initialize(o, opt) { |
|
||||
Component.prototype.initialize.apply(this, arguments); |
|
||||
var attr = this.get('attributes'); |
|
||||
if(attr.src) |
|
||||
this.set('src', attr.src); |
|
||||
}, |
|
||||
|
|
||||
initToolbar(...args) { |
initToolbar(...args) { |
||||
Component.prototype.initToolbar.apply(this, args); |
Component.prototype.initToolbar.apply(this, args); |
||||
|
|
||||
if (this.sm && this.sm.get) { |
if (this.sm && this.sm.get) { |
||||
var cmd = this.sm.get('Commands'); |
var cmd = this.sm.get('Commands'); |
||||
var cmdName = 'image-editor'; |
var cmdName = 'image-editor'; |
||||
|
|
||||
// Add Image Editor button only if the default command exists
|
// Add Image Editor button only if the default command exists
|
||||
if (cmd.has(cmdName)) { |
if (cmd.has(cmdName)) { |
||||
var tb = this.get('toolbar'); |
var tb = this.get('toolbar'); |
||||
tb.push({ |
tb.push({ |
||||
attributes: {class: 'fa fa-pencil'}, |
attributes: { class: 'fa fa-pencil' }, |
||||
command: cmdName, |
command: cmdName |
||||
}); |
}); |
||||
this.set('toolbar', tb); |
this.set('toolbar', tb); |
||||
|
} |
||||
} |
} |
||||
} |
}, |
||||
}, |
|
||||
|
|
||||
/** |
/** |
||||
* Returns object of attributes for HTML |
* Returns object of attributes for HTML |
||||
* @return {Object} |
* @return {Object} |
||||
* @private |
* @private |
||||
*/ |
*/ |
||||
getAttrToHTML(...args) { |
getAttrToHTML(...args) { |
||||
var attr = Component.prototype.getAttrToHTML.apply(this, args); |
var attr = Component.prototype.getAttrToHTML.apply(this, args); |
||||
delete attr.onmousedown; |
delete attr.onmousedown; |
||||
var src = this.get('src'); |
var src = this.get('src'); |
||||
if(src) |
if (src) attr.src = src; |
||||
attr.src = src; |
return attr; |
||||
return attr; |
}, |
||||
}, |
|
||||
|
|
||||
/** |
/** |
||||
* Parse uri |
* Parse uri |
||||
* @param {string} uri |
* @param {string} uri |
||||
* @return {object} |
* @return {object} |
||||
* @private |
* @private |
||||
*/ |
*/ |
||||
parseUri(uri) { |
parseUri(uri) { |
||||
var el = document.createElement('a'); |
var el = document.createElement('a'); |
||||
el.href = uri; |
el.href = uri; |
||||
var query = {}; |
var query = {}; |
||||
var qrs = el.search.substring(1).split('&'); |
var qrs = el.search.substring(1).split('&'); |
||||
for (var i = 0; i < qrs.length; i++) { |
for (var i = 0; i < qrs.length; i++) { |
||||
var pair = qrs[i].split('='); |
var pair = qrs[i].split('='); |
||||
var name = decodeURIComponent(pair[0]); |
var name = decodeURIComponent(pair[0]); |
||||
if(name) |
if (name) query[name] = decodeURIComponent(pair[1]); |
||||
query[name] = decodeURIComponent(pair[1]); |
} |
||||
|
return { |
||||
|
hostname: el.hostname, |
||||
|
pathname: el.pathname, |
||||
|
protocol: el.protocol, |
||||
|
search: el.search, |
||||
|
hash: el.hash, |
||||
|
port: el.port, |
||||
|
query |
||||
|
}; |
||||
} |
} |
||||
return { |
|
||||
hostname: el.hostname, |
|
||||
pathname: el.pathname, |
|
||||
protocol: el.protocol, |
|
||||
search: el.search, |
|
||||
hash: el.hash, |
|
||||
port: el.port, |
|
||||
query, |
|
||||
}; |
|
||||
}, |
}, |
||||
|
{ |
||||
},{ |
/** |
||||
|
* Detect if the passed element is a valid component. |
||||
/** |
* In case the element is valid an object abstracted |
||||
* Detect if the passed element is a valid component. |
* from the element will be returned |
||||
* In case the element is valid an object abstracted |
* @param {HTMLElement} |
||||
* from the element will be returned |
* @return {Object} |
||||
* @param {HTMLElement} |
* @private |
||||
* @return {Object} |
*/ |
||||
* @private |
isComponent(el) { |
||||
*/ |
var result = ''; |
||||
isComponent(el) { |
if (el.tagName == 'IMG') { |
||||
var result = ''; |
result = { type: 'image' }; |
||||
if(el.tagName == 'IMG'){ |
} |
||||
result = {type: 'image'}; |
return result; |
||||
} |
} |
||||
return result; |
} |
||||
}, |
); |
||||
|
|
||||
}); |
|
||||
|
|||||
@ -1,53 +1,53 @@ |
|||||
const Component = require('./ComponentText'); |
const Component = require('./ComponentText'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
defaults: { ...Component.prototype.defaults, |
defaults: { |
||||
|
...Component.prototype.defaults, |
||||
type: 'link', |
type: 'link', |
||||
tagName: 'a', |
tagName: 'a', |
||||
traits: ['title', 'href', 'target'], |
traits: ['title', 'href', 'target'] |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* Returns object of attributes for HTML |
* Returns object of attributes for HTML |
||||
* @return {Object} |
* @return {Object} |
||||
* @private |
* @private |
||||
*/ |
*/ |
||||
getAttrToHTML(...args) { |
getAttrToHTML(...args) { |
||||
const attr = Component.prototype.getAttrToHTML.apply(this, args); |
const attr = Component.prototype.getAttrToHTML.apply(this, args); |
||||
delete attr.onmousedown; |
delete attr.onmousedown; |
||||
return attr; |
return attr; |
||||
|
} |
||||
}, |
}, |
||||
|
{ |
||||
}, { |
isComponent(el) { |
||||
|
let result; |
||||
isComponent(el) { |
let avoidEdit; |
||||
let result; |
|
||||
let avoidEdit; |
if (el.tagName == 'A') { |
||||
|
result = { |
||||
if (el.tagName == 'A') { |
type: 'link', |
||||
result = { |
editable: 0 |
||||
type: 'link', |
}; |
||||
editable: 0, |
|
||||
}; |
// The link is editable only if, at least, one of its
|
||||
|
// children is a text node (not empty one)
|
||||
// The link is editable only if, at least, one of its
|
const children = el.childNodes; |
||||
// children is a text node (not empty one)
|
const len = children.length; |
||||
const children = el.childNodes; |
if (!len) delete result.editable; |
||||
const len = children.length; |
|
||||
if (!len) delete result.editable; |
for (let i = 0; i < len; i++) { |
||||
|
const child = children[i]; |
||||
for (let i = 0; i < len; i++) { |
|
||||
const child = children[i]; |
if (child.nodeType == 3 && child.textContent.trim() != '') { |
||||
|
delete result.editable; |
||||
if (child.nodeType == 3 && child.textContent.trim() != '') { |
break; |
||||
delete result.editable; |
} |
||||
break; |
|
||||
} |
} |
||||
} |
} |
||||
} |
|
||||
|
|
||||
return result; |
return result; |
||||
}, |
} |
||||
|
} |
||||
}); |
); |
||||
|
|||||
@ -1,27 +1,26 @@ |
|||||
var Component = require('./Component'); |
var Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
defaults: _.extend({}, Component.prototype.defaults, { |
defaults: _.extend({}, Component.prototype.defaults, { |
||||
type: 'script', |
type: 'script', |
||||
droppable: false, |
droppable: false, |
||||
draggable: false, |
draggable: false, |
||||
layerable: false, |
layerable: false |
||||
}), |
}) |
||||
|
}, |
||||
}, { |
{ |
||||
|
isComponent(el) { |
||||
|
if (el.tagName == 'SCRIPT') { |
||||
|
var result = { type: 'script' }; |
||||
|
|
||||
isComponent(el) { |
if (el.src) { |
||||
if (el.tagName == 'SCRIPT') { |
result.src = el.src; |
||||
var result = {type: 'script'}; |
result.onload = el.onload; |
||||
|
} |
||||
|
|
||||
if (el.src) { |
return result; |
||||
result.src = el.src; |
|
||||
result.onload = el.onload; |
|
||||
} |
} |
||||
|
|
||||
return result; |
|
||||
} |
} |
||||
}, |
} |
||||
|
); |
||||
}); |
|
||||
|
|||||
@ -1,33 +1,33 @@ |
|||||
var Component = require('./Component'); |
var Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
|
defaults: { |
||||
|
...Component.prototype.defaults, |
||||
|
highlightable: 0 |
||||
|
}, |
||||
|
|
||||
defaults: { ...Component.prototype.defaults, |
getName() { |
||||
highlightable: 0, |
let name = this.get('tagName'); |
||||
}, |
let customName = this.get('custom-name'); |
||||
|
name = name.charAt(0).toUpperCase() + name.slice(1); |
||||
getName() { |
return customName || name; |
||||
let name = this.get('tagName'); |
|
||||
let customName = this.get('custom-name'); |
|
||||
name = name.charAt(0).toUpperCase() + name.slice(1); |
|
||||
return customName || name; |
|
||||
}, |
|
||||
|
|
||||
}, { |
|
||||
|
|
||||
isComponent(el) { |
|
||||
if (SVGElement && el instanceof SVGElement) { |
|
||||
// Some SVG elements require uppercase letters (eg. <linearGradient>)
|
|
||||
const tagName = el.tagName; |
|
||||
// Make the root resizable
|
|
||||
const resizable = tagName == 'svg' ? true : false; |
|
||||
|
|
||||
return { |
|
||||
tagName, |
|
||||
type: 'svg', |
|
||||
resizable |
|
||||
}; |
|
||||
} |
} |
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
if (SVGElement && el instanceof SVGElement) { |
||||
|
// Some SVG elements require uppercase letters (eg. <linearGradient>)
|
||||
|
const tagName = el.tagName; |
||||
|
// Make the root resizable
|
||||
|
const resizable = tagName == 'svg' ? true : false; |
||||
|
|
||||
}); |
return { |
||||
|
tagName, |
||||
|
type: 'svg', |
||||
|
resizable |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
); |
||||
|
|||||
@ -1,29 +1,29 @@ |
|||||
const Component = require('./Component'); |
const Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
defaults: { ...Component.prototype.defaults, |
defaults: { |
||||
|
...Component.prototype.defaults, |
||||
type: 'table', |
type: 'table', |
||||
tagName: 'table', |
tagName: 'table', |
||||
droppable: ['tbody', 'thead', 'tfoot'], |
droppable: ['tbody', 'thead', 'tfoot'] |
||||
}, |
}, |
||||
|
|
||||
initialize(o, opt) { |
initialize(o, opt) { |
||||
Component.prototype.initialize.apply(this, arguments); |
Component.prototype.initialize.apply(this, arguments); |
||||
const components = this.get('components'); |
const components = this.get('components'); |
||||
!components.length && components.add({ type: 'tbody' }); |
!components.length && components.add({ type: 'tbody' }); |
||||
|
} |
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
let result = ''; |
||||
|
|
||||
}, { |
if (el.tagName == 'TABLE') { |
||||
|
result = { type: 'table' }; |
||||
isComponent(el) { |
} |
||||
let result = ''; |
|
||||
|
|
||||
if (el.tagName == 'TABLE') { |
return result; |
||||
result = { type: 'table' }; |
|
||||
} |
} |
||||
|
} |
||||
return result; |
); |
||||
}, |
|
||||
|
|
||||
}); |
|
||||
|
|||||
@ -1,58 +1,58 @@ |
|||||
const Component = require('./Component'); |
const Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
defaults: { ...Component.prototype.defaults, |
defaults: { |
||||
type: 'tbody', |
...Component.prototype.defaults, |
||||
tagName: 'tbody', |
type: 'tbody', |
||||
draggable: ['table'], |
tagName: 'tbody', |
||||
droppable: ['tr'], |
draggable: ['table'], |
||||
columns: 1, |
droppable: ['tr'], |
||||
rows: 1, |
columns: 1, |
||||
}, |
rows: 1 |
||||
|
}, |
||||
initialize(o, opt) { |
|
||||
Component.prototype.initialize.apply(this, arguments); |
initialize(o, opt) { |
||||
const components = this.get('components'); |
Component.prototype.initialize.apply(this, arguments); |
||||
let columns = this.get('columns'); |
const components = this.get('components'); |
||||
let rows = this.get('rows'); |
let columns = this.get('columns'); |
||||
|
let rows = this.get('rows'); |
||||
// Init components if empty
|
|
||||
if (!components.length) { |
// Init components if empty
|
||||
const rowsToAdd = []; |
if (!components.length) { |
||||
|
const rowsToAdd = []; |
||||
while (rows--) { |
|
||||
const columnsToAdd = []; |
while (rows--) { |
||||
let clm = columns; |
const columnsToAdd = []; |
||||
|
let clm = columns; |
||||
while (clm--) { |
|
||||
columnsToAdd.push({ |
while (clm--) { |
||||
type: 'cell', |
columnsToAdd.push({ |
||||
classes: ['cell'] |
type: 'cell', |
||||
|
classes: ['cell'] |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
rowsToAdd.push({ |
||||
|
type: 'row', |
||||
|
classes: ['row'], |
||||
|
components: columnsToAdd |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
rowsToAdd.push({ |
components.add(rowsToAdd); |
||||
type: 'row', |
|
||||
classes: ['row'], |
|
||||
components: columnsToAdd |
|
||||
}); |
|
||||
} |
} |
||||
|
|
||||
components.add(rowsToAdd); |
|
||||
} |
} |
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
let result = ''; |
||||
|
|
||||
},{ |
if (el.tagName == 'TBODY') { |
||||
|
result = { type: 'tbody' }; |
||||
isComponent(el) { |
} |
||||
let result = ''; |
|
||||
|
|
||||
if (el.tagName == 'TBODY') { |
return result; |
||||
result = { type: 'tbody' }; |
|
||||
} |
} |
||||
|
} |
||||
return result; |
); |
||||
}, |
|
||||
|
|
||||
}); |
|
||||
|
|||||
@ -1,26 +1,27 @@ |
|||||
const Component = require('./Component'); |
const Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
defaults: { ...Component.prototype.defaults, |
defaults: { |
||||
|
...Component.prototype.defaults, |
||||
type: 'cell', |
type: 'cell', |
||||
tagName: 'td', |
tagName: 'td', |
||||
draggable: ['tr'], |
draggable: ['tr'] |
||||
|
} |
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
let result = ''; |
||||
|
const tag = el.tagName; |
||||
|
|
||||
}, { |
if (tag == 'TD' || tag == 'TH') { |
||||
isComponent(el) { |
result = { |
||||
let result = ''; |
type: 'cell', |
||||
const tag = el.tagName; |
tagName: tag.toLowerCase() |
||||
|
}; |
||||
|
} |
||||
|
|
||||
if (tag == 'TD' || tag == 'TH') { |
return result; |
||||
result = { |
|
||||
type: 'cell', |
|
||||
tagName: tag.toLowerCase() |
|
||||
}; |
|
||||
} |
} |
||||
|
} |
||||
return result; |
); |
||||
}, |
|
||||
|
|
||||
}); |
|
||||
|
|||||
@ -1,21 +1,22 @@ |
|||||
const ComponentTableBody = require('./ComponentTableBody'); |
const ComponentTableBody = require('./ComponentTableBody'); |
||||
|
|
||||
module.exports = ComponentTableBody.extend({ |
module.exports = ComponentTableBody.extend( |
||||
|
{ |
||||
defaults: { ...ComponentTableBody.prototype.defaults, |
defaults: { |
||||
type: 'tfoot', |
...ComponentTableBody.prototype.defaults, |
||||
tagName: 'tfoot', |
type: 'tfoot', |
||||
|
tagName: 'tfoot' |
||||
|
} |
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
let result = ''; |
||||
|
|
||||
},{ |
if (el.tagName == 'TFOOT') { |
||||
isComponent(el) { |
result = { type: 'tfoot' }; |
||||
let result = ''; |
} |
||||
|
|
||||
if (el.tagName == 'TFOOT') { |
return result; |
||||
result = { type: 'tfoot' }; |
|
||||
} |
} |
||||
|
} |
||||
return result; |
); |
||||
}, |
|
||||
|
|
||||
}); |
|
||||
|
|||||
@ -1,21 +1,22 @@ |
|||||
const ComponentTableBody = require('./ComponentTableBody'); |
const ComponentTableBody = require('./ComponentTableBody'); |
||||
|
|
||||
module.exports = ComponentTableBody.extend({ |
module.exports = ComponentTableBody.extend( |
||||
|
{ |
||||
defaults: { ...ComponentTableBody.prototype.defaults, |
defaults: { |
||||
type: 'thead', |
...ComponentTableBody.prototype.defaults, |
||||
tagName: 'thead' |
type: 'thead', |
||||
|
tagName: 'thead' |
||||
|
} |
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
let result = ''; |
||||
|
|
||||
}, { |
if (el.tagName == 'THEAD') { |
||||
isComponent(el) { |
result = { type: 'thead' }; |
||||
let result = ''; |
} |
||||
|
|
||||
if (el.tagName == 'THEAD') { |
return result; |
||||
result = { type: 'thead' }; |
|
||||
} |
} |
||||
|
} |
||||
return result; |
); |
||||
}, |
|
||||
|
|
||||
}); |
|
||||
|
|||||
@ -1,33 +1,34 @@ |
|||||
const Component = require('./Component'); |
const Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
defaults: { ...Component.prototype.defaults, |
defaults: { |
||||
|
...Component.prototype.defaults, |
||||
type: 'row', |
type: 'row', |
||||
tagName: 'tr', |
tagName: 'tr', |
||||
draggable: ['thead', 'tbody', 'tfoot'], |
draggable: ['thead', 'tbody', 'tfoot'], |
||||
droppable: ['th', 'td'] |
droppable: ['th', 'td'] |
||||
}, |
}, |
||||
|
|
||||
initialize(o, opt) { |
|
||||
Component.prototype.initialize.apply(this, arguments); |
|
||||
|
|
||||
// Clean the row from non cell components
|
|
||||
const cells = []; |
|
||||
const components = this.get('components'); |
|
||||
components.each(model => model.is('cell') && cells.push(model)); |
|
||||
components.reset(cells); |
|
||||
} |
|
||||
|
|
||||
}, { |
initialize(o, opt) { |
||||
isComponent(el) { |
Component.prototype.initialize.apply(this, arguments); |
||||
let result = ''; |
|
||||
|
|
||||
if (el.tagName == 'TR') { |
// Clean the row from non cell components
|
||||
result = { type: 'row' }; |
const cells = []; |
||||
|
const components = this.get('components'); |
||||
|
components.each(model => model.is('cell') && cells.push(model)); |
||||
|
components.reset(cells); |
||||
} |
} |
||||
|
|
||||
return result; |
|
||||
}, |
}, |
||||
|
{ |
||||
|
isComponent(el) { |
||||
|
let result = ''; |
||||
|
|
||||
|
if (el.tagName == 'TR') { |
||||
|
result = { type: 'row' }; |
||||
|
} |
||||
|
|
||||
}); |
return result; |
||||
|
} |
||||
|
} |
||||
|
); |
||||
|
|||||
@ -1,11 +1,10 @@ |
|||||
const Component = require('./Component'); |
const Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend({ |
||||
|
defaults: { |
||||
defaults: { ...Component.prototype.defaults, |
...Component.prototype.defaults, |
||||
type: 'text', |
type: 'text', |
||||
droppable: false, |
droppable: false, |
||||
editable: true, |
editable: true |
||||
}, |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
@ -1,27 +1,26 @@ |
|||||
var Component = require('./Component'); |
var Component = require('./Component'); |
||||
|
|
||||
module.exports = Component.extend({ |
module.exports = Component.extend( |
||||
|
{ |
||||
|
defaults: _.extend({}, Component.prototype.defaults, { |
||||
|
droppable: false, |
||||
|
editable: true |
||||
|
}), |
||||
|
|
||||
defaults: _.extend({}, Component.prototype.defaults, { |
toHTML() { |
||||
droppable: false, |
return this.get('content'); |
||||
editable: true, |
|
||||
}), |
|
||||
|
|
||||
toHTML() { |
|
||||
return this.get('content'); |
|
||||
}, |
|
||||
|
|
||||
}, { |
|
||||
|
|
||||
isComponent(el) { |
|
||||
var result = ''; |
|
||||
if(el.nodeType === 3){ |
|
||||
result = { |
|
||||
type: 'textnode', |
|
||||
content: el.textContent |
|
||||
}; |
|
||||
} |
} |
||||
return result; |
|
||||
}, |
}, |
||||
|
{ |
||||
}); |
isComponent(el) { |
||||
|
var result = ''; |
||||
|
if (el.nodeType === 3) { |
||||
|
result = { |
||||
|
type: 'textnode', |
||||
|
content: el.textContent |
||||
|
}; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
); |
||||
|
|||||
@ -1,4 +1,4 @@ |
|||||
var Backbone = require('backbone'); |
var Backbone = require('backbone'); |
||||
var ToolbarButton = require('./ToolbarButton'); |
var ToolbarButton = require('./ToolbarButton'); |
||||
|
|
||||
module.exports = Backbone.Collection.extend({model: ToolbarButton}); |
module.exports = Backbone.Collection.extend({ model: ToolbarButton }); |
||||
|
|||||
@ -1,10 +1,8 @@ |
|||||
var Backbone = require('backbone'); |
var Backbone = require('backbone'); |
||||
|
|
||||
module.exports = Backbone.Model.extend({ |
module.exports = Backbone.Model.extend({ |
||||
|
|
||||
defaults: { |
defaults: { |
||||
command: '', |
command: '', |
||||
attributes: {}, |
attributes: {} |
||||
}, |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
@ -1,9 +1,7 @@ |
|||||
const ComponentView = require('./ComponentView'); |
const ComponentView = require('./ComponentView'); |
||||
|
|
||||
module.exports = ComponentView.extend({ |
module.exports = ComponentView.extend({ |
||||
|
|
||||
_createElement: function(tagName) { |
_createElement: function(tagName) { |
||||
return document.createElementNS('http://www.w3.org/2000/svg', tagName); |
return document.createElementNS('http://www.w3.org/2000/svg', tagName); |
||||
} |
} |
||||
|
|
||||
}); |
}); |
||||
|
|||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue