Skip to content

Commit

Permalink
add: #235 core-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Mar 6, 2020
1 parent b09f19a commit 15bb3af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions sample/html/out/document-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ <h4 class="name" id="util"><span class="type-signature"></span>util<span
<dl class="details"></dl>


<h4 class="name" id="util"><span class="type-signature"></span>functions<span
class="type-signature"></span></h4>
<div class="description">
<a href="document-user.html" target="_blank">Functions object</a>
</div>
<dl class="details"></dl>


<h4 class="name" id="notice"><span class="type-signature"></span>notice<span
class="type-signature"></span></h4>
<div class="description">
Expand Down
21 changes: 16 additions & 5 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export default function (context, pluginCallButtons, plugins, lang, options) {
*/
util: util,

/**
* @description Functions object
*/
functions: null,

/**
* @description Notice object
*/
Expand Down Expand Up @@ -723,10 +728,13 @@ export default function (context, pluginCallButtons, plugins, lang, options) {
const onlyTable = function (current) {
return util.isTable(current) ? /^TABLE$/i.test(current.nodeName) : true;
};
const startRangeEl = util.getRangeFormatElement(startLine, onlyTable);
const endRangeEl = util.getRangeFormatElement(endLine, onlyTable);
const sameRange = startRangeEl === endRangeEl;

let startRangeEl = util.getRangeFormatElement(startLine, onlyTable);
let endRangeEl = util.getRangeFormatElement(endLine, onlyTable);
if (startRangeEl && util.isListCell(startRangeEl.parentNode)) startRangeEl = startRangeEl.parentNode;
if (endRangeEl && util.isListCell(endRangeEl.parentNode)) endRangeEl = endRangeEl.parentNode;

const sameRange = startRangeEl === endRangeEl;
for (let i = 0, len = lineNodes.length, line; i < len; i++) {
line = lineNodes[i];

Expand Down Expand Up @@ -979,7 +987,7 @@ export default function (context, pluginCallButtons, plugins, lang, options) {
afterNode = null;
} else if (!afterNode) {
const r = this.removeNode();
const container = r.container.nodeType === 3 ? (util.getFormatElement(r.container) || r.container.parentNode) : r.container;
const container = r.container.nodeType === 3 ? (util.isListCell(util.getFormatElement(r.container)) ? r.container : (util.getFormatElement(r.container) || r.container.parentNode)) : r.container;
parentNode = container.parentNode;
afterNode = container.nextSibling;
}
Expand Down Expand Up @@ -4202,7 +4210,7 @@ export default function (context, pluginCallButtons, plugins, lang, options) {
}
}

if (util.isListCell(formatEl) && util.isList(rangeEl) && (util.isListCell(rangeEl.parentNode) || formatEl.previousElementSibling) && (selectionNode === formatEl || (selectionNode.nodeType === 3 && !selectionNode.nextSibling && range.collapsed && range.endOffset === selectionNode.textContent.length))) {
if (util.isListCell(formatEl) && util.isList(rangeEl) && (selectionNode === formatEl || (selectionNode.nodeType === 3 && !selectionNode.nextSibling && range.collapsed && range.endOffset === selectionNode.textContent.length))) {
const next = formatEl.nextElementSibling;
if (next && util.getArrayItem(next.children, util.isList, false)) {
e.preventDefault();
Expand Down Expand Up @@ -5220,5 +5228,8 @@ export default function (context, pluginCallButtons, plugins, lang, options) {
event._addEvent();
core._charCount(0, false);

// functionss
core.functions = userFunction;

return userFunction;
}

0 comments on commit 15bb3af

Please sign in to comment.