@gravity-ui/markdown-editor 15.34.5 → 15.35.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.
Files changed (133) hide show
  1. package/build/cjs/bundle/MarkupEditorView.js +1 -1
  2. package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
  3. package/build/cjs/bundle/ToolbarView.d.ts +1 -2
  4. package/build/cjs/bundle/ToolbarView.js +22 -10
  5. package/build/cjs/bundle/ToolbarView.js.map +1 -1
  6. package/build/cjs/bundle/WysiwygEditorView.d.ts +1 -1
  7. package/build/cjs/bundle/WysiwygEditorView.js +4 -4
  8. package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
  9. package/build/cjs/bundle/config/markup.js +1 -0
  10. package/build/cjs/bundle/config/markup.js.map +1 -1
  11. package/build/cjs/bundle/config/wysiwyg.js +2 -0
  12. package/build/cjs/bundle/config/wysiwyg.js.map +1 -1
  13. package/build/cjs/bundle/emoji.js +3 -0
  14. package/build/cjs/bundle/emoji.js.map +1 -1
  15. package/build/cjs/bundle/toolbar/wysiwyg/WToolbarColors.js +36 -2
  16. package/build/cjs/bundle/toolbar/wysiwyg/WToolbarColors.js.map +1 -1
  17. package/build/cjs/extensions/markdown/Lists/commands.d.ts +1 -0
  18. package/build/cjs/extensions/markdown/Lists/commands.js +14 -0
  19. package/build/cjs/extensions/markdown/Lists/commands.js.map +1 -1
  20. package/build/cjs/extensions/markdown/Lists/index.js +1 -0
  21. package/build/cjs/extensions/markdown/Lists/index.js.map +1 -1
  22. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.d.ts +27 -0
  23. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js +81 -0
  24. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js.map +1 -0
  25. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +33 -0
  26. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
  27. package/build/cjs/modules/toolbars/items.js +2 -0
  28. package/build/cjs/modules/toolbars/items.js.map +1 -1
  29. package/build/cjs/modules/toolbars/types.d.ts +1 -0
  30. package/build/cjs/modules/toolbars/types.js.map +1 -1
  31. package/build/cjs/react-utils/memo.d.ts +1 -0
  32. package/build/cjs/react-utils/memo.js +8 -0
  33. package/build/cjs/react-utils/memo.js.map +1 -0
  34. package/build/cjs/styles/markdown.css +1 -1
  35. package/build/cjs/styles/styles.css +5 -0
  36. package/build/cjs/styles/yfm-overrides.css +1 -1
  37. package/build/cjs/toolbar/Toolbar.d.ts +4 -0
  38. package/build/cjs/toolbar/Toolbar.js +9 -4
  39. package/build/cjs/toolbar/Toolbar.js.map +1 -1
  40. package/build/cjs/toolbar/ToolbarButton.js +3 -3
  41. package/build/cjs/toolbar/ToolbarButton.js.map +1 -1
  42. package/build/cjs/toolbar/ToolbarButtonPopup.js +3 -3
  43. package/build/cjs/toolbar/ToolbarButtonPopup.js.map +1 -1
  44. package/build/cjs/toolbar/ToolbarGroup.js +5 -4
  45. package/build/cjs/toolbar/ToolbarGroup.js.map +1 -1
  46. package/build/cjs/toolbar/ToolbarListButton.js +9 -6
  47. package/build/cjs/toolbar/ToolbarListButton.js.map +1 -1
  48. package/build/cjs/toolbar/ToolbarRerender.d.ts +3 -0
  49. package/build/cjs/toolbar/ToolbarRerender.js +48 -0
  50. package/build/cjs/toolbar/ToolbarRerender.js.map +1 -0
  51. package/build/cjs/toolbar/context.d.ts +10 -0
  52. package/build/cjs/toolbar/context.js +12 -0
  53. package/build/cjs/toolbar/context.js.map +1 -0
  54. package/build/cjs/toolbar/hooks.d.ts +8 -0
  55. package/build/cjs/toolbar/hooks.js +68 -0
  56. package/build/cjs/toolbar/hooks.js.map +1 -0
  57. package/build/cjs/toolbar/index.d.ts +1 -0
  58. package/build/cjs/toolbar/index.js +4 -0
  59. package/build/cjs/toolbar/index.js.map +1 -1
  60. package/build/cjs/toolbar/types.d.ts +1 -0
  61. package/build/cjs/toolbar/types.js.map +1 -1
  62. package/build/cjs/version.js +1 -1
  63. package/build/cjs/version.js.map +1 -1
  64. package/build/cjs/view/hocs/withMermaid/index.js +6 -1
  65. package/build/cjs/view/hocs/withMermaid/index.js.map +1 -1
  66. package/build/esm/bundle/MarkupEditorView.js +1 -1
  67. package/build/esm/bundle/MarkupEditorView.js.map +1 -1
  68. package/build/esm/bundle/ToolbarView.d.ts +1 -2
  69. package/build/esm/bundle/ToolbarView.js +24 -12
  70. package/build/esm/bundle/ToolbarView.js.map +1 -1
  71. package/build/esm/bundle/WysiwygEditorView.d.ts +1 -1
  72. package/build/esm/bundle/WysiwygEditorView.js +3 -4
  73. package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
  74. package/build/esm/bundle/config/markup.js +1 -0
  75. package/build/esm/bundle/config/markup.js.map +1 -1
  76. package/build/esm/bundle/config/wysiwyg.js +2 -0
  77. package/build/esm/bundle/config/wysiwyg.js.map +1 -1
  78. package/build/esm/bundle/emoji.js +3 -0
  79. package/build/esm/bundle/emoji.js.map +1 -1
  80. package/build/esm/bundle/toolbar/wysiwyg/WToolbarColors.js +36 -2
  81. package/build/esm/bundle/toolbar/wysiwyg/WToolbarColors.js.map +1 -1
  82. package/build/esm/extensions/markdown/Lists/commands.d.ts +1 -0
  83. package/build/esm/extensions/markdown/Lists/commands.js +13 -0
  84. package/build/esm/extensions/markdown/Lists/commands.js.map +1 -1
  85. package/build/esm/extensions/markdown/Lists/index.js +2 -1
  86. package/build/esm/extensions/markdown/Lists/index.js.map +1 -1
  87. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.d.ts +27 -0
  88. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js +77 -0
  89. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-auto-scroll.js.map +1 -0
  90. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +33 -0
  91. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
  92. package/build/esm/modules/toolbars/items.js +2 -0
  93. package/build/esm/modules/toolbars/items.js.map +1 -1
  94. package/build/esm/modules/toolbars/types.d.ts +1 -0
  95. package/build/esm/modules/toolbars/types.js.map +1 -1
  96. package/build/esm/react-utils/memo.d.ts +1 -0
  97. package/build/esm/react-utils/memo.js +5 -0
  98. package/build/esm/react-utils/memo.js.map +1 -0
  99. package/build/esm/styles/markdown.css +1 -1
  100. package/build/esm/styles/styles.css +5 -0
  101. package/build/esm/styles/yfm-overrides.css +1 -1
  102. package/build/esm/toolbar/Toolbar.d.ts +4 -0
  103. package/build/esm/toolbar/Toolbar.js +9 -4
  104. package/build/esm/toolbar/Toolbar.js.map +1 -1
  105. package/build/esm/toolbar/ToolbarButton.js +3 -3
  106. package/build/esm/toolbar/ToolbarButton.js.map +1 -1
  107. package/build/esm/toolbar/ToolbarButtonPopup.js +3 -3
  108. package/build/esm/toolbar/ToolbarButtonPopup.js.map +1 -1
  109. package/build/esm/toolbar/ToolbarGroup.js +5 -4
  110. package/build/esm/toolbar/ToolbarGroup.js.map +1 -1
  111. package/build/esm/toolbar/ToolbarListButton.js +9 -6
  112. package/build/esm/toolbar/ToolbarListButton.js.map +1 -1
  113. package/build/esm/toolbar/ToolbarRerender.d.ts +3 -0
  114. package/build/esm/toolbar/ToolbarRerender.js +44 -0
  115. package/build/esm/toolbar/ToolbarRerender.js.map +1 -0
  116. package/build/esm/toolbar/context.d.ts +10 -0
  117. package/build/esm/toolbar/context.js +8 -0
  118. package/build/esm/toolbar/context.js.map +1 -0
  119. package/build/esm/toolbar/hooks.d.ts +8 -0
  120. package/build/esm/toolbar/hooks.js +64 -0
  121. package/build/esm/toolbar/hooks.js.map +1 -0
  122. package/build/esm/toolbar/index.d.ts +1 -0
  123. package/build/esm/toolbar/index.js +1 -0
  124. package/build/esm/toolbar/index.js.map +1 -1
  125. package/build/esm/toolbar/types.d.ts +1 -0
  126. package/build/esm/toolbar/types.js.map +1 -1
  127. package/build/esm/version.js +1 -1
  128. package/build/esm/version.js.map +1 -1
  129. package/build/esm/view/hocs/withMermaid/index.js +6 -1
  130. package/build/esm/view/hocs/withMermaid/index.js.map +1 -1
  131. package/build/styles.css +7 -2
  132. package/package.json +17 -79
  133. package/README.md +0 -89
@@ -10,6 +10,7 @@ import { useTargetZIndex } from "../react-utils/index.js";
10
10
  import { useBooleanState, useElementState } from "../react-utils/hooks.js";
11
11
  import { PreviewTooltip } from "./PreviewTooltip.js";
12
12
  import { ToolbarButtonView } from "./ToolbarButton.js";
13
+ import { useActionsState } from "./hooks.js";
13
14
  import "./ToolbarListButton.css";
14
15
  const b = cn('toolbar-list-button');
15
16
  export function ToolbarListButton({ className, editor, focus, onClick, icon, title, withArrow, data, alwaysActive, replaceActiveIcon, qa, qaMenu, qaActionDisabledPopover = 'g-md-toolbar-action-disabled-hint', disableHotkey, disablePreview, disableTooltip, }) {
@@ -17,7 +18,8 @@ export function ToolbarListButton({ className, editor, focus, onClick, icon, tit
17
18
  const [open, , hide, toggleOpen] = useBooleanState(false);
18
19
  const [popupItem, setPopupItem] = useState();
19
20
  const zIndex = useTargetZIndex(LAYOUT.STICKY_TOOLBAR);
20
- const everyDisabled = alwaysActive ? false : data.every((item) => !item.isEnable(editor));
21
+ const actionsState = useActionsState(editor, data);
22
+ const everyDisabled = alwaysActive ? false : actionsState.every((item) => !item.enabled);
21
23
  const popupOpen = everyDisabled ? false : open;
22
24
  const shouldForceHide = open && !popupOpen;
23
25
  useEffect(() => {
@@ -27,7 +29,7 @@ export function ToolbarListButton({ className, editor, focus, onClick, icon, tit
27
29
  }, [hide, shouldForceHide]);
28
30
  if (data.length === 0)
29
31
  return null;
30
- const activeItem = data.find((item) => item.isActive(editor) && !item.doNotActivateList);
32
+ const activeItem = data.find((item, idx) => actionsState[idx].active && !item.doNotActivateList);
31
33
  const someActive = alwaysActive ? false : Boolean(activeItem);
32
34
  if (replaceActiveIcon && someActive && activeItem) {
33
35
  icon = activeItem.icon;
@@ -44,11 +46,12 @@ export function ToolbarListButton({ className, editor, focus, onClick, icon, tit
44
46
  else
45
47
  toggleOpen();
46
48
  }, disableTooltip: disableTooltip || popupOpen, children: buttonContent }), _jsx(Popup, { anchorElement: anchorElement, open: popupOpen, onOpenChange: hide, zIndex: typeof zIndex === 'number' ? zIndex : undefined, children: _jsx(Menu, { size: "l", className: b('menu'), qa: qaMenu, "data-toolbar-menu-for": titleText, children: data
47
- .map((data) => {
48
- const { id, title, icon, hotkey, isActive, isEnable, exec, hint, hintWhenDisabled, preview, } = data;
49
+ .map((data, idx) => {
50
+ const { id, title, icon, hotkey, exec, hint, hintWhenDisabled, preview } = data;
49
51
  const titleText = isFunction(title) ? title() : title;
50
52
  const hintText = isFunction(hint) ? hint() : hint;
51
- const disabled = !isEnable(editor);
53
+ const actionState = actionsState[idx];
54
+ const disabled = !actionState.enabled;
52
55
  const hideHintWhenDisabled = hintWhenDisabled === false || !disabled;
53
56
  const hintWhenDisabledText = typeof hintWhenDisabled === 'string'
54
57
  ? hintWhenDisabled
@@ -67,7 +70,7 @@ export function ToolbarListButton({ className, editor, focus, onClick, icon, tit
67
70
  onClick?.(id);
68
71
  }
69
72
  };
70
- return (_jsx(Popover, { className: b('action-disabled-popover'), content: _jsx("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), placement: "left", modal: false, disabled: hideHintWhenDisabled, qa: qaActionDisabledPopover, children: (props, ref) => (_jsx(PreviewTooltip, { preview: preview, disabled: disablePreview, children: _jsx(Menu.Item, { ref: ref, active: isActive(editor), disabled: !isEnable(editor), onClick: handleClick, iconStart: _jsx(Icon, { data: icon.data, size: icon.size ?? 16 }), extraProps: {
73
+ return (_jsx(Popover, { className: b('action-disabled-popover'), content: _jsx("div", { className: b('action-disabled-tooltip'), children: hintWhenDisabledText }), placement: "left", modal: false, disabled: hideHintWhenDisabled, qa: qaActionDisabledPopover, children: (props, ref) => (_jsx(PreviewTooltip, { preview: preview, disabled: disablePreview, children: _jsx(Menu.Item, { ref: ref, active: actionState.active, disabled: disabled, onClick: handleClick, iconStart: _jsx(Icon, { data: icon.data, size: icon.size ?? 16 }), extraProps: {
71
74
  ...props,
72
75
  'aria-label': titleText,
73
76
  }, children: _jsxs("div", { className: b('item'), children: [titleText, !disableHotkey && (_jsxs("div", { className: b('extra'), children: [hotkey && _jsx(Hotkey, { value: hotkey }), hintText && (_jsx(HelpMark, { className: b('hint'), popoverProps: { modal: false }, children: hintText }))] }))] }) }, id) })) }, id));
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarListButton.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarListButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAC,MAAM,EAAC,4BAA0B;AAEzC,OAAO,EAAC,EAAE,EAAC,wBAAqB;AAChC,OAAO,EAAC,IAAI,EAAC,gCAAuB;AACpC,OAAO,EAAC,UAAU,EAAC,qBAAkB;AACrC,OAAO,EAAC,eAAe,EAAC,gCAAuB;AAC/C,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,gCAA6B;AAEtE,OAAO,EAAC,cAAc,EAAC,4BAAyB;AAChD,OAAO,EAAC,iBAAiB,EAAC,2BAAwB;AAQlD,iCAAkC;AAElC,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAC;AAUpC,MAAM,UAAU,iBAAiB,CAAI,EACjC,SAAS,EACT,MAAM,EACN,KAAK,EACL,OAAO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BACN,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":";AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,O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MAAM,EAAE,WAAW,CAAC,MAAM,EAC1B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,WAAW,EACpB,SAAS,EACL,KAAC,IAAI,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,eAAK,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,aACpB,SAAS,EACT,CAAC,aAAa,IAAI,CACf,eAAK,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,aACrB,MAAM,IAAI,KAAC,MAAM,IAAC,KAAK,EAAE,MAAM,GAAI,EACnC,QAAQ,IAAI,CACT,KAAC,QAAQ,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,3 @@
1
+ export type ToolbarRerenderWrapperProps = {
2
+ content: () => React.ReactNode;
3
+ };
@@ -0,0 +1,44 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo } from 'react';
3
+ import { useUpdate } from 'react-use';
4
+ import { EventEmitter } from "../utils/index.js";
5
+ import { ToolbarProvider, useToolbarContext, } from "./context.js";
6
+ /**
7
+ Rerender the content when an update event is received in the event bus from the context.
8
+ @internal
9
+ */
10
+ // TODO [major]: Always expect the toolbar to be wrapped in context; remove this component as unnecessary.
11
+ export function ToolbarUpdateOnRerender({ content }) {
12
+ const rerender = useUpdate();
13
+ const context = useToolbarContext();
14
+ useEffect(() => {
15
+ if (!context)
16
+ return undefined;
17
+ context.eventBus.on('update', rerender);
18
+ return () => {
19
+ context.eventBus.off('update', rerender);
20
+ };
21
+ }, [context, rerender]);
22
+ return _jsx(_Fragment, { children: content() });
23
+ }
24
+ /**
25
+ If there is no external context, wraps the content in the toolbar context
26
+ and emits an update event on each component re-render.
27
+ @internal
28
+ */
29
+ // TODO [major]: Always expect the toolbar to be wrapped in context; remove this component as unnecessary.
30
+ export function ToolbarWrapToContext({ editor, children }) {
31
+ const outerContext = useToolbarContext();
32
+ const innerContext = useMemo(() => {
33
+ if (outerContext)
34
+ return undefined;
35
+ const eventBus = new EventEmitter();
36
+ return { editor, eventBus };
37
+ }, [editor, outerContext]);
38
+ useEffect(() => {
39
+ innerContext?.eventBus.emit('update', null);
40
+ });
41
+ // wrapping in inner context only if there is no outer context
42
+ return innerContext ? (_jsx(ToolbarProvider, { value: innerContext, children: children })) : (_jsx(_Fragment, { children: children }));
43
+ }
44
+ //# sourceMappingURL=ToolbarRerender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarRerender.js","sourceRoot":"../../../src","sources":["toolbar/ToolbarRerender.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAyB,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAC,YAAY,EAAC,0BAAkB;AAEvC,OAAO,EAGH,eAAe,EACf,iBAAiB,GACpB,qBAAkB;AAMnB;;;GAGG;AACH,0GAA0G;AAC1G,MAAM,UAAU,uBAAuB,CAAC,EAAC,OAAO,EAA8B;IAC1E,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IAEpC,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAC/B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxC,OAAO,GAAG,EAAE;YACR,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IAExB,OAAO,4BAAG,OAAO,EAAE,GAAI,CAAC;AAC5B,CAAC;AAMD;;;;GAIG;AACH,0GAA0G;AAC1G,MAAM,UAAU,oBAAoB,CAAI,EAAC,MAAM,EAAE,QAAQ,EAA+B;IACpF,MAAM,YAAY,GAAG,iBAAiB,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,IAAI,YAAY;YAAE,OAAO,SAAS,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAiB,CAAC;QACnD,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAkC,CAAC;IAC/D,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;QACX,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,8DAA8D;IAC9D,OAAO,YAAY,CAAC,CAAC,CAAC,CAClB,KAAC,eAAe,IAAC,KAAK,EAAE,YAAY,YAAG,QAAQ,GAAmB,CACrE,CAAC,CAAC,CAAC,CACA,4BAAG,QAAQ,GAAI,CAClB,CAAC;AACN,CAAC","sourcesContent":["import {type PropsWithChildren, useEffect, useMemo} from 'react';\n\nimport {useUpdate} from 'react-use';\n\nimport {EventEmitter} from 'src/utils';\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,8 @@
1
+ import { createContext, useContext } from 'react';
2
+ // TODO: specify generic editor type
3
+ const ToolbarContext = createContext(undefined);
4
+ export const ToolbarProvider = ToolbarContext.Provider;
5
+ export function useToolbarContext() {
6
+ return useContext(ToolbarContext);
7
+ }
8
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"../../../src","sources":["toolbar/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAchD,oCAAoC;AACpC,MAAM,cAAc,GAAG,aAAa,CAA2C,SAAS,CAAC,CAAC;AAE1F,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC;AAEvD,MAAM,UAAU,iBAAiB;IAC7B,OAAO,UAAU,CAAC,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,64 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { useLatest } from 'react-use';
3
+ import { isEqual } from "../lodash.js";
4
+ import { useToolbarContext } from "./context.js";
5
+ export function useActionState(editor, { isActive, isEnable }) {
6
+ const context = useToolbarContext();
7
+ const eventBus = context?.eventBus;
8
+ const [state, setState] = useState({
9
+ active: false,
10
+ enabled: true,
11
+ });
12
+ const stateRef = useLatest(state);
13
+ useEffect(() => {
14
+ const onUpdate = () => {
15
+ const newActive = isActive(editor);
16
+ const newEnabled = isEnable(editor);
17
+ const { active, enabled } = stateRef.current;
18
+ if (active !== newActive || enabled !== newEnabled) {
19
+ setState({
20
+ active: newActive,
21
+ enabled: newEnabled,
22
+ });
23
+ }
24
+ };
25
+ onUpdate();
26
+ if (eventBus) {
27
+ eventBus.on('update', onUpdate);
28
+ return () => eventBus.off('update', onUpdate);
29
+ }
30
+ return undefined;
31
+ }, [editor, isActive, isEnable, eventBus, stateRef]);
32
+ return state;
33
+ }
34
+ export function useActionsState(editor, actions) {
35
+ const context = useToolbarContext();
36
+ const eventBus = context?.eventBus;
37
+ const [state, setState] = useState(() => actions.map(() => ({
38
+ active: false,
39
+ enabled: true,
40
+ })));
41
+ const stateRef = useLatest(state);
42
+ useEffect(() => {
43
+ const onUpdate = () => {
44
+ const currentState = stateRef.current;
45
+ const newState = actions.map(({ isActive, isEnable }) => ({
46
+ active: isActive(editor),
47
+ enabled: isEnable(editor),
48
+ }));
49
+ if (!isEqual(currentState, newState)) {
50
+ setState(newState);
51
+ }
52
+ };
53
+ onUpdate();
54
+ if (eventBus) {
55
+ eventBus.on('update', onUpdate);
56
+ return () => eventBus.off('update', onUpdate);
57
+ }
58
+ return undefined;
59
+ }, [actions, editor, eventBus, stateRef]);
60
+ return state.length === actions.length
61
+ ? state
62
+ : actions.map(() => ({ active: false, enabled: true }));
63
+ }
64
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"../../../src","sources":["toolbar/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAC,OAAO,EAAC,qBAAmB;AAEnC,OAAO,EAAC,iBAAiB,EAAC,qBAAkB;AAU5C,MAAM,UAAU,cAAc,CAC1B,MAAS,EACT,EAAC,QAAQ,EAAE,QAAQ,EAAmB;IAEtC,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;IAEnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAuB;QACrD,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,IAAI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CAAC;IACF,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAElC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,QAAQ,GAAG,GAAG,EAAE;YAClB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;YACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC;gBACpD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACxB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;aAC5B,CAAC,CAAC,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;gBACnC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;QACL,CAAC,CAAC;QAEF,QAAQ,EAAE,CAAC;QAEX,IAAI,QAAQ,EAAE,CAAC;YACX,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAChC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE1C,OAAO,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QAClC,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAC,MAAM,EAAE,KAAK,EAAE,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"]}
@@ -5,3 +5,4 @@ export * from "./ToolbarButton.js";
5
5
  export * from "./ToolbarGroup.js";
6
6
  export * from "./ToolbarListButton.js";
7
7
  export * from "./FlexToolbar.js";
8
+ export { ToolbarProvider, useToolbarContext, type ToolbarContextValue } from "./context.js";
@@ -5,4 +5,5 @@ export * from "./ToolbarButton.js";
5
5
  export * from "./ToolbarGroup.js";
6
6
  export * from "./ToolbarListButton.js";
7
7
  export * from "./FlexToolbar.js";
8
+ export { ToolbarProvider, useToolbarContext } from "./context.js";
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["toolbar/index.ts"],"names":[],"mappings":"AAAA,2BAAwB;AACxB,2BAAwB;AACxB,6BAA0B;AAC1B,mCAAgC;AAChC,kCAA+B;AAC/B,uCAAoC;AACpC,iCAA8B","sourcesContent":["export * from './const';\nexport * from './types';\nexport * from './Toolbar';\nexport * from './ToolbarButton';\nexport * from './ToolbarGroup';\nexport * from './ToolbarListButton';\nexport * from './FlexToolbar';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../src","sources":["toolbar/index.ts"],"names":[],"mappings":"AAAA,2BAAwB;AACxB,2BAAwB;AACxB,6BAA0B;AAC1B,mCAAgC;AAChC,kCAA+B;AAC/B,uCAAoC;AACpC,iCAA8B;AAE9B,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAA2B,qBAAkB","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,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACvB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,kDAAkD;IAClD,uCAAoB,CAAA;IACpB,kDAAkD;IAClD,4CAAyB,CAAA;IACzB,iDAA8B,CAAA;AAClC,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B","sourcesContent":["import type {HotkeyProps, IconProps, QAProps} from '@gravity-ui/uikit';\n\nimport type {ClassNameProps} from '../classname';\n\nexport type ToolbarBaseProps<E> = ClassNameProps &\n QAProps & {\n editor: E;\n focus(): void;\n onClick?(id: string, attrs?: {[key: string]: any}): void;\n 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,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACvB,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,kDAAkD;IAClD,uCAAoB,CAAA;IACpB,kDAAkD;IAClD,4CAAyB,CAAA;IACzB,iDAA8B,CAAA;AAClC,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B","sourcesContent":["import type {HotkeyProps, IconProps, QAProps} from '@gravity-ui/uikit';\n\nimport type {ClassNameProps} from '../classname';\n\nexport type ToolbarBaseProps<E> = ClassNameProps &\n QAProps & {\n editor: E;\n focus(): void;\n onClick?(id: string, attrs?: {[key: string]: any}): void;\n 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"]}
@@ -1,3 +1,3 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '15.34.5' !== 'undefined' ? '15.34.5' : 'unknown';
2
+ export const VERSION = typeof '15.35.0' !== 'undefined' ? '15.35.0' : 'unknown';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.34.5' !== 'undefined' ? '15.34.5' : 'unknown';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"../../src","sources":["version.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC","sourcesContent":["/** During build process, the current version will be injected here */\nexport const VERSION = typeof '15.35.0' !== 'undefined' ? '15.35.0' : 'unknown';\n"]}
@@ -8,7 +8,12 @@ export function withMermaid(opts) {
8
8
  const renderMermaid = useMermaid();
9
9
  useMermaidRuntime(meta, opts.runtime);
10
10
  useEffect(() => {
11
- renderMermaid(mermaidConfig);
11
+ // do not render mermaid diagrams inside the editor component
12
+ // because they are handled differently (no data-content attribute)
13
+ // and the editor is managing their render itself
14
+ renderMermaid(mermaidConfig, {
15
+ querySelector: '.mermaid:not(.g-md-wysiwyg-editor .mermaid)',
16
+ });
12
17
  }, [html, mermaidConfig, renderMermaid]);
13
18
  return _jsx(Component, { ...props, ref: ref });
14
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["view/hocs/withMermaid/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAyC,UAAU,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAEpF,OAAO,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAC;AAG7D,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AAatD,MAAM,UAAU,WAAW,CAAC,IAAwB;IAChD,OAAO,CACH,SAA2D,EAC7D,EAAE,CACA,UAAU,CAAuC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG;QAC1E,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAC,GAAG,KAAK,CAAC;QAE1C,MAAM,aAAa,GAAG,UAAU,EAAE,CAAC;QAEnC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,SAAS,CAAC,GAAG,EAAE;YACX,aAAa,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;QAEzC,OAAO,KAAC,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 renderMermaid(mermaidConfig);\n }, [html, mermaidConfig, renderMermaid]);\n\n return <Component {...props} ref={ref} />;\n });\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["view/hocs/withMermaid/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAyC,UAAU,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAEpF,OAAO,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAC;AAG7D,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AAatD,MAAM,UAAU,WAAW,CAAC,IAAwB;IAChD,OAAO,CACH,SAA2D,EAC7D,EAAE,CACA,UAAU,CAAuC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG;QAC1E,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAC,GAAG,KAAK,CAAC;QAE1C,MAAM,aAAa,GAAG,UAAU,EAAE,CAAC;QAEnC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,SAAS,CAAC,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,KAAC,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"]}
package/build/styles.css CHANGED
@@ -279,7 +279,7 @@
279
279
 
280
280
  .yfm {
281
281
  --yfm-hr-height: 4px;
282
- --yfm-hr-margin: 24px;
282
+ --yfm-hr-margin: 24px 0;
283
283
  }
284
284
 
285
285
  .g-root .yfm:not(.yfm_only-light) {
@@ -609,6 +609,11 @@
609
609
  .yfm li > p:last-child {
610
610
  margin-block: var(--yfm-list-text-only-margin-block, 0);
611
611
  }
612
+
613
+ .yfm {
614
+ --yfm-hr-height: 4px;
615
+ --yfm-hr-margin: 24px 0;
616
+ }
612
617
  .g-root {
613
618
  --yfm-color-text-gray: var(--g-color-text-secondary);
614
619
  --yfm-color-text-yellow: var(--g-color-private-yellow-600-solid);
@@ -634,7 +639,7 @@
634
639
  }
635
640
  .yfm {
636
641
  --yfm-hr-height: 4px;
637
- --yfm-hr-margin: 24px;
642
+ --yfm-hr-margin: 24px 0;
638
643
  }
639
644
  .yfm {
640
645
  --yfm-color-base: var(--g-color-base-background);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "15.34.5",
3
+ "version": "15.35.0",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,18 +14,6 @@
14
14
  "codemirror",
15
15
  "prosemirror"
16
16
  ],
17
- "devEngines": {
18
- "runtime": {
19
- "name": "node",
20
- "version": "24",
21
- "onFail": "warn"
22
- },
23
- "packageManager": {
24
- "name": "pnpm",
25
- "version": "10.17.1",
26
- "onFail": "warn"
27
- }
28
- },
29
17
  "exports": {
30
18
  ".": {
31
19
  "import": {
@@ -173,7 +161,7 @@
173
161
  "@lezer/highlight": "^1.2.1",
174
162
  "@lezer/markdown": "^1.4.0",
175
163
  "@types/is-number": "^7.0.1",
176
- "@types/markdown-it": "^12.2.3",
164
+ "@types/markdown-it": "^13.0.0",
177
165
  "base64-arraybuffer": "1.0.2",
178
166
  "is-number": "^7.0.0",
179
167
  "lodash": "^4.17.21",
@@ -206,35 +194,19 @@
206
194
  "uuid": "11.0.5"
207
195
  },
208
196
  "devDependencies": {
209
- "@babel/preset-env": "7.28.5",
210
- "@babel/preset-react": "7.28.5",
211
- "@babel/preset-typescript": "7.28.5",
212
- "@commitlint/cli": "20.2.0",
213
- "@commitlint/config-conventional": "20.2.0",
214
197
  "@diplodoc/cut-extension": "^1.1.0",
198
+ "@diplodoc/file-extension": "^0.2.1",
215
199
  "@diplodoc/folding-headings-extension": "^0.1.2",
216
200
  "@diplodoc/html-extension": "^2.9.1",
217
201
  "@diplodoc/latex-extension": "^1.4.1",
218
- "@diplodoc/mermaid-extension": "^1.4.0",
202
+ "@diplodoc/mermaid-extension": "^2.0.0",
219
203
  "@diplodoc/quote-link-extension": "0.1.3",
220
204
  "@diplodoc/tabs-extension": "^3.7.5",
221
205
  "@diplodoc/themes": "^1.0.0",
222
- "@diplodoc/transform": "4.66.0",
206
+ "@diplodoc/transform": "4.69.0",
223
207
  "@gravity-ui/components": "4.10.0",
224
- "@gravity-ui/eslint-config": "4.2.0",
225
208
  "@gravity-ui/gulp-utils": "1.0.3",
226
- "@gravity-ui/prettier-config": "1.1.0",
227
- "@gravity-ui/stylelint-config": "5.0.0",
228
- "@gravity-ui/tsconfig": "1.0.0",
229
209
  "@gravity-ui/uikit": "^7.13.1",
230
- "@playwright/experimental-ct-react": "1.49.0",
231
- "@playwright/test": "1.49.0",
232
- "@storybook/addon-docs": "10.1.10",
233
- "@storybook/addon-webpack5-compiler-babel": "4.0.0",
234
- "@storybook/cli": "10.1.10",
235
- "@storybook/preset-scss": "1.0.3",
236
- "@storybook/react": "10.1.10",
237
- "@storybook/react-webpack5": "10.1.10",
238
210
  "@types/gulp": "4.0.9",
239
211
  "@types/gulp-sass": "5.0.0",
240
212
  "@types/jest": "^29.5.14",
@@ -248,43 +220,37 @@
248
220
  "@types/sanitize-html": "2.11.0",
249
221
  "bem-cn-lite": "4.1.0",
250
222
  "dpdm": "3.14.0",
251
- "esbuild": "0.25.0",
223
+ "esbuild": "0.21.5",
252
224
  "esbuild-sass-plugin": "2.15.0",
253
- "eslint": "9.39.2",
254
- "eslint-plugin-lodash": "8.0.0",
255
- "eslint-plugin-react": "7.37.5",
256
225
  "gulp": "5.0.0",
257
226
  "gulp-cli": "3.0.0",
258
227
  "gulp-concat": "2.6.1",
259
228
  "gulp-replace": "1.1.3",
260
229
  "gulp-sass": "6.0.0",
261
230
  "gulp-sourcemaps": "3.0.0",
231
+ "highlight.js": "^11.8.0",
262
232
  "identity-obj-proxy": "^3.0.0",
263
233
  "ist": "1.1.7",
264
234
  "jest": "^29.7.0",
265
235
  "jest-css-modules": "^2.1.0",
266
236
  "jest-environment-jsdom": "^29.7.0",
267
237
  "jsdom": "25.0.1",
238
+ "katex": "^0.16.9",
268
239
  "lowlight": "3.0.0",
240
+ "markdown-it": "^13.0.0",
269
241
  "markdown-it-testgen": "^0.1.6",
270
- "mermaid": "11.10.0",
242
+ "mermaid": "11.13.0",
271
243
  "npm-run-all": "^4.1.5",
272
- "path-browserify": "1.0.1",
273
244
  "postcss": "8.5.6",
274
245
  "prettier": "3.7.4",
275
- "process": "0.11.10",
276
- "prosemirror-dev-toolkit": "1.1.8",
277
246
  "react": "18.2.0",
278
247
  "react-dom": "18.2.0",
279
248
  "rimraf": "3.0.2",
280
249
  "sass": "^1.84.0",
281
250
  "sass-loader": "^13.3.2",
282
- "storybook": "10.1.10",
283
- "stylelint": "16.26.1",
284
251
  "ts-jest": "^29.2.5",
285
252
  "typescript": "^5.9.3",
286
- "url": "0.11.4",
287
- "webpack": "^5.97.1"
253
+ "@markdown-editor/tsconfig": "0.0.0"
288
254
  },
289
255
  "peerDependenciesMeta": {
290
256
  "@diplodoc/folding-headings-extension": {
@@ -315,7 +281,7 @@
315
281
  "@diplodoc/folding-headings-extension": "^0.1.0",
316
282
  "@diplodoc/html-extension": "^2.3.2",
317
283
  "@diplodoc/latex-extension": "^1.0.3",
318
- "@diplodoc/mermaid-extension": "^1.0.0",
284
+ "@diplodoc/mermaid-extension": "^1.0.0 || ^2.0.0",
319
285
  "@diplodoc/quote-link-extension": "^0.1.3",
320
286
  "@diplodoc/tabs-extension": "^3.5.1",
321
287
  "@diplodoc/transform": "^4.43.0",
@@ -328,17 +294,6 @@
328
294
  "react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
329
295
  "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
330
296
  },
331
- "lint-staged": {
332
- "*.{css,scss}": [
333
- "stylelint --fix",
334
- "prettier --write"
335
- ],
336
- "*.{js,jsx,ts,tsx}": [
337
- "eslint --cache --fix --quiet",
338
- "prettier --write"
339
- ],
340
- "*.{md,json,yaml,yml}": "prettier --write"
341
- },
342
297
  "sideEffects": [
343
298
  "*.css",
344
299
  "*.scss",
@@ -348,34 +303,17 @@
348
303
  "build/**/shortcuts/default.js"
349
304
  ],
350
305
  "scripts": {
351
- "deps:global": "npm install -g pnpm@10.17.1",
352
- "deps:ci": "pnpm i --frozen-lockfile",
353
- "start": "pnpm run sb:start",
354
306
  "clean": "gulp clean",
355
- "build": "gulp",
307
+ "build": "gulp build",
356
308
  "typecheck": "tsc -p tsconfig.json --noEmit",
357
- "sb:start": "storybook dev -p 8888 -c .storybook",
358
- "sb:build": "storybook build -c .storybook -o storybook-static",
359
309
  "lint": "run-p -cs lint:*",
360
- "lint:js": "eslint \"{src,demo}/**/*.{js,jsx,ts,tsx}\"",
361
- "lint:styles": "stylelint \"{src,demo}/**/*.{css,scss}\"",
362
- "lint:prettier": "prettier --check \"{src,demo}/**/*.{js,jsx,ts,tsx,css,scss}\"",
363
- "check-circular-deps": "node scripts/check-circular-deps.js 49",
310
+ "lint:js": "eslint './**/*.{js,jsx,mjs,ts,tsx}'",
311
+ "lint:styles": "stylelint './**/*.{css,scss}'",
312
+ "lint:prettier": "prettier --check './**/*.{js,jsx,mjs,ts,tsx,css,scss}'",
364
313
  "test": "jest",
365
314
  "test:cov": "jest --coverage",
366
315
  "test:watch": "jest --watchAll",
367
316
  "test:esbuild": "node tests/esbuild-test/esbuild-tester.js",
368
- "playwright:install": "playwright install chromium webkit --with-deps",
369
- "playwright": "playwright test --config=tests/playwright/playwright.config.ts",
370
- "playwright:generate": "node scripts/generate-playwright-test.js",
371
- "playwright:watch": "pnpm run playwright --ui",
372
- "playwright:headed": "playwright test --config=tests/playwright/playwright.config.ts --headed",
373
- "playwright:update": "pnpm run playwright -u",
374
- "playwright:clear": "rm -rf ./tests/playwright/.cache",
375
- "playwright:report": "playwright show-report playwright-report",
376
- "playwright:docker": "./scripts/playwright-docker.sh test",
377
- "playwright:docker:update": "./scripts/playwright-docker.sh update",
378
- "playwright:docker:clear": "./scripts/playwright-docker.sh clear",
379
- "playwright:docker:report": "playwright show-report playwright-report-docker"
317
+ "test:circular-deps": "node scripts/check-circular-deps.js 48"
380
318
  }
381
319
  }