@wangeditor-next/editor 5.3.0 → 5.3.2
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/CHANGELOG.md +16 -0
- package/dist/index.esm.js +65 -6
- package/dist/index.js +65 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.3.2](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/editor@5.3.1...@wangeditor-next/editor@5.3.2) (2024-07-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @wangeditor-next/editor
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [5.3.1](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/editor@5.3.0...@wangeditor-next/editor@5.3.1) (2024-06-29)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @wangeditor-next/editor
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [5.3.0](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/editor@5.2.8...@wangeditor-next/editor@5.3.0) (2024-06-24)
|
|
7
23
|
|
|
8
24
|
|
package/dist/index.esm.js
CHANGED
|
@@ -19040,7 +19040,7 @@ var withDOM = function (editor) {
|
|
|
19040
19040
|
Transforms.deselect(e);
|
|
19041
19041
|
IS_FOCUSED.set(e, false);
|
|
19042
19042
|
};
|
|
19043
|
-
//
|
|
19043
|
+
// 手动更新视图
|
|
19044
19044
|
e.updateView = function () {
|
|
19045
19045
|
var textarea = DomEditor.getTextarea(e);
|
|
19046
19046
|
textarea.changeViewState();
|
|
@@ -22332,6 +22332,15 @@ function handleCompositionStart(e, textarea, editor) {
|
|
|
22332
22332
|
// 记录下 dom range startContainer
|
|
22333
22333
|
EDITOR_TO_START_CONTAINER.set(editor, startContainer);
|
|
22334
22334
|
}
|
|
22335
|
+
if (selection && Range.isExpanded(selection)) {
|
|
22336
|
+
// 记录下 dom text ,以便触发 maxLength 时使用
|
|
22337
|
+
var domRange = DomEditor.toDOMRange(editor, selection);
|
|
22338
|
+
var startContainer = domRange.startContainer;
|
|
22339
|
+
var curText = startContainer.textContent || '';
|
|
22340
|
+
EDITOR_TO_TEXT.set(editor, curText);
|
|
22341
|
+
// 记录下 dom range startContainer
|
|
22342
|
+
EDITOR_TO_START_CONTAINER.set(editor, startContainer);
|
|
22343
|
+
}
|
|
22335
22344
|
textarea.isComposing = true;
|
|
22336
22345
|
// 隐藏 placeholder
|
|
22337
22346
|
hidePlaceholder(textarea, editor);
|
|
@@ -22402,6 +22411,15 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
22402
22411
|
}
|
|
22403
22412
|
}
|
|
22404
22413
|
else {
|
|
22414
|
+
// 拼音输入,当选区的边缘在两个 text node 之间时 需要重置为 domselction 的 选区
|
|
22415
|
+
var root = DomEditor.findDocumentOrShadowRoot(editor);
|
|
22416
|
+
var domSelection = root.getSelection();
|
|
22417
|
+
if (domSelection && areBothTextNodes(editor, selection)) {
|
|
22418
|
+
editor.selection = DomEditor.toSlateRange(editor, domSelection, {
|
|
22419
|
+
exactMatch: false,
|
|
22420
|
+
suppressThrow: false,
|
|
22421
|
+
});
|
|
22422
|
+
}
|
|
22405
22423
|
Editor.insertText(editor, data);
|
|
22406
22424
|
}
|
|
22407
22425
|
// 检查拼音输入是否夸 DOM 节点了,解决 wangEditor-v5/issues/47
|
|
@@ -22422,6 +22440,25 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
22422
22440
|
oldStartContainer.textContent = EDITOR_TO_TEXT.get(editor) || '';
|
|
22423
22441
|
});
|
|
22424
22442
|
}
|
|
22443
|
+
}
|
|
22444
|
+
function areBothTextNodes(editor, selection) {
|
|
22445
|
+
if (Range.isCollapsed(selection)) {
|
|
22446
|
+
var anchor = selection.anchor, focus_1 = selection.focus;
|
|
22447
|
+
if (anchor.path.length === 2 &&
|
|
22448
|
+
focus_1.path.length === 2 &&
|
|
22449
|
+
(anchor.offset === 0 || focus_1.path.offset === 0)) {
|
|
22450
|
+
var nowEntry = Editor.node(editor, anchor.path);
|
|
22451
|
+
var nowPath = anchor.offset === 0 ? anchor.path : focus_1.path;
|
|
22452
|
+
var prePath = [nowPath[0], nowPath[1] - 1];
|
|
22453
|
+
if (nowPath[1] === 0) {
|
|
22454
|
+
return false;
|
|
22455
|
+
}
|
|
22456
|
+
var preEntry = Editor.node(editor, prePath);
|
|
22457
|
+
if (Text.isText(preEntry[0]) && Text.isText(nowEntry[0])) {
|
|
22458
|
+
return true;
|
|
22459
|
+
}
|
|
22460
|
+
}
|
|
22461
|
+
}
|
|
22425
22462
|
}
|
|
22426
22463
|
|
|
22427
22464
|
/**
|
|
@@ -29485,7 +29522,7 @@ function genLinkNode(url, text) {
|
|
|
29485
29522
|
*/
|
|
29486
29523
|
function insertLink(editor, text, url) {
|
|
29487
29524
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
29488
|
-
var checkRes, parsedUrl, selection, isCollapsed, linkNode, selectedText, linkNode, linkNode;
|
|
29525
|
+
var checkRes, parsedUrl, selection, isCollapsed, leftLength, linkNode, selectedText, leftLength, linkNode, linkNode;
|
|
29489
29526
|
return __generator$2(this, function (_a) {
|
|
29490
29527
|
switch (_a.label) {
|
|
29491
29528
|
case 0:
|
|
@@ -29513,8 +29550,17 @@ function insertLink(editor, text, url) {
|
|
|
29513
29550
|
isCollapsed = Range.isCollapsed(selection);
|
|
29514
29551
|
// 执行:插入链接
|
|
29515
29552
|
if (isCollapsed) {
|
|
29553
|
+
leftLength = DomEditor.getLeftLengthOfMaxLength(editor);
|
|
29554
|
+
if (leftLength <= 0) {
|
|
29555
|
+
// 已经触发 maxLength ,不再输入文字
|
|
29556
|
+
return [2 /*return*/];
|
|
29557
|
+
}
|
|
29516
29558
|
// 链接前后插入空格,方便操作
|
|
29517
29559
|
editor.insertText(' ');
|
|
29560
|
+
if (leftLength < text.length + 1) {
|
|
29561
|
+
// 剩余长度小于 text 长度,则截取 text
|
|
29562
|
+
text = text.slice(0, leftLength - 1);
|
|
29563
|
+
}
|
|
29518
29564
|
linkNode = genLinkNode(parsedUrl, text);
|
|
29519
29565
|
Transforms.insertNodes(editor, linkNode);
|
|
29520
29566
|
// https://github.com/wangeditor-team/wangEditor/issues/332
|
|
@@ -29525,7 +29571,15 @@ function insertLink(editor, text, url) {
|
|
|
29525
29571
|
selectedText = Editor.string(editor, selection) // 选中的文字
|
|
29526
29572
|
;
|
|
29527
29573
|
if (selectedText !== text) {
|
|
29528
|
-
|
|
29574
|
+
leftLength = DomEditor.getLeftLengthOfMaxLength(editor);
|
|
29575
|
+
if (leftLength <= 0) {
|
|
29576
|
+
// 已经触发 maxLength ,不再输入文字
|
|
29577
|
+
return [2 /*return*/];
|
|
29578
|
+
}
|
|
29579
|
+
if (leftLength < selectedText.length - text.length) {
|
|
29580
|
+
// 剩余长度小于 text 长度,则截取 text
|
|
29581
|
+
text = text.slice(0, leftLength);
|
|
29582
|
+
}
|
|
29529
29583
|
editor.deleteFragment();
|
|
29530
29584
|
linkNode = genLinkNode(parsedUrl, text);
|
|
29531
29585
|
Transforms.insertNodes(editor, linkNode);
|
|
@@ -37293,7 +37347,7 @@ var zhResources$2 = {
|
|
|
37293
37347
|
videoPosterPlaceHolder: '封面图片 url',
|
|
37294
37348
|
ok: '确定',
|
|
37295
37349
|
editSize: '修改尺寸',
|
|
37296
|
-
edit: '
|
|
37350
|
+
edit: '编辑视频',
|
|
37297
37351
|
width: '宽度',
|
|
37298
37352
|
height: '高度',
|
|
37299
37353
|
},
|
|
@@ -38411,7 +38465,7 @@ var uploadVideoMenuConf = {
|
|
|
38411
38465
|
// 创建编辑器时,可通过 editorConfig.MENU_CONF[key] = {...} 来修改
|
|
38412
38466
|
config: genUploadVideoMenuConfig(),
|
|
38413
38467
|
};
|
|
38414
|
-
var
|
|
38468
|
+
var editorVideoSizeMenuConf = {
|
|
38415
38469
|
key: 'editVideoSize',
|
|
38416
38470
|
factory: function () {
|
|
38417
38471
|
return new EditorVideoSizeMenu();
|
|
@@ -38440,7 +38494,12 @@ var video = {
|
|
|
38440
38494
|
elemsToHtml: [videoToHtmlConf],
|
|
38441
38495
|
preParseHtml: [preParseHtmlConf],
|
|
38442
38496
|
parseElemsHtml: [parseHtmlConf],
|
|
38443
|
-
menus: [
|
|
38497
|
+
menus: [
|
|
38498
|
+
insertVideoMenuConf,
|
|
38499
|
+
uploadVideoMenuConf,
|
|
38500
|
+
editorVideoSizeMenuConf,
|
|
38501
|
+
editorVideoSrcMenuConf,
|
|
38502
|
+
],
|
|
38444
38503
|
editorPlugin: withVideo,
|
|
38445
38504
|
};
|
|
38446
38505
|
|
package/dist/index.js
CHANGED
|
@@ -23233,7 +23233,7 @@
|
|
|
23233
23233
|
slate.Transforms.deselect(e);
|
|
23234
23234
|
IS_FOCUSED.set(e, false);
|
|
23235
23235
|
};
|
|
23236
|
-
//
|
|
23236
|
+
// 手动更新视图
|
|
23237
23237
|
e.updateView = function () {
|
|
23238
23238
|
var textarea = DomEditor.getTextarea(e);
|
|
23239
23239
|
textarea.changeViewState();
|
|
@@ -26547,6 +26547,15 @@
|
|
|
26547
26547
|
// 记录下 dom range startContainer
|
|
26548
26548
|
EDITOR_TO_START_CONTAINER.set(editor, startContainer);
|
|
26549
26549
|
}
|
|
26550
|
+
if (selection && slate.Range.isExpanded(selection)) {
|
|
26551
|
+
// 记录下 dom text ,以便触发 maxLength 时使用
|
|
26552
|
+
var domRange = DomEditor.toDOMRange(editor, selection);
|
|
26553
|
+
var startContainer = domRange.startContainer;
|
|
26554
|
+
var curText = startContainer.textContent || '';
|
|
26555
|
+
EDITOR_TO_TEXT.set(editor, curText);
|
|
26556
|
+
// 记录下 dom range startContainer
|
|
26557
|
+
EDITOR_TO_START_CONTAINER.set(editor, startContainer);
|
|
26558
|
+
}
|
|
26550
26559
|
textarea.isComposing = true;
|
|
26551
26560
|
// 隐藏 placeholder
|
|
26552
26561
|
hidePlaceholder(textarea, editor);
|
|
@@ -26617,6 +26626,15 @@
|
|
|
26617
26626
|
}
|
|
26618
26627
|
}
|
|
26619
26628
|
else {
|
|
26629
|
+
// 拼音输入,当选区的边缘在两个 text node 之间时 需要重置为 domselction 的 选区
|
|
26630
|
+
var root = DomEditor.findDocumentOrShadowRoot(editor);
|
|
26631
|
+
var domSelection = root.getSelection();
|
|
26632
|
+
if (domSelection && areBothTextNodes(editor, selection)) {
|
|
26633
|
+
editor.selection = DomEditor.toSlateRange(editor, domSelection, {
|
|
26634
|
+
exactMatch: false,
|
|
26635
|
+
suppressThrow: false,
|
|
26636
|
+
});
|
|
26637
|
+
}
|
|
26620
26638
|
slate.Editor.insertText(editor, data);
|
|
26621
26639
|
}
|
|
26622
26640
|
// 检查拼音输入是否夸 DOM 节点了,解决 wangEditor-v5/issues/47
|
|
@@ -26637,6 +26655,25 @@
|
|
|
26637
26655
|
oldStartContainer.textContent = EDITOR_TO_TEXT.get(editor) || '';
|
|
26638
26656
|
});
|
|
26639
26657
|
}
|
|
26658
|
+
}
|
|
26659
|
+
function areBothTextNodes(editor, selection) {
|
|
26660
|
+
if (slate.Range.isCollapsed(selection)) {
|
|
26661
|
+
var anchor = selection.anchor, focus_1 = selection.focus;
|
|
26662
|
+
if (anchor.path.length === 2 &&
|
|
26663
|
+
focus_1.path.length === 2 &&
|
|
26664
|
+
(anchor.offset === 0 || focus_1.path.offset === 0)) {
|
|
26665
|
+
var nowEntry = slate.Editor.node(editor, anchor.path);
|
|
26666
|
+
var nowPath = anchor.offset === 0 ? anchor.path : focus_1.path;
|
|
26667
|
+
var prePath = [nowPath[0], nowPath[1] - 1];
|
|
26668
|
+
if (nowPath[1] === 0) {
|
|
26669
|
+
return false;
|
|
26670
|
+
}
|
|
26671
|
+
var preEntry = slate.Editor.node(editor, prePath);
|
|
26672
|
+
if (slate.Text.isText(preEntry[0]) && slate.Text.isText(nowEntry[0])) {
|
|
26673
|
+
return true;
|
|
26674
|
+
}
|
|
26675
|
+
}
|
|
26676
|
+
}
|
|
26640
26677
|
}
|
|
26641
26678
|
|
|
26642
26679
|
/**
|
|
@@ -33816,7 +33853,7 @@
|
|
|
33816
33853
|
*/
|
|
33817
33854
|
function insertLink(editor, text, url) {
|
|
33818
33855
|
return __awaiter(this, void 0, void 0, function () {
|
|
33819
|
-
var checkRes, parsedUrl, selection, isCollapsed, linkNode, selectedText, linkNode, linkNode;
|
|
33856
|
+
var checkRes, parsedUrl, selection, isCollapsed, leftLength, linkNode, selectedText, leftLength, linkNode, linkNode;
|
|
33820
33857
|
return __generator(this, function (_a) {
|
|
33821
33858
|
switch (_a.label) {
|
|
33822
33859
|
case 0:
|
|
@@ -33844,8 +33881,17 @@
|
|
|
33844
33881
|
isCollapsed = slate.Range.isCollapsed(selection);
|
|
33845
33882
|
// 执行:插入链接
|
|
33846
33883
|
if (isCollapsed) {
|
|
33884
|
+
leftLength = core.DomEditor.getLeftLengthOfMaxLength(editor);
|
|
33885
|
+
if (leftLength <= 0) {
|
|
33886
|
+
// 已经触发 maxLength ,不再输入文字
|
|
33887
|
+
return [2 /*return*/];
|
|
33888
|
+
}
|
|
33847
33889
|
// 链接前后插入空格,方便操作
|
|
33848
33890
|
editor.insertText(' ');
|
|
33891
|
+
if (leftLength < text.length + 1) {
|
|
33892
|
+
// 剩余长度小于 text 长度,则截取 text
|
|
33893
|
+
text = text.slice(0, leftLength - 1);
|
|
33894
|
+
}
|
|
33849
33895
|
linkNode = genLinkNode(parsedUrl, text);
|
|
33850
33896
|
slate.Transforms.insertNodes(editor, linkNode);
|
|
33851
33897
|
// https://github.com/wangeditor-team/wangEditor/issues/332
|
|
@@ -33856,7 +33902,15 @@
|
|
|
33856
33902
|
selectedText = slate.Editor.string(editor, selection) // 选中的文字
|
|
33857
33903
|
;
|
|
33858
33904
|
if (selectedText !== text) {
|
|
33859
|
-
|
|
33905
|
+
leftLength = core.DomEditor.getLeftLengthOfMaxLength(editor);
|
|
33906
|
+
if (leftLength <= 0) {
|
|
33907
|
+
// 已经触发 maxLength ,不再输入文字
|
|
33908
|
+
return [2 /*return*/];
|
|
33909
|
+
}
|
|
33910
|
+
if (leftLength < selectedText.length - text.length) {
|
|
33911
|
+
// 剩余长度小于 text 长度,则截取 text
|
|
33912
|
+
text = text.slice(0, leftLength);
|
|
33913
|
+
}
|
|
33860
33914
|
editor.deleteFragment();
|
|
33861
33915
|
linkNode = genLinkNode(parsedUrl, text);
|
|
33862
33916
|
slate.Transforms.insertNodes(editor, linkNode);
|
|
@@ -41682,7 +41736,7 @@
|
|
|
41682
41736
|
videoPosterPlaceHolder: '封面图片 url',
|
|
41683
41737
|
ok: '确定',
|
|
41684
41738
|
editSize: '修改尺寸',
|
|
41685
|
-
edit: '
|
|
41739
|
+
edit: '编辑视频',
|
|
41686
41740
|
width: '宽度',
|
|
41687
41741
|
height: '高度',
|
|
41688
41742
|
},
|
|
@@ -42800,7 +42854,7 @@
|
|
|
42800
42854
|
// 创建编辑器时,可通过 editorConfig.MENU_CONF[key] = {...} 来修改
|
|
42801
42855
|
config: genUploadVideoMenuConfig(),
|
|
42802
42856
|
};
|
|
42803
|
-
var
|
|
42857
|
+
var editorVideoSizeMenuConf = {
|
|
42804
42858
|
key: 'editVideoSize',
|
|
42805
42859
|
factory: function () {
|
|
42806
42860
|
return new EditorVideoSizeMenu();
|
|
@@ -42829,7 +42883,12 @@
|
|
|
42829
42883
|
elemsToHtml: [videoToHtmlConf],
|
|
42830
42884
|
preParseHtml: [preParseHtmlConf],
|
|
42831
42885
|
parseElemsHtml: [parseHtmlConf],
|
|
42832
|
-
menus: [
|
|
42886
|
+
menus: [
|
|
42887
|
+
insertVideoMenuConf,
|
|
42888
|
+
uploadVideoMenuConf,
|
|
42889
|
+
editorVideoSizeMenuConf,
|
|
42890
|
+
editorVideoSrcMenuConf,
|
|
42891
|
+
],
|
|
42833
42892
|
editorPlugin: withVideo,
|
|
42834
42893
|
};
|
|
42835
42894
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wangeditor-next/editor",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
4
4
|
"description": "Web rich text editor, Web 富文本编辑器",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wangeditor",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@uppy/core": "^2.1.1",
|
|
52
52
|
"@uppy/xhr-upload": "^2.0.3",
|
|
53
|
-
"@wangeditor-next/basic-modules": "^1.2.
|
|
53
|
+
"@wangeditor-next/basic-modules": "^1.2.7",
|
|
54
54
|
"@wangeditor-next/code-highlight": "^1.2.1",
|
|
55
|
-
"@wangeditor-next/core": "^1.4.
|
|
55
|
+
"@wangeditor-next/core": "^1.4.2",
|
|
56
56
|
"@wangeditor-next/list-module": "^1.1.1",
|
|
57
57
|
"@wangeditor-next/table-module": "^1.2.1",
|
|
58
58
|
"@wangeditor-next/upload-image-module": "^1.1.1",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"slate": "^0.72.0",
|
|
71
71
|
"snabbdom": "^3.1.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "25ed7e7ad11c7572f3457355ba860eb1a27e2503"
|
|
74
74
|
}
|