@ones-editor/editor 2.1.1-beta.29 → 2.1.1-beta.30
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,5 +1,8 @@
|
|
|
1
1
|
import { BlockOptions, CommandItem } from '../../../../../@ones-editor/core';
|
|
2
|
+
import { QuickMenuCommandProvider } from '../../quick-menu/types';
|
|
2
3
|
export interface QuickMenuItem extends CommandItem {
|
|
3
4
|
blockOptions?: BlockOptions;
|
|
5
|
+
commandProvider?: QuickMenuCommandProvider;
|
|
4
6
|
}
|
|
5
7
|
export declare const injectBlockOptions: (commands: QuickMenuItem[], blockOptions: BlockOptions) => void;
|
|
8
|
+
export declare const injectCommandProvider: (commands: QuickMenuItem[], commandProvider: QuickMenuCommandProvider) => void;
|
package/dist/index.js
CHANGED
|
@@ -56813,6 +56813,15 @@ $$${mathData.mathjaxText}$$
|
|
|
56813
56813
|
}
|
|
56814
56814
|
}
|
|
56815
56815
|
};
|
|
56816
|
+
const injectCommandProvider = (commands, commandProvider) => {
|
|
56817
|
+
var _a;
|
|
56818
|
+
for (const item of commands) {
|
|
56819
|
+
item.commandProvider = commandProvider;
|
|
56820
|
+
if ((_a = item.children) == null ? void 0 : _a.length) {
|
|
56821
|
+
injectCommandProvider(item.children, commandProvider);
|
|
56822
|
+
}
|
|
56823
|
+
}
|
|
56824
|
+
};
|
|
56816
56825
|
const logger$1M = getLogger("insert-menu");
|
|
56817
56826
|
const injectGroup = (commands, group, startIndex) => {
|
|
56818
56827
|
commands.forEach((command, index2) => {
|
|
@@ -56831,7 +56840,7 @@ $$${mathData.mathjaxText}$$
|
|
|
56831
56840
|
__publicField(this, "providers", []);
|
|
56832
56841
|
__publicField(this, "quickProviders", []);
|
|
56833
56842
|
__publicField(this, "getInsertCommands", (editor, containerId) => {
|
|
56834
|
-
var _a, _b, _c;
|
|
56843
|
+
var _a, _b, _c, _d;
|
|
56835
56844
|
const commands = [];
|
|
56836
56845
|
let startIndex = 100;
|
|
56837
56846
|
for (const [id, provider] of this.providersMap) {
|
|
@@ -56857,12 +56866,14 @@ $$${mathData.mathjaxText}$$
|
|
|
56857
56866
|
commands.push(...((_b = provider.getInsertCommands) == null ? void 0 : _b.call(provider, editor, containerId)) || []);
|
|
56858
56867
|
}
|
|
56859
56868
|
for (const provider of this.quickProviders) {
|
|
56860
|
-
|
|
56869
|
+
const quickCmd = (_d = (_c = provider.getCommands) == null ? void 0 : _c.call(provider, editor, { from: "block-menu" })) != null ? _d : [];
|
|
56870
|
+
injectCommandProvider(quickCmd, provider);
|
|
56871
|
+
commands.push(...quickCmd);
|
|
56861
56872
|
}
|
|
56862
56873
|
return addSection(commands);
|
|
56863
56874
|
});
|
|
56864
56875
|
__publicField(this, "getAvailableCommands", (editor, block, range) => {
|
|
56865
|
-
var _a, _b, _c;
|
|
56876
|
+
var _a, _b, _c, _d;
|
|
56866
56877
|
const commands = [];
|
|
56867
56878
|
let startIndex = 100;
|
|
56868
56879
|
for (const [id, provider] of this.providersMap) {
|
|
@@ -56888,12 +56899,14 @@ $$${mathData.mathjaxText}$$
|
|
|
56888
56899
|
commands.push(...((_b = provider.getAvailableCommands) == null ? void 0 : _b.call(provider, editor, block, range)) || []);
|
|
56889
56900
|
}
|
|
56890
56901
|
for (const provider of this.quickProviders) {
|
|
56891
|
-
|
|
56902
|
+
const quickCmd = (_d = (_c = provider.getCommands) == null ? void 0 : _c.call(provider, editor, { from: "block-menu" })) != null ? _d : [];
|
|
56903
|
+
injectCommandProvider(quickCmd, provider);
|
|
56904
|
+
commands.push(...quickCmd);
|
|
56892
56905
|
}
|
|
56893
56906
|
return addSection(commands);
|
|
56894
56907
|
});
|
|
56895
56908
|
__publicField(this, "executeInsertCommand", (editor, containerId, blockIndex, item, params) => {
|
|
56896
|
-
var _a, _b, _c, _d, _e;
|
|
56909
|
+
var _a, _b, _c, _d, _e, _f;
|
|
56897
56910
|
const quickItem = item;
|
|
56898
56911
|
if ((_a = quickItem.blockOptions) == null ? void 0 : _a.handleInsertEmptyBlock) {
|
|
56899
56912
|
(_b = quickItem.blockOptions) == null ? void 0 : _b.handleInsertEmptyBlock(editor, {
|
|
@@ -56904,24 +56917,25 @@ $$${mathData.mathjaxText}$$
|
|
|
56904
56917
|
});
|
|
56905
56918
|
return true;
|
|
56906
56919
|
}
|
|
56920
|
+
if (quickItem.commandProvider) {
|
|
56921
|
+
const params2 = { from: "block-menu", containerId, blockIndex };
|
|
56922
|
+
(_d = (_c = quickItem.commandProvider).executeCommand) == null ? void 0 : _d.call(_c, editor, item, params2);
|
|
56923
|
+
return true;
|
|
56924
|
+
}
|
|
56907
56925
|
for (const provider of this.providers) {
|
|
56908
|
-
if ((
|
|
56926
|
+
if ((_e = provider.executeInsertCommand) == null ? void 0 : _e.call(provider, editor, containerId, blockIndex, item, params)) {
|
|
56909
56927
|
return true;
|
|
56910
56928
|
}
|
|
56911
56929
|
}
|
|
56912
56930
|
for (const [id, provider] of this.providersMap) {
|
|
56913
|
-
if ((
|
|
56931
|
+
if ((_f = provider.executeInsertCommand) == null ? void 0 : _f.call(provider, editor, containerId, blockIndex, item, params)) {
|
|
56914
56932
|
return true;
|
|
56915
56933
|
}
|
|
56916
56934
|
}
|
|
56917
|
-
for (const provider of this.quickProviders) {
|
|
56918
|
-
const params2 = { from: "block-menu", containerId, blockIndex };
|
|
56919
|
-
(_e = provider.executeCommand) == null ? void 0 : _e.call(provider, editor, item, params2);
|
|
56920
|
-
}
|
|
56921
56935
|
return false;
|
|
56922
56936
|
});
|
|
56923
56937
|
__publicField(this, "executeCommand", (editor, block, range, item, params) => {
|
|
56924
|
-
var _a, _b, _c, _d, _e;
|
|
56938
|
+
var _a, _b, _c, _d, _e, _f;
|
|
56925
56939
|
const quickItem = item;
|
|
56926
56940
|
if ((_a = quickItem.blockOptions) == null ? void 0 : _a.handleInsertEmptyBlock) {
|
|
56927
56941
|
const blockIndex = editor.getBlockIndex(block);
|
|
@@ -56946,23 +56960,24 @@ $$${mathData.mathjaxText}$$
|
|
|
56946
56960
|
});
|
|
56947
56961
|
return true;
|
|
56948
56962
|
}
|
|
56963
|
+
const blockId = getBlockId(block);
|
|
56964
|
+
assert(logger$1M, range.isSimple(), "invalid range");
|
|
56965
|
+
const offset = range.start.offset;
|
|
56966
|
+
if (quickItem.commandProvider) {
|
|
56967
|
+
const params2 = { from: "quick-menu", blockId, offset };
|
|
56968
|
+
(_d = (_c = quickItem.commandProvider).executeCommand) == null ? void 0 : _d.call(_c, editor, item, params2);
|
|
56969
|
+
return true;
|
|
56970
|
+
}
|
|
56949
56971
|
for (const provider of this.providers) {
|
|
56950
|
-
if ((
|
|
56972
|
+
if ((_e = provider.executeCommand) == null ? void 0 : _e.call(provider, editor, block, range, item, params)) {
|
|
56951
56973
|
return true;
|
|
56952
56974
|
}
|
|
56953
56975
|
}
|
|
56954
|
-
const blockId = getBlockId(block);
|
|
56955
|
-
assert(logger$1M, range.isSimple(), "invalid range");
|
|
56956
|
-
const offset = range.start.offset;
|
|
56957
56976
|
for (const [id, provider] of this.providersMap) {
|
|
56958
|
-
if ((
|
|
56977
|
+
if ((_f = provider.executeCommand) == null ? void 0 : _f.call(provider, editor, block, range, item, params)) {
|
|
56959
56978
|
return true;
|
|
56960
56979
|
}
|
|
56961
56980
|
}
|
|
56962
|
-
for (const provider of this.quickProviders) {
|
|
56963
|
-
const params2 = { from: "quick-menu", blockId, offset };
|
|
56964
|
-
(_e = provider.executeCommand) == null ? void 0 : _e.call(provider, editor, item, params2);
|
|
56965
|
-
}
|
|
56966
56981
|
return false;
|
|
56967
56982
|
});
|
|
56968
56983
|
this.editor = editor;
|
|
@@ -84936,7 +84951,7 @@ ${data2.flowchartText}
|
|
|
84936
84951
|
}
|
|
84937
84952
|
}
|
|
84938
84953
|
});
|
|
84939
|
-
editor.version = "2.1.1-beta.
|
|
84954
|
+
editor.version = "2.1.1-beta.30";
|
|
84940
84955
|
if (Logger$2.level === LogLevel.DEBUG) {
|
|
84941
84956
|
window.setReauthFail = (fail) => {
|
|
84942
84957
|
window.isReauthError = fail;
|
|
@@ -85033,7 +85048,7 @@ ${data2.flowchartText}
|
|
|
85033
85048
|
});
|
|
85034
85049
|
editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
|
|
85035
85050
|
OnesEditorToolbar.register(editor);
|
|
85036
|
-
editor.version = "2.1.1-beta.
|
|
85051
|
+
editor.version = "2.1.1-beta.30";
|
|
85037
85052
|
return editor;
|
|
85038
85053
|
}
|
|
85039
85054
|
async function showDocVersions(editor, options, serverUrl) {
|