@gravity-ui/markdown-editor 15.17.0 → 15.19.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/Editor.d.ts +1 -1
- package/build/cjs/bundle/Editor.js +6 -1
- package/build/cjs/bundle/Editor.js.map +1 -1
- package/build/cjs/bundle/MarkdownEditorView.js +3 -1
- package/build/cjs/bundle/MarkdownEditorView.js.map +1 -1
- package/build/cjs/bundle/MarkupEditorView.d.ts +2 -1
- package/build/cjs/bundle/MarkupEditorView.js +2 -2
- package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
- package/build/cjs/bundle/ToolbarView.d.ts +3 -2
- package/build/cjs/bundle/ToolbarView.js +3 -2
- package/build/cjs/bundle/ToolbarView.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorView.d.ts +2 -1
- package/build/cjs/bundle/WysiwygEditorView.js +2 -2
- package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
- package/build/cjs/bundle/settings/index.d.ts +1 -0
- package/build/cjs/bundle/settings/index.js +3 -3
- package/build/cjs/bundle/settings/index.js.map +1 -1
- package/build/cjs/bundle/types.d.ts +2 -0
- package/build/cjs/bundle/types.js.map +1 -1
- package/build/cjs/bundle/useMarkdownEditor.js +2 -1
- package/build/cjs/bundle/useMarkdownEditor.js.map +1 -1
- package/build/cjs/bundle/wysiwyg-preset.d.ts +1 -0
- package/build/cjs/bundle/wysiwyg-preset.js +1 -1
- package/build/cjs/bundle/wysiwyg-preset.js.map +1 -1
- package/build/cjs/extensions/behavior/Clipboard/code.js +8 -3
- package/build/cjs/extensions/behavior/Clipboard/code.js.map +1 -1
- package/build/cjs/extensions/behavior/Resizable/Resizable.d.ts +2 -1
- package/build/cjs/extensions/behavior/Resizable/Resizable.js.map +1 -1
- package/build/cjs/extensions/behavior/index.d.ts +1 -0
- package/build/cjs/extensions/behavior/index.js +6 -4
- package/build/cjs/extensions/behavior/index.js.map +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +13 -11
- package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/handle-paste.d.ts +1 -1
- package/build/cjs/extensions/markdown/CodeBlock/handle-paste.js +21 -5
- package/build/cjs/extensions/markdown/CodeBlock/handle-paste.js.map +1 -1
- package/build/cjs/i18n/gallery/en.json +5 -0
- package/build/cjs/i18n/gallery/index.d.ts +7 -0
- package/build/cjs/i18n/gallery/index.js +10 -0
- package/build/cjs/i18n/gallery/index.js.map +1 -0
- package/build/cjs/i18n/gallery/ru.json +5 -0
- package/build/cjs/i18n/placeholder/en.json +1 -0
- package/build/cjs/i18n/placeholder/index.d.ts +2 -1
- package/build/cjs/i18n/placeholder/ru.json +1 -0
- package/build/cjs/toolbar/FlexToolbar.js +9 -3
- package/build/cjs/toolbar/FlexToolbar.js.map +1 -1
- package/build/cjs/toolbar/PreviewTooltip.d.ts +1 -0
- package/build/cjs/toolbar/PreviewTooltip.js +3 -3
- package/build/cjs/toolbar/PreviewTooltip.js.map +1 -1
- package/build/cjs/toolbar/Toolbar.css +3 -0
- package/build/cjs/toolbar/Toolbar.d.ts +1 -1
- package/build/cjs/toolbar/Toolbar.js +3 -3
- package/build/cjs/toolbar/Toolbar.js.map +1 -1
- package/build/cjs/toolbar/ToolbarButton.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarButton.js +2 -2
- package/build/cjs/toolbar/ToolbarButton.js.map +1 -1
- package/build/cjs/toolbar/ToolbarGroup.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarGroup.js +4 -4
- package/build/cjs/toolbar/ToolbarGroup.js.map +1 -1
- package/build/cjs/toolbar/ToolbarListButton.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarListButton.js +4 -4
- package/build/cjs/toolbar/ToolbarListButton.js.map +1 -1
- package/build/cjs/toolbar/types.d.ts +5 -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/cjs/view/hooks/useFilesGallery/types.d.ts +6 -0
- package/build/cjs/view/hooks/useFilesGallery/types.js.map +1 -1
- package/build/cjs/view/hooks/useFilesGallery/useFilesGallery.d.ts +2 -2
- package/build/cjs/view/hooks/useFilesGallery/useFilesGallery.js +39 -4
- package/build/cjs/view/hooks/useFilesGallery/useFilesGallery.js.map +1 -1
- package/build/esm/bundle/Editor.d.ts +1 -1
- package/build/esm/bundle/Editor.js +6 -1
- package/build/esm/bundle/Editor.js.map +1 -1
- package/build/esm/bundle/MarkdownEditorView.js +3 -1
- package/build/esm/bundle/MarkdownEditorView.js.map +1 -1
- package/build/esm/bundle/MarkupEditorView.d.ts +2 -1
- package/build/esm/bundle/MarkupEditorView.js +2 -2
- package/build/esm/bundle/MarkupEditorView.js.map +1 -1
- package/build/esm/bundle/ToolbarView.d.ts +3 -2
- package/build/esm/bundle/ToolbarView.js +3 -2
- package/build/esm/bundle/ToolbarView.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorView.d.ts +2 -1
- package/build/esm/bundle/WysiwygEditorView.js +2 -2
- package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
- package/build/esm/bundle/settings/index.d.ts +1 -0
- package/build/esm/bundle/settings/index.js +3 -3
- package/build/esm/bundle/settings/index.js.map +1 -1
- package/build/esm/bundle/types.d.ts +2 -0
- package/build/esm/bundle/types.js.map +1 -1
- package/build/esm/bundle/useMarkdownEditor.js +2 -1
- package/build/esm/bundle/useMarkdownEditor.js.map +1 -1
- package/build/esm/bundle/wysiwyg-preset.d.ts +1 -0
- package/build/esm/bundle/wysiwyg-preset.js +1 -1
- package/build/esm/bundle/wysiwyg-preset.js.map +1 -1
- package/build/esm/extensions/behavior/Clipboard/code.js +8 -3
- package/build/esm/extensions/behavior/Clipboard/code.js.map +1 -1
- package/build/esm/extensions/behavior/Resizable/Resizable.d.ts +2 -1
- package/build/esm/extensions/behavior/Resizable/Resizable.js.map +1 -1
- package/build/esm/extensions/behavior/index.d.ts +1 -0
- package/build/esm/extensions/behavior/index.js +6 -4
- package/build/esm/extensions/behavior/index.js.map +1 -1
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +13 -11
- package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
- package/build/esm/extensions/markdown/CodeBlock/handle-paste.d.ts +1 -1
- package/build/esm/extensions/markdown/CodeBlock/handle-paste.js +20 -5
- package/build/esm/extensions/markdown/CodeBlock/handle-paste.js.map +1 -1
- package/build/esm/i18n/gallery/en.json +5 -0
- package/build/esm/i18n/gallery/index.d.ts +7 -0
- package/build/esm/i18n/gallery/index.js +6 -0
- package/build/esm/i18n/gallery/index.js.map +1 -0
- package/build/esm/i18n/gallery/ru.json +5 -0
- package/build/esm/i18n/placeholder/en.json +1 -0
- package/build/esm/i18n/placeholder/index.d.ts +2 -1
- package/build/esm/i18n/placeholder/ru.json +1 -0
- package/build/esm/toolbar/FlexToolbar.js +9 -3
- package/build/esm/toolbar/FlexToolbar.js.map +1 -1
- package/build/esm/toolbar/PreviewTooltip.d.ts +1 -0
- package/build/esm/toolbar/PreviewTooltip.js +3 -3
- package/build/esm/toolbar/PreviewTooltip.js.map +1 -1
- package/build/esm/toolbar/Toolbar.css +3 -0
- package/build/esm/toolbar/Toolbar.d.ts +1 -1
- package/build/esm/toolbar/Toolbar.js +3 -3
- package/build/esm/toolbar/Toolbar.js.map +1 -1
- package/build/esm/toolbar/ToolbarButton.d.ts +1 -1
- package/build/esm/toolbar/ToolbarButton.js +2 -2
- package/build/esm/toolbar/ToolbarButton.js.map +1 -1
- package/build/esm/toolbar/ToolbarGroup.d.ts +1 -1
- package/build/esm/toolbar/ToolbarGroup.js +4 -4
- package/build/esm/toolbar/ToolbarGroup.js.map +1 -1
- package/build/esm/toolbar/ToolbarListButton.d.ts +1 -1
- package/build/esm/toolbar/ToolbarListButton.js +4 -4
- package/build/esm/toolbar/ToolbarListButton.js.map +1 -1
- package/build/esm/toolbar/types.d.ts +5 -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/build/esm/view/hooks/useFilesGallery/types.d.ts +6 -0
- package/build/esm/view/hooks/useFilesGallery/types.js.map +1 -1
- package/build/esm/view/hooks/useFilesGallery/useFilesGallery.d.ts +2 -2
- package/build/esm/view/hooks/useFilesGallery/useFilesGallery.js +40 -5
- package/build/esm/view/hooks/useFilesGallery/useFilesGallery.js.map +1 -1
- package/build/styles.css +3 -0
- package/package.json +4 -4
|
@@ -37,17 +37,19 @@ export const CodeBlockHighlight = (builder, opts) => {
|
|
|
37
37
|
key,
|
|
38
38
|
state: {
|
|
39
39
|
init: (_, state) => {
|
|
40
|
-
loadModules().then(() => {
|
|
41
|
-
modulesLoaded =
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
loadModules().then((loaded) => {
|
|
41
|
+
modulesLoaded = loaded;
|
|
42
|
+
if (modulesLoaded) {
|
|
43
|
+
for (const lang of Object.keys(langs)) {
|
|
44
|
+
const defs = langs[lang](hljs);
|
|
45
|
+
selectItems.push({
|
|
46
|
+
value: lang,
|
|
47
|
+
content: defs.name || capitalize(lang),
|
|
48
|
+
});
|
|
49
|
+
if (defs.aliases) {
|
|
50
|
+
for (const alias of defs.aliases) {
|
|
51
|
+
mapping[alias] = lang;
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|
package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockHighlight.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/CodeBlock/CodeBlockHighlight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AC;gBAC9B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;oBACjB,KAAK,CAAC,IAAI,CACN,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE;wBACxB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;qBAC3B,CAAC,CACL,CAAC;gBACN,CAAC;gBACD,IAAI,GAAG,EAAE,CAAC;YACd,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC,CAAC;AAEF,SAAS,UAAU,CACf,KAAuB,EACvB,YAA+B,EAAE;IAEjC,OAAO,KAAK;SACP,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACV,IAAI,OAAO,GAAG,SAAS,CAAC;QACxB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAE,IAAI,CAAC,UAAU,CAAC,SAAsB,IAAI,EAAE,CAAC,CAAC;YACxE,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACvE,OAAO;SACV,CAAC;IACN,CAAC,CAAC;SACD,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,IAAU;IAC7B,mBAAmB;IACnB,OAAO,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;AACxE,CAAC","sourcesContent":["import type {Options} from '@diplodoc/transform';\n// importing only type, because lowlight and highlight.js is optional deps\nimport type HLJS from 'highlight.js/lib/core';\nimport type {createLowlight} from 'lowlight' with {'resolution-mode': 'import'};\nimport type {Node} from 'prosemirror-model';\nimport {Plugin, PluginKey} from 'prosemirror-state';\nimport type {Step} from 'prosemirror-transform';\n// @ts-ignore // TODO: fix cjs build\nimport {findChildrenByType} from 'prosemirror-utils';\nimport {Decoration, DecorationSet} from 'prosemirror-view';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {capitalize} from '../../../../lodash';\nimport {globalLogger} from '../../../../logger';\nimport {CodeBlockNodeAttr, codeBlockNodeName, codeBlockType} from '../CodeBlockSpecs';\n\nimport {codeLangSelectTooltipViewCreator} from './TooltipPlugin';\n\nexport type HighlightLangMap = Options['highlightLangs'];\n\ntype Lowlight = ReturnType<typeof createLowlight>;\ntype Root = ReturnType<Lowlight['highlight']>;\n\ntype LangSelectItem = {\n value: string;\n content: string;\n};\n\nconst key = new PluginKey<DecorationSet>('code_block_highlight');\n\nexport type CodeBlockHighlightOptions = {\n langs?: HighlightLangMap;\n};\n\nexport const CodeBlockHighlight: ExtensionAuto<CodeBlockHighlightOptions> = (builder, opts) => {\n let langs: NonNullable<HighlightLangMap>;\n let lowlight: Lowlight;\n let hljs: typeof HLJS;\n\n const loadModules = async () => {\n try {\n hljs = (await import('highlight.js/lib/core')).default;\n const low = await import('lowlight');\n\n const all: HighlightLangMap = low.all;\n const create: typeof createLowlight = low.createLowlight;\n langs = {...all, ...opts.langs};\n lowlight = create(langs);\n return true;\n } catch (e) {\n globalLogger.info('Skip code_block highlighting');\n builder.logger.log('Skip code_block highlighting');\n return false;\n }\n };\n\n builder.addPlugin(() => {\n let modulesLoaded = false;\n\n const selectItems: LangSelectItem[] = [];\n const mapping: Record<string, string> = {};\n\n // TODO: add TAB key handler\n // TODO: Remove constant selection of block\n return new Plugin<DecorationSet>({\n key,\n state: {\n init: (_, state) => {\n loadModules().then(() => {\n modulesLoaded = true;\n\n for (const lang of Object.keys(langs)) {\n const defs = langs[lang](hljs);\n selectItems.push({\n value: lang,\n content: defs.name || capitalize(lang),\n });\n if (defs.aliases) {\n for (const alias of defs.aliases) {\n mapping[alias] = lang;\n }\n }\n }\n });\n return getDecorations(state.doc);\n },\n apply: (tr, decos, oldState, newState) => {\n if (!modulesLoaded) {\n return DecorationSet.empty;\n }\n\n if (tr.docChanged) {\n const oldNodeName = oldState.selection.$head.parent.type.name;\n const newNodeName = newState.selection.$head.parent.type.name;\n\n // Apply decorations if:\n if (\n oldNodeName === codeBlockNodeName ||\n newNodeName === codeBlockNodeName\n ) {\n // selection includes codeblock node,\n return getDecorations(tr.doc);\n } else {\n const oldNodes = findChildrenByType(\n oldState.doc,\n codeBlockType(oldState.schema),\n );\n const newNodes = findChildrenByType(\n newState.doc,\n codeBlockType(newState.schema),\n );\n if (\n // OR transaction adds/removes codeblock nodes,\n newNodes.length !== oldNodes.length ||\n // OR transaction has changes that completely encapsulate a node\n // (for example, a transaction that affects the entire document).\n // Such transactions can happen during collab syncing via y-prosemirror, for example.\n tr.steps.some((step) => {\n return (\n stepHasFromTo(step) &&\n oldNodes.some(\n (node: {node: Node; pos: number}) =>\n node.pos >= step.from &&\n node.pos + node.node.nodeSize <= step.to,\n )\n );\n })\n ) {\n return getDecorations(tr.doc);\n }\n }\n }\n return decos.map(tr.mapping, tr.doc);\n },\n },\n view: (view) => codeLangSelectTooltipViewCreator(view, selectItems, mapping),\n props: {\n decorations: (state) => {\n return key.getState(state);\n },\n nodeViews: {\n [codeBlockNodeName]: (node) => {\n let prevLang = node.attrs[CodeBlockNodeAttr.Lang];\n\n const dom = document.createElement('pre');\n\n const contentDOM = document.createElement('code');\n contentDOM.classList.add('hljs');\n\n if (prevLang) {\n dom.setAttribute(CodeBlockNodeAttr.Lang, prevLang);\n contentDOM.classList.add(prevLang);\n }\n\n dom.append(contentDOM);\n\n return {\n dom,\n contentDOM,\n update(newNode) {\n if (node.type !== newNode.type) return false;\n\n const newLang = newNode.attrs[CodeBlockNodeAttr.Lang];\n if (prevLang !== newLang) {\n contentDOM.className = 'hljs';\n if (newLang) {\n dom.setAttribute(CodeBlockNodeAttr.Lang, newLang);\n contentDOM.classList.add(newLang);\n } else {\n dom.removeAttribute(CodeBlockNodeAttr.Lang);\n }\n prevLang = newLang;\n }\n\n return true;\n },\n };\n },\n },\n },\n });\n });\n\n function getDecorations(doc: Node) {\n const decos: Decoration[] = [];\n\n if (!lowlight) {\n return DecorationSet.empty;\n }\n\n for (const {node, pos} of findChildrenByType(doc, codeBlockType(doc.type.schema), true)) {\n let from = pos + 1;\n let nodes: Root['children'];\n\n const lang: string | undefined = node.attrs[CodeBlockNodeAttr.Lang];\n if (lang && lowlight.registered(lang)) {\n nodes = lowlight.highlight(lang, node.textContent).children;\n } else {\n continue;\n }\n\n for (const {text, classes} of parseNodes(nodes)) {\n const to = from + text.length;\n if (classes.length) {\n decos.push(\n Decoration.inline(from, to, {\n class: classes.join(' '),\n }),\n );\n }\n from = to;\n }\n }\n\n return DecorationSet.create(doc, decos);\n }\n};\n\nfunction parseNodes(\n nodes: Root['children'],\n className: readonly string[] = [],\n): {text: string; classes: readonly string[]}[] {\n return nodes\n .map((node) => {\n let classes = className;\n if (node.type === 'element') {\n classes = classes.concat((node.properties.className as string[]) ?? []);\n return parseNodes(node.children, classes);\n }\n\n return {\n text: node.type === 'comment' || node.type === 'text' ? node.value : '',\n classes,\n };\n })\n .flat();\n}\n\nfunction stepHasFromTo(step: Step): step is Step & {from: number; to: number} {\n // @ts-expect-error\n return typeof step.from === 'number' && typeof step.to === 'number';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CodeBlockHighlight.js","sourceRoot":"../../../../../../src","sources":["extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAEpD,oCAAoC;AACpC,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAC;AA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AAG,CAAC;qBAC3B,CAAC,CACL,CAAC;gBACN,CAAC;gBACD,IAAI,GAAG,EAAE,CAAC;YACd,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC,CAAC;AAEF,SAAS,UAAU,CACf,KAAuB,EACvB,YAA+B,EAAE;IAEjC,OAAO,KAAK;SACP,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACV,IAAI,OAAO,GAAG,SAAS,CAAC;QACxB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAE,IAAI,CAAC,UAAU,CAAC,SAAsB,IAAI,EAAE,CAAC,CAAC;YACxE,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACvE,OAAO;SACV,CAAC;IACN,CAAC,CAAC;SACD,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,IAAU;IAC7B,mBAAmB;IACnB,OAAO,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;AACxE,CAAC","sourcesContent":["import type {Options} from '@diplodoc/transform';\n// importing only type, because lowlight and highlight.js is optional deps\nimport type HLJS from 'highlight.js/lib/core';\nimport type {createLowlight} from 'lowlight' with {'resolution-mode': 'import'};\nimport type {Node} from 'prosemirror-model';\nimport {Plugin, PluginKey} from 'prosemirror-state';\nimport type {Step} from 'prosemirror-transform';\n// @ts-ignore // TODO: fix cjs build\nimport {findChildrenByType} from 'prosemirror-utils';\nimport {Decoration, DecorationSet} from 'prosemirror-view';\n\nimport type {ExtensionAuto} from '../../../../core';\nimport {capitalize} from '../../../../lodash';\nimport {globalLogger} from '../../../../logger';\nimport {CodeBlockNodeAttr, codeBlockNodeName, codeBlockType} from '../CodeBlockSpecs';\n\nimport {codeLangSelectTooltipViewCreator} from './TooltipPlugin';\n\nexport type HighlightLangMap = Options['highlightLangs'];\n\ntype Lowlight = ReturnType<typeof createLowlight>;\ntype Root = ReturnType<Lowlight['highlight']>;\n\ntype LangSelectItem = {\n value: string;\n content: string;\n};\n\nconst key = new PluginKey<DecorationSet>('code_block_highlight');\n\nexport type CodeBlockHighlightOptions = {\n langs?: HighlightLangMap;\n};\n\nexport const CodeBlockHighlight: ExtensionAuto<CodeBlockHighlightOptions> = (builder, opts) => {\n let langs: NonNullable<HighlightLangMap>;\n let lowlight: Lowlight;\n let hljs: typeof HLJS;\n\n const loadModules = async () => {\n try {\n hljs = (await import('highlight.js/lib/core')).default;\n const low = await import('lowlight');\n\n const all: HighlightLangMap = low.all;\n const create: typeof createLowlight = low.createLowlight;\n langs = {...all, ...opts.langs};\n lowlight = create(langs);\n return true;\n } catch (e) {\n globalLogger.info('Skip code_block highlighting');\n builder.logger.log('Skip code_block highlighting');\n return false;\n }\n };\n\n builder.addPlugin(() => {\n let modulesLoaded = false;\n\n const selectItems: LangSelectItem[] = [];\n const mapping: Record<string, string> = {};\n\n // TODO: add TAB key handler\n // TODO: Remove constant selection of block\n return new Plugin<DecorationSet>({\n key,\n state: {\n init: (_, state) => {\n loadModules().then((loaded) => {\n modulesLoaded = loaded;\n\n if (modulesLoaded) {\n for (const lang of Object.keys(langs)) {\n const defs = langs[lang](hljs);\n selectItems.push({\n value: lang,\n content: defs.name || capitalize(lang),\n });\n if (defs.aliases) {\n for (const alias of defs.aliases) {\n mapping[alias] = lang;\n }\n }\n }\n }\n });\n return getDecorations(state.doc);\n },\n apply: (tr, decos, oldState, newState) => {\n if (!modulesLoaded) {\n return DecorationSet.empty;\n }\n\n if (tr.docChanged) {\n const oldNodeName = oldState.selection.$head.parent.type.name;\n const newNodeName = newState.selection.$head.parent.type.name;\n\n // Apply decorations if:\n if (\n oldNodeName === codeBlockNodeName ||\n newNodeName === codeBlockNodeName\n ) {\n // selection includes codeblock node,\n return getDecorations(tr.doc);\n } else {\n const oldNodes = findChildrenByType(\n oldState.doc,\n codeBlockType(oldState.schema),\n );\n const newNodes = findChildrenByType(\n newState.doc,\n codeBlockType(newState.schema),\n );\n if (\n // OR transaction adds/removes codeblock nodes,\n newNodes.length !== oldNodes.length ||\n // OR transaction has changes that completely encapsulate a node\n // (for example, a transaction that affects the entire document).\n // Such transactions can happen during collab syncing via y-prosemirror, for example.\n tr.steps.some((step) => {\n return (\n stepHasFromTo(step) &&\n oldNodes.some(\n (node: {node: Node; pos: number}) =>\n node.pos >= step.from &&\n node.pos + node.node.nodeSize <= step.to,\n )\n );\n })\n ) {\n return getDecorations(tr.doc);\n }\n }\n }\n return decos.map(tr.mapping, tr.doc);\n },\n },\n view: (view) => codeLangSelectTooltipViewCreator(view, selectItems, mapping),\n props: {\n decorations: (state) => {\n return key.getState(state);\n },\n nodeViews: {\n [codeBlockNodeName]: (node) => {\n let prevLang = node.attrs[CodeBlockNodeAttr.Lang];\n\n const dom = document.createElement('pre');\n\n const contentDOM = document.createElement('code');\n contentDOM.classList.add('hljs');\n\n if (prevLang) {\n dom.setAttribute(CodeBlockNodeAttr.Lang, prevLang);\n contentDOM.classList.add(prevLang);\n }\n\n dom.append(contentDOM);\n\n return {\n dom,\n contentDOM,\n update(newNode) {\n if (node.type !== newNode.type) return false;\n\n const newLang = newNode.attrs[CodeBlockNodeAttr.Lang];\n if (prevLang !== newLang) {\n contentDOM.className = 'hljs';\n if (newLang) {\n dom.setAttribute(CodeBlockNodeAttr.Lang, newLang);\n contentDOM.classList.add(newLang);\n } else {\n dom.removeAttribute(CodeBlockNodeAttr.Lang);\n }\n prevLang = newLang;\n }\n\n return true;\n },\n };\n },\n },\n },\n });\n });\n\n function getDecorations(doc: Node) {\n const decos: Decoration[] = [];\n\n if (!lowlight) {\n return DecorationSet.empty;\n }\n\n for (const {node, pos} of findChildrenByType(doc, codeBlockType(doc.type.schema), true)) {\n let from = pos + 1;\n let nodes: Root['children'];\n\n const lang: string | undefined = node.attrs[CodeBlockNodeAttr.Lang];\n if (lang && lowlight.registered(lang)) {\n nodes = lowlight.highlight(lang, node.textContent).children;\n } else {\n continue;\n }\n\n for (const {text, classes} of parseNodes(nodes)) {\n const to = from + text.length;\n if (classes.length) {\n decos.push(\n Decoration.inline(from, to, {\n class: classes.join(' '),\n }),\n );\n }\n from = to;\n }\n }\n\n return DecorationSet.create(doc, decos);\n }\n};\n\nfunction parseNodes(\n nodes: Root['children'],\n className: readonly string[] = [],\n): {text: string; classes: readonly string[]}[] {\n return nodes\n .map((node) => {\n let classes = className;\n if (node.type === 'element') {\n classes = classes.concat((node.properties.className as string[]) ?? []);\n return parseNodes(node.children, classes);\n }\n\n return {\n text: node.type === 'comment' || node.type === 'text' ? node.value : '',\n classes,\n };\n })\n .flat();\n}\n\nfunction stepHasFromTo(step: Step): step is Step & {from: number; to: number} {\n // @ts-expect-error\n return typeof step.from === 'number' && typeof step.to === 'number';\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { EditorProps } from
|
|
1
|
+
import type { EditorProps } from "../../../pm/view.js";
|
|
2
2
|
export declare const handlePaste: NonNullable<EditorProps['handlePaste']>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import dd from 'ts-dedent';
|
|
2
|
+
import { getLoggerFromState } from "../../../core/index.js";
|
|
3
|
+
import { Fragment } from "../../../pm/model.js";
|
|
1
4
|
import { DataTransferType, isVSCode, tryParseVSCodeData } from "../../../utils/clipboard.js";
|
|
2
5
|
import { CodeBlockNodeAttr } from "./CodeBlockSpecs/index.js";
|
|
3
6
|
import { codeBlockType } from "./const.js";
|
|
@@ -7,10 +10,22 @@ export const handlePaste = (view, e) => {
|
|
|
7
10
|
const code = getCodeData(e.clipboardData);
|
|
8
11
|
if (!code)
|
|
9
12
|
return false;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
getLoggerFromState(view.state).event({
|
|
14
|
+
domEvent: 'paste',
|
|
15
|
+
event: 'paste-from-code-editor',
|
|
16
|
+
editor: code.editor,
|
|
17
|
+
editorMode: code.mode,
|
|
18
|
+
empty: !code.value,
|
|
19
|
+
dataTypes: e.clipboardData.types,
|
|
20
|
+
});
|
|
21
|
+
const { tr, schema } = view.state;
|
|
22
|
+
if (code.value) {
|
|
23
|
+
const codeBlockNode = codeBlockType(schema).create({ [CodeBlockNodeAttr.Lang]: code.mode }, schema.text(code.value));
|
|
24
|
+
tr.replaceSelectionWith(codeBlockNode);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
tr.replaceWith(tr.selection.from, tr.selection.to, Fragment.empty);
|
|
28
|
+
}
|
|
14
29
|
view.dispatch(tr.scrollIntoView());
|
|
15
30
|
return true;
|
|
16
31
|
};
|
|
@@ -24,7 +39,7 @@ function getCodeData(data) {
|
|
|
24
39
|
}
|
|
25
40
|
else
|
|
26
41
|
return null;
|
|
27
|
-
return { editor, mode, value: data.getData(DataTransferType.Text) };
|
|
42
|
+
return { editor, mode, value: dd(data.getData(DataTransferType.Text)) };
|
|
28
43
|
}
|
|
29
44
|
return null;
|
|
30
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-paste.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/CodeBlock/handle-paste.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handle-paste.js","sourceRoot":"../../../../../src","sources":["extensions/markdown/CodeBlock/handle-paste.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3B,OAAO,EAAC,kBAAkB,EAAC,+BAAc;AACzC,OAAO,EAAC,QAAQ,EAAC,6BAAkB;AAEnC,OAAO,EA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AE,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,SAAS,WAAW,CAAC,IAAkB;IACnC,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,IAAI,IAAwB,CAAC;QAE7B,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACjB,MAAM,GAAG,QAAQ,CAAC;YAClB,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;QAC1C,CAAC;;YAAM,OAAO,IAAI,CAAC;QAEnB,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAC,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import dd from 'ts-dedent';\n\nimport {getLoggerFromState} from '#core';\nimport {Fragment} from '#pm/model';\nimport type {EditorProps} from '#pm/view';\nimport {DataTransferType, isVSCode, tryParseVSCodeData} from 'src/utils/clipboard';\n\nimport {CodeBlockNodeAttr} from './CodeBlockSpecs';\nimport {codeBlockType} from './const';\n\nexport const handlePaste: NonNullable<EditorProps['handlePaste']> = (view, e) => {\n if (!e.clipboardData || view.state.selection.$from.parent.type.spec.code) return false;\n const code = getCodeData(e.clipboardData);\n if (!code) return false;\n\n getLoggerFromState(view.state).event({\n domEvent: 'paste',\n event: 'paste-from-code-editor',\n editor: code.editor,\n editorMode: code.mode,\n empty: !code.value,\n dataTypes: e.clipboardData.types,\n });\n\n const {tr, schema} = view.state;\n if (code.value) {\n const codeBlockNode = codeBlockType(schema).create(\n {[CodeBlockNodeAttr.Lang]: code.mode},\n schema.text(code.value),\n );\n tr.replaceSelectionWith(codeBlockNode);\n } else {\n tr.replaceWith(tr.selection.from, tr.selection.to, Fragment.empty);\n }\n view.dispatch(tr.scrollIntoView());\n return true;\n};\n\nfunction getCodeData(data: DataTransfer): null | {editor: string; mode?: string; value: string} {\n if (data.getData(DataTransferType.Text)) {\n let editor = 'unknown';\n let mode: string | undefined;\n\n if (isVSCode(data)) {\n editor = 'vscode';\n mode = tryParseVSCodeData(data)?.mode;\n } else return null;\n\n return {editor, mode, value: dd(data.getData(DataTransferType.Text))};\n }\n return null;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const i18n: <G extends "link_copied" | "link_copy" | "file_download", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}) => S extends G ? {
|
|
4
|
+
link_copied: string;
|
|
5
|
+
link_copy: string;
|
|
6
|
+
file_download: string;
|
|
7
|
+
}[G] : string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["i18n/gallery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,mBAAgB;AAEvC,OAAO,EAAE,kBAAkB;AAC3B,OAAO,EAAE,kBAAkB;AAE3B,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,EAAC,EAAE,EAAE,EAAE,EAAC,CAAC,CAAC","sourcesContent":["import {registerKeyset} from '../i18n';\n\nimport en from './en.json';\nimport ru from './ru.json';\n\nconst KEYSET = 'gallery';\n\nexport const i18n = registerKeyset(KEYSET, {en, ru});\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const i18n: <G extends "block" | "checkbox" | "heading" | "codeblock" | "doc_empty" | "deflist_term" | "deflist_desc" | "cut_title" | "cut_content" | "note_title" | "note_content" | "layout_cell" | "table_cell" | "select_filter", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
1
|
+
export declare const i18n: <G extends "block" | "checkbox" | "heading" | "codeblock" | "doc_empty" | "doc_empty_mobile" | "deflist_term" | "deflist_desc" | "cut_title" | "cut_content" | "note_title" | "note_content" | "layout_cell" | "table_cell" | "select_filter", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}) => S extends G ? {
|
|
4
4
|
doc_empty: string;
|
|
5
|
+
doc_empty_mobile: string;
|
|
5
6
|
checkbox: string;
|
|
6
7
|
codeblock: string;
|
|
7
8
|
deflist_term: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"doc_empty": "Начните писать текст или введите \"/\", чтобы открыть список команд",
|
|
3
|
+
"doc_empty_mobile": "Начните писать текст",
|
|
3
4
|
"checkbox": "Добавьте описание задачи или пункт проверки",
|
|
4
5
|
"codeblock": "Добавьте в блок код или текст",
|
|
5
6
|
"deflist_term": "Термин",
|
|
@@ -19,7 +19,7 @@ export function FlexToolbar(props) {
|
|
|
19
19
|
duration: time,
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
-
const { data, className, hiddenActions } = props;
|
|
22
|
+
const { data, className, hiddenActions, disableTooltip, disablePreview, disableHotkey, display = 'shrink', } = props;
|
|
23
23
|
const [ref, { width }] = useMeasure();
|
|
24
24
|
const { data: items, dots } = useMemo(() => {
|
|
25
25
|
const toolbarButtonIds = data.reduce((a, toolbarGroup) => {
|
|
@@ -37,12 +37,18 @@ export function FlexToolbar(props) {
|
|
|
37
37
|
}, []);
|
|
38
38
|
// Finding only actions tha are not present in the main toolbar config
|
|
39
39
|
const filteredHiddenAction = hiddenActions?.filter((a) => !toolbarButtonIds.includes(a.id));
|
|
40
|
+
if (display === 'scroll') {
|
|
41
|
+
return {
|
|
42
|
+
data,
|
|
43
|
+
dots: filteredHiddenAction?.length ? filteredHiddenAction : undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
40
46
|
return shrinkToolbarData({
|
|
41
47
|
data,
|
|
42
48
|
availableWidth: width,
|
|
43
49
|
hiddenActions: filteredHiddenAction,
|
|
44
50
|
});
|
|
45
|
-
}, [data,
|
|
46
|
-
return (_jsx("div", { ref: ref, className: b(null, [className]), children: _jsxs("div", { className: b('container'), children: [_jsx(Toolbar, { ...props, data: items, className: b('bar') }), dots?.length && (_jsx(ToolbarListButton, { qa: "g-md-toolbar-more-action", qaMenu: "g-md-toolbar-additional", data: dots, icon: { data: Ellipsis }, title: props.dotsTitle, editor: props.editor, focus: props.focus, onClick: props.onClick, className: b('dots'), alwaysActive: true }))] }) }));
|
|
51
|
+
}, [data, display, hiddenActions, width]);
|
|
52
|
+
return (_jsx("div", { ref: ref, className: b(null, [className]), children: _jsxs("div", { className: b('container'), children: [_jsx(Toolbar, { ...props, data: items, className: b('bar') }), dots?.length && (_jsx(ToolbarListButton, { qa: "g-md-toolbar-more-action", qaMenu: "g-md-toolbar-additional", data: dots, icon: { data: Ellipsis }, title: props.dotsTitle, editor: props.editor, focus: props.focus, onClick: props.onClick, className: b('dots'), alwaysActive: true, disableTooltip: disableTooltip, disableHotkey: disablePreview, disablePreview: disableHotkey }))] }) }));
|
|
47
53
|
}
|
|
48
54
|
//# sourceMappingURL=FlexToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlexToolbar.js","sourceRoot":"../../../src","sources":["toolbar/FlexToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AAErC,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAChC,OAAO,EAAC,MAAM,EAAC,qBAAkB;AACjC,OAAO,EAAC,aAAa,EAAC,gCAA6B;AAEnD,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AAK;YACrB,aAAa,EAAE,oBAAoB;SACtC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1C,OAAO,CACH,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,YAC1C,eAAK,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,aAC1B,KAAC,OAAO,OAAK,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,GAAI,EACvD,IAAI,EAAE,MAAM,IAAI,CACb,KAAC,iBAAiB,IACd,EAAE,EAAC,0BAA0B,EAC7B,MAAM,EAAC,yBAAyB,EAChC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACtB,KAAK,EAAE,KAAK,CAAC,SAAS,EACtB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EACpB,YAAY,EAAE,IAAI,EAClB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,cAAc,EAC7B,cAAc,EAAE,aAAa,GAC/B,CACL,IACC,GACJ,CACT,CAAC;AACN,CAAC","sourcesContent":["import {useMemo} from 'react';\n\nimport {Ellipsis} from '@gravity-ui/icons';\nimport {useMeasure} from 'react-use';\n\nimport {cn} from '../classname';\nimport {logger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport {Toolbar, type ToolbarProps} from './Toolbar';\nimport {ToolbarListButton} from './ToolbarListButton';\nimport {shrinkToolbarData} from './flexible';\nimport {ToolbarDataType, type ToolbarItemData} from './types';\n\nimport './FlexToolbar.scss';\n\nconst b = cn('flex-toolbar');\n\nexport type FlexToolbarProps<E> = ToolbarProps<E> & {\n dotsTitle: string | (() => string);\n hiddenActions?: ToolbarItemData<E>[];\n};\n\nexport function FlexToolbar<E>(props: FlexToolbarProps<E>) {\n useRenderTime((time) => {\n logger.metrics({\n component: 'toolbar',\n event: 'render',\n duration: time,\n });\n });\n\n const {\n data,\n className,\n hiddenActions,\n disableTooltip,\n disablePreview,\n disableHotkey,\n display = 'shrink',\n } = props;\n\n const [ref, {width}] = useMeasure<HTMLDivElement>();\n const {data: items, dots} = useMemo(() => {\n const toolbarButtonIds = data.reduce((a: string[], toolbarGroup) => {\n return [\n ...a,\n ...toolbarGroup\n .map((toolbarButton) => {\n if (toolbarButton.type === ToolbarDataType.ListButton) {\n return toolbarButton.data.map((v) => v.id);\n }\n return toolbarButton.id;\n })\n .flat(),\n ];\n }, []);\n\n // Finding only actions tha are not present in the main toolbar config\n const filteredHiddenAction = hiddenActions?.filter((a) => !toolbarButtonIds.includes(a.id));\n\n if (display === 'scroll') {\n return {\n data,\n dots: filteredHiddenAction?.length ? filteredHiddenAction : undefined,\n };\n }\n\n return shrinkToolbarData({\n data,\n availableWidth: width,\n hiddenActions: filteredHiddenAction,\n });\n }, [data, display, hiddenActions, width]);\n\n return (\n <div ref={ref} className={b(null, [className])}>\n <div className={b('container')}>\n <Toolbar {...props} data={items} className={b('bar')} />\n {dots?.length && (\n <ToolbarListButton\n qa=\"g-md-toolbar-more-action\"\n qaMenu=\"g-md-toolbar-additional\"\n data={dots}\n icon={{data: Ellipsis}}\n title={props.dotsTitle}\n editor={props.editor}\n focus={props.focus}\n onClick={props.onClick}\n className={b('dots')}\n alwaysActive={true}\n disableTooltip={disableTooltip}\n disableHotkey={disablePreview}\n disablePreview={disableHotkey}\n />\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -4,9 +4,9 @@ import { cn } from "../classname.js";
|
|
|
4
4
|
import { ToolbarTooltipDelay } from "./const.js";
|
|
5
5
|
import "./PreviewTooltip.css";
|
|
6
6
|
const b = cn('preview-tooltip');
|
|
7
|
-
export const PreviewTooltip = ({ preview, children }) => {
|
|
8
|
-
if (!preview)
|
|
7
|
+
export const PreviewTooltip = ({ preview, children, disabled }) => {
|
|
8
|
+
if (!preview || disabled)
|
|
9
9
|
return children;
|
|
10
|
-
return (_jsx(Tooltip, { placement: ['right', 'left'], className: b(),
|
|
10
|
+
return (_jsx(Tooltip, { placement: ['right', 'left'], className: b(), openDelay: ToolbarTooltipDelay.Open, closeDelay: ToolbarTooltipDelay.Close, content: _jsx("div", { className: b('content'), children: preview }), children: children }));
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=PreviewTooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewTooltip.js","sourceRoot":"../../../src","sources":["toolbar/PreviewTooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAEhC,OAAO,EAAC,mBAAmB,EAAC,mBAAgB;AAE5C,8BAA+B;AAE/B,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"PreviewTooltip.js","sourceRoot":"../../../src","sources":["toolbar/PreviewTooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAEhC,OAAO,EAAC,mBAAmB,EAAC,mBAAgB;AAE5C,8BAA+B;AAE/B,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;AAQhC,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC3F,IAAI,CAAC,OAAO,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE1C,OAAO,CACH,KAAC,OAAO,IACJ,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAC5B,SAAS,EAAE,CAAC,EAAE,EACd,SAAS,EAAE,mBAAmB,CAAC,IAAI,EACnC,UAAU,EAAE,mBAAmB,CAAC,KAAK,EACrC,OAAO,EAAE,cAAK,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,YAAG,OAAO,GAAO,YAErD,QAAQ,GACH,CACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Tooltip} from '@gravity-ui/uikit';\n\nimport {cn} from '../classname';\n\nimport {ToolbarTooltipDelay} from './const';\n\nimport './PreviewTooltip.scss';\n\nconst b = cn('preview-tooltip');\n\ntype PreviewTooltipProps = {\n preview?: React.ReactNode;\n children: React.ReactElement;\n disabled?: boolean;\n};\n\nexport const PreviewTooltip: React.FC<PreviewTooltipProps> = ({preview, children, disabled}) => {\n if (!preview || disabled) return children;\n\n return (\n <Tooltip\n placement={['right', 'left']}\n className={b()}\n openDelay={ToolbarTooltipDelay.Open}\n closeDelay={ToolbarTooltipDelay.Close}\n content={<div className={b('content')}>{preview}</div>}\n >\n {children}\n </Tooltip>\n );\n};\n"]}
|
|
@@ -4,4 +4,4 @@ export type { ToolbarData };
|
|
|
4
4
|
export type ToolbarProps<E> = ToolbarBaseProps<E> & {
|
|
5
5
|
data: ToolbarData<E>;
|
|
6
6
|
};
|
|
7
|
-
export declare function Toolbar<E>({ editor, data, className, focus, onClick, qa }: ToolbarProps<E>): JSX.Element;
|
|
7
|
+
export declare function Toolbar<E>({ editor, data, className, focus, onClick, display, qa, disableHotkey, disablePreview, disableTooltip, }: ToolbarProps<E>): JSX.Element;
|
|
@@ -4,10 +4,10 @@ import { cn } from "../classname.js";
|
|
|
4
4
|
import { ToolbarButtonGroup } from "./ToolbarGroup.js";
|
|
5
5
|
import "./Toolbar.css";
|
|
6
6
|
const b = cn('toolbar');
|
|
7
|
-
export function Toolbar({ editor, data, className, focus, onClick, qa }) {
|
|
8
|
-
return (_jsx("div", { className: b(
|
|
7
|
+
export function Toolbar({ editor, data, className, focus, onClick, display, qa, disableHotkey, disablePreview, disableTooltip, }) {
|
|
8
|
+
return (_jsx("div", { className: b({ display }, [className]), "data-qa": qa, children: data.map((group, index) => {
|
|
9
9
|
const isLastGroup = index === data.length - 1;
|
|
10
|
-
return (_jsxs(Fragment, { children: [_jsx(ToolbarButtonGroup, { data: group, editor: editor, focus: focus, onClick: onClick, className: b('group') }), isLastGroup || _jsx("div", { className: b('group-separator') })] }, index));
|
|
10
|
+
return (_jsxs(Fragment, { children: [_jsx(ToolbarButtonGroup, { data: group, editor: editor, focus: focus, onClick: onClick, className: b('group'), disableHotkey: disableHotkey, disablePreview: disablePreview, disableTooltip: disableTooltip }), isLastGroup || _jsx("div", { className: b('group-separator') })] }, index));
|
|
11
11
|
}) }));
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=Toolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.js","sourceRoot":"../../../src","sources":["toolbar/Toolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAEhC,OAAO,EAAC,kBAAkB,EAAC,0BAAuB;AAGlD,uBAAwB;AAExB,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAQxB,MAAM,UAAU,OAAO,CAAI,
|
|
1
|
+
{"version":3,"file":"Toolbar.js","sourceRoot":"../../../src","sources":["toolbar/Toolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAEhC,OAAO,EAAC,kBAAkB,EAAC,0BAAuB;AAGlD,uBAAwB;AAExB,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAQxB,MAAM,UAAU,OAAO,CAAI,EACvB,MAAM,EACN,IAAI,EACJ,SAAS,EACT,KAAK,EACL,OAAO,EACP,OAAO,EACP,EAAE,EACF,aAAa,EACb,cAAc,EACd,cAAc,GACA;IACd,OAAO,CACH,cAAK,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,aAAW,EAAE,YACjD,IAAI,CAAC,GAAG,CAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACxC,MAAM,WAAW,GAAG,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAE9C,OAAO,CACH,MAAC,QAAQ,eACL,KAAC,kBAAkB,IACf,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,EACrB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAChC,EACD,WAAW,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAI,KAX7C,KAAK,CAYT,CACd,CAAC;QACN,CAAC,CAAC,GACA,CACT,CAAC;AACN,CAAC","sourcesContent":["import {Fragment} from 'react';\n\nimport {cn} from '../classname';\n\nimport {ToolbarButtonGroup} from './ToolbarGroup';\nimport type {ToolbarBaseProps, ToolbarData} from './types';\n\nimport './Toolbar.scss';\n\nconst b = cn('toolbar');\n\nexport type {ToolbarData};\n\nexport type ToolbarProps<E> = ToolbarBaseProps<E> & {\n data: ToolbarData<E>;\n};\n\nexport function Toolbar<E>({\n editor,\n data,\n className,\n focus,\n onClick,\n display,\n qa,\n disableHotkey,\n disablePreview,\n disableTooltip,\n}: ToolbarProps<E>) {\n return (\n <div className={b({display}, [className])} data-qa={qa}>\n {data.map<React.ReactNode>((group, index) => {\n const isLastGroup = index === data.length - 1;\n\n return (\n <Fragment key={index}>\n <ToolbarButtonGroup\n data={group}\n editor={editor}\n focus={focus}\n onClick={onClick}\n className={b('group')}\n disableHotkey={disableHotkey}\n disablePreview={disablePreview}\n disableTooltip={disableTooltip}\n />\n {isLastGroup || <div className={b('group-separator')} />}\n </Fragment>\n );\n })}\n </div>\n );\n}\n"]}
|
|
@@ -10,6 +10,6 @@ export type ToolbarButtonViewProps = Pick<ToolbarItemData<unknown>, 'title' | 'h
|
|
|
10
10
|
className?: string;
|
|
11
11
|
} & (Pick<ToolbarItemData<unknown>, 'icon'> | {
|
|
12
12
|
children: ReactNode;
|
|
13
|
-
})
|
|
13
|
+
}) & Pick<ToolbarBaseProps<unknown>, 'disableTooltip'>;
|
|
14
14
|
export declare const ToolbarButtonView: import("react").ForwardRefExoticComponent<ToolbarButtonViewProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
15
15
|
export declare function ToolbarButton<E>(props: ToolbarButtonProps<E>): JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { ToolbarTooltipDelay } from "./const.js";
|
|
|
8
8
|
import "./ToolbarButton.css";
|
|
9
9
|
const b = cn('toolbar-button');
|
|
10
10
|
const DEFAULT_ICON_SIZE = 16;
|
|
11
|
-
export const ToolbarButtonView = forwardRef(function ToolbarButtonView({ title, hint, hotkey, hintWhenDisabled, active, enabled, onClick, className, qa, id, ...props }, ref) {
|
|
11
|
+
export const ToolbarButtonView = forwardRef(function ToolbarButtonView({ title, hint, hotkey, hintWhenDisabled, active, enabled, onClick, className, qa, id, disableTooltip, ...props }, ref) {
|
|
12
12
|
const disabled = !active && !enabled;
|
|
13
13
|
const titleText = isFunction(title) ? title() : title;
|
|
14
14
|
const hintText = isFunction(hint) ? hint() : hint;
|
|
@@ -18,7 +18,7 @@ export const ToolbarButtonView = forwardRef(function ToolbarButtonView({ title,
|
|
|
18
18
|
: typeof hintWhenDisabled === 'function'
|
|
19
19
|
? hintWhenDisabled()
|
|
20
20
|
: i18n('toolbar_action_disabled');
|
|
21
|
-
return (_jsx(Popover, { content: _jsx("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), disabled: hideHintWhenDisabled, placement: ['bottom'], children: (_, refForPopover) => (_jsx(ActionTooltip, { openDelay: ToolbarTooltipDelay.Open, closeDelay: ToolbarTooltipDelay.Close, description: hintText, title: titleText, hotkey: hotkey, children: (__, refForTooltip) => (_jsx(Button, { qa: qa, size: "m", ref: (elem) => {
|
|
21
|
+
return (_jsx(Popover, { content: _jsx("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), disabled: hideHintWhenDisabled, placement: ['bottom'], children: (_, refForPopover) => (_jsx(ActionTooltip, { openDelay: ToolbarTooltipDelay.Open, closeDelay: ToolbarTooltipDelay.Close, description: hintText, title: titleText, hotkey: hotkey, disabled: disableTooltip, children: (__, refForTooltip) => (_jsx(Button, { qa: qa, size: "m", ref: (elem) => {
|
|
22
22
|
setRef(ref, elem);
|
|
23
23
|
setRef(refForPopover, elem);
|
|
24
24
|
setRef(refForTooltip, elem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarButton.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiB,UAAU,EAAC,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAChC,OAAO,EAAC,IAAI,EAAC,gCAAuB;AACpC,OAAO,EAAC,UAAU,EAAC,qBAAkB;AAErC,OAAO,EAAC,mBAAmB,EAAC,mBAAgB;AAG5C,6BAA8B;AAE9B,MAAM,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolbarButton.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiB,UAAU,EAAC,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE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AE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAErE,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,GAAG,EAAE;QACrB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,CAAC,CAAC;QACb,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,KAAC,iBAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAI,CAAC;AACpG,CAAC","sourcesContent":["import {type ReactNode, forwardRef} from 'react';\n\nimport {ActionTooltip, Button, Icon, Popover, setRef} from '@gravity-ui/uikit';\n\nimport {cn} from '../classname';\nimport {i18n} from '../i18n/common';\nimport {isFunction} from '../lodash';\n\nimport {ToolbarTooltipDelay} from './const';\nimport type {ToolbarBaseProps, ToolbarItemData} from './types';\n\nimport './ToolbarButton.scss';\n\nconst b = cn('toolbar-button');\n\nexport type ToolbarButtonProps<E> = ToolbarBaseProps<E> & ToolbarItemData<E>;\n\nexport type ToolbarButtonViewProps = Pick<\n ToolbarItemData<unknown>,\n 'title' | 'hint' | 'hotkey' | 'hintWhenDisabled' | 'qa'\n> & {\n active: boolean;\n enabled: boolean;\n onClick: () => void;\n id?: string;\n className?: string;\n} & (Pick<ToolbarItemData<unknown>, 'icon'> | {children: ReactNode}) &\n Pick<ToolbarBaseProps<unknown>, 'disableTooltip'>;\n\nconst DEFAULT_ICON_SIZE = 16;\n\nexport const ToolbarButtonView = forwardRef<HTMLButtonElement, ToolbarButtonViewProps>(\n function ToolbarButtonView(\n {\n title,\n hint,\n hotkey,\n hintWhenDisabled,\n active,\n enabled,\n onClick,\n className,\n qa,\n id,\n disableTooltip,\n ...props\n },\n ref,\n ) {\n const disabled = !active && !enabled;\n const titleText: string = isFunction(title) ? title() : title;\n const hintText: string | undefined = isFunction(hint) ? hint() : hint;\n const hideHintWhenDisabled = hintWhenDisabled === false || !disabled;\n const hintWhenDisabledText =\n typeof hintWhenDisabled === 'string'\n ? hintWhenDisabled\n : typeof hintWhenDisabled === 'function'\n ? hintWhenDisabled()\n : i18n('toolbar_action_disabled');\n\n return (\n <Popover\n content={<div className={b('action-disabled-tooltip')}>{hintWhenDisabledText}</div>}\n disabled={hideHintWhenDisabled}\n placement={['bottom']}\n >\n {(_, refForPopover) => (\n <ActionTooltip\n openDelay={ToolbarTooltipDelay.Open}\n closeDelay={ToolbarTooltipDelay.Close}\n description={hintText}\n title={titleText}\n hotkey={hotkey}\n disabled={disableTooltip}\n >\n {(__, refForTooltip) => (\n <Button\n qa={qa}\n size=\"m\"\n ref={(elem: HTMLButtonElement) => {\n setRef(ref, elem);\n setRef(refForPopover, elem);\n setRef(refForTooltip, elem);\n }}\n selected={active}\n disabled={disabled}\n view={active ? 'normal' : 'flat'}\n onClick={onClick}\n className={b(null, [className])}\n aria-label={titleText}\n data-toolbar-item={id}\n >\n {'icon' in props ? (\n <Icon\n data={props.icon.data}\n size={props.icon.size ?? DEFAULT_ICON_SIZE}\n />\n ) : (\n props.children\n )}\n </Button>\n )}\n </ActionTooltip>\n )}\n </Popover>\n );\n },\n);\n\nexport function ToolbarButton<E>(props: ToolbarButtonProps<E>) {\n const {id, editor, focus, isActive, isEnable, exec, onClick} = props;\n\n const active = isActive(editor);\n const enabled = isEnable(editor);\n\n const handleClick = () => {\n focus();\n exec(editor);\n onClick?.(id);\n };\n\n return <ToolbarButtonView {...props} active={active} enabled={enabled} onClick={handleClick} />;\n}\n"]}
|
|
@@ -4,4 +4,4 @@ export type { ToolbarGroupData };
|
|
|
4
4
|
export type ToolbarGroupProps<E> = ToolbarBaseProps<E> & {
|
|
5
5
|
data: ToolbarGroupData<E>;
|
|
6
6
|
};
|
|
7
|
-
export declare function ToolbarButtonGroup<E>({ className, editor, data, focus, onClick, }: ToolbarGroupProps<E>): JSX.Element;
|
|
7
|
+
export declare function ToolbarButtonGroup<E>({ className, editor, data, focus, onClick, disableTooltip, disablePreview, disableHotkey, }: ToolbarGroupProps<E>): JSX.Element;
|
|
@@ -8,16 +8,16 @@ import { ToolbarListButton } from "./ToolbarListButton.js";
|
|
|
8
8
|
import { ToolbarDataType } from "./types.js";
|
|
9
9
|
import "./ToolbarGroup.css";
|
|
10
10
|
const b = cn('toolbar-group');
|
|
11
|
-
export function ToolbarButtonGroup({ className, editor, data, focus, onClick, }) {
|
|
11
|
+
export function ToolbarButtonGroup({ className, editor, data, focus, onClick, disableTooltip, disablePreview, disableHotkey, }) {
|
|
12
12
|
return (_jsx("div", { className: b(null, [className]), children: data.map((item) => {
|
|
13
13
|
if (item.type === ToolbarDataType.SingleButton) {
|
|
14
|
-
return (_createElement(ToolbarButton, { ...item, key: item.id, editor: editor, focus: focus, onClick: onClick, className: b(item.type, { id: item.id }, [item.className]) }));
|
|
14
|
+
return (_createElement(ToolbarButton, { ...item, key: item.id, editor: editor, focus: focus, onClick: onClick, className: b(item.type, { id: item.id }, [item.className]), disableTooltip: disableTooltip }));
|
|
15
15
|
}
|
|
16
16
|
if (item.type === ToolbarDataType.ButtonPopup) {
|
|
17
|
-
return (_createElement(ToolbarButtonPopup, { ...item, key: item.id, editor: editor, focus: focus, onClick: onClick, className: b(item.type, { id: item.id }, item.className) }));
|
|
17
|
+
return (_createElement(ToolbarButtonPopup, { ...item, key: item.id, editor: editor, focus: focus, onClick: onClick, className: b(item.type, { id: item.id }, item.className), disableTooltip: disableTooltip }));
|
|
18
18
|
}
|
|
19
19
|
if (item.type === ToolbarDataType.ListButton) {
|
|
20
|
-
return (_createElement(ToolbarListButton, { ...item, qaMenu: "g-md-toolbar-menu", key: item.id, editor: editor, focus: focus, onClick: onClick, className: b(item.type, { id: item.id }, [item.className]) }));
|
|
20
|
+
return (_createElement(ToolbarListButton, { ...item, qaMenu: "g-md-toolbar-menu", key: item.id, editor: editor, focus: focus, onClick: onClick, className: b(item.type, { id: item.id }, [item.className]), disablePreview: disablePreview, disableHotkey: disableHotkey, disableTooltip: disableTooltip }));
|
|
21
21
|
}
|
|
22
22
|
if (item.type === ToolbarDataType.ReactComponent) {
|
|
23
23
|
const Component = item.component;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarGroup.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarGroup.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAEhC,OAAO,EAAC,aAAa,EAAC,2BAAwB;AAC9C,OAAO,EAAC,kBAAkB,EAAC,gCAA6B;AACxD,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AACtD,OAAO,EAAwB,eAAe,EAAwB,mBAAgB;AAEtF,4BAA6B;AAE7B,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAQ9B,MAAM,UAAU,kBAAkB,CAAI,EAClC,SAAS,EACT,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"ToolbarGroup.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarGroup.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAEhC,OAAO,EAAC,aAAa,EAAC,2BAAwB;AAC9C,OAAO,EAAC,kBAAkB,EAAC,gCAA6B;AACxD,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AACtD,OAAO,EAAwB,eAAe,EAAwB,mBAAgB;AAEtF,4BAA6B;AAE7B,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAQ9B,MAAM,UAAU,kBAAkB,CAAI,EAClC,SAAS,EACT,MAAM,EACN,I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AAE,OAAO,EAChB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EACxD,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAChC,CACL,CAAC;YACN,CAAC;YAED,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,cAAc,EAAE,CAAC;gBAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;gBACjC,OAAO,CACH,eAAC,SAAS,OACF,IAAI,CAAC,KAAK,EACd,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAC1D,CACL,CAAC;YACN,CAAC;YAED,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,SAAS,EAAE,CAAC;gBAC1C,OAAO,KAAC,QAAQ,cAAgB,IAAI,CAAC,OAAO,IAAtB,IAAI,CAAC,EAAE,CAA2B,CAAC;YAC7D,CAAC;YAED,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,WAAW,EAAE,CAAC;gBAC5C,OAAO,KAAC,QAAQ,cAAgB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAA9B,IAAI,CAAC,EAAE,CAAmC,CAAC;YACrE,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,GACA,CACT,CAAC;AACN,CAAC","sourcesContent":["import {Fragment} from 'react';\n\nimport {cn} from '../classname';\n\nimport {ToolbarButton} from './ToolbarButton';\nimport {ToolbarButtonPopup} from './ToolbarButtonPopup';\nimport {ToolbarListButton} from './ToolbarListButton';\nimport {type ToolbarBaseProps, ToolbarDataType, type ToolbarGroupData} from './types';\n\nimport './ToolbarGroup.scss';\n\nconst b = cn('toolbar-group');\n\nexport type {ToolbarGroupData};\n\nexport type ToolbarGroupProps<E> = ToolbarBaseProps<E> & {\n data: ToolbarGroupData<E>;\n};\n\nexport function ToolbarButtonGroup<E>({\n className,\n editor,\n data,\n focus,\n onClick,\n disableTooltip,\n disablePreview,\n disableHotkey,\n}: ToolbarGroupProps<E>) {\n return (\n <div className={b(null, [className])}>\n {data.map((item) => {\n if (item.type === ToolbarDataType.SingleButton) {\n return (\n <ToolbarButton\n {...item}\n key={item.id}\n editor={editor}\n focus={focus}\n onClick={onClick}\n className={b(item.type, {id: item.id}, [item.className])}\n disableTooltip={disableTooltip}\n />\n );\n }\n\n if (item.type === ToolbarDataType.ButtonPopup) {\n return (\n <ToolbarButtonPopup\n {...item}\n key={item.id}\n editor={editor}\n focus={focus}\n onClick={onClick}\n className={b(item.type, {id: item.id}, item.className)}\n disableTooltip={disableTooltip}\n />\n );\n }\n\n if (item.type === ToolbarDataType.ListButton) {\n return (\n <ToolbarListButton\n {...item}\n qaMenu=\"g-md-toolbar-menu\"\n key={item.id}\n editor={editor}\n focus={focus}\n onClick={onClick}\n className={b(item.type, {id: item.id}, [item.className])}\n disablePreview={disablePreview}\n disableHotkey={disableHotkey}\n disableTooltip={disableTooltip}\n />\n );\n }\n\n if (item.type === ToolbarDataType.ReactComponent) {\n const Component = item.component;\n return (\n <Component\n {...item.props}\n key={item.id}\n editor={editor}\n focus={focus}\n onClick={onClick}\n className={b(item.type, {id: item.id}, [item.className])}\n />\n );\n }\n\n if (item.type === ToolbarDataType.ReactNode) {\n return <Fragment key={item.id}>{item.content}</Fragment>;\n }\n\n if (item.type === ToolbarDataType.ReactNodeFn) {\n return <Fragment key={item.id}>{item.content(editor)}</Fragment>;\n }\n\n return null;\n })}\n </div>\n );\n}\n"]}
|
|
@@ -5,4 +5,4 @@ export type ToolbarListButtonProps<E> = ToolbarBaseProps<E> & ToolbarListButtonD
|
|
|
5
5
|
qaMenu?: string;
|
|
6
6
|
qaActionDisabledPopover?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare function ToolbarListButton<E>({ className, editor, focus, onClick, icon, title, withArrow, data, alwaysActive, replaceActiveIcon, qa, qaMenu, qaActionDisabledPopover, }: ToolbarListButtonProps<E>): JSX.Element | null;
|
|
8
|
+
export declare function ToolbarListButton<E>({ className, editor, focus, onClick, icon, title, withArrow, data, alwaysActive, replaceActiveIcon, qa, qaMenu, qaActionDisabledPopover, disableHotkey, disablePreview, disableTooltip, }: ToolbarListButtonProps<E>): JSX.Element | null;
|
|
@@ -10,7 +10,7 @@ import { PreviewTooltip } from "./PreviewTooltip.js";
|
|
|
10
10
|
import { ToolbarButtonView } from "./ToolbarButton.js";
|
|
11
11
|
import "./ToolbarListButton.css";
|
|
12
12
|
const b = cn('toolbar-list-button');
|
|
13
|
-
export function ToolbarListButton({ className, editor, focus, onClick, icon, title, withArrow, data, alwaysActive, replaceActiveIcon, qa, qaMenu, qaActionDisabledPopover = 'g-md-toolbar-action-disabled-hint', }) {
|
|
13
|
+
export function ToolbarListButton({ className, editor, focus, onClick, icon, title, withArrow, data, alwaysActive, replaceActiveIcon, qa, qaMenu, qaActionDisabledPopover = 'g-md-toolbar-action-disabled-hint', disableHotkey, disablePreview, disableTooltip, }) {
|
|
14
14
|
const [anchorElement, setAnchorElement] = useElementState();
|
|
15
15
|
const [open, , hide, toggleOpen] = useBooleanState(false);
|
|
16
16
|
const [popupItem, setPopupItem] = useState();
|
|
@@ -40,7 +40,7 @@ export function ToolbarListButton({ className, editor, focus, onClick, icon, tit
|
|
|
40
40
|
setPopupItem(undefined);
|
|
41
41
|
else
|
|
42
42
|
toggleOpen();
|
|
43
|
-
}, children: buttonContent }), _jsx(Popup, { anchorElement: anchorElement, open: popupOpen, onOpenChange: hide, children: _jsx(Menu, { size: "l", className: b('menu'), qa: qaMenu, "data-toolbar-menu-for": titleText, children: data
|
|
43
|
+
}, disableTooltip: disableTooltip, children: buttonContent }), _jsx(Popup, { anchorElement: anchorElement, open: popupOpen, onOpenChange: hide, children: _jsx(Menu, { size: "l", className: b('menu'), qa: qaMenu, "data-toolbar-menu-for": titleText, children: data
|
|
44
44
|
.map((data) => {
|
|
45
45
|
const { id, title, icon, hotkey, isActive, isEnable, exec, hint, hintWhenDisabled, preview, } = data;
|
|
46
46
|
const titleText = isFunction(title) ? title() : title;
|
|
@@ -64,10 +64,10 @@ export function ToolbarListButton({ className, editor, focus, onClick, icon, tit
|
|
|
64
64
|
onClick?.(id);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
return (_jsx(Popover, { className: b('action-disabled-popover'), content: _jsx("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), placement: "left", modal: false, disabled: hideHintWhenDisabled, qa: qaActionDisabledPopover, children: (props, ref) => (_jsx(PreviewTooltip, { preview: preview, children: _jsx(Menu.Item, { ref: ref, active: isActive(editor), disabled: !isEnable(editor), onClick: handleClick, iconStart: _jsx(Icon, { data: icon.data, size: icon.size ?? 16 }), extraProps: {
|
|
67
|
+
return (_jsx(Popover, { className: b('action-disabled-popover'), content: _jsx("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), placement: "left", modal: false, disabled: hideHintWhenDisabled, qa: qaActionDisabledPopover, children: (props, ref) => (_jsx(PreviewTooltip, { preview: preview, disabled: disablePreview, children: _jsx(Menu.Item, { ref: ref, active: isActive(editor), disabled: !isEnable(editor), onClick: handleClick, iconStart: _jsx(Icon, { data: icon.data, size: icon.size ?? 16 }), extraProps: {
|
|
68
68
|
...props,
|
|
69
69
|
'aria-label': titleText,
|
|
70
|
-
}, children: _jsxs("div", { className: b('item'), children: [titleText, _jsxs("div", { className: b('extra'), children: [hotkey && _jsx(Hotkey, { value: hotkey }), hintText && (_jsx(HelpMark, { className: b('hint'), popoverProps: { modal: false }, children: hintText }))] })] }) }, id) })) }, id));
|
|
70
|
+
}, children: _jsxs("div", { className: b('item'), children: [titleText, !disableHotkey && (_jsxs("div", { className: b('extra'), children: [hotkey && _jsx(Hotkey, { value: hotkey }), hintText && (_jsx(HelpMark, { className: b('hint'), popoverProps: { modal: false }, children: hintText }))] }))] }) }, id) })) }, id));
|
|
71
71
|
})
|
|
72
72
|
.filter(Boolean) }) }), popupItem
|
|
73
73
|
? popupItem.renderPopup({
|