@ones-editor/editor 3.0.18-beta.1 → 3.0.19-beta.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/graph-embed/package.json +4 -3
- package/@ones-editor/graph-embed/src/config/index.d.ts +1 -1
- package/@ones-editor/sharedb-doc/src/index.d.ts +1 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/versions/src/history-diff.d.ts +12 -0
- package/@ones-editor/versions/src/index.d.ts +2 -0
- package/@ones-editor/versions/src/version-dialog/play-history.d.ts +1 -1
- package/dist/history-diff.d.ts +12 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +153 -16
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OnesEditorVersionsProvider } from './types';
|
|
2
|
+
import type { DocObject, OnesEditor, OnesEditorBlockRenderer, OnesEditorDocHistoryData, OnesEditorDocServer, OnesEditorDocVersionHelper } from '../../../@ones-editor/core';
|
|
3
|
+
export interface CreateOnesEditorHistoryDiffOptions {
|
|
4
|
+
server: OnesEditorDocServer;
|
|
5
|
+
provider: OnesEditorVersionsProvider;
|
|
6
|
+
doc: DocObject;
|
|
7
|
+
historyData: OnesEditorDocHistoryData[];
|
|
8
|
+
versionHelper: Pick<OnesEditorDocVersionHelper, 'parseHistoryData'>;
|
|
9
|
+
editorOptions?: unknown;
|
|
10
|
+
textRenders?: OnesEditorBlockRenderer[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createOnesEditorHistoryDiff(parent: HTMLElement, options: CreateOnesEditorHistoryDiffOptions): Promise<OnesEditor>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import './index.scss';
|
|
2
2
|
import './locale';
|
|
3
3
|
export { OnesEditorVersionsDialog } from './version-dialog';
|
|
4
|
+
export { createOnesEditorHistoryDiff } from './history-diff';
|
|
4
5
|
export { HISTORY_TOOLTIP_IDENTIFIER } from './constant';
|
|
5
6
|
export * from './types';
|
|
7
|
+
export type { CreateOnesEditorHistoryDiffOptions } from './history-diff';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OnesEditorDocHistoryData, OnesEditorDocVersionHelper } from '../../../../@ones-editor/core';
|
|
2
2
|
import HistoryDoc from '../history-doc';
|
|
3
|
-
export declare function playHistoryData(doc: HistoryDoc, versionHelper: OnesEditorDocVersionHelper, historyData: OnesEditorDocHistoryData[]): Promise<void>;
|
|
3
|
+
export declare function playHistoryData(doc: HistoryDoc, versionHelper: Pick<OnesEditorDocVersionHelper, 'parseHistoryData'>, historyData: OnesEditorDocHistoryData[]): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CreateOnesEditorOptions } from './types';
|
|
2
|
+
import type { EditorDoc } from '../@ones-editor/sharedb-doc';
|
|
3
|
+
import type { DocObject, OnesEditor, OnesEditorBlockRenderer, OnesEditorDocServer, OnesEditorDocVersionHelper } from '../@ones-editor/core';
|
|
4
|
+
export interface CreateDocHistoryDiffEditorOptions {
|
|
5
|
+
data: string | EditorDoc | DocObject;
|
|
6
|
+
ops?: unknown[];
|
|
7
|
+
editorOptions: CreateOnesEditorOptions;
|
|
8
|
+
server?: OnesEditorDocServer;
|
|
9
|
+
versionHelper?: Pick<OnesEditorDocVersionHelper, 'parseHistoryData'>;
|
|
10
|
+
textRenders?: OnesEditorBlockRenderer[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createDocHistoryDiffEditor(parent: HTMLElement, options: CreateDocHistoryDiffEditorOptions): Promise<OnesEditor>;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export * from './helper';
|
|
|
49
49
|
export { OnesEditorComments, OnesEditorCommentsRender } from '../@ones-editor/comments';
|
|
50
50
|
export * from '../@ones-editor/cke-html';
|
|
51
51
|
export { type DocListBlock } from '../@ones-editor/list-block';
|
|
52
|
+
export { createDocHistoryDiffEditor } from './history-diff';
|
|
53
|
+
export type { CreateDocHistoryDiffEditorOptions } from './history-diff';
|
|
52
54
|
export declare function getDefaultOnesEditorOptions(options: CreateOnesEditorOptions): {
|
|
53
55
|
id: string | undefined;
|
|
54
56
|
scrollContainer: HTMLElement | undefined;
|
|
@@ -61,7 +63,7 @@ export declare function getDefaultOnesEditorOptions(options: CreateOnesEditorOpt
|
|
|
61
63
|
embeds: import("@ones-editor/core").Embed[];
|
|
62
64
|
boxes: import("@ones-editor/core").Box[];
|
|
63
65
|
commandProviders: (import("@ones-editor/core").OnesEditorCommandProvider | TableBlockCommandProvider)[];
|
|
64
|
-
decorators: (
|
|
66
|
+
decorators: (CodeTextDecorator | RemoteCaretsDecorator)[];
|
|
65
67
|
insertions: import("@ones-editor/core").Insertion[];
|
|
66
68
|
blockHooks: (import("@ones-editor/core").OnesEditorBlockHook | BlockExclusiveHook)[];
|
|
67
69
|
textRenders: OnesEditorBlockRenderer[];
|
package/dist/index.js
CHANGED
|
@@ -83942,7 +83942,7 @@ ${docStr}
|
|
|
83942
83942
|
const getReferenceClientRect2 = () => this.getReferenceClientRect(reference);
|
|
83943
83943
|
instance.setProps({
|
|
83944
83944
|
appendTo: () => {
|
|
83945
|
-
const editorContainer = document.querySelector(".version-dialog-editor");
|
|
83945
|
+
const editorContainer = document.querySelector(".version-dialog-editor") || this.editor.rootElement.parentElement || this.editor.rootElement;
|
|
83946
83946
|
return editorContainer;
|
|
83947
83947
|
},
|
|
83948
83948
|
getReferenceClientRect: getReferenceClientRect2,
|
|
@@ -83988,6 +83988,9 @@ ${docStr}
|
|
|
83988
83988
|
}
|
|
83989
83989
|
getPseudoMaskRect(reference) {
|
|
83990
83990
|
const currentRootContainer = document.getElementById("ones-editor-container-root");
|
|
83991
|
+
if (!currentRootContainer) {
|
|
83992
|
+
return null;
|
|
83993
|
+
}
|
|
83991
83994
|
const editorRootRect = currentRootContainer.getBoundingClientRect();
|
|
83992
83995
|
const safetyLeftOffset = editorRootRect.left - this.gap;
|
|
83993
83996
|
const internalProcess = (pseudoHolder) => {
|
|
@@ -84315,6 +84318,19 @@ ${docStr}
|
|
|
84315
84318
|
(_c = this.editor) == null ? void 0 : _c.destroy();
|
|
84316
84319
|
}
|
|
84317
84320
|
}
|
|
84321
|
+
async function createOnesEditorHistoryDiff(parent, options) {
|
|
84322
|
+
var _a;
|
|
84323
|
+
const historyDoc = new HistoryDoc(options.server, options.doc, options.editorOptions);
|
|
84324
|
+
const viewer = options.provider.createHistoryEditor(parent, historyDoc);
|
|
84325
|
+
viewer.editorBlockRenders.registerRender(new OnesEditorHistoryRender());
|
|
84326
|
+
viewer.editorBoxes.registerBoxClass(HistoryDeletedTextBox);
|
|
84327
|
+
(_a = options.textRenders) == null ? void 0 : _a.forEach((render) => viewer.editorBlockRenders.registerRender(render));
|
|
84328
|
+
OnesEditorHistoryTooltip.register(viewer);
|
|
84329
|
+
addClass(viewer.rootElement, HistoryClass.HISTORY);
|
|
84330
|
+
viewer.rootElement.style.setProperty("--history-mask-identifier", `"${HISTORY_MASK_IDENTIFIER}"`);
|
|
84331
|
+
await playHistoryData(historyDoc, options.versionHelper, options.historyData);
|
|
84332
|
+
return viewer;
|
|
84333
|
+
}
|
|
84318
84334
|
const zhCN$e = {
|
|
84319
84335
|
expandCollapseButton: {
|
|
84320
84336
|
expand: "\u5C55\u5F00",
|
|
@@ -86748,7 +86764,7 @@ ${docStr}
|
|
|
86748
86764
|
},
|
|
86749
86765
|
convertTo: convertTo$6
|
|
86750
86766
|
};
|
|
86751
|
-
const MERMAID_SCRIPTS = "https://cdn.jsdelivr.net/npm/mermaid@
|
|
86767
|
+
const MERMAID_SCRIPTS = "https://cdn.jsdelivr.net/npm/mermaid@9.0.1/dist/mermaid.min.js";
|
|
86752
86768
|
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"];
|
|
86753
86769
|
const PLANTUML_PRE = "https://www.plantuml.com/plantuml/svg";
|
|
86754
86770
|
const GRAPH_MIN_HEIGHT = 150;
|
|
@@ -87465,17 +87481,22 @@ ${docStr}
|
|
|
87465
87481
|
const mermaid = window.mermaid;
|
|
87466
87482
|
assert(logger$l, mermaid, "Resource load failed: Mermaid javaScript resource injection failed");
|
|
87467
87483
|
const id = genId();
|
|
87468
|
-
|
|
87469
|
-
|
|
87470
|
-
|
|
87471
|
-
|
|
87472
|
-
|
|
87473
|
-
|
|
87474
|
-
|
|
87475
|
-
|
|
87476
|
-
|
|
87477
|
-
|
|
87478
|
-
|
|
87484
|
+
const promise = new Promise((resolve, reject) => {
|
|
87485
|
+
try {
|
|
87486
|
+
mermaid.mermaidAPI.render(id, code, (svgCode2) => {
|
|
87487
|
+
setTimeout(() => {
|
|
87488
|
+
resolve(svgCode2);
|
|
87489
|
+
});
|
|
87490
|
+
});
|
|
87491
|
+
} catch (err) {
|
|
87492
|
+
err.message = err.str;
|
|
87493
|
+
const delId = `d${id}`;
|
|
87494
|
+
const el = document.getElementById(delId);
|
|
87495
|
+
el == null ? void 0 : el.remove();
|
|
87496
|
+
reject(err);
|
|
87497
|
+
}
|
|
87498
|
+
});
|
|
87499
|
+
const svgCode = await promise;
|
|
87479
87500
|
const domParser = new DOMParser();
|
|
87480
87501
|
const xml = domParser.parseFromString(svgCode, "image/svg+xml");
|
|
87481
87502
|
const xmlSvg = xml.firstChild;
|
|
@@ -97076,6 +97097,119 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97076
97097
|
function combineRichTextValue(value1, value2) {
|
|
97077
97098
|
return combineCkeHtml(value1, value2);
|
|
97078
97099
|
}
|
|
97100
|
+
const DefaultHistoryDiffUser = {
|
|
97101
|
+
userId: "history-diff",
|
|
97102
|
+
displayName: ""
|
|
97103
|
+
};
|
|
97104
|
+
const isRecord = (value) => {
|
|
97105
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
97106
|
+
};
|
|
97107
|
+
const isDocObject = (value) => {
|
|
97108
|
+
const blocks = value.blocks;
|
|
97109
|
+
return Boolean(blocks && typeof blocks === "object" && Array.isArray(blocks.root));
|
|
97110
|
+
};
|
|
97111
|
+
const parseDocData = (data2) => {
|
|
97112
|
+
if (typeof data2 !== "string") {
|
|
97113
|
+
return data2;
|
|
97114
|
+
}
|
|
97115
|
+
const parsed = JSON.parse(data2);
|
|
97116
|
+
if (!isRecord(parsed)) {
|
|
97117
|
+
throw new Error("invalid history diff doc data");
|
|
97118
|
+
}
|
|
97119
|
+
return parsed;
|
|
97120
|
+
};
|
|
97121
|
+
const toDocObject = (data2) => {
|
|
97122
|
+
const parsed = parseDocData(data2);
|
|
97123
|
+
if (isDocObject(parsed)) {
|
|
97124
|
+
return parsed;
|
|
97125
|
+
}
|
|
97126
|
+
return editorDoc2DocObject(parsed);
|
|
97127
|
+
};
|
|
97128
|
+
const getHistoryDiffUser = (op) => {
|
|
97129
|
+
var _a;
|
|
97130
|
+
const createdBy = (_a = op.meta) == null ? void 0 : _a.createdBy;
|
|
97131
|
+
const user = op.user || createdBy;
|
|
97132
|
+
return {
|
|
97133
|
+
userId: (user == null ? void 0 : user.userId) || DefaultHistoryDiffUser.userId,
|
|
97134
|
+
displayName: (user == null ? void 0 : user.displayName) || DefaultHistoryDiffUser.displayName
|
|
97135
|
+
};
|
|
97136
|
+
};
|
|
97137
|
+
const getHistoryDiffOp = (op) => {
|
|
97138
|
+
if (Array.isArray(op.op)) {
|
|
97139
|
+
return op.op;
|
|
97140
|
+
}
|
|
97141
|
+
if (Array.isArray(op.ops)) {
|
|
97142
|
+
return op.ops;
|
|
97143
|
+
}
|
|
97144
|
+
return [];
|
|
97145
|
+
};
|
|
97146
|
+
const toHistoryData = (ops = []) => {
|
|
97147
|
+
return ops.reduce((historyData, op) => {
|
|
97148
|
+
if (!isRecord(op)) {
|
|
97149
|
+
return historyData;
|
|
97150
|
+
}
|
|
97151
|
+
const opData = op;
|
|
97152
|
+
const user = getHistoryDiffUser(opData);
|
|
97153
|
+
const normalizedOp = getHistoryDiffOp(opData);
|
|
97154
|
+
if (normalizedOp.length === 0) {
|
|
97155
|
+
return historyData;
|
|
97156
|
+
}
|
|
97157
|
+
historyData.push({
|
|
97158
|
+
user,
|
|
97159
|
+
data: {
|
|
97160
|
+
...opData,
|
|
97161
|
+
meta: {
|
|
97162
|
+
...isRecord(opData.meta) ? opData.meta : {},
|
|
97163
|
+
createdBy: user
|
|
97164
|
+
},
|
|
97165
|
+
op: normalizedOp
|
|
97166
|
+
}
|
|
97167
|
+
});
|
|
97168
|
+
return historyData;
|
|
97169
|
+
}, []);
|
|
97170
|
+
};
|
|
97171
|
+
class HistoryDiffVersionHelper {
|
|
97172
|
+
parseHistoryData(historyData, handler) {
|
|
97173
|
+
const data2 = historyData.data;
|
|
97174
|
+
parseOps(data2.op || [], handler, true);
|
|
97175
|
+
}
|
|
97176
|
+
}
|
|
97177
|
+
class HistoryDiffDocServer {
|
|
97178
|
+
constructor(editorOptions) {
|
|
97179
|
+
__publicField(this, "remoteUsers", new RemoteUsers());
|
|
97180
|
+
this.editorOptions = editorOptions;
|
|
97181
|
+
}
|
|
97182
|
+
buildResourceUrl(resourceId, options) {
|
|
97183
|
+
return resourceId;
|
|
97184
|
+
}
|
|
97185
|
+
getRemoteUsers() {
|
|
97186
|
+
return this.remoteUsers;
|
|
97187
|
+
}
|
|
97188
|
+
getServerMeta() {
|
|
97189
|
+
return {
|
|
97190
|
+
appId: this.editorOptions.appId,
|
|
97191
|
+
docId: this.editorOptions.docId,
|
|
97192
|
+
serverId: this.editorOptions.serverUrl,
|
|
97193
|
+
apiServer: this.editorOptions.serverUrl
|
|
97194
|
+
};
|
|
97195
|
+
}
|
|
97196
|
+
}
|
|
97197
|
+
async function createDocHistoryDiffEditor(parent, options) {
|
|
97198
|
+
const doc2 = toDocObject(options.data);
|
|
97199
|
+
const historyData = toHistoryData(options.ops);
|
|
97200
|
+
const server = options.server || new HistoryDiffDocServer(options.editorOptions);
|
|
97201
|
+
const versionHelper = options.versionHelper || new HistoryDiffVersionHelper();
|
|
97202
|
+
const provider = new ShareDBDocVersionsProvider(options.editorOptions);
|
|
97203
|
+
return createOnesEditorHistoryDiff(parent, {
|
|
97204
|
+
server,
|
|
97205
|
+
provider,
|
|
97206
|
+
doc: doc2,
|
|
97207
|
+
historyData,
|
|
97208
|
+
versionHelper,
|
|
97209
|
+
editorOptions: options.editorOptions,
|
|
97210
|
+
textRenders: options.textRenders
|
|
97211
|
+
});
|
|
97212
|
+
}
|
|
97079
97213
|
const logger = getLogger("create-editor");
|
|
97080
97214
|
function getHooks(options, local) {
|
|
97081
97215
|
var _a;
|
|
@@ -97335,7 +97469,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97335
97469
|
}
|
|
97336
97470
|
}
|
|
97337
97471
|
});
|
|
97338
|
-
editor.version = "3.0.
|
|
97472
|
+
editor.version = "3.0.19-beta.1";
|
|
97339
97473
|
return editor;
|
|
97340
97474
|
}
|
|
97341
97475
|
function isDoc(doc2) {
|
|
@@ -97469,7 +97603,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97469
97603
|
OnesEditorDropTarget.register(editor);
|
|
97470
97604
|
OnesEditorTocProvider.register(editor);
|
|
97471
97605
|
OnesEditorExclusiveBlock.register(editor);
|
|
97472
|
-
editor.version = "3.0.
|
|
97606
|
+
editor.version = "3.0.19-beta.1";
|
|
97473
97607
|
return editor;
|
|
97474
97608
|
}
|
|
97475
97609
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -97604,7 +97738,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97604
97738
|
}
|
|
97605
97739
|
}
|
|
97606
97740
|
});
|
|
97607
|
-
editor.version = "3.0.
|
|
97741
|
+
editor.version = "3.0.19-beta.1";
|
|
97608
97742
|
return editor;
|
|
97609
97743
|
}
|
|
97610
97744
|
const emojis$1 = {
|
|
@@ -143701,6 +143835,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
143701
143835
|
exports2.createContainer = createContainer$1;
|
|
143702
143836
|
exports2.createContainerElement = createContainerElement;
|
|
143703
143837
|
exports2.createDeleteOps = createDeleteOps;
|
|
143838
|
+
exports2.createDocHistoryDiffEditor = createDocHistoryDiffEditor;
|
|
143704
143839
|
exports2.createEditor = createEditor;
|
|
143705
143840
|
exports2.createEditorSelectionRange = createEditorSelectionRange;
|
|
143706
143841
|
exports2.createElement = createElement;
|
|
@@ -143720,6 +143855,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
143720
143855
|
exports2.createMobileBottomMenu = createMobileBottomMenu;
|
|
143721
143856
|
exports2.createMouseEventFromTouchEvent = createMouseEventFromTouchEvent;
|
|
143722
143857
|
exports2.createOnesEditor = createOnesEditor;
|
|
143858
|
+
exports2.createOnesEditorHistoryDiff = createOnesEditorHistoryDiff;
|
|
143723
143859
|
exports2.createRange = createRange;
|
|
143724
143860
|
exports2.createRichText = createRichText;
|
|
143725
143861
|
exports2.createRootContainer = createRootContainer;
|
|
@@ -144088,6 +144224,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144088
144224
|
exports2.mergeText = mergeText;
|
|
144089
144225
|
exports2.multiSplitText = multiSplitText;
|
|
144090
144226
|
exports2.overflowText = overflowText;
|
|
144227
|
+
exports2.parseOps = parseOps;
|
|
144091
144228
|
exports2.parseShortcut = parseShortcut;
|
|
144092
144229
|
exports2.patchNode = patchNode;
|
|
144093
144230
|
exports2.pointInRect = pointInRect;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-editor/editor",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.19-beta.1",
|
|
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": "^9.1.0",
|
|
52
52
|
"mime-db": "^1.52.0",
|
|
53
53
|
"nanoid": "^3.2.0",
|
|
54
54
|
"ot-json1": "^1.0.2",
|