@ones-editor/editor 5.0.6-beta.DNP8216.1 → 5.0.6-beta.DNP8216.2
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/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +55 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29994,6 +29994,56 @@ var __publicField = (obj, key, value) => {
|
|
|
29994
29994
|
});
|
|
29995
29995
|
return true;
|
|
29996
29996
|
}
|
|
29997
|
+
const editorHooks = /* @__PURE__ */ new WeakMap();
|
|
29998
|
+
function registerDocResourceHook(editor, hook) {
|
|
29999
|
+
if (editor.destroyed) {
|
|
30000
|
+
throw new Error("Cannot register a document resource hook on a destroyed editor");
|
|
30001
|
+
}
|
|
30002
|
+
const registration = { hook, collect: hook.collect, rewrite: hook.rewrite };
|
|
30003
|
+
let hooks = editorHooks.get(editor);
|
|
30004
|
+
if (!hooks) {
|
|
30005
|
+
hooks = /* @__PURE__ */ new Set();
|
|
30006
|
+
editorHooks.set(editor, hooks);
|
|
30007
|
+
}
|
|
30008
|
+
const registrations = hooks;
|
|
30009
|
+
registrations.add(registration);
|
|
30010
|
+
return () => {
|
|
30011
|
+
if (!registrations.delete(registration)) {
|
|
30012
|
+
return;
|
|
30013
|
+
}
|
|
30014
|
+
if (registrations.size === 0 && editorHooks.get(editor) === registrations) {
|
|
30015
|
+
editorHooks.delete(editor);
|
|
30016
|
+
}
|
|
30017
|
+
};
|
|
30018
|
+
}
|
|
30019
|
+
function collectDocResourceHooks(editor, doc2, resources) {
|
|
30020
|
+
const hooks = editorHooks.get(editor);
|
|
30021
|
+
if (!hooks) {
|
|
30022
|
+
return;
|
|
30023
|
+
}
|
|
30024
|
+
for (const registration of hooks) {
|
|
30025
|
+
const ids = registration.collect.call(registration.hook, doc2);
|
|
30026
|
+
for (const id of ids) {
|
|
30027
|
+
resources.add(id);
|
|
30028
|
+
}
|
|
30029
|
+
}
|
|
30030
|
+
}
|
|
30031
|
+
function rewriteDocResourceHooks(editor, doc2, resources) {
|
|
30032
|
+
const hooks = editorHooks.get(editor);
|
|
30033
|
+
if (!hooks) {
|
|
30034
|
+
return;
|
|
30035
|
+
}
|
|
30036
|
+
for (const registration of hooks) {
|
|
30037
|
+
registration.rewrite.call(registration.hook, doc2, resources);
|
|
30038
|
+
}
|
|
30039
|
+
}
|
|
30040
|
+
function clearDocResourceHooks(editor) {
|
|
30041
|
+
const hooks = editorHooks.get(editor);
|
|
30042
|
+
if (hooks) {
|
|
30043
|
+
hooks.clear();
|
|
30044
|
+
editorHooks.delete(editor);
|
|
30045
|
+
}
|
|
30046
|
+
}
|
|
29997
30047
|
function defaultGetResourceFromBlock(editor, doc2, block, resources) {
|
|
29998
30048
|
if (block.type === "embed") {
|
|
29999
30049
|
const embedData = block.embedData;
|
|
@@ -30068,6 +30118,7 @@ var __publicField = (obj, key, value) => {
|
|
|
30068
30118
|
defaultGetResourceFromBlock(editor, doc2, block, resources);
|
|
30069
30119
|
}
|
|
30070
30120
|
});
|
|
30121
|
+
collectDocResourceHooks(editor, doc2, resources);
|
|
30071
30122
|
return Array.from(resources);
|
|
30072
30123
|
}
|
|
30073
30124
|
function injectDocToHtmlFragment(htmlFragment, doc2) {
|
|
@@ -30440,6 +30491,7 @@ ${codeText}
|
|
|
30440
30491
|
defaultReplaceBlockResources(doc2, block, resources);
|
|
30441
30492
|
}
|
|
30442
30493
|
});
|
|
30494
|
+
rewriteDocResourceHooks(editor, doc2, resources);
|
|
30443
30495
|
}
|
|
30444
30496
|
async function addLocalResourcesToDoc(editor, resources) {
|
|
30445
30497
|
let localResources = resources.filter((res) => res.indexOf(":") === -1);
|
|
@@ -32725,35 +32777,6 @@ ${codeText}
|
|
|
32725
32777
|
return void 0;
|
|
32726
32778
|
}
|
|
32727
32779
|
}
|
|
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
32780
|
const logger$3b = getLogger("editor");
|
|
32758
32781
|
class Editor extends tinyTypedEmitter.TypedEmitter {
|
|
32759
32782
|
constructor(parent, doc2, optionalOptions) {
|
|
@@ -98420,7 +98443,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98420
98443
|
}
|
|
98421
98444
|
}
|
|
98422
98445
|
});
|
|
98423
|
-
editor.version = "5.0.6-beta.DNP8216.
|
|
98446
|
+
editor.version = "5.0.6-beta.DNP8216.2";
|
|
98424
98447
|
return editor;
|
|
98425
98448
|
}
|
|
98426
98449
|
function isDoc(doc2) {
|
|
@@ -98556,7 +98579,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98556
98579
|
OnesEditorDropTarget.register(editor);
|
|
98557
98580
|
OnesEditorTocProvider.register(editor);
|
|
98558
98581
|
OnesEditorExclusiveBlock.register(editor);
|
|
98559
|
-
editor.version = "5.0.6-beta.DNP8216.
|
|
98582
|
+
editor.version = "5.0.6-beta.DNP8216.2";
|
|
98560
98583
|
return editor;
|
|
98561
98584
|
} catch (error2) {
|
|
98562
98585
|
try {
|
|
@@ -98699,7 +98722,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98699
98722
|
}
|
|
98700
98723
|
}
|
|
98701
98724
|
});
|
|
98702
|
-
editor.version = "5.0.6-beta.DNP8216.
|
|
98725
|
+
editor.version = "5.0.6-beta.DNP8216.2";
|
|
98703
98726
|
return editor;
|
|
98704
98727
|
}
|
|
98705
98728
|
const emojis$1 = {
|