@kerebron/extension-menu 0.4.26 → 0.4.27

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,11 +0,0 @@
1
- import { Plugin } from 'prosemirror-state';
2
- import { Extension } from '@kerebron/editor';
3
- import { type MenuElement } from './menu.js';
4
- export interface CustomMenuOptions {
5
- content: readonly (readonly MenuElement[])[];
6
- }
7
- export declare class ExtensionCustomMenu extends Extension {
8
- name: string;
9
- getProseMirrorPlugins(): Plugin[];
10
- }
11
- //# sourceMappingURL=ExtensionCustomMenu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionCustomMenu.d.ts","sourceRoot":"","sources":["../src/ExtensionCustomMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,WAAW,iBAAiB;IAEhC,OAAO,EAAE,SAAS,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,CAAC;CAC9C;AAGD,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,IAAI,SAAgB;IAEX,qBAAqB,IAAI,MAAM,EAAE;CAY3C"}
@@ -1,18 +0,0 @@
1
- import { Extension } from '@kerebron/editor';
2
- import { buildMenu } from './buildMenu.js';
3
- import { CustomMenuPlugin } from './CustomMenuPlugin.js';
4
- /// Extension for a customizable menu with pinned items
5
- export class ExtensionCustomMenu extends Extension {
6
- name = 'customMenu';
7
- getProseMirrorPlugins() {
8
- if (!this.editor.config.element) {
9
- return [];
10
- }
11
- const content = buildMenu(this.editor, this.editor.schema);
12
- return [
13
- new CustomMenuPlugin(this.editor, {
14
- content,
15
- }),
16
- ];
17
- }
18
- }
@@ -1,2 +0,0 @@
1
- export declare const dntGlobalThis: Omit<typeof globalThis, never>;
2
- //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
package/esm/_dnt.shims.js DELETED
@@ -1,57 +0,0 @@
1
- const dntGlobals = {};
2
- export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
3
- function createMergeProxy(baseObj, extObj) {
4
- return new Proxy(baseObj, {
5
- get(_target, prop, _receiver) {
6
- if (prop in extObj) {
7
- return extObj[prop];
8
- }
9
- else {
10
- return baseObj[prop];
11
- }
12
- },
13
- set(_target, prop, value) {
14
- if (prop in extObj) {
15
- delete extObj[prop];
16
- }
17
- baseObj[prop] = value;
18
- return true;
19
- },
20
- deleteProperty(_target, prop) {
21
- let success = false;
22
- if (prop in extObj) {
23
- delete extObj[prop];
24
- success = true;
25
- }
26
- if (prop in baseObj) {
27
- delete baseObj[prop];
28
- success = true;
29
- }
30
- return success;
31
- },
32
- ownKeys(_target) {
33
- const baseKeys = Reflect.ownKeys(baseObj);
34
- const extKeys = Reflect.ownKeys(extObj);
35
- const extKeysSet = new Set(extKeys);
36
- return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
37
- },
38
- defineProperty(_target, prop, desc) {
39
- if (prop in extObj) {
40
- delete extObj[prop];
41
- }
42
- Reflect.defineProperty(baseObj, prop, desc);
43
- return true;
44
- },
45
- getOwnPropertyDescriptor(_target, prop) {
46
- if (prop in extObj) {
47
- return Reflect.getOwnPropertyDescriptor(extObj, prop);
48
- }
49
- else {
50
- return Reflect.getOwnPropertyDescriptor(baseObj, prop);
51
- }
52
- },
53
- has(_target, prop) {
54
- return prop in extObj || prop in baseObj;
55
- },
56
- });
57
- }
@@ -1,5 +0,0 @@
1
- import { Schema } from 'prosemirror-model';
2
- import { type CoreEditor } from '@kerebron/editor';
3
- import { type MenuElement } from './menu.js';
4
- export declare function buildMenu(editor: CoreEditor, schema: Schema): MenuElement[][];
5
- //# sourceMappingURL=buildMenu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildMenu.d.ts","sourceRoot":"","sources":["../src/buildMenu.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAGL,KAAK,WAAW,EAGjB,MAAM,WAAW,CAAC;AAoCnB,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE,CAgX7E"}
package/esm/buildMenu.js DELETED
@@ -1,331 +0,0 @@
1
- import { NodeSelection } from 'prosemirror-state';
2
- import { EditorView } from 'prosemirror-view';
3
- import { Dropdown, DropdownSubmenu, MenuItem, } from './menu.js';
4
- import { icons } from './icons.js';
5
- import { openPrompt, TextField } from './prompt.js';
6
- function canInsert(state, nodeType) {
7
- let $from = state.selection.$from;
8
- for (let d = $from.depth; d >= 0; d--) {
9
- let index = $from.index(d);
10
- if ($from.node(d).canReplaceWith(index, index, nodeType))
11
- return true;
12
- }
13
- return false;
14
- }
15
- function cmdItem(cmd, options) {
16
- let passedOptions = {
17
- label: options.title,
18
- run: cmd,
19
- };
20
- for (let prop in options) {
21
- passedOptions[prop] = options[prop];
22
- }
23
- if (!options.enable && !options.select) {
24
- passedOptions[options.enable ? 'enable' : 'select'] = (state) => cmd(state);
25
- }
26
- return new MenuItem(passedOptions);
27
- }
28
- function markActive(state, type) {
29
- let { from, $from, to, empty } = state.selection;
30
- if (empty)
31
- return !!type.isInSet(state.storedMarks || $from.marks());
32
- else
33
- return state.doc.rangeHasMark(from, to, type);
34
- }
35
- const cut = (arr) => arr.filter((x) => x);
36
- export function buildMenu(editor, schema) {
37
- function markItem(markType, options) {
38
- let passedOptions = {
39
- active(state) {
40
- return markActive(state, markType);
41
- },
42
- };
43
- for (let prop in options) {
44
- passedOptions[prop] = options[prop];
45
- }
46
- return cmdItem(editor.commandFactories.toggleMark(markType), passedOptions);
47
- }
48
- function wrapItem(nodeType, options) {
49
- let passedOptions = {
50
- run(state, dispatch) {
51
- return editor.commandFactories.wrapIn(nodeType, options.attrs)(state, dispatch);
52
- },
53
- select(state) {
54
- return editor.commandFactories.wrapIn(nodeType, options.attrs)(state);
55
- },
56
- };
57
- for (let prop in options) {
58
- passedOptions[prop] = options[prop];
59
- }
60
- return new MenuItem(passedOptions);
61
- }
62
- function wrapListItem(nodeType, options) {
63
- return cmdItem(editor.commandFactories.wrapInList(nodeType, options.attrs), options);
64
- }
65
- /// Build a menu item for changing the type of the textblock around the
66
- /// selection to the given type. Provides `run`, `active`, and `select`
67
- /// properties. Others must be given in `options`. `options.attrs` may
68
- /// be an object to provide the attributes for the textblock node.
69
- function blockTypeItem(nodeType, options) {
70
- let command = editor.commandFactories.setBlockType(nodeType, options.attrs);
71
- let passedOptions = {
72
- run: command,
73
- enable(state) {
74
- return command(state);
75
- },
76
- active(state) {
77
- let { $from, to, node } = state.selection;
78
- if (node)
79
- return node.hasMarkup(nodeType, options.attrs);
80
- return to <= $from.end() &&
81
- $from.parent.hasMarkup(nodeType, options.attrs);
82
- },
83
- };
84
- for (let prop in options) {
85
- passedOptions[prop] = options[prop];
86
- }
87
- return new MenuItem(passedOptions);
88
- }
89
- const menu = [];
90
- if (schema.marks.strong) {
91
- menu.push(new MenuItem({
92
- title: 'Toggle strong assets',
93
- run: () => editor.chain().toggleStrong().run(),
94
- enable: (state) => editor.can().toggleStrong().run(),
95
- icon: icons.strong,
96
- }));
97
- }
98
- if (schema.marks.em) {
99
- menu.push(new MenuItem({
100
- title: 'Toggle emphasis',
101
- run: () => editor.chain().toggleItalic().run(),
102
- enable: (state) => editor.can().toggleItalic().run(),
103
- icon: icons.em,
104
- }));
105
- }
106
- if (schema.marks.underline) {
107
- menu.push(new MenuItem({
108
- title: 'Toggle underline',
109
- label: '_',
110
- run: () => editor.chain().toggleUnderline().run(),
111
- enable: (state) => editor.can().toggleUnderline().run(),
112
- icon: icons.underline,
113
- }));
114
- }
115
- if (schema.marks.code) {
116
- menu.push(markItem(schema.marks.code, {
117
- title: 'Toggle code font',
118
- icon: icons.code,
119
- }));
120
- }
121
- if (schema.marks.link) {
122
- const markType = schema.marks.link;
123
- menu.push(new MenuItem({
124
- title: 'Add or remove link',
125
- icon: icons.link,
126
- active(state) {
127
- return markActive(state, markType);
128
- },
129
- enable(state) {
130
- return !state.selection.empty;
131
- },
132
- run(state, dispatch) {
133
- if (markActive(state, markType)) {
134
- editor.commandFactories.toggleMark(markType)(state, dispatch);
135
- return true;
136
- }
137
- openPrompt({
138
- title: 'Create a link',
139
- fields: {
140
- href: new TextField({
141
- label: 'Link target',
142
- required: true,
143
- }),
144
- title: new TextField({ label: 'Title' }),
145
- },
146
- callback(attrs) {
147
- editor.commandFactories.toggleMark(markType, attrs)(editor.view.state, editor.view.dispatch);
148
- editor.view.focus();
149
- },
150
- });
151
- return true;
152
- },
153
- }));
154
- }
155
- const blockMenu = [];
156
- const insertMenu = [];
157
- const typeMenu = [];
158
- if (schema.nodes.bullet_list) {
159
- blockMenu.push(wrapListItem(schema.nodes.bullet_list, {
160
- title: 'Wrap in bullet list',
161
- icon: icons.bulletList,
162
- }));
163
- }
164
- if (schema.nodes.ordered_list) {
165
- blockMenu.push(wrapListItem(schema.nodes.ordered_list, {
166
- title: 'Wrap in ordered list',
167
- icon: icons.orderedList,
168
- }));
169
- }
170
- if (schema.nodes.blockquote) {
171
- blockMenu.push(wrapItem(schema.nodes.blockquote, {
172
- title: 'Wrap in block quote',
173
- icon: icons.blockquote,
174
- }));
175
- }
176
- if (schema.nodes.paragraph) {
177
- typeMenu.push(blockTypeItem(schema.nodes.paragraph, {
178
- title: 'Change to paragraph',
179
- label: 'Plain',
180
- }));
181
- }
182
- if (schema.nodes.code_block) {
183
- typeMenu.push(blockTypeItem(schema.nodes.code_block, {
184
- title: 'Change to code block',
185
- label: 'Code',
186
- }));
187
- }
188
- if (schema.nodes.heading) {
189
- const makeHeadMenu = [];
190
- for (let i = 1; i <= 6; i++) {
191
- makeHeadMenu.push(blockTypeItem(schema.nodes.heading, {
192
- title: 'Change to heading ' + i,
193
- label: 'Heading ' + i,
194
- attrs: { level: i },
195
- }));
196
- }
197
- typeMenu.push(new DropdownSubmenu(makeHeadMenu, { label: 'Headings' }));
198
- }
199
- blockMenu.push(new MenuItem({
200
- title: 'Join with above block',
201
- run: () => editor.chain().joinUp().run(),
202
- select: () => editor.can().joinUp().run(),
203
- icon: icons.join,
204
- }));
205
- blockMenu.push(new MenuItem({
206
- title: 'Lift out of enclosing block',
207
- run: () => editor.chain().lift().run(),
208
- select: () => editor.can().lift().run(),
209
- icon: icons.lift,
210
- }));
211
- blockMenu.push(new MenuItem({
212
- title: 'Select parent node',
213
- run: () => editor.chain().selectParentNode().run(),
214
- select: () => editor.can().selectParentNode().run(),
215
- icon: icons.selectParentNode,
216
- }));
217
- if (schema.nodes.image) {
218
- const nodeType = schema.nodes.image;
219
- insertMenu.push(new MenuItem({
220
- title: 'Insert image',
221
- label: 'Image',
222
- // enable: (state) => editor.can().setHorizontalRule().run(),
223
- enable: (state) => canInsert(state, nodeType),
224
- run(state, dispatch) {
225
- let { from, to } = state.selection, attrs = null;
226
- if (state.selection instanceof NodeSelection &&
227
- state.selection.node.type == nodeType) {
228
- attrs = state.selection.node.attrs;
229
- }
230
- openPrompt({
231
- title: 'Insert image',
232
- fields: {
233
- src: new TextField({
234
- label: 'Location',
235
- required: true,
236
- value: attrs && attrs.src,
237
- }),
238
- title: new TextField({
239
- label: 'Title',
240
- value: attrs && attrs.title,
241
- }),
242
- alt: new TextField({
243
- label: 'Description',
244
- value: attrs ? attrs.alt : state.doc.textBetween(from, to, ' '),
245
- }),
246
- },
247
- callback(attrs) {
248
- editor.view.dispatch(editor.view.state.tr.replaceSelectionWith(nodeType.createAndFill(attrs)));
249
- editor.view.focus();
250
- },
251
- });
252
- return true;
253
- },
254
- }));
255
- }
256
- if (schema.nodes.hr) {
257
- insertMenu.push(new MenuItem({
258
- title: 'Insert horizontal rule',
259
- label: 'Horizontal rule',
260
- run: () => editor.chain().setHorizontalRule().run(),
261
- enable: (state) => editor.can().setHorizontalRule().run(),
262
- }));
263
- }
264
- menu.push(new Dropdown(cut(insertMenu), {
265
- label: 'Insert',
266
- }));
267
- menu.push(new Dropdown(cut(typeMenu), {
268
- label: 'Type',
269
- }));
270
- /*
271
- r.blockMenu = [
272
- cut([
273
- r.wrapBulletList,
274
- r.wrapOrderedList,
275
- r.wrapBlockQuote,
276
- joinUpItem,
277
- liftItem,
278
- selectParentNodeItem,
279
- ]),
280
- ];
281
- */
282
- const editorView = editor.view;
283
- if (editorView instanceof EditorView) {
284
- menu.push(new MenuItem({
285
- title: 'Undo last change',
286
- run: (state, dispatch) => {
287
- return editor.commandFactories.undo()(editor.view.state, editor.view.dispatch, editorView);
288
- },
289
- enable: (state) => {
290
- return editor.commandFactories.undo()(state);
291
- },
292
- icon: icons.undo,
293
- }));
294
- menu.push(new MenuItem({
295
- title: 'Redo last undone change',
296
- run: (state, dispatch) => {
297
- return editor.commandFactories.redo()(state, dispatch);
298
- },
299
- enable: (state) => editor.commandFactories.redo()(state),
300
- icon: icons.redo,
301
- }));
302
- }
303
- if (schema.nodes.table) {
304
- const item = (label, cmdName) => {
305
- return new MenuItem({
306
- label,
307
- enable: () => editor.can()[cmdName]().run(),
308
- run: () => editor.chain()[cmdName]().run(),
309
- });
310
- };
311
- const tableMenu = [
312
- item('Insert table', 'insertTable'),
313
- item('Insert column before', 'addColumnBefore'),
314
- item('Insert column after', 'addColumnAfter'),
315
- item('Delete column', 'deleteColumn'),
316
- item('Insert row before', 'addRowBefore'),
317
- item('Insert row after', 'addRowAfter'),
318
- item('Delete row', 'deleteRow'),
319
- item('Delete table', 'deleteTable'),
320
- item('Merge cells', 'mergeCells'),
321
- item('Split cell', 'splitCell'),
322
- item('Toggle header column', 'toggleHeaderColumn'),
323
- item('Toggle header row', 'toggleHeaderRow'),
324
- item('Toggle header cells', 'toggleHeaderCell'),
325
- // item('Make cell green', setCellAttr('background', '#dfd')),
326
- // item('Make cell not-green', setCellAttr('background', null)),
327
- ];
328
- menu.push(new Dropdown(tableMenu, { label: 'Table' }));
329
- }
330
- return [menu, blockMenu];
331
- }
package/esm/icons.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { IconSpec } from './menu.js';
2
- export declare function getIcon(root: Document | ShadowRoot, icon: {
3
- path: string;
4
- width: number;
5
- height: number;
6
- } | {
7
- text: string;
8
- css?: string;
9
- } | {
10
- dom: Node;
11
- }): HTMLElement;
12
- export declare const icons: {
13
- [name: string]: IconSpec;
14
- };
15
- //# sourceMappingURL=icons.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAerC,wBAAgB,OAAO,CACrB,IAAI,EAAE,QAAQ,GAAG,UAAU,EAC3B,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,GAChB,WAAW,CAmCb;AA8BD,eAAO,MAAM,KAAK,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAyE7C,CAAC"}
package/esm/icons.js DELETED
@@ -1,123 +0,0 @@
1
- const SVG = 'http://www.w3.org/2000/svg';
2
- const XLINK = 'http://www.w3.org/1999/xlink';
3
- const prefix = 'kb-icon';
4
- function hashPath(path) {
5
- let hash = 0;
6
- for (let i = 0; i < path.length; i++) {
7
- hash = (((hash << 5) - hash) + path.charCodeAt(i)) | 0;
8
- }
9
- return hash;
10
- }
11
- export function getIcon(root, icon) {
12
- let doc = (root.nodeType == 9 ? root : root.ownerDocument) ||
13
- document;
14
- let node = doc.createElement('div');
15
- node.className = prefix;
16
- if (icon.path) {
17
- let { path, width, height } = icon;
18
- let name = 'pm-icon-' + hashPath(path).toString(16);
19
- if (!doc.getElementById(name)) {
20
- buildSVG(root, name, icon);
21
- }
22
- let svg = node.appendChild(doc.createElementNS(SVG, 'svg'));
23
- svg.style.width = (width / height) + 'em';
24
- let use = svg.appendChild(doc.createElementNS(SVG, 'use'));
25
- use.setAttributeNS(XLINK, 'href', /([^#]*)/.exec(doc.location.toString())[1] + '#' + name);
26
- }
27
- else if (icon.dom) {
28
- node.appendChild(icon.dom.cloneNode(true));
29
- }
30
- else {
31
- let { text, css } = icon;
32
- node.appendChild(doc.createElement('span')).textContent = text || '';
33
- if (css)
34
- node.firstChild.style.cssText = css;
35
- }
36
- return node;
37
- }
38
- function buildSVG(root, name, data) {
39
- let [doc, top] = root.nodeType == 9
40
- ? [root, root.body]
41
- : [root.ownerDocument || document, root];
42
- let collection = doc.getElementById(prefix + '-collection');
43
- if (!collection) {
44
- collection = doc.createElementNS(SVG, 'svg');
45
- collection.id = prefix + '-collection';
46
- collection.style.display = 'none';
47
- top.insertBefore(collection, top.firstChild);
48
- }
49
- let sym = doc.createElementNS(SVG, 'symbol');
50
- sym.id = name;
51
- sym.setAttribute('viewBox', '0 0 ' + data.width + ' ' + data.height);
52
- let path = sym.appendChild(doc.createElementNS(SVG, 'path'));
53
- path.setAttribute('d', data.path);
54
- collection.appendChild(sym);
55
- }
56
- /// A set of basic editor-related icons. Contains the properties
57
- /// `join`, `lift`, `selectParentNode`, `undo`, `redo`, `strong`, `em`,
58
- /// `code`, `link`, `bulletList`, `orderedList`, and `blockquote`, each
59
- /// holding an object that can be used as the `icon` option to
60
- /// `MenuItem`.
61
- export const icons = {
62
- join: {
63
- width: 800,
64
- height: 900,
65
- path: 'M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z',
66
- },
67
- lift: {
68
- width: 1024,
69
- height: 1024,
70
- path: 'M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z',
71
- },
72
- selectParentNode: { text: '\u2b1a', css: 'font-weight: bold' },
73
- undo: {
74
- width: 1024,
75
- height: 1024,
76
- path: 'M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z',
77
- },
78
- redo: {
79
- width: 1024,
80
- height: 1024,
81
- path: 'M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z',
82
- },
83
- strong: {
84
- width: 805,
85
- height: 1024,
86
- path: 'M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z',
87
- },
88
- em: {
89
- width: 585,
90
- height: 1024,
91
- path: 'M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z',
92
- },
93
- underline: {
94
- width: 585,
95
- height: 1024,
96
- path: 'M0 908h1024v64H0Z',
97
- },
98
- code: {
99
- width: 896,
100
- height: 1024,
101
- path: 'M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z',
102
- },
103
- link: {
104
- width: 951,
105
- height: 1024,
106
- path: 'M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z',
107
- },
108
- bulletList: {
109
- width: 768,
110
- height: 896,
111
- path: 'M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z',
112
- },
113
- orderedList: {
114
- width: 768,
115
- height: 896,
116
- path: 'M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z',
117
- },
118
- blockquote: {
119
- width: 640,
120
- height: 896,
121
- path: 'M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z',
122
- },
123
- };
package/esm/menu.d.ts DELETED
@@ -1,81 +0,0 @@
1
- import { EditorView } from 'prosemirror-view';
2
- import { EditorState, Transaction } from 'prosemirror-state';
3
- export interface MenuElement {
4
- render(pm: EditorView): {
5
- dom: HTMLElement;
6
- update: (state: EditorState) => boolean;
7
- };
8
- }
9
- export declare class MenuItem implements MenuElement {
10
- readonly spec: MenuItemSpec;
11
- CSS_PREFIX: string;
12
- constructor(spec: MenuItemSpec);
13
- render(view: EditorView): {
14
- dom: HTMLElement | null;
15
- update: (state: EditorState) => boolean;
16
- };
17
- }
18
- export type IconSpec = {
19
- path: string;
20
- width: number;
21
- height: number;
22
- } | {
23
- text: string;
24
- css?: string;
25
- } | {
26
- dom: Node;
27
- };
28
- export interface MenuItemSpec {
29
- run: (state: EditorState, dispatch: (tr: Transaction) => void) => boolean | Promise<boolean>;
30
- select?: (state: EditorState) => boolean;
31
- enable?: (state: EditorState) => boolean;
32
- active?: (state: EditorState) => boolean;
33
- render?: (view: EditorView) => HTMLElement;
34
- icon?: IconSpec;
35
- label?: string;
36
- title?: string | ((state: EditorState) => string);
37
- class?: string;
38
- css?: string;
39
- }
40
- export declare class Dropdown implements MenuElement {
41
- readonly options: {
42
- label?: string;
43
- title?: string;
44
- class?: string;
45
- css?: string;
46
- };
47
- CSS_PREFIX: string;
48
- content: readonly MenuElement[];
49
- constructor(content: readonly MenuElement[] | MenuElement, options?: {
50
- label?: string;
51
- title?: string;
52
- class?: string;
53
- css?: string;
54
- });
55
- render(view: EditorView): {
56
- dom: any;
57
- update: (state: EditorState) => boolean;
58
- };
59
- expand(dom: HTMLElement, items: readonly Node[]): {
60
- close: () => boolean;
61
- node: any;
62
- };
63
- }
64
- export declare class DropdownSubmenu implements MenuElement {
65
- readonly options: {
66
- label?: string;
67
- };
68
- content: readonly MenuElement[];
69
- constructor(content: readonly MenuElement[] | MenuElement, options?: {
70
- label?: string;
71
- });
72
- render(view: EditorView): {
73
- dom: any;
74
- update: (state: EditorState) => boolean;
75
- };
76
- }
77
- export declare function renderGrouped(view: EditorView, content: readonly (readonly MenuElement[])[]): {
78
- dom: any;
79
- update: (state: EditorState) => boolean;
80
- };
81
- //# sourceMappingURL=menu.d.ts.map
package/esm/menu.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAO7D,MAAM,WAAW,WAAW;IAK1B,MAAM,CACJ,EAAE,EAAE,UAAU,GACb;QAAE,GAAG,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;KAAE,CAAC;CAClE;AAGD,qBAAa,QAAS,YAAW,WAAW;IAMxC,QAAQ,CAAC,IAAI,EAAE,YAAY;IAL7B,UAAU,SAAqB;gBAKpB,IAAI,EAAE,YAAY;IAM7B,MAAM,CAAC,IAAI,EAAE,UAAU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