@kaitify/core 0.0.1-beta.32 → 0.0.1-beta.34
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/lib/kaitify-core.es.js +37 -21
- package/lib/kaitify-core.umd.js +1 -1
- package/lib/model/Editor.d.ts +2 -2
- package/package.json +2 -2
package/lib/kaitify-core.es.js
CHANGED
|
@@ -2123,6 +2123,7 @@ class History {
|
|
|
2123
2123
|
* 更新当前记录的编辑器的光标
|
|
2124
2124
|
*/
|
|
2125
2125
|
updateSelection(selection) {
|
|
2126
|
+
if (this.records.length === 0) return;
|
|
2126
2127
|
const record = this.records[this.records.length - 1];
|
|
2127
2128
|
const newSelection = this.cloneSelection(record.nodes, selection);
|
|
2128
2129
|
this.records[this.records.length - 1].selection = newSelection;
|
|
@@ -2969,18 +2970,17 @@ const formatPlaceholderMerge = ({ editor, node }) => {
|
|
|
2969
2970
|
const formatLineBreakSpaceText = ({ editor, node }) => {
|
|
2970
2971
|
if (node.isText() && !node.isEmpty()) {
|
|
2971
2972
|
node.textContent = node.textContent.replace(/\r\n/g, "\n").replace(/\u00A0/g, " ").replace(/\uFEFF/g, getZeroWidthText());
|
|
2972
|
-
let
|
|
2973
|
-
let
|
|
2973
|
+
let startPrevNumber = 0;
|
|
2974
|
+
let endPrevNumber = 0;
|
|
2975
|
+
const regExp = new RegExp(`\\n(?!${getZeroWidthText()})`, "g");
|
|
2974
2976
|
if (editor.selection.focused()) {
|
|
2975
2977
|
if (editor.selection.start.node.isEqual(node)) {
|
|
2976
|
-
const
|
|
2977
|
-
|
|
2978
|
-
startInBreak = chart === "\n";
|
|
2978
|
+
const preText = editor.selection.start.offset > 0 ? node.textContent.slice(0, editor.selection.start.offset) : "";
|
|
2979
|
+
startPrevNumber = (preText.match(regExp) || []).length;
|
|
2979
2980
|
}
|
|
2980
2981
|
if (editor.selection.end.node.isEqual(node)) {
|
|
2981
|
-
const
|
|
2982
|
-
|
|
2983
|
-
endInBreak = chart === "\n";
|
|
2982
|
+
const preText = editor.selection.end.offset > 0 ? node.textContent.slice(0, editor.selection.end.offset) : "";
|
|
2983
|
+
endPrevNumber = (preText.match(regExp) || []).length;
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
2986
|
node.textContent = node.textContent.replace(/\n/g, (chart, index) => {
|
|
@@ -2990,11 +2990,11 @@ const formatLineBreakSpaceText = ({ editor, node }) => {
|
|
|
2990
2990
|
}
|
|
2991
2991
|
return chart;
|
|
2992
2992
|
});
|
|
2993
|
-
if (
|
|
2994
|
-
editor.selection.start.offset +=
|
|
2993
|
+
if (startPrevNumber > 0) {
|
|
2994
|
+
editor.selection.start.offset += startPrevNumber;
|
|
2995
2995
|
}
|
|
2996
|
-
if (
|
|
2997
|
-
editor.selection.end.offset +=
|
|
2996
|
+
if (endPrevNumber > 0) {
|
|
2997
|
+
editor.selection.end.offset += endPrevNumber;
|
|
2998
2998
|
}
|
|
2999
2999
|
}
|
|
3000
3000
|
};
|
|
@@ -6095,6 +6095,8 @@ const imageResizable = (editor) => {
|
|
|
6095
6095
|
enabled: true,
|
|
6096
6096
|
//指定可以调整大小的边缘
|
|
6097
6097
|
edges: { left: false, right: true, bottom: false, top: false },
|
|
6098
|
+
//设置可拖拽区域宽度
|
|
6099
|
+
margin: 5,
|
|
6098
6100
|
//设置鼠标样式
|
|
6099
6101
|
cursorChecker() {
|
|
6100
6102
|
return editor.isEditable() ? "ew-resize" : "default";
|
|
@@ -6263,6 +6265,8 @@ const videoResizable = (editor) => {
|
|
|
6263
6265
|
enabled: true,
|
|
6264
6266
|
//指定可以调整大小的边缘
|
|
6265
6267
|
edges: { left: false, right: true, bottom: false, top: false },
|
|
6268
|
+
//设置可拖拽区域宽度
|
|
6269
|
+
margin: 5,
|
|
6266
6270
|
//设置鼠标样式
|
|
6267
6271
|
cursorChecker() {
|
|
6268
6272
|
return editor.isEditable() ? "ew-resize" : "default";
|
|
@@ -35228,11 +35232,15 @@ const CodeBlockExtension = () => Extension.create({
|
|
|
35228
35232
|
tag: "pre"
|
|
35229
35233
|
});
|
|
35230
35234
|
if (!!codeBlockNode && this.selection.start.node.isText()) {
|
|
35231
|
-
const
|
|
35232
|
-
const
|
|
35233
|
-
const
|
|
35234
|
-
|
|
35235
|
-
|
|
35235
|
+
const index = this.selection.start.offset === 0 ? 0 : this.selection.start.offset - 1;
|
|
35236
|
+
const textContent = this.selection.start.node.textContent;
|
|
35237
|
+
const currentChar = textContent.charAt(index);
|
|
35238
|
+
const p1Char = index - 1 >= 0 ? textContent.charAt(index - 1) : null;
|
|
35239
|
+
const p2Char = index - 2 >= 0 ? textContent.charAt(index - 2) : null;
|
|
35240
|
+
const isLastChar = index === textContent.length - 1;
|
|
35241
|
+
const isLastText = this.selection.start.node.lastInTargetNode(codeBlockNode);
|
|
35242
|
+
if (currentChar === "\n" && p1Char !== null && p2Char !== null && isZeroWidthText(p1Char) && p2Char === "\n" && isLastChar && isLastText) {
|
|
35243
|
+
this.selection.start.node.textContent = this.selection.start.node.textContent.slice(0, index - 2);
|
|
35236
35244
|
const paragraph = KNode.create({
|
|
35237
35245
|
type: "block",
|
|
35238
35246
|
tag: this.blockRenderTag,
|
|
@@ -35829,6 +35837,8 @@ const tableResizable = (editor) => {
|
|
|
35829
35837
|
enabled: true,
|
|
35830
35838
|
//指定可以调整大小的边缘
|
|
35831
35839
|
edges: { left: false, right: true, bottom: false, top: false },
|
|
35840
|
+
//设置可拖拽区域宽度
|
|
35841
|
+
margin: 5,
|
|
35832
35842
|
//设置鼠标样式
|
|
35833
35843
|
cursorChecker(_action, _interactable, element2, _interacting) {
|
|
35834
35844
|
return editor.isEditable() && element2.nextElementSibling ? "ew-resize" : "default";
|
|
@@ -38166,7 +38176,6 @@ class Editor {
|
|
|
38166
38176
|
await delay();
|
|
38167
38177
|
this.internalCauseSelectionChange = false;
|
|
38168
38178
|
this.scrollViewToSelection();
|
|
38169
|
-
this.history.updateSelection(this.selection);
|
|
38170
38179
|
if (typeof this.onSelectionUpdate == "function") {
|
|
38171
38180
|
this.onSelectionUpdate.apply(this, [this.selection]);
|
|
38172
38181
|
}
|
|
@@ -38201,13 +38210,20 @@ class Editor {
|
|
|
38201
38210
|
event.off(this.$el, "beforeinput.kaitify compositionstart.kaitify compositionupdate.kaitify compositionend.kaitify keydown.kaitify keyup.kaitify copy.kaitify focus.kaitify blur.kaitify");
|
|
38202
38211
|
}
|
|
38203
38212
|
/**
|
|
38204
|
-
*
|
|
38213
|
+
* 获取编辑器的纯文本内容,excludeBreak表示是否排除换行符\n,excludeZeroWidthText表示是否排除零宽度空白字符
|
|
38205
38214
|
*/
|
|
38206
|
-
getContent() {
|
|
38215
|
+
getContent(excludeBreak = false, excludeZeroWidthText = false) {
|
|
38207
38216
|
if (!this.$el) {
|
|
38208
38217
|
return "";
|
|
38209
38218
|
}
|
|
38210
|
-
|
|
38219
|
+
let text2 = this.$el.textContent ?? "";
|
|
38220
|
+
if (excludeBreak) {
|
|
38221
|
+
text2 = text2.split("\n").join("");
|
|
38222
|
+
}
|
|
38223
|
+
if (excludeZeroWidthText) {
|
|
38224
|
+
text2 = text2.split(getZeroWidthText()).join("");
|
|
38225
|
+
}
|
|
38226
|
+
return text2;
|
|
38211
38227
|
}
|
|
38212
38228
|
/**
|
|
38213
38229
|
* 获取编辑器的html内容,该方法会返回一个包含style标签和div标签的html内容。自行展示html内容时可保证样式与编辑器一致,但是对于附件等有交互事件的元素交互事件会失效
|