@ones-editor/editor 5.0.6-beta.DNP8216.1 → 5.0.6-beta.p8216.1
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/core/src/core/doc/doc.d.ts +2 -72
- package/@ones-editor/core/src/core/doc/index.d.ts +1 -0
- package/@ones-editor/core/src/core/doc/wiki-macro.d.ts +15 -0
- package/@ones-editor/core/src/core/doc/wiki-macro.test.d.ts +1 -0
- package/@ones-editor/core/src/core/editor/index.d.ts +0 -1
- package/@ones-editor/core/src/core/editor-doc/editor-doc.d.ts +0 -6
- package/@ones-editor/core/src/core/types.d.ts +12 -19
- package/@ones-editor/core/src/core/undo-manager/actions/async-action.d.ts +7 -0
- package/@ones-editor/core/src/core/undo-manager/undo-manager.d.ts +10 -10
- package/@ones-editor/core/src/core/undo-manager/undo-manager.test.d.ts +1 -0
- package/@ones-editor/core/src/local-doc/index.d.ts +1 -7
- package/@ones-editor/server-tools/src/to-markdown/embeds/wiki-macro.d.ts +4 -0
- package/@ones-editor/server-tools/src/to-markdown/embeds/wiki-macro.test.d.ts +1 -0
- package/@ones-editor/sharedb-doc/src/doc/auth-connection.d.ts +0 -12
- package/@ones-editor/sharedb-doc/src/doc/sharedb-client.d.ts +1 -2
- package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +1 -6
- package/@ones-editor/sharedb-doc/src/doc/sharedb-local-doc.d.ts +0 -1
- package/@ones-editor/sharedb-doc/src/types.d.ts +0 -4
- package/@ones-editor/sharedb-doc/src/versions/sharedb-server.d.ts +0 -2
- package/@ones-editor/sharedb-doc/src/versions/simple-client.d.ts +1 -2
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/block-menu/index.d.ts +0 -1
- package/@ones-editor/versions/src/history-diff.d.ts +0 -1
- package/@ones-editor/versions/src/history-doc/history-doc.d.ts +1 -6
- package/dist/index.js +219 -587
- package/package.json +1 -1
- package/@ones-editor/core/src/core/composition/clipboard/resources/doc-resource-hooks.d.ts +0 -6
- package/@ones-editor/core/src/core/editor/wiki-macro-locks.d.ts +0 -9
- package/@ones-editor/core/src/core/undo-manager/actions/macro-edit-action.d.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -24923,19 +24923,6 @@ var __publicField = (obj, key, value) => {
|
|
|
24923
24923
|
}
|
|
24924
24924
|
return versions;
|
|
24925
24925
|
}
|
|
24926
|
-
class WikiMacroError extends Error {
|
|
24927
|
-
constructor(details, requestId) {
|
|
24928
|
-
super(details.message || details.code);
|
|
24929
|
-
__publicField(this, "code");
|
|
24930
|
-
__publicField(this, "sizeBytes");
|
|
24931
|
-
__publicField(this, "limitBytes");
|
|
24932
|
-
this.requestId = requestId;
|
|
24933
|
-
this.name = "WikiMacroError";
|
|
24934
|
-
this.code = details.code;
|
|
24935
|
-
this.sizeBytes = details.sizeBytes;
|
|
24936
|
-
this.limitBytes = details.limitBytes;
|
|
24937
|
-
}
|
|
24938
|
-
}
|
|
24939
24926
|
const logger$4b = getLogger("create-text-op");
|
|
24940
24927
|
function createTextOp(text2, attributes) {
|
|
24941
24928
|
assert(logger$4b, text2, "text is empty");
|
|
@@ -25283,6 +25270,63 @@ var __publicField = (obj, key, value) => {
|
|
|
25283
25270
|
focus: pos
|
|
25284
25271
|
};
|
|
25285
25272
|
}
|
|
25273
|
+
const WIKI_MACRO_TYPE = "ones-open-wiki-macro";
|
|
25274
|
+
function getWikiMacroExportSpec(data2) {
|
|
25275
|
+
if (!data2 || data2.protocolVersion !== 2 || !Array.isArray(data2.exportSpec))
|
|
25276
|
+
return [];
|
|
25277
|
+
return data2.exportSpec.filter((spec) => {
|
|
25278
|
+
if (!spec || typeof spec !== "object")
|
|
25279
|
+
return false;
|
|
25280
|
+
if (spec.type === "text")
|
|
25281
|
+
return typeof spec.data === "string";
|
|
25282
|
+
if (spec.type === "image")
|
|
25283
|
+
return typeof spec.data === "string" && !!spec.data;
|
|
25284
|
+
return spec.type === "link" && spec.data && typeof spec.data.title === "string" && typeof spec.data.url === "string" && /^(https?:\/\/|mailto:)/i.test(spec.data.url.trim());
|
|
25285
|
+
});
|
|
25286
|
+
}
|
|
25287
|
+
function getWikiMacroResources(data2) {
|
|
25288
|
+
if (!data2 || data2.protocolVersion !== 2)
|
|
25289
|
+
return [];
|
|
25290
|
+
const resources = /* @__PURE__ */ new Set();
|
|
25291
|
+
if (Array.isArray(data2.resources)) {
|
|
25292
|
+
data2.resources.forEach((resource) => {
|
|
25293
|
+
if (typeof resource === "string" && resource)
|
|
25294
|
+
resources.add(resource);
|
|
25295
|
+
});
|
|
25296
|
+
}
|
|
25297
|
+
getWikiMacroExportSpec(data2).forEach((spec) => {
|
|
25298
|
+
if (spec.type === "image" && typeof spec.data === "string" && spec.data)
|
|
25299
|
+
resources.add(spec.data);
|
|
25300
|
+
});
|
|
25301
|
+
return Array.from(resources);
|
|
25302
|
+
}
|
|
25303
|
+
function replaceWikiMacroResources(data2, resources) {
|
|
25304
|
+
if (!data2 || data2.protocolVersion !== 2)
|
|
25305
|
+
return;
|
|
25306
|
+
if (Array.isArray(data2.resources)) {
|
|
25307
|
+
data2.resources = data2.resources.map((resource) => {
|
|
25308
|
+
var _a;
|
|
25309
|
+
return (_a = resources.get(resource)) != null ? _a : resource;
|
|
25310
|
+
});
|
|
25311
|
+
}
|
|
25312
|
+
getWikiMacroExportSpec(data2).forEach((spec) => {
|
|
25313
|
+
var _a;
|
|
25314
|
+
if (spec.type === "image" && typeof spec.data === "string")
|
|
25315
|
+
spec.data = (_a = resources.get(spec.data)) != null ? _a : spec.data;
|
|
25316
|
+
});
|
|
25317
|
+
}
|
|
25318
|
+
function wikiMacroToText(data2) {
|
|
25319
|
+
return getWikiMacroExportSpec(data2).map((spec) => {
|
|
25320
|
+
if (spec.type === "text" && typeof spec.data === "string")
|
|
25321
|
+
return spec.data;
|
|
25322
|
+
if (spec.type === "link" && spec.data && typeof spec.data === "object") {
|
|
25323
|
+
const link2 = spec.data;
|
|
25324
|
+
if (typeof link2.title === "string" && typeof link2.url === "string")
|
|
25325
|
+
return `${link2.title} ${link2.url}`;
|
|
25326
|
+
}
|
|
25327
|
+
return "";
|
|
25328
|
+
}).filter(Boolean).join("\n");
|
|
25329
|
+
}
|
|
25286
25330
|
const logger$44 = getLogger("repair-duplicated-block-ids");
|
|
25287
25331
|
const ROOT_CONTAINER_ID = "root";
|
|
25288
25332
|
function buildChildContainersDelta(doc2, block) {
|
|
@@ -27133,6 +27177,9 @@ var __publicField = (obj, key, value) => {
|
|
|
27133
27177
|
return text2;
|
|
27134
27178
|
}
|
|
27135
27179
|
function blockToText(editor, blockData, doc2, path) {
|
|
27180
|
+
if (blockData.type === "embed" && blockData.embedType === WIKI_MACRO_TYPE) {
|
|
27181
|
+
return wikiMacroToText(blockData.embedData);
|
|
27182
|
+
}
|
|
27136
27183
|
const blockClass = getBlockClassByType(editor, blockData.type);
|
|
27137
27184
|
if (blockClass.convertTo) {
|
|
27138
27185
|
return blockClass.convertTo(editor, blockData, doc2, "text", path);
|
|
@@ -27527,83 +27574,6 @@ var __publicField = (obj, key, value) => {
|
|
|
27527
27574
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
27528
27575
|
return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
|
|
27529
27576
|
}
|
|
27530
|
-
const editorLeases = /* @__PURE__ */ new WeakMap();
|
|
27531
|
-
function getLeaseState(editor) {
|
|
27532
|
-
let state = editorLeases.get(editor);
|
|
27533
|
-
if (!state) {
|
|
27534
|
-
state = { locks: /* @__PURE__ */ new Map(), activeSessions: /* @__PURE__ */ new Set(), known: true };
|
|
27535
|
-
editorLeases.set(editor, state);
|
|
27536
|
-
}
|
|
27537
|
-
return state;
|
|
27538
|
-
}
|
|
27539
|
-
function initializeWikiMacroLocks(editor) {
|
|
27540
|
-
getLeaseState(editor).known = false;
|
|
27541
|
-
}
|
|
27542
|
-
function updateWikiMacroLocks(editor, locks) {
|
|
27543
|
-
const state = getLeaseState(editor);
|
|
27544
|
-
state.known = true;
|
|
27545
|
-
state.locks.clear();
|
|
27546
|
-
locks.forEach((lock) => state.locks.set(lock.blockId, lock));
|
|
27547
|
-
}
|
|
27548
|
-
function setWikiMacroLockSession(editor, sessionId, active) {
|
|
27549
|
-
const state = getLeaseState(editor);
|
|
27550
|
-
if (active) {
|
|
27551
|
-
state.activeSessions.add(sessionId);
|
|
27552
|
-
} else {
|
|
27553
|
-
state.activeSessions.delete(sessionId);
|
|
27554
|
-
}
|
|
27555
|
-
}
|
|
27556
|
-
function isWikiMacroBlockLocked(editor, block, macroSessionId) {
|
|
27557
|
-
var _a;
|
|
27558
|
-
const state = editorLeases.get(editor);
|
|
27559
|
-
if (!state || state.known && state.locks.size === 0)
|
|
27560
|
-
return false;
|
|
27561
|
-
const mayOwnLease = !!macroSessionId && state.activeSessions.has(macroSessionId);
|
|
27562
|
-
if (!((_a = block.children) == null ? void 0 : _a.length)) {
|
|
27563
|
-
if (block.type !== "embed" || block.embedType !== "ones-open-wiki-macro")
|
|
27564
|
-
return false;
|
|
27565
|
-
if (!state.known)
|
|
27566
|
-
return true;
|
|
27567
|
-
const lease = state.locks.get(block.id);
|
|
27568
|
-
return !!lease && (!mayOwnLease || lease.sessionId !== macroSessionId);
|
|
27569
|
-
}
|
|
27570
|
-
const visited = /* @__PURE__ */ new Set();
|
|
27571
|
-
const hasLockedDescendant = (data2) => {
|
|
27572
|
-
if (visited.has(data2.id))
|
|
27573
|
-
return false;
|
|
27574
|
-
visited.add(data2.id);
|
|
27575
|
-
if (data2.type === "embed" && data2.embedType === "ones-open-wiki-macro") {
|
|
27576
|
-
if (!state.known)
|
|
27577
|
-
return true;
|
|
27578
|
-
const lease = state.locks.get(data2.id);
|
|
27579
|
-
if (lease && (!mayOwnLease || lease.sessionId !== macroSessionId))
|
|
27580
|
-
return true;
|
|
27581
|
-
}
|
|
27582
|
-
for (const containerId of data2.children || []) {
|
|
27583
|
-
const children = editor.doc.findContainerBlocks(containerId) || [];
|
|
27584
|
-
if (children.some(hasLockedDescendant))
|
|
27585
|
-
return true;
|
|
27586
|
-
}
|
|
27587
|
-
return false;
|
|
27588
|
-
};
|
|
27589
|
-
return hasLockedDescendant(block);
|
|
27590
|
-
}
|
|
27591
|
-
function isWikiMacroElementLocked(editor, block, macroSessionId) {
|
|
27592
|
-
const state = editorLeases.get(editor);
|
|
27593
|
-
if (!state || state.known && state.locks.size === 0)
|
|
27594
|
-
return false;
|
|
27595
|
-
if (isWikiMacroBlockLocked(editor, editor.getBlockData(block), macroSessionId))
|
|
27596
|
-
return true;
|
|
27597
|
-
return isHeadingBlock$1(block) && isCollapsedHeadingBlock(block) && getHeadingBlockChildren(block).some(
|
|
27598
|
-
(child) => isWikiMacroBlockLocked(editor, editor.getBlockData(child), macroSessionId)
|
|
27599
|
-
);
|
|
27600
|
-
}
|
|
27601
|
-
function clearWikiMacroLocks(editor) {
|
|
27602
|
-
const state = editorLeases.get(editor);
|
|
27603
|
-
state == null ? void 0 : state.locks.clear();
|
|
27604
|
-
state == null ? void 0 : state.activeSessions.clear();
|
|
27605
|
-
editorLeases.delete(editor);
|
|
27606
|
-
}
|
|
27607
27577
|
const logger$3J = getLogger("delete-block");
|
|
27608
27578
|
function getAllChildContainers(editor, blockData, containerIds) {
|
|
27609
27579
|
if (blockData.children) {
|
|
@@ -27633,8 +27603,6 @@ var __publicField = (obj, key, value) => {
|
|
|
27633
27603
|
return blockData;
|
|
27634
27604
|
}
|
|
27635
27605
|
function editorDeleteBlock(editor, block, newDocRange) {
|
|
27636
|
-
if (isWikiMacroElementLocked(editor, block))
|
|
27637
|
-
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
27638
27606
|
return editor.undoManager.runInGroup(() => {
|
|
27639
27607
|
const container = getParentContainer(block);
|
|
27640
27608
|
if (getChildBlockCount(container) === 1) {
|
|
@@ -28001,9 +27969,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28001
27969
|
blockData[newKey] = value;
|
|
28002
27970
|
});
|
|
28003
27971
|
blockData.id = genId();
|
|
28004
|
-
if (blockData.type === "embed" && blockData.embedType === "ones-open-wiki-macro") {
|
|
28005
|
-
blockData.macroRevision = 1;
|
|
28006
|
-
}
|
|
28007
27972
|
if (info) {
|
|
28008
27973
|
info.blockIdMap.set(data2.id, blockData.id);
|
|
28009
27974
|
childContainerIdMap.forEach((newId, oldId) => info.containerIdMap.set(oldId, newId));
|
|
@@ -29997,6 +29962,10 @@ var __publicField = (obj, key, value) => {
|
|
|
29997
29962
|
function defaultGetResourceFromBlock(editor, doc2, block, resources) {
|
|
29998
29963
|
if (block.type === "embed") {
|
|
29999
29964
|
const embedData = block.embedData;
|
|
29965
|
+
if (block.embedType === WIKI_MACRO_TYPE) {
|
|
29966
|
+
getWikiMacroResources(embedData).forEach((resource) => resources.add(resource));
|
|
29967
|
+
return;
|
|
29968
|
+
}
|
|
30000
29969
|
const src = embedData.src;
|
|
30001
29970
|
if (src && typeof src === "string") {
|
|
30002
29971
|
for (const item of src.split("|")) {
|
|
@@ -30383,6 +30352,10 @@ ${codeText}
|
|
|
30383
30352
|
function defaultReplaceBlockResources(doc2, block, resources) {
|
|
30384
30353
|
if (block.type === "embed") {
|
|
30385
30354
|
const embedData = block.embedData;
|
|
30355
|
+
if (block.embedType === WIKI_MACRO_TYPE) {
|
|
30356
|
+
replaceWikiMacroResources(embedData, resources);
|
|
30357
|
+
return;
|
|
30358
|
+
}
|
|
30386
30359
|
const src = embedData.src;
|
|
30387
30360
|
if (src && typeof src === "string") {
|
|
30388
30361
|
const newSrc = resources.get(src);
|
|
@@ -31140,38 +31113,10 @@ ${codeText}
|
|
|
31140
31113
|
constructor(editor, externalDoc, localEvents) {
|
|
31141
31114
|
super();
|
|
31142
31115
|
__publicField(this, "localEvents", []);
|
|
31143
|
-
__publicField(this, "unsubscribeMacroLocks");
|
|
31144
31116
|
this.editor = editor;
|
|
31145
31117
|
this.externalDoc = externalDoc;
|
|
31146
31118
|
this.externalDoc.registerCallback(this);
|
|
31147
31119
|
this.registerLocalEvents(localEvents);
|
|
31148
|
-
this.subscribeMacroLocks();
|
|
31149
|
-
}
|
|
31150
|
-
subscribeMacroLocks() {
|
|
31151
|
-
initializeWikiMacroLocks(this.editor);
|
|
31152
|
-
try {
|
|
31153
|
-
this.unsubscribeMacroLocks = this.externalDoc.onWikiMacroLocks((locks) => {
|
|
31154
|
-
updateWikiMacroLocks(this.editor, locks);
|
|
31155
|
-
this.editor.emit("wikiMacroLocksChanged", this.editor);
|
|
31156
|
-
});
|
|
31157
|
-
} catch (error2) {
|
|
31158
|
-
clearWikiMacroLocks(this.editor);
|
|
31159
|
-
if (!(error2 instanceof WikiMacroError) || error2.code !== "READ_ONLY")
|
|
31160
|
-
throw error2;
|
|
31161
|
-
}
|
|
31162
|
-
}
|
|
31163
|
-
requestWikiMacro(message) {
|
|
31164
|
-
if (this.editor.readonly && message.operation !== "locks" && message.operation !== "getEditResult" && message.operation !== "cancelEdit") {
|
|
31165
|
-
return Promise.reject(new WikiMacroError({ code: "READ_ONLY" }));
|
|
31166
|
-
}
|
|
31167
|
-
return this.externalDoc.requestWikiMacro(message);
|
|
31168
|
-
}
|
|
31169
|
-
onWikiMacroLocks(listener) {
|
|
31170
|
-
return this.externalDoc.onWikiMacroLocks(listener);
|
|
31171
|
-
}
|
|
31172
|
-
getDocumentVersion() {
|
|
31173
|
-
var _a, _b;
|
|
31174
|
-
return (_b = (_a = this.externalDoc).getDocumentVersion) == null ? void 0 : _b.call(_a);
|
|
31175
31120
|
}
|
|
31176
31121
|
beginBatchUpdate() {
|
|
31177
31122
|
return this.externalDoc.beginBatchUpdate();
|
|
@@ -31210,8 +31155,6 @@ ${codeText}
|
|
|
31210
31155
|
}
|
|
31211
31156
|
localUpdateBlockText(containerId, blockIndex, actions2, options) {
|
|
31212
31157
|
const blockData = this.getBlockData(containerId, blockIndex);
|
|
31213
|
-
if (isWikiMacroBlockLocked(this.editor, blockData))
|
|
31214
|
-
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31215
31158
|
const oldText = blockData.text;
|
|
31216
31159
|
assert(logger$3l, oldText, `no text, ${containerId}, ${blockIndex}`);
|
|
31217
31160
|
const newRange = transformSelection(this.editor, blockData.id, actions2, true);
|
|
@@ -31223,10 +31166,6 @@ ${codeText}
|
|
|
31223
31166
|
}
|
|
31224
31167
|
localUpdateBlockData(containerId, blockIndex, delta, newRange, options) {
|
|
31225
31168
|
const block = this.editor.getBlockByIndex(containerId, blockIndex);
|
|
31226
|
-
const blockedByMacroLease = isWikiMacroBlockLocked(this.editor, this.getBlockData(containerId, blockIndex));
|
|
31227
|
-
if (blockedByMacroLease && (delta.delete.some((key) => key !== "comments") || Object.keys(delta.insert).some((key) => key !== "comments"))) {
|
|
31228
|
-
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31229
|
-
}
|
|
31230
31169
|
if (!this.editor.isBlockWritable(block)) {
|
|
31231
31170
|
const deletedKeys = Array.from(delta.delete).filter((key) => key !== "comments");
|
|
31232
31171
|
const insertedKeys = Object.keys(delta.insert).filter((key) => key !== "comments");
|
|
@@ -31243,8 +31182,6 @@ ${codeText}
|
|
|
31243
31182
|
}
|
|
31244
31183
|
localInsertBlock(containerId, blockIndex, data2, newRange, options) {
|
|
31245
31184
|
assert(logger$3l, !this.editor.readonly, "editor is readonly");
|
|
31246
|
-
if (isWikiMacroBlockLocked(this.editor, data2))
|
|
31247
|
-
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31248
31185
|
this.localEvents.forEach((event) => event.onBeforeInsertBlock(containerId, blockIndex, data2, newRange));
|
|
31249
31186
|
const ret = this.externalDoc.localInsertBlock(containerId, blockIndex, data2, newRange);
|
|
31250
31187
|
if (!(options == null ? void 0 : options.noFocus)) {
|
|
@@ -31263,9 +31200,6 @@ ${codeText}
|
|
|
31263
31200
|
}
|
|
31264
31201
|
localDeleteChildContainers(containerIds) {
|
|
31265
31202
|
assert(logger$3l, !this.editor.readonly, "editor is readonly");
|
|
31266
|
-
if (containerIds.some((containerId) => this.getContainerBlocks(containerId).some((block) => isWikiMacroBlockLocked(this.editor, block)))) {
|
|
31267
|
-
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31268
|
-
}
|
|
31269
31203
|
containerIds.forEach((containerId) => {
|
|
31270
31204
|
const blocks = cloneDeep__default.default(this.getContainerBlocks(containerId));
|
|
31271
31205
|
this.localEvents.forEach((event) => event.onBeforeDeleteChildContainer(containerId, blocks));
|
|
@@ -31274,9 +31208,6 @@ ${codeText}
|
|
|
31274
31208
|
}
|
|
31275
31209
|
localInsertChildContainers(containers) {
|
|
31276
31210
|
assert(logger$3l, !this.editor.readonly, "editor is readonly");
|
|
31277
|
-
if (containers.some((container) => container.blocks.some((block) => isWikiMacroBlockLocked(this.editor, block)))) {
|
|
31278
|
-
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31279
|
-
}
|
|
31280
31211
|
const data2 = cloneDeep__default.default(containers);
|
|
31281
31212
|
data2.forEach((item) => {
|
|
31282
31213
|
this.localEvents.forEach((event) => event.onBeforeInsertChildContainer(item.containerId, item.blocks));
|
|
@@ -31385,11 +31316,6 @@ ${codeText}
|
|
|
31385
31316
|
(_b = (_a = this.externalDoc).triggerReAuth) == null ? void 0 : _b.call(_a, auto);
|
|
31386
31317
|
}
|
|
31387
31318
|
destroy() {
|
|
31388
|
-
var _a;
|
|
31389
|
-
this.editor.undoManager.destroy();
|
|
31390
|
-
(_a = this.unsubscribeMacroLocks) == null ? void 0 : _a.call(this);
|
|
31391
|
-
this.unsubscribeMacroLocks = void 0;
|
|
31392
|
-
clearWikiMacroLocks(this.editor);
|
|
31393
31319
|
this.externalDoc.destroy();
|
|
31394
31320
|
this.clearCallbacks();
|
|
31395
31321
|
}
|
|
@@ -31398,17 +31324,24 @@ ${codeText}
|
|
|
31398
31324
|
return (_c = (_b = (_a = this.externalDoc).getServerMeta) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
31399
31325
|
}
|
|
31400
31326
|
reset(doc2) {
|
|
31401
|
-
var _a;
|
|
31402
31327
|
logger$3l.log("reset doc");
|
|
31403
|
-
(_a = this.unsubscribeMacroLocks) == null ? void 0 : _a.call(this);
|
|
31404
|
-
clearWikiMacroLocks(this.editor);
|
|
31405
31328
|
this.externalDoc = doc2;
|
|
31406
31329
|
this.externalDoc.registerCallback(this);
|
|
31407
|
-
initializeWikiMacroLocks(this.editor);
|
|
31408
31330
|
this.editor.reload();
|
|
31409
|
-
this.subscribeMacroLocks();
|
|
31410
31331
|
}
|
|
31411
31332
|
}
|
|
31333
|
+
function addActions(actions2, action) {
|
|
31334
|
+
if (actions2.length === 0) {
|
|
31335
|
+
actions2.push(action);
|
|
31336
|
+
return;
|
|
31337
|
+
}
|
|
31338
|
+
const last = actions2[actions2.length - 1];
|
|
31339
|
+
if (!last.combinable(action)) {
|
|
31340
|
+
actions2.push(action);
|
|
31341
|
+
return;
|
|
31342
|
+
}
|
|
31343
|
+
last.combine(action);
|
|
31344
|
+
}
|
|
31412
31345
|
const logger$3k = getLogger("undo-action");
|
|
31413
31346
|
class Action {
|
|
31414
31347
|
constructor(editor, containerId, afterRange, batchActionId) {
|
|
@@ -31472,38 +31405,6 @@ ${codeText}
|
|
|
31472
31405
|
return true;
|
|
31473
31406
|
}
|
|
31474
31407
|
}
|
|
31475
|
-
class MacroEditAction extends Action {
|
|
31476
|
-
constructor(editor, options) {
|
|
31477
|
-
super(editor, "", editor.selection.range.toDocRange());
|
|
31478
|
-
__publicField(this, "options");
|
|
31479
|
-
this.options = options;
|
|
31480
|
-
}
|
|
31481
|
-
apply(direction) {
|
|
31482
|
-
if (!this.options) {
|
|
31483
|
-
return Promise.reject(new WikiMacroError({ code: "SESSION_EXPIRED", message: "Macro history action disposed" }));
|
|
31484
|
-
}
|
|
31485
|
-
return this.options[direction]();
|
|
31486
|
-
}
|
|
31487
|
-
reportError(error2) {
|
|
31488
|
-
var _a, _b;
|
|
31489
|
-
(_b = (_a = this.options) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error2);
|
|
31490
|
-
}
|
|
31491
|
-
dispose() {
|
|
31492
|
-
this.options = null;
|
|
31493
|
-
}
|
|
31494
|
-
}
|
|
31495
|
-
function addActions(actions2, action) {
|
|
31496
|
-
if (actions2.length === 0) {
|
|
31497
|
-
actions2.push(action);
|
|
31498
|
-
return;
|
|
31499
|
-
}
|
|
31500
|
-
const last = actions2[actions2.length - 1];
|
|
31501
|
-
if (!last.combinable(action)) {
|
|
31502
|
-
actions2.push(action);
|
|
31503
|
-
return;
|
|
31504
|
-
}
|
|
31505
|
-
last.combine(action);
|
|
31506
|
-
}
|
|
31507
31408
|
const logger$3j = getLogger("block-action");
|
|
31508
31409
|
class BlockAction extends Action {
|
|
31509
31410
|
constructor(editor, containerId, blockIndex, data2, afterRange) {
|
|
@@ -31561,32 +31462,10 @@ ${codeText}
|
|
|
31561
31462
|
}
|
|
31562
31463
|
class DeleteBlockAction$1 extends BlockAction {
|
|
31563
31464
|
undo(editor) {
|
|
31564
|
-
|
|
31565
|
-
return this.insertBlock(editor, this.beforeRange);
|
|
31566
|
-
}
|
|
31567
|
-
const revision = this.blockData.macroRevision;
|
|
31568
|
-
this.blockData.macroRevision = revision + 1;
|
|
31569
|
-
let inserted = false;
|
|
31570
|
-
try {
|
|
31571
|
-
inserted = this.insertBlock(editor, this.beforeRange);
|
|
31572
|
-
return inserted;
|
|
31573
|
-
} finally {
|
|
31574
|
-
if (!inserted)
|
|
31575
|
-
this.blockData.macroRevision = revision;
|
|
31576
|
-
}
|
|
31465
|
+
return this.insertBlock(editor, this.beforeRange);
|
|
31577
31466
|
}
|
|
31578
31467
|
redo(editor) {
|
|
31579
|
-
|
|
31580
|
-
return this.deleteBlock(editor, this.afterRange);
|
|
31581
|
-
}
|
|
31582
|
-
const block = editor.findBlockById(this.blockData.id);
|
|
31583
|
-
if (!block)
|
|
31584
|
-
return false;
|
|
31585
|
-
const deletedSnapshot = cloneDeep__default.default(editor.getBlockData(block));
|
|
31586
|
-
const deleted = this.deleteBlock(editor, this.afterRange);
|
|
31587
|
-
if (deleted)
|
|
31588
|
-
this.blockData = deletedSnapshot;
|
|
31589
|
-
return deleted;
|
|
31468
|
+
return this.deleteBlock(editor, this.afterRange);
|
|
31590
31469
|
}
|
|
31591
31470
|
}
|
|
31592
31471
|
class GroupAction extends Action {
|
|
@@ -31853,6 +31732,12 @@ ${codeText}
|
|
|
31853
31732
|
return this.deleteChildContainer(editor);
|
|
31854
31733
|
}
|
|
31855
31734
|
}
|
|
31735
|
+
class AsyncAction extends Action {
|
|
31736
|
+
constructor(editor, operation) {
|
|
31737
|
+
super(editor, "", editor.selection.range.toDocRange());
|
|
31738
|
+
this.operation = operation;
|
|
31739
|
+
}
|
|
31740
|
+
}
|
|
31856
31741
|
const BATCH_ACTION_TS = 1e3 * 3;
|
|
31857
31742
|
const logger$3f = getLogger("undo");
|
|
31858
31743
|
class UndoManager {
|
|
@@ -31863,11 +31748,9 @@ ${codeText}
|
|
|
31863
31748
|
__publicField(this, "currentGroup", null);
|
|
31864
31749
|
__publicField(this, "groupCounter", 0);
|
|
31865
31750
|
__publicField(this, "undoRedoing", false);
|
|
31866
|
-
__publicField(this, "
|
|
31867
|
-
__publicField(this, "
|
|
31868
|
-
__publicField(this, "
|
|
31869
|
-
__publicField(this, "macroGeneration", 0);
|
|
31870
|
-
__publicField(this, "destroyed", false);
|
|
31751
|
+
__publicField(this, "undoLocks", /* @__PURE__ */ new Set());
|
|
31752
|
+
__publicField(this, "pendingAction");
|
|
31753
|
+
__publicField(this, "resetVersion", 0);
|
|
31871
31754
|
__publicField(this, "handleSelectionChange", (editor) => {
|
|
31872
31755
|
if (this.currentGroup) {
|
|
31873
31756
|
this.currentGroup.setAfterRange(editor.selection.range.toDocRange());
|
|
@@ -31883,109 +31766,25 @@ ${codeText}
|
|
|
31883
31766
|
this.editor = editor;
|
|
31884
31767
|
this.undoCursor = -1;
|
|
31885
31768
|
this.editor.addListener("selectionChanged", this.handleSelectionChange);
|
|
31886
|
-
|
|
31887
|
-
registerMacroEditAction(options) {
|
|
31888
|
-
if (this.destroyed) {
|
|
31889
|
-
throw new WikiMacroError({ code: "SESSION_EXPIRED", message: "Editor destroyed" });
|
|
31890
|
-
}
|
|
31891
|
-
if (this.macroActionIds.has(options.actionId))
|
|
31892
|
-
return;
|
|
31893
|
-
this.prepareSaveUndoState();
|
|
31894
|
-
this.macroActionIds.add(options.actionId);
|
|
31895
|
-
const action = new MacroEditAction(this.editor, options);
|
|
31896
|
-
this.actions.push(action);
|
|
31897
|
-
this.editor.input.handleChanged(action);
|
|
31898
|
-
}
|
|
31899
|
-
setMacroEditSessionActive(sessionId, active) {
|
|
31900
|
-
if (this.destroyed)
|
|
31901
|
-
return;
|
|
31902
|
-
setWikiMacroLockSession(this.editor, sessionId, active);
|
|
31903
|
-
if (active) {
|
|
31904
|
-
this.macroSessions.add(sessionId);
|
|
31905
|
-
} else {
|
|
31906
|
-
this.macroSessions.delete(sessionId);
|
|
31907
|
-
}
|
|
31908
|
-
}
|
|
31909
|
-
destroy() {
|
|
31910
|
-
this.destroyed = true;
|
|
31911
|
-
this.reset();
|
|
31912
|
-
this.macroSessions.clear();
|
|
31913
|
-
this.editor.removeListener("selectionChanged", this.handleSelectionChange);
|
|
31914
|
-
}
|
|
31915
|
-
applyMacroAction(action, direction) {
|
|
31916
|
-
const generation = this.macroGeneration;
|
|
31917
|
-
const cursor = this.undoCursor;
|
|
31918
|
-
const historyLength = this.actions.length;
|
|
31919
|
-
this.pendingMacroAction = action;
|
|
31920
|
-
Promise.resolve().then(() => action.apply(direction)).then(() => {
|
|
31921
|
-
if (generation !== this.macroGeneration || this.destroyed)
|
|
31922
|
-
return;
|
|
31923
|
-
const index2 = this.actions.indexOf(action);
|
|
31924
|
-
if (direction === "undo") {
|
|
31925
|
-
if (index2 < 0)
|
|
31926
|
-
return;
|
|
31927
|
-
if (this.undoCursor === cursor && this.actions.length === historyLength) {
|
|
31928
|
-
this.undoCursor = index2;
|
|
31929
|
-
} else {
|
|
31930
|
-
this.actions.splice(index2, 1);
|
|
31931
|
-
this.actions.push(action);
|
|
31932
|
-
this.undoCursor = this.actions.length - 1;
|
|
31933
|
-
}
|
|
31934
|
-
} else if (index2 >= 0 && this.undoCursor === cursor && this.actions.length === historyLength) {
|
|
31935
|
-
this.undoCursor = index2 + 1;
|
|
31936
|
-
} else {
|
|
31937
|
-
if (index2 >= 0)
|
|
31938
|
-
this.actions.splice(index2, 1);
|
|
31939
|
-
this.actions.push(action);
|
|
31940
|
-
this.undoCursor = -1;
|
|
31941
|
-
}
|
|
31942
|
-
try {
|
|
31943
|
-
this.editor.input.handleChanged(action);
|
|
31944
|
-
} catch (error2) {
|
|
31945
|
-
logger$3f.error("Macro history change observer failed");
|
|
31946
|
-
}
|
|
31947
|
-
}).catch((error2) => {
|
|
31948
|
-
if (generation !== this.macroGeneration || this.destroyed)
|
|
31949
|
-
return;
|
|
31950
|
-
const failure = error2 instanceof Error ? error2 : new Error("Macro history action failed");
|
|
31951
|
-
try {
|
|
31952
|
-
action.reportError(failure);
|
|
31953
|
-
} catch (callbackError) {
|
|
31954
|
-
logger$3f.error("Macro history error callback failed");
|
|
31955
|
-
}
|
|
31956
|
-
}).finally(() => {
|
|
31957
|
-
if (generation === this.macroGeneration) {
|
|
31958
|
-
this.pendingMacroAction = null;
|
|
31959
|
-
if (!this.actions.includes(action))
|
|
31960
|
-
action.dispose();
|
|
31961
|
-
}
|
|
31962
|
-
});
|
|
31963
|
-
return true;
|
|
31769
|
+
this.editor.addListener("destroy", () => this.reset());
|
|
31964
31770
|
}
|
|
31965
31771
|
reset() {
|
|
31966
|
-
|
|
31967
|
-
this.
|
|
31968
|
-
(_a = this.pendingMacroAction) == null ? void 0 : _a.dispose();
|
|
31969
|
-
this.pendingMacroAction = null;
|
|
31970
|
-
this.actions.forEach((action) => {
|
|
31971
|
-
if (action instanceof MacroEditAction)
|
|
31972
|
-
action.dispose();
|
|
31973
|
-
});
|
|
31974
|
-
this.macroActionIds.clear();
|
|
31772
|
+
this.resetVersion += 1;
|
|
31773
|
+
this.actions.forEach((action) => this.discard(action));
|
|
31975
31774
|
this.actions = [];
|
|
31976
31775
|
this.undoCursor = -1;
|
|
31977
31776
|
}
|
|
31978
31777
|
prepareSaveUndoState() {
|
|
31778
|
+
if (this.pendingAction)
|
|
31779
|
+
throw new Error("An asynchronous undo action is pending");
|
|
31979
31780
|
if (this.undoCursor !== -1) {
|
|
31980
|
-
|
|
31981
|
-
removed.forEach((action) => {
|
|
31982
|
-
if (action instanceof MacroEditAction && action !== this.pendingMacroAction)
|
|
31983
|
-
action.dispose();
|
|
31984
|
-
});
|
|
31781
|
+
this.actions.splice(this.undoCursor).forEach((action) => this.discard(action));
|
|
31985
31782
|
this.undoCursor = -1;
|
|
31986
31783
|
}
|
|
31987
31784
|
}
|
|
31988
31785
|
addAction(action) {
|
|
31786
|
+
if (this.pendingAction)
|
|
31787
|
+
throw new Error("An asynchronous undo action is pending");
|
|
31989
31788
|
if (this.currentGroup) {
|
|
31990
31789
|
this.currentGroup.addAction(action);
|
|
31991
31790
|
} else {
|
|
@@ -31995,6 +31794,79 @@ ${codeText}
|
|
|
31995
31794
|
});
|
|
31996
31795
|
}
|
|
31997
31796
|
}
|
|
31797
|
+
addAsyncAction(operation) {
|
|
31798
|
+
if (this.currentGroup)
|
|
31799
|
+
throw new Error("An asynchronous undo action cannot join a synchronous group");
|
|
31800
|
+
this.prepareSaveUndoState();
|
|
31801
|
+
const action = new AsyncAction(this.editor, operation);
|
|
31802
|
+
this.addAction(action);
|
|
31803
|
+
return () => {
|
|
31804
|
+
const index2 = this.actions.indexOf(action);
|
|
31805
|
+
if (index2 === -1)
|
|
31806
|
+
return;
|
|
31807
|
+
this.actions.splice(index2, 1);
|
|
31808
|
+
if (this.undoCursor !== -1 && index2 < this.undoCursor)
|
|
31809
|
+
this.undoCursor -= 1;
|
|
31810
|
+
this.discard(action);
|
|
31811
|
+
};
|
|
31812
|
+
}
|
|
31813
|
+
discard(action) {
|
|
31814
|
+
var _a, _b;
|
|
31815
|
+
if (action instanceof AsyncAction)
|
|
31816
|
+
(_b = (_a = action.operation).onDiscard) == null ? void 0 : _b.call(_a);
|
|
31817
|
+
}
|
|
31818
|
+
acquireUndoLock() {
|
|
31819
|
+
const lock = Symbol("macro-edit-session");
|
|
31820
|
+
this.undoLocks.add(lock);
|
|
31821
|
+
return () => {
|
|
31822
|
+
this.undoLocks.delete(lock);
|
|
31823
|
+
};
|
|
31824
|
+
}
|
|
31825
|
+
async undoAsync() {
|
|
31826
|
+
if (this.pendingAction)
|
|
31827
|
+
return false;
|
|
31828
|
+
const accepted = this.undo();
|
|
31829
|
+
return this.pendingAction || accepted;
|
|
31830
|
+
}
|
|
31831
|
+
async redoAsync() {
|
|
31832
|
+
if (this.pendingAction)
|
|
31833
|
+
return false;
|
|
31834
|
+
const accepted = this.redo();
|
|
31835
|
+
return this.pendingAction || accepted;
|
|
31836
|
+
}
|
|
31837
|
+
runAsyncAction(action, index2, direction) {
|
|
31838
|
+
const release = this.editor.acquireReadonly();
|
|
31839
|
+
const resetVersion = this.resetVersion;
|
|
31840
|
+
this.pendingAction = Promise.resolve().then(() => action.operation[direction]()).then((success) => {
|
|
31841
|
+
if (!success)
|
|
31842
|
+
return false;
|
|
31843
|
+
if (this.resetVersion !== resetVersion || this.actions[index2] !== action)
|
|
31844
|
+
return false;
|
|
31845
|
+
this.undoCursor = direction === "undo" ? index2 : index2 + 1;
|
|
31846
|
+
const range = direction === "undo" ? action.beforeRange : action.afterRange;
|
|
31847
|
+
if (range) {
|
|
31848
|
+
try {
|
|
31849
|
+
this.editor.selection.setRange(fromDocRange(this.editor, range));
|
|
31850
|
+
} catch (error2) {
|
|
31851
|
+
logger$3f.warn(`failed to restore selection after asynchronous ${direction}`);
|
|
31852
|
+
}
|
|
31853
|
+
}
|
|
31854
|
+
this.editor.input.handleChanged(action);
|
|
31855
|
+
return true;
|
|
31856
|
+
}).catch((error2) => {
|
|
31857
|
+
try {
|
|
31858
|
+
action.operation.onError(error2);
|
|
31859
|
+
} catch (notificationError) {
|
|
31860
|
+
logger$3f.warn("failed to report asynchronous undo error");
|
|
31861
|
+
}
|
|
31862
|
+
return false;
|
|
31863
|
+
}).finally(() => {
|
|
31864
|
+
this.pendingAction = void 0;
|
|
31865
|
+
release();
|
|
31866
|
+
this.checkRange();
|
|
31867
|
+
});
|
|
31868
|
+
return true;
|
|
31869
|
+
}
|
|
31998
31870
|
beginGroup() {
|
|
31999
31871
|
if (this.groupCounter === 0) {
|
|
32000
31872
|
assert(logger$3f, !this.currentGroup, "current group already exists");
|
|
@@ -32063,22 +31935,19 @@ ${codeText}
|
|
|
32063
31935
|
}
|
|
32064
31936
|
}
|
|
32065
31937
|
undo() {
|
|
32066
|
-
if (this.
|
|
31938
|
+
if (this.pendingAction || this.undoLocks.size)
|
|
32067
31939
|
return false;
|
|
32068
|
-
const candidate = this.actions[(this.undoCursor === -1 ? this.actions.length : this.undoCursor) - 1];
|
|
32069
|
-
if (candidate instanceof MacroEditAction)
|
|
32070
|
-
return this.applyMacroAction(candidate, "undo");
|
|
32071
31940
|
if (this.undoCursor === -1) {
|
|
32072
31941
|
this.undoCursor = this.actions.length;
|
|
32073
31942
|
}
|
|
32074
31943
|
try {
|
|
32075
31944
|
this.undoRedoing = true;
|
|
32076
31945
|
while (this.undoCursor > 0) {
|
|
32077
|
-
const
|
|
32078
|
-
if (
|
|
32079
|
-
return this.
|
|
32080
|
-
}
|
|
31946
|
+
const candidate = this.actions[this.undoCursor - 1];
|
|
31947
|
+
if (candidate instanceof AsyncAction)
|
|
31948
|
+
return this.runAsyncAction(candidate, this.undoCursor - 1, "undo");
|
|
32081
31949
|
this.undoCursor -= 1;
|
|
31950
|
+
const action = this.actions[this.undoCursor];
|
|
32082
31951
|
if (action.undo(this.editor)) {
|
|
32083
31952
|
try {
|
|
32084
31953
|
this.editor.selection.setRange(fromDocRange(this.editor, action.beforeRange));
|
|
@@ -32104,11 +31973,8 @@ ${codeText}
|
|
|
32104
31973
|
}
|
|
32105
31974
|
}
|
|
32106
31975
|
redo() {
|
|
32107
|
-
if (this.
|
|
31976
|
+
if (this.pendingAction || this.undoLocks.size)
|
|
32108
31977
|
return false;
|
|
32109
|
-
const candidate = this.actions[this.undoCursor];
|
|
32110
|
-
if (candidate instanceof MacroEditAction)
|
|
32111
|
-
return this.applyMacroAction(candidate, "redo");
|
|
32112
31978
|
if (this.undoCursor === -1) {
|
|
32113
31979
|
this.undoCursor = this.actions.length;
|
|
32114
31980
|
}
|
|
@@ -32116,9 +31982,8 @@ ${codeText}
|
|
|
32116
31982
|
this.undoRedoing = true;
|
|
32117
31983
|
while (this.undoCursor < this.actions.length) {
|
|
32118
31984
|
const action = this.actions[this.undoCursor];
|
|
32119
|
-
if (action instanceof
|
|
32120
|
-
return this.
|
|
32121
|
-
}
|
|
31985
|
+
if (action instanceof AsyncAction)
|
|
31986
|
+
return this.runAsyncAction(action, this.undoCursor, "redo");
|
|
32122
31987
|
this.undoCursor += 1;
|
|
32123
31988
|
if (action.redo(this.editor)) {
|
|
32124
31989
|
try {
|
|
@@ -32147,7 +32012,7 @@ ${codeText}
|
|
|
32147
32012
|
}
|
|
32148
32013
|
}
|
|
32149
32014
|
canUndo() {
|
|
32150
|
-
if (this.
|
|
32015
|
+
if (this.pendingAction || this.undoLocks.size)
|
|
32151
32016
|
return false;
|
|
32152
32017
|
if (this.actions.length === 0) {
|
|
32153
32018
|
return false;
|
|
@@ -32158,7 +32023,7 @@ ${codeText}
|
|
|
32158
32023
|
return true;
|
|
32159
32024
|
}
|
|
32160
32025
|
canRedo() {
|
|
32161
|
-
if (this.
|
|
32026
|
+
if (this.pendingAction || this.undoLocks.size)
|
|
32162
32027
|
return false;
|
|
32163
32028
|
if (this.actions.length === 0) {
|
|
32164
32029
|
return false;
|
|
@@ -32185,10 +32050,8 @@ ${codeText}
|
|
|
32185
32050
|
if (lastAction === action) {
|
|
32186
32051
|
return true;
|
|
32187
32052
|
}
|
|
32188
|
-
if (
|
|
32189
|
-
this.undo();
|
|
32053
|
+
if (lastAction instanceof AsyncAction)
|
|
32190
32054
|
return false;
|
|
32191
|
-
}
|
|
32192
32055
|
if (!this.undo()) {
|
|
32193
32056
|
return false;
|
|
32194
32057
|
}
|
|
@@ -32725,35 +32588,6 @@ ${codeText}
|
|
|
32725
32588
|
return void 0;
|
|
32726
32589
|
}
|
|
32727
32590
|
}
|
|
32728
|
-
const editorHooks = /* @__PURE__ */ new WeakMap();
|
|
32729
|
-
function registerDocResourceHook(editor, hook) {
|
|
32730
|
-
if (editor.destroyed) {
|
|
32731
|
-
throw new Error("Cannot register a document resource hook on a destroyed editor");
|
|
32732
|
-
}
|
|
32733
|
-
const registration = { hook, collect: hook.collect, rewrite: hook.rewrite };
|
|
32734
|
-
let hooks = editorHooks.get(editor);
|
|
32735
|
-
if (!hooks) {
|
|
32736
|
-
hooks = /* @__PURE__ */ new Set();
|
|
32737
|
-
editorHooks.set(editor, hooks);
|
|
32738
|
-
}
|
|
32739
|
-
const registrations = hooks;
|
|
32740
|
-
registrations.add(registration);
|
|
32741
|
-
return () => {
|
|
32742
|
-
if (!registrations.delete(registration)) {
|
|
32743
|
-
return;
|
|
32744
|
-
}
|
|
32745
|
-
if (registrations.size === 0 && editorHooks.get(editor) === registrations) {
|
|
32746
|
-
editorHooks.delete(editor);
|
|
32747
|
-
}
|
|
32748
|
-
};
|
|
32749
|
-
}
|
|
32750
|
-
function clearDocResourceHooks(editor) {
|
|
32751
|
-
const hooks = editorHooks.get(editor);
|
|
32752
|
-
if (hooks) {
|
|
32753
|
-
hooks.clear();
|
|
32754
|
-
editorHooks.delete(editor);
|
|
32755
|
-
}
|
|
32756
|
-
}
|
|
32757
32591
|
const logger$3b = getLogger("editor");
|
|
32758
32592
|
class Editor extends tinyTypedEmitter.TypedEmitter {
|
|
32759
32593
|
constructor(parent, doc2, optionalOptions) {
|
|
@@ -32791,6 +32625,7 @@ ${codeText}
|
|
|
32791
32625
|
__publicField(this, "_readonly", false);
|
|
32792
32626
|
__publicField(this, "_scrollable", true);
|
|
32793
32627
|
__publicField(this, "_destroyed", false);
|
|
32628
|
+
__publicField(this, "readonlyLocks", /* @__PURE__ */ new Set());
|
|
32794
32629
|
__publicField(this, "getColor", (index2) => {
|
|
32795
32630
|
const colors = this.options.colors;
|
|
32796
32631
|
if (colors.length === 0) {
|
|
@@ -32846,11 +32681,21 @@ ${codeText}
|
|
|
32846
32681
|
this.emit("load", this, false);
|
|
32847
32682
|
}
|
|
32848
32683
|
get readonly() {
|
|
32849
|
-
return this._readonly;
|
|
32684
|
+
return this._readonly || this.readonlyLocks.size > 0;
|
|
32685
|
+
}
|
|
32686
|
+
acquireReadonly() {
|
|
32687
|
+
const lock = Symbol("pending-document-action");
|
|
32688
|
+
this.readonlyLocks.add(lock);
|
|
32689
|
+
this.readonly = this._readonly;
|
|
32690
|
+
return () => {
|
|
32691
|
+
if (!this.readonlyLocks.delete(lock))
|
|
32692
|
+
return;
|
|
32693
|
+
this.readonly = this._readonly;
|
|
32694
|
+
};
|
|
32850
32695
|
}
|
|
32851
32696
|
set readonly(val) {
|
|
32852
32697
|
this._readonly = val;
|
|
32853
|
-
if (
|
|
32698
|
+
if (this.readonly) {
|
|
32854
32699
|
addClass(this.rootElement, "readonly");
|
|
32855
32700
|
} else {
|
|
32856
32701
|
removeClass(this.rootElement, "readonly");
|
|
@@ -32924,21 +32769,9 @@ ${codeText}
|
|
|
32924
32769
|
createInsertion(blockContent, insertion) {
|
|
32925
32770
|
return this.editorInsertions.createInsertion(blockContent, insertion);
|
|
32926
32771
|
}
|
|
32927
|
-
addDocResourceHook(hook) {
|
|
32928
|
-
return registerDocResourceHook(this, hook);
|
|
32929
|
-
}
|
|
32930
|
-
registerMacroEditAction(options) {
|
|
32931
|
-
this.undoManager.registerMacroEditAction(options);
|
|
32932
|
-
}
|
|
32933
|
-
setMacroEditSessionActive(sessionId, active) {
|
|
32934
|
-
if (this.destroyed)
|
|
32935
|
-
return;
|
|
32936
|
-
this.undoManager.setMacroEditSessionActive(sessionId, active);
|
|
32937
|
-
}
|
|
32938
32772
|
destroy() {
|
|
32939
32773
|
logger$3b.debug("destroy editor");
|
|
32940
32774
|
this.emit("destroy", this);
|
|
32941
|
-
this.undoManager.destroy();
|
|
32942
32775
|
this.input.destroy();
|
|
32943
32776
|
this.rootContainerObject.destroy();
|
|
32944
32777
|
this.rootElement.remove();
|
|
@@ -32949,7 +32782,6 @@ ${codeText}
|
|
|
32949
32782
|
this.domEvents.destroy();
|
|
32950
32783
|
this.removeAllListeners();
|
|
32951
32784
|
this.inputHandlers.destroy();
|
|
32952
|
-
clearDocResourceHooks(this);
|
|
32953
32785
|
this._destroyed = true;
|
|
32954
32786
|
}
|
|
32955
32787
|
get destroyed() {
|
|
@@ -32964,15 +32796,7 @@ ${codeText}
|
|
|
32964
32796
|
isWritable() {
|
|
32965
32797
|
return editorIsWritable(this);
|
|
32966
32798
|
}
|
|
32967
|
-
isBlockWritable(block
|
|
32968
|
-
if (macroSessionId && this.readonly)
|
|
32969
|
-
return false;
|
|
32970
|
-
if (Array.isArray(block)) {
|
|
32971
|
-
if (block.some((item) => isWikiMacroElementLocked(this, item, macroSessionId)))
|
|
32972
|
-
return false;
|
|
32973
|
-
} else if (isWikiMacroElementLocked(this, block, macroSessionId)) {
|
|
32974
|
-
return false;
|
|
32975
|
-
}
|
|
32799
|
+
isBlockWritable(block) {
|
|
32976
32800
|
return editorIsBlockWritable(this, block);
|
|
32977
32801
|
}
|
|
32978
32802
|
getChildContainerData(childContainerId) {
|
|
@@ -33321,7 +33145,6 @@ ${codeText}
|
|
|
33321
33145
|
super();
|
|
33322
33146
|
__publicField(this, "doc");
|
|
33323
33147
|
__publicField(this, "serviceUrl");
|
|
33324
|
-
__publicField(this, "documentVersion");
|
|
33325
33148
|
if (doc2) {
|
|
33326
33149
|
this.doc = doc2;
|
|
33327
33150
|
} else {
|
|
@@ -33336,16 +33159,6 @@ ${codeText}
|
|
|
33336
33159
|
};
|
|
33337
33160
|
}
|
|
33338
33161
|
this.serviceUrl = (options == null ? void 0 : options.serverUrl) || "";
|
|
33339
|
-
this.documentVersion = options == null ? void 0 : options.documentVersion;
|
|
33340
|
-
}
|
|
33341
|
-
requestWikiMacro(message) {
|
|
33342
|
-
return Promise.reject(new WikiMacroError({ code: "READ_ONLY", message: "Local and history documents cannot edit Wiki macros" }));
|
|
33343
|
-
}
|
|
33344
|
-
onWikiMacroLocks(listener) {
|
|
33345
|
-
throw new WikiMacroError({ code: "READ_ONLY", message: "Local and history documents have no macro lock channel" });
|
|
33346
|
-
}
|
|
33347
|
-
getDocumentVersion() {
|
|
33348
|
-
return this.documentVersion;
|
|
33349
33162
|
}
|
|
33350
33163
|
beginBatchUpdate() {
|
|
33351
33164
|
return 0;
|
|
@@ -33484,9 +33297,8 @@ ${codeText}
|
|
|
33484
33297
|
getRemoteUsers() {
|
|
33485
33298
|
return new RemoteUsers();
|
|
33486
33299
|
}
|
|
33487
|
-
setDoc(doc2
|
|
33300
|
+
setDoc(doc2) {
|
|
33488
33301
|
this.doc = cloneDeep__default.default(doc2);
|
|
33489
|
-
this.documentVersion = documentVersion;
|
|
33490
33302
|
this.callbacks.forEach((c) => {
|
|
33491
33303
|
var _a;
|
|
33492
33304
|
return (_a = c.onRequestReload) == null ? void 0 : _a.call(c, "change doc");
|
|
@@ -39030,11 +38842,6 @@ ${codeText}
|
|
|
39030
38842
|
__publicField(this, "connectionStatus", null);
|
|
39031
38843
|
__publicField(this, "reauthing", false);
|
|
39032
38844
|
__publicField(this, "ready", false);
|
|
39033
|
-
__publicField(this, "macroRequests", /* @__PURE__ */ new Map());
|
|
39034
|
-
__publicField(this, "macroLocksListeners", /* @__PURE__ */ new Set());
|
|
39035
|
-
__publicField(this, "macroLocks", []);
|
|
39036
|
-
__publicField(this, "macroLocksKnown", false);
|
|
39037
|
-
__publicField(this, "macroLocksLoading", false);
|
|
39038
38845
|
__publicField(this, "pingOptions", { interval: 5e4, timeout: 15e4 });
|
|
39039
38846
|
__publicField(this, "handleAuthError", (err) => {
|
|
39040
38847
|
if (!this.renewTokenFunc) {
|
|
@@ -39082,7 +38889,6 @@ ${codeText}
|
|
|
39082
38889
|
});
|
|
39083
38890
|
__publicField(this, "handleDisconnected", (reason) => {
|
|
39084
38891
|
this.connectionDisconnected = true;
|
|
39085
|
-
this.clearWikiMacroRequests("Document disconnected; query the original request before retrying");
|
|
39086
38892
|
this.emit("disconnected", reason);
|
|
39087
38893
|
});
|
|
39088
38894
|
__publicField(this, "handleVisibilityChange", () => {
|
|
@@ -39100,111 +38906,6 @@ ${codeText}
|
|
|
39100
38906
|
this.renewTokenFunc = renewTokenFunc;
|
|
39101
38907
|
this.authMessage = authMessage;
|
|
39102
38908
|
}
|
|
39103
|
-
loadWikiMacroLocks() {
|
|
39104
|
-
if (this.closed || this.macroLocksLoading || this.macroLocksListeners.size === 0)
|
|
39105
|
-
return;
|
|
39106
|
-
this.macroLocksLoading = true;
|
|
39107
|
-
this.requestWikiMacro({ operation: "locks" }).then((result) => {
|
|
39108
|
-
if (this.closed)
|
|
39109
|
-
return;
|
|
39110
|
-
if (!Array.isArray(result.locks)) {
|
|
39111
|
-
throw new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Macro lock snapshot unavailable" });
|
|
39112
|
-
}
|
|
39113
|
-
this.notifyWikiMacroLocks(result.locks);
|
|
39114
|
-
}).catch(() => {
|
|
39115
|
-
if (!this.closed)
|
|
39116
|
-
logger$31.warn("Macro lock snapshot unavailable");
|
|
39117
|
-
}).finally(() => {
|
|
39118
|
-
this.macroLocksLoading = false;
|
|
39119
|
-
});
|
|
39120
|
-
}
|
|
39121
|
-
requestWikiMacro(message) {
|
|
39122
|
-
var _a;
|
|
39123
|
-
const requestId = genId();
|
|
39124
|
-
if (this.closed || ((_a = this.connection) == null ? void 0 : _a.state) !== "connected" || this.reauthing || this.connectionDisconnected) {
|
|
39125
|
-
return Promise.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Document connection unavailable" }, requestId));
|
|
39126
|
-
}
|
|
39127
|
-
return new Promise((resolve, reject) => {
|
|
39128
|
-
const timeout = window.setTimeout(() => {
|
|
39129
|
-
this.macroRequests.delete(requestId);
|
|
39130
|
-
reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Macro result unknown; query the original request" }, requestId));
|
|
39131
|
-
}, 6e4);
|
|
39132
|
-
this.macroRequests.set(requestId, { resolve, reject, timeout });
|
|
39133
|
-
try {
|
|
39134
|
-
this.connection.send({
|
|
39135
|
-
a: "wikiMacro",
|
|
39136
|
-
requestId,
|
|
39137
|
-
operation: message.operation,
|
|
39138
|
-
blockId: message.blockId,
|
|
39139
|
-
sessionId: message.sessionId,
|
|
39140
|
-
fence: message.fence,
|
|
39141
|
-
expectedRevision: message.expectedRevision,
|
|
39142
|
-
content: message.content,
|
|
39143
|
-
actionId: message.actionId,
|
|
39144
|
-
direction: message.direction,
|
|
39145
|
-
targetRequestId: message.targetRequestId
|
|
39146
|
-
});
|
|
39147
|
-
} catch (error2) {
|
|
39148
|
-
this.macroRequests.delete(requestId);
|
|
39149
|
-
window.clearTimeout(timeout);
|
|
39150
|
-
reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Unable to send macro request" }, requestId));
|
|
39151
|
-
}
|
|
39152
|
-
});
|
|
39153
|
-
}
|
|
39154
|
-
onWikiMacroLocks(listener) {
|
|
39155
|
-
if (this.closed) {
|
|
39156
|
-
throw new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Document connection closed" });
|
|
39157
|
-
}
|
|
39158
|
-
this.macroLocksListeners.add(listener);
|
|
39159
|
-
try {
|
|
39160
|
-
if (this.macroLocksKnown)
|
|
39161
|
-
listener(this.macroLocks || []);
|
|
39162
|
-
} catch (error2) {
|
|
39163
|
-
this.macroLocksListeners.delete(listener);
|
|
39164
|
-
throw error2;
|
|
39165
|
-
}
|
|
39166
|
-
this.loadWikiMacroLocks();
|
|
39167
|
-
return () => {
|
|
39168
|
-
this.macroLocksListeners.delete(listener);
|
|
39169
|
-
};
|
|
39170
|
-
}
|
|
39171
|
-
handleWikiMacroReply(message) {
|
|
39172
|
-
if (message.operation === "locks" && Array.isArray(message.locks)) {
|
|
39173
|
-
this.notifyWikiMacroLocks(message.locks);
|
|
39174
|
-
}
|
|
39175
|
-
if (!message.requestId)
|
|
39176
|
-
return;
|
|
39177
|
-
const pending = this.macroRequests.get(message.requestId);
|
|
39178
|
-
if (!pending)
|
|
39179
|
-
return;
|
|
39180
|
-
this.macroRequests.delete(message.requestId);
|
|
39181
|
-
window.clearTimeout(pending.timeout);
|
|
39182
|
-
if (message.error) {
|
|
39183
|
-
pending.reject(new WikiMacroError(message.error, message.requestId));
|
|
39184
|
-
} else if (message.result) {
|
|
39185
|
-
pending.resolve({ ...message.result, requestId: message.requestId });
|
|
39186
|
-
} else {
|
|
39187
|
-
pending.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Invalid macro acknowledgement" }, message.requestId));
|
|
39188
|
-
}
|
|
39189
|
-
}
|
|
39190
|
-
clearWikiMacroRequests(message) {
|
|
39191
|
-
this.macroRequests.forEach((pending, requestId) => {
|
|
39192
|
-
window.clearTimeout(pending.timeout);
|
|
39193
|
-
pending.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message }, requestId));
|
|
39194
|
-
});
|
|
39195
|
-
this.macroRequests.clear();
|
|
39196
|
-
}
|
|
39197
|
-
notifyWikiMacroLocks(locks) {
|
|
39198
|
-
this.macroLocks = locks;
|
|
39199
|
-
this.macroLocksKnown = true;
|
|
39200
|
-
this.macroLocksListeners.forEach((listener) => {
|
|
39201
|
-
try {
|
|
39202
|
-
listener(locks);
|
|
39203
|
-
} catch (error2) {
|
|
39204
|
-
logger$31.error("Wiki macro lock listener failed");
|
|
39205
|
-
}
|
|
39206
|
-
});
|
|
39207
|
-
}
|
|
39208
38909
|
getBaseURL() {
|
|
39209
38910
|
const parsedURL = new URL(this.url);
|
|
39210
38911
|
const protocol = parsedURL.protocol === "wss:" ? "https:" : "http:";
|
|
@@ -39299,10 +39000,6 @@ ${codeText}
|
|
|
39299
39000
|
const msg = message;
|
|
39300
39001
|
if (this.connection)
|
|
39301
39002
|
this.connection.lastReceiveTime = Date.now();
|
|
39302
|
-
if (msg.a === "wikiMacro") {
|
|
39303
|
-
this.handleWikiMacroReply(msg);
|
|
39304
|
-
return;
|
|
39305
|
-
}
|
|
39306
39003
|
if ("err" in msg || msg.a === "pong") {
|
|
39307
39004
|
this.handleMessage(msg);
|
|
39308
39005
|
} else {
|
|
@@ -39319,7 +39016,6 @@ ${codeText}
|
|
|
39319
39016
|
this.emit("ready");
|
|
39320
39017
|
this.ready = true;
|
|
39321
39018
|
this.connectionDisconnected = false;
|
|
39322
|
-
this.loadWikiMacroLocks();
|
|
39323
39019
|
}
|
|
39324
39020
|
}
|
|
39325
39021
|
try {
|
|
@@ -39397,10 +39093,6 @@ ${codeText}
|
|
|
39397
39093
|
end(logout) {
|
|
39398
39094
|
var _a, _b, _c, _d, _e;
|
|
39399
39095
|
this.closed = true;
|
|
39400
|
-
this.clearWikiMacroRequests("Document connection closed");
|
|
39401
|
-
this.macroLocksListeners.clear();
|
|
39402
|
-
this.macroLocks = [];
|
|
39403
|
-
this.macroLocksKnown = false;
|
|
39404
39096
|
this.renewTokenFunc = void 0;
|
|
39405
39097
|
this.removeAllListeners();
|
|
39406
39098
|
(_a = this.autoRenewToken) == null ? void 0 : _a.destroy();
|
|
@@ -39695,16 +39387,10 @@ ${codeText}
|
|
|
39695
39387
|
return versions;
|
|
39696
39388
|
}
|
|
39697
39389
|
async getVersion(ver) {
|
|
39698
|
-
return (await this.getVersionSnapshot(ver)).doc;
|
|
39699
|
-
}
|
|
39700
|
-
async getVersionSnapshot(ver) {
|
|
39701
39390
|
const server = this.apiServer();
|
|
39702
39391
|
const api = `${server}/versions/${ver}`;
|
|
39703
39392
|
const ret = await this.request(api);
|
|
39704
|
-
return
|
|
39705
|
-
doc: JSON.parse(ret.data.data),
|
|
39706
|
-
documentVersion: typeof ret.data.documentVersion === "number" ? ret.data.documentVersion : void 0
|
|
39707
|
-
};
|
|
39393
|
+
return JSON.parse(ret.data.data);
|
|
39708
39394
|
}
|
|
39709
39395
|
async getLatestVersion() {
|
|
39710
39396
|
const server = this.apiServer();
|
|
@@ -40715,21 +40401,6 @@ ${codeText}
|
|
|
40715
40401
|
this.editStatus = new EditStatus(options);
|
|
40716
40402
|
this.client.connection.addListener("opReceived", this.handleOpReceived);
|
|
40717
40403
|
}
|
|
40718
|
-
requestWikiMacro(message) {
|
|
40719
|
-
if (this.destroyed) {
|
|
40720
|
-
return Promise.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Document destroyed" }));
|
|
40721
|
-
}
|
|
40722
|
-
if (this.getUser().permission !== "w" && message.operation !== "locks" && message.operation !== "getEditResult" && message.operation !== "cancelEdit") {
|
|
40723
|
-
return Promise.reject(new WikiMacroError({ code: "READ_ONLY" }));
|
|
40724
|
-
}
|
|
40725
|
-
return this.client.connection.requestWikiMacro(message);
|
|
40726
|
-
}
|
|
40727
|
-
onWikiMacroLocks(listener) {
|
|
40728
|
-
return this.client.connection.onWikiMacroLocks(listener);
|
|
40729
|
-
}
|
|
40730
|
-
getDocumentVersion() {
|
|
40731
|
-
return typeof this.doc.version === "number" ? this.doc.version : void 0;
|
|
40732
|
-
}
|
|
40733
40404
|
beginBatchUpdate() {
|
|
40734
40405
|
this.doc.preventCompose = false;
|
|
40735
40406
|
this.batching++;
|
|
@@ -40857,6 +40528,10 @@ ${codeText}
|
|
|
40857
40528
|
});
|
|
40858
40529
|
});
|
|
40859
40530
|
}
|
|
40531
|
+
getDocumentVersion() {
|
|
40532
|
+
var _a;
|
|
40533
|
+
return (_a = this.doc.version) != null ? _a : void 0;
|
|
40534
|
+
}
|
|
40860
40535
|
toJSON() {
|
|
40861
40536
|
return editorDoc2DocObject(this.data());
|
|
40862
40537
|
}
|
|
@@ -41147,10 +40822,6 @@ ${codeText}
|
|
|
41147
40822
|
const data2 = await this.client.getVersion(ver);
|
|
41148
40823
|
return editorDoc2DocObject(data2);
|
|
41149
40824
|
}
|
|
41150
|
-
async getVersionSnapshot(ver) {
|
|
41151
|
-
const snapshot2 = await this.client.getVersionSnapshot(ver);
|
|
41152
|
-
return { doc: editorDoc2DocObject(snapshot2.doc), documentVersion: snapshot2.documentVersion };
|
|
41153
|
-
}
|
|
41154
40825
|
async getLatestVersion() {
|
|
41155
40826
|
const doc2 = await this.client.getLatestVersion();
|
|
41156
40827
|
return editorDoc2DocObject(doc2);
|
|
@@ -41497,8 +41168,7 @@ ${codeText}
|
|
|
41497
41168
|
class ShareDBLocalDoc extends LocalDoc {
|
|
41498
41169
|
constructor(docObject, _options) {
|
|
41499
41170
|
super(docObject, {
|
|
41500
|
-
serverUrl: _options.serverUrl
|
|
41501
|
-
documentVersion: _options.documentVersion
|
|
41171
|
+
serverUrl: _options.serverUrl
|
|
41502
41172
|
});
|
|
41503
41173
|
__publicField(this, "_client");
|
|
41504
41174
|
this._options = _options;
|
|
@@ -41605,16 +41275,10 @@ ${codeText}
|
|
|
41605
41275
|
return versions;
|
|
41606
41276
|
}
|
|
41607
41277
|
async getVersion(ver) {
|
|
41608
|
-
return (await this.getVersionSnapshot(ver)).doc;
|
|
41609
|
-
}
|
|
41610
|
-
async getVersionSnapshot(ver) {
|
|
41611
41278
|
const server = this.apiServer();
|
|
41612
41279
|
const api = `${server}/versions/${ver}`;
|
|
41613
41280
|
const ret = await this.request(api);
|
|
41614
|
-
return
|
|
41615
|
-
doc: JSON.parse(ret.data.data),
|
|
41616
|
-
documentVersion: typeof ret.data.documentVersion === "number" ? ret.data.documentVersion : void 0
|
|
41617
|
-
};
|
|
41281
|
+
return JSON.parse(ret.data.data);
|
|
41618
41282
|
}
|
|
41619
41283
|
async getLatestVersion() {
|
|
41620
41284
|
const server = this.apiServer();
|
|
@@ -41738,10 +41402,6 @@ ${codeText}
|
|
|
41738
41402
|
const data2 = await this.client.getVersion(ver);
|
|
41739
41403
|
return editorDoc2DocObject(data2);
|
|
41740
41404
|
}
|
|
41741
|
-
async getVersionSnapshot(ver) {
|
|
41742
|
-
const snapshot2 = await this.client.getVersionSnapshot(ver);
|
|
41743
|
-
return { doc: editorDoc2DocObject(snapshot2.doc), documentVersion: snapshot2.documentVersion };
|
|
41744
|
-
}
|
|
41745
41405
|
async getLatestVersion() {
|
|
41746
41406
|
const doc2 = await this.client.getLatestVersion();
|
|
41747
41407
|
return editorDoc2DocObject(doc2);
|
|
@@ -64331,8 +63991,6 @@ $$${mathData.mathjaxText}$$
|
|
|
64331
63991
|
const blockId = item.data;
|
|
64332
63992
|
try {
|
|
64333
63993
|
const block = editor.getBlockById(blockId);
|
|
64334
|
-
if ((item.id === "delete" || item.id === "cut") && isWikiMacroElementLocked(editor, block))
|
|
64335
|
-
return;
|
|
64336
63994
|
if (item.id === "delete") {
|
|
64337
63995
|
this.deleteBlock(editor, block);
|
|
64338
63996
|
return;
|
|
@@ -64352,7 +64010,6 @@ $$${mathData.mathjaxText}$$
|
|
|
64352
64010
|
commands(editor, blockElement) {
|
|
64353
64011
|
const locked = isBlockLocked(editor, blockElement);
|
|
64354
64012
|
const lockedBySelf = locked && isBlockLockedBySelf(editor, blockElement);
|
|
64355
|
-
const macroLeased = isWikiMacroElementLocked(editor, blockElement);
|
|
64356
64013
|
const data2 = getBlockId(blockElement);
|
|
64357
64014
|
const isEnvSecure = window.isSecureContext;
|
|
64358
64015
|
const isBlockExclusive = isExclusiveBlock(blockElement);
|
|
@@ -64374,7 +64031,7 @@ $$${mathData.mathjaxText}$$
|
|
|
64374
64031
|
data: data2,
|
|
64375
64032
|
icon: CutIcon,
|
|
64376
64033
|
order: 20,
|
|
64377
|
-
states:
|
|
64034
|
+
states: locked && !lockedBySelf || !isEnvSecure || isBlockExclusive ? ["disabled"] : [],
|
|
64378
64035
|
disableReason: !isEnvSecure ? i18n$1.t("copyCutProperty.unsafeEnvTips", {
|
|
64379
64036
|
shortCut: shortcutToDisplayText("CtrlOrCmd+X"),
|
|
64380
64037
|
operation: i18n$1.t("copyCutProperty.cut")
|
|
@@ -64386,7 +64043,7 @@ $$${mathData.mathjaxText}$$
|
|
|
64386
64043
|
data: data2,
|
|
64387
64044
|
icon: DeleteIcon,
|
|
64388
64045
|
order: 30,
|
|
64389
|
-
states:
|
|
64046
|
+
states: locked && !lockedBySelf || isBlockExclusive ? ["disabled"] : []
|
|
64390
64047
|
};
|
|
64391
64048
|
return {
|
|
64392
64049
|
group: "standard-block-actions",
|
|
@@ -64427,15 +64084,6 @@ $$${mathData.mathjaxText}$$
|
|
|
64427
64084
|
this.menu.updateItems(items);
|
|
64428
64085
|
this.commandBlock = this.currentBlock;
|
|
64429
64086
|
});
|
|
64430
|
-
__publicField(this, "handleMacroLocksChanged", () => {
|
|
64431
|
-
if (!this.menu.isVisible)
|
|
64432
|
-
return;
|
|
64433
|
-
if (!this.currentBlock || !this.editor.contains(this.currentBlock)) {
|
|
64434
|
-
this.close();
|
|
64435
|
-
return;
|
|
64436
|
-
}
|
|
64437
|
-
this.handleShow();
|
|
64438
|
-
});
|
|
64439
64087
|
__publicField(this, "handleClose", () => {
|
|
64440
64088
|
if (shouldFocusToEditor(this.editor)) {
|
|
64441
64089
|
this.editor.focus();
|
|
@@ -64461,7 +64109,6 @@ $$${mathData.mathjaxText}$$
|
|
|
64461
64109
|
this.menu.on("close", this.handleClose);
|
|
64462
64110
|
this.menu.on("click", this.handleItemClick);
|
|
64463
64111
|
editor.blockHooks.push(new StandardBlockActionHook());
|
|
64464
|
-
editor.addListener("wikiMacroLocksChanged", this.handleMacroLocksChanged);
|
|
64465
64112
|
}
|
|
64466
64113
|
addFilter(id, filter) {
|
|
64467
64114
|
var _a, _b;
|
|
@@ -64483,7 +64130,6 @@ $$${mathData.mathjaxText}$$
|
|
|
64483
64130
|
return this.menu.isVisible;
|
|
64484
64131
|
}
|
|
64485
64132
|
destroy() {
|
|
64486
|
-
this.editor.removeListener("wikiMacroLocksChanged", this.handleMacroLocksChanged);
|
|
64487
64133
|
this.menu.destroy();
|
|
64488
64134
|
}
|
|
64489
64135
|
}
|
|
@@ -84021,21 +83667,11 @@ ${docStr}
|
|
|
84021
83667
|
assert(logger$C, false, "no local actions for history doc");
|
|
84022
83668
|
}
|
|
84023
83669
|
class HistoryDoc extends EventCallbacks {
|
|
84024
|
-
constructor(server, docObject, editorOptions
|
|
83670
|
+
constructor(server, docObject, editorOptions) {
|
|
84025
83671
|
super();
|
|
84026
83672
|
this.server = server;
|
|
84027
83673
|
this.docObject = docObject;
|
|
84028
83674
|
this.editorOptions = editorOptions;
|
|
84029
|
-
this.documentVersion = documentVersion;
|
|
84030
|
-
}
|
|
84031
|
-
requestWikiMacro(message) {
|
|
84032
|
-
return Promise.reject(new WikiMacroError({ code: "READ_ONLY", message: "History documents cannot edit Wiki macros" }));
|
|
84033
|
-
}
|
|
84034
|
-
onWikiMacroLocks(listener) {
|
|
84035
|
-
throw new WikiMacroError({ code: "READ_ONLY", message: "History documents have no macro lock channel" });
|
|
84036
|
-
}
|
|
84037
|
-
getDocumentVersion() {
|
|
84038
|
-
return this.documentVersion;
|
|
84039
83675
|
}
|
|
84040
83676
|
beginBatchUpdate() {
|
|
84041
83677
|
return 0;
|
|
@@ -85028,7 +84664,6 @@ ${docStr}
|
|
|
85028
84664
|
const forceRequestVersionAsLatest = !!((_d = this.versionOptions) == null ? void 0 : _d.forceRequestVersionAsLatest);
|
|
85029
84665
|
let docObject;
|
|
85030
84666
|
let historyData;
|
|
85031
|
-
let snapshotVersion;
|
|
85032
84667
|
if (from) {
|
|
85033
84668
|
const requestVersion = forceRequestVersionAsLatest ? -1 : Math.max(version.version, from);
|
|
85034
84669
|
const requestFrom = forceRequestVersionAsLatest ? from : Math.min(version.version, from);
|
|
@@ -85036,18 +84671,12 @@ ${docStr}
|
|
|
85036
84671
|
docObject = ret.doc;
|
|
85037
84672
|
historyData = ret.historyData;
|
|
85038
84673
|
} else {
|
|
85039
|
-
|
|
85040
|
-
const snapshot2 = await this.versionHelper.getVersionSnapshot(version.version);
|
|
85041
|
-
docObject = snapshot2.doc;
|
|
85042
|
-
snapshotVersion = snapshot2.documentVersion;
|
|
85043
|
-
} else {
|
|
85044
|
-
docObject = await this.versionHelper.getVersion(version.version);
|
|
85045
|
-
}
|
|
84674
|
+
docObject = await this.versionHelper.getVersion(version.version);
|
|
85046
84675
|
historyData = [];
|
|
85047
84676
|
}
|
|
85048
84677
|
const { editorContainer: editorElement } = this.components;
|
|
85049
84678
|
editorElement.innerHTML = "";
|
|
85050
|
-
const historyDoc = new HistoryDoc(this.server, docObject, this.editorOptions
|
|
84679
|
+
const historyDoc = new HistoryDoc(this.server, docObject, this.editorOptions);
|
|
85051
84680
|
const viewer = this.provider.createHistoryEditor(editorElement, historyDoc);
|
|
85052
84681
|
viewer.editorBlockRenders.registerRender(new OnesEditorHistoryRender());
|
|
85053
84682
|
viewer.editorBoxes.registerBoxClass(HistoryDeletedTextBox);
|
|
@@ -85254,7 +84883,7 @@ ${docStr}
|
|
|
85254
84883
|
}
|
|
85255
84884
|
async function createOnesEditorHistoryDiff(parent, options) {
|
|
85256
84885
|
var _a;
|
|
85257
|
-
const historyDoc = new HistoryDoc(options.server, options.doc, options.editorOptions
|
|
84886
|
+
const historyDoc = new HistoryDoc(options.server, options.doc, options.editorOptions);
|
|
85258
84887
|
const viewer = options.provider.createHistoryEditor(parent, historyDoc);
|
|
85259
84888
|
viewer.editorBlockRenders.registerRender(new OnesEditorHistoryRender());
|
|
85260
84889
|
viewer.editorBoxes.registerBoxClass(HistoryDeletedTextBox);
|
|
@@ -98420,7 +98049,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98420
98049
|
}
|
|
98421
98050
|
}
|
|
98422
98051
|
});
|
|
98423
|
-
editor.version = "5.0.6-beta.
|
|
98052
|
+
editor.version = "5.0.6-beta.p8216.1";
|
|
98424
98053
|
return editor;
|
|
98425
98054
|
}
|
|
98426
98055
|
function isDoc(doc2) {
|
|
@@ -98556,7 +98185,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98556
98185
|
OnesEditorDropTarget.register(editor);
|
|
98557
98186
|
OnesEditorTocProvider.register(editor);
|
|
98558
98187
|
OnesEditorExclusiveBlock.register(editor);
|
|
98559
|
-
editor.version = "5.0.6-beta.
|
|
98188
|
+
editor.version = "5.0.6-beta.p8216.1";
|
|
98560
98189
|
return editor;
|
|
98561
98190
|
} catch (error2) {
|
|
98562
98191
|
try {
|
|
@@ -98699,7 +98328,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98699
98328
|
}
|
|
98700
98329
|
}
|
|
98701
98330
|
});
|
|
98702
|
-
editor.version = "5.0.6-beta.
|
|
98331
|
+
editor.version = "5.0.6-beta.p8216.1";
|
|
98703
98332
|
return editor;
|
|
98704
98333
|
}
|
|
98705
98334
|
const emojis$1 = {
|
|
@@ -144717,10 +144346,10 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144717
144346
|
exports2.UnorderedListIcon = UnorderedListIcon;
|
|
144718
144347
|
exports2.UnorderedListItem = UnorderedListItem;
|
|
144719
144348
|
exports2.VideoIcon = VideoIcon;
|
|
144349
|
+
exports2.WIKI_MACRO_TYPE = WIKI_MACRO_TYPE;
|
|
144720
144350
|
exports2.WarningFilledIcon = WarningFilledIcon;
|
|
144721
144351
|
exports2.WarningIcon = WarningIcon;
|
|
144722
144352
|
exports2.WebPageIcon = WebPageIcon;
|
|
144723
|
-
exports2.WikiMacroError = WikiMacroError;
|
|
144724
144353
|
exports2.YoukuIcon = YoukuIcon;
|
|
144725
144354
|
exports2.ZERO_WIDTH_SPACE_CHAR = ZERO_WIDTH_SPACE_CHAR;
|
|
144726
144355
|
exports2.abbreviation = abbreviation;
|
|
@@ -145073,6 +144702,8 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
145073
144702
|
exports2.getTextWidth = getTextWidth;
|
|
145074
144703
|
exports2.getToolbar = getToolbar;
|
|
145075
144704
|
exports2.getToolbarDefaultItems = getToolbarDefaultItems;
|
|
144705
|
+
exports2.getWikiMacroExportSpec = getWikiMacroExportSpec;
|
|
144706
|
+
exports2.getWikiMacroResources = getWikiMacroResources;
|
|
145076
144707
|
exports2.groupEachCommand = groupEachCommand;
|
|
145077
144708
|
exports2.handleBlockElementUpdated = handleBlockElementUpdated$1;
|
|
145078
144709
|
exports2.hasAltOnly = hasAltOnly;
|
|
@@ -145175,7 +144806,6 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
145175
144806
|
exports2.isToday = isToday;
|
|
145176
144807
|
exports2.isValidOffset = isValidOffset;
|
|
145177
144808
|
exports2.isVisibleBlock = isVisibleBlock;
|
|
145178
|
-
exports2.isWikiMacroElementLocked = isWikiMacroElementLocked;
|
|
145179
144809
|
exports2.isYesterday = isYesterday;
|
|
145180
144810
|
exports2.loadJs = loadJs;
|
|
145181
144811
|
exports2.loadJsPromise = loadJsPromise;
|
|
@@ -145212,6 +144842,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
145212
144842
|
exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
|
|
145213
144843
|
exports2.replaceAllText = replaceAllText;
|
|
145214
144844
|
exports2.replaceText = replaceText;
|
|
144845
|
+
exports2.replaceWikiMacroResources = replaceWikiMacroResources;
|
|
145215
144846
|
exports2.requestDownload = requestDownload;
|
|
145216
144847
|
exports2.resetListStart = resetListStart;
|
|
145217
144848
|
exports2.saveAs = saveAs$1;
|
|
@@ -145260,6 +144891,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
145260
144891
|
exports2.updateOpAttributes = updateOpAttributes;
|
|
145261
144892
|
exports2.updateTextBlockContent = updateTextBlockContent;
|
|
145262
144893
|
exports2.updateUrl = updateUrl;
|
|
144894
|
+
exports2.wikiMacroToText = wikiMacroToText;
|
|
145263
144895
|
for (const k in tinyTypedEmitter) {
|
|
145264
144896
|
if (k !== "default" && !exports2.hasOwnProperty(k))
|
|
145265
144897
|
Object.defineProperty(exports2, k, {
|