@gravity-ui/markdown-editor 15.34.5 → 15.35.1
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/MarkupEditorView.js +1 -1
- package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
- package/build/cjs/bundle/ToolbarView.d.ts +1 -2
- package/build/cjs/bundle/ToolbarView.js +22 -10
- package/build/cjs/bundle/ToolbarView.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorView.d.ts +1 -1
- package/build/cjs/bundle/WysiwygEditorView.js +4 -4
- package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
- package/build/cjs/bundle/config/markup.js +1 -0
- package/build/cjs/bundle/config/markup.js.map +1 -1
- package/build/cjs/bundle/config/wysiwyg.js +2 -0
- package/build/cjs/bundle/config/wysiwyg.js.map +1 -1
- package/build/cjs/bundle/emoji.js +3 -0
- package/build/cjs/bundle/emoji.js.map +1 -1
- package/build/cjs/bundle/toolbar/wysiwyg/WToolbarColors.js +36 -2
- package/build/cjs/bundle/toolbar/wysiwyg/WToolbarColors.js.map +1 -1
- package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js +11 -7
- package/build/cjs/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js.map +1 -1
- package/build/cjs/extensions/additional/Mermaid/index.d.ts +5 -0
- package/build/cjs/extensions/additional/Mermaid/index.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/commands.d.ts +1 -0
- package/build/cjs/extensions/markdown/Lists/commands.js +14 -0
- package/build/cjs/extensions/markdown/Lists/commands.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/index.js +1 -0
- package/build/cjs/extensions/markdown/Lists/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.d.ts +27 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js +81 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js.map +1 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +33 -0
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
- package/build/cjs/modules/toolbars/items.js +2 -0
- package/build/cjs/modules/toolbars/items.js.map +1 -1
- package/build/cjs/modules/toolbars/types.d.ts +1 -0
- package/build/cjs/modules/toolbars/types.js.map +1 -1
- package/build/cjs/react-utils/memo.d.ts +1 -0
- package/build/cjs/react-utils/memo.js +8 -0
- package/build/cjs/react-utils/memo.js.map +1 -0
- package/build/cjs/styles/markdown.css +1 -1
- package/build/cjs/styles/styles.css +5 -0
- package/build/cjs/styles/yfm-overrides.css +1 -1
- package/build/cjs/toolbar/Toolbar.d.ts +4 -0
- package/build/cjs/toolbar/Toolbar.js +9 -4
- package/build/cjs/toolbar/Toolbar.js.map +1 -1
- package/build/cjs/toolbar/ToolbarButton.js +3 -3
- package/build/cjs/toolbar/ToolbarButton.js.map +1 -1
- package/build/cjs/toolbar/ToolbarButtonPopup.js +3 -3
- package/build/cjs/toolbar/ToolbarButtonPopup.js.map +1 -1
- package/build/cjs/toolbar/ToolbarGroup.js +5 -4
- package/build/cjs/toolbar/ToolbarGroup.js.map +1 -1
- package/build/cjs/toolbar/ToolbarListButton.js +9 -6
- package/build/cjs/toolbar/ToolbarListButton.js.map +1 -1
- package/build/cjs/toolbar/ToolbarRerender.d.ts +3 -0
- package/build/cjs/toolbar/ToolbarRerender.js +48 -0
- package/build/cjs/toolbar/ToolbarRerender.js.map +1 -0
- package/build/cjs/toolbar/context.d.ts +10 -0
- package/build/cjs/toolbar/context.js +12 -0
- package/build/cjs/toolbar/context.js.map +1 -0
- package/build/cjs/toolbar/hooks.d.ts +8 -0
- package/build/cjs/toolbar/hooks.js +68 -0
- package/build/cjs/toolbar/hooks.js.map +1 -0
- package/build/cjs/toolbar/index.d.ts +1 -0
- package/build/cjs/toolbar/index.js +4 -0
- package/build/cjs/toolbar/index.js.map +1 -1
- package/build/cjs/toolbar/types.d.ts +1 -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/hocs/withMermaid/index.js +6 -1
- package/build/cjs/view/hocs/withMermaid/index.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 +1 -2
- package/build/esm/bundle/ToolbarView.js +24 -12
- package/build/esm/bundle/ToolbarView.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorView.d.ts +1 -1
- package/build/esm/bundle/WysiwygEditorView.js +3 -4
- package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
- package/build/esm/bundle/config/markup.js +1 -0
- package/build/esm/bundle/config/markup.js.map +1 -1
- package/build/esm/bundle/config/wysiwyg.js +2 -0
- package/build/esm/bundle/config/wysiwyg.js.map +1 -1
- package/build/esm/bundle/emoji.js +3 -0
- package/build/esm/bundle/emoji.js.map +1 -1
- package/build/esm/bundle/toolbar/wysiwyg/WToolbarColors.js +36 -2
- package/build/esm/bundle/toolbar/wysiwyg/WToolbarColors.js.map +1 -1
- package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js +11 -7
- package/build/esm/extensions/additional/Mermaid/MermaidNodeView/MermaidView.js.map +1 -1
- package/build/esm/extensions/additional/Mermaid/index.d.ts +5 -0
- package/build/esm/extensions/additional/Mermaid/index.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/commands.d.ts +1 -0
- package/build/esm/extensions/markdown/Lists/commands.js +13 -0
- package/build/esm/extensions/markdown/Lists/commands.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/index.js +2 -1
- package/build/esm/extensions/markdown/Lists/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.d.ts +27 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js +77 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js.map +1 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +33 -0
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
- package/build/esm/modules/toolbars/items.js +2 -0
- package/build/esm/modules/toolbars/items.js.map +1 -1
- package/build/esm/modules/toolbars/types.d.ts +1 -0
- package/build/esm/modules/toolbars/types.js.map +1 -1
- package/build/esm/react-utils/memo.d.ts +1 -0
- package/build/esm/react-utils/memo.js +5 -0
- package/build/esm/react-utils/memo.js.map +1 -0
- package/build/esm/styles/markdown.css +1 -1
- package/build/esm/styles/styles.css +5 -0
- package/build/esm/styles/yfm-overrides.css +1 -1
- package/build/esm/toolbar/Toolbar.d.ts +4 -0
- package/build/esm/toolbar/Toolbar.js +9 -4
- package/build/esm/toolbar/Toolbar.js.map +1 -1
- package/build/esm/toolbar/ToolbarButton.js +3 -3
- package/build/esm/toolbar/ToolbarButton.js.map +1 -1
- package/build/esm/toolbar/ToolbarButtonPopup.js +3 -3
- package/build/esm/toolbar/ToolbarButtonPopup.js.map +1 -1
- package/build/esm/toolbar/ToolbarGroup.js +5 -4
- package/build/esm/toolbar/ToolbarGroup.js.map +1 -1
- package/build/esm/toolbar/ToolbarListButton.js +9 -6
- package/build/esm/toolbar/ToolbarListButton.js.map +1 -1
- package/build/esm/toolbar/ToolbarRerender.d.ts +3 -0
- package/build/esm/toolbar/ToolbarRerender.js +44 -0
- package/build/esm/toolbar/ToolbarRerender.js.map +1 -0
- package/build/esm/toolbar/context.d.ts +10 -0
- package/build/esm/toolbar/context.js +8 -0
- package/build/esm/toolbar/context.js.map +1 -0
- package/build/esm/toolbar/hooks.d.ts +8 -0
- package/build/esm/toolbar/hooks.js +64 -0
- package/build/esm/toolbar/hooks.js.map +1 -0
- package/build/esm/toolbar/index.d.ts +1 -0
- package/build/esm/toolbar/index.js +1 -0
- package/build/esm/toolbar/index.js.map +1 -1
- package/build/esm/toolbar/types.d.ts +1 -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/hocs/withMermaid/index.js +6 -1
- package/build/esm/view/hocs/withMermaid/index.js.map +1 -1
- package/build/styles.css +7 -2
- package/package.json +17 -79
- package/README.md +0 -89
|
@@ -13,6 +13,7 @@ const react_utils_1 = require("../react-utils/index.js");
|
|
|
13
13
|
const hooks_1 = require("../react-utils/hooks.js");
|
|
14
14
|
const PreviewTooltip_1 = require("./PreviewTooltip.js");
|
|
15
15
|
const ToolbarButton_1 = require("./ToolbarButton.js");
|
|
16
|
+
const hooks_2 = require("./hooks.js");
|
|
16
17
|
require("./ToolbarListButton.css");
|
|
17
18
|
const b = (0, classname_1.cn)('toolbar-list-button');
|
|
18
19
|
function ToolbarListButton({ className, editor, focus, onClick, icon, title, withArrow, data, alwaysActive, replaceActiveIcon, qa, qaMenu, qaActionDisabledPopover = 'g-md-toolbar-action-disabled-hint', disableHotkey, disablePreview, disableTooltip, }) {
|
|
@@ -20,7 +21,8 @@ function ToolbarListButton({ className, editor, focus, onClick, icon, title, wit
|
|
|
20
21
|
const [open, , hide, toggleOpen] = (0, hooks_1.useBooleanState)(false);
|
|
21
22
|
const [popupItem, setPopupItem] = (0, react_1.useState)();
|
|
22
23
|
const zIndex = (0, react_utils_1.useTargetZIndex)(layout_1.LAYOUT.STICKY_TOOLBAR);
|
|
23
|
-
const
|
|
24
|
+
const actionsState = (0, hooks_2.useActionsState)(editor, data);
|
|
25
|
+
const everyDisabled = alwaysActive ? false : actionsState.every((item) => !item.enabled);
|
|
24
26
|
const popupOpen = everyDisabled ? false : open;
|
|
25
27
|
const shouldForceHide = open && !popupOpen;
|
|
26
28
|
(0, react_1.useEffect)(() => {
|
|
@@ -30,7 +32,7 @@ function ToolbarListButton({ className, editor, focus, onClick, icon, title, wit
|
|
|
30
32
|
}, [hide, shouldForceHide]);
|
|
31
33
|
if (data.length === 0)
|
|
32
34
|
return null;
|
|
33
|
-
const activeItem = data.find((item) =>
|
|
35
|
+
const activeItem = data.find((item, idx) => actionsState[idx].active && !item.doNotActivateList);
|
|
34
36
|
const someActive = alwaysActive ? false : Boolean(activeItem);
|
|
35
37
|
if (replaceActiveIcon && someActive && activeItem) {
|
|
36
38
|
icon = activeItem.icon;
|
|
@@ -47,11 +49,12 @@ function ToolbarListButton({ className, editor, focus, onClick, icon, title, wit
|
|
|
47
49
|
else
|
|
48
50
|
toggleOpen();
|
|
49
51
|
}, disableTooltip: disableTooltip || popupOpen, children: buttonContent }), (0, jsx_runtime_1.jsx)(uikit_1.Popup, { anchorElement: anchorElement, open: popupOpen, onOpenChange: hide, zIndex: typeof zIndex === 'number' ? zIndex : undefined, children: (0, jsx_runtime_1.jsx)(uikit_1.Menu, { size: "l", className: b('menu'), qa: qaMenu, "data-toolbar-menu-for": titleText, children: data
|
|
50
|
-
.map((data) => {
|
|
51
|
-
const { id, title, icon, hotkey,
|
|
52
|
+
.map((data, idx) => {
|
|
53
|
+
const { id, title, icon, hotkey, exec, hint, hintWhenDisabled, preview } = data;
|
|
52
54
|
const titleText = (0, lodash_1.isFunction)(title) ? title() : title;
|
|
53
55
|
const hintText = (0, lodash_1.isFunction)(hint) ? hint() : hint;
|
|
54
|
-
const
|
|
56
|
+
const actionState = actionsState[idx];
|
|
57
|
+
const disabled = !actionState.enabled;
|
|
55
58
|
const hideHintWhenDisabled = hintWhenDisabled === false || !disabled;
|
|
56
59
|
const hintWhenDisabledText = typeof hintWhenDisabled === 'string'
|
|
57
60
|
? hintWhenDisabled
|
|
@@ -70,7 +73,7 @@ function ToolbarListButton({ className, editor, focus, onClick, icon, title, wit
|
|
|
70
73
|
onClick?.(id);
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(uikit_1.Popover, { className: b('action-disabled-popover'), content: (0, jsx_runtime_1.jsx)("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), placement: "left", modal: false, disabled: hideHintWhenDisabled, qa: qaActionDisabledPopover, children: (props, ref) => ((0, jsx_runtime_1.jsx)(PreviewTooltip_1.PreviewTooltip, { preview: preview, disabled: disablePreview, children: (0, jsx_runtime_1.jsx)(uikit_1.Menu.Item, { ref: ref, active:
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(uikit_1.Popover, { className: b('action-disabled-popover'), content: (0, jsx_runtime_1.jsx)("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), placement: "left", modal: false, disabled: hideHintWhenDisabled, qa: qaActionDisabledPopover, children: (props, ref) => ((0, jsx_runtime_1.jsx)(PreviewTooltip_1.PreviewTooltip, { preview: preview, disabled: disablePreview, children: (0, jsx_runtime_1.jsx)(uikit_1.Menu.Item, { ref: ref, active: actionState.active, disabled: disabled, onClick: handleClick, iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icon.data, size: icon.size ?? 16 }), extraProps: {
|
|
74
77
|
...props,
|
|
75
78
|
'aria-label': titleText,
|
|
76
79
|
}, children: (0, jsx_runtime_1.jsxs)("div", { className: b('item'), children: [titleText, !disableHotkey && ((0, jsx_runtime_1.jsxs)("div", { className: b('extra'), children: [hotkey && (0, jsx_runtime_1.jsx)(uikit_1.Hotkey, { value: hotkey }), hintText && ((0, jsx_runtime_1.jsx)(uikit_1.HelpMark, { className: b('hint'), popoverProps: { modal: false }, children: hintText }))] }))] }) }, id) })) }, id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarListButton.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarListButton.tsx"],"names":[],"mappings":";;AAkCA,8CAqLC;;AAvND,iCAAoD;AAEpD,6CAA8C;AAC9C,6CAA+E;AAE/E,gDAAyC;AAEzC,+CAAgC;AAChC,oDAAo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AAC,CAAC,OAAO,CAAC,aACrB,MAAM,IAAI,uBAAC,cAAM,IAAC,KAAK,EAAE,MAAM,GAAI,EACnC,QAAQ,IAAI,CACT,uBAAC,gBAAQ,IACL,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EACpB,YAAY,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,YAE3B,QAAQ,GACF,CACd,IACC,CACT,IACC,IA5BD,EAAE,CA6BC,GACC,CACpB,IApCI,EAAE,CAqCD,CACb,CAAC;oBACN,CAAC,CAAC;yBACD,MAAM,CAAC,OAAO,CAAC,GACjB,GACH,EACP,SAAS;gBACN,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;oBAClB,GAAG,SAAS;oBACZ,MAAM;oBACN,KAAK;oBACL,OAAO;oBACP,aAAa;oBACb,IAAI,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC;iBACtC,CAAC;gBACJ,CAAC,CAAC,IAAI,IACX,CACN,CAAC;AACN,CAAC;AAED,SAAS,WAAW,CAAI,IAAwB;IAC5C,OAAO,OAAO,CAAE,IAAkC,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import {Fragment, useEffect, useState} from 'react';\n\nimport {ChevronDown} from '@gravity-ui/icons';\nimport {HelpMark, Hotkey, Icon, Menu, Popover, Popup} from '@gravity-ui/uikit';\n\nimport {LAYOUT} from 'src/common/layout';\n\nimport {cn} from '../classname';\nimport {i18n} from '../i18n/common';\nimport {isFunction} from '../lodash';\nimport {useTargetZIndex} from '../react-utils';\nimport {useBooleanState, useElementState} from '../react-utils/hooks';\n\nimport {PreviewTooltip} from './PreviewTooltip';\nimport {ToolbarButtonView} from './ToolbarButton';\nimport type {\n ToolbarBaseProps,\n ToolbarButtonPopupData,\n ToolbarItemData,\n ToolbarListButtonData,\n} from './types';\n\nimport './ToolbarListButton.scss';\n\nconst b = cn('toolbar-list-button');\n\nexport type {ToolbarListButtonData};\n\nexport type ToolbarListButtonProps<E> = ToolbarBaseProps<E> &\n ToolbarListButtonData<E> & {\n qaMenu?: string;\n qaActionDisabledPopover?: string;\n };\n\nexport function ToolbarListButton<E>({\n className,\n editor,\n focus,\n onClick,\n icon,\n title,\n withArrow,\n data,\n alwaysActive,\n replaceActiveIcon,\n qa,\n qaMenu,\n qaActionDisabledPopover = 'g-md-toolbar-action-disabled-hint',\n disableHotkey,\n disablePreview,\n disableTooltip,\n}: ToolbarListButtonProps<E>) {\n const [anchorElement, setAnchorElement] = useElementState();\n const [open, , hide, toggleOpen] = useBooleanState(false);\n const [popupItem, setPopupItem] = useState<ToolbarButtonPopupData<E>>();\n const zIndex = useTargetZIndex(LAYOUT.STICKY_TOOLBAR);\n\n const everyDisabled = alwaysActive ? false : data.every((item) => !item.isEnable(editor));\n const popupOpen = everyDisabled ? false : open;\n const shouldForceHide = open && !popupOpen;\n\n useEffect(() => {\n if (shouldForceHide) {\n hide();\n }\n }, [hide, shouldForceHide]);\n\n if (data.length === 0) return null;\n\n const activeItem = data.find((item) => item.isActive(editor) && !item.doNotActivateList);\n const someActive = alwaysActive ? false : Boolean(activeItem);\n\n if (replaceActiveIcon && someActive && activeItem) {\n icon = activeItem.icon;\n }\n\n const buttonContent = [<Icon key={1} data={icon.data} size={icon.size ?? 16} />];\n if (withArrow) {\n buttonContent.push(<Fragment key={2}>{''}</Fragment>);\n buttonContent.push(<Icon key={3} data={ChevronDown} size={16} />);\n }\n const titleText: string = isFunction(title) ? title() : title;\n\n return (\n <>\n <ToolbarButtonView\n qa={qa}\n ref={setAnchorElement}\n active={someActive}\n enabled={!everyDisabled}\n title={title}\n className={b({arrow: withArrow}, [className])}\n onClick={() => {\n if (popupItem) setPopupItem(undefined);\n else toggleOpen();\n }}\n disableTooltip={disableTooltip || popupOpen}\n >\n {buttonContent}\n </ToolbarButtonView>\n <Popup\n anchorElement={anchorElement}\n open={popupOpen}\n onOpenChange={hide}\n zIndex={typeof zIndex === 'number' ? zIndex : undefined}\n >\n <Menu size=\"l\" className={b('menu')} qa={qaMenu} data-toolbar-menu-for={titleText}>\n {data\n .map((data) => {\n const {\n id,\n title,\n icon,\n hotkey,\n isActive,\n isEnable,\n exec,\n hint,\n hintWhenDisabled,\n preview,\n } = data;\n\n const titleText = isFunction(title) ? title() : title;\n const hintText = isFunction(hint) ? hint() : hint;\n\n const disabled = !isEnable(editor);\n\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 const handleClick = () => {\n hide();\n\n if (isPopupItem(data)) {\n setPopupItem(data);\n } else {\n setPopupItem(undefined);\n focus();\n exec(editor);\n onClick?.(id);\n }\n };\n\n return (\n <Popover\n className={b('action-disabled-popover')}\n content={\n <div className={b('action-disabled-tooltip')}>\n {hintWhenDisabledText}\n </div>\n }\n placement=\"left\"\n modal={false}\n disabled={hideHintWhenDisabled}\n qa={qaActionDisabledPopover}\n key={id}\n >\n {(props, ref) => (\n <PreviewTooltip preview={preview} disabled={disablePreview}>\n <Menu.Item\n key={id}\n ref={ref}\n active={isActive(editor)}\n disabled={!isEnable(editor)}\n onClick={handleClick}\n iconStart={\n <Icon data={icon.data} size={icon.size ?? 16} />\n }\n extraProps={{\n ...props,\n 'aria-label': titleText,\n }}\n >\n <div className={b('item')}>\n {titleText}\n {!disableHotkey && (\n <div className={b('extra')}>\n {hotkey && <Hotkey value={hotkey} />}\n {hintText && (\n <HelpMark\n className={b('hint')}\n popoverProps={{modal: false}}\n >\n {hintText}\n </HelpMark>\n )}\n </div>\n )}\n </div>\n </Menu.Item>\n </PreviewTooltip>\n )}\n </Popover>\n );\n })\n .filter(Boolean)}\n </Menu>\n </Popup>\n {popupItem\n ? popupItem.renderPopup({\n ...popupItem,\n editor,\n focus,\n onClick,\n anchorElement,\n hide: () => setPopupItem(undefined),\n })\n : null}\n </>\n );\n}\n\nfunction isPopupItem<E>(item: ToolbarItemData<E>): item is ToolbarButtonPopupData<E> {\n return Boolean((item as ToolbarButtonPopupData<E>).renderPopup);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ToolbarListButton.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarListButton.tsx"],"names":[],"mappings":";;AAmCA,8CAgLC;;AAnND,iCAAoD;AAEpD,6CAA8C;AAC9C,6CAA+E;AAE/E,gDAAyC;AAEzC,+CAAgC;AAChC,oDAAoC;AACpC,yCAAqC;AACrC,yDAA+C;AAC/C,mDAAsE;AAEtE,wDAAgD;AAChD,sDAAkD;AAClD,sCAAwC;AAQxC,mCAAkC;AAElC,MAAM,CAAC,GAAG,IAAA,cAAE,EAAC,qBAAqB,CAAC,CAAC;AAUpC,SAAgB,iBAAiB,CAAI,EACjC,SAAS,EACT,MAAM,EACN,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,iBAAiB,EACjB,EAAE,EACF,MAAM,EACN,uBAAuB,GAAG,mCAAmC,EAC7D,aAAa,EACb,cAAc,EACd,cAAc,GACU;IACxB,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,uBAAe,GAAE,CAAC;IAC5D,MAAM,CAAC,IAAI,EAAE,AAAD,EAAG,IAAI,EAAE,UAAU,CAAC,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,GAA6B,CAAC;IACxE,MAAM,MAAM,GAAG,IAAA,6BAAe,EAAC,eAAM,CAAC,cAAc,CAAC,CAAC;IAEtD,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnD,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,C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R,MAAM,EAAE,WAAW,CAAC,MAAM,EAC1B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,WAAW,EACpB,SAAS,EACL,uBAAC,YAAI,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,GAAI,EAEpD,UAAU,EAAE;wCACR,GAAG,KAAK;wCACR,YAAY,EAAE,SAAS;qCAC1B,YAED,iCAAK,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,aACpB,SAAS,EACT,CAAC,aAAa,IAAI,CACf,iCAAK,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,aACrB,MAAM,IAAI,uBAAC,cAAM,IAAC,KAAK,EAAE,MAAM,GAAI,EACnC,QAAQ,IAAI,CACT,uBAAC,gBAAQ,IACL,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EACpB,YAAY,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,YAE3B,QAAQ,GACF,CACd,IACC,CACT,IACC,IA5BD,EAAE,CA6BC,GACC,CACpB,IApCI,EAAE,CAqCD,CACb,CAAC;oBACN,CAAC,CAAC;yBACD,MAAM,CAAC,OAAO,CAAC,GACjB,GACH,EACP,SAAS;gBACN,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;oBAClB,GAAG,SAAS;oBACZ,MAAM;oBACN,KAAK;oBACL,OAAO;oBACP,aAAa;oBACb,IAAI,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC;iBACtC,CAAC;gBACJ,CAAC,CAAC,IAAI,IACX,CACN,CAAC;AACN,CAAC;AAED,SAAS,WAAW,CAAI,IAAwB;IAC5C,OAAO,OAAO,CAAE,IAAkC,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import {Fragment, useEffect, useState} from 'react';\n\nimport {ChevronDown} from '@gravity-ui/icons';\nimport {HelpMark, Hotkey, Icon, Menu, Popover, Popup} from '@gravity-ui/uikit';\n\nimport {LAYOUT} from 'src/common/layout';\n\nimport {cn} from '../classname';\nimport {i18n} from '../i18n/common';\nimport {isFunction} from '../lodash';\nimport {useTargetZIndex} from '../react-utils';\nimport {useBooleanState, useElementState} from '../react-utils/hooks';\n\nimport {PreviewTooltip} from './PreviewTooltip';\nimport {ToolbarButtonView} from './ToolbarButton';\nimport {useActionsState} from './hooks';\nimport type {\n ToolbarBaseProps,\n ToolbarButtonPopupData,\n ToolbarItemData,\n ToolbarListButtonData,\n} from './types';\n\nimport './ToolbarListButton.scss';\n\nconst b = cn('toolbar-list-button');\n\nexport type {ToolbarListButtonData};\n\nexport type ToolbarListButtonProps<E> = ToolbarBaseProps<E> &\n ToolbarListButtonData<E> & {\n qaMenu?: string;\n qaActionDisabledPopover?: string;\n };\n\nexport function ToolbarListButton<E>({\n className,\n editor,\n focus,\n onClick,\n icon,\n title,\n withArrow,\n data,\n alwaysActive,\n replaceActiveIcon,\n qa,\n qaMenu,\n qaActionDisabledPopover = 'g-md-toolbar-action-disabled-hint',\n disableHotkey,\n disablePreview,\n disableTooltip,\n}: ToolbarListButtonProps<E>) {\n const [anchorElement, setAnchorElement] = useElementState();\n const [open, , hide, toggleOpen] = useBooleanState(false);\n const [popupItem, setPopupItem] = useState<ToolbarButtonPopupData<E>>();\n const zIndex = useTargetZIndex(LAYOUT.STICKY_TOOLBAR);\n\n const actionsState = useActionsState(editor, data);\n\n const everyDisabled = alwaysActive ? false : actionsState.every((item) => !item.enabled);\n const popupOpen = everyDisabled ? false : open;\n const shouldForceHide = open && !popupOpen;\n\n useEffect(() => {\n if (shouldForceHide) {\n hide();\n }\n }, [hide, shouldForceHide]);\n\n if (data.length === 0) return null;\n\n const activeItem = data.find(\n (item, idx) => actionsState[idx].active && !item.doNotActivateList,\n );\n const someActive = alwaysActive ? false : Boolean(activeItem);\n\n if (replaceActiveIcon && someActive && activeItem) {\n icon = activeItem.icon;\n }\n\n const buttonContent = [<Icon key={1} data={icon.data} size={icon.size ?? 16} />];\n if (withArrow) {\n buttonContent.push(<Fragment key={2}>{''}</Fragment>);\n buttonContent.push(<Icon key={3} data={ChevronDown} size={16} />);\n }\n const titleText: string = isFunction(title) ? title() : title;\n\n return (\n <>\n <ToolbarButtonView\n qa={qa}\n ref={setAnchorElement}\n active={someActive}\n enabled={!everyDisabled}\n title={title}\n className={b({arrow: withArrow}, [className])}\n onClick={() => {\n if (popupItem) setPopupItem(undefined);\n else toggleOpen();\n }}\n disableTooltip={disableTooltip || popupOpen}\n >\n {buttonContent}\n </ToolbarButtonView>\n <Popup\n anchorElement={anchorElement}\n open={popupOpen}\n onOpenChange={hide}\n zIndex={typeof zIndex === 'number' ? zIndex : undefined}\n >\n <Menu size=\"l\" className={b('menu')} qa={qaMenu} data-toolbar-menu-for={titleText}>\n {data\n .map((data, idx) => {\n const {id, title, icon, hotkey, exec, hint, hintWhenDisabled, preview} =\n data;\n\n const titleText = isFunction(title) ? title() : title;\n const hintText = isFunction(hint) ? hint() : hint;\n\n const actionState = actionsState[idx];\n const disabled = !actionState.enabled;\n\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 const handleClick = () => {\n hide();\n\n if (isPopupItem(data)) {\n setPopupItem(data);\n } else {\n setPopupItem(undefined);\n focus();\n exec(editor);\n onClick?.(id);\n }\n };\n\n return (\n <Popover\n className={b('action-disabled-popover')}\n content={\n <div className={b('action-disabled-tooltip')}>\n {hintWhenDisabledText}\n </div>\n }\n placement=\"left\"\n modal={false}\n disabled={hideHintWhenDisabled}\n qa={qaActionDisabledPopover}\n key={id}\n >\n {(props, ref) => (\n <PreviewTooltip preview={preview} disabled={disablePreview}>\n <Menu.Item\n key={id}\n ref={ref}\n active={actionState.active}\n disabled={disabled}\n onClick={handleClick}\n iconStart={\n <Icon data={icon.data} size={icon.size ?? 16} />\n }\n extraProps={{\n ...props,\n 'aria-label': titleText,\n }}\n >\n <div className={b('item')}>\n {titleText}\n {!disableHotkey && (\n <div className={b('extra')}>\n {hotkey && <Hotkey value={hotkey} />}\n {hintText && (\n <HelpMark\n className={b('hint')}\n popoverProps={{modal: false}}\n >\n {hintText}\n </HelpMark>\n )}\n </div>\n )}\n </div>\n </Menu.Item>\n </PreviewTooltip>\n )}\n </Popover>\n );\n })\n .filter(Boolean)}\n </Menu>\n </Popup>\n {popupItem\n ? popupItem.renderPopup({\n ...popupItem,\n editor,\n focus,\n onClick,\n anchorElement,\n hide: () => setPopupItem(undefined),\n })\n : null}\n </>\n );\n}\n\nfunction isPopupItem<E>(item: ToolbarItemData<E>): item is ToolbarButtonPopupData<E> {\n return Boolean((item as ToolbarButtonPopupData<E>).renderPopup);\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolbarUpdateOnRerender = ToolbarUpdateOnRerender;
|
|
4
|
+
exports.ToolbarWrapToContext = ToolbarWrapToContext;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_use_1 = require("react-use");
|
|
8
|
+
const utils_1 = require("../utils/index.js");
|
|
9
|
+
const context_1 = require("./context.js");
|
|
10
|
+
/**
|
|
11
|
+
Rerender the content when an update event is received in the event bus from the context.
|
|
12
|
+
@internal
|
|
13
|
+
*/
|
|
14
|
+
// TODO [major]: Always expect the toolbar to be wrapped in context; remove this component as unnecessary.
|
|
15
|
+
function ToolbarUpdateOnRerender({ content }) {
|
|
16
|
+
const rerender = (0, react_use_1.useUpdate)();
|
|
17
|
+
const context = (0, context_1.useToolbarContext)();
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
if (!context)
|
|
20
|
+
return undefined;
|
|
21
|
+
context.eventBus.on('update', rerender);
|
|
22
|
+
return () => {
|
|
23
|
+
context.eventBus.off('update', rerender);
|
|
24
|
+
};
|
|
25
|
+
}, [context, rerender]);
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: content() });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
If there is no external context, wraps the content in the toolbar context
|
|
30
|
+
and emits an update event on each component re-render.
|
|
31
|
+
@internal
|
|
32
|
+
*/
|
|
33
|
+
// TODO [major]: Always expect the toolbar to be wrapped in context; remove this component as unnecessary.
|
|
34
|
+
function ToolbarWrapToContext({ editor, children }) {
|
|
35
|
+
const outerContext = (0, context_1.useToolbarContext)();
|
|
36
|
+
const innerContext = (0, react_1.useMemo)(() => {
|
|
37
|
+
if (outerContext)
|
|
38
|
+
return undefined;
|
|
39
|
+
const eventBus = new utils_1.EventEmitter();
|
|
40
|
+
return { editor, eventBus };
|
|
41
|
+
}, [editor, outerContext]);
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
innerContext?.eventBus.emit('update', null);
|
|
44
|
+
});
|
|
45
|
+
// wrapping in inner context only if there is no outer context
|
|
46
|
+
return innerContext ? ((0, jsx_runtime_1.jsx)(context_1.ToolbarProvider, { value: innerContext, children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ToolbarRerender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarRerender.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarRerender.tsx"],"names":[],"mappings":";;AAsBA,0DAaC;AAYD,oDAkBC;;AAjED,iCAAiE;AAEjE,yCAAoC;AAEpC,6CAAuC;AAEvC,0CAKmB;AAMnB;;;GAGG;AACH,0GAA0G;AAC1G,SAAgB,uBAAuB,CAAC,EAAC,OAAO,EAA8B;IAC1E,MAAM,QAAQ,GAAG,IAAA,qBAAS,GAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAA,2B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ils';\n\nimport {\n type ToolbarContextValue,\n type ToolbarEvents,\n ToolbarProvider,\n useToolbarContext,\n} from './context';\n\nexport type ToolbarRerenderWrapperProps = {\n content: () => React.ReactNode;\n};\n\n/**\n Rerender the content when an update event is received in the event bus from the context.\n @internal\n */\n// TODO [major]: Always expect the toolbar to be wrapped in context; remove this component as unnecessary.\nexport function ToolbarUpdateOnRerender({content}: ToolbarRerenderWrapperProps) {\n const rerender = useUpdate();\n const context = useToolbarContext();\n\n useEffect(() => {\n if (!context) return undefined;\n context.eventBus.on('update', rerender);\n return () => {\n context.eventBus.off('update', rerender);\n };\n }, [context, rerender]);\n\n return <>{content()}</>;\n}\n\ntype ToolbarWrapToContextProps<E> = PropsWithChildren<{\n editor: E;\n}>;\n\n/**\n If there is no external context, wraps the content in the toolbar context\n and emits an update event on each component re-render.\n @internal\n */\n// TODO [major]: Always expect the toolbar to be wrapped in context; remove this component as unnecessary.\nexport function ToolbarWrapToContext<E>({editor, children}: ToolbarWrapToContextProps<E>) {\n const outerContext = useToolbarContext();\n const innerContext = useMemo(() => {\n if (outerContext) return undefined;\n const eventBus = new EventEmitter<ToolbarEvents>();\n return {editor, eventBus} satisfies ToolbarContextValue<E>;\n }, [editor, outerContext]);\n\n useEffect(() => {\n innerContext?.eventBus.emit('update', null);\n });\n\n // wrapping in inner context only if there is no outer context\n return innerContext ? (\n <ToolbarProvider value={innerContext}>{children}</ToolbarProvider>\n ) : (\n <>{children}</>\n );\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Receiver } from "../utils/event-emitter.js";
|
|
2
|
+
export type ToolbarEvents = {
|
|
3
|
+
update: null;
|
|
4
|
+
};
|
|
5
|
+
export type ToolbarContextValue<E> = {
|
|
6
|
+
editor: E;
|
|
7
|
+
eventBus: Receiver<ToolbarEvents>;
|
|
8
|
+
};
|
|
9
|
+
export declare const ToolbarProvider: import("react").Provider<ToolbarContextValue<unknown> | undefined>;
|
|
10
|
+
export declare function useToolbarContext<E>(): ToolbarContextValue<E>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolbarProvider = void 0;
|
|
4
|
+
exports.useToolbarContext = useToolbarContext;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
// TODO: specify generic editor type
|
|
7
|
+
const ToolbarContext = (0, react_1.createContext)(undefined);
|
|
8
|
+
exports.ToolbarProvider = ToolbarContext.Provider;
|
|
9
|
+
function useToolbarContext() {
|
|
10
|
+
return (0, react_1.useContext)(ToolbarContext);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"../../../src","sources":["toolbar/context.ts"],"names":[],"mappings":";;;AAmBA,8CAEC;AArBD,iCAAgD;AAchD,oCAAoC;AACpC,MAAM,cAAc,GAAG,IAAA,qBAAa,EAA2C,SAAS,CAAC,CAAC;AAE7E,QAAA,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC;AAEvD,SAAgB,iBAAiB;IAC7B,OAAO,IAAA,kBAAU,EAAC,cAAc,CAA2B,CAAC;AAChE,CAAC","sourcesContent":["import {createContext, useContext} from 'react';\n\nimport type {Receiver} from 'src/utils/event-emitter';\n\nexport type ToolbarEvents = {\n update: null;\n};\n\n// TODO: [major] pass to context all other methods (focus, onClick, etc.)\nexport type ToolbarContextValue<E> = {\n editor: E;\n eventBus: Receiver<ToolbarEvents>;\n};\n\n// TODO: specify generic editor type\nconst ToolbarContext = createContext<ToolbarContextValue<unknown> | undefined>(undefined);\n\nexport const ToolbarProvider = ToolbarContext.Provider;\n\nexport function useToolbarContext<E>(): ToolbarContextValue<E> {\n return useContext(ToolbarContext) as ToolbarContextValue<E>;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolbarItemData } from "./types.js";
|
|
2
|
+
export type UseActionStateReturn = {
|
|
3
|
+
active: boolean;
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type ToolbarAction<E> = Pick<ToolbarItemData<E>, 'isActive' | 'isEnable'>;
|
|
7
|
+
export declare function useActionState<E>(editor: E, { isActive, isEnable }: ToolbarAction<E>): UseActionStateReturn;
|
|
8
|
+
export declare function useActionsState<E>(editor: E, actions: ToolbarAction<E>[]): UseActionStateReturn[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useActionState = useActionState;
|
|
4
|
+
exports.useActionsState = useActionsState;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_use_1 = require("react-use");
|
|
7
|
+
const lodash_1 = require("../lodash.js");
|
|
8
|
+
const context_1 = require("./context.js");
|
|
9
|
+
function useActionState(editor, { isActive, isEnable }) {
|
|
10
|
+
const context = (0, context_1.useToolbarContext)();
|
|
11
|
+
const eventBus = context?.eventBus;
|
|
12
|
+
const [state, setState] = (0, react_1.useState)({
|
|
13
|
+
active: false,
|
|
14
|
+
enabled: true,
|
|
15
|
+
});
|
|
16
|
+
const stateRef = (0, react_use_1.useLatest)(state);
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
const onUpdate = () => {
|
|
19
|
+
const newActive = isActive(editor);
|
|
20
|
+
const newEnabled = isEnable(editor);
|
|
21
|
+
const { active, enabled } = stateRef.current;
|
|
22
|
+
if (active !== newActive || enabled !== newEnabled) {
|
|
23
|
+
setState({
|
|
24
|
+
active: newActive,
|
|
25
|
+
enabled: newEnabled,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
onUpdate();
|
|
30
|
+
if (eventBus) {
|
|
31
|
+
eventBus.on('update', onUpdate);
|
|
32
|
+
return () => eventBus.off('update', onUpdate);
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}, [editor, isActive, isEnable, eventBus, stateRef]);
|
|
36
|
+
return state;
|
|
37
|
+
}
|
|
38
|
+
function useActionsState(editor, actions) {
|
|
39
|
+
const context = (0, context_1.useToolbarContext)();
|
|
40
|
+
const eventBus = context?.eventBus;
|
|
41
|
+
const [state, setState] = (0, react_1.useState)(() => actions.map(() => ({
|
|
42
|
+
active: false,
|
|
43
|
+
enabled: true,
|
|
44
|
+
})));
|
|
45
|
+
const stateRef = (0, react_use_1.useLatest)(state);
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
const onUpdate = () => {
|
|
48
|
+
const currentState = stateRef.current;
|
|
49
|
+
const newState = actions.map(({ isActive, isEnable }) => ({
|
|
50
|
+
active: isActive(editor),
|
|
51
|
+
enabled: isEnable(editor),
|
|
52
|
+
}));
|
|
53
|
+
if (!(0, lodash_1.isEqual)(currentState, newState)) {
|
|
54
|
+
setState(newState);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
onUpdate();
|
|
58
|
+
if (eventBus) {
|
|
59
|
+
eventBus.on('update', onUpdate);
|
|
60
|
+
return () => eventBus.off('update', onUpdate);
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}, [actions, editor, eventBus, stateRef]);
|
|
64
|
+
return state.length === actions.length
|
|
65
|
+
? state
|
|
66
|
+
: actions.map(() => ({ active: false, enabled: true }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"../../../src","sources":["toolbar/hooks.ts"],"names":[],"mappings":";;AAgBA,wCAsCC;AAED,0CAqCC;AA7FD,iCAA0C;AAE1C,yCAAoC;AAEpC,yCAAmC;AAEnC,0CAA4C;AAU5C,SAAgB,cAAc,CAC1B,MAAS,EACT,EAAC,QAAQ,EAAE,QAAQ,EAAmB;IAEtC,MAAM,OAAO,GAAG,IAAA,2BAAiB,GAAE,CAAC;IACpC,MAAM,QAAQ,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E,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import {useEffect, useState} from 'react';\n\nimport {useLatest} from 'react-use';\n\nimport {isEqual} from 'src/lodash';\n\nimport {useToolbarContext} from './context';\nimport type {ToolbarItemData} from './types';\n\nexport type UseActionStateReturn = {\n active: boolean;\n enabled: boolean;\n};\n\nexport type ToolbarAction<E> = Pick<ToolbarItemData<E>, 'isActive' | 'isEnable'>;\n\nexport function useActionState<E>(\n editor: E,\n {isActive, isEnable}: ToolbarAction<E>,\n): UseActionStateReturn {\n const context = useToolbarContext();\n const eventBus = context?.eventBus;\n\n const [state, setState] = useState<UseActionStateReturn>({\n active: false,\n enabled: true,\n });\n const stateRef = useLatest(state);\n\n useEffect(() => {\n const onUpdate = () => {\n const newActive = isActive(editor);\n const newEnabled = isEnable(editor);\n\n const {active, enabled} = stateRef.current;\n if (active !== newActive || enabled !== newEnabled) {\n setState({\n active: newActive,\n enabled: newEnabled,\n });\n }\n };\n\n onUpdate();\n\n if (eventBus) {\n eventBus.on('update', onUpdate);\n return () => eventBus.off('update', onUpdate);\n }\n\n return undefined;\n }, [editor, isActive, isEnable, eventBus, stateRef]);\n\n return state;\n}\n\nexport function useActionsState<E>(editor: E, actions: ToolbarAction<E>[]): UseActionStateReturn[] {\n const context = useToolbarContext();\n const eventBus = context?.eventBus;\n\n const [state, setState] = useState<UseActionStateReturn[]>(() =>\n actions.map(() => ({\n active: false,\n enabled: true,\n })),\n );\n const stateRef = useLatest(state);\n\n useEffect(() => {\n const onUpdate = () => {\n const currentState = stateRef.current;\n const newState = actions.map(({isActive, isEnable}) => ({\n active: isActive(editor),\n enabled: isEnable(editor),\n }));\n if (!isEqual(currentState, newState)) {\n setState(newState);\n }\n };\n\n onUpdate();\n\n if (eventBus) {\n eventBus.on('update', onUpdate);\n return () => eventBus.off('update', onUpdate);\n }\n\n return undefined;\n }, [actions, editor, eventBus, stateRef]);\n\n return state.length === actions.length\n ? state\n : actions.map(() => ({active: false, enabled: true}));\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToolbarContext = exports.ToolbarProvider = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./const.js"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
@@ -8,4 +9,7 @@ tslib_1.__exportStar(require("./ToolbarButton.js"), exports);
|
|
|
8
9
|
tslib_1.__exportStar(require("./ToolbarGroup.js"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./ToolbarListButton.js"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./FlexToolbar.js"), exports);
|
|
12
|
+
var context_1 = require("./context.js");
|
|
13
|
+
Object.defineProperty(exports, "ToolbarProvider", { enumerable: true, get: function () { return context_1.ToolbarProvider; } });
|
|
14
|
+
Object.defineProperty(exports, "useToolbarContext", { enumerable: true, get: function () { return context_1.useToolbarContext; } });
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["toolbar/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["toolbar/index.ts"],"names":[],"mappings":";;;;AAAA,qDAAwB;AACxB,qDAAwB;AACxB,uDAA0B;AAC1B,6DAAgC;AAChC,4DAA+B;AAC/B,iEAAoC;AACpC,2DAA8B;AAE9B,wCAAuF;AAA/E,0GAAA,eAAe,OAAA;AAAE,4GAAA,iBAAiB,OAAA","sourcesContent":["export * from './const';\nexport * from './types';\nexport * from './Toolbar';\nexport * from './ToolbarButton';\nexport * from './ToolbarGroup';\nexport * from './ToolbarListButton';\nexport * from './FlexToolbar';\n\nexport {ToolbarProvider, useToolbarContext, type ToolbarContextValue} from './context';\n"]}
|
|
@@ -69,6 +69,7 @@ export type ToolbarReactComponentData<E> = {
|
|
|
69
69
|
width: number;
|
|
70
70
|
className?: string;
|
|
71
71
|
component: React.ComponentType<ToolbarBaseProps<E>>;
|
|
72
|
+
noRerenderOnUpdate?: boolean;
|
|
72
73
|
props?: object;
|
|
73
74
|
};
|
|
74
75
|
export type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["toolbar/types.ts"],"names":[],"mappings":";;;AAgDA,IAAY,eASX;AATD,WAAY,eAAe;IACvB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,kDAAkD;IAClD,uCAAoB,CAAA;IACpB,kDAAkD;IAClD,4CAAyB,CAAA;IACzB,iDAA8B,CAAA;AAClC,CAAC,EATW,eAAe,+BAAf,eAAe,QAS1B","sourcesContent":["import type {HotkeyProps, IconProps, QAProps} from '@gravity-ui/uikit';\n\nimport type {ClassNameProps} from '../classname';\n\nexport type ToolbarBaseProps<E> = ClassNameProps &\n QAProps & {\n editor: E;\n focus(): void;\n onClick?(id: string, attrs?: {[key: string]: any}): void;\n display?: ToolbarDisplay;\n disableTooltip?: boolean;\n disablePreview?: boolean;\n disableHotkey?: boolean;\n };\n\nexport type ToolbarIconData = Pick<IconProps, 'data' | 'size'>;\nexport type ToolbarGroupData<E> = Array<ToolbarGroupItemData<E>>;\nexport type ToolbarData<E> = ToolbarGroupData<E>[];\nexport type ToolbarDisplay = 'shrink' | 'scroll';\n\nexport type ToolbarItemData<E> = QAProps & {\n id: string;\n icon: ToolbarIconData;\n title: string | (() => string);\n hint?: string | (() => string);\n hotkey?: HotkeyProps['value'];\n preview?: React.ReactNode;\n theme?: 'normal' | 'danger';\n /**\n * Alternative IDs that can be used to find this command\n */\n aliases?: string[];\n /**\n * Show hint when _isEnable()_ returns false\n *\n * `false` – don't show hint;\n *\n * `true` – show default hint;\n *\n * `string` or `() => string` – show hint with custom message.\n * @default true\n */\n hintWhenDisabled?: boolean | string | (() => string);\n exec(editor: E): void;\n isActive(editor: E): boolean;\n isEnable(editor: E): boolean;\n};\n\nexport enum ToolbarDataType {\n SingleButton = 's-button',\n ListButton = 'list-b',\n ButtonPopup = 'b-popup',\n /** @deprecated Use ReactComponent type instead */\n ReactNode = 'r-node',\n /** @deprecated Use ReactComponent type instead */\n ReactNodeFn = 'r-node-fn',\n ReactComponent = 'r-component',\n}\n\nexport type ToolbarGroupItemData<E> =\n | ToolbarSingleItemData<E>\n | ToolbarButtonPopupData<E>\n | ToolbarListItemData<E>\n | ToolbarReactNodeData\n | ToolbarReactNodeFnData<E>\n | ToolbarReactComponentData<E>;\n\nexport type ToolbarSingleItemData<E> = ToolbarItemData<E> & {\n id: string;\n type: ToolbarDataType.SingleButton;\n className?: string;\n};\n\nexport type ToolbarListItemData<E> = ToolbarListButtonData<E> & {\n id: string;\n type: ToolbarDataType.ListButton;\n className?: string;\n};\n\nexport type ToolbarReactComponentData<E> = {\n id: string;\n type: ToolbarDataType.ReactComponent;\n width: number;\n className?: string;\n component: React.ComponentType<ToolbarBaseProps<E>>;\n props?: object;\n};\n\nexport type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {\n /** not used, may be an empty function */\n exec: ToolbarItemData<E>['exec'];\n type: ToolbarDataType.ButtonPopup;\n renderPopup: (\n props: ToolbarBaseProps<E> & {hide: () => void; anchorElement: HTMLElement | null},\n ) => React.ReactNode;\n className?: string;\n};\n\nexport type ToolbarListButtonItemData<E> = ToolbarItemData<E> & {\n doNotActivateList?: boolean;\n};\n\nexport type ToolbarListButtonData<E> = {\n icon: ToolbarIconData;\n title: string | (() => string);\n withArrow?: boolean;\n data: ToolbarListButtonItemData<E>[];\n alwaysActive?: boolean;\n hideDisabled?: boolean;\n /** When state changes to active, replace default icon with icon of first active item */\n replaceActiveIcon?: boolean;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n */\nexport type ToolbarReactNodeData = {\n id: string;\n type: ToolbarDataType.ReactNode;\n width: number;\n content: React.ReactNode;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n */\nexport type ToolbarReactNodeFnData<E> = {\n id: string;\n type: ToolbarDataType.ReactNodeFn;\n width: number;\n content: (e: E) => React.ReactNode;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["toolbar/types.ts"],"names":[],"mappings":";;;AAgDA,IAAY,eASX;AATD,WAAY,eAAe;IACvB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,kDAAkD;IAClD,uCAAoB,CAAA;IACpB,kDAAkD;IAClD,4CAAyB,CAAA;IACzB,iDAA8B,CAAA;AAClC,CAAC,EATW,eAAe,+BAAf,eAAe,QAS1B","sourcesContent":["import type {HotkeyProps, IconProps, QAProps} from '@gravity-ui/uikit';\n\nimport type {ClassNameProps} from '../classname';\n\nexport type ToolbarBaseProps<E> = ClassNameProps &\n QAProps & {\n editor: E;\n focus(): void;\n onClick?(id: string, attrs?: {[key: string]: any}): void;\n display?: ToolbarDisplay;\n disableTooltip?: boolean;\n disablePreview?: boolean;\n disableHotkey?: boolean;\n };\n\nexport type ToolbarIconData = Pick<IconProps, 'data' | 'size'>;\nexport type ToolbarGroupData<E> = Array<ToolbarGroupItemData<E>>;\nexport type ToolbarData<E> = ToolbarGroupData<E>[];\nexport type ToolbarDisplay = 'shrink' | 'scroll';\n\nexport type ToolbarItemData<E> = QAProps & {\n id: string;\n icon: ToolbarIconData;\n title: string | (() => string);\n hint?: string | (() => string);\n hotkey?: HotkeyProps['value'];\n preview?: React.ReactNode;\n theme?: 'normal' | 'danger';\n /**\n * Alternative IDs that can be used to find this command\n */\n aliases?: string[];\n /**\n * Show hint when _isEnable()_ returns false\n *\n * `false` – don't show hint;\n *\n * `true` – show default hint;\n *\n * `string` or `() => string` – show hint with custom message.\n * @default true\n */\n hintWhenDisabled?: boolean | string | (() => string);\n exec(editor: E): void;\n isActive(editor: E): boolean;\n isEnable(editor: E): boolean;\n};\n\nexport enum ToolbarDataType {\n SingleButton = 's-button',\n ListButton = 'list-b',\n ButtonPopup = 'b-popup',\n /** @deprecated Use ReactComponent type instead */\n ReactNode = 'r-node',\n /** @deprecated Use ReactComponent type instead */\n ReactNodeFn = 'r-node-fn',\n ReactComponent = 'r-component',\n}\n\nexport type ToolbarGroupItemData<E> =\n | ToolbarSingleItemData<E>\n | ToolbarButtonPopupData<E>\n | ToolbarListItemData<E>\n | ToolbarReactNodeData\n | ToolbarReactNodeFnData<E>\n | ToolbarReactComponentData<E>;\n\nexport type ToolbarSingleItemData<E> = ToolbarItemData<E> & {\n id: string;\n type: ToolbarDataType.SingleButton;\n className?: string;\n};\n\nexport type ToolbarListItemData<E> = ToolbarListButtonData<E> & {\n id: string;\n type: ToolbarDataType.ListButton;\n className?: string;\n};\n\nexport type ToolbarReactComponentData<E> = {\n id: string;\n type: ToolbarDataType.ReactComponent;\n width: number;\n className?: string;\n component: React.ComponentType<ToolbarBaseProps<E>>;\n noRerenderOnUpdate?: boolean;\n props?: object;\n};\n\nexport type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {\n /** not used, may be an empty function */\n exec: ToolbarItemData<E>['exec'];\n type: ToolbarDataType.ButtonPopup;\n renderPopup: (\n props: ToolbarBaseProps<E> & {hide: () => void; anchorElement: HTMLElement | null},\n ) => React.ReactNode;\n className?: string;\n};\n\nexport type ToolbarListButtonItemData<E> = ToolbarItemData<E> & {\n doNotActivateList?: boolean;\n};\n\nexport type ToolbarListButtonData<E> = {\n icon: ToolbarIconData;\n title: string | (() => string);\n withArrow?: boolean;\n data: ToolbarListButtonItemData<E>[];\n alwaysActive?: boolean;\n hideDisabled?: boolean;\n /** When state changes to active, replace default icon with icon of first active item */\n replaceActiveIcon?: boolean;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n */\nexport type ToolbarReactNodeData = {\n id: string;\n type: ToolbarDataType.ReactNode;\n width: number;\n content: React.ReactNode;\n};\n\n/**\n * @deprecated Use ReactComponent type instead\n */\nexport type ToolbarReactNodeFnData<E> = {\n id: string;\n type: ToolbarDataType.ReactNodeFn;\n width: number;\n content: (e: E) => React.ReactNode;\n};\n"]}
|
package/build/cjs/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '15.
|
|
5
|
+
exports.VERSION = typeof '15.35.1' !== 'undefined' ? '15.35.1' : 'unknown';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/build/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACzD,QAAA,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACzD,QAAA,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.35.1' !== 'undefined' ? '15.35.1' : 'unknown';\n"]}
|
|
@@ -11,7 +11,12 @@ function withMermaid(opts) {
|
|
|
11
11
|
const renderMermaid = (0, react_2.useMermaid)();
|
|
12
12
|
(0, useMermaidRuntime_1.useMermaidRuntime)(meta, opts.runtime);
|
|
13
13
|
(0, react_1.useEffect)(() => {
|
|
14
|
-
|
|
14
|
+
// do not render mermaid diagrams inside the editor component
|
|
15
|
+
// because they are handled differently (no data-content attribute)
|
|
16
|
+
// and the editor is managing their render itself
|
|
17
|
+
renderMermaid(mermaidConfig, {
|
|
18
|
+
querySelector: '.mermaid:not(.g-md-wysiwyg-editor .mermaid)',
|
|
19
|
+
});
|
|
15
20
|
}, [html, mermaidConfig, renderMermaid]);
|
|
16
21
|
return (0, jsx_runtime_1.jsx)(Component, { ...props, ref: ref });
|
|
17
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["view/hocs/withMermaid/index.tsx"],"names":[],"mappings":";;AAkBA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["view/hocs/withMermaid/index.tsx"],"names":[],"mappings":";;AAkBA,kCAsBC;;AAxCD,iCAAoF;AAEpF,6DAA6D;AAG7D,8DAAsD;AAatD,SAAgB,WAAW,CAAC,IAAwB;IAChD,OAAO,CACH,SAA2D,EAC7D,EAAE,CACA,IAAA,kBAAU,EAAuC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG;QAC1E,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAC,GAAG,KAAK,CAAC;QAE1C,MAAM,aAAa,GAAG,IAAA,kBAAU,GAAE,CAAC;QAEnC,IAAA,qCAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAA,iBAAS,EAAC,GAAG,EAAE;YACX,6DAA6D;YAC7D,mEAAmE;YACnE,iDAAiD;YACjD,aAAa,CAAC,aAAa,EAAE;gBACzB,aAAa,EAAE,6CAA6C;aAC/D,CAAC,CAAC;QACP,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;QAEzC,OAAO,uBAAC,SAAS,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;IAC9C,CAAC,CAAC,CAAC;AACX,CAAC","sourcesContent":["import {type ComponentType, type RefAttributes, forwardRef, useEffect} from 'react';\n\nimport {useMermaid} from '@diplodoc/mermaid-extension/react';\n\nimport type {PluginRuntime, TransformMeta} from './types';\nimport {useMermaidRuntime} from './useMermaidRuntime';\n\nexport type MermaidConfig = Parameters<ReturnType<typeof useMermaid>>[0];\n\nexport type WithMermaidOptions = {\n runtime: PluginRuntime;\n};\n\nexport type WithMermaidProps = {\n meta: TransformMeta;\n mermaidConfig: MermaidConfig;\n};\n\nexport function withMermaid(opts: WithMermaidOptions) {\n return <T extends {html: string}>(\n Component: ComponentType<T & RefAttributes<HTMLDivElement>>,\n ) =>\n forwardRef<HTMLDivElement, T & WithMermaidProps>(function WithLatex(props, ref) {\n const {meta, html, mermaidConfig} = props;\n\n const renderMermaid = useMermaid();\n\n useMermaidRuntime(meta, opts.runtime);\n\n useEffect(() => {\n // do not render mermaid diagrams inside the editor component\n // because they are handled differently (no data-content attribute)\n // and the editor is managing their render itself\n renderMermaid(mermaidConfig, {\n querySelector: '.mermaid:not(.g-md-wysiwyg-editor .mermaid)',\n });\n }, [html, mermaidConfig, renderMermaid]);\n\n return <Component {...props} ref={ref} />;\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, { qa: "g-md-toolbar-main", editor: editor, editorMode: "markup", toolbarEditor: editor, hiddenActionsConfig: hiddenActionsConfig, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig,
|
|
29
|
+
}, children: _jsx(ToolbarView, { qa: "g-md-toolbar-main", editor: editor, editorMode: "markup", toolbarEditor: editor, hiddenActionsConfig: hiddenActionsConfig, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), toolbarDisplay: toolbarDisplay, 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;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,qBAAqB,EAAC,mCAAgC;AAC9D,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAC1C,OAAO,EAAC,4BAA4B,EAAC,oCAAiC;AAItE,gCAAiC;AAEjC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAkB9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAwB,CAAC,KAAK,EAAE,EAAE;IAClE,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,EACpB,cAAc,GACjB,GAAG,KAAK,CAAC;IACV,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE;QACnB,YAAY,CAAC,OAAO,CAAC;YACjB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,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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, ToolbarDisplay} 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 toolbarDisplay?: ToolbarDisplay;\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 toolbarDisplay,\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-main\"\n editor={editor}\n editorMode=\"markup\"\n toolbarEditor={editor}\n hiddenActionsConfig={hiddenActionsConfig}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n toolbarDisplay={toolbarDisplay}\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"]}
|
|
@@ -7,7 +7,6 @@ export type ToolbarViewProps<T> = ClassNameProps & QAProps & {
|
|
|
7
7
|
editor: EditorInt;
|
|
8
8
|
editorMode: MarkdownEditorMode;
|
|
9
9
|
toolbarEditor: T;
|
|
10
|
-
toolbarFocus: () => void;
|
|
11
10
|
toolbarConfig: ToolbarData<T>;
|
|
12
11
|
settingsVisible?: boolean;
|
|
13
12
|
hiddenActionsConfig?: ToolbarItemData<T>[];
|
|
@@ -15,4 +14,4 @@ export type ToolbarViewProps<T> = ClassNameProps & QAProps & {
|
|
|
15
14
|
stickyToolbar: boolean;
|
|
16
15
|
toolbarDisplay?: ToolbarDisplay;
|
|
17
16
|
};
|
|
18
|
-
export declare function ToolbarView<T>({ editor, editorMode, toolbarEditor,
|
|
17
|
+
export declare function ToolbarView<T>({ editor, editorMode, toolbarEditor, toolbarConfig, toolbarDisplay, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, qa, }: ToolbarViewProps<T>): JSX.Element;
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useLayoutEffect, useRef } from 'react';
|
|
3
|
-
import { useUpdate } from 'react-use';
|
|
2
|
+
import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
4
3
|
import { LAYOUT } from "../common/layout.js";
|
|
4
|
+
import { typedMemo } from "../react-utils/memo.js";
|
|
5
|
+
import { EventEmitter } from "../utils/index.js";
|
|
5
6
|
import { i18n } from "../i18n/menubar/index.js";
|
|
6
7
|
import { useSticky } from "../react-utils/useSticky.js";
|
|
7
|
-
import { FlexToolbar } from "../toolbar/index.js";
|
|
8
|
+
import { FlexToolbar, ToolbarProvider, } from "../toolbar/index.js";
|
|
8
9
|
import { stickyCn } from "./sticky/index.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
useLayoutEffect(() => {
|
|
12
|
-
editor.on('rerender-toolbar', rerender);
|
|
13
|
-
return () => {
|
|
14
|
-
editor.off('rerender-toolbar', rerender);
|
|
15
|
-
};
|
|
16
|
-
}, [editor, rerender]);
|
|
10
|
+
const MemoizedFlexibleToolbar = typedMemo(FlexToolbar);
|
|
11
|
+
export function ToolbarView({ editor, editorMode, toolbarEditor, toolbarConfig, toolbarDisplay, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, qa, }) {
|
|
17
12
|
const wrapperRef = useRef(null);
|
|
18
13
|
const isStickyActive = useSticky(wrapperRef) && stickyToolbar;
|
|
19
14
|
const mobile = editor.mobile;
|
|
15
|
+
const clickHandle = useCallback((id, attrs) => editor.emit('toolbar-action', { id, attrs, editorMode }), [editor, editorMode]);
|
|
16
|
+
const toolbarProviderValue = useMemo(() => ({
|
|
17
|
+
editor: toolbarEditor,
|
|
18
|
+
eventBus: new EventEmitter(),
|
|
19
|
+
}), [toolbarEditor]);
|
|
20
|
+
const handleFocus = useCallback(() => {
|
|
21
|
+
editor.focus();
|
|
22
|
+
}, [editor]);
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
const onRerender = () => {
|
|
25
|
+
toolbarProviderValue.eventBus.emit('update', null);
|
|
26
|
+
};
|
|
27
|
+
editor.on('rerender-toolbar', onRerender);
|
|
28
|
+
return () => {
|
|
29
|
+
editor.off('rerender-toolbar', onRerender);
|
|
30
|
+
};
|
|
31
|
+
}, [editor, toolbarProviderValue]);
|
|
20
32
|
return (_jsxs("div", { "data-qa": qa, ref: wrapperRef, className: stickyCn.toolbar({
|
|
21
33
|
withSettings: settingsVisible,
|
|
22
34
|
stickyActive: isStickyActive,
|
|
23
35
|
isSticky: stickyToolbar,
|
|
24
|
-
}, [className]), "data-layout": LAYOUT.STICKY_TOOLBAR, children: [_jsx(
|
|
36
|
+
}, [className]), "data-layout": LAYOUT.STICKY_TOOLBAR, children: [_jsx(ToolbarProvider, { value: toolbarProviderValue, children: _jsx(MemoizedFlexibleToolbar, { data: toolbarConfig, hiddenActions: hiddenActionsConfig, editor: toolbarEditor, focus: handleFocus, dotsTitle: i18n('more_action'), onClick: clickHandle, display: toolbarDisplay, disableTooltip: mobile, disableHotkey: mobile, disablePreview: mobile }) }), children] }));
|
|
25
37
|
}
|
|
26
38
|
//# sourceMappingURL=ToolbarView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarView.js","sourceRoot":"../../../src","sources":["bundle/ToolbarView.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ToolbarView.js","sourceRoot":"../../../src","sources":["bundle/ToolbarView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAIzF,OAAO,EAAC,MAAM,EAAC,4BAA0B;AACzC,OAAO,EAAC,SAAS,EAAC,+BAA6B;AAC/C,OAAO,EAAC,YAAY,EAAC,0BAAkB;AAGvC,OAAO,EAAC,IAAI,EAAC,iCAAwB;AACrC,OAAO,EAAC,SAAS,EAAC,oCAAiC;AACnD,OAAO,EACH,WAAW,EAKX,eAAe,GAClB,4BAAmB;A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kBAAkB,EAAE,UAAU,CAAC,CAAC;QAC/C,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAEnC,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,iBACY,MAAM,CAAC,cAAc,aAElC,KAAC,eAAe,IAAC,KAAK,EAAE,oBAAoB,YACxC,KAAC,uBAAuB,IACpB,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,mBAAmB,EAClC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,EAC9B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,cAAc,EACvB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACxB,GACY,EACjB,QAAQ,IACP,CACT,CAAC;AACN,CAAC","sourcesContent":["import {type ComponentProps, useCallback, useLayoutEffect, useMemo, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {LAYOUT} from 'src/common/layout';\nimport {typedMemo} from 'src/react-utils/memo';\nimport {EventEmitter} from 'src/utils';\n\nimport type {ClassNameProps} from '../classname';\nimport {i18n} from '../i18n/menubar';\nimport {useSticky} from '../react-utils/useSticky';\nimport {\n FlexToolbar,\n type FlexToolbarProps,\n type ToolbarData,\n type ToolbarDisplay,\n type ToolbarItemData,\n ToolbarProvider,\n} from '../toolbar';\n\nimport type {EditorInt} from './Editor';\nimport {stickyCn} from './sticky';\nimport type {MarkdownEditorMode} from './types';\n\nconst MemoizedFlexibleToolbar = typedMemo(FlexToolbar);\n\ntype ToolbarProviderValue = NonNullable<ComponentProps<typeof ToolbarProvider>['value']>;\n\nexport type ToolbarViewProps<T> = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n editorMode: MarkdownEditorMode;\n toolbarEditor: T;\n toolbarConfig: ToolbarData<T>;\n settingsVisible?: boolean;\n hiddenActionsConfig?: ToolbarItemData<T>[];\n children?: React.ReactNode;\n stickyToolbar: boolean;\n toolbarDisplay?: ToolbarDisplay;\n };\n\nexport function ToolbarView<T>({\n editor,\n editorMode,\n toolbarEditor,\n toolbarConfig,\n toolbarDisplay,\n hiddenActionsConfig,\n settingsVisible,\n className,\n children,\n stickyToolbar,\n qa,\n}: ToolbarViewProps<T>) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const isStickyActive = useSticky(wrapperRef) && stickyToolbar;\n\n const mobile = editor.mobile;\n\n const clickHandle = useCallback<NonNullable<FlexToolbarProps<T>['onClick']>>(\n (id, attrs) => editor.emit('toolbar-action', {id, attrs, editorMode}),\n [editor, editorMode],\n );\n\n const toolbarProviderValue = useMemo(\n () =>\n ({\n editor: toolbarEditor,\n eventBus: new EventEmitter<{update: null}>(),\n }) satisfies ToolbarProviderValue,\n [toolbarEditor],\n );\n\n const handleFocus = useCallback(() => {\n editor.focus();\n }, [editor]);\n\n useLayoutEffect(() => {\n const onRerender = () => {\n toolbarProviderValue.eventBus.emit('update', null);\n };\n\n editor.on('rerender-toolbar', onRerender);\n return () => {\n editor.off('rerender-toolbar', onRerender);\n };\n }, [editor, toolbarProviderValue]);\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 data-layout={LAYOUT.STICKY_TOOLBAR}\n >\n <ToolbarProvider value={toolbarProviderValue}>\n <MemoizedFlexibleToolbar\n data={toolbarConfig}\n hiddenActions={hiddenActionsConfig}\n editor={toolbarEditor}\n focus={handleFocus}\n dotsTitle={i18n('more_action')}\n onClick={clickHandle}\n display={toolbarDisplay}\n disableTooltip={mobile}\n disableHotkey={mobile}\n disablePreview={mobile}\n />\n </ToolbarProvider>\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -15,4 +15,4 @@ export type WysiwygEditorViewProps = ClassNameProps & QAProps & {
|
|
|
15
15
|
children?: React.ReactNode;
|
|
16
16
|
toolbarDisplay?: ToolbarDisplay;
|
|
17
17
|
};
|
|
18
|
-
export declare const WysiwygEditorView:
|
|
18
|
+
export declare const WysiwygEditorView: React.FC<WysiwygEditorViewProps>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from 'react';
|
|
3
2
|
import { cn } from "../classname.js";
|
|
4
3
|
import { ReactRendererComponent } from "../extensions/index.js";
|
|
5
4
|
import { globalLogger } from "../logger.js";
|
|
@@ -8,7 +7,7 @@ import { ToolbarView } from "./ToolbarView.js";
|
|
|
8
7
|
import { WysiwygEditorComponent } from "./WysiwygEditorComponent.js";
|
|
9
8
|
import "./WysiwygEditorView.css";
|
|
10
9
|
const b = cn('wysiwyg-editor');
|
|
11
|
-
export const WysiwygEditorView =
|
|
10
|
+
export const WysiwygEditorView = (props) => {
|
|
12
11
|
const { editor, autofocus, settingsVisible, toolbarVisible, toolbarConfig, hiddenActionsConfig, qa, className, toolbarClassName, children, stickyToolbar = true, toolbarDisplay, } = props;
|
|
13
12
|
useRenderTime((time) => {
|
|
14
13
|
globalLogger.metrics({
|
|
@@ -22,7 +21,7 @@ export const WysiwygEditorView = memo((props) => {
|
|
|
22
21
|
duration: time,
|
|
23
22
|
});
|
|
24
23
|
});
|
|
25
|
-
return (_jsxs("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? (_jsx(ToolbarView, { qa: "g-md-toolbar-main", editor: editor, editorMode: "wysiwyg", toolbarEditor: editor, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig,
|
|
26
|
-
}
|
|
24
|
+
return (_jsxs("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? (_jsx(ToolbarView, { qa: "g-md-toolbar-main", editor: editor, editorMode: "wysiwyg", toolbarEditor: editor, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, hiddenActionsConfig: hiddenActionsConfig, settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), toolbarDisplay: toolbarDisplay, children: children })) : null, _jsx(WysiwygEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor'), children: _jsx(ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
25
|
+
};
|
|
27
26
|
WysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';
|
|
28
27
|
//# sourceMappingURL=WysiwygEditorView.js.map
|