@kerebron/extension-menu 0.3.2 → 0.4.0
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/README.md +26 -1
- package/assets/custom-menu.css +838 -0
- package/assets/menu.css +353 -26
- package/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/editor/src/CoreEditor.d.ts +13 -4
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +64 -12
- package/esm/editor/src/Extension.d.ts +6 -1
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/Extension.js +21 -1
- package/esm/editor/src/ExtensionManager.d.ts +5 -6
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.js +43 -55
- package/esm/editor/src/Mark.d.ts +3 -0
- package/esm/editor/src/Mark.d.ts.map +1 -1
- package/esm/editor/src/Mark.js +11 -0
- package/esm/editor/src/Node.d.ts +5 -2
- package/esm/editor/src/Node.d.ts.map +1 -1
- package/esm/editor/src/Node.js +13 -2
- package/esm/editor/src/commands/CommandManager.d.ts +13 -6
- package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
- package/esm/editor/src/commands/CommandManager.js +59 -2
- package/esm/editor/src/commands/baseCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/baseCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/baseCommandFactories.js +836 -0
- package/esm/editor/src/commands/keyCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/keyCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/keyCommandFactories.js +10 -0
- package/esm/editor/src/commands/mod.d.ts +5 -53
- package/esm/editor/src/commands/mod.d.ts.map +1 -1
- package/esm/editor/src/commands/mod.js +14 -821
- package/esm/editor/src/commands/replaceCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/replaceCommandFactories.js +94 -0
- package/esm/editor/src/commands/types.d.ts +18 -0
- package/esm/editor/src/commands/types.d.ts.map +1 -0
- package/esm/editor/src/commands/types.js +1 -0
- package/esm/editor/src/mod.d.ts +2 -0
- package/esm/editor/src/mod.d.ts.map +1 -1
- package/esm/editor/src/mod.js +2 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +6 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +1 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.js +24 -0
- package/esm/editor/src/types.d.ts +19 -1
- package/esm/editor/src/types.d.ts.map +1 -1
- package/esm/editor/src/ui.d.ts +15 -0
- package/esm/editor/src/ui.d.ts.map +1 -0
- package/esm/editor/src/ui.js +16 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts +9 -7
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -1
- package/esm/editor/src/utilities/SmartOutput.js +35 -20
- package/esm/extension-menu/src/CustomMenuPlugin.d.ts +61 -0
- package/esm/extension-menu/src/CustomMenuPlugin.d.ts.map +1 -0
- package/esm/extension-menu/src/CustomMenuPlugin.js +1130 -0
- package/esm/extension-menu/src/ExtensionCustomMenu.d.ts +11 -0
- package/esm/extension-menu/src/ExtensionCustomMenu.d.ts.map +1 -0
- package/esm/extension-menu/src/ExtensionCustomMenu.js +23 -0
- package/esm/extension-menu/src/buildMenu.d.ts +5 -0
- package/esm/extension-menu/src/buildMenu.d.ts.map +1 -0
- package/esm/extension-menu/src/{ExtensionMenu.js → buildMenu.js} +88 -75
- package/esm/extension-menu/src/icons.d.ts.map +1 -1
- package/esm/extension-menu/src/icons.js +5 -0
- package/esm/extension-menu/src/menu.d.ts +1 -8
- package/esm/extension-menu/src/menu.d.ts.map +1 -1
- package/esm/extension-menu/src/menu.js +9 -51
- package/esm/extension-menu/src/mod.d.ts +3 -0
- package/esm/extension-menu/src/mod.d.ts.map +1 -0
- package/esm/extension-menu/src/mod.js +2 -0
- package/package.json +8 -4
- package/esm/extension-menu/src/ExtensionMenu.d.ts +0 -17
- package/esm/extension-menu/src/ExtensionMenu.d.ts.map +0 -1
- package/esm/extension-menu/src/MenuPlugin.d.ts +0 -9
- package/esm/extension-menu/src/MenuPlugin.d.ts.map +0 -1
- package/esm/extension-menu/src/MenuPlugin.js +0 -245
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceCommandFactories.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/replaceCommandFactories.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,UAAU,CAAC;AAwHxD,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAMlE,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Fragment, Slice } from 'prosemirror-model';
|
|
2
|
+
const replaceRangeText = (range, text) => {
|
|
3
|
+
return (state, dispatch) => {
|
|
4
|
+
const tr = state.tr;
|
|
5
|
+
const from = tr.mapping.map(range.from);
|
|
6
|
+
const to = tr.mapping.map(range.to);
|
|
7
|
+
const frag = Fragment.from(state.schema.text(text));
|
|
8
|
+
const insert = new Slice(frag, 0, 0);
|
|
9
|
+
tr.replace(from, to, insert);
|
|
10
|
+
if (dispatch) {
|
|
11
|
+
dispatch(tr);
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const replaceRangeSlice = (range, insert) => {
|
|
17
|
+
return (state, dispatch) => {
|
|
18
|
+
const tr = state.tr;
|
|
19
|
+
const from = tr.mapping.map(range.from);
|
|
20
|
+
const to = tr.mapping.map(range.to);
|
|
21
|
+
tr.replace(from, to, insert);
|
|
22
|
+
if (dispatch) {
|
|
23
|
+
dispatch(tr);
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
function getTopMostBlockStartForOffset(state, offset) {
|
|
29
|
+
const { doc } = state;
|
|
30
|
+
const $pos = doc.resolve(offset);
|
|
31
|
+
const blockPos = $pos.before($pos.depth);
|
|
32
|
+
if ($pos.depth === 1)
|
|
33
|
+
return blockPos;
|
|
34
|
+
return $pos.start(1);
|
|
35
|
+
}
|
|
36
|
+
function getTopMostBlockEndForOffset(state, offset) {
|
|
37
|
+
const { doc } = state;
|
|
38
|
+
const $pos = doc.resolve(offset);
|
|
39
|
+
return $pos.end(1);
|
|
40
|
+
}
|
|
41
|
+
function getAdjacentTopBlock(state, offset) {
|
|
42
|
+
const { doc } = state;
|
|
43
|
+
if (offset < 0 || offset > doc.content.size) {
|
|
44
|
+
throw new RangeError('Offset is outside the document');
|
|
45
|
+
}
|
|
46
|
+
const $pos = doc.resolve(offset);
|
|
47
|
+
const atBlockStart = $pos.pos === $pos.start($pos.depth);
|
|
48
|
+
if (atBlockStart) {
|
|
49
|
+
return getTopMostBlockStartForOffset(state, offset);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return getTopMostBlockEndForOffset(state, offset);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const insertBlockBefore = (pos, insert) => {
|
|
56
|
+
return (state, dispatch) => {
|
|
57
|
+
const tr = state.tr;
|
|
58
|
+
const blockPos = getTopMostBlockStartForOffset(state, tr.mapping.map(pos));
|
|
59
|
+
tr.insert(blockPos, insert);
|
|
60
|
+
if (dispatch) {
|
|
61
|
+
dispatch(tr);
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const insertBlockAfter = (pos, insert) => {
|
|
67
|
+
return (state, dispatch) => {
|
|
68
|
+
const tr = state.tr;
|
|
69
|
+
const blockPos = getTopMostBlockEndForOffset(state, tr.mapping.map(pos));
|
|
70
|
+
tr.insert(blockPos, insert);
|
|
71
|
+
if (dispatch) {
|
|
72
|
+
dispatch(tr);
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const insertBlockSmart = (pos, insert) => {
|
|
78
|
+
return (state, dispatch) => {
|
|
79
|
+
const tr = state.tr;
|
|
80
|
+
const blockPos = getAdjacentTopBlock(state, tr.mapping.map(pos));
|
|
81
|
+
tr.insert(blockPos, insert);
|
|
82
|
+
if (dispatch) {
|
|
83
|
+
dispatch(tr);
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export const replaceCommandFactories = {
|
|
89
|
+
replaceRangeText,
|
|
90
|
+
replaceRangeSlice,
|
|
91
|
+
insertBlockBefore,
|
|
92
|
+
insertBlockAfter,
|
|
93
|
+
insertBlockSmart,
|
|
94
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
export { Command };
|
|
3
|
+
export type CommandFactory = (...args: any[]) => Command;
|
|
4
|
+
export interface Commands {
|
|
5
|
+
[name: string]: Command;
|
|
6
|
+
}
|
|
7
|
+
export interface CommandFactories {
|
|
8
|
+
[name: string]: CommandFactory;
|
|
9
|
+
}
|
|
10
|
+
export type CommandShortcuts = {
|
|
11
|
+
[name: string]: string;
|
|
12
|
+
};
|
|
13
|
+
export type ChainedCommands = {
|
|
14
|
+
[Item in keyof Commands]: (...args: unknown[]) => ChainedCommands;
|
|
15
|
+
} & {
|
|
16
|
+
run: () => boolean;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAEzD,MAAM,WAAW,QAAQ;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;CAChC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB;KACC,IAAI,IAAI,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,eAAe;CAClE,GACC;IACA,GAAG,EAAE,MAAM,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/editor/src/mod.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC"}
|
package/esm/editor/src/mod.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrackSelecionPlugin.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/plugins/TrackSelecionPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,mBAAoB,SAAQ,MAAM;gBACjC,MAAM,EAAE,UAAU;CAsB/B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
export class TrackSelecionPlugin extends Plugin {
|
|
3
|
+
constructor(editor) {
|
|
4
|
+
super({
|
|
5
|
+
view(editorView) {
|
|
6
|
+
return {
|
|
7
|
+
update(view, prevState) {
|
|
8
|
+
const state = view.state;
|
|
9
|
+
const prevSelection = prevState.selection;
|
|
10
|
+
const selection = state.selection;
|
|
11
|
+
if (!prevSelection.eq(selection)) {
|
|
12
|
+
const event = new CustomEvent('selection', {
|
|
13
|
+
detail: {
|
|
14
|
+
selection,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
editor.dispatchEvent(event);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -7,11 +7,14 @@ export type AnyExtensionOrReq = AnyExtension | {
|
|
|
7
7
|
requires: Array<AnyExtensionOrReq | string>;
|
|
8
8
|
};
|
|
9
9
|
export type Content = JSONContent | JSONContent[] | null;
|
|
10
|
-
export interface
|
|
10
|
+
export interface EditorConfig {
|
|
11
11
|
element: HTMLElement;
|
|
12
12
|
content: Content;
|
|
13
13
|
parseOptions: ParseOptions;
|
|
14
14
|
extensions: AnyExtensionOrReq[];
|
|
15
|
+
cdnUrl?: string;
|
|
16
|
+
uri?: string;
|
|
17
|
+
languageID?: string;
|
|
15
18
|
topNode?: string;
|
|
16
19
|
}
|
|
17
20
|
export type JSONContent = {
|
|
@@ -31,4 +34,19 @@ export type Attribute<T> = {
|
|
|
31
34
|
default: T;
|
|
32
35
|
toDom?: (node: ProseMirrorNode) => T;
|
|
33
36
|
};
|
|
37
|
+
export interface TextRange {
|
|
38
|
+
from: number;
|
|
39
|
+
to: number;
|
|
40
|
+
}
|
|
41
|
+
export interface RawTextMapEntry {
|
|
42
|
+
nodeIdx: number;
|
|
43
|
+
targetRow: number;
|
|
44
|
+
targetCol: number;
|
|
45
|
+
sourceCol?: number;
|
|
46
|
+
targetPos: number;
|
|
47
|
+
}
|
|
48
|
+
export interface RawTextResult {
|
|
49
|
+
content: string;
|
|
50
|
+
rawTextMap: Array<RawTextMapEntry>;
|
|
51
|
+
}
|
|
34
52
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/editor/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG;IAC7C,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,EAAE,GAAG,IAAI,CAAC;AAEzD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/editor/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI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,CAAC;IACX,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CoreEditor } from './CoreEditor.js';
|
|
2
|
+
interface SelectParams {
|
|
3
|
+
anchor: number;
|
|
4
|
+
scrollIntoView: boolean;
|
|
5
|
+
userEvent: string;
|
|
6
|
+
}
|
|
7
|
+
export interface EditorUi {
|
|
8
|
+
showMessage(msg: string): void;
|
|
9
|
+
showError(err: Error): void;
|
|
10
|
+
focus(): void;
|
|
11
|
+
select(params: SelectParams): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function defaultUi(editor: CoreEditor): EditorUi;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/editor/src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CAmBtD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function defaultUi(editor) {
|
|
2
|
+
return {
|
|
3
|
+
showMessage(msg) {
|
|
4
|
+
globalThis.alert(msg);
|
|
5
|
+
},
|
|
6
|
+
showError(err) {
|
|
7
|
+
globalThis.alert(err.message);
|
|
8
|
+
console.error(err);
|
|
9
|
+
},
|
|
10
|
+
focus() {
|
|
11
|
+
// editor.run.focus();
|
|
12
|
+
},
|
|
13
|
+
select({ anchor: number, scrollIntoView: boolean, userEvent: string, }) {
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export interface OutputMeta<K> {
|
|
2
|
+
pos: number;
|
|
2
3
|
rowPos: number;
|
|
3
4
|
colPos: number;
|
|
4
|
-
item
|
|
5
|
+
item?: K;
|
|
5
6
|
}
|
|
6
7
|
interface Mapping {
|
|
7
8
|
sourceNo: number;
|
|
@@ -20,20 +21,21 @@ export interface SourceMap {
|
|
|
20
21
|
export declare class SmartOutput<K> {
|
|
21
22
|
private _rowPos;
|
|
22
23
|
private _colPos;
|
|
24
|
+
private _pos;
|
|
23
25
|
private chunks;
|
|
24
26
|
private metas;
|
|
25
|
-
log(text: string, item
|
|
27
|
+
log(text: string, item?: K): void;
|
|
28
|
+
getMetas(): OutputMeta<K>[];
|
|
26
29
|
get chunkPos(): number;
|
|
27
30
|
rollback(pos: number): void;
|
|
28
31
|
get rowPos(): number;
|
|
29
32
|
get colPos(): number;
|
|
33
|
+
get pos(): number;
|
|
30
34
|
endsWith(text: string): boolean;
|
|
31
35
|
toString(): string;
|
|
32
|
-
getSourceMap(mapper: (
|
|
36
|
+
getSourceMap(mapper: (rowPos: number, colPos: number, pos: number, item?: K) => Mapping | void): SourceMap;
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
export declare function
|
|
36
|
-
/** @param {number | number[]} value */
|
|
37
|
-
export declare function encode(value: any): string;
|
|
38
|
+
export declare function decode(string: string): number[];
|
|
39
|
+
export declare function encode(value: number | number[]): string;
|
|
38
40
|
export {};
|
|
39
41
|
//# sourceMappingURL=SmartOutput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartOutput.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/SmartOutput.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SmartOutput.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/SmartOutput.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,CAAC,CAAC;CACV;AAED,UAAU,OAAO;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,CAAC,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW,CAAC,CAAC;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,IAAI,CAAK;IAEjB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,KAAK,CAA4B;IAEzC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;IAyB1B,QAAQ;IAIR,IAAI,QAAQ,WAEX;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM;IAKpB,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAET;IAED,IAAI,GAAG,WAEN;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIrB,QAAQ;IAIR,YAAY,CACV,MAAM,EAAE,CACN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,CAAC,KACL,OAAO,GAAG,IAAI,GAClB,SAAS;CA4Db;AAuDD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,YAoCpC;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,UAW9C"}
|
|
@@ -12,6 +12,12 @@ export class SmartOutput {
|
|
|
12
12
|
writable: true,
|
|
13
13
|
value: 0
|
|
14
14
|
});
|
|
15
|
+
Object.defineProperty(this, "_pos", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: 0
|
|
20
|
+
});
|
|
15
21
|
Object.defineProperty(this, "chunks", {
|
|
16
22
|
enumerable: true,
|
|
17
23
|
configurable: true,
|
|
@@ -26,8 +32,12 @@ export class SmartOutput {
|
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
34
|
log(text, item) {
|
|
35
|
+
if (text.length === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
29
38
|
this.chunks.push(text);
|
|
30
39
|
this.metas.push({
|
|
40
|
+
pos: this._pos,
|
|
31
41
|
colPos: this._colPos,
|
|
32
42
|
rowPos: this._rowPos,
|
|
33
43
|
item,
|
|
@@ -40,6 +50,10 @@ export class SmartOutput {
|
|
|
40
50
|
this._rowPos += lines.length - 1;
|
|
41
51
|
this._colPos = lines[lines.length - 1].length;
|
|
42
52
|
}
|
|
53
|
+
this._pos += text.length;
|
|
54
|
+
}
|
|
55
|
+
getMetas() {
|
|
56
|
+
return this.metas;
|
|
43
57
|
}
|
|
44
58
|
get chunkPos() {
|
|
45
59
|
return this.chunks.length;
|
|
@@ -54,6 +68,9 @@ export class SmartOutput {
|
|
|
54
68
|
get colPos() {
|
|
55
69
|
return this._colPos;
|
|
56
70
|
}
|
|
71
|
+
get pos() {
|
|
72
|
+
return this._pos;
|
|
73
|
+
}
|
|
57
74
|
endsWith(text) {
|
|
58
75
|
return this.chunks.join('').endsWith(text);
|
|
59
76
|
}
|
|
@@ -64,20 +81,31 @@ export class SmartOutput {
|
|
|
64
81
|
const mappingRows = [];
|
|
65
82
|
let lastRow = -1;
|
|
66
83
|
let lastCol = -1;
|
|
84
|
+
let prevSourceNo = 0;
|
|
85
|
+
let prevSourceRowPos = 0;
|
|
86
|
+
let prevSourceColPos = 0;
|
|
87
|
+
let prevColPos = 0;
|
|
67
88
|
for (const meta of this.metas) {
|
|
68
89
|
while (meta.rowPos >= mappingRows.length) {
|
|
69
90
|
mappingRows.push([]);
|
|
70
91
|
}
|
|
71
92
|
if (lastRow != meta.rowPos || lastCol != meta.colPos) {
|
|
72
93
|
const currentRow = mappingRows[meta.rowPos];
|
|
73
|
-
|
|
94
|
+
if (lastRow != meta.rowPos) {
|
|
95
|
+
prevColPos = 0;
|
|
96
|
+
}
|
|
97
|
+
const mapping = mapper(meta.rowPos, meta.colPos, meta.pos, meta.item);
|
|
74
98
|
if (mapping) {
|
|
75
99
|
currentRow.push([
|
|
76
|
-
meta.colPos,
|
|
77
|
-
mapping.sourceNo,
|
|
78
|
-
mapping.sourceRowPos,
|
|
79
|
-
mapping.sourceColPos,
|
|
100
|
+
meta.colPos - prevColPos,
|
|
101
|
+
mapping.sourceNo - prevSourceNo,
|
|
102
|
+
mapping.sourceRowPos - prevSourceRowPos,
|
|
103
|
+
mapping.sourceColPos - prevSourceColPos,
|
|
80
104
|
]);
|
|
105
|
+
prevColPos = meta.colPos;
|
|
106
|
+
prevSourceNo = mapping.sourceNo;
|
|
107
|
+
prevSourceRowPos = mapping.sourceRowPos;
|
|
108
|
+
prevSourceColPos = mapping.sourceColPos;
|
|
81
109
|
}
|
|
82
110
|
}
|
|
83
111
|
lastRow = meta.rowPos;
|
|
@@ -87,13 +115,6 @@ export class SmartOutput {
|
|
|
87
115
|
.map((row) => row.map((group) => encode(group))
|
|
88
116
|
.join(','))
|
|
89
117
|
.join(';');
|
|
90
|
-
mappingRows.forEach((row, rowNo) => {
|
|
91
|
-
// console.log('g', rowNo, row);
|
|
92
|
-
row.forEach((group) => {
|
|
93
|
-
const enc = encode(group);
|
|
94
|
-
// console.log('g', rowNo, group, enc, decode(enc));
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
118
|
return {
|
|
98
119
|
version: 3,
|
|
99
120
|
file: '',
|
|
@@ -139,19 +160,15 @@ function encodeVLQ(input) {
|
|
|
139
160
|
}
|
|
140
161
|
return result;
|
|
141
162
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
/** @type {Record<number, string>} */
|
|
145
|
-
let integer_to_char = {};
|
|
163
|
+
const char_to_integer = {};
|
|
164
|
+
const integer_to_char = {};
|
|
146
165
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
147
166
|
.split('')
|
|
148
167
|
.forEach(function (char, i) {
|
|
149
168
|
char_to_integer[char] = i;
|
|
150
169
|
integer_to_char[i] = char;
|
|
151
170
|
});
|
|
152
|
-
/** @param {string} string */
|
|
153
171
|
export function decode(string) {
|
|
154
|
-
/** @type {number[]} */
|
|
155
172
|
let result = [];
|
|
156
173
|
let shift = 0;
|
|
157
174
|
let value = 0;
|
|
@@ -181,7 +198,6 @@ export function decode(string) {
|
|
|
181
198
|
}
|
|
182
199
|
return result;
|
|
183
200
|
}
|
|
184
|
-
/** @param {number | number[]} value */
|
|
185
201
|
export function encode(value) {
|
|
186
202
|
if (typeof value === 'number') {
|
|
187
203
|
return encode_integer(value);
|
|
@@ -192,7 +208,6 @@ export function encode(value) {
|
|
|
192
208
|
}
|
|
193
209
|
return result;
|
|
194
210
|
}
|
|
195
|
-
/** @param {number} num */
|
|
196
211
|
function encode_integer(num) {
|
|
197
212
|
let result = '';
|
|
198
213
|
if (num < 0) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EditorState, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import type { CoreEditor } from '../../editor/src/mod.js';
|
|
4
|
+
import { CustomMenuOptions } from './ExtensionCustomMenu.js';
|
|
5
|
+
import type { MenuElement } from './menu.js';
|
|
6
|
+
interface ToolItem {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
element: MenuElement;
|
|
10
|
+
isPinned: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class CustomMenuView {
|
|
13
|
+
readonly editorView: EditorView;
|
|
14
|
+
readonly editor: CoreEditor;
|
|
15
|
+
readonly content: readonly (readonly MenuElement[])[];
|
|
16
|
+
wrapper: HTMLElement;
|
|
17
|
+
toolbar: HTMLElement;
|
|
18
|
+
overflowMenu: HTMLElement;
|
|
19
|
+
pinnedDropdownMenu: HTMLElement | null;
|
|
20
|
+
modal: HTMLElement | null;
|
|
21
|
+
tools: ToolItem[];
|
|
22
|
+
root: Document | ShadowRoot;
|
|
23
|
+
resizeHandle: HTMLElement;
|
|
24
|
+
editorContainer: HTMLElement;
|
|
25
|
+
private closeOverflowHandler;
|
|
26
|
+
private closePinnedDropdownHandler;
|
|
27
|
+
private submenuStack;
|
|
28
|
+
private pinnedDropdownStack;
|
|
29
|
+
constructor(editorView: EditorView, editor: CoreEditor, content: readonly (readonly MenuElement[])[]);
|
|
30
|
+
private initializeTools;
|
|
31
|
+
/**
|
|
32
|
+
* Generate a stable ID from a label by converting it to a kebab-case slug.
|
|
33
|
+
* Falls back to a hash if the label is empty or contains only special characters.
|
|
34
|
+
*/
|
|
35
|
+
private generateStableId;
|
|
36
|
+
/**
|
|
37
|
+
* Simple hash function for generating stable IDs from strings.
|
|
38
|
+
*/
|
|
39
|
+
private simpleHash;
|
|
40
|
+
private extractLabel;
|
|
41
|
+
private loadPinnedState;
|
|
42
|
+
private savePinnedState;
|
|
43
|
+
private showSubmenu;
|
|
44
|
+
private goBack;
|
|
45
|
+
private showPinnedDropdown;
|
|
46
|
+
private pinnedDropdownGoBack;
|
|
47
|
+
private pinnedDropdownShowSubmenu;
|
|
48
|
+
private renderPinnedDropdown;
|
|
49
|
+
private renderOverflowMenu;
|
|
50
|
+
private render;
|
|
51
|
+
private openManageModal;
|
|
52
|
+
private updateModalState;
|
|
53
|
+
private setupResize;
|
|
54
|
+
update(view: EditorView, prevState: EditorState): void;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
}
|
|
57
|
+
export declare class CustomMenuPlugin extends Plugin {
|
|
58
|
+
constructor(editor: CoreEditor, options: CustomMenuOptions);
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=CustomMenuPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMenuPlugin.d.ts","sourceRoot":"","sources":["../../../src/extension-menu/src/CustomMenuPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0B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