@gravity-ui/markdown-editor 15.8.0 → 15.9.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/MarkupEditorComponent.d.ts +2 -1
- package/build/cjs/bundle/MarkupEditorComponent.js +2 -2
- package/build/cjs/bundle/MarkupEditorComponent.js.map +1 -1
- package/build/cjs/bundle/MarkupEditorView.js +1 -1
- package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
- package/build/cjs/bundle/ToolbarView.d.ts +3 -2
- package/build/cjs/bundle/ToolbarView.js +2 -2
- package/build/cjs/bundle/ToolbarView.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorComponent.d.ts +2 -1
- package/build/cjs/bundle/WysiwygEditorComponent.js +2 -2
- package/build/cjs/bundle/WysiwygEditorComponent.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorView.js +1 -1
- package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
- package/build/cjs/bundle/settings/index.d.ts +2 -1
- package/build/cjs/bundle/settings/index.js +3 -3
- package/build/cjs/bundle/settings/index.js.map +1 -1
- package/build/cjs/extensions/behavior/CommandMenu/component.js +1 -1
- package/build/cjs/extensions/behavior/CommandMenu/component.js.map +1 -1
- package/build/cjs/extensions/behavior/SelectionContext/index.d.ts +12 -0
- package/build/cjs/extensions/behavior/SelectionContext/index.js +5 -4
- package/build/cjs/extensions/behavior/SelectionContext/index.js.map +1 -1
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.d.ts +11 -5
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.js +30 -32
- package/build/cjs/extensions/behavior/SelectionContext/tooltip.js.map +1 -1
- package/build/cjs/extensions/markdown/Link/PlaceholderWidget/widget.js +1 -1
- package/build/cjs/extensions/markdown/Link/PlaceholderWidget/widget.js.map +1 -1
- package/build/cjs/extensions/markdown/Superscript/SuperscriptSpecs/index.js +2 -2
- package/build/cjs/extensions/markdown/Superscript/SuperscriptSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/ImgSize/ImgSizeSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/ImgSize/ImgSizeSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/Monospace/MonospaceSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/Monospace/MonospaceSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/Video/VideoSpecs/index.js +2 -3
- package/build/cjs/extensions/yfm/Video/VideoSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/YfmTableSpecs/index.js +2 -2
- package/build/cjs/extensions/yfm/YfmTable/YfmTableSpecs/index.js.map +1 -1
- package/build/cjs/modules/toolbars/items.js +2 -1
- package/build/cjs/modules/toolbars/items.js.map +1 -1
- package/build/cjs/toolbar/FlexToolbar.js +1 -1
- package/build/cjs/toolbar/FlexToolbar.js.map +1 -1
- package/build/cjs/toolbar/ToolbarButton.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarButton.js +10 -8
- package/build/cjs/toolbar/ToolbarButton.js.map +1 -1
- package/build/cjs/toolbar/ToolbarListButton.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarListButton.js +2 -2
- package/build/cjs/toolbar/ToolbarListButton.js.map +1 -1
- package/build/cjs/toolbar/types.d.ts +3 -3
- 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/components/YfmHtml/YfmStaticView.d.ts +3 -4
- package/build/cjs/view/components/YfmHtml/YfmStaticView.js.map +1 -1
- package/build/esm/bundle/MarkupEditorComponent.d.ts +2 -1
- package/build/esm/bundle/MarkupEditorComponent.js +2 -2
- package/build/esm/bundle/MarkupEditorComponent.js.map +1 -1
- package/build/esm/bundle/MarkupEditorView.js +1 -1
- package/build/esm/bundle/MarkupEditorView.js.map +1 -1
- package/build/esm/bundle/ToolbarView.d.ts +3 -2
- package/build/esm/bundle/ToolbarView.js +2 -2
- package/build/esm/bundle/ToolbarView.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorComponent.d.ts +2 -1
- package/build/esm/bundle/WysiwygEditorComponent.js +2 -2
- package/build/esm/bundle/WysiwygEditorComponent.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorView.js +1 -1
- package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
- package/build/esm/bundle/settings/index.d.ts +2 -1
- package/build/esm/bundle/settings/index.js +3 -3
- package/build/esm/bundle/settings/index.js.map +1 -1
- package/build/esm/extensions/behavior/CommandMenu/component.js +1 -1
- package/build/esm/extensions/behavior/CommandMenu/component.js.map +1 -1
- package/build/esm/extensions/behavior/SelectionContext/index.d.ts +12 -0
- package/build/esm/extensions/behavior/SelectionContext/index.js +5 -4
- package/build/esm/extensions/behavior/SelectionContext/index.js.map +1 -1
- package/build/esm/extensions/behavior/SelectionContext/tooltip.d.ts +11 -5
- package/build/esm/extensions/behavior/SelectionContext/tooltip.js +30 -32
- package/build/esm/extensions/behavior/SelectionContext/tooltip.js.map +1 -1
- package/build/esm/extensions/markdown/Link/PlaceholderWidget/widget.js +1 -1
- package/build/esm/extensions/markdown/Link/PlaceholderWidget/widget.js.map +1 -1
- package/build/esm/extensions/markdown/Superscript/SuperscriptSpecs/index.js +1 -1
- package/build/esm/extensions/markdown/Superscript/SuperscriptSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/ImgSize/ImgSizeSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/ImgSize/ImgSizeSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/Monospace/MonospaceSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/Monospace/MonospaceSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/Video/VideoSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/Video/VideoSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/YfmTableSpecs/index.js +1 -1
- package/build/esm/extensions/yfm/YfmTable/YfmTableSpecs/index.js.map +1 -1
- package/build/esm/modules/toolbars/items.js +2 -1
- package/build/esm/modules/toolbars/items.js.map +1 -1
- package/build/esm/toolbar/FlexToolbar.js +1 -1
- package/build/esm/toolbar/FlexToolbar.js.map +1 -1
- package/build/esm/toolbar/ToolbarButton.d.ts +1 -1
- package/build/esm/toolbar/ToolbarButton.js +10 -8
- package/build/esm/toolbar/ToolbarButton.js.map +1 -1
- package/build/esm/toolbar/ToolbarListButton.d.ts +1 -1
- package/build/esm/toolbar/ToolbarListButton.js +2 -2
- package/build/esm/toolbar/ToolbarListButton.js.map +1 -1
- package/build/esm/toolbar/types.d.ts +3 -3
- 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/components/YfmHtml/YfmStaticView.d.ts +3 -4
- package/build/esm/view/components/YfmHtml/YfmStaticView.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
3
|
-
export const MarkupEditorComponent = function MarkupEditorComponent({ editor, autofocus, className, children }) {
|
|
3
|
+
export const MarkupEditorComponent = function MarkupEditorComponent({ editor, autofocus, className, children, qa }) {
|
|
4
4
|
const ref = useRef(null);
|
|
5
5
|
// insert editor to dom
|
|
6
6
|
useLayoutEffect(() => {
|
|
@@ -21,7 +21,7 @@ export const MarkupEditorComponent = function MarkupEditorComponent({ editor, au
|
|
|
21
21
|
}, [editor.markupEditor]);
|
|
22
22
|
return (
|
|
23
23
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
24
|
-
_jsx("div", { ref: ref, className: className, onClick: (event) => {
|
|
24
|
+
_jsx("div", { "data-qa": qa, ref: ref, className: className, onClick: (event) => {
|
|
25
25
|
const target = event.target;
|
|
26
26
|
if (target instanceof Element && target.classList.contains('cm-editor')) {
|
|
27
27
|
editor.markupEditor.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MarkupEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAazD,MAAM,CAAC,MAAM,qBAAqB,GAC9B,SAAS,qBAAqB,CAAC,EAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAC;IACvE,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzC,uBAAuB;IACvB,eAAe,CAAC,GAAG,EAAE;QACjB,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC;QAC3C,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACd,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,GAAG,EAAE;YACR,OAAO,CAAC,MAAM,EAAE,CAAC;QACrB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE1B,wCAAwC;IACxC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC;QACxC,IAAI,SAAS,EAAE,CAAC;YACZ,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAChC,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE1B,OAAO;IACH,0GAA0G;IAC1G,yBACa,EAAE,EACX,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACf,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAE5B,IAAI,MAAM,YAAY,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtE,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAChC,CAAC;QACL,CAAC,YAEA,QAAQ,GACP,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useEffect, useLayoutEffect, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport type {EditorInt} from './Editor';\n\nexport type MarkupEditorComponentProps = QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const MarkupEditorComponent: React.FC<MarkupEditorComponentProps> =\n function MarkupEditorComponent({editor, autofocus, className, children, qa}) {\n const ref = useRef<HTMLDivElement>(null);\n\n // insert editor to dom\n useLayoutEffect(() => {\n const domElem = editor.markupEditor.cm.dom;\n if (ref.current) {\n ref.current.appendChild(domElem);\n }\n return () => {\n domElem.remove();\n };\n }, [editor.markupEditor]);\n\n // update editor after connecting to dom\n useEffect(() => {\n editor.markupEditor.cm.requestMeasure();\n if (autofocus) {\n editor.markupEditor.focus();\n }\n }, [editor.markupEditor]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <div\n data-qa={qa}\n ref={ref}\n className={className}\n onClick={(event) => {\n const target = event.target;\n\n if (target instanceof Element && target.classList.contains('cm-editor')) {\n editor.markupEditor.focus();\n }\n }}\n >\n {children}\n </div>\n );\n };\n"]}
|
|
@@ -26,7 +26,7 @@ export const MarkupEditorView = memo((props) => {
|
|
|
26
26
|
return (_jsxs("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? (_jsx(MarkupToolbarContextProvider, { value: {
|
|
27
27
|
uploadHandler: editor.fileUploadHandler,
|
|
28
28
|
needToSetDimensionsForUploadedImages: editor.needToSetDimensionsForUploadedImages,
|
|
29
|
-
}, children: _jsx(ToolbarView, { editor: editor, editorMode: "markup", toolbarEditor: editor, hiddenActionsConfig: hiddenActionsConfig, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children }) })) : null, _jsx(MarkupEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor', { 'toolbar-visible': toolbarVisible }), children: _jsx(ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
29
|
+
}, children: _jsx(ToolbarView, { qa: "g-md-toolbar", editor: editor, editorMode: "markup", toolbarEditor: editor, hiddenActionsConfig: hiddenActionsConfig, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children }) })) : null, _jsx(MarkupEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor', { 'toolbar-visible': toolbarVisible }), children: _jsx(ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
30
30
|
});
|
|
31
31
|
MarkupEditorView.displayName = 'MarkdownMarkupEditorView';
|
|
32
32
|
//# sourceMappingURL=MarkupEditorView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAI3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AM,EACd,UAAU,EAAC,QAAQ,EACnB,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,GACa,CAClC,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,qBAAqB,IAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,iBAAiB,EAAE,cAAc,EAAC,CAAC,YAE3D,KAAC,sBAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACrC,IACtB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {MarkupEditorComponent} from './MarkupEditorComponent';\nimport {ToolbarView} from './ToolbarView';\nimport {MarkupToolbarContextProvider} from './toolbar/markup/context';\nimport type {MToolbarData, MToolbarItemData} from './toolbar/types';\nimport type {MarkdownEditorSplitMode} from './types';\n\nimport './MarkupEditorView.scss';\n\nconst b = cn('markup-editor');\n\nexport type MarkupEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n toolbarConfig: MToolbarData;\n settingsVisible?: boolean;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled: boolean;\n hiddenActionsConfig?: MToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const MarkupEditorView = memo<MarkupEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n });\n\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <MarkupToolbarContextProvider\n value={{\n uploadHandler: editor.fileUploadHandler,\n needToSetDimensionsForUploadedImages:\n editor.needToSetDimensionsForUploadedImages,\n }}\n >\n <ToolbarView\n editor={editor}\n editorMode=\"markup\"\n toolbarEditor={editor}\n hiddenActionsConfig={hiddenActionsConfig}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n </MarkupToolbarContextProvider>\n ) : null}\n <MarkupEditorComponent\n autofocus={autofocus}\n editor={editor}\n className={b('editor', {'toolbar-visible': toolbarVisible})}\n >\n <ReactRendererComponent storage={editor.renderStorage} />\n </MarkupEditorComponent>\n </div>\n );\n});\nMarkupEditorView.displayName = 'MarkdownMarkupEditorView';\n"]}
|
|
1
|
+
{"version":3,"file":"MarkupEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAI3B,OAAO,EAAsB,EAAE,EAAC,wBAAqB;AACrD,OAAO,EAAC,sBAAsB,EAAC,+BAAsB;AACrD,OAAO,EAAC,YAAY,EAAC,qBAAkB;AACvC,OAAO,EAAC,aAAa,EAAC,gCAA6B;A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AC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,GACa,CAClC,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,qBAAqB,IAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,iBAAiB,EAAE,cAAc,EAAC,CAAC,YAE3D,KAAC,sBAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACrC,IACtB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {MarkupEditorComponent} from './MarkupEditorComponent';\nimport {ToolbarView} from './ToolbarView';\nimport {MarkupToolbarContextProvider} from './toolbar/markup/context';\nimport type {MToolbarData, MToolbarItemData} from './toolbar/types';\nimport type {MarkdownEditorSplitMode} from './types';\n\nimport './MarkupEditorView.scss';\n\nconst b = cn('markup-editor');\n\nexport type MarkupEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n toolbarConfig: MToolbarData;\n settingsVisible?: boolean;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled: boolean;\n hiddenActionsConfig?: MToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const MarkupEditorView = memo<MarkupEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n });\n\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <MarkupToolbarContextProvider\n value={{\n uploadHandler: editor.fileUploadHandler,\n needToSetDimensionsForUploadedImages:\n editor.needToSetDimensionsForUploadedImages,\n }}\n >\n <ToolbarView\n qa=\"g-md-toolbar\"\n editor={editor}\n editorMode=\"markup\"\n toolbarEditor={editor}\n hiddenActionsConfig={hiddenActionsConfig}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n </MarkupToolbarContextProvider>\n ) : null}\n <MarkupEditorComponent\n autofocus={autofocus}\n editor={editor}\n className={b('editor', {'toolbar-visible': toolbarVisible})}\n >\n <ReactRendererComponent storage={editor.renderStorage} />\n </MarkupEditorComponent>\n </div>\n );\n});\nMarkupEditorView.displayName = 'MarkdownMarkupEditorView';\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import type { ClassNameProps } from "../classname.js";
|
|
2
3
|
import { type ToolbarData, type ToolbarItemData } from "../toolbar/index.js";
|
|
3
4
|
import type { EditorInt } from "./Editor.js";
|
|
4
5
|
import type { MarkdownEditorMode } from "./types.js";
|
|
5
|
-
export type ToolbarViewProps<T> = ClassNameProps & {
|
|
6
|
+
export type ToolbarViewProps<T> = ClassNameProps & QAProps & {
|
|
6
7
|
editor: EditorInt;
|
|
7
8
|
editorMode: MarkdownEditorMode;
|
|
8
9
|
toolbarEditor: T;
|
|
@@ -13,4 +14,4 @@ export type ToolbarViewProps<T> = ClassNameProps & {
|
|
|
13
14
|
children?: React.ReactNode;
|
|
14
15
|
stickyToolbar: boolean;
|
|
15
16
|
};
|
|
16
|
-
export declare function ToolbarView<T>({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, }: ToolbarViewProps<T>): JSX.Element;
|
|
17
|
+
export declare function ToolbarView<T>({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, qa, }: ToolbarViewProps<T>): JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { i18n } from "../i18n/menubar/index.js";
|
|
|
5
5
|
import { useSticky } from "../react-utils/useSticky.js";
|
|
6
6
|
import { FlexToolbar } from "../toolbar/index.js";
|
|
7
7
|
import { stickyCn } from "./sticky/index.js";
|
|
8
|
-
export function ToolbarView({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, }) {
|
|
8
|
+
export function ToolbarView({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, qa, }) {
|
|
9
9
|
const rerender = useUpdate();
|
|
10
10
|
useLayoutEffect(() => {
|
|
11
11
|
editor.on('rerender-toolbar', rerender);
|
|
@@ -15,7 +15,7 @@ export function ToolbarView({ editor, editorMode, toolbarEditor, toolbarFocus, t
|
|
|
15
15
|
}, [editor, rerender]);
|
|
16
16
|
const wrapperRef = useRef(null);
|
|
17
17
|
const isStickyActive = useSticky(wrapperRef) && stickyToolbar;
|
|
18
|
-
return (_jsxs("div", { ref: wrapperRef, className: stickyCn.toolbar({
|
|
18
|
+
return (_jsxs("div", { "data-qa": qa, ref: wrapperRef, className: stickyCn.toolbar({
|
|
19
19
|
withSettings: settingsVisible,
|
|
20
20
|
stickyActive: isStickyActive,
|
|
21
21
|
isSticky: stickyToolbar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarView.js","sourceRoot":"../../../src","sources":["bundle/ToolbarView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolbarView.js","sourceRoot":"../../../src","sources":["bundle/ToolbarView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAC,IAAI,EAAC,iCAAwB;AACrC,OAAO,EAAC,SAAS,EAAC,oCAAiC;AACnD,OAAO,EAAC,WAAW,EAAyC,4BAAmB;AAG/E,OAAO,EAAC,QAAQ,EAAC,0BAAiB;AAgBlC,MAAM,UAAU,WAAW,CAAI,EAC3B,MAAM,EACN,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,aAAa,EACb,EAAE,GACgB;IAClB,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;IAC7B,eAAe,CAAC,GAAG,EAAE;QACjB,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QACxC,OAAO,GAAG,EAAE;YACR,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvB,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,aAAa,CAAC;IAE9D,OAAO,CACH,0BACa,EAAE,EACX,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,QAAQ,CAAC,OAAO,CACvB;YACI,YAAY,EAAE,eAAe;YAC7B,YAAY,EAAE,cAAc;YAC5B,QAAQ,EAAE,aAAa;SAC1B,EACD,CAAC,SAAS,CAAC,CACd,aAED,KAAC,WAAW,IACR,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,mBAAmB,EAClC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,EAC9B,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAC,EAAE,EAAE,KAAK,EAAE,UAAU,EAAC,CAAC,GAChF,EACD,QAAQ,IACP,CACT,CAAC;AACN,CAAC","sourcesContent":["import {useLayoutEffect, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\nimport {useUpdate} from 'react-use';\n\nimport type {ClassNameProps} from '../classname';\nimport {i18n} from '../i18n/menubar';\nimport {useSticky} from '../react-utils/useSticky';\nimport {FlexToolbar, type ToolbarData, type ToolbarItemData} from '../toolbar';\n\nimport type {EditorInt} from './Editor';\nimport {stickyCn} from './sticky';\nimport type {MarkdownEditorMode} from './types';\n\nexport type ToolbarViewProps<T> = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n editorMode: MarkdownEditorMode;\n toolbarEditor: T;\n toolbarFocus: () => void;\n toolbarConfig: ToolbarData<T>;\n settingsVisible?: boolean;\n hiddenActionsConfig?: ToolbarItemData<T>[];\n children?: React.ReactNode;\n stickyToolbar: boolean;\n };\n\nexport function ToolbarView<T>({\n editor,\n editorMode,\n toolbarEditor,\n toolbarFocus,\n toolbarConfig,\n hiddenActionsConfig,\n settingsVisible,\n className,\n children,\n stickyToolbar,\n qa,\n}: ToolbarViewProps<T>) {\n const rerender = useUpdate();\n useLayoutEffect(() => {\n editor.on('rerender-toolbar', rerender);\n return () => {\n editor.off('rerender-toolbar', rerender);\n };\n }, [editor, rerender]);\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const isStickyActive = useSticky(wrapperRef) && stickyToolbar;\n\n return (\n <div\n data-qa={qa}\n ref={wrapperRef}\n className={stickyCn.toolbar(\n {\n withSettings: settingsVisible,\n stickyActive: isStickyActive,\n isSticky: stickyToolbar,\n },\n [className],\n )}\n >\n <FlexToolbar\n data={toolbarConfig}\n hiddenActions={hiddenActionsConfig}\n editor={toolbarEditor}\n focus={toolbarFocus}\n dotsTitle={i18n('more_action')}\n onClick={(id, attrs) => editor.emit('toolbar-action', {id, attrs, editorMode})}\n />\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
|
-
export const WysiwygEditorComponent = function WysiwygEditorComponent({ className, autofocus, editor, children }) {
|
|
3
|
+
export const WysiwygEditorComponent = function WysiwygEditorComponent({ className, autofocus, editor, children, qa }) {
|
|
4
4
|
const ref = useRef(null);
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
const { current } = ref;
|
|
@@ -11,6 +11,6 @@ export const WysiwygEditorComponent = function WysiwygEditorComponent({ classNam
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}, [editor]);
|
|
14
|
-
return (_jsx("div", { ref: ref, className: className, children: children }));
|
|
14
|
+
return (_jsx("div", { "data-qa": qa, ref: ref, className: className, children: children }));
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=WysiwygEditorComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WysiwygEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"WysiwygEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAaxC,MAAM,CAAC,MAAM,sBAAsB,GAC/B,SAAS,sBAAsB,CAAC,EAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAC;IACxE,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,EAAC,OAAO,EAAC,GAAG,GAAG,CAAC;QACtB,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAC9C,IAAI,SAAS,EAAE,CAAC;gBACZ,MAAM,CAAC,KAAK,EAAE,CAAC;YACnB,CAAC;QACL,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACH,yBAAc,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,YAC3C,QAAQ,GACP,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useEffect, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport type {EditorInt} from './Editor';\n\nexport type WysiwygEditorComponentProps = QAProps & {\n className?: string;\n autofocus?: boolean;\n editor: EditorInt;\n children?: React.ReactNode;\n};\n\nexport const WysiwygEditorComponent: React.FC<WysiwygEditorComponentProps> =\n function WysiwygEditorComponent({className, autofocus, editor, children, qa}) {\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const {current} = ref;\n if (current) {\n current.appendChild(editor.wysiwygEditor.dom);\n if (autofocus) {\n editor.focus();\n }\n }\n }, [editor]);\n\n return (\n <div data-qa={qa} ref={ref} className={className}>\n {children}\n </div>\n );\n };\n"]}
|
|
@@ -22,7 +22,7 @@ export const WysiwygEditorView = memo((props) => {
|
|
|
22
22
|
duration: time,
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
-
return (_jsxs("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? (_jsx(ToolbarView, { editor: editor, editorMode: "wysiwyg", toolbarEditor: editor, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), hiddenActionsConfig: hiddenActionsConfig, settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children })) : null, _jsx(WysiwygEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor'), children: _jsx(ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
25
|
+
return (_jsxs("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? (_jsx(ToolbarView, { qa: "g-md-toolbar", editor: editor, editorMode: "wysiwyg", toolbarEditor: editor, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), hiddenActionsConfig: hiddenActionsConfig, settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children })) : null, _jsx(WysiwygEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor'), children: _jsx(ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
26
26
|
});
|
|
27
27
|
WysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';
|
|
28
28
|
//# sourceMappingURL=WysiwygEditorView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WysiwygEditorView.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAI3B,OAAO,EAAsB,EAAE,EAAC,wBAAqB;AACrD,OAAO,EAAC,sBAAsB,EAAC,+BAAsB;AACrD,OAAO,EAAC,YAAY,EAAC,qBAAkB;AACvC,OAAO,EAAC,aAAa,EAAC,gCAA6B;AAGnD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAC1C,OAAO,EAAC,sBAAsB,EAAC,oCAAiC;AAGhE,iCAAkC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AAE,CAAC,CAAC,QAAQ,CAAC,YAChF,KAAC,sBAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACpC,IACvB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,iBAAiB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {ToolbarView} from './ToolbarView';\nimport {WysiwygEditorComponent} from './WysiwygEditorComponent';\nimport type {WToolbarData, WToolbarItemData} from './toolbar/types';\n\nimport './WysiwygEditorView.scss';\n\nconst b = cn('wysiwyg-editor');\n\nexport type WysiwygEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n settingsVisible?: boolean;\n toolbarConfig: WToolbarData;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n hiddenActionsConfig?: WToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const WysiwygEditorView = memo<WysiwygEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n });\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <ToolbarView\n editor={editor}\n editorMode=\"wysiwyg\"\n toolbarEditor={editor}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n hiddenActionsConfig={hiddenActionsConfig}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n ) : null}\n <WysiwygEditorComponent autofocus={autofocus} editor={editor} className={b('editor')}>\n <ReactRendererComponent storage={editor.renderStorage} />\n </WysiwygEditorComponent>\n </div>\n );\n});\nWysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';\n"]}
|
|
1
|
+
{"version":3,"file":"WysiwygEditorView.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAI3B,OAAO,EAAsB,EAAE,EAAC,wBAAqB;AACrD,OAAO,EAAC,sBAAsB,EAAC,+BAAsB;AACrD,OAAO,EAAC,YAAY,EAAC,qBAAkB;AACvC,OAAO,EAAC,aAAa,EAAC,gCAA6B;AAGnD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAC1C,OAAO,EAAC,sBAAsB,EAAC,oCAAiC;AAGhE,iCAAkC;AAElC,MAAM,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;AAe/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAyB,CAAC,KAAK,EAAE,EAAE;IACpE,MAAM,EACF,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,aAAa,GAAG,IAAI,GACvB,GAAG,KAAK,CAAC;IACV,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE;QACnB,YAAY,CAAC,OAAO,CAAC;YACjB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,CACH,eAAK,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,aAAW,EAAE,aACjE,cAAc,CAAC,CAAC,CAAC,CACd,KAAC,WAAW,IACR,EAAE,EAAC,cAAc,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAC,SAAS,EACpB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,CACjB,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,sBAAsB,IAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,YAChF,KAAC,sBAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACpC,IACvB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,iBAAiB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {ToolbarView} from './ToolbarView';\nimport {WysiwygEditorComponent} from './WysiwygEditorComponent';\nimport type {WToolbarData, WToolbarItemData} from './toolbar/types';\n\nimport './WysiwygEditorView.scss';\n\nconst b = cn('wysiwyg-editor');\n\nexport type WysiwygEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n settingsVisible?: boolean;\n toolbarConfig: WToolbarData;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n hiddenActionsConfig?: WToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const WysiwygEditorView = memo<WysiwygEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n });\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <ToolbarView\n qa=\"g-md-toolbar\"\n editor={editor}\n editorMode=\"wysiwyg\"\n toolbarEditor={editor}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n hiddenActionsConfig={hiddenActionsConfig}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n ) : null}\n <WysiwygEditorComponent autofocus={autofocus} editor={editor} className={b('editor')}>\n <ReactRendererComponent storage={editor.renderStorage} />\n </WysiwygEditorComponent>\n </div>\n );\n});\nWysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { type ClassNameProps } from "../../classname.js";
|
|
2
3
|
import type { MarkdownEditorMode, MarkdownEditorSplitMode } from "../types.js";
|
|
3
4
|
import "./index.css";
|
|
@@ -6,7 +7,7 @@ export type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
|
6
7
|
settingsVisible?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const EditorSettings: import("react").NamedExoticComponent<EditorSettingsProps>;
|
|
9
|
-
type SettingsContentProps = ClassNameProps & {
|
|
10
|
+
type SettingsContentProps = ClassNameProps & QAProps & {
|
|
10
11
|
mode: MarkdownEditorMode;
|
|
11
12
|
onClose: () => void;
|
|
12
13
|
onModeChange: (mode: MarkdownEditorMode) => void;
|
|
@@ -20,11 +20,11 @@ export const EditorSettings = memo(function EditorSettings(props) {
|
|
|
20
20
|
const { className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible } = props;
|
|
21
21
|
const [chevronElement, setChevronElement] = useState(null);
|
|
22
22
|
const [popupShown, , hidePopup, togglePopup] = useBooleanState(false);
|
|
23
|
-
return (_jsxs("div", { className: bSettings(null, [className]), children: [renderPreviewButton && (_jsxs(_Fragment, { children: [_jsx(ActionTooltip, { openDelay: ToolbarTooltipDelay.Open, closeDelay: ToolbarTooltipDelay.Close, title: i18n('preview_hint'), hotkey: "mod+shift+p", children: _jsx(Button, { qa: "g-md-markup-preview-button", size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange?.(!showPreview), selected: showPreview, children: _jsx(Icon, { data: Eye }) }) }), settingsVisible && _jsx("div", { className: bSettings('separator') })] })), settingsVisible && (_jsxs(_Fragment, { children: [_jsx(Button, { size: "m", view: "flat", pin: "round-round", onClick: togglePopup, ref: setChevronElement, qa: "g-md-settings-button", className: bSettings('dropdown-button'), children: _jsx(Icon, { data: Gear }) }), _jsx(Popup, { open: popupShown, anchorElement: chevronElement, placement: placement, onOpenChange: hidePopup, children: _jsx(SettingsContent, { ...props, onClose: hidePopup, className: bSettings('content') }) })] }))] }));
|
|
23
|
+
return (_jsxs("div", { className: bSettings(null, [className]), children: [renderPreviewButton && (_jsxs(_Fragment, { children: [_jsx(ActionTooltip, { openDelay: ToolbarTooltipDelay.Open, closeDelay: ToolbarTooltipDelay.Close, title: i18n('preview_hint'), hotkey: "mod+shift+p", children: _jsx(Button, { qa: "g-md-markup-preview-button", size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange?.(!showPreview), selected: showPreview, children: _jsx(Icon, { data: Eye }) }) }), settingsVisible && _jsx("div", { className: bSettings('separator') })] })), settingsVisible && (_jsxs(_Fragment, { children: [_jsx(Button, { size: "m", view: "flat", pin: "round-round", onClick: togglePopup, ref: setChevronElement, qa: "g-md-settings-button", className: bSettings('dropdown-button'), children: _jsx(Icon, { data: Gear }) }), _jsx(Popup, { open: popupShown, anchorElement: chevronElement, placement: placement, onOpenChange: hidePopup, children: _jsx(SettingsContent, { ...props, qa: "g-md-settings-content", onClose: hidePopup, className: bSettings('content') }) })] }))] }));
|
|
24
24
|
});
|
|
25
25
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
26
|
-
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
27
|
-
return (_jsxs("div", { className: bContent(null, [className]), "data-qa":
|
|
26
|
+
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, qa, }) {
|
|
27
|
+
return (_jsxs("div", { className: bContent(null, [className]), "data-qa": qa, children: [_jsxs(Menu, { size: "l", className: bContent('mode'), children: [_jsx(Menu.Item, { qa: "g-md-settings-mode-wysiwyg", active: mode === 'wysiwyg', onClick: () => {
|
|
28
28
|
onModeChange('wysiwyg');
|
|
29
29
|
onClose();
|
|
30
30
|
}, iconStart: _jsx(Icon, { data: WysiwygModeIcon }), children: i18n('settings_wysiwyg') }), _jsxs(Menu.Item, { qa: "g-md-settings-mode-markup", active: mode === 'markup', onClick: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["bundle/settings/index.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,0DAA0D;A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ACP,cAAK,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAI,EACxC,CAAC,WAAW,IAAI,CACb,eAAK,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,aAC/B,KAAC,QAAQ,IACL,IAAI,EAAC,GAAG,EACR,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,yBAAyB,YAElC,IAAI,CAAC,kBAAkB,CAAC,GAClB,EACX,cAAK,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,YAAG,IAAI,CAAC,eAAe,CAAC,GAAO,IACrE,CACT,EACA,SAAS,IAAI,CACV,eAAK,SAAS,EAAE,QAAQ,CAAC,YAAY,CAAC,aAClC,KAAC,QAAQ,IACL,IAAI,EAAC,GAAG,EACR,QAAQ,EAAE,IAAI,KAAK,QAAQ,EAC3B,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,iBAAiB,IAAI,IAAI,YAElC,IAAI,CAAC,qBAAqB,CAAC,GACrB,EACX,cAAK,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,YACnC,IAAI,CAAC,0BAA0B,CAAC,GAC/B,IACJ,CACT,EACD,eAAM,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,YAAG,OAAO,GAAQ,IACpD,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport {memo, useState} from 'react';\n\nimport {Eye, Gear, LogoMarkdown} from '@gravity-ui/icons';\nimport {\n ActionTooltip,\n Button,\n Checkbox,\n HelpMark,\n Icon,\n Menu,\n Popup,\n type PopupPlacement,\n} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../../classname';\nimport {i18n} from '../../i18n/bundle';\nimport WysiwygModeIcon from '../../icons/WysiwygMode';\nimport {noop} from '../../lodash';\nimport {useBooleanState} from '../../react-utils/hooks';\nimport {ToolbarTooltipDelay} from '../../toolbar';\nimport {VERSION} from '../../version';\nimport type {MarkdownEditorMode, MarkdownEditorSplitMode} from '../types';\n\nimport {MarkdownHints} from './MarkdownHints';\n\nimport './index.scss';\n\nconst placement: PopupPlacement = ['bottom-end', 'top-end'];\n\nconst bSettings = cn('editor-settings');\nconst bContent = cn('settings-content');\n\nexport type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {\n renderPreviewButton?: boolean;\n settingsVisible?: boolean;\n};\n\nexport const EditorSettings = memo<EditorSettingsProps>(function EditorSettings(props) {\n const {className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible} =\n props;\n const [chevronElement, setChevronElement] = useState<HTMLButtonElement | null>(null);\n const [popupShown, , hidePopup, togglePopup] = useBooleanState(false);\n\n return (\n <div className={bSettings(null, [className])}>\n {renderPreviewButton && (\n <>\n <ActionTooltip\n openDelay={ToolbarTooltipDelay.Open}\n closeDelay={ToolbarTooltipDelay.Close}\n title={i18n('preview_hint')}\n hotkey=\"mod+shift+p\"\n >\n <Button\n qa=\"g-md-markup-preview-button\"\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n className={bSettings('preview-button')}\n onClick={() => onShowPreviewChange?.(!showPreview)}\n selected={showPreview}\n >\n <Icon data={Eye} />\n </Button>\n </ActionTooltip>\n {settingsVisible && <div className={bSettings('separator')} />}\n </>\n )}\n {settingsVisible && (\n <>\n <Button\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n onClick={togglePopup}\n ref={setChevronElement}\n qa=\"g-md-settings-button\"\n className={bSettings('dropdown-button')}\n >\n <Icon data={Gear} />\n </Button>\n <Popup\n open={popupShown}\n anchorElement={chevronElement}\n placement={placement}\n onOpenChange={hidePopup}\n >\n <SettingsContent\n {...props}\n onClose={hidePopup}\n className={bSettings('content')}\n />\n </Popup>\n </>\n )}\n </div>\n );\n});\n\ntype SettingsContentProps = ClassNameProps & {\n mode: MarkdownEditorMode;\n onClose: () => void;\n onModeChange: (mode: MarkdownEditorMode) => void;\n onShowPreviewChange: (showPreview: boolean) => void;\n showPreview: boolean;\n toolbarVisibility: boolean;\n onToolbarVisibilityChange: (val: boolean) => void;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled?: boolean;\n onSplitModeChange?: (splitModeEnabled: boolean) => void;\n};\n\nconst mdHelpPlacement: PopupPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];\n\nconst SettingsContent: React.FC<SettingsContentProps> = function SettingsContent({\n mode,\n onClose,\n onModeChange,\n toolbarVisibility,\n onToolbarVisibilityChange,\n onSplitModeChange,\n splitMode = false,\n splitModeEnabled,\n className,\n showPreview,\n}) {\n return (\n <div className={bContent(null, [className])} data-qa=\"g-md-settings-content\">\n <Menu size=\"l\" className={bContent('mode')}>\n <Menu.Item\n qa=\"g-md-settings-mode-wysiwyg\"\n active={mode === 'wysiwyg'}\n onClick={() => {\n onModeChange('wysiwyg');\n onClose();\n }}\n iconStart={<Icon data={WysiwygModeIcon} />}\n >\n {i18n('settings_wysiwyg')}\n </Menu.Item>\n <Menu.Item\n qa=\"g-md-settings-mode-markup\"\n active={mode === 'markup'}\n onClick={() => {\n onModeChange('markup');\n onClose();\n }}\n iconStart={<Icon data={LogoMarkdown} />}\n >\n {i18n('settings_markup')}\n <HelpMark\n popoverProps={{\n placement: mdHelpPlacement,\n modal: false,\n }}\n className={bContent('mode-help')}\n >\n <div\n onClick={(e) => {\n // stop clicks propagation\n // because otherwise click in MarkdownHints handled as click on MenuItem\n e.stopPropagation();\n }}\n >\n <MarkdownHints />\n </div>\n </HelpMark>\n </Menu.Item>\n </Menu>\n <div className={bContent('separator')} />\n {!showPreview && (\n <div className={bContent('toolbar')}>\n <Checkbox\n size=\"m\"\n checked={toolbarVisibility}\n onUpdate={onToolbarVisibilityChange}\n >\n {i18n('settings_menubar')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>{i18n('settings_hint')}</div>\n </div>\n )}\n {splitMode && (\n <div className={bContent('split-mode')}>\n <Checkbox\n size=\"m\"\n disabled={mode !== 'markup'}\n checked={splitModeEnabled}\n onUpdate={onSplitModeChange ?? noop}\n >\n {i18n('settings_split-mode')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>\n {i18n('settings_split-mode-hint')}\n </div>\n </div>\n )}\n <span className={bContent('version')}>{VERSION}</span>\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["bundle/settings/index.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,0DAA0D;AAC1D,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACH,aAAa,EACb,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,KAAK,GAGR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAsB,EAAE,EAAC,2BAAwB;AACxD,OAAO,EAAC,IAAI,EAAC,mCAA0B;AACvC,OAAO,eAAe,mCAAgC;AACtD,OAAO,EAAC,IAAI,EAAC,wBAAqB;AAClC,OAAO,EAAC,eAAe,EAAC,mCAAgC;AACxD,OAAO,EAAC,mBAAmB,EAAC,+BAAsB;AAClD,OAAO,EAAC,OAAO,EAAC,yBAAsB;AAGtC,OAAO,EAAC,aAAa,EAAC,iCAAwB;AAE9C,qBAAsB;AAEtB,MAAM,SAAS,GAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE5D,MAAM,SAAS,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC;AAOxC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAsB,SAAS,cAAc,CAAC,KAAK;IACjF,MAAM,EAAC,SAAS,EAAE,mBAAmB,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAC,GACrF,KAAK,CAAC;IACV,MAA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IAAI,CAAC,iBAAiB,CAAC,EACxB,KAAC,QAAQ,IACL,YAAY,EAAE;oCACV,SAAS,EAAE,eAAe;oCAC1B,KAAK,EAAE,KAAK;iCACf,EACD,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,YAEhC,cACI,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;wCACX,0BAA0B;wCAC1B,wEAAwE;wCACxE,CAAC,CAAC,eAAe,EAAE,CAAC;oCACxB,CAAC,YAED,KAAC,aAAa,KAAG,GACf,GACC,IACH,IACT,EACP,cAAK,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAI,EACxC,CAAC,WAAW,IAAI,CACb,eAAK,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,aAC/B,KAAC,QAAQ,IACL,IAAI,EAAC,GAAG,EACR,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,yBAAyB,YAElC,IAAI,CAAC,kBAAkB,CAAC,GAClB,EACX,cAAK,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,YAAG,IAAI,CAAC,eAAe,CAAC,GAAO,IACrE,CACT,EACA,SAAS,IAAI,CACV,eAAK,SAAS,EAAE,QAAQ,CAAC,YAAY,CAAC,aAClC,KAAC,QAAQ,IACL,IAAI,EAAC,GAAG,EACR,QAAQ,EAAE,IAAI,KAAK,QAAQ,EAC3B,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,iBAAiB,IAAI,IAAI,YAElC,IAAI,CAAC,qBAAqB,CAAC,GACrB,EACX,cAAK,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,YACnC,IAAI,CAAC,0BAA0B,CAAC,GAC/B,IACJ,CACT,EACD,eAAM,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,YAAG,OAAO,GAAQ,IACpD,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport {memo, useState} from 'react';\n\nimport {Eye, Gear, LogoMarkdown} from '@gravity-ui/icons';\nimport {\n ActionTooltip,\n Button,\n Checkbox,\n HelpMark,\n Icon,\n Menu,\n Popup,\n type PopupPlacement,\n type QAProps,\n} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../../classname';\nimport {i18n} from '../../i18n/bundle';\nimport WysiwygModeIcon from '../../icons/WysiwygMode';\nimport {noop} from '../../lodash';\nimport {useBooleanState} from '../../react-utils/hooks';\nimport {ToolbarTooltipDelay} from '../../toolbar';\nimport {VERSION} from '../../version';\nimport type {MarkdownEditorMode, MarkdownEditorSplitMode} from '../types';\n\nimport {MarkdownHints} from './MarkdownHints';\n\nimport './index.scss';\n\nconst placement: PopupPlacement = ['bottom-end', 'top-end'];\n\nconst bSettings = cn('editor-settings');\nconst bContent = cn('settings-content');\n\nexport type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {\n renderPreviewButton?: boolean;\n settingsVisible?: boolean;\n};\n\nexport const EditorSettings = memo<EditorSettingsProps>(function EditorSettings(props) {\n const {className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible} =\n props;\n const [chevronElement, setChevronElement] = useState<HTMLButtonElement | null>(null);\n const [popupShown, , hidePopup, togglePopup] = useBooleanState(false);\n\n return (\n <div className={bSettings(null, [className])}>\n {renderPreviewButton && (\n <>\n <ActionTooltip\n openDelay={ToolbarTooltipDelay.Open}\n closeDelay={ToolbarTooltipDelay.Close}\n title={i18n('preview_hint')}\n hotkey=\"mod+shift+p\"\n >\n <Button\n qa=\"g-md-markup-preview-button\"\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n className={bSettings('preview-button')}\n onClick={() => onShowPreviewChange?.(!showPreview)}\n selected={showPreview}\n >\n <Icon data={Eye} />\n </Button>\n </ActionTooltip>\n {settingsVisible && <div className={bSettings('separator')} />}\n </>\n )}\n {settingsVisible && (\n <>\n <Button\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n onClick={togglePopup}\n ref={setChevronElement}\n qa=\"g-md-settings-button\"\n className={bSettings('dropdown-button')}\n >\n <Icon data={Gear} />\n </Button>\n <Popup\n open={popupShown}\n anchorElement={chevronElement}\n placement={placement}\n onOpenChange={hidePopup}\n >\n <SettingsContent\n {...props}\n qa=\"g-md-settings-content\"\n onClose={hidePopup}\n className={bSettings('content')}\n />\n </Popup>\n </>\n )}\n </div>\n );\n});\n\ntype SettingsContentProps = ClassNameProps &\n QAProps & {\n mode: MarkdownEditorMode;\n onClose: () => void;\n onModeChange: (mode: MarkdownEditorMode) => void;\n onShowPreviewChange: (showPreview: boolean) => void;\n showPreview: boolean;\n toolbarVisibility: boolean;\n onToolbarVisibilityChange: (val: boolean) => void;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled?: boolean;\n onSplitModeChange?: (splitModeEnabled: boolean) => void;\n };\n\nconst mdHelpPlacement: PopupPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];\n\nconst SettingsContent: React.FC<SettingsContentProps> = function SettingsContent({\n mode,\n onClose,\n onModeChange,\n toolbarVisibility,\n onToolbarVisibilityChange,\n onSplitModeChange,\n splitMode = false,\n splitModeEnabled,\n className,\n showPreview,\n qa,\n}) {\n return (\n <div className={bContent(null, [className])} data-qa={qa}>\n <Menu size=\"l\" className={bContent('mode')}>\n <Menu.Item\n qa=\"g-md-settings-mode-wysiwyg\"\n active={mode === 'wysiwyg'}\n onClick={() => {\n onModeChange('wysiwyg');\n onClose();\n }}\n iconStart={<Icon data={WysiwygModeIcon} />}\n >\n {i18n('settings_wysiwyg')}\n </Menu.Item>\n <Menu.Item\n qa=\"g-md-settings-mode-markup\"\n active={mode === 'markup'}\n onClick={() => {\n onModeChange('markup');\n onClose();\n }}\n iconStart={<Icon data={LogoMarkdown} />}\n >\n {i18n('settings_markup')}\n <HelpMark\n popoverProps={{\n placement: mdHelpPlacement,\n modal: false,\n }}\n className={bContent('mode-help')}\n >\n <div\n onClick={(e) => {\n // stop clicks propagation\n // because otherwise click in MarkdownHints handled as click on MenuItem\n e.stopPropagation();\n }}\n >\n <MarkdownHints />\n </div>\n </HelpMark>\n </Menu.Item>\n </Menu>\n <div className={bContent('separator')} />\n {!showPreview && (\n <div className={bContent('toolbar')}>\n <Checkbox\n size=\"m\"\n checked={toolbarVisibility}\n onUpdate={onToolbarVisibilityChange}\n >\n {i18n('settings_menubar')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>{i18n('settings_hint')}</div>\n </div>\n )}\n {splitMode && (\n <div className={bContent('split-mode')}>\n <Checkbox\n size=\"m\"\n disabled={mode !== 'markup'}\n checked={splitModeEnabled}\n onUpdate={onSplitModeChange ?? noop}\n >\n {i18n('settings_split-mode')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>\n {i18n('settings_split-mode-hint')}\n </div>\n </div>\n )}\n <span className={bContent('version')}>{VERSION}</span>\n </div>\n );\n};\n"]}
|
|
@@ -19,7 +19,7 @@ function calcListHeight(itemsCount) {
|
|
|
19
19
|
export const CommandMenuComponent = ({ anchorElement, currentIndex, items, onItemClick, onOpenChange, }) => {
|
|
20
20
|
if (!anchorElement)
|
|
21
21
|
return null;
|
|
22
|
-
return (_jsx(Popup, { open: true, anchorElement: anchorElement, placement: placement, onOpenChange: onOpenChange, children: _jsx("div", { className: b(), children: _jsx(List, { virtualized: true, items: items, sortable: false, filterable: false, emptyPlaceholder: i18n('empty-msg'), itemHeight: ITEM_HEIGHT, itemsHeight: calcListHeight(items.length), renderItem: renderItem, deactivateOnLeave: false, activeItemIndex: currentIndex, onItemClick: (_item, index) => onItemClick(index), className: b('list'), itemClassName: b('list-item') }) }) }));
|
|
22
|
+
return (_jsx(Popup, { open: true, anchorElement: anchorElement, placement: placement, onOpenChange: onOpenChange, qa: "g-md-command-menu", children: _jsx("div", { className: b(), children: _jsx(List, { virtualized: true, items: items, sortable: false, filterable: false, emptyPlaceholder: i18n('empty-msg'), itemHeight: ITEM_HEIGHT, itemsHeight: calcListHeight(items.length), renderItem: renderItem, deactivateOnLeave: false, activeItemIndex: currentIndex, onItemClick: (_item, index) => onItemClick(index), className: b('list'), itemClassName: b('list-item') }) }) }));
|
|
23
23
|
};
|
|
24
24
|
function renderItem({ id, title, icon, hotkey, hint, preview }) {
|
|
25
25
|
const titleText = isFunction(title) ? title() : title;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/CommandMenu/component.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAsB,MAAM,mBAAmB,CAAC;AAE3F,OAAO,EAAC,EAAE,EAAC,8BAA2B;AACtC,OAAO,EAAC,IAAI,EAAC,uCAA8B;AAC3C,OAAO,EAAC,UAAU,EAAC,2BAAwB;AAC3C,OAAO,EAAC,mBAAmB,EAAC,8CAA2C;AACvE,OAAO,EAAC,cAAc,EAAC,2CAAwC;AAK/D,yBAA0B;AAE1B,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC;AAC7B,MAAM,SAAS,GAAmB,CAAC,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;AAEzF,MAAM,WAAW,GAAG,EAAE,CAAC,CAAC,KAAK;AAC7B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,eAAe,GAAG,WAAW,GAAG,mBAAmB,CAAC,CAAC,KAAK;AAChE,SAAS,cAAc,CAAC,UAAkB;IACtC,IAAI,UAAU,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC;AAC/D,CAAC;AAaD,MAAM,CAAC,MAAM,oBAAoB,GAAwC,CAAC,EACtE,aAAa,EACb,YAAY,EACZ,KAAK,EACL,WAAW,EACX,YAAY,GACf,EAAE,EAAE;IACD,IAAI,CAAC,aAAa;QAAE,OAA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,GAAQ,EACpD,eAAK,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,aAC1B,MAAM,IAAI,KAAC,MAAM,IAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,GAAI,EAChE,QAAQ,IAAI,KAAC,QAAQ,IAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,YAAG,QAAQ,GAAY,IACrE,IACJ,KARA,EAAE,CASN,GACO,CACpB,CAAC;AACN,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAgC;IACnD,OAAO,CACH,KAAC,mBAAmB,cAChB,KAAC,oBAAoB,OAAK,KAAK,GAAI,GACjB,CACzB,CAAC;AACN,CAAC","sourcesContent":["import {HelpMark, Hotkey, Icon, List, Popup, type PopupPlacement} from '@gravity-ui/uikit';\n\nimport {cn} from '../../../classname';\nimport {i18n} from '../../../i18n/suggest';\nimport {isFunction} from '../../../lodash';\nimport {ErrorLoggerBoundary} from '../../../react-utils/ErrorBoundary';\nimport {PreviewTooltip} from '../../../toolbar/PreviewTooltip';\nimport type {AutocompletePopupProps} from '../../../utils/autocomplete-popup';\n\nimport type {CommandAction} from './types';\n\nimport './component.scss';\n\nconst b = cn('command-menu');\nconst placement: PopupPlacement = ['bottom-start', 'top-start', 'bottom-end', 'top-end'];\n\nconst ITEM_HEIGHT = 28; // px\nconst VISIBLE_ITEMS_COUNT = 10;\nconst MAX_LIST_HEIGHT = ITEM_HEIGHT * VISIBLE_ITEMS_COUNT; // px\nfunction calcListHeight(itemsCount: number): number | undefined {\n if (itemsCount <= 0) return undefined;\n return Math.min(MAX_LIST_HEIGHT, itemsCount * ITEM_HEIGHT);\n}\n\nexport type CommandMenuItem = Pick<\n CommandAction,\n 'id' | 'title' | 'icon' | 'hotkey' | 'hint' | 'preview'\n>;\n\nexport type CommandMenuComponentProps = AutocompletePopupProps & {\n currentIndex?: number;\n items: readonly CommandMenuItem[];\n onItemClick(itemIndex: number): void;\n};\n\nexport const CommandMenuComponent: React.FC<CommandMenuComponentProps> = ({\n anchorElement,\n currentIndex,\n items,\n onItemClick,\n onOpenChange,\n}) => {\n if (!anchorElement) return null;\n\n return (\n <Popup\n open\n anchorElement={anchorElement}\n placement={placement}\n onOpenChange={onOpenChange}\n qa=\"g-md-command-menu\"\n >\n <div className={b()}>\n <List<CommandMenuItem>\n virtualized\n items={items as CommandMenuItem[]}\n sortable={false}\n filterable={false}\n emptyPlaceholder={i18n('empty-msg')}\n itemHeight={ITEM_HEIGHT}\n itemsHeight={calcListHeight(items.length)}\n renderItem={renderItem}\n deactivateOnLeave={false}\n activeItemIndex={currentIndex}\n onItemClick={(_item, index) => onItemClick(index)}\n className={b('list')}\n itemClassName={b('list-item')}\n />\n </div>\n </Popup>\n );\n};\n\nfunction renderItem({id, title, icon, hotkey, hint, preview}: CommandMenuItem): React.ReactNode {\n const titleText = isFunction(title) ? title() : title;\n const hintText = isFunction(hint) ? hint() : hint;\n\n return (\n <PreviewTooltip preview={preview}>\n <div key={id} className={b('item', {id})}>\n <Icon data={icon.data} size={20} className={b('item-icon')} />\n <div className={b('item-body')}>\n <span className={b('item-title')}>{titleText}</span>\n <div className={b('item-extra')}>\n {hotkey && <Hotkey value={hotkey} className={b('item-hotkey')} />}\n {hintText && <HelpMark className={b('item-hint')}>{hintText}</HelpMark>}\n </div>\n </div>\n </div>\n </PreviewTooltip>\n );\n}\n\nexport function render(props: CommandMenuComponentProps): React.ReactNode {\n return (\n <ErrorLoggerBoundary>\n <CommandMenuComponent {...props} />\n </ErrorLoggerBoundary>\n );\n}\n"]}
|
|
@@ -3,5 +3,17 @@ import { type ContextConfig } from "./tooltip.js";
|
|
|
3
3
|
export type { ContextConfig as SelectionContextConfig, ContextGroupItemData as SelectionContextItemData, } from "./tooltip.js";
|
|
4
4
|
export type SelectionContextOptions = {
|
|
5
5
|
config?: ContextConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Placement of context popup
|
|
8
|
+
*
|
|
9
|
+
* @default 'bottom'
|
|
10
|
+
*/
|
|
11
|
+
placement?: 'top' | 'bottom';
|
|
12
|
+
/**
|
|
13
|
+
* Prevents context popup from overflowing
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
flip?: boolean;
|
|
6
18
|
};
|
|
7
19
|
export declare const SelectionContext: ExtensionAuto<SelectionContextOptions>;
|
|
@@ -2,9 +2,10 @@ import { keydownHandler } from 'prosemirror-keymap';
|
|
|
2
2
|
import { AllSelection, Plugin, TextSelection, } from 'prosemirror-state';
|
|
3
3
|
import { isCodeBlock } from "../../../utils/nodes.js";
|
|
4
4
|
import { TooltipView } from "./tooltip.js";
|
|
5
|
-
export const SelectionContext = (builder,
|
|
5
|
+
export const SelectionContext = (builder, opts) => {
|
|
6
|
+
const { config } = opts;
|
|
6
7
|
if (Array.isArray(config) && config.length > 0) {
|
|
7
|
-
builder.addPlugin(({ actions }) => new Plugin(new SelectionTooltip(actions, config, builder.logger)));
|
|
8
|
+
builder.addPlugin(({ actions }) => new Plugin(new SelectionTooltip(actions, config, builder.logger, opts)));
|
|
8
9
|
}
|
|
9
10
|
};
|
|
10
11
|
class SelectionTooltip {
|
|
@@ -12,8 +13,8 @@ class SelectionTooltip {
|
|
|
12
13
|
tooltip;
|
|
13
14
|
hideTimeoutRef = null;
|
|
14
15
|
_isMousePressed = false;
|
|
15
|
-
constructor(actions, menuConfig, logger) {
|
|
16
|
-
this.tooltip = new TooltipView(actions, menuConfig, logger);
|
|
16
|
+
constructor(actions, menuConfig, logger, options) {
|
|
17
|
+
this.tooltip = new TooltipView(actions, menuConfig, logger, options);
|
|
17
18
|
}
|
|
18
19
|
get props() {
|
|
19
20
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACH,YAAY,EAEZ,MAAM,EAEN,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAC,WAAW,EAAC,gCAA6B;AAEjD,OAAO,EAAqB,WAAW,EAAC,qBAAkB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["extensions/behavior/SelectionContext/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACH,YAAY,EAEZ,MAAM,EAEN,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAC,WAAW,EAAC,gCAA6B;AAEjD,OAAO,EAAqB,WAAW,EAAC,qBAAkB;AAuB1D,MAAM,CAAC,MAAM,gBAAgB,GAA2C,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IACtF,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;IACtB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,OAAO,CAAC,SAAS,CACb,CAAC,EAAC,OAAO,EAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CACzF,CAAC;IACN,CAAC;AACL,CAAC,CAAC;AAIF,MAAM,gBAAgB;IACV,SAAS,GAAG,KAAK,CAAC;IAElB,OAAO,CAAc;IACrB,cAAc,GAAyC,IAAI,CAAC;IAE5D,eAAe,GAAG,KAAK,CAAC;IAEhC,YACI,OAAsB,EACtB,UAAyB,EACzB,MAAuB,EACvB,OAAgC;QAEhC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,KAAK;QACL,OAAO;YACH,qBAAqB;YACrB,aAAa,EAAE,c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EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACpC,IAAI,MAAM,KAAK,YAAY;oBAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAClE,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAEO,qBAAqB,CAAC,IAAgB;QAC1C,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,GAAG,EAAE;YAClC,mDAAmD;YACnD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;IAEO,mBAAmB;QACvB,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YAC/B,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import {keydownHandler} from 'prosemirror-keymap';\nimport {\n AllSelection,\n type EditorState,\n Plugin,\n type PluginSpec,\n TextSelection,\n} from 'prosemirror-state';\nimport type {EditorProps, EditorView} from 'prosemirror-view';\n\nimport type {ActionStorage, ExtensionAuto} from '../../../core';\nimport type {Logger2} from '../../../logger';\nimport {isCodeBlock} from '../../../utils/nodes';\n\nimport {type ContextConfig, TooltipView} from './tooltip';\n\nexport type {\n ContextConfig as SelectionContextConfig,\n ContextGroupItemData as SelectionContextItemData,\n} from './tooltip';\n\nexport type SelectionContextOptions = {\n config?: ContextConfig;\n /**\n * Placement of context popup\n *\n * @default 'bottom'\n */\n placement?: 'top' | 'bottom';\n /**\n * Prevents context popup from overflowing\n *\n * @default false\n */\n flip?: boolean;\n};\n\nexport const SelectionContext: ExtensionAuto<SelectionContextOptions> = (builder, opts) => {\n const {config} = opts;\n if (Array.isArray(config) && config.length > 0) {\n builder.addPlugin(\n ({actions}) => new Plugin(new SelectionTooltip(actions, config, builder.logger, opts)),\n );\n }\n};\n\ntype TinyState = Pick<EditorState, 'doc' | 'selection'>;\n\nclass SelectionTooltip implements PluginSpec<unknown> {\n private destroyed = false;\n\n private tooltip: TooltipView;\n private hideTimeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n private _isMousePressed = false;\n\n constructor(\n actions: ActionStorage,\n menuConfig: ContextConfig,\n logger: Logger2.ILogger,\n options: SelectionContextOptions,\n ) {\n this.tooltip = new TooltipView(actions, menuConfig, logger, options);\n }\n\n get props(): EditorProps {\n return {\n // same as keymap({})\n handleKeyDown: keydownHandler({\n // hide context menu when Esc was pressed\n Escape: (_state, _dispatch, view) => {\n if (this.tooltip.isTooltipOpen) {\n this.tooltip.hide(view!);\n return true;\n }\n return false;\n },\n }),\n handleDOMEvents: {\n mousedown: (view) => {\n const startState: TinyState = {\n doc: view.state.doc,\n selection: view.state.selection,\n };\n this._isMousePressed = true;\n this.cancelTooltipHiding();\n this.tooltip.hide(view);\n\n const onMouseUp = () => {\n if (this.destroyed) return;\n this._isMousePressed = false;\n this.update(view, startState);\n };\n\n document.addEventListener('mouseup', onMouseUp, {once: true});\n },\n },\n };\n }\n\n view(view: EditorView) {\n this.update(view);\n return {\n update: this.update.bind(this),\n destroy: () => {\n this.destroyed = true;\n this.cancelTooltipHiding();\n this.tooltip.destroy();\n },\n };\n }\n\n private update(view: EditorView, prevState?: TinyState) {\n if (this._isMousePressed) return;\n\n this.cancelTooltipHiding();\n\n // Don't show tooltip if editor not mounted to the DOM\n // or when view is out of focus\n if (!view.dom.parentNode || !view.hasFocus()) {\n this.tooltip.hide(view);\n return;\n }\n\n const {state} = view;\n // Don't do anything if the document/selection didn't change\n if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection))\n return;\n\n const {selection} = state;\n // Hide the tooltip if the selection is empty\n if (\n selection.empty ||\n !(selection instanceof TextSelection || selection instanceof AllSelection)\n ) {\n this.tooltip.hide(view);\n return;\n }\n\n // Hide the tooltip when one side of selection inside codeblock\n if (isCodeBlock(selection.$from.parent) || isCodeBlock(selection.$to.parent)) {\n this.tooltip.hide(view);\n return;\n }\n\n this.tooltip.show(view, {\n onOpenChange: (_open, _event, reason) => {\n if (reason !== 'escape-key') this.scheduleTooltipHiding(view);\n },\n });\n }\n\n private scheduleTooltipHiding(view: EditorView) {\n this.hideTimeoutRef = setTimeout(() => {\n // hide tooltip if view is out of focus after 30 ms\n if (!view.hasFocus()) {\n this.tooltip.hide(view);\n }\n }, 30);\n }\n\n private cancelTooltipHiding() {\n if (this.hideTimeoutRef !== null) {\n clearTimeout(this.hideTimeoutRef);\n this.hideTimeoutRef = null;\n }\n }\n}\n"]}
|
|
@@ -11,15 +11,22 @@ export type ContextGroupItemData = (ToolbarGroupItemData<ActionStorage> & {
|
|
|
11
11
|
});
|
|
12
12
|
export type ContextGroupData = ContextGroupItemData[];
|
|
13
13
|
export type ContextConfig = ContextGroupData[];
|
|
14
|
+
export type TooltipViewParams = {
|
|
15
|
+
/** @default 'bottom' */
|
|
16
|
+
placement?: 'top' | 'bottom';
|
|
17
|
+
/** @default false */
|
|
18
|
+
flip?: boolean;
|
|
19
|
+
};
|
|
14
20
|
export declare class TooltipView {
|
|
15
21
|
#private;
|
|
16
|
-
private logger;
|
|
17
|
-
private actions;
|
|
18
|
-
private menuConfig;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
private readonly actions;
|
|
24
|
+
private readonly menuConfig;
|
|
25
|
+
private readonly placement;
|
|
19
26
|
private view;
|
|
20
27
|
private baseProps;
|
|
21
28
|
private _tooltipRenderItem;
|
|
22
|
-
constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger);
|
|
29
|
+
constructor(actions: ActionStorage, menuConfig: ContextConfig, logger: Logger2.ILogger, params: TooltipViewParams);
|
|
23
30
|
get isTooltipOpen(): boolean;
|
|
24
31
|
show(view: EditorView, popupProps?: PopupProps): void;
|
|
25
32
|
hide(view: EditorView): void;
|
|
@@ -29,5 +36,4 @@ export declare class TooltipView {
|
|
|
29
36
|
private renderPopup;
|
|
30
37
|
private get tooltipRenderItem();
|
|
31
38
|
private calcPosition;
|
|
32
|
-
private get popupTextOffset();
|
|
33
39
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { offset, shift } from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
2
|
import { Popup } from '@gravity-ui/uikit';
|
|
4
3
|
import { isFunction } from "../../../lodash.js";
|
|
5
4
|
import { globalLogger } from "../../../logger.js";
|
|
@@ -16,13 +15,16 @@ export class TooltipView {
|
|
|
16
15
|
logger;
|
|
17
16
|
actions;
|
|
18
17
|
menuConfig;
|
|
18
|
+
placement;
|
|
19
19
|
view;
|
|
20
20
|
baseProps = { show: false, poppupProps: {} };
|
|
21
21
|
_tooltipRenderItem = null;
|
|
22
|
-
constructor(actions, menuConfig, logger) {
|
|
22
|
+
constructor(actions, menuConfig, logger, params) {
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
this.actions = actions;
|
|
25
25
|
this.menuConfig = menuConfig;
|
|
26
|
+
const { flip, placement = 'bottom' } = params;
|
|
27
|
+
this.placement = flip ? placement : [placement];
|
|
26
28
|
}
|
|
27
29
|
get isTooltipOpen() {
|
|
28
30
|
return this.#isTooltipOpen;
|
|
@@ -88,38 +90,34 @@ export class TooltipView {
|
|
|
88
90
|
return this._tooltipRenderItem;
|
|
89
91
|
}
|
|
90
92
|
calcPosition(view) {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
const virtualElem = {
|
|
94
|
+
getBoundingClientRect() {
|
|
95
|
+
// These are in screen coordinates
|
|
96
|
+
const start = view.coordsAtPos(view.state.selection.from);
|
|
97
|
+
const end = view.coordsAtPos(view.state.selection.to);
|
|
98
|
+
// Find a center-ish x position from the selection endpoints (when
|
|
99
|
+
// crossing lines, end may be more to the left)
|
|
100
|
+
const yCenter = Math.max((start.left + end.left) / 2, start.left + 3);
|
|
101
|
+
const top = start.top;
|
|
102
|
+
const left = yCenter - 1;
|
|
103
|
+
const width = 2;
|
|
104
|
+
const height = end.bottom - start.top;
|
|
105
|
+
return {
|
|
106
|
+
top,
|
|
107
|
+
left,
|
|
108
|
+
right: left + width,
|
|
109
|
+
bottom: top + height,
|
|
110
|
+
y: top,
|
|
111
|
+
x: left,
|
|
112
|
+
height,
|
|
113
|
+
width,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
104
117
|
return {
|
|
105
|
-
placement:
|
|
106
|
-
anchorElement:
|
|
107
|
-
// override floating middlewares
|
|
108
|
-
floatingMiddlewares: [
|
|
109
|
-
offset({
|
|
110
|
-
mainAxis: bottomOffset,
|
|
111
|
-
crossAxis: leftOffset,
|
|
112
|
-
}),
|
|
113
|
-
shift({
|
|
114
|
-
mainAxis: true,
|
|
115
|
-
crossAxis: false,
|
|
116
|
-
padding: 4,
|
|
117
|
-
}),
|
|
118
|
-
],
|
|
118
|
+
placement: this.placement,
|
|
119
|
+
anchorElement: virtualElem,
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
|
-
get popupTextOffset() {
|
|
122
|
-
return 4; // 4px offset from text selection
|
|
123
|
-
}
|
|
124
122
|
}
|
|
125
123
|
//# sourceMappingURL=tooltip.js.map
|