@ones-editor/editor 1.0.2-beta.14 → 1.0.2-beta.16
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/@ones-editor/context-menu/src/helper/actions.d.ts +4 -4
- package/@ones-editor/context-menu/src/menu/index.d.ts +0 -3
- package/@ones-editor/core/src/core/composition/clipboard/copy.d.ts +1 -6
- package/@ones-editor/core/src/core/index.d.ts +0 -1
- package/@ones-editor/core/src/core/input-handler/input-handler.d.ts +1 -0
- package/@ones-editor/core/src/core/keyboard/default-shortcuts.d.ts +2 -1
- package/@ones-editor/core/src/utils/blob-to-string.d.ts +1 -0
- package/@ones-editor/core/src/utils/index.d.ts +1 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +208 -205
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8334,6 +8334,19 @@ var __publicField = (obj, key, value) => {
|
|
|
8334
8334
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
8335
8335
|
return ColorNames[colorIndex];
|
|
8336
8336
|
}
|
|
8337
|
+
function blob2String(blob) {
|
|
8338
|
+
return new Promise((resolve, reject) => {
|
|
8339
|
+
const reader = new FileReader();
|
|
8340
|
+
reader.onload = () => {
|
|
8341
|
+
const result = reader.result;
|
|
8342
|
+
resolve(result);
|
|
8343
|
+
};
|
|
8344
|
+
reader.onerror = () => {
|
|
8345
|
+
reject(new Error("Failed to read Blob as string."));
|
|
8346
|
+
};
|
|
8347
|
+
reader.readAsText(blob);
|
|
8348
|
+
});
|
|
8349
|
+
}
|
|
8337
8350
|
const logger$43 = getLogger("container-children");
|
|
8338
8351
|
function getChildBlocks(container) {
|
|
8339
8352
|
const blocks = Array.from(container.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));
|
|
@@ -22901,8 +22914,8 @@ var __publicField = (obj, key, value) => {
|
|
|
22901
22914
|
to = getNextValidOffset(block, to);
|
|
22902
22915
|
}
|
|
22903
22916
|
const deleteCount = to - from;
|
|
22904
|
-
const
|
|
22905
|
-
editor.doc.localUpdateBlockText(containerId, blockIndex,
|
|
22917
|
+
const actions2 = createDeleteOps(from, deleteCount);
|
|
22918
|
+
editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
|
|
22906
22919
|
console.log("delete");
|
|
22907
22920
|
return deleteCount;
|
|
22908
22921
|
}
|
|
@@ -25254,33 +25267,34 @@ var __publicField = (obj, key, value) => {
|
|
|
25254
25267
|
event.clipboardData.setData("text/plain", text2);
|
|
25255
25268
|
event.clipboardData.setData("text/x-ones-editor-doc", JSON.stringify(doc2));
|
|
25256
25269
|
}
|
|
25257
|
-
function editorCopyWithoutEvent(editor
|
|
25258
|
-
copyAsMarkdown: false,
|
|
25259
|
-
beforeCopy: void 0
|
|
25260
|
-
}) {
|
|
25261
|
-
var _a;
|
|
25270
|
+
function editorCopyWithoutEvent(editor) {
|
|
25262
25271
|
if (editor.selection.range.isCollapsed()) {
|
|
25263
25272
|
return;
|
|
25264
25273
|
}
|
|
25265
25274
|
let doc2 = selectionToDoc$1(editor);
|
|
25266
|
-
|
|
25267
|
-
|
|
25268
|
-
|
|
25269
|
-
|
|
25270
|
-
|
|
25271
|
-
|
|
25272
|
-
|
|
25275
|
+
editor.input.callbacks.forEach((handler) => {
|
|
25276
|
+
if (handler.handleBeforeCopy) {
|
|
25277
|
+
const ret2 = handler.handleBeforeCopy(editor, new ClipboardEvent("mock-event"), doc2);
|
|
25278
|
+
if (ret2 === true) {
|
|
25279
|
+
return true;
|
|
25280
|
+
}
|
|
25281
|
+
if (typeof ret2 === "object" && ret2 != null) {
|
|
25282
|
+
return ret2;
|
|
25283
|
+
}
|
|
25284
|
+
return false;
|
|
25285
|
+
}
|
|
25286
|
+
return false;
|
|
25287
|
+
});
|
|
25273
25288
|
addMetaToDoc(editor, doc2);
|
|
25274
25289
|
const htmlFragment = docToHtmlFragment(editor, doc2);
|
|
25275
25290
|
const html = injectDocToHtmlFragment(htmlFragment, doc2);
|
|
25276
25291
|
const text2 = docToText(editor, doc2);
|
|
25277
|
-
const markdown = docToMarkdown(editor, doc2);
|
|
25278
25292
|
const blob = new Blob([html], {
|
|
25279
25293
|
type: "text/html"
|
|
25280
25294
|
});
|
|
25281
25295
|
setClipboardData([{
|
|
25282
25296
|
type: "text/plain",
|
|
25283
|
-
data: new Blob([
|
|
25297
|
+
data: new Blob([text2], { type: "text/plain" })
|
|
25284
25298
|
}, {
|
|
25285
25299
|
type: "text/html",
|
|
25286
25300
|
data: blob
|
|
@@ -25354,14 +25368,35 @@ var __publicField = (obj, key, value) => {
|
|
|
25354
25368
|
return true;
|
|
25355
25369
|
}
|
|
25356
25370
|
function editorHandleCopyMarkdown(editor) {
|
|
25357
|
-
if (editor.readonly || !editor.isWritable() || !window.isSecureContext) {
|
|
25371
|
+
if (editor.readonly || !editor.isWritable() || !window.isSecureContext || editor.selection.range.isCollapsed()) {
|
|
25358
25372
|
return false;
|
|
25359
25373
|
}
|
|
25360
|
-
|
|
25361
|
-
|
|
25374
|
+
const doc2 = selectionToDoc$1(editor);
|
|
25375
|
+
addMetaToDoc(editor, doc2);
|
|
25376
|
+
const htmlFragment = docToHtmlFragment(editor, doc2);
|
|
25377
|
+
const html = injectDocToHtmlFragment(htmlFragment, doc2);
|
|
25378
|
+
const markdown = docToMarkdown(editor, doc2);
|
|
25379
|
+
const blob = new Blob([html], {
|
|
25380
|
+
type: "text/html"
|
|
25362
25381
|
});
|
|
25382
|
+
setClipboardData([{
|
|
25383
|
+
type: "text/plain",
|
|
25384
|
+
data: new Blob([markdown], { type: "text/plain" })
|
|
25385
|
+
}, {
|
|
25386
|
+
type: "text/html",
|
|
25387
|
+
data: blob
|
|
25388
|
+
}]);
|
|
25363
25389
|
return true;
|
|
25364
25390
|
}
|
|
25391
|
+
const actions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
25392
|
+
__proto__: null,
|
|
25393
|
+
editorHandleEnter,
|
|
25394
|
+
editorHandleDelete,
|
|
25395
|
+
editorHandleBackspace,
|
|
25396
|
+
editorHandleInsertBr,
|
|
25397
|
+
editorHandlePastePlainText,
|
|
25398
|
+
editorHandleCopyMarkdown
|
|
25399
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
25365
25400
|
const DefaultShortcuts = {
|
|
25366
25401
|
"ArrowDown": editorMoveDown,
|
|
25367
25402
|
"ArrowUp": editorMoveUp,
|
|
@@ -25682,6 +25717,14 @@ var __publicField = (obj, key, value) => {
|
|
|
25682
25717
|
event.preventDefault();
|
|
25683
25718
|
event.stopPropagation();
|
|
25684
25719
|
if (!event.clipboardData) {
|
|
25720
|
+
this.getClipboardData().then((clipboardData) => {
|
|
25721
|
+
const docPromise2 = this.editor.dataConverter.fromData(this.editor, clipboardData);
|
|
25722
|
+
docPromise2.then(async (docs) => {
|
|
25723
|
+
if (docs) {
|
|
25724
|
+
this.pasteDocs(docs, event, []);
|
|
25725
|
+
}
|
|
25726
|
+
});
|
|
25727
|
+
});
|
|
25685
25728
|
return;
|
|
25686
25729
|
}
|
|
25687
25730
|
const docPromise = this.editor.dataConverter.fromData(this.editor, event.clipboardData);
|
|
@@ -25819,6 +25862,19 @@ var __publicField = (obj, key, value) => {
|
|
|
25819
25862
|
forEach(cb) {
|
|
25820
25863
|
this.handlers.forEach(cb);
|
|
25821
25864
|
}
|
|
25865
|
+
async getClipboardData() {
|
|
25866
|
+
const clipboardItems = await navigator.clipboard.read();
|
|
25867
|
+
const clipboardItem = clipboardItems[0];
|
|
25868
|
+
const types2 = clipboardItem.types;
|
|
25869
|
+
const dataTransfer = new DataTransfer();
|
|
25870
|
+
for (let i = 0; i < types2.length; i++) {
|
|
25871
|
+
const type = types2[i];
|
|
25872
|
+
const data = await clipboardItem.getType(type);
|
|
25873
|
+
const str = await blob2String(data);
|
|
25874
|
+
dataTransfer.setData(type, str);
|
|
25875
|
+
}
|
|
25876
|
+
return dataTransfer;
|
|
25877
|
+
}
|
|
25822
25878
|
}
|
|
25823
25879
|
function removeBlock(editor, container, blockIndex) {
|
|
25824
25880
|
const block = getBlockByIndex(container, blockIndex);
|
|
@@ -26019,14 +26075,14 @@ var __publicField = (obj, key, value) => {
|
|
|
26019
26075
|
return createEditorSelectionRange(editor, { anchor: newAnchor, focus: newFocus });
|
|
26020
26076
|
}
|
|
26021
26077
|
const logger$2E = getLogger("handle-block-text-changed");
|
|
26022
|
-
function onBlockTextChanged(editor, containerId, blockIndex,
|
|
26078
|
+
function onBlockTextChanged(editor, containerId, blockIndex, actions2, local) {
|
|
26023
26079
|
const container = editor.getContainerById(containerId);
|
|
26024
26080
|
const block = getBlockByIndex(container, blockIndex);
|
|
26025
26081
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26026
26082
|
assert(logger$2E, blockData.text, "no block text");
|
|
26027
26083
|
getTextBlockClass(editor, block).setBlockText(editor, block, blockData.text);
|
|
26028
26084
|
if (!local) {
|
|
26029
|
-
const newRange = transformSelection(editor, blockData.id,
|
|
26085
|
+
const newRange = transformSelection(editor, blockData.id, actions2, local);
|
|
26030
26086
|
editor.selection.setRange(newRange, { noScroll: true });
|
|
26031
26087
|
}
|
|
26032
26088
|
}
|
|
@@ -26096,16 +26152,16 @@ var __publicField = (obj, key, value) => {
|
|
|
26096
26152
|
const block = this.editor.getBlockByIndex(containerId, blockIndex);
|
|
26097
26153
|
assert(logger$2D, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
|
|
26098
26154
|
}
|
|
26099
|
-
localUpdateBlockText(containerId, blockIndex,
|
|
26155
|
+
localUpdateBlockText(containerId, blockIndex, actions2, options) {
|
|
26100
26156
|
assert(logger$2D, !this.editor.readonly, "editor is readonly");
|
|
26101
26157
|
this.verifyBlockWritable(containerId, blockIndex);
|
|
26102
26158
|
const blockData = this.getBlockData(containerId, blockIndex);
|
|
26103
26159
|
const oldText = blockData.text;
|
|
26104
26160
|
assert(logger$2D, oldText, `no text, ${containerId}, ${blockIndex}`);
|
|
26105
|
-
const newRange = transformSelection(this.editor, blockData.id,
|
|
26106
|
-
const newText = RichText.apply(oldText,
|
|
26161
|
+
const newRange = transformSelection(this.editor, blockData.id, actions2, true);
|
|
26162
|
+
const newText = RichText.apply(oldText, actions2);
|
|
26107
26163
|
this.localEvents.forEach((event) => event.onBeforeUpdateBlockText(containerId, blockData.id, oldText, newText, newRange.toDocRange()));
|
|
26108
|
-
const ret = this.externalDoc.localUpdateBlockText(containerId, blockIndex,
|
|
26164
|
+
const ret = this.externalDoc.localUpdateBlockText(containerId, blockIndex, actions2);
|
|
26109
26165
|
this.editor.selection.setRange(newRange, options);
|
|
26110
26166
|
return ret;
|
|
26111
26167
|
}
|
|
@@ -26170,12 +26226,12 @@ var __publicField = (obj, key, value) => {
|
|
|
26170
26226
|
const local = false;
|
|
26171
26227
|
this.editor.emit("docChanged", this.editor, local);
|
|
26172
26228
|
}
|
|
26173
|
-
onUpdateBlockText(containerId, blockIndex,
|
|
26229
|
+
onUpdateBlockText(containerId, blockIndex, actions2, local) {
|
|
26174
26230
|
this.callbacks.forEach((c) => {
|
|
26175
26231
|
var _a;
|
|
26176
|
-
return (_a = c.onUpdateBlockText) == null ? void 0 : _a.call(c, containerId, blockIndex,
|
|
26232
|
+
return (_a = c.onUpdateBlockText) == null ? void 0 : _a.call(c, containerId, blockIndex, actions2, local);
|
|
26177
26233
|
});
|
|
26178
|
-
onBlockTextChanged(this.editor, containerId, blockIndex,
|
|
26234
|
+
onBlockTextChanged(this.editor, containerId, blockIndex, actions2, local);
|
|
26179
26235
|
this.editor.emit("docChanged", this.editor, local);
|
|
26180
26236
|
}
|
|
26181
26237
|
onUpdateBlockData(containerId, blockIndex, delta, local) {
|
|
@@ -26271,14 +26327,14 @@ var __publicField = (obj, key, value) => {
|
|
|
26271
26327
|
this.editor.reload();
|
|
26272
26328
|
}
|
|
26273
26329
|
}
|
|
26274
|
-
function addActions(
|
|
26275
|
-
if (
|
|
26276
|
-
|
|
26330
|
+
function addActions(actions2, action) {
|
|
26331
|
+
if (actions2.length === 0) {
|
|
26332
|
+
actions2.push(action);
|
|
26277
26333
|
return;
|
|
26278
26334
|
}
|
|
26279
|
-
const last =
|
|
26335
|
+
const last = actions2[actions2.length - 1];
|
|
26280
26336
|
if (!last.combinable(action)) {
|
|
26281
|
-
|
|
26337
|
+
actions2.push(action);
|
|
26282
26338
|
return;
|
|
26283
26339
|
}
|
|
26284
26340
|
last.combine(action);
|
|
@@ -27813,7 +27869,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27813
27869
|
return ret;
|
|
27814
27870
|
});
|
|
27815
27871
|
}
|
|
27816
|
-
onUpdateBlockText(blockData,
|
|
27872
|
+
onUpdateBlockText(blockData, actions2, local) {
|
|
27817
27873
|
const text2 = blockData.text;
|
|
27818
27874
|
if (!text2) {
|
|
27819
27875
|
return;
|
|
@@ -27823,10 +27879,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27823
27879
|
if (isSimpleRange(cursor.range)) {
|
|
27824
27880
|
const { anchor: anchor2, focus } = cursor.range;
|
|
27825
27881
|
if (anchor2.blockId === blockData.id) {
|
|
27826
|
-
anchor2.offset = RichText.transformCursor(anchor2.offset,
|
|
27882
|
+
anchor2.offset = RichText.transformCursor(anchor2.offset, actions2, local);
|
|
27827
27883
|
}
|
|
27828
27884
|
if (focus.blockId === blockData.id) {
|
|
27829
|
-
focus.offset = RichText.transformCursor(focus.offset,
|
|
27885
|
+
focus.offset = RichText.transformCursor(focus.offset, actions2, local);
|
|
27830
27886
|
}
|
|
27831
27887
|
}
|
|
27832
27888
|
});
|
|
@@ -27888,15 +27944,15 @@ var __publicField = (obj, key, value) => {
|
|
|
27888
27944
|
assert(logger$2r, blockData, `no block data: ${blockIndex}`);
|
|
27889
27945
|
return blockData;
|
|
27890
27946
|
}
|
|
27891
|
-
localUpdateBlockText(containerId, blockIndex,
|
|
27947
|
+
localUpdateBlockText(containerId, blockIndex, actions2) {
|
|
27892
27948
|
const blockData = this.getBlockData(containerId, blockIndex);
|
|
27893
27949
|
assert(logger$2r, blockData.text, "no text for data");
|
|
27894
|
-
const newText = RichText.apply(blockData.text,
|
|
27950
|
+
const newText = RichText.apply(blockData.text, actions2);
|
|
27895
27951
|
blockData.text = newText;
|
|
27896
27952
|
assert(logger$2r, this.callbacks.length > 0, "no callbacks");
|
|
27897
27953
|
this.callbacks.forEach((cb) => {
|
|
27898
27954
|
var _a;
|
|
27899
|
-
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, containerId, blockIndex,
|
|
27955
|
+
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, containerId, blockIndex, actions2, true);
|
|
27900
27956
|
});
|
|
27901
27957
|
return newText;
|
|
27902
27958
|
}
|
|
@@ -32972,10 +33028,10 @@ var __publicField = (obj, key, value) => {
|
|
|
32972
33028
|
Connection$1.prototype.endBulk = function() {
|
|
32973
33029
|
if (this.bulk) {
|
|
32974
33030
|
for (var collection in this.bulk) {
|
|
32975
|
-
var
|
|
32976
|
-
this._sendBulk("f", collection,
|
|
32977
|
-
this._sendBulk("s", collection,
|
|
32978
|
-
this._sendBulk("u", collection,
|
|
33031
|
+
var actions2 = this.bulk[collection];
|
|
33032
|
+
this._sendBulk("f", collection, actions2.f);
|
|
33033
|
+
this._sendBulk("s", collection, actions2.s);
|
|
33034
|
+
this._sendBulk("u", collection, actions2.u);
|
|
32979
33035
|
}
|
|
32980
33036
|
}
|
|
32981
33037
|
this.bulk = null;
|
|
@@ -33013,8 +33069,8 @@ var __publicField = (obj, key, value) => {
|
|
|
33013
33069
|
Connection$1.prototype._sendActions = function(action, doc2, version) {
|
|
33014
33070
|
this._addDoc(doc2);
|
|
33015
33071
|
if (this.bulk) {
|
|
33016
|
-
var
|
|
33017
|
-
var versions =
|
|
33072
|
+
var actions2 = this.bulk[doc2.collection] || (this.bulk[doc2.collection] = {});
|
|
33073
|
+
var versions = actions2[action] || (actions2[action] = {});
|
|
33018
33074
|
var isDuplicate = versions.hasOwnProperty(doc2.id);
|
|
33019
33075
|
versions[doc2.id] = version;
|
|
33020
33076
|
return isDuplicate;
|
|
@@ -34113,11 +34169,11 @@ var __publicField = (obj, key, value) => {
|
|
|
34113
34169
|
});
|
|
34114
34170
|
}
|
|
34115
34171
|
end() {
|
|
34116
|
-
const
|
|
34172
|
+
const actions2 = this.actions;
|
|
34117
34173
|
const deletedBlocks = /* @__PURE__ */ new Set();
|
|
34118
34174
|
const updatingBlockDataDeltaMap = /* @__PURE__ */ new Map();
|
|
34119
34175
|
const blockIds = new ContainerBlockIds();
|
|
34120
|
-
const deleteActions =
|
|
34176
|
+
const deleteActions = actions2.filter((action) => action.type === "deleteBlock" || action.type === "deleteBlockData");
|
|
34121
34177
|
for (const action of deleteActions) {
|
|
34122
34178
|
if (action.type === "deleteBlock") {
|
|
34123
34179
|
const a = action;
|
|
@@ -34359,21 +34415,21 @@ var __publicField = (obj, key, value) => {
|
|
|
34359
34415
|
}
|
|
34360
34416
|
function parseCommentsOp(ops, parseType, handler) {
|
|
34361
34417
|
const commentId = ops[1];
|
|
34362
|
-
const
|
|
34418
|
+
const actions2 = ops[2];
|
|
34363
34419
|
assert(logger$2g, commentId, `invalid comment op, no commentId: ${JSON.stringify(ops)}`);
|
|
34364
|
-
assert(logger$2g,
|
|
34365
|
-
if (typeof
|
|
34420
|
+
assert(logger$2g, actions2, `invalid comment op, no actions: ${JSON.stringify(ops)}`);
|
|
34421
|
+
if (typeof actions2 === "string") {
|
|
34366
34422
|
logger$2g.error(`unknown comment op, ${JSON.stringify(ops)}`);
|
|
34367
34423
|
} else {
|
|
34368
|
-
if (
|
|
34424
|
+
if (actions2.i && actions2.r) {
|
|
34369
34425
|
if (parseType === "upsert") {
|
|
34370
34426
|
handler.onUpdateComment(commentId);
|
|
34371
34427
|
}
|
|
34372
|
-
} else if (
|
|
34428
|
+
} else if (actions2.i) {
|
|
34373
34429
|
if (parseType === "upsert") {
|
|
34374
34430
|
handler.onCreateComment(commentId);
|
|
34375
34431
|
}
|
|
34376
|
-
} else if (
|
|
34432
|
+
} else if (actions2.r) {
|
|
34377
34433
|
if (parseType === "remove") {
|
|
34378
34434
|
handler.onDeleteComment(commentId);
|
|
34379
34435
|
}
|
|
@@ -34827,12 +34883,12 @@ var __publicField = (obj, key, value) => {
|
|
|
34827
34883
|
this.submitDeleteBlock(containerId, blockIndex);
|
|
34828
34884
|
return oldData;
|
|
34829
34885
|
}
|
|
34830
|
-
localUpdateBlockText(containerId, blockIndex,
|
|
34886
|
+
localUpdateBlockText(containerId, blockIndex, actions2) {
|
|
34831
34887
|
const oldBlockData = this.getBlockData(containerId, blockIndex);
|
|
34832
34888
|
assert(logger$2e, oldBlockData.text, "no block text");
|
|
34833
34889
|
const oldText = cloneDeep__default.default(oldBlockData.text);
|
|
34834
|
-
this.submitUpdateRichText(containerId, blockIndex,
|
|
34835
|
-
const newText = RichText.apply(oldText,
|
|
34890
|
+
this.submitUpdateRichText(containerId, blockIndex, actions2);
|
|
34891
|
+
const newText = RichText.apply(oldText, actions2);
|
|
34836
34892
|
assert(logger$2e, newText, "no block text");
|
|
34837
34893
|
return newText;
|
|
34838
34894
|
}
|
|
@@ -34910,11 +34966,11 @@ var __publicField = (obj, key, value) => {
|
|
|
34910
34966
|
return (_a = cb.onUpdateBlockData) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, delta, local);
|
|
34911
34967
|
});
|
|
34912
34968
|
}
|
|
34913
|
-
onUpdateBlockText(containerId, blockIndex,
|
|
34969
|
+
onUpdateBlockText(containerId, blockIndex, actions2, local) {
|
|
34914
34970
|
assert(logger$2e, this.callbacks.length > 0, "no callbacks");
|
|
34915
34971
|
this.callbacks.forEach((cb) => {
|
|
34916
34972
|
var _a;
|
|
34917
|
-
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex,
|
|
34973
|
+
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, actions2, local);
|
|
34918
34974
|
});
|
|
34919
34975
|
}
|
|
34920
34976
|
onDeleteContainer(containerId, local) {
|
|
@@ -56184,7 +56240,7 @@ ${codeText}
|
|
|
56184
56240
|
super();
|
|
56185
56241
|
this.editor = editor;
|
|
56186
56242
|
}
|
|
56187
|
-
onUpdateBlockText(containerId, blockIndex,
|
|
56243
|
+
onUpdateBlockText(containerId, blockIndex, actions2) {
|
|
56188
56244
|
const findDialog = this.editor.getCustom("find-dialog");
|
|
56189
56245
|
if (!findDialog || !findDialog.isVisible()) {
|
|
56190
56246
|
return;
|
|
@@ -56193,7 +56249,7 @@ ${codeText}
|
|
|
56193
56249
|
if (!isTextKindBlock(this.editor, block)) {
|
|
56194
56250
|
return;
|
|
56195
56251
|
}
|
|
56196
|
-
const hasContentChanged =
|
|
56252
|
+
const hasContentChanged = actions2.some((action) => action.insert || action.delete);
|
|
56197
56253
|
if (!hasContentChanged) {
|
|
56198
56254
|
return;
|
|
56199
56255
|
}
|
|
@@ -56995,19 +57051,6 @@ ${codeText}
|
|
|
56995
57051
|
handleFindReplace(editor);
|
|
56996
57052
|
}
|
|
56997
57053
|
const logger$H = getLogger("context-menu-utils");
|
|
56998
|
-
function blobToString(blob) {
|
|
56999
|
-
return new Promise((resolve, reject) => {
|
|
57000
|
-
const reader = new FileReader();
|
|
57001
|
-
reader.onload = () => {
|
|
57002
|
-
const result = reader.result;
|
|
57003
|
-
resolve(result);
|
|
57004
|
-
};
|
|
57005
|
-
reader.onerror = () => {
|
|
57006
|
-
reject(new Error("Failed to read Blob as string."));
|
|
57007
|
-
};
|
|
57008
|
-
reader.readAsText(blob);
|
|
57009
|
-
});
|
|
57010
|
-
}
|
|
57011
57054
|
async function isClipboardEmpty() {
|
|
57012
57055
|
try {
|
|
57013
57056
|
const data = await navigator.clipboard.readText();
|
|
@@ -57029,53 +57072,18 @@ ${codeText}
|
|
|
57029
57072
|
anchor2.click();
|
|
57030
57073
|
}
|
|
57031
57074
|
}
|
|
57032
|
-
async function handleCopyAction(editor
|
|
57033
|
-
editorCopyWithoutEvent(editor
|
|
57034
|
-
copyAsMarkdown: id === "copy-markdown",
|
|
57035
|
-
beforeCopy: (editor2, event, doc2) => {
|
|
57036
|
-
if (!inputHandlers) {
|
|
57037
|
-
return void 0;
|
|
57038
|
-
}
|
|
57039
|
-
for (let i = 0; i < inputHandlers.handlers.length; i++) {
|
|
57040
|
-
const handler = inputHandlers.handlers[i];
|
|
57041
|
-
if (handler.handleBeforeCopy) {
|
|
57042
|
-
const ret = handler.handleBeforeCopy(editor2, event, doc2);
|
|
57043
|
-
if (ret === true) {
|
|
57044
|
-
return true;
|
|
57045
|
-
}
|
|
57046
|
-
if (typeof ret === "object" && ret != null) {
|
|
57047
|
-
return ret;
|
|
57048
|
-
}
|
|
57049
|
-
}
|
|
57050
|
-
}
|
|
57051
|
-
return void 0;
|
|
57052
|
-
}
|
|
57053
|
-
});
|
|
57054
|
-
}
|
|
57055
|
-
async function handleCutAction(editor, inputHandlers) {
|
|
57056
|
-
handleCopyAction(editor, inputHandlers, "copy");
|
|
57057
|
-
editorClearSelectedContents(editor);
|
|
57075
|
+
async function handleCopyAction(editor) {
|
|
57076
|
+
editorCopyWithoutEvent(editor);
|
|
57058
57077
|
}
|
|
57059
|
-
async function
|
|
57060
|
-
|
|
57061
|
-
|
|
57062
|
-
const clipboardItem = clipboardItems[0];
|
|
57063
|
-
const types2 = clipboardItem.types;
|
|
57064
|
-
const dataTransfer = new DataTransfer();
|
|
57065
|
-
for (let i = 0; i < types2.length; i++) {
|
|
57066
|
-
const type = types2[i];
|
|
57067
|
-
const data = await clipboardItem.getType(type);
|
|
57068
|
-
const str = await blobToString(data);
|
|
57069
|
-
dataTransfer.setData(type, str);
|
|
57070
|
-
}
|
|
57071
|
-
const docPromise = editor.dataConverter.fromData(editor, dataTransfer);
|
|
57072
|
-
docPromise.then(async (docs) => {
|
|
57073
|
-
if (docs && inputHandlers) {
|
|
57074
|
-
inputHandlers.pasteDocs(docs, null, []);
|
|
57075
|
-
}
|
|
57076
|
-
});
|
|
57077
|
-
} catch (error2) {
|
|
57078
|
+
async function handleCopyMarkdownAction(editor) {
|
|
57079
|
+
if (editor.selection.range.isCollapsed()) {
|
|
57080
|
+
return;
|
|
57078
57081
|
}
|
|
57082
|
+
editorHandleCopyMarkdown(editor);
|
|
57083
|
+
}
|
|
57084
|
+
async function handleCutAction(editor) {
|
|
57085
|
+
handleCopyAction(editor);
|
|
57086
|
+
editorClearSelectedContents(editor);
|
|
57079
57087
|
}
|
|
57080
57088
|
class ContextMenuCommandItems {
|
|
57081
57089
|
constructor(editor) {
|
|
@@ -57297,12 +57305,12 @@ ${codeText}
|
|
|
57297
57305
|
constructor(editor) {
|
|
57298
57306
|
__publicField(this, "contextMenu");
|
|
57299
57307
|
__publicField(this, "contextMenuCommandItems");
|
|
57300
|
-
__publicField(this, "contextMenuInputHandlers", null);
|
|
57301
57308
|
__publicField(this, "updateEditorCaret", (event) => {
|
|
57302
57309
|
const { x, y } = event;
|
|
57303
57310
|
const nextRange = getBlockNearestRangeFromPoint(this.editor, x, y);
|
|
57304
57311
|
const oldRange = this.editor.selection.range;
|
|
57305
|
-
|
|
57312
|
+
const selectBlocks = oldRange.getSelectedBlocks();
|
|
57313
|
+
if (oldRange.focus.blockId !== (nextRange == null ? void 0 : nextRange.focus.blockId) && !(selectBlocks == null ? void 0 : selectBlocks.some((block) => block.block.id !== oldRange.focus.blockId))) {
|
|
57306
57314
|
this.editor.selectionHandler.handleMouseDown(event, { autoScroll: false });
|
|
57307
57315
|
}
|
|
57308
57316
|
});
|
|
@@ -57341,8 +57349,8 @@ ${codeText}
|
|
|
57341
57349
|
return isCursorInEditor && (this.isInMenu(event) || isTargetInRootContainer);
|
|
57342
57350
|
});
|
|
57343
57351
|
__publicField(this, "handleContextMenuShown", async () => {
|
|
57344
|
-
|
|
57345
|
-
|
|
57352
|
+
if (this.editor.findCustom("toolbar-handler")) {
|
|
57353
|
+
const editorToolBar = this.editor.getCustom("toolbar-handler");
|
|
57346
57354
|
editorToolBar.hide();
|
|
57347
57355
|
}
|
|
57348
57356
|
const items = await this.contextMenuCommandItems.getCommandItems();
|
|
@@ -57355,17 +57363,19 @@ ${codeText}
|
|
|
57355
57363
|
const { id } = item;
|
|
57356
57364
|
switch (id) {
|
|
57357
57365
|
case "copy":
|
|
57366
|
+
handleCopyAction(this.editor);
|
|
57367
|
+
break;
|
|
57358
57368
|
case "copy-markdown":
|
|
57359
|
-
|
|
57369
|
+
handleCopyMarkdownAction(this.editor);
|
|
57360
57370
|
break;
|
|
57361
57371
|
case "cut":
|
|
57362
57372
|
if (this.handleImageEmbedAction(id)) {
|
|
57363
57373
|
break;
|
|
57364
57374
|
}
|
|
57365
|
-
handleCutAction(this.editor
|
|
57375
|
+
handleCutAction(this.editor);
|
|
57366
57376
|
break;
|
|
57367
57377
|
case "paste":
|
|
57368
|
-
|
|
57378
|
+
this.editor.input.callbacks.onPaste(new ClipboardEvent("mock-paste-event"));
|
|
57369
57379
|
break;
|
|
57370
57380
|
case "copy-image":
|
|
57371
57381
|
case "copy-image-url":
|
|
@@ -57391,7 +57401,6 @@ ${codeText}
|
|
|
57391
57401
|
document.addEventListener("contextmenu", this.handleContextMenu);
|
|
57392
57402
|
this.contextMenuCommandItems = new ContextMenuCommandItems(editor);
|
|
57393
57403
|
editor.addListener("destroy", this.destroy);
|
|
57394
|
-
this.initInputHandlers();
|
|
57395
57404
|
}
|
|
57396
57405
|
destroy() {
|
|
57397
57406
|
this.contextMenuCommandItems.destroy();
|
|
@@ -57409,16 +57418,6 @@ ${codeText}
|
|
|
57409
57418
|
}
|
|
57410
57419
|
});
|
|
57411
57420
|
}
|
|
57412
|
-
initInputHandlers() {
|
|
57413
|
-
this.contextMenuInputHandlers = new EditorInputHandlers(this.editor);
|
|
57414
|
-
const editorInputHandlers = this.editor.input.callbacks;
|
|
57415
|
-
editorInputHandlers.forEach((handler) => {
|
|
57416
|
-
if (this.contextMenuInputHandlers) {
|
|
57417
|
-
this.contextMenuInputHandlers.addHandler(handler);
|
|
57418
|
-
}
|
|
57419
|
-
});
|
|
57420
|
-
this.contextMenuInputHandlers.addHandler(new CopyCodeInputHandler());
|
|
57421
|
-
}
|
|
57422
57421
|
handleImageEmbedAction(operation) {
|
|
57423
57422
|
const focusedBlock = this.editor.selection.focusedBlock;
|
|
57424
57423
|
if (isEmbedBlock(focusedBlock) && getEmbedType(focusedBlock) === "image") {
|
|
@@ -57467,33 +57466,33 @@ ${codeText}
|
|
|
57467
57466
|
newTabOpenImage: "\u65B0\u6807\u7B7E\u9875\u6253\u5F00\u56FE\u7247",
|
|
57468
57467
|
selectBlock: "\u9009\u4E2D\u533A\u5757",
|
|
57469
57468
|
selectAll: "\u9009\u4E2D\u5168\u6587",
|
|
57470
|
-
uneditableBlockSelected: "\
|
|
57469
|
+
uneditableBlockSelected: "\u9009\u4E2D\u533A\u57DF\u5305\u542B\u9501\u5B9A\u533A\u5757\uFF0C\u6682\u4E0D\u652F\u6301\u526A\u5207"
|
|
57471
57470
|
}
|
|
57472
57471
|
};
|
|
57473
57472
|
const enUS$f = {
|
|
57474
57473
|
contextMenu: {
|
|
57475
|
-
copyMarkdown: "
|
|
57474
|
+
copyMarkdown: "Copy as Markdown",
|
|
57476
57475
|
paste: "paste",
|
|
57477
|
-
copyImage: "
|
|
57478
|
-
copyImageUrl: "
|
|
57479
|
-
imageSaveAs: "
|
|
57480
|
-
newTabOpenImage: "
|
|
57481
|
-
selectBlock: "
|
|
57482
|
-
selectAll: "
|
|
57476
|
+
copyImage: "Copy image",
|
|
57477
|
+
copyImageUrl: "Copy image address",
|
|
57478
|
+
imageSaveAs: "Save image as",
|
|
57479
|
+
newTabOpenImage: "Open image in a new tab",
|
|
57480
|
+
selectBlock: "Select the block",
|
|
57481
|
+
selectAll: "Select all",
|
|
57483
57482
|
uneditableBlockSelected: "\u5F85\u8865\u5145\u8BDD\u672F"
|
|
57484
57483
|
}
|
|
57485
57484
|
};
|
|
57486
57485
|
const jaJP$f = {
|
|
57487
57486
|
contextMenu: {
|
|
57488
|
-
copyMarkdown: "\
|
|
57489
|
-
paste: "\
|
|
57490
|
-
copyImage: "\
|
|
57491
|
-
copyImageUrl: "\
|
|
57492
|
-
imageSaveAs: "\
|
|
57493
|
-
newTabOpenImage: "\u65B0\
|
|
57494
|
-
selectBlock: "\
|
|
57495
|
-
selectAll: "\
|
|
57496
|
-
uneditableBlockSelected: "\
|
|
57487
|
+
copyMarkdown: "Markdown \u3068\u3057\u3066\u30B3\u30D4\u30FC",
|
|
57488
|
+
paste: "\u8CBC\u308A\u4ED8\u3051",
|
|
57489
|
+
copyImage: "\u753B\u50CF\u3092\u30B3\u30D4\u30FC",
|
|
57490
|
+
copyImageUrl: "\u753B\u50CF\u30A2\u30C9\u30EC\u30B9\u3092\u30B3\u30D4\u30FC",
|
|
57491
|
+
imageSaveAs: "\u540D\u524D\u3092\u4ED8\u3051\u3066\u753B\u50CF\u3092\u4FDD\u5B58",
|
|
57492
|
+
newTabOpenImage: "\u65B0\u3057\u3044\u30BF\u30D6\u3067\u753B\u50CF\u3092\u958B\u304F",
|
|
57493
|
+
selectBlock: "\u30D6\u30ED\u30C3\u30AF\u3092\u9078\u629E",
|
|
57494
|
+
selectAll: "\u30C6\u30AD\u30B9\u30C8\u3092\u5168\u9078\u629E",
|
|
57495
|
+
uneditableBlockSelected: "\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u306B\u30ED\u30C3\u30AF\u3055\u308C\u305F\u30D6\u30ED\u30C3\u30AF\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u5207\u308A\u53D6\u308A\u304C\u3067\u304D\u307E\u305B\u3093"
|
|
57497
57496
|
}
|
|
57498
57497
|
};
|
|
57499
57498
|
i18n$1.mergeLang({
|
|
@@ -58096,13 +58095,13 @@ ${codeText}
|
|
|
58096
58095
|
}
|
|
58097
58096
|
});
|
|
58098
58097
|
__publicField(this, "handleEditorReadonlyChange", (editor) => {
|
|
58099
|
-
const { components: { actions }, root: root2 } = this;
|
|
58098
|
+
const { components: { actions: actions2 }, root: root2 } = this;
|
|
58100
58099
|
if (editor.readonly) {
|
|
58101
58100
|
root2.classList.remove(COMMENT_ITEM_EDITING_CLS);
|
|
58102
|
-
|
|
58101
|
+
actions2.classList.add("hidden");
|
|
58103
58102
|
} else {
|
|
58104
58103
|
root2.classList.add(COMMENT_ITEM_EDITING_CLS);
|
|
58105
|
-
|
|
58104
|
+
actions2.classList.remove("hidden");
|
|
58106
58105
|
}
|
|
58107
58106
|
});
|
|
58108
58107
|
__publicField(this, "handleFocus", () => {
|
|
@@ -58195,12 +58194,12 @@ ${codeText}
|
|
|
58195
58194
|
commentEditor.editor.addListener("focus", this.handleFocus);
|
|
58196
58195
|
commentEditor.editor.input.addHandler(new CommentEditorInputHandler(commentsProvider, groupItem, this));
|
|
58197
58196
|
commentEditorContainer.append(commentEditor.root);
|
|
58198
|
-
const
|
|
58197
|
+
const actions2 = createElement("div", ["item-actions", "hidden"], this.root);
|
|
58199
58198
|
const cancelButton = createButton$1(GroupItemActions.CommentItemCancel, t$4("common.cancel"));
|
|
58200
58199
|
addGroupActionToElement(cancelButton, GroupItemActions.CommentItemCancel);
|
|
58201
58200
|
const okButton = createButton$1(GroupItemActions.CommentItemOk, t$4("comment.send"), void 0, ["primary", "disabled"]);
|
|
58202
58201
|
addGroupActionToElement(okButton, GroupItemActions.CommentItemOk);
|
|
58203
|
-
|
|
58202
|
+
actions2.append(cancelButton, okButton);
|
|
58204
58203
|
return {
|
|
58205
58204
|
head,
|
|
58206
58205
|
replyButton,
|
|
@@ -58208,7 +58207,7 @@ ${codeText}
|
|
|
58208
58207
|
commentEditor,
|
|
58209
58208
|
okButton,
|
|
58210
58209
|
cancelButton,
|
|
58211
|
-
actions,
|
|
58210
|
+
actions: actions2,
|
|
58212
58211
|
headTools: tools
|
|
58213
58212
|
};
|
|
58214
58213
|
}
|
|
@@ -58479,12 +58478,12 @@ ${codeText}
|
|
|
58479
58478
|
replyEditor.editor.addListener("focus", this.handleFocus);
|
|
58480
58479
|
replyEditor.editor.input.addHandler(new QuickReplyEditorInputHandler(this.groupItem));
|
|
58481
58480
|
replyEditorContainer.append(replyEditor.root);
|
|
58482
|
-
const
|
|
58481
|
+
const actions2 = createElement("div", ["reply-editor-actions"], replyEditorContainer);
|
|
58483
58482
|
const cancelButton = createButton$1(GroupItemActions.QuickReplyCancel, t$3("common.cancel"));
|
|
58484
58483
|
addGroupActionToElement(cancelButton, GroupItemActions.QuickReplyCancel);
|
|
58485
58484
|
const okButton = createButton$1(GroupItemActions.QuickReplyOk, t$3("comment.send"), void 0, ["primary", "disabled"]);
|
|
58486
58485
|
addGroupActionToElement(okButton, GroupItemActions.QuickReplyOk);
|
|
58487
|
-
|
|
58486
|
+
actions2.append(cancelButton, okButton);
|
|
58488
58487
|
this.hideReplyEditor();
|
|
58489
58488
|
return {
|
|
58490
58489
|
replyTextButton,
|
|
@@ -60956,8 +60955,8 @@ ${codeText}
|
|
|
60956
60955
|
nameElement.textContent = fileName;
|
|
60957
60956
|
}
|
|
60958
60957
|
createElement("div", ["file-size"], detail, formatBytes(fileSize));
|
|
60959
|
-
const
|
|
60960
|
-
const downloadButton = createElement("button", ["download"],
|
|
60958
|
+
const actions2 = createElement("div", ["file-actions"], card);
|
|
60959
|
+
const downloadButton = createElement("button", ["download"], actions2);
|
|
60961
60960
|
downloadButton.innerHTML = DownloadIcon;
|
|
60962
60961
|
return { card, downloadButton };
|
|
60963
60962
|
}
|
|
@@ -61617,15 +61616,15 @@ ${codeText}
|
|
|
61617
61616
|
createElement("div", ["version-item-latest"], title, t$1("version.latest"));
|
|
61618
61617
|
}
|
|
61619
61618
|
createElement("div", ["spacer"], title);
|
|
61620
|
-
const
|
|
61621
|
-
const addMemo = createElement("button", ["add-memo-button"],
|
|
61619
|
+
const actions2 = createElement("div", ["version-actions"], title);
|
|
61620
|
+
const addMemo = createElement("button", ["add-memo-button"], actions2);
|
|
61622
61621
|
addMemo.textContent = t$1("version.memo");
|
|
61623
61622
|
if (!this.options.enableEdit) {
|
|
61624
61623
|
addClass(addMemo, "disabled");
|
|
61625
61624
|
addMemo.setAttribute("data-editor-tooltip-common", i18n$1.t("version.tooltip.auth"));
|
|
61626
61625
|
}
|
|
61627
61626
|
if (!isFirst) {
|
|
61628
|
-
const revert = createElement("button", ["revert-button"],
|
|
61627
|
+
const revert = createElement("button", ["revert-button"], actions2);
|
|
61629
61628
|
revert.textContent = t$1("version.revert");
|
|
61630
61629
|
if (!this.options.enableEdit) {
|
|
61631
61630
|
addClass(revert, "disabled");
|
|
@@ -61765,8 +61764,8 @@ ${codeText}
|
|
|
61765
61764
|
onInsertBlock(containerId, blockIndex, blockData) {
|
|
61766
61765
|
this.doc.onInsertBlock(containerId, blockIndex, blockData, this.user);
|
|
61767
61766
|
}
|
|
61768
|
-
onUpdateBlockText(containerId, blockIndex,
|
|
61769
|
-
this.doc.onUpdateBlockText(containerId, blockIndex,
|
|
61767
|
+
onUpdateBlockText(containerId, blockIndex, actions2) {
|
|
61768
|
+
this.doc.onUpdateBlockText(containerId, blockIndex, actions2, this.user);
|
|
61770
61769
|
}
|
|
61771
61770
|
onUpdateBlockData(containerId, blockIndex, delta) {
|
|
61772
61771
|
this.doc.onUpdateBlockData(containerId, blockIndex, delta, this.user);
|
|
@@ -61790,57 +61789,57 @@ ${codeText}
|
|
|
61790
61789
|
}
|
|
61791
61790
|
}
|
|
61792
61791
|
const logger$o = getLogger("split-text-actions");
|
|
61793
|
-
function isInsertOnly(
|
|
61794
|
-
if (
|
|
61792
|
+
function isInsertOnly(actions2) {
|
|
61793
|
+
if (actions2.length > 2) {
|
|
61795
61794
|
return false;
|
|
61796
61795
|
}
|
|
61797
|
-
if (
|
|
61798
|
-
return
|
|
61796
|
+
if (actions2.length === 1) {
|
|
61797
|
+
return actions2[0].insert !== void 0;
|
|
61799
61798
|
}
|
|
61800
|
-
assert(logger$o,
|
|
61801
|
-
if (
|
|
61799
|
+
assert(logger$o, actions2.length === 2, `invalid text actions: ${JSON.stringify(actions2)}`);
|
|
61800
|
+
if (actions2[0].retain === void 0) {
|
|
61802
61801
|
return false;
|
|
61803
61802
|
}
|
|
61804
|
-
return
|
|
61803
|
+
return actions2[1].insert !== void 0;
|
|
61805
61804
|
}
|
|
61806
|
-
function isDeleteOnly(
|
|
61807
|
-
if (
|
|
61805
|
+
function isDeleteOnly(actions2) {
|
|
61806
|
+
if (actions2.length > 2) {
|
|
61808
61807
|
return false;
|
|
61809
61808
|
}
|
|
61810
|
-
if (
|
|
61811
|
-
return
|
|
61809
|
+
if (actions2.length === 1) {
|
|
61810
|
+
return actions2[0].delete !== void 0;
|
|
61812
61811
|
}
|
|
61813
|
-
assert(logger$o,
|
|
61814
|
-
if (
|
|
61812
|
+
assert(logger$o, actions2.length === 2, `invalid text actions: ${JSON.stringify(actions2)}`);
|
|
61813
|
+
if (actions2[0].retain === void 0) {
|
|
61815
61814
|
return false;
|
|
61816
61815
|
}
|
|
61817
|
-
return
|
|
61816
|
+
return actions2[1].delete !== void 0;
|
|
61818
61817
|
}
|
|
61819
|
-
function isAttributesOnly(
|
|
61820
|
-
if (
|
|
61818
|
+
function isAttributesOnly(actions2) {
|
|
61819
|
+
if (actions2.length > 2) {
|
|
61821
61820
|
return false;
|
|
61822
61821
|
}
|
|
61823
|
-
if (
|
|
61824
|
-
return
|
|
61822
|
+
if (actions2.length === 1) {
|
|
61823
|
+
return actions2[0].insert === void 0 && actions2[0].delete === void 0 && actions2[0].attributes !== void 0;
|
|
61825
61824
|
}
|
|
61826
|
-
assert(logger$o,
|
|
61827
|
-
if (
|
|
61825
|
+
assert(logger$o, actions2.length === 2, `invalid text actions: ${JSON.stringify(actions2)}`);
|
|
61826
|
+
if (actions2[0].retain === void 0) {
|
|
61828
61827
|
return false;
|
|
61829
61828
|
}
|
|
61830
|
-
return
|
|
61829
|
+
return actions2[1].attributes !== void 0;
|
|
61831
61830
|
}
|
|
61832
|
-
function splitToSingleActions(
|
|
61831
|
+
function splitToSingleActions(actions2) {
|
|
61833
61832
|
const ret = [];
|
|
61834
|
-
const ops = cloneDeep__default.default(
|
|
61833
|
+
const ops = cloneDeep__default.default(actions2);
|
|
61835
61834
|
if (ops.length === 0) {
|
|
61836
61835
|
return [];
|
|
61837
61836
|
}
|
|
61838
61837
|
if (ops.length === 1) {
|
|
61839
|
-
return [
|
|
61838
|
+
return [actions2];
|
|
61840
61839
|
}
|
|
61841
61840
|
if (ops.length === 2) {
|
|
61842
|
-
if (isDeleteOnly(
|
|
61843
|
-
return [
|
|
61841
|
+
if (isDeleteOnly(actions2) || isInsertOnly(actions2) || isAttributesOnly(actions2)) {
|
|
61842
|
+
return [actions2];
|
|
61844
61843
|
}
|
|
61845
61844
|
}
|
|
61846
61845
|
const createSubOps = (offset2, op) => {
|
|
@@ -61945,9 +61944,9 @@ ${codeText}
|
|
|
61945
61944
|
return newText;
|
|
61946
61945
|
}
|
|
61947
61946
|
function applyActionsToText(text2, ops, user) {
|
|
61948
|
-
const
|
|
61947
|
+
const actions2 = splitToSingleActions(ops);
|
|
61949
61948
|
let newText = text2;
|
|
61950
|
-
for (const action of
|
|
61949
|
+
for (const action of actions2) {
|
|
61951
61950
|
if (isDeleteOnly(action)) {
|
|
61952
61951
|
newText = applyDeleteAction(newText, action, user);
|
|
61953
61952
|
} else if (isInsertOnly(action)) {
|
|
@@ -62183,18 +62182,18 @@ ${codeText}
|
|
|
62183
62182
|
return (_a = cb.onInsertBlock) == null ? void 0 : _a.call(cb, containerId, insertIndex, newData, true);
|
|
62184
62183
|
});
|
|
62185
62184
|
}
|
|
62186
|
-
onUpdateBlockText(containerId, blockIndex,
|
|
62185
|
+
onUpdateBlockText(containerId, blockIndex, actions2, user) {
|
|
62187
62186
|
const updateIndex = this.transformBlockIndex(containerId, blockIndex, true);
|
|
62188
62187
|
const blocks = this.docObject.blocks[containerId];
|
|
62189
62188
|
const blockData = blocks[updateIndex];
|
|
62190
62189
|
assert(logger$m, !blockData.deleted, `block has already deleted: ${containerId}/${blockIndex}`);
|
|
62191
62190
|
const text2 = blockData.text;
|
|
62192
62191
|
assert(logger$m, text2, `no text for block: ${JSON.stringify(blockData)}`);
|
|
62193
|
-
const newText = updateBlockText(text2,
|
|
62192
|
+
const newText = updateBlockText(text2, actions2, user);
|
|
62194
62193
|
blockData.text = newText;
|
|
62195
62194
|
this.callbacks.forEach((cb) => {
|
|
62196
62195
|
var _a;
|
|
62197
|
-
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, containerId, updateIndex,
|
|
62196
|
+
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, containerId, updateIndex, actions2, true);
|
|
62198
62197
|
});
|
|
62199
62198
|
}
|
|
62200
62199
|
onUpdateBlockData(containerId, blockIndex, delta, user) {
|
|
@@ -63364,7 +63363,7 @@ ${codeText}
|
|
|
63364
63363
|
}
|
|
63365
63364
|
this.updateToc();
|
|
63366
63365
|
}
|
|
63367
|
-
onUpdateBlockText(containerId, blockIndex,
|
|
63366
|
+
onUpdateBlockText(containerId, blockIndex, actions2, local) {
|
|
63368
63367
|
if (containerId !== "root") {
|
|
63369
63368
|
return;
|
|
63370
63369
|
}
|
|
@@ -67455,12 +67454,12 @@ ${codeText}
|
|
|
67455
67454
|
}
|
|
67456
67455
|
return isDrop ? baseSlice(array, fromRight ? 0 : index2, fromRight ? index2 + 1 : length) : baseSlice(array, fromRight ? index2 + 1 : 0, fromRight ? length : index2);
|
|
67457
67456
|
}
|
|
67458
|
-
function baseWrapperValue(value,
|
|
67457
|
+
function baseWrapperValue(value, actions2) {
|
|
67459
67458
|
var result2 = value;
|
|
67460
67459
|
if (result2 instanceof LazyWrapper) {
|
|
67461
67460
|
result2 = result2.value();
|
|
67462
67461
|
}
|
|
67463
|
-
return arrayReduce2(
|
|
67462
|
+
return arrayReduce2(actions2, function(result3, action) {
|
|
67464
67463
|
return action.func.apply(action.thisArg, arrayPush([result3], action.args));
|
|
67465
67464
|
}, result2);
|
|
67466
67465
|
}
|
|
@@ -70383,8 +70382,8 @@ ${codeText}
|
|
|
70383
70382
|
object.prototype[methodName] = function() {
|
|
70384
70383
|
var chainAll = this.__chain__;
|
|
70385
70384
|
if (chain2 || chainAll) {
|
|
70386
|
-
var result2 = object(this.__wrapped__),
|
|
70387
|
-
|
|
70385
|
+
var result2 = object(this.__wrapped__), actions2 = result2.__actions__ = copyArray(this.__actions__);
|
|
70386
|
+
actions2.push({ "func": func, "args": arguments, "thisArg": object });
|
|
70388
70387
|
result2.__chain__ = chainAll;
|
|
70389
70388
|
return result2;
|
|
70390
70389
|
}
|
|
@@ -72532,6 +72531,9 @@ ${data.flowchartText}
|
|
|
72532
72531
|
editor.readonly = true;
|
|
72533
72532
|
editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
|
|
72534
72533
|
editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
|
|
72534
|
+
if (options == null ? void 0 : options.enableContextMenu) {
|
|
72535
|
+
editor.addCustom("editor-context-menu", (editor2) => new OnesEditorContextMenu(editor2));
|
|
72536
|
+
}
|
|
72535
72537
|
editor.addListener("clickLink", (editor2, event, link2) => {
|
|
72536
72538
|
var _a2;
|
|
72537
72539
|
if ((_a2 = options == null ? void 0 : options.events) == null ? void 0 : _a2.onClickLink) {
|
|
@@ -74336,7 +74338,6 @@ ${data.flowchartText}
|
|
|
74336
74338
|
exports2.EditorComplexSelectionRange = EditorComplexSelectionRange;
|
|
74337
74339
|
exports2.EditorDecorators = EditorDecorators;
|
|
74338
74340
|
exports2.EditorEmbeds = EditorEmbeds;
|
|
74339
|
-
exports2.EditorInputHandlers = EditorInputHandlers;
|
|
74340
74341
|
exports2.EditorInsertions = EditorInsertions;
|
|
74341
74342
|
exports2.EditorSimpleBlockPosition = EditorSimpleBlockPosition;
|
|
74342
74343
|
exports2.EditorSimpleSelectionRange = EditorSimpleSelectionRange;
|
|
@@ -74407,6 +74408,7 @@ ${data.flowchartText}
|
|
|
74407
74408
|
exports2.applyPlaceholderToBlock = applyPlaceholderToBlock;
|
|
74408
74409
|
exports2.assert = assert;
|
|
74409
74410
|
exports2.autoShowHideTemplates = autoShowHideTemplates;
|
|
74411
|
+
exports2.blob2String = blob2String;
|
|
74410
74412
|
exports2.blockToDoc = blockToDoc;
|
|
74411
74413
|
exports2.blockToHtml = blockToHtml;
|
|
74412
74414
|
exports2.blockToMarkdown = blockToMarkdown;
|
|
@@ -74690,6 +74692,7 @@ ${data.flowchartText}
|
|
|
74690
74692
|
exports2.i18n = i18n$1;
|
|
74691
74693
|
exports2.injectDocToHtmlFragment = injectDocToHtmlFragment;
|
|
74692
74694
|
exports2.injectStyle = injectStyle;
|
|
74695
|
+
exports2.inputActions = actions;
|
|
74693
74696
|
exports2.insertEmptyBlock = insertEmptyBlock$1;
|
|
74694
74697
|
exports2.insertEmptyEmbedBlock = insertEmptyEmbedBlock;
|
|
74695
74698
|
exports2.insertText = insertText;
|