@ones-editor/editor 3.0.19-beta.1 → 3.0.19
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocBlock, DocBlockDelta, DocBlockText, DocBlockTextActions, DocObject, EventCallbacks, OnesEditorDoc, OnesEditorDocCallbacks, OnesEditorUser, UploadResourceResult, OnesEditorDocServerMeta, OnesEditorDocServer } from '../../../../@ones-editor/core';
|
|
1
|
+
import { BuildResourceUrlOptions, DocBlock, DocBlockDelta, DocBlockText, DocBlockTextActions, DocObject, EventCallbacks, OnesEditorDoc, OnesEditorDocCallbacks, OnesEditorUser, UploadResourceResult, OnesEditorDocServerMeta, OnesEditorDocServer } from '../../../../@ones-editor/core';
|
|
2
2
|
import { HistoryUser } from '../types';
|
|
3
3
|
export default class HistoryDoc extends EventCallbacks<OnesEditorDocCallbacks> implements OnesEditorDoc {
|
|
4
4
|
private server;
|
|
@@ -21,7 +21,7 @@ export default class HistoryDoc extends EventCallbacks<OnesEditorDocCallbacks> i
|
|
|
21
21
|
uploadResource(): Promise<UploadResourceResult>;
|
|
22
22
|
addResources(resourceIds: string[]): Promise<string[]>;
|
|
23
23
|
getServerMeta(): OnesEditorDocServerMeta;
|
|
24
|
-
buildResourceUrl(src: string): string;
|
|
24
|
+
buildResourceUrl(src: string, options?: BuildResourceUrlOptions): string;
|
|
25
25
|
request<T>(): Promise<T>;
|
|
26
26
|
broadcastMessage(): void;
|
|
27
27
|
getUser(): OnesEditorUser;
|
package/dist/index.js
CHANGED
|
@@ -39402,40 +39402,41 @@ ${codeText}
|
|
|
39402
39402
|
return false;
|
|
39403
39403
|
}
|
|
39404
39404
|
const firstOp = ops[0];
|
|
39405
|
-
if (typeof firstOp !== "object") {
|
|
39405
|
+
if (!firstOp || typeof firstOp !== "object") {
|
|
39406
39406
|
return false;
|
|
39407
39407
|
}
|
|
39408
39408
|
if (!firstOp.i || Object.keys(firstOp).length !== 1) {
|
|
39409
39409
|
return false;
|
|
39410
39410
|
}
|
|
39411
|
-
for (let i = 1; i < ops.length;
|
|
39411
|
+
for (let i = 1; i < ops.length; ) {
|
|
39412
39412
|
const nextOp = ops[i];
|
|
39413
|
-
|
|
39413
|
+
const isArrayInsertOp = Array.isArray(nextOp);
|
|
39414
|
+
if (isArrayInsertOp && nextOp.length !== 2) {
|
|
39414
39415
|
return false;
|
|
39415
39416
|
}
|
|
39416
|
-
|
|
39417
|
-
return false;
|
|
39418
|
-
}
|
|
39419
|
-
const key = nextOp[0];
|
|
39417
|
+
const key = isArrayInsertOp ? nextOp[0] : nextOp;
|
|
39420
39418
|
if (typeof key !== "string") {
|
|
39421
39419
|
return false;
|
|
39422
39420
|
}
|
|
39423
|
-
const op = nextOp[1];
|
|
39424
|
-
if (typeof op !== "object") {
|
|
39421
|
+
const op = isArrayInsertOp ? nextOp[1] : ops[i + 1];
|
|
39422
|
+
if (!op || typeof op !== "object") {
|
|
39425
39423
|
return false;
|
|
39426
39424
|
}
|
|
39427
39425
|
if (op.i === void 0 || Object.keys(op).length !== 1) {
|
|
39428
39426
|
return false;
|
|
39429
39427
|
}
|
|
39428
|
+
i += isArrayInsertOp ? 1 : 2;
|
|
39430
39429
|
}
|
|
39431
39430
|
const blockData = firstOp.i;
|
|
39432
39431
|
assert(logger$2Y, blockData.id, "block id is required");
|
|
39433
39432
|
assert(logger$2Y, blockData.type, "block type is required");
|
|
39434
|
-
for (let i = 1; i < ops.length;
|
|
39433
|
+
for (let i = 1; i < ops.length; ) {
|
|
39435
39434
|
const nextOp = ops[i];
|
|
39436
|
-
const
|
|
39437
|
-
const
|
|
39435
|
+
const isArrayInsertOp = Array.isArray(nextOp);
|
|
39436
|
+
const key = isArrayInsertOp ? nextOp[0] : nextOp;
|
|
39437
|
+
const op = isArrayInsertOp ? nextOp[1] : ops[i + 1];
|
|
39438
39438
|
blockData[key] = op.i;
|
|
39439
|
+
i += isArrayInsertOp ? 1 : 2;
|
|
39439
39440
|
}
|
|
39440
39441
|
parser.onInsertBlock(containerId, blockIndex, blockData);
|
|
39441
39442
|
return true;
|
|
@@ -39577,6 +39578,19 @@ ${codeText}
|
|
|
39577
39578
|
}
|
|
39578
39579
|
}
|
|
39579
39580
|
}
|
|
39581
|
+
function parseBlockOps(containerId, ops, parseType, handler) {
|
|
39582
|
+
if (ops.length === 0) {
|
|
39583
|
+
return;
|
|
39584
|
+
}
|
|
39585
|
+
if (Array.isArray(ops[0])) {
|
|
39586
|
+
const blockOpsList = parseType === "remove" ? ops.concat().reverse() : ops;
|
|
39587
|
+
blockOpsList.forEach((op) => {
|
|
39588
|
+
parseBlockOp(containerId, op, parseType, handler);
|
|
39589
|
+
});
|
|
39590
|
+
return;
|
|
39591
|
+
}
|
|
39592
|
+
parseBlockOp(containerId, ops, parseType, handler);
|
|
39593
|
+
}
|
|
39580
39594
|
function parseOp(ops, parseType, handler) {
|
|
39581
39595
|
const firstOp = ops[0];
|
|
39582
39596
|
if (Array.isArray(firstOp)) {
|
|
@@ -39597,15 +39611,7 @@ ${codeText}
|
|
|
39597
39611
|
}
|
|
39598
39612
|
const containerId = rootKey;
|
|
39599
39613
|
if (Array.isArray(ops[1])) {
|
|
39600
|
-
|
|
39601
|
-
ops.slice(1).reverse().forEach((op) => {
|
|
39602
|
-
parseBlockOp(containerId, op, parseType, handler);
|
|
39603
|
-
});
|
|
39604
|
-
} else {
|
|
39605
|
-
ops.slice(1).forEach((op) => {
|
|
39606
|
-
parseBlockOp(containerId, op, parseType, handler);
|
|
39607
|
-
});
|
|
39608
|
-
}
|
|
39614
|
+
parseBlockOps(containerId, ops.slice(1), parseType, handler);
|
|
39609
39615
|
} else {
|
|
39610
39616
|
if (typeof ops[1] === "object") {
|
|
39611
39617
|
const action = ops[1];
|
|
@@ -39619,6 +39625,7 @@ ${codeText}
|
|
|
39619
39625
|
handler.onCreateContainer(containerId, action.i);
|
|
39620
39626
|
}
|
|
39621
39627
|
}
|
|
39628
|
+
parseBlockOps(containerId, ops.slice(2), parseType, handler);
|
|
39622
39629
|
} else {
|
|
39623
39630
|
assert(logger$2Y, typeof ops[1] === "number", `invalid ops[1], not a number: ${JSON.stringify(ops)}`);
|
|
39624
39631
|
parseBlockOp(containerId, ops.slice(1), parseType, handler);
|
|
@@ -83165,12 +83172,12 @@ ${docStr}
|
|
|
83165
83172
|
var _a, _b, _c;
|
|
83166
83173
|
return (_c = (_b = (_a = this.server).getServerMeta) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
83167
83174
|
}
|
|
83168
|
-
buildResourceUrl(src) {
|
|
83175
|
+
buildResourceUrl(src, options) {
|
|
83169
83176
|
var _a;
|
|
83170
83177
|
if ((_a = this.editorOptions) == null ? void 0 : _a.buildResourceUrl) {
|
|
83171
|
-
return this.editorOptions.buildResourceUrl(this, src);
|
|
83178
|
+
return this.editorOptions.buildResourceUrl(this, src, options);
|
|
83172
83179
|
}
|
|
83173
|
-
return this.server.buildResourceUrl(src);
|
|
83180
|
+
return this.server.buildResourceUrl(src, options);
|
|
83174
83181
|
}
|
|
83175
83182
|
request() {
|
|
83176
83183
|
disableLocalActions();
|
|
@@ -86764,7 +86771,7 @@ ${docStr}
|
|
|
86764
86771
|
},
|
|
86765
86772
|
convertTo: convertTo$6
|
|
86766
86773
|
};
|
|
86767
|
-
const MERMAID_SCRIPTS = "https://cdn.jsdelivr.net/npm/mermaid@
|
|
86774
|
+
const MERMAID_SCRIPTS = "https://cdn.jsdelivr.net/npm/mermaid@11.15.0/dist/mermaid.min.js";
|
|
86768
86775
|
const FLOWCHART_SCRIPTS = ["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js", "//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"];
|
|
86769
86776
|
const PLANTUML_PRE = "https://www.plantuml.com/plantuml/svg";
|
|
86770
86777
|
const GRAPH_MIN_HEIGHT = 150;
|
|
@@ -87481,22 +87488,17 @@ ${docStr}
|
|
|
87481
87488
|
const mermaid = window.mermaid;
|
|
87482
87489
|
assert(logger$l, mermaid, "Resource load failed: Mermaid javaScript resource injection failed");
|
|
87483
87490
|
const id = genId();
|
|
87484
|
-
|
|
87485
|
-
|
|
87486
|
-
|
|
87487
|
-
|
|
87488
|
-
|
|
87489
|
-
|
|
87490
|
-
|
|
87491
|
-
|
|
87492
|
-
|
|
87493
|
-
|
|
87494
|
-
|
|
87495
|
-
el == null ? void 0 : el.remove();
|
|
87496
|
-
reject(err);
|
|
87497
|
-
}
|
|
87498
|
-
});
|
|
87499
|
-
const svgCode = await promise;
|
|
87491
|
+
let svgCode = "";
|
|
87492
|
+
try {
|
|
87493
|
+
const result = await mermaid.render(id, code);
|
|
87494
|
+
svgCode = typeof result === "string" ? result : result.svg;
|
|
87495
|
+
} catch (err) {
|
|
87496
|
+
err.message = err.str || err.message;
|
|
87497
|
+
const delId = `d${id}`;
|
|
87498
|
+
const el = document.getElementById(delId);
|
|
87499
|
+
el == null ? void 0 : el.remove();
|
|
87500
|
+
throw err;
|
|
87501
|
+
}
|
|
87500
87502
|
const domParser = new DOMParser();
|
|
87501
87503
|
const xml = domParser.parseFromString(svgCode, "image/svg+xml");
|
|
87502
87504
|
const xmlSvg = xml.firstChild;
|
|
@@ -97108,6 +97110,24 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97108
97110
|
const blocks = value.blocks;
|
|
97109
97111
|
return Boolean(blocks && typeof blocks === "object" && Array.isArray(blocks.root));
|
|
97110
97112
|
};
|
|
97113
|
+
const trimTrailingSlash = (value) => {
|
|
97114
|
+
return value.replace(/\/+$/, "");
|
|
97115
|
+
};
|
|
97116
|
+
const buildDocApiServer = (editorOptions) => {
|
|
97117
|
+
const serverUrl = trimTrailingSlash(editorOptions.serverUrl);
|
|
97118
|
+
const { appId, docId } = editorOptions;
|
|
97119
|
+
if (!serverUrl || !appId || !docId) {
|
|
97120
|
+
return editorOptions.serverUrl;
|
|
97121
|
+
}
|
|
97122
|
+
const docApiServer = serverUrl + "/" + appId + "/" + docId;
|
|
97123
|
+
if (docApiServer.startsWith("ws://")) {
|
|
97124
|
+
return `http://${docApiServer.substring(5)}`;
|
|
97125
|
+
}
|
|
97126
|
+
if (docApiServer.startsWith("wss://")) {
|
|
97127
|
+
return `https://${docApiServer.substring(6)}`;
|
|
97128
|
+
}
|
|
97129
|
+
return docApiServer;
|
|
97130
|
+
};
|
|
97111
97131
|
const parseDocData = (data2) => {
|
|
97112
97132
|
if (typeof data2 !== "string") {
|
|
97113
97133
|
return data2;
|
|
@@ -97190,7 +97210,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97190
97210
|
appId: this.editorOptions.appId,
|
|
97191
97211
|
docId: this.editorOptions.docId,
|
|
97192
97212
|
serverId: this.editorOptions.serverUrl,
|
|
97193
|
-
apiServer: this.editorOptions
|
|
97213
|
+
apiServer: buildDocApiServer(this.editorOptions)
|
|
97194
97214
|
};
|
|
97195
97215
|
}
|
|
97196
97216
|
}
|
|
@@ -97469,7 +97489,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97469
97489
|
}
|
|
97470
97490
|
}
|
|
97471
97491
|
});
|
|
97472
|
-
editor.version = "3.0.19
|
|
97492
|
+
editor.version = "3.0.19";
|
|
97473
97493
|
return editor;
|
|
97474
97494
|
}
|
|
97475
97495
|
function isDoc(doc2) {
|
|
@@ -97603,7 +97623,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97603
97623
|
OnesEditorDropTarget.register(editor);
|
|
97604
97624
|
OnesEditorTocProvider.register(editor);
|
|
97605
97625
|
OnesEditorExclusiveBlock.register(editor);
|
|
97606
|
-
editor.version = "3.0.19
|
|
97626
|
+
editor.version = "3.0.19";
|
|
97607
97627
|
return editor;
|
|
97608
97628
|
}
|
|
97609
97629
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -97738,7 +97758,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97738
97758
|
}
|
|
97739
97759
|
}
|
|
97740
97760
|
});
|
|
97741
|
-
editor.version = "3.0.19
|
|
97761
|
+
editor.version = "3.0.19";
|
|
97742
97762
|
return editor;
|
|
97743
97763
|
}
|
|
97744
97764
|
const emojis$1 = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-editor/editor",
|
|
3
|
-
"version": "3.0.19
|
|
3
|
+
"version": "3.0.19",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"marked-extended-latex": "^1.1.0",
|
|
49
49
|
"markmap-common": "0.15.3",
|
|
50
50
|
"markmap-view": "0.15.4",
|
|
51
|
-
"mermaid": "
|
|
51
|
+
"mermaid": "11.15.0",
|
|
52
52
|
"mime-db": "^1.52.0",
|
|
53
53
|
"nanoid": "^3.2.0",
|
|
54
54
|
"ot-json1": "^1.0.2",
|