@gravity-ui/markdown-editor 15.16.2 → 15.17.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/build/cjs/bundle/config/w-heading-config.js +6 -0
- package/build/cjs/bundle/config/w-heading-config.js.map +1 -1
- package/build/cjs/extensions/behavior/CommandMenu/handler.d.ts +2 -1
- package/build/cjs/extensions/behavior/CommandMenu/handler.js +10 -2
- package/build/cjs/extensions/behavior/CommandMenu/handler.js.map +1 -1
- package/build/cjs/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.js +23 -39
- package/build/cjs/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.js.map +1 -1
- package/build/cjs/toolbar/types.d.ts +4 -0
- package/build/cjs/toolbar/types.js.map +1 -1
- package/build/cjs/version.js +1 -1
- package/build/cjs/version.js.map +1 -1
- package/build/esm/bundle/config/w-heading-config.js +6 -0
- package/build/esm/bundle/config/w-heading-config.js.map +1 -1
- package/build/esm/extensions/behavior/CommandMenu/handler.d.ts +2 -1
- package/build/esm/extensions/behavior/CommandMenu/handler.js +10 -3
- package/build/esm/extensions/behavior/CommandMenu/handler.js.map +1 -1
- package/build/esm/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.js +23 -39
- package/build/esm/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.js.map +1 -1
- package/build/esm/toolbar/types.d.ts +4 -0
- package/build/esm/toolbar/types.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ exports.wHeading1ItemData = {
|
|
|
27
27
|
exec: (e) => e.actions.toH1.run(),
|
|
28
28
|
isActive: (e) => e.actions.toH1.isActive(),
|
|
29
29
|
isEnable: (e) => e.actions.toH1.isEnable(),
|
|
30
|
+
aliases: ['h1'],
|
|
30
31
|
preview: (0, jsx_runtime_1.jsx)(HeadingPreview_1.HeadingPreview, { level: 1 }),
|
|
31
32
|
};
|
|
32
33
|
exports.wHeading2ItemData = {
|
|
@@ -37,6 +38,7 @@ exports.wHeading2ItemData = {
|
|
|
37
38
|
exec: (e) => e.actions.toH2.run(),
|
|
38
39
|
isActive: (e) => e.actions.toH2.isActive(),
|
|
39
40
|
isEnable: (e) => e.actions.toH2.isEnable(),
|
|
41
|
+
aliases: ['h2'],
|
|
40
42
|
preview: (0, jsx_runtime_1.jsx)(HeadingPreview_1.HeadingPreview, { level: 2 }),
|
|
41
43
|
};
|
|
42
44
|
exports.wHeading3ItemData = {
|
|
@@ -47,6 +49,7 @@ exports.wHeading3ItemData = {
|
|
|
47
49
|
exec: (e) => e.actions.toH3.run(),
|
|
48
50
|
isActive: (e) => e.actions.toH3.isActive(),
|
|
49
51
|
isEnable: (e) => e.actions.toH3.isEnable(),
|
|
52
|
+
aliases: ['h3'],
|
|
50
53
|
preview: (0, jsx_runtime_1.jsx)(HeadingPreview_1.HeadingPreview, { level: 3 }),
|
|
51
54
|
};
|
|
52
55
|
exports.wHeading4ItemData = {
|
|
@@ -57,6 +60,7 @@ exports.wHeading4ItemData = {
|
|
|
57
60
|
exec: (e) => e.actions.toH4.run(),
|
|
58
61
|
isActive: (e) => e.actions.toH4.isActive(),
|
|
59
62
|
isEnable: (e) => e.actions.toH4.isEnable(),
|
|
63
|
+
aliases: ['h4'],
|
|
60
64
|
preview: (0, jsx_runtime_1.jsx)(HeadingPreview_1.HeadingPreview, { level: 4 }),
|
|
61
65
|
};
|
|
62
66
|
exports.wHeading5ItemData = {
|
|
@@ -67,6 +71,7 @@ exports.wHeading5ItemData = {
|
|
|
67
71
|
exec: (e) => e.actions.toH5.run(),
|
|
68
72
|
isActive: (e) => e.actions.toH5.isActive(),
|
|
69
73
|
isEnable: (e) => e.actions.toH5.isEnable(),
|
|
74
|
+
aliases: ['h5'],
|
|
70
75
|
preview: (0, jsx_runtime_1.jsx)(HeadingPreview_1.HeadingPreview, { level: 5 }),
|
|
71
76
|
};
|
|
72
77
|
exports.wHeading6ItemData = {
|
|
@@ -77,6 +82,7 @@ exports.wHeading6ItemData = {
|
|
|
77
82
|
exec: (e) => e.actions.toH6.run(),
|
|
78
83
|
isActive: (e) => e.actions.toH6.isActive(),
|
|
79
84
|
isEnable: (e) => e.actions.toH6.isEnable(),
|
|
85
|
+
aliases: ['h6'],
|
|
80
86
|
preview: (0, jsx_runtime_1.jsx)(HeadingPreview_1.HeadingPreview, { level: 6 }),
|
|
81
87
|
};
|
|
82
88
|
exports.wHeadingListConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"w-heading-config.js","sourceRoot":"../../../../src","sources":["bundle/config/w-heading-config.tsx"],"names":[],"mappings":";;;;AAAA,yDAAwC;AACxC,wDAA4D;AAG5D,oDAA0C;AAC1C,sCAA8B;AAC9B,iEAAyD;AACzD,2DAAmD;AAEtC,QAAA,aAAa,GAA+B;IACrD,EAAE,EAAE,yBAAU,CAAC,SAAS;IACxB,KAAK,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,aAAK,CAAC,IAAI;IAChB,MAAM,EAAE,qBAAC,CAAC,MAAM,CAAC,kBAAC,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE;IACxC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE;IACjD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE;IACjD,iBAAiB,EAAE,IAAI;IACvB,OAAO,EAAE,uBAAC,yBAAW,KAAG;CAC3B,CAAC;AACW,QAAA,iBAAiB,GAA+B;IACzD,EAAE,EAAE,yBAAU,CAAC,QAAQ;IACvB,KAAK,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,EA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ACvB,KAAK,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;IACjC,IAAI,EAAE;QACF,qBAAa;QACb,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;KACpB;CACJ,CAAC","sourcesContent":["import {i18n} from '../../i18n/menubar';\nimport {Action as A, formatter as f} from '../../shortcuts';\nimport type {WToolbarListButtonData, WToolbarListButtonItemData} from '../toolbar/types';\n\nimport {ActionName} from './action-names';\nimport {icons} from './icons';\nimport {HeadingPreview} from './previews/HeadingPreview';\nimport {TextPreview} from './previews/TextPreview';\n\nexport const wTextItemData: WToolbarListButtonItemData = {\n id: ActionName.paragraph,\n title: i18n.bind(null, 'text'),\n icon: icons.text,\n hotkey: f.toView(A.Text),\n exec: (e) => e.actions.toParagraph.run(),\n isActive: (e) => e.actions.toParagraph.isActive(),\n isEnable: (e) => e.actions.toParagraph.isEnable(),\n doNotActivateList: true,\n preview: <TextPreview />,\n};\nexport const wHeading1ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading1,\n title: i18n.bind(null, 'heading1'),\n icon: icons.h1,\n hotkey: f.toView(A.Heading1),\n exec: (e) => e.actions.toH1.run(),\n isActive: (e) => e.actions.toH1.isActive(),\n isEnable: (e) => e.actions.toH1.isEnable(),\n preview: <HeadingPreview level={1} />,\n};\nexport const wHeading2ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading2,\n title: i18n.bind(null, 'heading2'),\n icon: icons.h2,\n hotkey: f.toView(A.Heading2),\n exec: (e) => e.actions.toH2.run(),\n isActive: (e) => e.actions.toH2.isActive(),\n isEnable: (e) => e.actions.toH2.isEnable(),\n preview: <HeadingPreview level={2} />,\n};\nexport const wHeading3ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading3,\n title: i18n.bind(null, 'heading3'),\n icon: icons.h3,\n hotkey: f.toView(A.Heading3),\n exec: (e) => e.actions.toH3.run(),\n isActive: (e) => e.actions.toH3.isActive(),\n isEnable: (e) => e.actions.toH3.isEnable(),\n preview: <HeadingPreview level={3} />,\n};\nexport const wHeading4ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading4,\n title: i18n.bind(null, 'heading4'),\n icon: icons.h4, // Предполагается, что icon исправлен для h4\n hotkey: f.toView(A.Heading4),\n exec: (e) => e.actions.toH4.run(),\n isActive: (e) => e.actions.toH4.isActive(),\n isEnable: (e) => e.actions.toH4.isEnable(),\n preview: <HeadingPreview level={4} />,\n};\nexport const wHeading5ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading5,\n title: i18n.bind(null, 'heading5'),\n icon: icons.h5, // Предполагается, что icon исправлен для h5\n hotkey: f.toView(A.Heading5),\n exec: (e) => e.actions.toH5.run(),\n isActive: (e) => e.actions.toH5.isActive(),\n isEnable: (e) => e.actions.toH5.isEnable(),\n preview: <HeadingPreview level={5} />,\n};\nexport const wHeading6ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading6,\n title: i18n.bind(null, 'heading6'),\n icon: icons.h6, // Предполагается, что icon исправлен для h6\n hotkey: f.toView(A.Heading6),\n exec: (e) => e.actions.toH6.run(),\n isActive: (e) => e.actions.toH6.isActive(),\n isEnable: (e) => e.actions.toH6.isEnable(),\n preview: <HeadingPreview level={6} />,\n};\n\nexport const wHeadingListConfig: WToolbarListButtonData = {\n icon: icons.headline,\n withArrow: true,\n replaceActiveIcon: true,\n title: i18n.bind(null, 'heading'),\n data: [\n wTextItemData,\n wHeading1ItemData,\n wHeading2ItemData,\n wHeading3ItemData,\n wHeading4ItemData,\n wHeading5ItemData,\n wHeading6ItemData,\n ],\n};\n"]}
|
|
1
|
+
{"version":3,"file":"w-heading-config.js","sourceRoot":"../../../../src","sources":["bundle/config/w-heading-config.tsx"],"names":[],"mappings":";;;;AAAA,yDAAwC;AACxC,wDAA4D;AAG5D,oDAA0C;AAC1C,sCAA8B;AAC9B,iEAAyD;AACzD,2DAAmD;AAEtC,QAAA,aAAa,GAA+B;IAC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AAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,OAAO,EAAE,uBAAC,+BAAc,IAAC,KAAK,EAAE,CAAC,GAAI;CACxC,CAAC;AACW,QAAA,iBAAiB,GAA+B;IACzD,EAAE,EAAE,yBAAU,CAAC,QAAQ;IACvB,KAAK,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;IAClC,IAAI,EAAE,aAAK,CAAC,EAAE,EAAE,4CAA4C;IAC5D,MAAM,EAAE,qBAAC,CAAC,MAAM,CAAC,kBAAC,CAAC,QAAQ,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;IACjC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC1C,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,OAAO,EAAE,uBAAC,+BAAc,IAAC,KAAK,EAAE,CAAC,GAAI;CACxC,CAAC;AAEW,QAAA,kBAAkB,GAA2B;IACtD,IAAI,EAAE,aAAK,CAAC,QAAQ;IACpB,SAAS,EAAE,IAAI;IACf,iBAAiB,EAAE,IAAI;IACvB,KAAK,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;IACjC,IAAI,EAAE;QACF,qBAAa;QACb,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;QACjB,yBAAiB;KACpB;CACJ,CAAC","sourcesContent":["import {i18n} from '../../i18n/menubar';\nimport {Action as A, formatter as f} from '../../shortcuts';\nimport type {WToolbarListButtonData, WToolbarListButtonItemData} from '../toolbar/types';\n\nimport {ActionName} from './action-names';\nimport {icons} from './icons';\nimport {HeadingPreview} from './previews/HeadingPreview';\nimport {TextPreview} from './previews/TextPreview';\n\nexport const wTextItemData: WToolbarListButtonItemData = {\n id: ActionName.paragraph,\n title: i18n.bind(null, 'text'),\n icon: icons.text,\n hotkey: f.toView(A.Text),\n exec: (e) => e.actions.toParagraph.run(),\n isActive: (e) => e.actions.toParagraph.isActive(),\n isEnable: (e) => e.actions.toParagraph.isEnable(),\n doNotActivateList: true,\n preview: <TextPreview />,\n};\nexport const wHeading1ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading1,\n title: i18n.bind(null, 'heading1'),\n icon: icons.h1,\n hotkey: f.toView(A.Heading1),\n exec: (e) => e.actions.toH1.run(),\n isActive: (e) => e.actions.toH1.isActive(),\n isEnable: (e) => e.actions.toH1.isEnable(),\n aliases: ['h1'],\n preview: <HeadingPreview level={1} />,\n};\nexport const wHeading2ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading2,\n title: i18n.bind(null, 'heading2'),\n icon: icons.h2,\n hotkey: f.toView(A.Heading2),\n exec: (e) => e.actions.toH2.run(),\n isActive: (e) => e.actions.toH2.isActive(),\n isEnable: (e) => e.actions.toH2.isEnable(),\n aliases: ['h2'],\n preview: <HeadingPreview level={2} />,\n};\nexport const wHeading3ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading3,\n title: i18n.bind(null, 'heading3'),\n icon: icons.h3,\n hotkey: f.toView(A.Heading3),\n exec: (e) => e.actions.toH3.run(),\n isActive: (e) => e.actions.toH3.isActive(),\n isEnable: (e) => e.actions.toH3.isEnable(),\n aliases: ['h3'],\n preview: <HeadingPreview level={3} />,\n};\nexport const wHeading4ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading4,\n title: i18n.bind(null, 'heading4'),\n icon: icons.h4, // Предполагается, что icon исправлен для h4\n hotkey: f.toView(A.Heading4),\n exec: (e) => e.actions.toH4.run(),\n isActive: (e) => e.actions.toH4.isActive(),\n isEnable: (e) => e.actions.toH4.isEnable(),\n aliases: ['h4'],\n preview: <HeadingPreview level={4} />,\n};\nexport const wHeading5ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading5,\n title: i18n.bind(null, 'heading5'),\n icon: icons.h5, // Предполагается, что icon исправлен для h5\n hotkey: f.toView(A.Heading5),\n exec: (e) => e.actions.toH5.run(),\n isActive: (e) => e.actions.toH5.isActive(),\n isEnable: (e) => e.actions.toH5.isEnable(),\n aliases: ['h5'],\n preview: <HeadingPreview level={5} />,\n};\nexport const wHeading6ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading6,\n title: i18n.bind(null, 'heading6'),\n icon: icons.h6, // Предполагается, что icon исправлен для h6\n hotkey: f.toView(A.Heading6),\n exec: (e) => e.actions.toH6.run(),\n isActive: (e) => e.actions.toH6.isActive(),\n isEnable: (e) => e.actions.toH6.isEnable(),\n aliases: ['h6'],\n preview: <HeadingPreview level={6} />,\n};\n\nexport const wHeadingListConfig: WToolbarListButtonData = {\n icon: icons.headline,\n withArrow: true,\n replaceActiveIcon: true,\n title: i18n.bind(null, 'heading'),\n data: [\n wTextItemData,\n wHeading1ItemData,\n wHeading2ItemData,\n wHeading3ItemData,\n wHeading4ItemData,\n wHeading5ItemData,\n wHeading6ItemData,\n ],\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActionStorage } from "../../../core/index.js";
|
|
2
2
|
import { type Logger2 } from "../../../logger.js";
|
|
3
3
|
import { type AutocompleteAction, type AutocompleteHandler } from "../Autocomplete/index.js";
|
|
4
|
-
import type { Config } from "./types.js";
|
|
4
|
+
import type { CommandAction, Config } from "./types.js";
|
|
5
5
|
declare module 'prosemirror-model' {
|
|
6
6
|
interface NodeSpec {
|
|
7
7
|
commandMenu?: boolean;
|
|
@@ -33,3 +33,4 @@ export declare class CommandHandler implements AutocompleteHandler {
|
|
|
33
33
|
private createMenuRenderItem;
|
|
34
34
|
private findAnchor;
|
|
35
35
|
}
|
|
36
|
+
export declare function filterActions(actions: readonly CommandAction[], text: string): CommandAction[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandHandler = void 0;
|
|
4
|
+
exports.filterActions = filterActions;
|
|
4
5
|
const lodash_1 = require("../../../lodash.js");
|
|
5
6
|
const logger_1 = require("../../../logger.js");
|
|
6
7
|
const autocomplete_popup_1 = require("../../../utils/autocomplete-popup.js");
|
|
@@ -181,8 +182,15 @@ class CommandHandler {
|
|
|
181
182
|
}
|
|
182
183
|
exports.CommandHandler = CommandHandler;
|
|
183
184
|
function filterActions(actions, text) {
|
|
184
|
-
return actions.filter((action) =>
|
|
185
|
-
|
|
185
|
+
return actions.filter((action) => {
|
|
186
|
+
const lowerText = text.toLowerCase();
|
|
187
|
+
const matchesId = action.id.toLowerCase().includes(lowerText);
|
|
188
|
+
const matchesTitle = ((0, lodash_1.isFunction)(action.title) ? action.title() : action.title)
|
|
189
|
+
.toLowerCase()
|
|
190
|
+
.includes(lowerText);
|
|
191
|
+
const matchesAliases = action.aliases?.some((alias) => alias.toLowerCase().includes(lowerText)) ?? false;
|
|
192
|
+
return matchesId || matchesTitle || matchesAliases;
|
|
193
|
+
});
|
|
186
194
|
}
|
|
187
195
|
const CHARS_TO_HIDE = 4;
|
|
188
196
|
function needToHide(actions, text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/CommandMenu/handler.ts"],"names":[],"mappings":";;;AAGA,+CAA2C;AAC3C,+CAA2D;AAC3D,6EAA0E;AAC1E,+DAAsD;AACtD,2DAMyB;AACzB,6DAA8E;AAE9E,8CAAmE;AAEnE,sCAAqC;AAerC,MAAa,cAAc;IACd,OAAO,CAAkB;IACzB,QAAQ,CAA2B;IACnC,cAAc,CAAgB;IAC9B,gBAAgB,CAAoB;IAC7C,wBAAwB,CAAgC;IAExD,KAAK,CAAc;IACnB,OAAO,GA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AAI,WAAW,CAAC,MAAM;YAAE,MAAM;QAC9B,IAAI,EAAE,CAAC;IACX,CAAC,QAAQ,IAAI,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,aAAa,EAAE;IACrD,OAAO,IAAI,IAAI,aAAa,CAAC;AACjC,CAAC","sourcesContent":["import type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {AutocompletePopupCloser} from '../../../utils/autocomplete-popup';\nimport {ArrayCarousel} from '../../../utils/carousel';\nimport {\n type AutocompleteAction,\n AutocompleteActionKind,\n type AutocompleteHandler,\n closeAutocomplete,\n getAutocompleteState,\n} from '../Autocomplete';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\nimport {type CommandMenuComponentProps, render} from './component';\nimport type {CommandAction, Config} from './types';\nimport {findDecoElem} from './utils';\n\ndeclare module 'prosemirror-model' {\n interface NodeSpec {\n commandMenu?: boolean;\n }\n}\n\nexport type CommandHandlerParams = {\n logger: Logger2.ILogger;\n actions: Config;\n storage: ActionStorage;\n nodesIgnoreList?: readonly string[];\n};\n\nexport class CommandHandler implements AutocompleteHandler {\n readonly #logger: Logger2.ILogger;\n readonly #actions: readonly CommandAction[];\n readonly #actionStorage: ActionStorage;\n readonly #nodesIgnoreList: readonly string[];\n #filteredActionsCarousel?: ArrayCarousel<CommandAction>;\n\n #view?: EditorView;\n #anchor: Element | null = null;\n #filterText?: string;\n #popupCloser?: AutocompletePopupCloser;\n\n #menuProps?: CommandMenuComponentProps;\n #menuRenderItem?: RendererItem;\n\n constructor({logger, actions, storage, nodesIgnoreList = []}: CommandHandlerParams) {\n this.#logger = logger;\n this.#actions = actions;\n this.#actionStorage = storage;\n this.#nodesIgnoreList = nodesIgnoreList;\n }\n\n onOpen(action: AutocompleteAction): boolean {\n this.findAnchor();\n if (!this.#anchor || this.shouldIgnore(action)) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.#popupCloser = new AutocompletePopupCloser(action.view);\n this.updateState(action);\n this.filterActions();\n this.render();\n\n return true;\n }\n\n onFilter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action) || action.filter?.endsWith(' ')) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.#filterText = action.filter?.trim().toLowerCase();\n const needToClose = this.filterActions();\n this.render();\n\n if (needToClose) {\n this.closeAutocomplete(action.view);\n }\n\n return true;\n }\n\n onArrow(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n if (!this.#filteredActionsCarousel) return false;\n\n switch (action.kind) {\n case AutocompleteActionKind.up: {\n this.#filteredActionsCarousel.prev();\n break;\n }\n case AutocompleteActionKind.down: {\n this.#filteredActionsCarousel.next();\n break;\n }\n default:\n return false;\n }\n\n this.render();\n\n return true;\n }\n\n onEnter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.select();\n\n return true;\n }\n\n onClose(action: AutocompleteAction): boolean {\n this.updateState(action);\n\n this.clear();\n\n return true;\n }\n\n onDestroy(): void {\n this.clear();\n }\n\n private closeAutocomplete(view: EditorView) {\n setTimeout(() => {\n closeAutocomplete(view);\n });\n }\n\n private shouldIgnore(action: AutocompleteAction): boolean {\n const parentType = action.view.state.doc.resolve(action.range.from).parent.type;\n return (\n parentType.spec.commandMenu === false || this.#nodesIgnoreList.includes(parentType.name)\n );\n }\n\n private select() {\n if (!this.#view) return;\n\n const action = this.#filteredActionsCarousel?.currentItem;\n if (!action) return;\n\n const autocompleteState = getAutocompleteState(this.#view.state);\n if (!autocompleteState || !autocompleteState.active) return;\n\n const view = this.#view;\n const {range} = autocompleteState;\n\n view.dispatch(view.state.tr.deleteRange(range.from, range.to).scrollIntoView());\n action.exec(this.#actionStorage);\n view.focus();\n\n globalLogger.action({mode: 'wysiwyg', source: 'command-menu', action: action.id});\n this.#logger.action({source: 'command-menu', action: action.id});\n }\n\n private filterActions(): boolean {\n const currentItem = this.#filteredActionsCarousel?.currentItem;\n const inputText = this.#filterText;\n\n const enabledActions = this.#actions.filter((action) =>\n action.isEnable(this.#actionStorage),\n );\n\n let filteredActions = enabledActions;\n let needToClose = false;\n\n if (inputText) {\n filteredActions = filterActions(enabledActions, inputText);\n needToClose = !filteredActions.length && needToHide(enabledActions, inputText);\n }\n\n this.#filteredActionsCarousel = new ArrayCarousel(filteredActions);\n\n if (currentItem) {\n const newIndex = this.#filteredActionsCarousel.array.findIndex(\n (item) => item === currentItem,\n );\n if (newIndex !== -1) {\n this.#filteredActionsCarousel.currentIndex = newIndex;\n }\n }\n\n return needToClose;\n }\n\n private render() {\n this.findAnchor();\n const viewItems = this.#filteredActionsCarousel?.array ?? [];\n this.#menuProps = {\n anchorElement: this.#anchor,\n currentIndex: this.#filteredActionsCarousel?.currentIndex,\n items: viewItems,\n onItemClick: this.onItemClick,\n onOpenChange: this.#popupCloser?.popupOpenChangeHandler,\n };\n this.#menuRenderItem = this.#menuRenderItem ?? this.createMenuRenderItem();\n this.#menuRenderItem.rerender();\n }\n\n private onItemClick = (index: number) => {\n if (this.#filteredActionsCarousel) {\n this.#filteredActionsCarousel.currentIndex = index;\n this.select();\n }\n this.#view?.focus();\n };\n\n private updateState({view}: AutocompleteAction) {\n this.#view = view;\n }\n\n private clear() {\n this.#view = undefined;\n this.#anchor = null;\n this.#filterText = undefined;\n this.#filteredActionsCarousel = undefined;\n this.#popupCloser?.cancelTimer();\n this.#popupCloser = undefined;\n this.#menuProps = undefined;\n this.#menuRenderItem?.remove();\n this.#menuRenderItem = undefined;\n }\n\n private createMenuRenderItem(): RendererItem {\n return getReactRendererFromState(this.#view!.state).createItem('command_menu', () =>\n this.#menuProps ? render(this.#menuProps) : null,\n );\n }\n\n private findAnchor() {\n this.#anchor = findDecoElem(this.#view?.dom);\n }\n}\n\nfunction filterActions(actions: readonly CommandAction[], text: string): CommandAction[] {\n return actions.filter(\n (action) =>\n action.id.toLowerCase().includes(text) ||\n (isFunction(action.title) ? action.title() : action.title).toLowerCase().includes(text),\n );\n}\n\nconst CHARS_TO_HIDE = 4;\nfunction needToHide(actions: readonly CommandAction[], text: string): boolean {\n let iter = 1;\n do {\n const prevInput = text.slice(0, text.length - iter);\n const prevActions = filterActions(actions, prevInput);\n if (prevActions.length) break;\n iter++;\n } while (iter < text.length && iter < CHARS_TO_HIDE);\n return iter >= CHARS_TO_HIDE;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/CommandMenu/handler.ts"],"names":[],"mappings":";;;AA8PA,sCAYC;AAvQD,+CAA2C;AAC3C,+CAA2D;AAC3D,6EAA0E;AAC1E,+DAAsD;AACtD,2DAMyB;AACzB,6DAA8E;AAE9E,8CAAmE;AAEnE,sCAAqC;AAerC,MAAa,cAAc;IACd,OAAO,CAAkB;IACzB,QAAQ,CAA2B;IACnC,cAAc,CAAgB;IAC9B,gBAAgB,CAAoB;IAC7C,wBAAwB,CAAgC;IAExD,KAAK,CAAc;IACnB,OAAO,GAAmB,IAAI,CAAC;IAC/B,WAAW,CAAU;IACrB,YAAY,CAA2B;IAEvC,UAAU,CAA6B;IACvC,eAAe,CAAgB;IAE/B,YAAY,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAuB;QAC9E,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,MAA0B;QAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAA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AAI,aAAa,CAAC;AACjC,CAAC","sourcesContent":["import type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {AutocompletePopupCloser} from '../../../utils/autocomplete-popup';\nimport {ArrayCarousel} from '../../../utils/carousel';\nimport {\n type AutocompleteAction,\n AutocompleteActionKind,\n type AutocompleteHandler,\n closeAutocomplete,\n getAutocompleteState,\n} from '../Autocomplete';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\nimport {type CommandMenuComponentProps, render} from './component';\nimport type {CommandAction, Config} from './types';\nimport {findDecoElem} from './utils';\n\ndeclare module 'prosemirror-model' {\n interface NodeSpec {\n commandMenu?: boolean;\n }\n}\n\nexport type CommandHandlerParams = {\n logger: Logger2.ILogger;\n actions: Config;\n storage: ActionStorage;\n nodesIgnoreList?: readonly string[];\n};\n\nexport class CommandHandler implements AutocompleteHandler {\n readonly #logger: Logger2.ILogger;\n readonly #actions: readonly CommandAction[];\n readonly #actionStorage: ActionStorage;\n readonly #nodesIgnoreList: readonly string[];\n #filteredActionsCarousel?: ArrayCarousel<CommandAction>;\n\n #view?: EditorView;\n #anchor: Element | null = null;\n #filterText?: string;\n #popupCloser?: AutocompletePopupCloser;\n\n #menuProps?: CommandMenuComponentProps;\n #menuRenderItem?: RendererItem;\n\n constructor({logger, actions, storage, nodesIgnoreList = []}: CommandHandlerParams) {\n this.#logger = logger;\n this.#actions = actions;\n this.#actionStorage = storage;\n this.#nodesIgnoreList = nodesIgnoreList;\n }\n\n onOpen(action: AutocompleteAction): boolean {\n this.findAnchor();\n if (!this.#anchor || this.shouldIgnore(action)) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.#popupCloser = new AutocompletePopupCloser(action.view);\n this.updateState(action);\n this.filterActions();\n this.render();\n\n return true;\n }\n\n onFilter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action) || action.filter?.endsWith(' ')) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.#filterText = action.filter?.trim().toLowerCase();\n const needToClose = this.filterActions();\n this.render();\n\n if (needToClose) {\n this.closeAutocomplete(action.view);\n }\n\n return true;\n }\n\n onArrow(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n if (!this.#filteredActionsCarousel) return false;\n\n switch (action.kind) {\n case AutocompleteActionKind.up: {\n this.#filteredActionsCarousel.prev();\n break;\n }\n case AutocompleteActionKind.down: {\n this.#filteredActionsCarousel.next();\n break;\n }\n default:\n return false;\n }\n\n this.render();\n\n return true;\n }\n\n onEnter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.select();\n\n return true;\n }\n\n onClose(action: AutocompleteAction): boolean {\n this.updateState(action);\n\n this.clear();\n\n return true;\n }\n\n onDestroy(): void {\n this.clear();\n }\n\n private closeAutocomplete(view: EditorView) {\n setTimeout(() => {\n closeAutocomplete(view);\n });\n }\n\n private shouldIgnore(action: AutocompleteAction): boolean {\n const parentType = action.view.state.doc.resolve(action.range.from).parent.type;\n return (\n parentType.spec.commandMenu === false || this.#nodesIgnoreList.includes(parentType.name)\n );\n }\n\n private select() {\n if (!this.#view) return;\n\n const action = this.#filteredActionsCarousel?.currentItem;\n if (!action) return;\n\n const autocompleteState = getAutocompleteState(this.#view.state);\n if (!autocompleteState || !autocompleteState.active) return;\n\n const view = this.#view;\n const {range} = autocompleteState;\n\n view.dispatch(view.state.tr.deleteRange(range.from, range.to).scrollIntoView());\n action.exec(this.#actionStorage);\n view.focus();\n\n globalLogger.action({mode: 'wysiwyg', source: 'command-menu', action: action.id});\n this.#logger.action({source: 'command-menu', action: action.id});\n }\n\n private filterActions(): boolean {\n const currentItem = this.#filteredActionsCarousel?.currentItem;\n const inputText = this.#filterText;\n\n const enabledActions = this.#actions.filter((action) =>\n action.isEnable(this.#actionStorage),\n );\n\n let filteredActions = enabledActions;\n let needToClose = false;\n\n if (inputText) {\n filteredActions = filterActions(enabledActions, inputText);\n needToClose = !filteredActions.length && needToHide(enabledActions, inputText);\n }\n\n this.#filteredActionsCarousel = new ArrayCarousel(filteredActions);\n\n if (currentItem) {\n const newIndex = this.#filteredActionsCarousel.array.findIndex(\n (item) => item === currentItem,\n );\n if (newIndex !== -1) {\n this.#filteredActionsCarousel.currentIndex = newIndex;\n }\n }\n\n return needToClose;\n }\n\n private render() {\n this.findAnchor();\n const viewItems = this.#filteredActionsCarousel?.array ?? [];\n this.#menuProps = {\n anchorElement: this.#anchor,\n currentIndex: this.#filteredActionsCarousel?.currentIndex,\n items: viewItems,\n onItemClick: this.onItemClick,\n onOpenChange: this.#popupCloser?.popupOpenChangeHandler,\n };\n this.#menuRenderItem = this.#menuRenderItem ?? this.createMenuRenderItem();\n this.#menuRenderItem.rerender();\n }\n\n private onItemClick = (index: number) => {\n if (this.#filteredActionsCarousel) {\n this.#filteredActionsCarousel.currentIndex = index;\n this.select();\n }\n this.#view?.focus();\n };\n\n private updateState({view}: AutocompleteAction) {\n this.#view = view;\n }\n\n private clear() {\n this.#view = undefined;\n this.#anchor = null;\n this.#filterText = undefined;\n this.#filteredActionsCarousel = undefined;\n this.#popupCloser?.cancelTimer();\n this.#popupCloser = undefined;\n this.#menuProps = undefined;\n this.#menuRenderItem?.remove();\n this.#menuRenderItem = undefined;\n }\n\n private createMenuRenderItem(): RendererItem {\n return getReactRendererFromState(this.#view!.state).createItem('command_menu', () =>\n this.#menuProps ? render(this.#menuProps) : null,\n );\n }\n\n private findAnchor() {\n this.#anchor = findDecoElem(this.#view?.dom);\n }\n}\n\nexport function filterActions(actions: readonly CommandAction[], text: string): CommandAction[] {\n return actions.filter((action) => {\n const lowerText = text.toLowerCase();\n const matchesId = action.id.toLowerCase().includes(lowerText);\n const matchesTitle = (isFunction(action.title) ? action.title() : action.title)\n .toLowerCase()\n .includes(lowerText);\n const matchesAliases =\n action.aliases?.some((alias) => alias.toLowerCase().includes(lowerText)) ?? false;\n\n return matchesId || matchesTitle || matchesAliases;\n });\n}\n\nconst CHARS_TO_HIDE = 4;\nfunction needToHide(actions: readonly CommandAction[], text: string): boolean {\n let iter = 1;\n do {\n const prevInput = text.slice(0, text.length - iter);\n const prevActions = filterActions(actions, prevInput);\n if (prevActions.length) break;\n iter++;\n } while (iter < text.length && iter < CHARS_TO_HIDE);\n return iter >= CHARS_TO_HIDE;\n}\n"]}
|
|
@@ -70,57 +70,42 @@ exports.linkTooltipPlugin = linkTooltipPlugin;
|
|
|
70
70
|
class SelectionTooltip {
|
|
71
71
|
normalizeUrl;
|
|
72
72
|
view;
|
|
73
|
+
show;
|
|
73
74
|
textNode;
|
|
74
75
|
textNodeRef;
|
|
75
|
-
isTooltipOpen = false;
|
|
76
76
|
manualHidden = false;
|
|
77
77
|
renderItem;
|
|
78
|
-
selectionTooltipProps = { show: false };
|
|
79
78
|
constructor(view, deps) {
|
|
80
79
|
this.normalizeUrl = (0, index_1.normalizeUrlFactory)(deps);
|
|
81
80
|
this.view = view;
|
|
82
|
-
this.
|
|
81
|
+
this.show = false;
|
|
82
|
+
this.update(view);
|
|
83
83
|
}
|
|
84
|
-
update(view
|
|
84
|
+
update(view) {
|
|
85
85
|
if (!view.dom.parentNode) {
|
|
86
86
|
this.hideTooltip();
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
const { state } = view;
|
|
90
|
-
|
|
91
|
-
return;
|
|
92
|
-
this.textNode = getTextNode(view.state);
|
|
90
|
+
this.textNode = getTextNode(state);
|
|
93
91
|
const prevRef = this.textNodeRef;
|
|
94
|
-
this.
|
|
95
|
-
if (!this.textNode || !this.textNodeRef) {
|
|
96
|
-
this.hideTooltip();
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
92
|
+
this.textNodeRef = this.view.dom.getElementsByClassName(className)[0];
|
|
99
93
|
if (prevRef !== this.textNodeRef) {
|
|
100
94
|
this.manualHidden = false;
|
|
101
95
|
}
|
|
102
|
-
if (this.manualHidden) {
|
|
96
|
+
if (this.manualHidden || !this.textNode || !this.textNodeRef) {
|
|
103
97
|
this.hideTooltip();
|
|
98
|
+
return;
|
|
104
99
|
}
|
|
105
|
-
|
|
106
|
-
this.renderTooltip({
|
|
107
|
-
show: true,
|
|
108
|
-
domElem: this.textNodeRef,
|
|
109
|
-
onCancel: () => this.cancelPopup(),
|
|
110
|
-
attrs: this.getMarkAttrs(),
|
|
111
|
-
onChange: this.changeAttrs.bind(this),
|
|
112
|
-
onOpenChange: this.onOpenChange,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
100
|
+
this.showTooltip();
|
|
115
101
|
}
|
|
116
102
|
destroy() {
|
|
117
|
-
this.
|
|
118
|
-
this.selectionTooltipProps = { show: false };
|
|
103
|
+
this.show = false;
|
|
119
104
|
this.renderItem?.remove();
|
|
120
105
|
this.renderItem = undefined;
|
|
121
106
|
}
|
|
122
107
|
onEscapeDown() {
|
|
123
|
-
if (this.
|
|
108
|
+
if (this.show) {
|
|
124
109
|
this.removePlaceholderLink(this.textNode);
|
|
125
110
|
this.manualHidden = true;
|
|
126
111
|
this.hideTooltip();
|
|
@@ -128,24 +113,23 @@ class SelectionTooltip {
|
|
|
128
113
|
}
|
|
129
114
|
return false;
|
|
130
115
|
}
|
|
131
|
-
updateTextNodeRef() {
|
|
132
|
-
const decoElem = this.view.dom.getElementsByClassName(className)[0];
|
|
133
|
-
this.textNodeRef = decoElem;
|
|
134
|
-
}
|
|
135
116
|
getMarkAttrs() {
|
|
136
117
|
const { textNode } = this;
|
|
137
118
|
const linkMark = textNode && (0, marks_1.findMark)(textNode.node, (0, index_1.linkType)(this.view.state.schema));
|
|
138
119
|
return linkMark?.attrs;
|
|
139
120
|
}
|
|
140
|
-
|
|
141
|
-
this.renderTooltip({ show: false });
|
|
142
|
-
}
|
|
143
|
-
renderTooltip(props) {
|
|
144
|
-
this.isTooltipOpen = props.show;
|
|
145
|
-
this.selectionTooltipProps = props;
|
|
121
|
+
renderTooltip() {
|
|
146
122
|
this.renderItem = this.renderItem ?? this.createRenderItem();
|
|
147
123
|
this.renderItem.rerender();
|
|
148
124
|
}
|
|
125
|
+
hideTooltip() {
|
|
126
|
+
this.show = false;
|
|
127
|
+
this.renderTooltip();
|
|
128
|
+
}
|
|
129
|
+
showTooltip() {
|
|
130
|
+
this.show = true;
|
|
131
|
+
this.renderTooltip();
|
|
132
|
+
}
|
|
149
133
|
onOpenChange = (open, _e, reason) => {
|
|
150
134
|
if (open)
|
|
151
135
|
return;
|
|
@@ -153,10 +137,10 @@ class SelectionTooltip {
|
|
|
153
137
|
this.cancelPopup();
|
|
154
138
|
}
|
|
155
139
|
else {
|
|
156
|
-
this.
|
|
140
|
+
this.onOutsideClick();
|
|
157
141
|
}
|
|
158
142
|
};
|
|
159
|
-
|
|
143
|
+
onOutsideClick = () => {
|
|
160
144
|
this.removePlaceholderLink(this.textNode);
|
|
161
145
|
this.hideTooltip();
|
|
162
146
|
this.manualHidden = true;
|
|
@@ -197,7 +181,7 @@ class SelectionTooltip {
|
|
|
197
181
|
}
|
|
198
182
|
}
|
|
199
183
|
createRenderItem() {
|
|
200
|
-
return (0, ReactRenderer_1.getReactRendererFromState)(this.view.state).createItem('link-tooltip', () => ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorLoggerBoundary, { children: (0, jsx_runtime_1.jsx)(SelectionTooltipView, {
|
|
184
|
+
return (0, ReactRenderer_1.getReactRendererFromState)(this.view.state).createItem('link-tooltip', () => ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorLoggerBoundary, { children: (0, jsx_runtime_1.jsx)(SelectionTooltipView, { show: this.show, domElem: this.textNodeRef, onCancel: this.cancelPopup.bind(this), attrs: this.getMarkAttrs(), onChange: this.changeAttrs.bind(this), onOpenChange: this.onOpenChange }) })));
|
|
201
185
|
}
|
|
202
186
|
}
|
|
203
187
|
const SelectionTooltipView = (props) => {
|
|
@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IACL,IAAI,EAAE,IAAI,IAAI,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GACpB,IAVG,IAAI,CAWL,CACX,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';\nimport {keydownHandler} from 'prosemirror-keymap';\nimport type {Node} from 'prosemirror-model';\nimport {type EditorState, Plugin, type PluginView, TextSelection} from 'prosemirror-state';\n// @ts-ignore // TODO: fix cjs build\nimport {findChildrenByMark, findParentNode} from 'prosemirror-utils';\nimport {Decoration, DecorationSet, type EditorView} from 'prosemirror-view';\n\nimport type {ExtensionDeps} from '../../../../../core';\nimport {ErrorLoggerBoundary} from '../../../../../react-utils/ErrorBoundary';\nimport {findMark, isMarkActive} from '../../../../../utils/marks';\nimport {type RendererItem, getReactRendererFromState} from '../../../../behavior/ReactRenderer';\nimport {LinkAttr, linkType, normalizeUrlFactory} from '../../../index';\n\nimport {LinkForm} from './TooltipView';\n\nconst className = 'pm-link-focus-deco';\nconst placement: PopupPlacement = ['bottom-start', 'bottom-end', 'top-start', 'top-end'];\n\nfunction getTextNode(state: EditorState) {\n if (\n !(state.selection instanceof TextSelection) ||\n !state.selection.empty ||\n !isMarkActive(state, linkType(state.schema))\n )\n return null;\n\n const parent = findParentNode(Boolean)(state.selection);\n\n if (!parent) {\n return null;\n }\n\n const textNodes = findChildrenByMark(parent?.node, linkType(state.schema));\n\n const textNode = textNodes.find((n: {node: Node; pos: number}) => {\n const start = n.pos + parent.pos;\n const end = start + n.node.nodeSize;\n return start <= state.selection.from && end >= state.selection.from;\n })!;\n\n if (!textNode) return null;\n\n const absolutePos = textNode.pos + parent.pos + 1;\n\n return {\n ...textNode,\n absolutePos,\n parent,\n from: absolutePos,\n to: absolutePos + textNode.node.nodeSize,\n };\n}\n\nexport const linkTooltipPlugin = (deps: ExtensionDeps) => {\n let viewTooltip: SelectionTooltip | null = null;\n return new Plugin({\n view(view) {\n viewTooltip = new SelectionTooltip(view, deps);\n return viewTooltip;\n },\n props: {\n handleKeyDown: keydownHandler({\n Escape: () => viewTooltip?.onEscapeDown() ?? false,\n }),\n decorations(state) {\n const textNode = getTextNode(state);\n if (!textNode) return DecorationSet.empty;\n\n const {from, to} = textNode;\n return DecorationSet.create(state.doc, [\n Decoration.inline(from, to, {\n class: `pm-node-selected ${className}`,\n }),\n ]);\n },\n },\n });\n};\n\nclass SelectionTooltip implements PluginView {\n private normalizeUrl;\n\n private view: EditorView;\n\n private textNode?: ReturnType<typeof getTextNode>;\n private textNodeRef: HTMLElement | undefined;\n\n private isTooltipOpen = false;\n private manualHidden = false;\n\n private renderItem?: RendererItem;\n private selectionTooltipProps: SelectionTooltipViewBaseProps = {show: false};\n\n constructor(view: EditorView, deps: ExtensionDeps) {\n this.normalizeUrl = normalizeUrlFactory(deps);\n\n this.view = view;\n\n this.update(view, null);\n }\n\n update(view: EditorView, prevState?: EditorState | null) {\n if (!view.dom.parentNode) {\n this.hideTooltip();\n return;\n }\n\n const {state} = view;\n\n if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection))\n return;\n\n this.textNode = getTextNode(view.state);\n\n const prevRef = this.textNodeRef;\n this.updateTextNodeRef();\n\n if (!this.textNode || !this.textNodeRef) {\n this.hideTooltip();\n return;\n }\n\n if (prevRef !== this.textNodeRef) {\n this.manualHidden = false;\n }\n\n if (this.manualHidden) {\n this.hideTooltip();\n } else {\n this.renderTooltip({\n show: true,\n domElem: this.textNodeRef,\n onCancel: () => this.cancelPopup(),\n attrs: this.getMarkAttrs(),\n onChange: this.changeAttrs.bind(this),\n onOpenChange: this.onOpenChange,\n });\n }\n }\n\n destroy() {\n this.isTooltipOpen = false;\n this.selectionTooltipProps = {show: false};\n this.renderItem?.remove();\n this.renderItem = undefined;\n }\n\n onEscapeDown(): boolean {\n if (this.isTooltipOpen) {\n this.removePlaceholderLink(this.textNode);\n this.manualHidden = true;\n this.hideTooltip();\n return true;\n }\n\n return false;\n }\n\n private updateTextNodeRef() {\n const decoElem = this.view.dom.getElementsByClassName(className)[0];\n this.textNodeRef = decoElem as HTMLElement | undefined;\n }\n\n private getMarkAttrs() {\n const {textNode} = this;\n const linkMark = textNode && findMark(textNode.node, linkType(this.view.state.schema));\n return linkMark?.attrs;\n }\n\n private hideTooltip() {\n this.renderTooltip({show: false});\n }\n\n private renderTooltip(props: SelectionTooltipViewBaseProps) {\n this.isTooltipOpen = props.show;\n this.selectionTooltipProps = props;\n this.renderItem = this.renderItem ?? this.createRenderItem();\n this.renderItem.rerender();\n }\n\n private onOpenChange: NonNullable<PopupProps['onOpenChange']> = (open, _e, reason) => {\n if (open) return;\n if (reason === 'escape-key') {\n this.cancelPopup();\n } else {\n this.onOutisdeClick();\n }\n };\n\n private onOutisdeClick = () => {\n this.removePlaceholderLink(this.textNode);\n this.hideTooltip();\n this.manualHidden = true;\n };\n\n private cancelPopup() {\n this.removePlaceholderLink(this.textNode, {returnSelection: true});\n this.manualHidden = true;\n this.hideTooltip();\n this.view.focus();\n }\n\n private removePlaceholderLink(\n textNode?: ReturnType<typeof getTextNode>,\n opts?: {returnSelection?: boolean},\n ) {\n if (textNode) {\n const {view} = this;\n const {state} = view;\n const attrs = findMark(textNode.node, linkType(state.schema))?.attrs;\n if (attrs?.[LinkAttr.IsPlaceholder]) {\n const {from, to} = textNode;\n let tr = state.tr.removeMark(from, to, linkType(state.schema));\n if (opts?.returnSelection) {\n tr = tr.setSelection(TextSelection.create(tr.doc, from, to));\n }\n view.dispatch(tr);\n }\n }\n }\n\n private changeAttrs({href}: {href: string}) {\n const {view, textNode} = this;\n if (!textNode) return;\n\n const normalizeResult = this.normalizeUrl(href);\n if (normalizeResult) {\n const {url} = normalizeResult;\n const {from, to} = textNode;\n\n const tr = view.state.tr;\n tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(to)));\n tr.addMark(from, to, linkType(view.state.schema).create({href: url}));\n view.dispatch(tr);\n }\n }\n\n private createRenderItem() {\n return getReactRendererFromState(this.view.state).createItem('link-tooltip', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltipView {...this.selectionTooltipProps} />\n </ErrorLoggerBoundary>\n ));\n }\n}\ntype SelectionTooltipViewBaseProps<T = boolean> = T extends false\n ? {\n show: T;\n }\n : {\n show: T;\n domElem: HTMLElement;\n onCancel: () => void;\n onChange: (opts: {href: string}) => void;\n attrs?: {[LinkAttr.Href]?: string; [LinkAttr.IsPlaceholder]?: boolean};\n } & Pick<PopupProps, 'onOpenChange'>;\n\ntype SelectionTooltipViewProps = SelectionTooltipViewBaseProps;\n\nconst SelectionTooltipView: React.FC<SelectionTooltipViewProps> = (props) => {\n const {show} = props;\n\n if (!show) return null;\n\n const {domElem, onChange, onCancel, onOpenChange, attrs = {}} = props;\n const href = attrs[LinkAttr.Href];\n const autoFocus = attrs[LinkAttr.IsPlaceholder];\n\n return (\n <Popup\n open\n key={href}\n anchorElement={domElem}\n placement={placement}\n onOpenChange={onOpenChange}\n >\n <LinkForm\n href={href ?? ''}\n autoFocus={autoFocus}\n onChange={onChange}\n onCancel={onCancel}\n />\n </Popup>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../../src","sources":["extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx"],"names":[],"mappings":";;;;AAAA,6CAA8E;AAC9E,2DAAkD;AAElD,yDAA2F;AAC3F,oCAAoC;AACpC,yDAAqE;AACrE,uDAA4E;AAG5E,+EAA6E;AAC7E,yDAAkE;AAClE,+EAAgG;AAChG,6CAAuE;AAEvE,kDAAuC;AAEvC,MAAM,SAAS,GAAG,oBAAoB,CAAC;AACvC,MAAM,SAAS,GAAmB,CAAC,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAEzF,SAAS,WAAW,CAAC,KAAkB;IACnC,IACI,CAAC,CAAC,KAAK,CAAC,SAAS,YAAY,iCAAa,CAAC;QAC3C,CAAC,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,KAAK,CAAC,gBAAQ,CAAC,aAAa,CAAC,CAAC;IAEhD,OAAO,CACH,uBAAC,aAAK,IACF,IAAI,QAEJ,aAAa,EAAE,OAAO,EACtB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,YAE1B,uBAAC,sBAAQ,IACL,IAAI,EAAE,IAAI,IAAI,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GACpB,IAVG,IAAI,CAWL,CACX,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';\nimport {keydownHandler} from 'prosemirror-keymap';\nimport type {Node} from 'prosemirror-model';\nimport {type EditorState, Plugin, type PluginView, TextSelection} from 'prosemirror-state';\n// @ts-ignore // TODO: fix cjs build\nimport {findChildrenByMark, findParentNode} from 'prosemirror-utils';\nimport {Decoration, DecorationSet, type EditorView} from 'prosemirror-view';\n\nimport type {ExtensionDeps} from '../../../../../core';\nimport {ErrorLoggerBoundary} from '../../../../../react-utils/ErrorBoundary';\nimport {findMark, isMarkActive} from '../../../../../utils/marks';\nimport {type RendererItem, getReactRendererFromState} from '../../../../behavior/ReactRenderer';\nimport {LinkAttr, linkType, normalizeUrlFactory} from '../../../index';\n\nimport {LinkForm} from './TooltipView';\n\nconst className = 'pm-link-focus-deco';\nconst placement: PopupPlacement = ['bottom-start', 'bottom-end', 'top-start', 'top-end'];\n\nfunction getTextNode(state: EditorState) {\n if (\n !(state.selection instanceof TextSelection) ||\n !state.selection.empty ||\n !isMarkActive(state, linkType(state.schema))\n )\n return null;\n\n const parent = findParentNode(Boolean)(state.selection);\n\n if (!parent) {\n return null;\n }\n\n const textNodes = findChildrenByMark(parent?.node, linkType(state.schema));\n\n const textNode = textNodes.find((n: {node: Node; pos: number}) => {\n const start = n.pos + parent.pos;\n const end = start + n.node.nodeSize;\n return start <= state.selection.from && end >= state.selection.from;\n })!;\n\n if (!textNode) return null;\n\n const absolutePos = textNode.pos + parent.pos + 1;\n\n return {\n ...textNode,\n absolutePos,\n parent,\n from: absolutePos,\n to: absolutePos + textNode.node.nodeSize,\n };\n}\n\nexport const linkTooltipPlugin = (deps: ExtensionDeps) => {\n let viewTooltip: SelectionTooltip | null = null;\n return new Plugin({\n view(view) {\n viewTooltip = new SelectionTooltip(view, deps);\n return viewTooltip;\n },\n props: {\n handleKeyDown: keydownHandler({\n Escape: () => viewTooltip?.onEscapeDown() ?? false,\n }),\n decorations(state) {\n const textNode = getTextNode(state);\n if (!textNode) return DecorationSet.empty;\n\n const {from, to} = textNode;\n return DecorationSet.create(state.doc, [\n Decoration.inline(from, to, {\n class: `pm-node-selected ${className}`,\n }),\n ]);\n },\n },\n });\n};\n\nclass SelectionTooltip implements PluginView {\n private normalizeUrl;\n\n private view: EditorView;\n private show: boolean;\n\n private textNode?: ReturnType<typeof getTextNode>;\n private textNodeRef: HTMLElement | undefined;\n\n private manualHidden = false;\n\n private renderItem?: RendererItem;\n\n constructor(view: EditorView, deps: ExtensionDeps) {\n this.normalizeUrl = normalizeUrlFactory(deps);\n\n this.view = view;\n this.show = false;\n\n this.update(view);\n }\n\n update(view: EditorView) {\n if (!view.dom.parentNode) {\n this.hideTooltip();\n return;\n }\n\n const {state} = view;\n\n this.textNode = getTextNode(state);\n\n const prevRef = this.textNodeRef;\n this.textNodeRef = this.view.dom.getElementsByClassName(className)[0] as\n | HTMLElement\n | undefined;\n\n if (prevRef !== this.textNodeRef) {\n this.manualHidden = false;\n }\n\n if (this.manualHidden || !this.textNode || !this.textNodeRef) {\n this.hideTooltip();\n return;\n }\n\n this.showTooltip();\n }\n\n destroy() {\n this.show = false;\n this.renderItem?.remove();\n this.renderItem = undefined;\n }\n\n onEscapeDown(): boolean {\n if (this.show) {\n this.removePlaceholderLink(this.textNode);\n this.manualHidden = true;\n this.hideTooltip();\n return true;\n }\n\n return false;\n }\n\n private getMarkAttrs() {\n const {textNode} = this;\n const linkMark = textNode && findMark(textNode.node, linkType(this.view.state.schema));\n return linkMark?.attrs;\n }\n\n private renderTooltip() {\n this.renderItem = this.renderItem ?? this.createRenderItem();\n this.renderItem.rerender();\n }\n\n private hideTooltip() {\n this.show = false;\n this.renderTooltip();\n }\n\n private showTooltip() {\n this.show = true;\n this.renderTooltip();\n }\n\n private onOpenChange: NonNullable<PopupProps['onOpenChange']> = (open, _e, reason) => {\n if (open) return;\n if (reason === 'escape-key') {\n this.cancelPopup();\n } else {\n this.onOutsideClick();\n }\n };\n\n private onOutsideClick = () => {\n this.removePlaceholderLink(this.textNode);\n this.hideTooltip();\n this.manualHidden = true;\n };\n\n private cancelPopup() {\n this.removePlaceholderLink(this.textNode, {returnSelection: true});\n this.manualHidden = true;\n this.hideTooltip();\n this.view.focus();\n }\n\n private removePlaceholderLink(\n textNode?: ReturnType<typeof getTextNode>,\n opts?: {returnSelection?: boolean},\n ) {\n if (textNode) {\n const {view} = this;\n const {state} = view;\n const attrs = findMark(textNode.node, linkType(state.schema))?.attrs;\n if (attrs?.[LinkAttr.IsPlaceholder]) {\n const {from, to} = textNode;\n let tr = state.tr.removeMark(from, to, linkType(state.schema));\n if (opts?.returnSelection) {\n tr = tr.setSelection(TextSelection.create(tr.doc, from, to));\n }\n view.dispatch(tr);\n }\n }\n }\n\n private changeAttrs({href}: {href: string}) {\n const {view, textNode} = this;\n if (!textNode) return;\n\n const normalizeResult = this.normalizeUrl(href);\n if (normalizeResult) {\n const {url} = normalizeResult;\n const {from, to} = textNode;\n\n const tr = view.state.tr;\n tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(to)));\n tr.addMark(from, to, linkType(view.state.schema).create({href: url}));\n view.dispatch(tr);\n }\n }\n\n private createRenderItem() {\n return getReactRendererFromState(this.view.state).createItem('link-tooltip', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltipView\n show={this.show}\n domElem={this.textNodeRef as HTMLElement}\n onCancel={this.cancelPopup.bind(this)}\n attrs={this.getMarkAttrs()}\n onChange={this.changeAttrs.bind(this)}\n onOpenChange={this.onOpenChange}\n />\n </ErrorLoggerBoundary>\n ));\n }\n}\ntype SelectionTooltipViewBaseProps<T = boolean> = T extends false\n ? {\n show: T;\n }\n : {\n show: T;\n domElem: HTMLElement;\n onCancel: () => void;\n onChange: (opts: {href: string}) => void;\n attrs?: {[LinkAttr.Href]?: string; [LinkAttr.IsPlaceholder]?: boolean};\n } & Pick<PopupProps, 'onOpenChange'>;\n\ntype SelectionTooltipViewProps = SelectionTooltipViewBaseProps;\n\nconst SelectionTooltipView: React.FC<SelectionTooltipViewProps> = (props) => {\n const {show} = props;\n\n if (!show) return null;\n\n const {domElem, onChange, onCancel, onOpenChange, attrs = {}} = props;\n const href = attrs[LinkAttr.Href];\n const autoFocus = attrs[LinkAttr.IsPlaceholder];\n\n return (\n <Popup\n open\n key={href}\n anchorElement={domElem}\n placement={placement}\n onOpenChange={onOpenChange}\n >\n <LinkForm\n href={href ?? ''}\n autoFocus={autoFocus}\n onChange={onChange}\n onCancel={onCancel}\n />\n </Popup>\n );\n};\n"]}
|
|
@@ -17,6 +17,10 @@ export type ToolbarItemData<E> = QAProps & {
|
|
|
17
17
|
hint?: string | (() => string);
|
|
18
18
|
hotkey?: HotkeyProps['value'];
|
|
19
19
|
preview?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Alternative IDs that can be used to find this command
|
|
22
|
+
*/
|
|
23
|
+
aliases?: string[];
|
|
20
24
|
/**
|
|
21
25
|
* Show hint when _isEnable()_ returns false
|
|
22
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["toolbar/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["toolbar/types.ts"],"names":[],"mappings":";;;AA2CA,IAAY,eASX;AATD,WAAY,eAAe;IACvB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,kDAAkD;IAClD,uCAAoB,CAAA;IACpB,kDAAkD;IAClD,4CAAyB,CAAA;IACzB,iDAA8B,CAAA;AAClC,CAAC,EATW,eAAe,+BAAf,eAAe,QAS1B","sourcesContent":["import type {HotkeyProps, IconProps, QAProps} from '@gravity-ui/uikit';\n\nimport type {ClassNameProps} from '../classname';\n\nexport type ToolbarBaseProps<E> = ClassNameProps &\n QAProps & {\n editor: E;\n focus(): void;\n onClick?(id: string, attrs?: {[key: string]: any}): void;\n };\n\nexport type ToolbarIconData = Pick<IconProps, 'data' | 'size'>;\nexport type ToolbarGroupData<E> = Array<ToolbarGroupItemData<E>>;\nexport type ToolbarData<E> = ToolbarGroupData<E>[];\n\nexport type ToolbarItemData<E> = QAProps & {\n id: string;\n icon: ToolbarIconData;\n title: string | (() => string);\n hint?: string | (() => string);\n hotkey?: HotkeyProps['value'];\n preview?: React.ReactNode;\n /**\n * Alternative IDs that can be used to find this command\n */\n aliases?: string[];\n /**\n * Show hint when _isEnable()_ returns false\n *\n * `false` – don't show hint;\n *\n * `true` – show default hint;\n *\n * `string` or `() => string` – show hint with custom message.\n *\n * @default true\n */\n hintWhenDisabled?: boolean | string | (() => string);\n exec(editor: E): void;\n isActive(editor: E): boolean;\n isEnable(editor: E): boolean;\n};\n\nexport enum ToolbarDataType {\n SingleButton = 's-button',\n ListButton = 'list-b',\n ButtonPopup = 'b-popup',\n /** @deprecated Use ReactComponent type instead */\n ReactNode = 'r-node',\n /** @deprecated Use ReactComponent type instead */\n ReactNodeFn = 'r-node-fn',\n ReactComponent = 'r-component',\n}\n\nexport type ToolbarGroupItemData<E> =\n | ToolbarSingleItemData<E>\n | ToolbarButtonPopupData<E>\n | ToolbarListItemData<E>\n | ToolbarReactNodeData\n | ToolbarReactNodeFnData<E>\n | ToolbarReactComponentData<E>;\n\nexport type ToolbarSingleItemData<E> = ToolbarItemData<E> & {\n id: string;\n type: ToolbarDataType.SingleButton;\n className?: string;\n};\n\nexport type ToolbarListItemData<E> = ToolbarListButtonData<E> & {\n id: string;\n type: ToolbarDataType.ListButton;\n className?: string;\n};\n\nexport type ToolbarReactComponentData<E> = {\n id: string;\n type: ToolbarDataType.ReactComponent;\n width: number;\n className?: string;\n component: React.ComponentType<ToolbarBaseProps<E>>;\n props?: object;\n};\n\nexport type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {\n /** not used, may be an empty function */\n exec: ToolbarItemData<E>['exec'];\n type: ToolbarDataType.ButtonPopup;\n renderPopup: (\n props: ToolbarBaseProps<E> & {hide: () => void; anchorElement: HTMLElement | null},\n ) => React.ReactNode;\n className?: string;\n};\n\nexport type ToolbarListButtonItemData<E> = ToolbarItemData<E> & {\n doNotActivateList?: boolean;\n};\n\nexport type ToolbarListButtonData<E> = {\n icon: ToolbarIconData;\n title: string | (() => string);\n withArrow?: boolean;\n data: ToolbarListButtonItemData<E>[];\n alwaysActive?: boolean;\n hideDisabled?: boolean;\n /** When state changes to active, replace default icon with icon of first active item */\n replaceActiveIcon?: boolean;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n * */\nexport type ToolbarReactNodeData = {\n id: string;\n type: ToolbarDataType.ReactNode;\n width: number;\n content: React.ReactNode;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n * */\nexport type ToolbarReactNodeFnData<E> = {\n id: string;\n type: ToolbarDataType.ReactNodeFn;\n width: number;\n content: (e: E) => React.ReactNode;\n};\n"]}
|
package/build/cjs/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '15.
|
|
5
|
+
exports.VERSION = typeof '15.17.0' !== 'undefined' ? '15.17.0' : 'unknown';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/build/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACzD,QAAA,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACzD,QAAA,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.17.0' !== 'undefined' ? '15.17.0' : 'unknown';\n"]}
|
|
@@ -24,6 +24,7 @@ export const wHeading1ItemData = {
|
|
|
24
24
|
exec: (e) => e.actions.toH1.run(),
|
|
25
25
|
isActive: (e) => e.actions.toH1.isActive(),
|
|
26
26
|
isEnable: (e) => e.actions.toH1.isEnable(),
|
|
27
|
+
aliases: ['h1'],
|
|
27
28
|
preview: _jsx(HeadingPreview, { level: 1 }),
|
|
28
29
|
};
|
|
29
30
|
export const wHeading2ItemData = {
|
|
@@ -34,6 +35,7 @@ export const wHeading2ItemData = {
|
|
|
34
35
|
exec: (e) => e.actions.toH2.run(),
|
|
35
36
|
isActive: (e) => e.actions.toH2.isActive(),
|
|
36
37
|
isEnable: (e) => e.actions.toH2.isEnable(),
|
|
38
|
+
aliases: ['h2'],
|
|
37
39
|
preview: _jsx(HeadingPreview, { level: 2 }),
|
|
38
40
|
};
|
|
39
41
|
export const wHeading3ItemData = {
|
|
@@ -44,6 +46,7 @@ export const wHeading3ItemData = {
|
|
|
44
46
|
exec: (e) => e.actions.toH3.run(),
|
|
45
47
|
isActive: (e) => e.actions.toH3.isActive(),
|
|
46
48
|
isEnable: (e) => e.actions.toH3.isEnable(),
|
|
49
|
+
aliases: ['h3'],
|
|
47
50
|
preview: _jsx(HeadingPreview, { level: 3 }),
|
|
48
51
|
};
|
|
49
52
|
export const wHeading4ItemData = {
|
|
@@ -54,6 +57,7 @@ export const wHeading4ItemData = {
|
|
|
54
57
|
exec: (e) => e.actions.toH4.run(),
|
|
55
58
|
isActive: (e) => e.actions.toH4.isActive(),
|
|
56
59
|
isEnable: (e) => e.actions.toH4.isEnable(),
|
|
60
|
+
aliases: ['h4'],
|
|
57
61
|
preview: _jsx(HeadingPreview, { level: 4 }),
|
|
58
62
|
};
|
|
59
63
|
export const wHeading5ItemData = {
|
|
@@ -64,6 +68,7 @@ export const wHeading5ItemData = {
|
|
|
64
68
|
exec: (e) => e.actions.toH5.run(),
|
|
65
69
|
isActive: (e) => e.actions.toH5.isActive(),
|
|
66
70
|
isEnable: (e) => e.actions.toH5.isEnable(),
|
|
71
|
+
aliases: ['h5'],
|
|
67
72
|
preview: _jsx(HeadingPreview, { level: 5 }),
|
|
68
73
|
};
|
|
69
74
|
export const wHeading6ItemData = {
|
|
@@ -74,6 +79,7 @@ export const wHeading6ItemData = {
|
|
|
74
79
|
exec: (e) => e.actions.toH6.run(),
|
|
75
80
|
isActive: (e) => e.actions.toH6.isActive(),
|
|
76
81
|
isEnable: (e) => e.actions.toH6.isEnable(),
|
|
82
|
+
aliases: ['h6'],
|
|
77
83
|
preview: _jsx(HeadingPreview, { level: 6 }),
|
|
78
84
|
};
|
|
79
85
|
export const wHeadingListConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"w-heading-config.js","sourceRoot":"../../../../src","sources":["bundle/config/w-heading-config.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,oCAA2B;AACxC,OAAO,EAAC,MAAM,IAAI,CAAC,EAAE,SAAS,IAAI,CAAC,EAAC,iCAAwB;AAG5D,OAAO,EAAC,UAAU,EAAC,0BAAuB;AAC1C,OAAO,EAAC,KAAK,EAAC,mBAAgB;AAC9B,OAAO,EAAC,cAAc,EAAC,qCAAkC;AACzD,OAAO,EAAC,WAA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KAAK,EAAE,CAAC,GAAI;CACxC,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAA+B;IACzD,EAAE,EAAE,UAAU,CAAC,QAAQ;IACvB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;IAClC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,4CAA4C;IAC5D,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;IACjC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC1C,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,KAAC,cAAc,IAAC,KAAK,EAAE,CAAC,GAAI;CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACtD,IAAI,EAAE,KAAK,CAAC,QAAQ;IACpB,SAAS,EAAE,IAAI;IACf,iBAAiB,EAAE,IAAI;IACvB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;IACjC,IAAI,EAAE;QACF,aAAa;QACb,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;KACpB;CACJ,CAAC","sourcesContent":["import {i18n} from '../../i18n/menubar';\nimport {Action as A, formatter as f} from '../../shortcuts';\nimport type {WToolbarListButtonData, WToolbarListButtonItemData} from '../toolbar/types';\n\nimport {ActionName} from './action-names';\nimport {icons} from './icons';\nimport {HeadingPreview} from './previews/HeadingPreview';\nimport {TextPreview} from './previews/TextPreview';\n\nexport const wTextItemData: WToolbarListButtonItemData = {\n id: ActionName.paragraph,\n title: i18n.bind(null, 'text'),\n icon: icons.text,\n hotkey: f.toView(A.Text),\n exec: (e) => e.actions.toParagraph.run(),\n isActive: (e) => e.actions.toParagraph.isActive(),\n isEnable: (e) => e.actions.toParagraph.isEnable(),\n doNotActivateList: true,\n preview: <TextPreview />,\n};\nexport const wHeading1ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading1,\n title: i18n.bind(null, 'heading1'),\n icon: icons.h1,\n hotkey: f.toView(A.Heading1),\n exec: (e) => e.actions.toH1.run(),\n isActive: (e) => e.actions.toH1.isActive(),\n isEnable: (e) => e.actions.toH1.isEnable(),\n preview: <HeadingPreview level={1} />,\n};\nexport const wHeading2ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading2,\n title: i18n.bind(null, 'heading2'),\n icon: icons.h2,\n hotkey: f.toView(A.Heading2),\n exec: (e) => e.actions.toH2.run(),\n isActive: (e) => e.actions.toH2.isActive(),\n isEnable: (e) => e.actions.toH2.isEnable(),\n preview: <HeadingPreview level={2} />,\n};\nexport const wHeading3ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading3,\n title: i18n.bind(null, 'heading3'),\n icon: icons.h3,\n hotkey: f.toView(A.Heading3),\n exec: (e) => e.actions.toH3.run(),\n isActive: (e) => e.actions.toH3.isActive(),\n isEnable: (e) => e.actions.toH3.isEnable(),\n preview: <HeadingPreview level={3} />,\n};\nexport const wHeading4ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading4,\n title: i18n.bind(null, 'heading4'),\n icon: icons.h4, // Предполагается, что icon исправлен для h4\n hotkey: f.toView(A.Heading4),\n exec: (e) => e.actions.toH4.run(),\n isActive: (e) => e.actions.toH4.isActive(),\n isEnable: (e) => e.actions.toH4.isEnable(),\n preview: <HeadingPreview level={4} />,\n};\nexport const wHeading5ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading5,\n title: i18n.bind(null, 'heading5'),\n icon: icons.h5, // Предполагается, что icon исправлен для h5\n hotkey: f.toView(A.Heading5),\n exec: (e) => e.actions.toH5.run(),\n isActive: (e) => e.actions.toH5.isActive(),\n isEnable: (e) => e.actions.toH5.isEnable(),\n preview: <HeadingPreview level={5} />,\n};\nexport const wHeading6ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading6,\n title: i18n.bind(null, 'heading6'),\n icon: icons.h6, // Предполагается, что icon исправлен для h6\n hotkey: f.toView(A.Heading6),\n exec: (e) => e.actions.toH6.run(),\n isActive: (e) => e.actions.toH6.isActive(),\n isEnable: (e) => e.actions.toH6.isEnable(),\n preview: <HeadingPreview level={6} />,\n};\n\nexport const wHeadingListConfig: WToolbarListButtonData = {\n icon: icons.headline,\n withArrow: true,\n replaceActiveIcon: true,\n title: i18n.bind(null, 'heading'),\n data: [\n wTextItemData,\n wHeading1ItemData,\n wHeading2ItemData,\n wHeading3ItemData,\n wHeading4ItemData,\n wHeading5ItemData,\n wHeading6ItemData,\n ],\n};\n"]}
|
|
1
|
+
{"version":3,"file":"w-heading-config.js","sourceRoot":"../../../../src","sources":["bundle/config/w-heading-config.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,oCAA2B;AACxC,OAAO,EAAC,MAAM,IAAI,CAAC,EAAE,SAAS,IAAI,CAAC,EAAC,iCAAwB;AAG5D,OAAO,EAAC,UAAU,EAAC,0BAAuB;AAC1C,OAAO,EAAC,KAAK,EAAC,mBAAgB;AAC9B,OAAO,EAAC,cAAc,EAAC,qCAAkC;AACzD,OAAO,EAAC,WAAW,EAAC,kCAA+B;AAEnD,MAAM,CAAC,MAAM,aAAa,GAA+B;IACrD,EAAE,EAAE,UAAU,CAAC,SAAS;IACxB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC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I,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;IAClC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,4CAA4C;IAC5D,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;IACjC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC1C,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,OAAO,EAAE,KAAC,cAAc,IAAC,KAAK,EAAE,CAAC,GAAI;CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACtD,IAAI,EAAE,KAAK,CAAC,QAAQ;IACpB,SAAS,EAAE,IAAI;IACf,iBAAiB,EAAE,IAAI;IACvB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;IACjC,IAAI,EAAE;QACF,aAAa;QACb,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;KACpB;CACJ,CAAC","sourcesContent":["import {i18n} from '../../i18n/menubar';\nimport {Action as A, formatter as f} from '../../shortcuts';\nimport type {WToolbarListButtonData, WToolbarListButtonItemData} from '../toolbar/types';\n\nimport {ActionName} from './action-names';\nimport {icons} from './icons';\nimport {HeadingPreview} from './previews/HeadingPreview';\nimport {TextPreview} from './previews/TextPreview';\n\nexport const wTextItemData: WToolbarListButtonItemData = {\n id: ActionName.paragraph,\n title: i18n.bind(null, 'text'),\n icon: icons.text,\n hotkey: f.toView(A.Text),\n exec: (e) => e.actions.toParagraph.run(),\n isActive: (e) => e.actions.toParagraph.isActive(),\n isEnable: (e) => e.actions.toParagraph.isEnable(),\n doNotActivateList: true,\n preview: <TextPreview />,\n};\nexport const wHeading1ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading1,\n title: i18n.bind(null, 'heading1'),\n icon: icons.h1,\n hotkey: f.toView(A.Heading1),\n exec: (e) => e.actions.toH1.run(),\n isActive: (e) => e.actions.toH1.isActive(),\n isEnable: (e) => e.actions.toH1.isEnable(),\n aliases: ['h1'],\n preview: <HeadingPreview level={1} />,\n};\nexport const wHeading2ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading2,\n title: i18n.bind(null, 'heading2'),\n icon: icons.h2,\n hotkey: f.toView(A.Heading2),\n exec: (e) => e.actions.toH2.run(),\n isActive: (e) => e.actions.toH2.isActive(),\n isEnable: (e) => e.actions.toH2.isEnable(),\n aliases: ['h2'],\n preview: <HeadingPreview level={2} />,\n};\nexport const wHeading3ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading3,\n title: i18n.bind(null, 'heading3'),\n icon: icons.h3,\n hotkey: f.toView(A.Heading3),\n exec: (e) => e.actions.toH3.run(),\n isActive: (e) => e.actions.toH3.isActive(),\n isEnable: (e) => e.actions.toH3.isEnable(),\n aliases: ['h3'],\n preview: <HeadingPreview level={3} />,\n};\nexport const wHeading4ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading4,\n title: i18n.bind(null, 'heading4'),\n icon: icons.h4, // Предполагается, что icon исправлен для h4\n hotkey: f.toView(A.Heading4),\n exec: (e) => e.actions.toH4.run(),\n isActive: (e) => e.actions.toH4.isActive(),\n isEnable: (e) => e.actions.toH4.isEnable(),\n aliases: ['h4'],\n preview: <HeadingPreview level={4} />,\n};\nexport const wHeading5ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading5,\n title: i18n.bind(null, 'heading5'),\n icon: icons.h5, // Предполагается, что icon исправлен для h5\n hotkey: f.toView(A.Heading5),\n exec: (e) => e.actions.toH5.run(),\n isActive: (e) => e.actions.toH5.isActive(),\n isEnable: (e) => e.actions.toH5.isEnable(),\n aliases: ['h5'],\n preview: <HeadingPreview level={5} />,\n};\nexport const wHeading6ItemData: WToolbarListButtonItemData = {\n id: ActionName.heading6,\n title: i18n.bind(null, 'heading6'),\n icon: icons.h6, // Предполагается, что icon исправлен для h6\n hotkey: f.toView(A.Heading6),\n exec: (e) => e.actions.toH6.run(),\n isActive: (e) => e.actions.toH6.isActive(),\n isEnable: (e) => e.actions.toH6.isEnable(),\n aliases: ['h6'],\n preview: <HeadingPreview level={6} />,\n};\n\nexport const wHeadingListConfig: WToolbarListButtonData = {\n icon: icons.headline,\n withArrow: true,\n replaceActiveIcon: true,\n title: i18n.bind(null, 'heading'),\n data: [\n wTextItemData,\n wHeading1ItemData,\n wHeading2ItemData,\n wHeading3ItemData,\n wHeading4ItemData,\n wHeading5ItemData,\n wHeading6ItemData,\n ],\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActionStorage } from "../../../core/index.js";
|
|
2
2
|
import { type Logger2 } from "../../../logger.js";
|
|
3
3
|
import { type AutocompleteAction, type AutocompleteHandler } from "../Autocomplete/index.js";
|
|
4
|
-
import type { Config } from "./types.js";
|
|
4
|
+
import type { CommandAction, Config } from "./types.js";
|
|
5
5
|
declare module 'prosemirror-model' {
|
|
6
6
|
interface NodeSpec {
|
|
7
7
|
commandMenu?: boolean;
|
|
@@ -33,3 +33,4 @@ export declare class CommandHandler implements AutocompleteHandler {
|
|
|
33
33
|
private createMenuRenderItem;
|
|
34
34
|
private findAnchor;
|
|
35
35
|
}
|
|
36
|
+
export declare function filterActions(actions: readonly CommandAction[], text: string): CommandAction[];
|
|
@@ -176,9 +176,16 @@ export class CommandHandler {
|
|
|
176
176
|
this.#anchor = findDecoElem(this.#view?.dom);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
function filterActions(actions, text) {
|
|
180
|
-
return actions.filter((action) =>
|
|
181
|
-
|
|
179
|
+
export function filterActions(actions, text) {
|
|
180
|
+
return actions.filter((action) => {
|
|
181
|
+
const lowerText = text.toLowerCase();
|
|
182
|
+
const matchesId = action.id.toLowerCase().includes(lowerText);
|
|
183
|
+
const matchesTitle = (isFunction(action.title) ? action.title() : action.title)
|
|
184
|
+
.toLowerCase()
|
|
185
|
+
.includes(lowerText);
|
|
186
|
+
const matchesAliases = action.aliases?.some((alias) => alias.toLowerCase().includes(lowerText)) ?? false;
|
|
187
|
+
return matchesId || matchesTitle || matchesAliases;
|
|
188
|
+
});
|
|
182
189
|
}
|
|
183
190
|
const CHARS_TO_HIDE = 4;
|
|
184
191
|
function needToHide(actions, text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/CommandMenu/handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAe,YAAY,EAAC,2BAAwB;AAC3D,OAAO,EAAC,uBAAuB,EAAC,6CAA0C;AAC1E,OAAO,EAAC,aAAa,EAAC,yCAAgC;AACtD,OAAO,EAEH,sBAAsB,EAEtB,iBAAiB,EACjB,oBAAoB,GACvB,iCAAwB;AACzB,OAAO,EAAoB,yBAAyB,EAAC,kCAAyB;AAE9E,OAAO,EAAiC,MAAM,EAAC,uBAAoB;AAEnE,OAAO,EAAC,YAAY,EAAC,mBAAgB;AAerC,MAAM,OAAO,cAAc;IACd,OAAO,CAAkB;IACzB,QAAQ,CAA2B;IACnC,cAAc,CAAgB;IAC9B,gBAAgB,CAAoB;IAC7C,wBAAwB,CAAgC;IAExD,KAAK,CAAc;IACnB,OAAO,GAAmB,IAAI,CAAC;IAC/B,WAAW,CAAU;IACrB,YAAY,CAA2B;IAEvC,UAAU,CAA6B;IACvC,eAAe,CAAgB;IAE/B,YAAY,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAuB;QAC9E,IAAI,CAAC,OAAO,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UAAU,CAAC,cAAc,EAAE,GAAG,EAAE,CAChF,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CACnD,CAAC;IACN,CAAC;IAEO,UAAU;QACd,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;CACJ;AAED,SAAS,aAAa,CAAC,OAAiC,EAAE,IAAY;IAClE,OAAO,OAAO,CAAC,MAAM,CACjB,CAAC,MAAM,EAAE,EAAE,CACP,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtC,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC9F,CAAC;AACN,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,SAAS,UAAU,CAAC,OAAiC,EAAE,IAAY;IAC/D,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,GAAG,CAAC;QACA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACpD,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACtD,IAAI,WAAW,CAAC,MAAM;YAAE,MAAM;QAC9B,IAAI,EAAE,CAAC;IACX,CAAC,QAAQ,IAAI,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,aAAa,EAAE;IACrD,OAAO,IAAI,IAAI,aAAa,CAAC;AACjC,CAAC","sourcesContent":["import type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {AutocompletePopupCloser} from '../../../utils/autocomplete-popup';\nimport {ArrayCarousel} from '../../../utils/carousel';\nimport {\n type AutocompleteAction,\n AutocompleteActionKind,\n type AutocompleteHandler,\n closeAutocomplete,\n getAutocompleteState,\n} from '../Autocomplete';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\nimport {type CommandMenuComponentProps, render} from './component';\nimport type {CommandAction, Config} from './types';\nimport {findDecoElem} from './utils';\n\ndeclare module 'prosemirror-model' {\n interface NodeSpec {\n commandMenu?: boolean;\n }\n}\n\nexport type CommandHandlerParams = {\n logger: Logger2.ILogger;\n actions: Config;\n storage: ActionStorage;\n nodesIgnoreList?: readonly string[];\n};\n\nexport class CommandHandler implements AutocompleteHandler {\n readonly #logger: Logger2.ILogger;\n readonly #actions: readonly CommandAction[];\n readonly #actionStorage: ActionStorage;\n readonly #nodesIgnoreList: readonly string[];\n #filteredActionsCarousel?: ArrayCarousel<CommandAction>;\n\n #view?: EditorView;\n #anchor: Element | null = null;\n #filterText?: string;\n #popupCloser?: AutocompletePopupCloser;\n\n #menuProps?: CommandMenuComponentProps;\n #menuRenderItem?: RendererItem;\n\n constructor({logger, actions, storage, nodesIgnoreList = []}: CommandHandlerParams) {\n this.#logger = logger;\n this.#actions = actions;\n this.#actionStorage = storage;\n this.#nodesIgnoreList = nodesIgnoreList;\n }\n\n onOpen(action: AutocompleteAction): boolean {\n this.findAnchor();\n if (!this.#anchor || this.shouldIgnore(action)) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.#popupCloser = new AutocompletePopupCloser(action.view);\n this.updateState(action);\n this.filterActions();\n this.render();\n\n return true;\n }\n\n onFilter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action) || action.filter?.endsWith(' ')) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.#filterText = action.filter?.trim().toLowerCase();\n const needToClose = this.filterActions();\n this.render();\n\n if (needToClose) {\n this.closeAutocomplete(action.view);\n }\n\n return true;\n }\n\n onArrow(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n if (!this.#filteredActionsCarousel) return false;\n\n switch (action.kind) {\n case AutocompleteActionKind.up: {\n this.#filteredActionsCarousel.prev();\n break;\n }\n case AutocompleteActionKind.down: {\n this.#filteredActionsCarousel.next();\n break;\n }\n default:\n return false;\n }\n\n this.render();\n\n return true;\n }\n\n onEnter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.select();\n\n return true;\n }\n\n onClose(action: AutocompleteAction): boolean {\n this.updateState(action);\n\n this.clear();\n\n return true;\n }\n\n onDestroy(): void {\n this.clear();\n }\n\n private closeAutocomplete(view: EditorView) {\n setTimeout(() => {\n closeAutocomplete(view);\n });\n }\n\n private shouldIgnore(action: AutocompleteAction): boolean {\n const parentType = action.view.state.doc.resolve(action.range.from).parent.type;\n return (\n parentType.spec.commandMenu === false || this.#nodesIgnoreList.includes(parentType.name)\n );\n }\n\n private select() {\n if (!this.#view) return;\n\n const action = this.#filteredActionsCarousel?.currentItem;\n if (!action) return;\n\n const autocompleteState = getAutocompleteState(this.#view.state);\n if (!autocompleteState || !autocompleteState.active) return;\n\n const view = this.#view;\n const {range} = autocompleteState;\n\n view.dispatch(view.state.tr.deleteRange(range.from, range.to).scrollIntoView());\n action.exec(this.#actionStorage);\n view.focus();\n\n globalLogger.action({mode: 'wysiwyg', source: 'command-menu', action: action.id});\n this.#logger.action({source: 'command-menu', action: action.id});\n }\n\n private filterActions(): boolean {\n const currentItem = this.#filteredActionsCarousel?.currentItem;\n const inputText = this.#filterText;\n\n const enabledActions = this.#actions.filter((action) =>\n action.isEnable(this.#actionStorage),\n );\n\n let filteredActions = enabledActions;\n let needToClose = false;\n\n if (inputText) {\n filteredActions = filterActions(enabledActions, inputText);\n needToClose = !filteredActions.length && needToHide(enabledActions, inputText);\n }\n\n this.#filteredActionsCarousel = new ArrayCarousel(filteredActions);\n\n if (currentItem) {\n const newIndex = this.#filteredActionsCarousel.array.findIndex(\n (item) => item === currentItem,\n );\n if (newIndex !== -1) {\n this.#filteredActionsCarousel.currentIndex = newIndex;\n }\n }\n\n return needToClose;\n }\n\n private render() {\n this.findAnchor();\n const viewItems = this.#filteredActionsCarousel?.array ?? [];\n this.#menuProps = {\n anchorElement: this.#anchor,\n currentIndex: this.#filteredActionsCarousel?.currentIndex,\n items: viewItems,\n onItemClick: this.onItemClick,\n onOpenChange: this.#popupCloser?.popupOpenChangeHandler,\n };\n this.#menuRenderItem = this.#menuRenderItem ?? this.createMenuRenderItem();\n this.#menuRenderItem.rerender();\n }\n\n private onItemClick = (index: number) => {\n if (this.#filteredActionsCarousel) {\n this.#filteredActionsCarousel.currentIndex = index;\n this.select();\n }\n this.#view?.focus();\n };\n\n private updateState({view}: AutocompleteAction) {\n this.#view = view;\n }\n\n private clear() {\n this.#view = undefined;\n this.#anchor = null;\n this.#filterText = undefined;\n this.#filteredActionsCarousel = undefined;\n this.#popupCloser?.cancelTimer();\n this.#popupCloser = undefined;\n this.#menuProps = undefined;\n this.#menuRenderItem?.remove();\n this.#menuRenderItem = undefined;\n }\n\n private createMenuRenderItem(): RendererItem {\n return getReactRendererFromState(this.#view!.state).createItem('command_menu', () =>\n this.#menuProps ? render(this.#menuProps) : null,\n );\n }\n\n private findAnchor() {\n this.#anchor = findDecoElem(this.#view?.dom);\n }\n}\n\nfunction filterActions(actions: readonly CommandAction[], text: string): CommandAction[] {\n return actions.filter(\n (action) =>\n action.id.toLowerCase().includes(text) ||\n (isFunction(action.title) ? action.title() : action.title).toLowerCase().includes(text),\n );\n}\n\nconst CHARS_TO_HIDE = 4;\nfunction needToHide(actions: readonly CommandAction[], text: string): boolean {\n let iter = 1;\n do {\n const prevInput = text.slice(0, text.length - iter);\n const prevActions = filterActions(actions, prevInput);\n if (prevActions.length) break;\n iter++;\n } while (iter < text.length && iter < CHARS_TO_HIDE);\n return iter >= CHARS_TO_HIDE;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/CommandMenu/handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAe,YAAY,EAAC,2BAAwB;AAC3D,OAAO,EAAC,uBAAuB,EAAC,6CAA0C;AAC1E,OAAO,EAAC,aAAa,EAAC,yCAAgC;AACtD,OAAO,EAEH,sBAAsB,EAEtB,iBAAiB,EACjB,oBAAoB,GACvB,iCAAwB;AACzB,OAAO,EAAoB,yBAAyB,EAAC,kCAAyB;AAE9E,OAAO,EAAiC,MAAM,EAAC,uBAAoB;AAEnE,OAAO,EAAC,YAAY,EAAC,mBAAgB;AAerC,MAAM,OAAO,cAAc;IACd,OAAO,CAAkB;IACzB,QAAQ,CAA2B;IACnC,cAAc,CAAgB;IAC9B,gBAAgB,CAAoB;IAC7C,wBAAwB,CAAgC;IAExD,KAAK,CAAc;IACnB,OAAO,GAAmB,IAAI,CAAC;IAC/B,WAAW,CAAU;IACrB,YAAY,CAA2B;IAEvC,UAAU,CAA6B;IACvC,eAAe,CAAgB;IAE/B,YAAY,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAuB;QAC9E,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,MAA0B;QAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,iBAAiB,CA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C,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC1E,WAAW,EAAE;aACb,QAAQ,CAAC,SAAS,CAAC,CAAC;QACzB,MAAM,cAAc,GAChB,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC;QAEtF,OAAO,SAAS,IAAI,YAAY,IAAI,cAAc,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,SAAS,UAAU,CAAC,OAAiC,EAAE,IAAY;IAC/D,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,GAAG,CAAC;QACA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACpD,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACtD,IAAI,WAAW,CAAC,MAAM;YAAE,MAAM;QAC9B,IAAI,EAAE,CAAC;IACX,CAAC,QAAQ,IAAI,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,aAAa,EAAE;IACrD,OAAO,IAAI,IAAI,aAAa,CAAC;AACjC,CAAC","sourcesContent":["import type {EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage} from '../../../core';\nimport {isFunction} from '../../../lodash';\nimport {type Logger2, globalLogger} from '../../../logger';\nimport {AutocompletePopupCloser} from '../../../utils/autocomplete-popup';\nimport {ArrayCarousel} from '../../../utils/carousel';\nimport {\n type AutocompleteAction,\n AutocompleteActionKind,\n type AutocompleteHandler,\n closeAutocomplete,\n getAutocompleteState,\n} from '../Autocomplete';\nimport {type RendererItem, getReactRendererFromState} from '../ReactRenderer';\n\nimport {type CommandMenuComponentProps, render} from './component';\nimport type {CommandAction, Config} from './types';\nimport {findDecoElem} from './utils';\n\ndeclare module 'prosemirror-model' {\n interface NodeSpec {\n commandMenu?: boolean;\n }\n}\n\nexport type CommandHandlerParams = {\n logger: Logger2.ILogger;\n actions: Config;\n storage: ActionStorage;\n nodesIgnoreList?: readonly string[];\n};\n\nexport class CommandHandler implements AutocompleteHandler {\n readonly #logger: Logger2.ILogger;\n readonly #actions: readonly CommandAction[];\n readonly #actionStorage: ActionStorage;\n readonly #nodesIgnoreList: readonly string[];\n #filteredActionsCarousel?: ArrayCarousel<CommandAction>;\n\n #view?: EditorView;\n #anchor: Element | null = null;\n #filterText?: string;\n #popupCloser?: AutocompletePopupCloser;\n\n #menuProps?: CommandMenuComponentProps;\n #menuRenderItem?: RendererItem;\n\n constructor({logger, actions, storage, nodesIgnoreList = []}: CommandHandlerParams) {\n this.#logger = logger;\n this.#actions = actions;\n this.#actionStorage = storage;\n this.#nodesIgnoreList = nodesIgnoreList;\n }\n\n onOpen(action: AutocompleteAction): boolean {\n this.findAnchor();\n if (!this.#anchor || this.shouldIgnore(action)) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.#popupCloser = new AutocompletePopupCloser(action.view);\n this.updateState(action);\n this.filterActions();\n this.render();\n\n return true;\n }\n\n onFilter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action) || action.filter?.endsWith(' ')) {\n this.closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.#filterText = action.filter?.trim().toLowerCase();\n const needToClose = this.filterActions();\n this.render();\n\n if (needToClose) {\n this.closeAutocomplete(action.view);\n }\n\n return true;\n }\n\n onArrow(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n if (!this.#filteredActionsCarousel) return false;\n\n switch (action.kind) {\n case AutocompleteActionKind.up: {\n this.#filteredActionsCarousel.prev();\n break;\n }\n case AutocompleteActionKind.down: {\n this.#filteredActionsCarousel.next();\n break;\n }\n default:\n return false;\n }\n\n this.render();\n\n return true;\n }\n\n onEnter(action: AutocompleteAction): boolean {\n if (this.shouldIgnore(action)) {\n closeAutocomplete(action.view);\n return true;\n }\n\n this.updateState(action);\n\n this.select();\n\n return true;\n }\n\n onClose(action: AutocompleteAction): boolean {\n this.updateState(action);\n\n this.clear();\n\n return true;\n }\n\n onDestroy(): void {\n this.clear();\n }\n\n private closeAutocomplete(view: EditorView) {\n setTimeout(() => {\n closeAutocomplete(view);\n });\n }\n\n private shouldIgnore(action: AutocompleteAction): boolean {\n const parentType = action.view.state.doc.resolve(action.range.from).parent.type;\n return (\n parentType.spec.commandMenu === false || this.#nodesIgnoreList.includes(parentType.name)\n );\n }\n\n private select() {\n if (!this.#view) return;\n\n const action = this.#filteredActionsCarousel?.currentItem;\n if (!action) return;\n\n const autocompleteState = getAutocompleteState(this.#view.state);\n if (!autocompleteState || !autocompleteState.active) return;\n\n const view = this.#view;\n const {range} = autocompleteState;\n\n view.dispatch(view.state.tr.deleteRange(range.from, range.to).scrollIntoView());\n action.exec(this.#actionStorage);\n view.focus();\n\n globalLogger.action({mode: 'wysiwyg', source: 'command-menu', action: action.id});\n this.#logger.action({source: 'command-menu', action: action.id});\n }\n\n private filterActions(): boolean {\n const currentItem = this.#filteredActionsCarousel?.currentItem;\n const inputText = this.#filterText;\n\n const enabledActions = this.#actions.filter((action) =>\n action.isEnable(this.#actionStorage),\n );\n\n let filteredActions = enabledActions;\n let needToClose = false;\n\n if (inputText) {\n filteredActions = filterActions(enabledActions, inputText);\n needToClose = !filteredActions.length && needToHide(enabledActions, inputText);\n }\n\n this.#filteredActionsCarousel = new ArrayCarousel(filteredActions);\n\n if (currentItem) {\n const newIndex = this.#filteredActionsCarousel.array.findIndex(\n (item) => item === currentItem,\n );\n if (newIndex !== -1) {\n this.#filteredActionsCarousel.currentIndex = newIndex;\n }\n }\n\n return needToClose;\n }\n\n private render() {\n this.findAnchor();\n const viewItems = this.#filteredActionsCarousel?.array ?? [];\n this.#menuProps = {\n anchorElement: this.#anchor,\n currentIndex: this.#filteredActionsCarousel?.currentIndex,\n items: viewItems,\n onItemClick: this.onItemClick,\n onOpenChange: this.#popupCloser?.popupOpenChangeHandler,\n };\n this.#menuRenderItem = this.#menuRenderItem ?? this.createMenuRenderItem();\n this.#menuRenderItem.rerender();\n }\n\n private onItemClick = (index: number) => {\n if (this.#filteredActionsCarousel) {\n this.#filteredActionsCarousel.currentIndex = index;\n this.select();\n }\n this.#view?.focus();\n };\n\n private updateState({view}: AutocompleteAction) {\n this.#view = view;\n }\n\n private clear() {\n this.#view = undefined;\n this.#anchor = null;\n this.#filterText = undefined;\n this.#filteredActionsCarousel = undefined;\n this.#popupCloser?.cancelTimer();\n this.#popupCloser = undefined;\n this.#menuProps = undefined;\n this.#menuRenderItem?.remove();\n this.#menuRenderItem = undefined;\n }\n\n private createMenuRenderItem(): RendererItem {\n return getReactRendererFromState(this.#view!.state).createItem('command_menu', () =>\n this.#menuProps ? render(this.#menuProps) : null,\n );\n }\n\n private findAnchor() {\n this.#anchor = findDecoElem(this.#view?.dom);\n }\n}\n\nexport function filterActions(actions: readonly CommandAction[], text: string): CommandAction[] {\n return actions.filter((action) => {\n const lowerText = text.toLowerCase();\n const matchesId = action.id.toLowerCase().includes(lowerText);\n const matchesTitle = (isFunction(action.title) ? action.title() : action.title)\n .toLowerCase()\n .includes(lowerText);\n const matchesAliases =\n action.aliases?.some((alias) => alias.toLowerCase().includes(lowerText)) ?? false;\n\n return matchesId || matchesTitle || matchesAliases;\n });\n}\n\nconst CHARS_TO_HIDE = 4;\nfunction needToHide(actions: readonly CommandAction[], text: string): boolean {\n let iter = 1;\n do {\n const prevInput = text.slice(0, text.length - iter);\n const prevActions = filterActions(actions, prevInput);\n if (prevActions.length) break;\n iter++;\n } while (iter < text.length && iter < CHARS_TO_HIDE);\n return iter >= CHARS_TO_HIDE;\n}\n"]}
|
|
@@ -66,57 +66,42 @@ export const linkTooltipPlugin = (deps) => {
|
|
|
66
66
|
class SelectionTooltip {
|
|
67
67
|
normalizeUrl;
|
|
68
68
|
view;
|
|
69
|
+
show;
|
|
69
70
|
textNode;
|
|
70
71
|
textNodeRef;
|
|
71
|
-
isTooltipOpen = false;
|
|
72
72
|
manualHidden = false;
|
|
73
73
|
renderItem;
|
|
74
|
-
selectionTooltipProps = { show: false };
|
|
75
74
|
constructor(view, deps) {
|
|
76
75
|
this.normalizeUrl = normalizeUrlFactory(deps);
|
|
77
76
|
this.view = view;
|
|
78
|
-
this.
|
|
77
|
+
this.show = false;
|
|
78
|
+
this.update(view);
|
|
79
79
|
}
|
|
80
|
-
update(view
|
|
80
|
+
update(view) {
|
|
81
81
|
if (!view.dom.parentNode) {
|
|
82
82
|
this.hideTooltip();
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
const { state } = view;
|
|
86
|
-
|
|
87
|
-
return;
|
|
88
|
-
this.textNode = getTextNode(view.state);
|
|
86
|
+
this.textNode = getTextNode(state);
|
|
89
87
|
const prevRef = this.textNodeRef;
|
|
90
|
-
this.
|
|
91
|
-
if (!this.textNode || !this.textNodeRef) {
|
|
92
|
-
this.hideTooltip();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
88
|
+
this.textNodeRef = this.view.dom.getElementsByClassName(className)[0];
|
|
95
89
|
if (prevRef !== this.textNodeRef) {
|
|
96
90
|
this.manualHidden = false;
|
|
97
91
|
}
|
|
98
|
-
if (this.manualHidden) {
|
|
92
|
+
if (this.manualHidden || !this.textNode || !this.textNodeRef) {
|
|
99
93
|
this.hideTooltip();
|
|
94
|
+
return;
|
|
100
95
|
}
|
|
101
|
-
|
|
102
|
-
this.renderTooltip({
|
|
103
|
-
show: true,
|
|
104
|
-
domElem: this.textNodeRef,
|
|
105
|
-
onCancel: () => this.cancelPopup(),
|
|
106
|
-
attrs: this.getMarkAttrs(),
|
|
107
|
-
onChange: this.changeAttrs.bind(this),
|
|
108
|
-
onOpenChange: this.onOpenChange,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
96
|
+
this.showTooltip();
|
|
111
97
|
}
|
|
112
98
|
destroy() {
|
|
113
|
-
this.
|
|
114
|
-
this.selectionTooltipProps = { show: false };
|
|
99
|
+
this.show = false;
|
|
115
100
|
this.renderItem?.remove();
|
|
116
101
|
this.renderItem = undefined;
|
|
117
102
|
}
|
|
118
103
|
onEscapeDown() {
|
|
119
|
-
if (this.
|
|
104
|
+
if (this.show) {
|
|
120
105
|
this.removePlaceholderLink(this.textNode);
|
|
121
106
|
this.manualHidden = true;
|
|
122
107
|
this.hideTooltip();
|
|
@@ -124,24 +109,23 @@ class SelectionTooltip {
|
|
|
124
109
|
}
|
|
125
110
|
return false;
|
|
126
111
|
}
|
|
127
|
-
updateTextNodeRef() {
|
|
128
|
-
const decoElem = this.view.dom.getElementsByClassName(className)[0];
|
|
129
|
-
this.textNodeRef = decoElem;
|
|
130
|
-
}
|
|
131
112
|
getMarkAttrs() {
|
|
132
113
|
const { textNode } = this;
|
|
133
114
|
const linkMark = textNode && findMark(textNode.node, linkType(this.view.state.schema));
|
|
134
115
|
return linkMark?.attrs;
|
|
135
116
|
}
|
|
136
|
-
|
|
137
|
-
this.renderTooltip({ show: false });
|
|
138
|
-
}
|
|
139
|
-
renderTooltip(props) {
|
|
140
|
-
this.isTooltipOpen = props.show;
|
|
141
|
-
this.selectionTooltipProps = props;
|
|
117
|
+
renderTooltip() {
|
|
142
118
|
this.renderItem = this.renderItem ?? this.createRenderItem();
|
|
143
119
|
this.renderItem.rerender();
|
|
144
120
|
}
|
|
121
|
+
hideTooltip() {
|
|
122
|
+
this.show = false;
|
|
123
|
+
this.renderTooltip();
|
|
124
|
+
}
|
|
125
|
+
showTooltip() {
|
|
126
|
+
this.show = true;
|
|
127
|
+
this.renderTooltip();
|
|
128
|
+
}
|
|
145
129
|
onOpenChange = (open, _e, reason) => {
|
|
146
130
|
if (open)
|
|
147
131
|
return;
|
|
@@ -149,10 +133,10 @@ class SelectionTooltip {
|
|
|
149
133
|
this.cancelPopup();
|
|
150
134
|
}
|
|
151
135
|
else {
|
|
152
|
-
this.
|
|
136
|
+
this.onOutsideClick();
|
|
153
137
|
}
|
|
154
138
|
};
|
|
155
|
-
|
|
139
|
+
onOutsideClick = () => {
|
|
156
140
|
this.removePlaceholderLink(this.textNode);
|
|
157
141
|
this.hideTooltip();
|
|
158
142
|
this.manualHidden = true;
|
|
@@ -193,7 +177,7 @@ class SelectionTooltip {
|
|
|
193
177
|
}
|
|
194
178
|
}
|
|
195
179
|
createRenderItem() {
|
|
196
|
-
return getReactRendererFromState(this.view.state).createItem('link-tooltip', () => (_jsx(ErrorLoggerBoundary, { children: _jsx(SelectionTooltipView, {
|
|
180
|
+
return getReactRendererFromState(this.view.state).createItem('link-tooltip', () => (_jsx(ErrorLoggerBoundary, { children: _jsx(SelectionTooltipView, { show: this.show, domElem: this.textNodeRef, onCancel: this.cancelPopup.bind(this), attrs: this.getMarkAttrs(), onChange: this.changeAttrs.bind(this), onOpenChange: this.onOpenChange }) })));
|
|
197
181
|
}
|
|
198
182
|
}
|
|
199
183
|
const SelectionTooltipView = (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../../../src","sources":["extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAuC,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAmB,MAAM,EAAmB,aAAa,EAAC,MAA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,IAAI,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GACpB,IAVG,IAAI,CAWL,CACX,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';\nimport {keydownHandler} from 'prosemirror-keymap';\nimport type {Node} from 'prosemirror-model';\nimport {type EditorState, Plugin, type PluginView, TextSelection} from 'prosemirror-state';\n// @ts-ignore // TODO: fix cjs build\nimport {findChildrenByMark, findParentNode} from 'prosemirror-utils';\nimport {Decoration, DecorationSet, type EditorView} from 'prosemirror-view';\n\nimport type {ExtensionDeps} from '../../../../../core';\nimport {ErrorLoggerBoundary} from '../../../../../react-utils/ErrorBoundary';\nimport {findMark, isMarkActive} from '../../../../../utils/marks';\nimport {type RendererItem, getReactRendererFromState} from '../../../../behavior/ReactRenderer';\nimport {LinkAttr, linkType, normalizeUrlFactory} from '../../../index';\n\nimport {LinkForm} from './TooltipView';\n\nconst className = 'pm-link-focus-deco';\nconst placement: PopupPlacement = ['bottom-start', 'bottom-end', 'top-start', 'top-end'];\n\nfunction getTextNode(state: EditorState) {\n if (\n !(state.selection instanceof TextSelection) ||\n !state.selection.empty ||\n !isMarkActive(state, linkType(state.schema))\n )\n return null;\n\n const parent = findParentNode(Boolean)(state.selection);\n\n if (!parent) {\n return null;\n }\n\n const textNodes = findChildrenByMark(parent?.node, linkType(state.schema));\n\n const textNode = textNodes.find((n: {node: Node; pos: number}) => {\n const start = n.pos + parent.pos;\n const end = start + n.node.nodeSize;\n return start <= state.selection.from && end >= state.selection.from;\n })!;\n\n if (!textNode) return null;\n\n const absolutePos = textNode.pos + parent.pos + 1;\n\n return {\n ...textNode,\n absolutePos,\n parent,\n from: absolutePos,\n to: absolutePos + textNode.node.nodeSize,\n };\n}\n\nexport const linkTooltipPlugin = (deps: ExtensionDeps) => {\n let viewTooltip: SelectionTooltip | null = null;\n return new Plugin({\n view(view) {\n viewTooltip = new SelectionTooltip(view, deps);\n return viewTooltip;\n },\n props: {\n handleKeyDown: keydownHandler({\n Escape: () => viewTooltip?.onEscapeDown() ?? false,\n }),\n decorations(state) {\n const textNode = getTextNode(state);\n if (!textNode) return DecorationSet.empty;\n\n const {from, to} = textNode;\n return DecorationSet.create(state.doc, [\n Decoration.inline(from, to, {\n class: `pm-node-selected ${className}`,\n }),\n ]);\n },\n },\n });\n};\n\nclass SelectionTooltip implements PluginView {\n private normalizeUrl;\n\n private view: EditorView;\n\n private textNode?: ReturnType<typeof getTextNode>;\n private textNodeRef: HTMLElement | undefined;\n\n private isTooltipOpen = false;\n private manualHidden = false;\n\n private renderItem?: RendererItem;\n private selectionTooltipProps: SelectionTooltipViewBaseProps = {show: false};\n\n constructor(view: EditorView, deps: ExtensionDeps) {\n this.normalizeUrl = normalizeUrlFactory(deps);\n\n this.view = view;\n\n this.update(view, null);\n }\n\n update(view: EditorView, prevState?: EditorState | null) {\n if (!view.dom.parentNode) {\n this.hideTooltip();\n return;\n }\n\n const {state} = view;\n\n if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection))\n return;\n\n this.textNode = getTextNode(view.state);\n\n const prevRef = this.textNodeRef;\n this.updateTextNodeRef();\n\n if (!this.textNode || !this.textNodeRef) {\n this.hideTooltip();\n return;\n }\n\n if (prevRef !== this.textNodeRef) {\n this.manualHidden = false;\n }\n\n if (this.manualHidden) {\n this.hideTooltip();\n } else {\n this.renderTooltip({\n show: true,\n domElem: this.textNodeRef,\n onCancel: () => this.cancelPopup(),\n attrs: this.getMarkAttrs(),\n onChange: this.changeAttrs.bind(this),\n onOpenChange: this.onOpenChange,\n });\n }\n }\n\n destroy() {\n this.isTooltipOpen = false;\n this.selectionTooltipProps = {show: false};\n this.renderItem?.remove();\n this.renderItem = undefined;\n }\n\n onEscapeDown(): boolean {\n if (this.isTooltipOpen) {\n this.removePlaceholderLink(this.textNode);\n this.manualHidden = true;\n this.hideTooltip();\n return true;\n }\n\n return false;\n }\n\n private updateTextNodeRef() {\n const decoElem = this.view.dom.getElementsByClassName(className)[0];\n this.textNodeRef = decoElem as HTMLElement | undefined;\n }\n\n private getMarkAttrs() {\n const {textNode} = this;\n const linkMark = textNode && findMark(textNode.node, linkType(this.view.state.schema));\n return linkMark?.attrs;\n }\n\n private hideTooltip() {\n this.renderTooltip({show: false});\n }\n\n private renderTooltip(props: SelectionTooltipViewBaseProps) {\n this.isTooltipOpen = props.show;\n this.selectionTooltipProps = props;\n this.renderItem = this.renderItem ?? this.createRenderItem();\n this.renderItem.rerender();\n }\n\n private onOpenChange: NonNullable<PopupProps['onOpenChange']> = (open, _e, reason) => {\n if (open) return;\n if (reason === 'escape-key') {\n this.cancelPopup();\n } else {\n this.onOutisdeClick();\n }\n };\n\n private onOutisdeClick = () => {\n this.removePlaceholderLink(this.textNode);\n this.hideTooltip();\n this.manualHidden = true;\n };\n\n private cancelPopup() {\n this.removePlaceholderLink(this.textNode, {returnSelection: true});\n this.manualHidden = true;\n this.hideTooltip();\n this.view.focus();\n }\n\n private removePlaceholderLink(\n textNode?: ReturnType<typeof getTextNode>,\n opts?: {returnSelection?: boolean},\n ) {\n if (textNode) {\n const {view} = this;\n const {state} = view;\n const attrs = findMark(textNode.node, linkType(state.schema))?.attrs;\n if (attrs?.[LinkAttr.IsPlaceholder]) {\n const {from, to} = textNode;\n let tr = state.tr.removeMark(from, to, linkType(state.schema));\n if (opts?.returnSelection) {\n tr = tr.setSelection(TextSelection.create(tr.doc, from, to));\n }\n view.dispatch(tr);\n }\n }\n }\n\n private changeAttrs({href}: {href: string}) {\n const {view, textNode} = this;\n if (!textNode) return;\n\n const normalizeResult = this.normalizeUrl(href);\n if (normalizeResult) {\n const {url} = normalizeResult;\n const {from, to} = textNode;\n\n const tr = view.state.tr;\n tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(to)));\n tr.addMark(from, to, linkType(view.state.schema).create({href: url}));\n view.dispatch(tr);\n }\n }\n\n private createRenderItem() {\n return getReactRendererFromState(this.view.state).createItem('link-tooltip', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltipView {...this.selectionTooltipProps} />\n </ErrorLoggerBoundary>\n ));\n }\n}\ntype SelectionTooltipViewBaseProps<T = boolean> = T extends false\n ? {\n show: T;\n }\n : {\n show: T;\n domElem: HTMLElement;\n onCancel: () => void;\n onChange: (opts: {href: string}) => void;\n attrs?: {[LinkAttr.Href]?: string; [LinkAttr.IsPlaceholder]?: boolean};\n } & Pick<PopupProps, 'onOpenChange'>;\n\ntype SelectionTooltipViewProps = SelectionTooltipViewBaseProps;\n\nconst SelectionTooltipView: React.FC<SelectionTooltipViewProps> = (props) => {\n const {show} = props;\n\n if (!show) return null;\n\n const {domElem, onChange, onCancel, onOpenChange, attrs = {}} = props;\n const href = attrs[LinkAttr.Href];\n const autoFocus = attrs[LinkAttr.IsPlaceholder];\n\n return (\n <Popup\n open\n key={href}\n anchorElement={domElem}\n placement={placement}\n onOpenChange={onOpenChange}\n >\n <LinkForm\n href={href ?? ''}\n autoFocus={autoFocus}\n onChange={onChange}\n onCancel={onCancel}\n />\n </Popup>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../../src","sources":["extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAuC,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAmB,MAAM,EAAmB,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAC3F,oCAAoC;AACpC,OAAO,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAC,UAAU,EAAE,aAAa,EAAkB,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAC,mBAAmB,EAAC,oDAAiD;AAC7E,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,sCAAmC;AAClE,OAAO,E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AAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,GAAG,EAAE,EAAC,GAAG,KAAK,CAAC;IACtE,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEhD,OAAO,CACH,KAAC,KAAK,IACF,IAAI,QAEJ,aAAa,EAAE,OAAO,EACtB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,YAE1B,KAAC,QAAQ,IACL,IAAI,EAAE,IAAI,IAAI,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GACpB,IAVG,IAAI,CAWL,CACX,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';\nimport {keydownHandler} from 'prosemirror-keymap';\nimport type {Node} from 'prosemirror-model';\nimport {type EditorState, Plugin, type PluginView, TextSelection} from 'prosemirror-state';\n// @ts-ignore // TODO: fix cjs build\nimport {findChildrenByMark, findParentNode} from 'prosemirror-utils';\nimport {Decoration, DecorationSet, type EditorView} from 'prosemirror-view';\n\nimport type {ExtensionDeps} from '../../../../../core';\nimport {ErrorLoggerBoundary} from '../../../../../react-utils/ErrorBoundary';\nimport {findMark, isMarkActive} from '../../../../../utils/marks';\nimport {type RendererItem, getReactRendererFromState} from '../../../../behavior/ReactRenderer';\nimport {LinkAttr, linkType, normalizeUrlFactory} from '../../../index';\n\nimport {LinkForm} from './TooltipView';\n\nconst className = 'pm-link-focus-deco';\nconst placement: PopupPlacement = ['bottom-start', 'bottom-end', 'top-start', 'top-end'];\n\nfunction getTextNode(state: EditorState) {\n if (\n !(state.selection instanceof TextSelection) ||\n !state.selection.empty ||\n !isMarkActive(state, linkType(state.schema))\n )\n return null;\n\n const parent = findParentNode(Boolean)(state.selection);\n\n if (!parent) {\n return null;\n }\n\n const textNodes = findChildrenByMark(parent?.node, linkType(state.schema));\n\n const textNode = textNodes.find((n: {node: Node; pos: number}) => {\n const start = n.pos + parent.pos;\n const end = start + n.node.nodeSize;\n return start <= state.selection.from && end >= state.selection.from;\n })!;\n\n if (!textNode) return null;\n\n const absolutePos = textNode.pos + parent.pos + 1;\n\n return {\n ...textNode,\n absolutePos,\n parent,\n from: absolutePos,\n to: absolutePos + textNode.node.nodeSize,\n };\n}\n\nexport const linkTooltipPlugin = (deps: ExtensionDeps) => {\n let viewTooltip: SelectionTooltip | null = null;\n return new Plugin({\n view(view) {\n viewTooltip = new SelectionTooltip(view, deps);\n return viewTooltip;\n },\n props: {\n handleKeyDown: keydownHandler({\n Escape: () => viewTooltip?.onEscapeDown() ?? false,\n }),\n decorations(state) {\n const textNode = getTextNode(state);\n if (!textNode) return DecorationSet.empty;\n\n const {from, to} = textNode;\n return DecorationSet.create(state.doc, [\n Decoration.inline(from, to, {\n class: `pm-node-selected ${className}`,\n }),\n ]);\n },\n },\n });\n};\n\nclass SelectionTooltip implements PluginView {\n private normalizeUrl;\n\n private view: EditorView;\n private show: boolean;\n\n private textNode?: ReturnType<typeof getTextNode>;\n private textNodeRef: HTMLElement | undefined;\n\n private manualHidden = false;\n\n private renderItem?: RendererItem;\n\n constructor(view: EditorView, deps: ExtensionDeps) {\n this.normalizeUrl = normalizeUrlFactory(deps);\n\n this.view = view;\n this.show = false;\n\n this.update(view);\n }\n\n update(view: EditorView) {\n if (!view.dom.parentNode) {\n this.hideTooltip();\n return;\n }\n\n const {state} = view;\n\n this.textNode = getTextNode(state);\n\n const prevRef = this.textNodeRef;\n this.textNodeRef = this.view.dom.getElementsByClassName(className)[0] as\n | HTMLElement\n | undefined;\n\n if (prevRef !== this.textNodeRef) {\n this.manualHidden = false;\n }\n\n if (this.manualHidden || !this.textNode || !this.textNodeRef) {\n this.hideTooltip();\n return;\n }\n\n this.showTooltip();\n }\n\n destroy() {\n this.show = false;\n this.renderItem?.remove();\n this.renderItem = undefined;\n }\n\n onEscapeDown(): boolean {\n if (this.show) {\n this.removePlaceholderLink(this.textNode);\n this.manualHidden = true;\n this.hideTooltip();\n return true;\n }\n\n return false;\n }\n\n private getMarkAttrs() {\n const {textNode} = this;\n const linkMark = textNode && findMark(textNode.node, linkType(this.view.state.schema));\n return linkMark?.attrs;\n }\n\n private renderTooltip() {\n this.renderItem = this.renderItem ?? this.createRenderItem();\n this.renderItem.rerender();\n }\n\n private hideTooltip() {\n this.show = false;\n this.renderTooltip();\n }\n\n private showTooltip() {\n this.show = true;\n this.renderTooltip();\n }\n\n private onOpenChange: NonNullable<PopupProps['onOpenChange']> = (open, _e, reason) => {\n if (open) return;\n if (reason === 'escape-key') {\n this.cancelPopup();\n } else {\n this.onOutsideClick();\n }\n };\n\n private onOutsideClick = () => {\n this.removePlaceholderLink(this.textNode);\n this.hideTooltip();\n this.manualHidden = true;\n };\n\n private cancelPopup() {\n this.removePlaceholderLink(this.textNode, {returnSelection: true});\n this.manualHidden = true;\n this.hideTooltip();\n this.view.focus();\n }\n\n private removePlaceholderLink(\n textNode?: ReturnType<typeof getTextNode>,\n opts?: {returnSelection?: boolean},\n ) {\n if (textNode) {\n const {view} = this;\n const {state} = view;\n const attrs = findMark(textNode.node, linkType(state.schema))?.attrs;\n if (attrs?.[LinkAttr.IsPlaceholder]) {\n const {from, to} = textNode;\n let tr = state.tr.removeMark(from, to, linkType(state.schema));\n if (opts?.returnSelection) {\n tr = tr.setSelection(TextSelection.create(tr.doc, from, to));\n }\n view.dispatch(tr);\n }\n }\n }\n\n private changeAttrs({href}: {href: string}) {\n const {view, textNode} = this;\n if (!textNode) return;\n\n const normalizeResult = this.normalizeUrl(href);\n if (normalizeResult) {\n const {url} = normalizeResult;\n const {from, to} = textNode;\n\n const tr = view.state.tr;\n tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(to)));\n tr.addMark(from, to, linkType(view.state.schema).create({href: url}));\n view.dispatch(tr);\n }\n }\n\n private createRenderItem() {\n return getReactRendererFromState(this.view.state).createItem('link-tooltip', () => (\n <ErrorLoggerBoundary>\n <SelectionTooltipView\n show={this.show}\n domElem={this.textNodeRef as HTMLElement}\n onCancel={this.cancelPopup.bind(this)}\n attrs={this.getMarkAttrs()}\n onChange={this.changeAttrs.bind(this)}\n onOpenChange={this.onOpenChange}\n />\n </ErrorLoggerBoundary>\n ));\n }\n}\ntype SelectionTooltipViewBaseProps<T = boolean> = T extends false\n ? {\n show: T;\n }\n : {\n show: T;\n domElem: HTMLElement;\n onCancel: () => void;\n onChange: (opts: {href: string}) => void;\n attrs?: {[LinkAttr.Href]?: string; [LinkAttr.IsPlaceholder]?: boolean};\n } & Pick<PopupProps, 'onOpenChange'>;\n\ntype SelectionTooltipViewProps = SelectionTooltipViewBaseProps;\n\nconst SelectionTooltipView: React.FC<SelectionTooltipViewProps> = (props) => {\n const {show} = props;\n\n if (!show) return null;\n\n const {domElem, onChange, onCancel, onOpenChange, attrs = {}} = props;\n const href = attrs[LinkAttr.Href];\n const autoFocus = attrs[LinkAttr.IsPlaceholder];\n\n return (\n <Popup\n open\n key={href}\n anchorElement={domElem}\n placement={placement}\n onOpenChange={onOpenChange}\n >\n <LinkForm\n href={href ?? ''}\n autoFocus={autoFocus}\n onChange={onChange}\n onCancel={onCancel}\n />\n </Popup>\n );\n};\n"]}
|
|
@@ -17,6 +17,10 @@ export type ToolbarItemData<E> = QAProps & {
|
|
|
17
17
|
hint?: string | (() => string);
|
|
18
18
|
hotkey?: HotkeyProps['value'];
|
|
19
19
|
preview?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Alternative IDs that can be used to find this command
|
|
22
|
+
*/
|
|
23
|
+
aliases?: string[];
|
|
20
24
|
/**
|
|
21
25
|
* Show hint when _isEnable()_ returns false
|
|
22
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["toolbar/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["toolbar/types.ts"],"names":[],"mappings":"AA2CA,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACvB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,kDAAkD;IAClD,uCAAoB,CAAA;IACpB,kDAAkD;IAClD,4CAAyB,CAAA;IACzB,iDAA8B,CAAA;AAClC,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B","sourcesContent":["import type {HotkeyProps, IconProps, QAProps} from '@gravity-ui/uikit';\n\nimport type {ClassNameProps} from '../classname';\n\nexport type ToolbarBaseProps<E> = ClassNameProps &\n QAProps & {\n editor: E;\n focus(): void;\n onClick?(id: string, attrs?: {[key: string]: any}): void;\n };\n\nexport type ToolbarIconData = Pick<IconProps, 'data' | 'size'>;\nexport type ToolbarGroupData<E> = Array<ToolbarGroupItemData<E>>;\nexport type ToolbarData<E> = ToolbarGroupData<E>[];\n\nexport type ToolbarItemData<E> = QAProps & {\n id: string;\n icon: ToolbarIconData;\n title: string | (() => string);\n hint?: string | (() => string);\n hotkey?: HotkeyProps['value'];\n preview?: React.ReactNode;\n /**\n * Alternative IDs that can be used to find this command\n */\n aliases?: string[];\n /**\n * Show hint when _isEnable()_ returns false\n *\n * `false` – don't show hint;\n *\n * `true` – show default hint;\n *\n * `string` or `() => string` – show hint with custom message.\n *\n * @default true\n */\n hintWhenDisabled?: boolean | string | (() => string);\n exec(editor: E): void;\n isActive(editor: E): boolean;\n isEnable(editor: E): boolean;\n};\n\nexport enum ToolbarDataType {\n SingleButton = 's-button',\n ListButton = 'list-b',\n ButtonPopup = 'b-popup',\n /** @deprecated Use ReactComponent type instead */\n ReactNode = 'r-node',\n /** @deprecated Use ReactComponent type instead */\n ReactNodeFn = 'r-node-fn',\n ReactComponent = 'r-component',\n}\n\nexport type ToolbarGroupItemData<E> =\n | ToolbarSingleItemData<E>\n | ToolbarButtonPopupData<E>\n | ToolbarListItemData<E>\n | ToolbarReactNodeData\n | ToolbarReactNodeFnData<E>\n | ToolbarReactComponentData<E>;\n\nexport type ToolbarSingleItemData<E> = ToolbarItemData<E> & {\n id: string;\n type: ToolbarDataType.SingleButton;\n className?: string;\n};\n\nexport type ToolbarListItemData<E> = ToolbarListButtonData<E> & {\n id: string;\n type: ToolbarDataType.ListButton;\n className?: string;\n};\n\nexport type ToolbarReactComponentData<E> = {\n id: string;\n type: ToolbarDataType.ReactComponent;\n width: number;\n className?: string;\n component: React.ComponentType<ToolbarBaseProps<E>>;\n props?: object;\n};\n\nexport type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {\n /** not used, may be an empty function */\n exec: ToolbarItemData<E>['exec'];\n type: ToolbarDataType.ButtonPopup;\n renderPopup: (\n props: ToolbarBaseProps<E> & {hide: () => void; anchorElement: HTMLElement | null},\n ) => React.ReactNode;\n className?: string;\n};\n\nexport type ToolbarListButtonItemData<E> = ToolbarItemData<E> & {\n doNotActivateList?: boolean;\n};\n\nexport type ToolbarListButtonData<E> = {\n icon: ToolbarIconData;\n title: string | (() => string);\n withArrow?: boolean;\n data: ToolbarListButtonItemData<E>[];\n alwaysActive?: boolean;\n hideDisabled?: boolean;\n /** When state changes to active, replace default icon with icon of first active item */\n replaceActiveIcon?: boolean;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n * */\nexport type ToolbarReactNodeData = {\n id: string;\n type: ToolbarDataType.ReactNode;\n width: number;\n content: React.ReactNode;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n * */\nexport type ToolbarReactNodeFnData<E> = {\n id: string;\n type: ToolbarDataType.ReactNodeFn;\n width: number;\n content: (e: E) => React.ReactNode;\n};\n"]}
|
package/build/esm/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** During build process, the current version will be injected here */
|
|
2
|
-
export const VERSION = typeof '15.
|
|
2
|
+
export const VERSION = typeof '15.17.0' !== 'undefined' ? '15.17.0' : 'unknown';
|
|
3
3
|
//# sourceMappingURL=version.js.map
|
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.17.0' !== 'undefined' ? '15.17.0' : 'unknown';\n"]}
|