mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 23:42:11 +02:00
Revert "MDL-44758 editor-atto: prevent table-in-table creation"
This reverts commit 3a6511a530015813f7bfda5547f8fc9de750efcf. Conflicts: lib/editor/atto/plugins/table/yui/build/moodle-atto_table-button/moodle-atto_table-button-debug.js lib/editor/atto/plugins/table/yui/build/moodle-atto_table-button/moodle-atto_table-button-min.js lib/editor/atto/plugins/table/yui/build/moodle-atto_table-button/moodle-atto_table-button.js lib/editor/atto/plugins/table/yui/src/button/js/button.js
This commit is contained in:
parent
ad5a8cd6a2
commit
7b28067413
@ -179,25 +179,28 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
* @private
|
||||
*/
|
||||
_displayTableEditor: function(e) {
|
||||
var cell = this._getSuitableTableCell();
|
||||
var selection = this.get('host').getSelectionParentNode(),
|
||||
cell;
|
||||
|
||||
if (!selection) {
|
||||
// We don't have a current selection at all, so show the standard dialogue.
|
||||
return this._displayDialogue(e);
|
||||
}
|
||||
|
||||
// Check all of the table cells found in the selection.
|
||||
Y.one(selection).ancestors('th, td', true).each(function(node) {
|
||||
if (this.editor.contains(node)) {
|
||||
cell = node;
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (cell) {
|
||||
// Add the cell to the EventFacade to save duplication in when showing the menu.
|
||||
e.tableCell = cell;
|
||||
return this._showTableMenu(e);
|
||||
}
|
||||
return this._displayDialogue(e);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns whether or not the parameter node exists within the editor.
|
||||
*
|
||||
* @method _stopAtContentEditableFilter
|
||||
* @param {Node} node
|
||||
* @private
|
||||
* @return {boolean} whether or not the parameter node exists within the editor.
|
||||
*/
|
||||
_stopAtContentEditableFilter: function(node) {
|
||||
this.editor.contains(node);
|
||||
return this._displayDialogue(e);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -244,44 +247,6 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
return this._content;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given the current selection, return a table cell suitable for table editing
|
||||
* purposes, i.e. the first table cell selected, or the first cell in the table
|
||||
* that the selection exists in, or null if not within a table.
|
||||
*
|
||||
* @method _getSuitableTableCell
|
||||
* @private
|
||||
* @return {Node} suitable target cell, or null if not within a table
|
||||
*/
|
||||
_getSuitableTableCell: function() {
|
||||
var targetcell = null,
|
||||
host = this.get('host');
|
||||
|
||||
host.getSelectedNodes().some(function (node) {
|
||||
if (node.ancestor('td, th, caption', true, this._stopAtContentEditableFilter)) {
|
||||
targetcell = node;
|
||||
|
||||
var caption = node.ancestor('caption', true, this._stopAtContentEditableFilter);
|
||||
if (caption) {
|
||||
var table = caption.get('parentNode');
|
||||
if (table) {
|
||||
targetcell = table.one('td, th');
|
||||
}
|
||||
}
|
||||
|
||||
// Once we've found a cell to target, we shouldn't need to keep looking.
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (targetcell) {
|
||||
var selection = host.getSelectionFromNode(targetcell);
|
||||
host.setSelection(selection);
|
||||
}
|
||||
|
||||
return targetcell;
|
||||
},
|
||||
|
||||
/**
|
||||
* Change a node from one type to another, copying all attributes and children.
|
||||
*
|
||||
|
File diff suppressed because one or more lines are too long
@ -179,25 +179,28 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
* @private
|
||||
*/
|
||||
_displayTableEditor: function(e) {
|
||||
var cell = this._getSuitableTableCell();
|
||||
var selection = this.get('host').getSelectionParentNode(),
|
||||
cell;
|
||||
|
||||
if (!selection) {
|
||||
// We don't have a current selection at all, so show the standard dialogue.
|
||||
return this._displayDialogue(e);
|
||||
}
|
||||
|
||||
// Check all of the table cells found in the selection.
|
||||
Y.one(selection).ancestors('th, td', true).each(function(node) {
|
||||
if (this.editor.contains(node)) {
|
||||
cell = node;
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (cell) {
|
||||
// Add the cell to the EventFacade to save duplication in when showing the menu.
|
||||
e.tableCell = cell;
|
||||
return this._showTableMenu(e);
|
||||
}
|
||||
return this._displayDialogue(e);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns whether or not the parameter node exists within the editor.
|
||||
*
|
||||
* @method _stopAtContentEditableFilter
|
||||
* @param {Node} node
|
||||
* @private
|
||||
* @return {boolean} whether or not the parameter node exists within the editor.
|
||||
*/
|
||||
_stopAtContentEditableFilter: function(node) {
|
||||
this.editor.contains(node);
|
||||
return this._displayDialogue(e);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -244,44 +247,6 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
return this._content;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given the current selection, return a table cell suitable for table editing
|
||||
* purposes, i.e. the first table cell selected, or the first cell in the table
|
||||
* that the selection exists in, or null if not within a table.
|
||||
*
|
||||
* @method _getSuitableTableCell
|
||||
* @private
|
||||
* @return {Node} suitable target cell, or null if not within a table
|
||||
*/
|
||||
_getSuitableTableCell: function() {
|
||||
var targetcell = null,
|
||||
host = this.get('host');
|
||||
|
||||
host.getSelectedNodes().some(function (node) {
|
||||
if (node.ancestor('td, th, caption', true, this._stopAtContentEditableFilter)) {
|
||||
targetcell = node;
|
||||
|
||||
var caption = node.ancestor('caption', true, this._stopAtContentEditableFilter);
|
||||
if (caption) {
|
||||
var table = caption.get('parentNode');
|
||||
if (table) {
|
||||
targetcell = table.one('td, th');
|
||||
}
|
||||
}
|
||||
|
||||
// Once we've found a cell to target, we shouldn't need to keep looking.
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (targetcell) {
|
||||
var selection = host.getSelectionFromNode(targetcell);
|
||||
host.setSelection(selection);
|
||||
}
|
||||
|
||||
return targetcell;
|
||||
},
|
||||
|
||||
/**
|
||||
* Change a node from one type to another, copying all attributes and children.
|
||||
*
|
||||
|
@ -177,25 +177,28 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
* @private
|
||||
*/
|
||||
_displayTableEditor: function(e) {
|
||||
var cell = this._getSuitableTableCell();
|
||||
var selection = this.get('host').getSelectionParentNode(),
|
||||
cell;
|
||||
|
||||
if (!selection) {
|
||||
// We don't have a current selection at all, so show the standard dialogue.
|
||||
return this._displayDialogue(e);
|
||||
}
|
||||
|
||||
// Check all of the table cells found in the selection.
|
||||
Y.one(selection).ancestors('th, td', true).each(function(node) {
|
||||
if (this.editor.contains(node)) {
|
||||
cell = node;
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (cell) {
|
||||
// Add the cell to the EventFacade to save duplication in when showing the menu.
|
||||
e.tableCell = cell;
|
||||
return this._showTableMenu(e);
|
||||
}
|
||||
return this._displayDialogue(e);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns whether or not the parameter node exists within the editor.
|
||||
*
|
||||
* @method _stopAtContentEditableFilter
|
||||
* @param {Node} node
|
||||
* @private
|
||||
* @return {boolean} whether or not the parameter node exists within the editor.
|
||||
*/
|
||||
_stopAtContentEditableFilter: function(node) {
|
||||
this.editor.contains(node);
|
||||
return this._displayDialogue(e);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -242,44 +245,6 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
return this._content;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given the current selection, return a table cell suitable for table editing
|
||||
* purposes, i.e. the first table cell selected, or the first cell in the table
|
||||
* that the selection exists in, or null if not within a table.
|
||||
*
|
||||
* @method _getSuitableTableCell
|
||||
* @private
|
||||
* @return {Node} suitable target cell, or null if not within a table
|
||||
*/
|
||||
_getSuitableTableCell: function() {
|
||||
var targetcell = null,
|
||||
host = this.get('host');
|
||||
|
||||
host.getSelectedNodes().some(function (node) {
|
||||
if (node.ancestor('td, th, caption', true, this._stopAtContentEditableFilter)) {
|
||||
targetcell = node;
|
||||
|
||||
var caption = node.ancestor('caption', true, this._stopAtContentEditableFilter);
|
||||
if (caption) {
|
||||
var table = caption.get('parentNode');
|
||||
if (table) {
|
||||
targetcell = table.one('td, th');
|
||||
}
|
||||
}
|
||||
|
||||
// Once we've found a cell to target, we shouldn't need to keep looking.
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (targetcell) {
|
||||
var selection = host.getSelectionFromNode(targetcell);
|
||||
host.setSelection(selection);
|
||||
}
|
||||
|
||||
return targetcell;
|
||||
},
|
||||
|
||||
/**
|
||||
* Change a node from one type to another, copying all attributes and children.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user