@wangeditor-next/core 1.7.11-beta.0 → 1.7.12-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -31
- package/dist/index.mjs +38 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5108,6 +5108,25 @@
|
|
|
5108
5108
|
*/
|
|
5109
5109
|
var EDITOR_TO_TEXT = new WeakMap();
|
|
5110
5110
|
var EDITOR_TO_START_CONTAINER = new WeakMap();
|
|
5111
|
+
function areBothTextNodes(editor, selection) {
|
|
5112
|
+
if (require$$1.Range.isCollapsed(selection)) {
|
|
5113
|
+
var anchor = selection.anchor, focus_1 = selection.focus;
|
|
5114
|
+
if (anchor.path.length === 2
|
|
5115
|
+
&& focus_1.path.length === 2
|
|
5116
|
+
&& (anchor.offset === 0 || focus_1.path.offset === 0)) {
|
|
5117
|
+
var nowEntry = require$$1.Editor.node(editor, anchor.path);
|
|
5118
|
+
var nowPath = anchor.offset === 0 ? anchor.path : focus_1.path;
|
|
5119
|
+
var prePath = [nowPath[0], nowPath[1] - 1];
|
|
5120
|
+
if (nowPath[1] === 0) {
|
|
5121
|
+
return false;
|
|
5122
|
+
}
|
|
5123
|
+
var preEntry = require$$1.Editor.node(editor, prePath);
|
|
5124
|
+
if (require$$1.Text.isText(preEntry[0]) && require$$1.Text.isText(nowEntry[0])) {
|
|
5125
|
+
return true;
|
|
5126
|
+
}
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5111
5130
|
/**
|
|
5112
5131
|
* composition start 事件
|
|
5113
5132
|
* @param e event
|
|
@@ -5116,8 +5135,9 @@
|
|
|
5116
5135
|
*/
|
|
5117
5136
|
function handleCompositionStart(e, textarea, editor) {
|
|
5118
5137
|
var event = e;
|
|
5119
|
-
if (!hasEditableTarget(editor, event.target))
|
|
5138
|
+
if (!hasEditableTarget(editor, event.target)) {
|
|
5120
5139
|
return;
|
|
5140
|
+
}
|
|
5121
5141
|
var selection = editor.selection;
|
|
5122
5142
|
if (selection && require$$1.Range.isExpanded(selection)) {
|
|
5123
5143
|
require$$1.Editor.deleteFragment(editor);
|
|
@@ -5129,9 +5149,9 @@
|
|
|
5129
5149
|
editorSelectionToDOM(textarea, editor, true);
|
|
5130
5150
|
});
|
|
5131
5151
|
}
|
|
5132
|
-
if (selection && (require$$1.Range.isExpanded(selection) || require$$1.Range.isCollapsed(selection))) {
|
|
5152
|
+
if (editor.selection && (require$$1.Range.isExpanded(editor.selection) || require$$1.Range.isCollapsed(editor.selection))) {
|
|
5133
5153
|
// 记录下 dom text ,以便触发 maxLength 时使用
|
|
5134
|
-
var domRange = DomEditor.toDOMRange(editor, selection);
|
|
5154
|
+
var domRange = DomEditor.toDOMRange(editor, editor.selection);
|
|
5135
5155
|
var startContainer = domRange.startContainer;
|
|
5136
5156
|
var curText = startContainer.textContent || '';
|
|
5137
5157
|
EDITOR_TO_TEXT.set(editor, curText);
|
|
@@ -5149,8 +5169,9 @@
|
|
|
5149
5169
|
* @param editor editor
|
|
5150
5170
|
*/
|
|
5151
5171
|
function handleCompositionUpdate(event, textarea, editor) {
|
|
5152
|
-
if (!hasEditableTarget(editor, event.target))
|
|
5172
|
+
if (!hasEditableTarget(editor, event.target)) {
|
|
5153
5173
|
return;
|
|
5174
|
+
}
|
|
5154
5175
|
textarea.isComposing = true;
|
|
5155
5176
|
}
|
|
5156
5177
|
/**
|
|
@@ -5161,12 +5182,14 @@
|
|
|
5161
5182
|
*/
|
|
5162
5183
|
function handleCompositionEnd(e, textarea, editor) {
|
|
5163
5184
|
var event = e;
|
|
5164
|
-
if (!hasEditableTarget(editor, event.target))
|
|
5185
|
+
if (!hasEditableTarget(editor, event.target)) {
|
|
5165
5186
|
return;
|
|
5187
|
+
}
|
|
5166
5188
|
textarea.isComposing = false;
|
|
5167
5189
|
var selection = editor.selection;
|
|
5168
|
-
if (selection == null)
|
|
5190
|
+
if (selection == null) {
|
|
5169
5191
|
return;
|
|
5192
|
+
}
|
|
5170
5193
|
// 清理可能暴露的 text 节点
|
|
5171
5194
|
// 例如 chrome 在链接后面,输入拼音,就会出现有暴露出来的 text node
|
|
5172
5195
|
if (IS_CHROME || IS_FIREFOX) {
|
|
@@ -5178,7 +5201,7 @@
|
|
|
5178
5201
|
// 因此需要设置新的 key 来强刷整行
|
|
5179
5202
|
var start = require$$1.Range.isBackward(selection) ? selection.focus : selection.anchor;
|
|
5180
5203
|
var _a = __read(require$$1.Editor.node(editor, [start.path[0]]), 1), paragraph = _a[0];
|
|
5181
|
-
for (var i = 0; i < start.path.length; i
|
|
5204
|
+
for (var i = 0; i < start.path.length; i += 1) {
|
|
5182
5205
|
var _b = __read(require$$1.Editor.node(editor, start.path.slice(0, i + 1)), 1), node = _b[0];
|
|
5183
5206
|
if (require$$1.Element.isElement(node)) {
|
|
5184
5207
|
if (((IS_SAFARI || IS_FIREFOX) && node.type === 'link') || node.type === 'code') {
|
|
@@ -5188,8 +5211,9 @@
|
|
|
5188
5211
|
}
|
|
5189
5212
|
}
|
|
5190
5213
|
var data = event.data;
|
|
5191
|
-
if (!data)
|
|
5214
|
+
if (!data) {
|
|
5192
5215
|
return;
|
|
5216
|
+
}
|
|
5193
5217
|
// 检查 maxLength -【注意】这里只处理拼音输入的 maxLength 限制。其他限制,在插件 with-max-length.ts 中处理
|
|
5194
5218
|
var maxLength = editor.getConfig().maxLength;
|
|
5195
5219
|
if (maxLength) {
|
|
@@ -5222,13 +5246,15 @@
|
|
|
5222
5246
|
// 检查拼音输入是否夸 DOM 节点了,解决 wangEditor-v5/issues/47
|
|
5223
5247
|
if (!IS_SAFARI) {
|
|
5224
5248
|
setTimeout(function () {
|
|
5225
|
-
var
|
|
5226
|
-
if (
|
|
5249
|
+
var setTImeoutSelection = editor.selection;
|
|
5250
|
+
if (setTImeoutSelection == null) {
|
|
5227
5251
|
return;
|
|
5252
|
+
}
|
|
5228
5253
|
var oldStartContainer = EDITOR_TO_START_CONTAINER.get(editor); // 拼音输入开始时的 text node
|
|
5229
|
-
if (oldStartContainer == null)
|
|
5254
|
+
if (oldStartContainer == null) {
|
|
5230
5255
|
return;
|
|
5231
|
-
|
|
5256
|
+
}
|
|
5257
|
+
var curStartContainer = DomEditor.toDOMRange(editor, setTImeoutSelection).startContainer; // 拼音输入结束时的 text node
|
|
5232
5258
|
if (curStartContainer === oldStartContainer) {
|
|
5233
5259
|
// 拼音输入的开始和结束,都在同一个 text node ,则不做处理
|
|
5234
5260
|
return;
|
|
@@ -5238,25 +5264,6 @@
|
|
|
5238
5264
|
});
|
|
5239
5265
|
}
|
|
5240
5266
|
}
|
|
5241
|
-
function areBothTextNodes(editor, selection) {
|
|
5242
|
-
if (require$$1.Range.isCollapsed(selection)) {
|
|
5243
|
-
var anchor = selection.anchor, focus_1 = selection.focus;
|
|
5244
|
-
if (anchor.path.length === 2 &&
|
|
5245
|
-
focus_1.path.length === 2 &&
|
|
5246
|
-
(anchor.offset === 0 || focus_1.path.offset === 0)) {
|
|
5247
|
-
var nowEntry = require$$1.Editor.node(editor, anchor.path);
|
|
5248
|
-
var nowPath = anchor.offset === 0 ? anchor.path : focus_1.path;
|
|
5249
|
-
var prePath = [nowPath[0], nowPath[1] - 1];
|
|
5250
|
-
if (nowPath[1] === 0) {
|
|
5251
|
-
return false;
|
|
5252
|
-
}
|
|
5253
|
-
var preEntry = require$$1.Editor.node(editor, prePath);
|
|
5254
|
-
if (require$$1.Text.isText(preEntry[0]) && require$$1.Text.isText(nowEntry[0])) {
|
|
5255
|
-
return true;
|
|
5256
|
-
}
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
|
-
}
|
|
5260
5267
|
|
|
5261
5268
|
/**
|
|
5262
5269
|
* @description 快捷键
|
package/dist/index.mjs
CHANGED
|
@@ -5067,6 +5067,25 @@ function handleOnClick(event, textarea, editor) {
|
|
|
5067
5067
|
*/
|
|
5068
5068
|
var EDITOR_TO_TEXT = new WeakMap();
|
|
5069
5069
|
var EDITOR_TO_START_CONTAINER = new WeakMap();
|
|
5070
|
+
function areBothTextNodes(editor, selection) {
|
|
5071
|
+
if (Range.isCollapsed(selection)) {
|
|
5072
|
+
var anchor = selection.anchor, focus_1 = selection.focus;
|
|
5073
|
+
if (anchor.path.length === 2
|
|
5074
|
+
&& focus_1.path.length === 2
|
|
5075
|
+
&& (anchor.offset === 0 || focus_1.path.offset === 0)) {
|
|
5076
|
+
var nowEntry = Editor.node(editor, anchor.path);
|
|
5077
|
+
var nowPath = anchor.offset === 0 ? anchor.path : focus_1.path;
|
|
5078
|
+
var prePath = [nowPath[0], nowPath[1] - 1];
|
|
5079
|
+
if (nowPath[1] === 0) {
|
|
5080
|
+
return false;
|
|
5081
|
+
}
|
|
5082
|
+
var preEntry = Editor.node(editor, prePath);
|
|
5083
|
+
if (Text.isText(preEntry[0]) && Text.isText(nowEntry[0])) {
|
|
5084
|
+
return true;
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5070
5089
|
/**
|
|
5071
5090
|
* composition start 事件
|
|
5072
5091
|
* @param e event
|
|
@@ -5075,8 +5094,9 @@ var EDITOR_TO_START_CONTAINER = new WeakMap();
|
|
|
5075
5094
|
*/
|
|
5076
5095
|
function handleCompositionStart(e, textarea, editor) {
|
|
5077
5096
|
var event = e;
|
|
5078
|
-
if (!hasEditableTarget(editor, event.target))
|
|
5097
|
+
if (!hasEditableTarget(editor, event.target)) {
|
|
5079
5098
|
return;
|
|
5099
|
+
}
|
|
5080
5100
|
var selection = editor.selection;
|
|
5081
5101
|
if (selection && Range.isExpanded(selection)) {
|
|
5082
5102
|
Editor.deleteFragment(editor);
|
|
@@ -5088,9 +5108,9 @@ function handleCompositionStart(e, textarea, editor) {
|
|
|
5088
5108
|
editorSelectionToDOM(textarea, editor, true);
|
|
5089
5109
|
});
|
|
5090
5110
|
}
|
|
5091
|
-
if (selection && (Range.isExpanded(selection) || Range.isCollapsed(selection))) {
|
|
5111
|
+
if (editor.selection && (Range.isExpanded(editor.selection) || Range.isCollapsed(editor.selection))) {
|
|
5092
5112
|
// 记录下 dom text ,以便触发 maxLength 时使用
|
|
5093
|
-
var domRange = DomEditor.toDOMRange(editor, selection);
|
|
5113
|
+
var domRange = DomEditor.toDOMRange(editor, editor.selection);
|
|
5094
5114
|
var startContainer = domRange.startContainer;
|
|
5095
5115
|
var curText = startContainer.textContent || '';
|
|
5096
5116
|
EDITOR_TO_TEXT.set(editor, curText);
|
|
@@ -5108,8 +5128,9 @@ function handleCompositionStart(e, textarea, editor) {
|
|
|
5108
5128
|
* @param editor editor
|
|
5109
5129
|
*/
|
|
5110
5130
|
function handleCompositionUpdate(event, textarea, editor) {
|
|
5111
|
-
if (!hasEditableTarget(editor, event.target))
|
|
5131
|
+
if (!hasEditableTarget(editor, event.target)) {
|
|
5112
5132
|
return;
|
|
5133
|
+
}
|
|
5113
5134
|
textarea.isComposing = true;
|
|
5114
5135
|
}
|
|
5115
5136
|
/**
|
|
@@ -5120,12 +5141,14 @@ function handleCompositionUpdate(event, textarea, editor) {
|
|
|
5120
5141
|
*/
|
|
5121
5142
|
function handleCompositionEnd(e, textarea, editor) {
|
|
5122
5143
|
var event = e;
|
|
5123
|
-
if (!hasEditableTarget(editor, event.target))
|
|
5144
|
+
if (!hasEditableTarget(editor, event.target)) {
|
|
5124
5145
|
return;
|
|
5146
|
+
}
|
|
5125
5147
|
textarea.isComposing = false;
|
|
5126
5148
|
var selection = editor.selection;
|
|
5127
|
-
if (selection == null)
|
|
5149
|
+
if (selection == null) {
|
|
5128
5150
|
return;
|
|
5151
|
+
}
|
|
5129
5152
|
// 清理可能暴露的 text 节点
|
|
5130
5153
|
// 例如 chrome 在链接后面,输入拼音,就会出现有暴露出来的 text node
|
|
5131
5154
|
if (IS_CHROME || IS_FIREFOX) {
|
|
@@ -5137,7 +5160,7 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
5137
5160
|
// 因此需要设置新的 key 来强刷整行
|
|
5138
5161
|
var start = Range.isBackward(selection) ? selection.focus : selection.anchor;
|
|
5139
5162
|
var _a = __read(Editor.node(editor, [start.path[0]]), 1), paragraph = _a[0];
|
|
5140
|
-
for (var i = 0; i < start.path.length; i
|
|
5163
|
+
for (var i = 0; i < start.path.length; i += 1) {
|
|
5141
5164
|
var _b = __read(Editor.node(editor, start.path.slice(0, i + 1)), 1), node = _b[0];
|
|
5142
5165
|
if (Element.isElement(node)) {
|
|
5143
5166
|
if (((IS_SAFARI || IS_FIREFOX) && node.type === 'link') || node.type === 'code') {
|
|
@@ -5147,8 +5170,9 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
5147
5170
|
}
|
|
5148
5171
|
}
|
|
5149
5172
|
var data = event.data;
|
|
5150
|
-
if (!data)
|
|
5173
|
+
if (!data) {
|
|
5151
5174
|
return;
|
|
5175
|
+
}
|
|
5152
5176
|
// 检查 maxLength -【注意】这里只处理拼音输入的 maxLength 限制。其他限制,在插件 with-max-length.ts 中处理
|
|
5153
5177
|
var maxLength = editor.getConfig().maxLength;
|
|
5154
5178
|
if (maxLength) {
|
|
@@ -5181,13 +5205,15 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
5181
5205
|
// 检查拼音输入是否夸 DOM 节点了,解决 wangEditor-v5/issues/47
|
|
5182
5206
|
if (!IS_SAFARI) {
|
|
5183
5207
|
setTimeout(function () {
|
|
5184
|
-
var
|
|
5185
|
-
if (
|
|
5208
|
+
var setTImeoutSelection = editor.selection;
|
|
5209
|
+
if (setTImeoutSelection == null) {
|
|
5186
5210
|
return;
|
|
5211
|
+
}
|
|
5187
5212
|
var oldStartContainer = EDITOR_TO_START_CONTAINER.get(editor); // 拼音输入开始时的 text node
|
|
5188
|
-
if (oldStartContainer == null)
|
|
5213
|
+
if (oldStartContainer == null) {
|
|
5189
5214
|
return;
|
|
5190
|
-
|
|
5215
|
+
}
|
|
5216
|
+
var curStartContainer = DomEditor.toDOMRange(editor, setTImeoutSelection).startContainer; // 拼音输入结束时的 text node
|
|
5191
5217
|
if (curStartContainer === oldStartContainer) {
|
|
5192
5218
|
// 拼音输入的开始和结束,都在同一个 text node ,则不做处理
|
|
5193
5219
|
return;
|
|
@@ -5197,25 +5223,6 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
5197
5223
|
});
|
|
5198
5224
|
}
|
|
5199
5225
|
}
|
|
5200
|
-
function areBothTextNodes(editor, selection) {
|
|
5201
|
-
if (Range.isCollapsed(selection)) {
|
|
5202
|
-
var anchor = selection.anchor, focus_1 = selection.focus;
|
|
5203
|
-
if (anchor.path.length === 2 &&
|
|
5204
|
-
focus_1.path.length === 2 &&
|
|
5205
|
-
(anchor.offset === 0 || focus_1.path.offset === 0)) {
|
|
5206
|
-
var nowEntry = Editor.node(editor, anchor.path);
|
|
5207
|
-
var nowPath = anchor.offset === 0 ? anchor.path : focus_1.path;
|
|
5208
|
-
var prePath = [nowPath[0], nowPath[1] - 1];
|
|
5209
|
-
if (nowPath[1] === 0) {
|
|
5210
|
-
return false;
|
|
5211
|
-
}
|
|
5212
|
-
var preEntry = Editor.node(editor, prePath);
|
|
5213
|
-
if (Text.isText(preEntry[0]) && Text.isText(nowEntry[0])) {
|
|
5214
|
-
return true;
|
|
5215
|
-
}
|
|
5216
|
-
}
|
|
5217
|
-
}
|
|
5218
|
-
}
|
|
5219
5226
|
|
|
5220
5227
|
/**
|
|
5221
5228
|
* @description 快捷键
|