X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-debug.js;h=27f607683cfc9137cb51c7d1ab1977af84eeedc3;hb=b999dac6d220ed742af894af4750d19d0e6dc586;hp=0a3060132a4bb6b68d442b456d067ff8bee6c6ca;hpb=6261309d679b59dc45afc117511f6e80c12eff80;p=roojs1 diff --git a/roojs-debug.js b/roojs-debug.js index 0a3060132a..27f607683c 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -5208,7 +5208,167 @@ undoManager.transact({ }; -/* +/** + * @class Roo.lib.Range + * @constructor + * This is a toolkit, normally used to copy features into a Dom Range element + * Roo.lib.Range.wrap(x); + * + * + * + */ +Roo.lib.Range = function() { }; + +/** + * Wrap a Dom Range object, to give it new features... + * @static + * @param {Range} the range to wrap + */ +Roo.lib.Range.wrap = function(r) { + return Roo.apply(r, Roo.lib.Range.prototype); +}; +/** + * find a parent node eg. LI / OL + * @param {string|Array} node name or array of nodenames + * @return {DomElement|false} + */ +Roo.apply(Roo.lib.Range.prototype, +{ + + closest : function(str) + { + if (typeof(str) != 'string') { + // assume it's a array. + for(var i = 0;i < str.length;i++) { + var r = this.closest(str[i]); + if (r !== false) { + return r; + } + + } + return false; + } + str = str.toLowerCase(); + var n = this.commonAncestorContainer; // might not be a node + while (n.nodeType != 1) { + n = n.parentNode; + } + + if (n.nodeName.toLowerCase() == str ) { + return n; + } + if (n.nodeName.toLowerCase() == 'body') { + return false; + } + + return n.closest(str) || false; + + }, + cloneRange : function() + { + return Roo.lib.Range.wrap(Range.prototype.cloneRange.call(this)); + } +});/** + * @class Roo.lib.Selection + * @constructor + * This is a toolkit, normally used to copy features into a Dom Selection element + * Roo.lib.Selection.wrap(x); + * + * + * + */ +Roo.lib.Selection = function() { }; + +/** + * Wrap a Dom Range object, to give it new features... + * @static + * @param {Range} the range to wrap + */ +Roo.lib.Selection.wrap = function(r, doc) { + Roo.apply(r, Roo.lib.Selection.prototype); + r.ownerDocument = doc; // usefull so we dont have to keep referening to it. + return r; +}; +/** + * find a parent node eg. LI / OL + * @param {string|Array} node name or array of nodenames + * @return {DomElement|false} + */ +Roo.apply(Roo.lib.Selection.prototype, +{ + /** + * the owner document + */ + ownerDocument : false, + + getRangeAt : function(n) + { + return Roo.lib.Range.wrap(Selection.prototype.getRangeAt.call(this,n)); + }, + + /** + * insert node at selection + * @param {DomElement|string} node + * @param {string} cursor (after|in|none) where to place the cursor after inserting. + */ + insertNode: function(node, cursor) + { + if (typeof(node) == 'string') { + node = this.ownerDocument.createElement(node); + if (cursor == 'in') { + node.innerHTML = ' '; + } + } + + var range = this.getRangeAt(0); + + if (this.type != 'Caret') { + range.deleteContents(); + } + var sn = node.childNodes[0]; // select the contents. + + + + range.insertNode(node); + if (cursor == 'after') { + node.insertAdjacentHTML('afterend', ' '); + sn = node.nextSibling; + } + + if (cursor == 'none') { + return; + } + + this.cursorText(sn); + }, + + cursorText : function(n) + { + + //var range = this.getRangeAt(0); + range = Roo.lib.Range.wrap(new Range()); + //range.selectNode(n); + + var ix = Array.from(n.parentNode.childNodes).indexOf(n); + range.setStart(n.parentNode,ix); + range.setEnd(n.parentNode,ix+1); + //range.collapse(false); + + this.removeAllRanges(); + this.addRange(range); + + Roo.log([n, range, this,this.baseOffset,this.extentOffset, this.type]); + }, + cursorAfter : function(n) + { + if (!n.nextSibling || n.nextSibling.nodeValue != ' ') { + n.insertAdjacentHTML('afterend', ' '); + } + this.cursorText (n.nextSibling); + } + + +});/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -5476,10 +5636,15 @@ Roo.DomHelper = function(){ from.data = to.data; return; } - + if (!from.parentNode) { + // not sure why this is happening? + return; + } // assume 'to' doesnt have '1/3 nodetypes! + // not sure why, by from, parent node might not exist? if (from.nodeType !=1 || from.tagName != to.tagName) { Roo.log(["ReplaceChild" , from, to ]); + from.parentNode.replaceChild(to, from); return; } @@ -34606,6 +34771,7 @@ Roo.extend(Roo.LayoutDialog, Roo.BasicDialog, { /** * @class Roo.MessageBox + * @static * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used. * Example usage: *
@@ -39824,7 +39990,7 @@ Roo.extend(Roo.menu.Item, Roo.menu.BaseItem, {
*/
text: '',
/**
- * @cfg {String} HTML to render in menu
+ * @cfg {String} html to render in menu
* The text to show on the menu item (HTML version).
*/
html: '',
@@ -46023,7 +46189,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
var cn = Array.from(node.childNodes);
var nn = node;
Roo.each(inject, function(t) {
- var nc = node.ownerDocument.createelement(t);
+ var nc = node.ownerDocument.createElement(t);
nn.appendChild(nc);
nn = nc;
});
@@ -46295,6 +46461,8 @@ Roo.htmleditor.Tidy.prototype = {
+
+
Roo.htmleditor.KeyEnter = function(cfg) {
Roo.apply(this, cfg);
// this does not actually call walk as it's really just a abstract class
@@ -46311,89 +46479,58 @@ Roo.htmleditor.KeyEnter.prototype = {
keypress : function(e)
{
- if (e.charCode != 13) {
+ if (e.charCode != 13 && e.charCode != 10) {
+ Roo.log([e.charCode,e]);
return true;
}
e.preventDefault();
// https://stackoverflow.com/questions/18552336/prevent-contenteditable-adding-div-on-enter-chrome
var doc = this.core.doc;
-
- var docFragment = doc.createDocumentFragment();
-
- //add a new line
+ //add a new line
-
- var range = this.core.win.getSelection().getRangeAt(0);
- var n = range.commonAncestorContainer ;
- while (n && n.nodeType != 1) {
- n = n.parentNode;
- }
- var li = false;
- if (n && n.tagName == 'UL') {
- li = doc.createElement('LI');
- n.appendChild(li);
-
- }
- if (n && n.tagName == 'LI') {
- li = doc.createElement('LI');
- if (n.nextSibling) {
- n.parentNode.insertBefore(li, n.firstSibling);
-
- } else {
- n.parentNode.appendChild(li);
- }
- }
- if (li) {
- range = doc.createRange();
- range.setStartAfter(li);
- range.collapse(true);
-
- //make the cursor there
- var sel = this.core.win.getSelection();
- sel.removeAllRanges();
- sel.addRange(range);
+ var sel = this.core.getSelection();
+ var range = sel.getRangeAt(0);
+ var n = range.commonAncestorContainer;
+ var pc = range.closest([ 'ol', 'ul']);
+ var pli = range.closest('li');
+ if (!pc || e.ctrlKey) {
+ sel.insertNode('br', 'after');
+
this.core.undoManager.addEvent();
+ this.core.fireEditorEvent(e);
return false;
-
-
}
- var newEle = doc.createTextNode('\n');
- docFragment.appendChild(newEle);
-
- //add the br, or p, or something else
- newEle = doc.createElement('br');
- //newEle.setAttribute('data-id', Roo.htmleditor.KeyEnter.i++);
- docFragment.appendChild(newEle);
- doc.createTextNode('\n');
- docFragment.appendChild(newEle);
- range.deleteContents();
- range.insertNode(docFragment); //<< inseting here...
-
- var ns = newEle.nextSibling;
- while (ns && ns.nodeType == 3) {
- ns = ns.nextSibling;
+ // deal with insetion
+ if (pli.innerText.trim() == '' &&
+ pli.previousSibling &&
+ pli.previousSibling.nodeName == 'LI' &&
+ pli.previousSibling.innerText.trim() == '') {
+ pli.parentNode.removeChild(pli.previousSibling);
+ sel.cursorAfter(pc);
+ this.core.undoManager.addEvent();
+ this.core.fireEditorEvent(e);
+ return false;
}
-
- if (!ns) {
- //Roo.log('add extra');
- ns = doc.createElement('br');
- //ns.setAttribute('data-id', 'x' + Roo.htmleditor.KeyEnter.i++);
- newEle.parentNode.appendChild(ns);
+
+ var li = doc.createElement('LI');
+ li.innerHTML = ' ';
+ if (!pli || !pli.firstSibling) {
+ pc.appendChild(li);
+ } else {
+ pli.parentNode.insertBefore(li, pli.firstSibling);
}
+ sel.cursorText (li.firstChild);
+
+ this.core.undoManager.addEvent();
+ this.core.fireEditorEvent(e);
+
+ return false;
+
- range = doc.createRange();
- range.setStartAfter(newEle);
- range.collapse(true);
-
- var sel = this.core.win.getSelection();
- sel.removeAllRanges();
- sel.addRange(range);
- //this.core.undoManager.addEvent();
- return false;
}
};
@@ -46424,7 +46561,7 @@ Roo.htmleditor.Block.factory = function(node)
var cc = Roo.htmleditor.Block.cache;
var id = Roo.get(node).id;
if (typeof(cc[id]) != 'undefined' && (!cc[id].node || cc[id].node.closest('body'))) {
- Roo.htmleditor.Block.cache[id].readElement();
+ Roo.htmleditor.Block.cache[id].readElement(node);
return Roo.htmleditor.Block.cache[id];
}
var db = node.getAttribute('data-block');
@@ -46506,14 +46643,17 @@ Roo.htmleditor.Block.prototype = {
// but kiss for now.
n = node.getElementsByTagName(tag).item(0);
}
+ if (!n) {
+ return '';
+ }
if (attr == 'html') {
return n.innerHTML;
}
if (attr == 'style') {
- return n.style[style]
+ return n.style[style];
}
- return Roo.get(n).attr(attr);
+ return n.hasAttribute(attr) ? n.getAttribute(attr) : '';
},
/**
@@ -46544,8 +46684,8 @@ Roo.htmleditor.Block.prototype = {
* Block that has an image and a figcaption
* @cfg {String} image_src the url for the image
* @cfg {String} align (left|right) alignment for the block default left
- * @cfg {String} text_align (left|right) alignment for the text caption default left.
* @cfg {String} caption the text to appear below (and in the alt tag)
+ * @cfg {String} caption_display (block|none) display or not the caption
* @cfg {String|number} image_width the width of the image number or %?
* @cfg {String|number} image_height the height of the image number or %?
*
@@ -46567,46 +46707,167 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, {
// setable values.
image_src: '',
-
- align: 'left',
+ align: 'center',
caption : '',
- text_align: 'left',
+ caption_display : 'block',
+ width : '100%',
+ cls : '',
+ href: '',
+ video_url : '',
- width : '46%',
- margin: '2%',
+ // margin: '2%', not used
+
+ text_align: 'left', // (left|right) alignment for the text caption default left. - not used at present
+
// used by context menu
friendly_name : 'Image with caption',
deleteTitle : "Delete Image and Caption",
- context : { // ?? static really
- width : {
- title: "Width",
- width: 40
- // ?? number
- },
- margin : {
- title: "Margin",
- width: 40
- // ?? number
- },
- align: {
- title: "Align",
- opts : [[ "left"],[ "right"]],
- width : 80
+ contextMenu : function(toolbar)
+ {
+
+ var block = function() {
+ return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
+ };
+
+
+ var rooui = typeof(Roo.bootstrap) == 'undefined' ? Roo : Roo.bootstrap;
+
+ var syncValue = toolbar.editorcore.syncValue;
+
+ var fields = {};
+
+ return [
+ {
+ xtype : 'TextItem',
+ text : "Source: ",
+ xns : rooui.Toolbar //Boostrap?
+ },
+ {
+ xtype : 'TextField',
+ allowBlank : false,
+ width : 150,
+ name : 'image_src',
+ listeners : {
+ keyup : function (combo, e)
+ {
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
+ var b = block();
+ b.image_src = this.getValue();
+ b.updateElement();
+ syncValue();
+ toolbar.editorcore.onEditorEvent();
+ }
+ },
+ xns : rooui.form
+
+ },
+ {
+ xtype : 'TextItem',
+ text : "Width: ",
+ xns : rooui.Toolbar //Boostrap?
+ },
+ {
+ xtype : 'ComboBox',
+ allowBlank : false,
+ displayField : 'val',
+ editable : true,
+ listWidth : 100,
+ triggerAction : 'all',
+ typeAhead : true,
+ valueField : 'val',
+ width : 70,
+ name : 'width',
+ listeners : {
+ select : function (combo, r, index)
+ {
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
+ var b = block();
+ b.width = r.get('val');
+ b.updateElement();
+ syncValue();
+ toolbar.editorcore.onEditorEvent();
+ }
+ },
+ xns : rooui.form,
+ store : {
+ xtype : 'SimpleStore',
+ data : [
+ ['auto'],
+ ['50%'],
+ ['100%']
+ ],
+ fields : [ 'val'],
+ xns : Roo.data
+ }
+ },
+ {
+ xtype : 'TextItem',
+ text : "Align: ",
+ xns : rooui.Toolbar //Boostrap?
+ },
+ {
+ xtype : 'ComboBox',
+ allowBlank : false,
+ displayField : 'val',
+ editable : true,
+ listWidth : 100,
+ triggerAction : 'all',
+ typeAhead : true,
+ valueField : 'val',
+ width : 70,
+ name : 'align',
+ listeners : {
+ select : function (combo, r, index)
+ {
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
+ var b = block();
+ b.align = r.get('val');
+ b.updateElement();
+ syncValue();
+ toolbar.editorcore.onEditorEvent();
+ }
+ },
+ xns : rooui.form,
+ store : {
+ xtype : 'SimpleStore',
+ data : [
+ ['left'],
+ ['right'],
+ ['center']
+ ],
+ fields : [ 'val'],
+ xns : Roo.data
+ }
+ },
- },
- text_align: {
- title: "Caption Align",
- opts : [ [ "left"],[ "right"],[ "center"]],
- width : 80
- },
+
+ {
+ xtype : 'Button',
+ text: 'Hide Caption',
+ name : 'caption_display',
+ pressed : false,
+ enableToggle : true,
+ setValue : function(v) {
+ this.toggle(v == 'block' ? false : true);
+ },
+ listeners : {
+ toggle: function (btn, state)
+ {
+ var b = block();
+ b.caption_display = b.caption_display == 'block' ? 'none' : 'block';
+ this.setText(b.caption_display == 'block' ? "Hide Caption" : "Show Caption");
+ b.updateElement();
+ syncValue();
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
+ toolbar.editorcore.onEditorEvent();
+ }
+ },
+ xns : rooui.Toolbar
+ }
+ ];
-
- image_src : {
- title: "Src",
- width: 220
- }
},
/**
* create a DomHelper friendly object - for use with
@@ -46617,48 +46878,115 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, {
var d = document.createElement('div');
d.innerHTML = this.caption;
- return {
+ var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0;
+
+ var img = {
+ tag : 'img',
+ contenteditable : 'false',
+ src : this.image_src,
+ alt : d.innerText.replace(/\n/g, " "), // removeHTML..
+ style: {
+ width : 'auto',
+ 'max-width': '100%',
+ margin : '0px'
+
+
+ }
+ };
+ /*
+ '' +
+ '' +
+ '' +
+ '' +
+ '',
+ */
+
+ if (this.href.length > 0) {
+ img = {
+ tag : 'a',
+ href: this.href,
+ contenteditable : 'true',
+ cn : [
+ img
+ ]
+ };
+ }
+
+
+ if (this.video_url.length > 0) {
+ img = {
+ tag : 'div',
+ cls : this.cls,
+ frameborder : 0,
+ allowfullscreen : true,
+ width : 420, // these are for video tricks - that we replace the outer
+ height : 315,
+ src : this.video_url,
+ cn : [
+ img
+ ]
+ };
+ }
+
+ return {
tag: 'figure',
'data-block' : 'Figure',
contenteditable : 'false',
style : {
- display: 'table',
+ display: 'block',
float : this.align ,
- width : this.width,
- margin: this.margin
+ 'max-width': this.width,
+ width : 'auto',
+ margin: m,
+ padding: '10px'
+
},
+
+
+ align : this.align,
cn : [
- {
- tag : 'img',
- src : this.image_src,
- alt : d.innerText.replace(/\n/g, " "), // removeHTML..
- style: {
- width: '100%'
- }
- },
+ img,
+
{
tag: 'figcaption',
contenteditable : true,
style : {
- 'text-align': this.text_align
+ 'text-align': 'left',
+ 'margin-top' : '16px',
+ 'font-size' : '16px',
+ 'line-height' : '24px',
+ 'font-style': 'italic',
+ display : this.caption_display
},
+ cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '',
html : this.caption
}
]
};
+
},
readElement : function(node)
{
+ // this should not really come from the link...
+ this.video_url = this.getVal(node, 'div', 'src');
+ this.cls = this.getVal(node, 'div', 'class');
+ this.href = this.getVal(node, 'a', 'href');
+
this.image_src = this.getVal(node, 'img', 'src');
- this.align = this.getVal(node, 'figure', 'style', 'float');
+
+ this.align = this.getVal(node, 'figure', 'align');
this.caption = this.getVal(node, 'figcaption', 'html');
- this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
- this.width = this.getVal(node, 'figure', 'style', 'width');
- this.margin = this.getVal(node, 'figure', 'style', 'margin');
+ //this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
+ this.width = this.getVal(node, 'figure', 'style', 'max-width');
+ //this.margin = this.getVal(node, 'figure', 'style', 'margin');
- }
+ },
+ removeNode : function()
+ {
+ return this.node;
+ }
@@ -46728,6 +47056,11 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
var fields = {};
return [
+ {
+ xtype : 'TextItem',
+ text : "Width: ",
+ xns : rooui.Toolbar //Boostrap?
+ },
{
xtype : 'ComboBox',
allowBlank : false,
@@ -46742,11 +47075,12 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
listeners : {
select : function (combo, r, index)
{
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
var b = block();
b.width = r.get('val');
b.updateElement();
syncValue();
-
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.form,
@@ -46774,8 +47108,10 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
block().removeColumn();
syncValue();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -46786,8 +47122,10 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
block().addColumn();
syncValue();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -46805,8 +47143,10 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
block().removeRow();
syncValue();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -46819,6 +47159,7 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
{
block().addRow();
syncValue();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -46833,6 +47174,7 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
{
block().resetWidths();
syncValue();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -46928,22 +47270,18 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
this.rows = [];
this.no_row = 0;
- var trs = Array.from(node.getElementsByTagName('tr'));
+ var trs = Array.from(node.rows);
trs.forEach(function(tr) {
var row = [];
this.rows.push(row);
- if (Roo.get(tr).hasClass('roo-html-editor-el')) { // ??? this is for our 'row' selection'
- return;
- }
+
this.no_row++;
var no_column = 0;
- Array.from(tr.getElementsByTagName('td')).forEach(function(td) {
- if (Roo.get(td).hasClass('roo-html-editor-el')) { // ??? this is for our 'row' selection'
- return;
- }
+ Array.from(tr.cells).forEach(function(td) {
+
var add = {
- colspan : td.hasAttribute('colspan') ? td.getAttribute('colspan') : 1,
- rowspan : td.hasAttribute('rowspan') ? td.getAttribute('rowspan') : 1,
+ colspan : td.hasAttribute('colspan') ? td.getAttribute('colspan')*1 : 1,
+ rowspan : td.hasAttribute('rowspan') ? td.getAttribute('rowspan')*1 : 1,
style : td.hasAttribute('style') ? td.getAttribute('style') : '',
html : td.innerHTML
};
@@ -47109,7 +47447,7 @@ Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
addRow : function()
{
- row = [];
+ var row = [];
for (var i = 0; i < this.no_col; i++ ) {
row.push(this.emptyCell());
@@ -47193,6 +47531,7 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
width: '',
textAlign : 'left',
+ valign : 'top',
colspan : 1,
rowspan : 1,
@@ -47200,7 +47539,7 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
// used by context menu
friendly_name : 'Table Cell',
- deleteTitle : 'Delete Table',
+ deleteTitle : false, // use our customer delete
// context menu is drawn once..
@@ -47269,10 +47608,10 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
- saveSel();
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
cell().shrinkColumn();
syncValue();
- restoreSel();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -47283,14 +47622,55 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
- saveSel();
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
cell().growColumn();
syncValue();
- restoreSel();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
},
+
+ {
+ xtype : 'TextItem',
+ text : "Vertical Align: ",
+ xns : rooui.Toolbar //Boostrap?
+ },
+ {
+ xtype : 'ComboBox',
+ allowBlank : false,
+ displayField : 'val',
+ editable : true,
+ listWidth : 100,
+ triggerAction : 'all',
+ typeAhead : true,
+ valueField : 'val',
+ width : 100,
+ name : 'valign',
+ listeners : {
+ select : function (combo, r, index)
+ {
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
+ var b = cell();
+ b.valign = r.get('val');
+ b.updateElement();
+ syncValue();
+ toolbar.editorcore.onEditorEvent();
+ }
+ },
+ xns : rooui.form,
+ store : {
+ xtype : 'SimpleStore',
+ data : [
+ ['top'],
+ ['middle'],
+ ['bottom'] // there are afew more...
+ ],
+ fields : [ 'val'],
+ xns : Roo.data
+ }
+ },
+
{
xtype : 'TextItem',
text : "Merge Cells: ",
@@ -47305,11 +47685,11 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
- saveSel();
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
cell().mergeRight();
//block().growColumn();
syncValue();
- restoreSel();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -47321,11 +47701,11 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
- saveSel();
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
cell().mergeBelow();
//block().growColumn();
syncValue();
- restoreSel();
+ toolbar.editorcore.onEditorEvent();
}
},
xns : rooui.Toolbar
@@ -47343,14 +47723,91 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
listeners : {
click : function (_self, e)
{
- saveSel();
+ //toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
cell().split();
syncValue();
- restoreSel();
+ toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
+ toolbar.editorcore.onEditorEvent();
+
}
},
xns : rooui.Toolbar
+ },
+ {
+ xtype : 'Fill',
+ xns : rooui.Toolbar
+
+ },
+
+
+ {
+ xtype : 'Button',
+ text: 'Delete',
+
+ xns : rooui.Toolbar,
+ menu : {
+ xtype : 'Menu',
+ xns : rooui.menu,
+ items : [
+ {
+ xtype : 'Item',
+ html: 'Column',
+ listeners : {
+ click : function (_self, e)
+ {
+ var t = table();
+
+ cell().deleteColumn();
+ syncValue();
+ toolbar.editorcore.selectNode(t.node);
+ toolbar.editorcore.onEditorEvent();
+ }
+ },
+ xns : rooui.menu
+ },
+ {
+ xtype : 'Item',
+ html: 'Row',
+ listeners : {
+ click : function (_self, e)
+ {
+ var t = table();
+ cell().deleteRow();
+ syncValue();
+
+ toolbar.editorcore.selectNode(t.node);
+ toolbar.editorcore.onEditorEvent();
+
+ }
+ },
+ xns : rooui.menu
+ },
+ {
+ xtype : 'Separator',
+ xns : rooui.menu
+ },
+ {
+ xtype : 'Item',
+ html: 'Table',
+ listeners : {
+ click : function (_self, e)
+ {
+ var t = table();
+ var nn = t.node.nextSibling || t.node.previousSibling;
+ t.node.parentNode.removeChild(t.node);
+ if (nn) {
+ toolbar.editorcore.selectNode(nn, true);
+ }
+ toolbar.editorcore.onEditorEvent();
+
+ }
+ },
+ xns : rooui.menu
+ }
+ ]
+ }
}
+
// align... << fixme
];
@@ -47375,21 +47832,27 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
tag : 'td',
contenteditable : 'true', // this stops cell selection from picking the table.
'data-block' : 'Td',
- width: this.width,
+ valign : this.valign,
style : {
- width: this.width,
'text-align' : this.textAlign,
border : 'solid 1px rgb(0, 0, 0)', // ??? hard coded?
- 'border-collapse' : 'collapse'
+ 'border-collapse' : 'collapse',
+ padding : '6px', // 8 for desktop / 4 for mobile
+ 'vertical-align': this.valign
},
html : this.html
};
+ if (this.width != '') {
+ ret.width = this.width;
+ ret.style.width = this.width;
+ }
+
if (this.colspan > 1) {
- ret.colspan = cell.colspan ;
+ ret.colspan = this.colspan ;
}
- if (ret.rowspan > 1) {
- this.rowspan = cell.rowspan ;
+ if (this.rowspan > 1) {
+ ret.rowspan = this.rowspan ;
}
@@ -47402,7 +47865,8 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
{
node = node ? node : this.node ;
this.width = node.style.width;
-
+ this.colspan = Math.max(1,1*node.getAttribute('colspan'));
+ this.rowspan = Math.max(1,1*node.getAttribute('rowspan'));
this.html = node.innerHTML;
@@ -47422,8 +47886,7 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
removeNode : function()
{
return this.node.closest('table');
-
-
+
},
cellData : false,
@@ -47596,13 +48059,19 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
var tab = this.node.closest('tr').closest('table');
+ var ctr = tab.rows[0].parentNode;
Array.from(tab.rows).forEach(function(r, ri){
+
Array.from(r.cells).forEach(function(ce, ci){
ce.parentNode.removeChild(ce);
});
+ r.parentNode.removeChild(r);
});
for(var r = 0 ; r < table.length; r++) {
var re = tab.rows[r];
+
+ var re = tab.ownerDocument.createElement('tr');
+ ctr.appendChild(re);
for(var c = 0 ; c < table[r].length; c++) {
if (table[r][c].cell === false) {
continue;
@@ -47718,9 +48187,52 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
}, this);
this.updateWidths(table);
+ },
+ deleteRow : function()
+ {
+ // delete this rows 'tr'
+ // if any of the cells in this row have a rowspan > 1 && row!= this row..
+ // then reduce the rowspan.
+ var table = this.toTableArray();
+ // this.cellData.row;
+ for (var i =0;i< table[this.cellData.row].length ; i++) {
+ var c = table[this.cellData.row][i];
+ if (c.row != this.cellData.row) {
+
+ c.rowspan--;
+ c.cell.setAttribute('rowspan', c.rowspan);
+ continue;
+ }
+ if (c.rowspan > 1) {
+ c.rowspan--;
+ c.cell.setAttribute('rowspan', c.rowspan);
+ }
+ }
+ table.splice(this.cellData.row,1);
+ this.redrawAllCells(table);
+
+ },
+ deleteColumn : function()
+ {
+ var table = this.toTableArray();
+
+ for (var i =0;i< table.length ; i++) {
+ var c = table[i][this.cellData.col];
+ if (c.col != this.cellData.col) {
+ table[i][this.cellData.col].colspan--;
+ } else if (c.colspan > 1) {
+ c.colspan--;
+ c.cell.setAttribute('colspan', c.colspan);
+ }
+ table[i].splice(this.cellData.col,1);
+ }
+
+ this.redrawAllCells(table);
}
+
+
})
//