Skip to content

Commit

Permalink
2.33.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Sep 5, 2020
2 parents c5d7ac5 + 0e784a7 commit fda4580
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ plugins: [
lang : language object. default : en {Object}
value : Initial value(html string) of the edit area.
If not, the value of the "target textarea". default: null {String}
historyStackDelayTime : When recording the history stack, this is the delay time(miliseconds) since the last input. default: 400 {Number}

// Whitelist--------------------------------------å---------------------------------------------------------
// _defaultTagsWhitelist : 'br|p|div|pre|blockquote|h[1-6]|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code'
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "suneditor",
"version": "2.33.0",
"version": "2.33.1",
"description": "Pure JavaScript based WYSIWYG web editor",
"main": "src/suneditor.js",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion dist/suneditor.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sideEffects": [
"./src/assets/css/*.css"
],
"version": "2.33.0",
"version": "2.33.1",
"description": "Pure JavaScript based WYSIWYG web editor",
"main": "src/suneditor.js",
"keywords": [
Expand Down Expand Up @@ -41,23 +41,23 @@
"@webpack-cli/init": "^0.2.2",
"babel-loader": "^8.1.0",
"clean-webpack-plugin": "^0.1.19",
"codemirror": "^5.52.2",
"codemirror": "^5.57.0",
"css-loader": "^1.0.1",
"csstype": "^2.6.10",
"csstype": "^2.6.13",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"jasmine": "^2.99.0",
"jasmine-core": "^2.99.1",
"jshint": "^2.11.0",
"jshint": "^2.12.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.2",
"katex": "^0.11.1",
"mini-css-extract-plugin": "^0.4.5",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"url-loader": "^1.1.2",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^4.2.2"
},
Expand Down
4 changes: 4 additions & 0 deletions sample/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<h4 style="color: #b94a48;">--Value</h4>
<label><input type="checkbox" id="editor_value">&nbsp;&nbsp;value&nbsp;&nbsp;&nbsp;</label><br>
<textarea id="editor_value_value" placeholder="HTML String ('&lt;p&gt;..&lt;/p&gt;')" style="width:320px"></textarea>
<br><br>
<label><input type="checkbox" id="historyStackDelayTime">&nbsp;&nbsp;historyStackDelayTime&nbsp;&nbsp;&nbsp;</label>
<input type="text" id="historyStackDelayTime_value" placeholder="Number (400)miliseconds">
<br>
<h4 style="color: #b94a48;">--Whitelist</h4>
<label><input type="checkbox" id="addTagsWhitelist">&nbsp;&nbsp;addTagsWhitelist&nbsp;&nbsp;&nbsp;</label>
Expand Down Expand Up @@ -466,6 +469,7 @@ <h2 class="sub-title">Applied options</h2>

var options = {
value: document.getElementById('editor_value').checked ? document.getElementById('editor_value_value').value : undefined,
historyStackDelayTime: document.getElementById('historyStackDelayTime').checked ? document.getElementById('historyStackDelayTime_value').value * 1 : undefined,
addTagsWhitelist: document.getElementById('addTagsWhitelist').checked ? document.getElementById('addTagsWhitelist_value').value : undefined,
pasteTagsWhitelist: document.getElementById('pasteTagsWhitelist').checked ? document.getElementById('pasteTagsWhitelist_value').value : undefined,
attributesWhitelist: !document.getElementById('attributesWhitelist').checked ? undefined : {
Expand Down
2 changes: 1 addition & 1 deletion sample/html/out/document-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h5 class="subsection-title">Properties:</h5>
</td>
<td class="description last">
Saving the current status to the history object stack<br>
If "delay" is true, it will be saved after 500 miliseconds<br>
If "delay" is true, it will be saved after (options.historyStackDelayTime || 400) miliseconds<br>
If the function is called again with the "delay" argument true before it is saved, the delay time is renewal.<br>
You can specify the delay time by sending a number.
</td>
Expand Down
1 change: 1 addition & 0 deletions src/lib/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export default {
/** Values */
options.lang = options.lang || _defaultLang;
options.value = typeof options.value === 'string' ? options.value : null;
options.historyStackDelayTime = typeof options.historyStackDelayTime === 'number' ? options.historyStackDelayTime : 400;
/** Whitelist */
options._defaultTagsWhitelist = typeof options._defaultTagsWhitelist === 'string' ? options._defaultTagsWhitelist : 'br|p|div|pre|blockquote|h[1-6]|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code';
options._editorTagsWhitelist = options._defaultTagsWhitelist + (typeof options.addTagsWhitelist === 'string' && options.addTagsWhitelist.length > 0 ? '|' + options.addTagsWhitelist : '');
Expand Down
12 changes: 6 additions & 6 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
getRange: function () {
const range = this._variable._range || this._createDefaultRange();
const selection = this.getSelection();
if (range.collapsed === selection.isCollapsed) return range;
if (range.collapsed === selection.isCollapsed || !context.element.wysiwyg.contains(selection.focusNode)) return range;

if (selection.rangeCount > 0) {
this._variable._range = selection.getRangeAt(0);
Expand Down Expand Up @@ -1016,8 +1016,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
let tempCon, tempOffset, tempChild;

if (util.isFormatElement(startCon)) {
startCon = startCon.childNodes[startOff] || startCon.firstChild;
startOff = 0;
startCon = startCon.childNodes[startOff] || startCon.lastChild;
startOff = startCon.textContent.length;
}
if (util.isFormatElement(endCon)) {
endCon = endCon.childNodes[endOff] || endCon.lastChild;
Expand Down Expand Up @@ -1260,8 +1260,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
return null;
}

this.getRange_addLine(this.getRange());
const r = this.removeNode();
this.getRange_addLine(this.getRange());
let oNode = null;
let selectionNode = this.getSelectionNode();
let formatEl = util.getFormatElement(selectionNode, null);
Expand Down Expand Up @@ -1493,7 +1493,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
afterNode = isFormats ? endCon : null;
}

while (afterNode && afterNode.parentNode !== commonCon) {
while (afterNode && !util.isFormatElement(afterNode) && afterNode.parentNode !== commonCon) {
afterNode = afterNode.parentNode;
}
}
Expand Down Expand Up @@ -1530,7 +1530,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
afterNode = parentNode.nextElementSibling;
parentNode = parentNode.parentNode;
}
parentNode.insertBefore(oNode, afterNode);
parentNode.insertBefore(oNode, parentNode === afterNode ? parentNode.lastChild : afterNode);
} catch (e) {
parentNode.appendChild(oNode);
} finally {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/history.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export interface History {
stack: any[];
/**
* @description Saving the current status to the history object stack
* If "delay" is true, it will be saved after 500 miliseconds
* If "delay" is true, it will be saved after (options.historyStackDelayTime || 400) miliseconds
* If the function is called again with the "delay" argument true before it is saved, the delay time is renewal
* You can specify the delay time by sending a number.
* @param {Boolean} delay If true, delays 500 milliseconds
* @param {Boolean} delay If true, Add stack without delay time.
*/
push: (delay: boolean | number) => void;
/**
Expand Down
9 changes: 5 additions & 4 deletions src/lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
'use strict';

export default function (core, change) {
const _w = window;
const _w = core._w;
const util = core.util;
const delayTime = core.context.options.historyStackDelayTime;
let editor = core.context.element;
let undo = core.context.tool.undo;
let redo = core.context.tool.redo;
Expand Down Expand Up @@ -93,14 +94,14 @@ export default function (core, change) {

/**
* @description Saving the current status to the history object stack
* If "delay" is true, it will be saved after 500 miliseconds
* If "delay" is true, it will be saved after (options.historyStackDelayTime || 400) miliseconds
* If the function is called again with the "delay" argument true before it is saved, the delay time is renewal
* You can specify the delay time by sending a number.
* @param {Boolean|Number} delay If true, delays 400 milliseconds
* @param {Boolean|Number} delay If true, Add stack without delay time.
*/
push: function (delay) {
_w.setTimeout(core._resourcesStateChange.bind(core));
const time = typeof delay === 'number' ? (delay > 0 ? delay : 0) : (!delay ? 0 : 400);
const time = typeof delay === 'number' ? (delay > 0 ? delay : 0) : (!delay ? 0 : delayTime);

if (!time || pushDelay) {
_w.clearTimeout(pushDelay);
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/dialog/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ export default {
this.setRange(textNode, 0, textNode, textNode.textContent.length);
}

// history stack
this.history.push(false);

contextLink._linkValue = contextLink.preview.textContent = contextLink.focusElement.value = contextLink.linkAnchorText.value = '';
}.bind(this);

Expand All @@ -181,7 +178,8 @@ export default {
} finally {
this.plugins.dialog.close.call(this);
this.closeLoading();
this.focus();
// history stack
this.history.push(false);
}

return false;
Expand Down
1 change: 1 addition & 0 deletions webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = merge(common, {
},

plugins: [
new webpack.SourceMapDevToolPlugin(),
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new CleanWebpackPlugin(['dist']),
Expand Down

0 comments on commit fda4580

Please sign in to comment.