@frontify/fondue 12.0.0-beta.10 → 12.0.0-beta.11

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 (44) hide show
  1. package/dist/components/RichTextEditor/Plugins/CheckboxListPlugin/CheckboxListButton/CheckboxListToolbarButton.es.js +8 -9
  2. package/dist/components/RichTextEditor/Plugins/CheckboxListPlugin/CheckboxListButton/CheckboxListToolbarButton.es.js.map +1 -1
  3. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js +7 -5
  4. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js.map +1 -1
  5. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.d.ts +3 -3
  6. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.es.js +1678 -23
  7. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.es.js.map +1 -1
  8. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/index.d.ts +0 -1
  9. package/dist/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js.map +1 -1
  10. package/dist/components/RichTextEditor/Plugins/LinkPlugin/index.es.js +16 -10
  11. package/dist/components/RichTextEditor/Plugins/LinkPlugin/index.es.js.map +1 -1
  12. package/dist/components/RichTextEditor/Plugins/MentionPlugin/MentionMarkupElement/MentionMarkupElementNode.es.js +1 -1
  13. package/dist/components/RichTextEditor/Plugins/MentionPlugin/MentionMarkupElement/MentionMarkupElementNode.es.js.map +1 -1
  14. package/dist/components/RichTextEditor/Plugins/MentionPlugin/createMentionPlugin.es.js.map +1 -1
  15. package/dist/components/RichTextEditor/Plugins/MentionPlugin/index.d.ts +2 -0
  16. package/dist/components/RichTextEditor/Plugins/MentionPlugin/index.es.js.map +1 -1
  17. package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.d.ts +3 -8
  18. package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.es.js +1 -1
  19. package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.es.js.map +1 -1
  20. package/dist/components/RichTextEditor/RichTextEditor.es.js +36 -36
  21. package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
  22. package/dist/components/RichTextEditor/context/RichTextEditorContext.d.ts +1 -1
  23. package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js +16 -15
  24. package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js.map +1 -1
  25. package/dist/components/RichTextEditor/utils/parseRawValue.d.ts +1 -1
  26. package/dist/components/RichTextEditor/utils/parseRawValue.es.js +13 -13
  27. package/dist/components/RichTextEditor/utils/parseRawValue.es.js.map +1 -1
  28. package/dist/components/Tree/Node.es.js +1795 -127
  29. package/dist/components/Tree/Node.es.js.map +1 -1
  30. package/dist/components/Tree/Tree.d.ts +2 -1
  31. package/dist/components/Tree/Tree.es.js.map +1 -1
  32. package/dist/components/Tree/utils/mocks.es.js +5 -4
  33. package/dist/components/Tree/utils/mocks.es.js.map +1 -1
  34. package/dist/index.cjs.js +4 -4
  35. package/dist/index.cjs.js.map +1 -1
  36. package/dist/index.es.js +3332 -3330
  37. package/dist/index.es.js.map +1 -1
  38. package/dist/index.umd.js +4 -4
  39. package/dist/index.umd.js.map +1 -1
  40. package/dist/styles.css +1 -1
  41. package/package.json +1 -1
  42. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.d.ts +0 -2
  43. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js +0 -36
  44. package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingLink.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n FloatingLinkEditButton,\n FloatingLinkProps,\n OpenLinkButton,\n UnlinkButton,\n createComponentAs,\n createElementAs,\n} from '@udecode/plate';\nimport { EditModal, useFloatingLinkEdit } from './EditLinkModal';\nimport { InsertModal, useFloatingLinkInsert } from './InsertLinkModal';\n\nconst FloatingLinkInsertRoot = createComponentAs<FloatingLinkProps>((props) => {\n const htmlProps = useFloatingLinkInsert(props);\n\n if (htmlProps.style?.display === 'none') {\n return null;\n }\n\n return createElementAs('div', htmlProps);\n});\n\nconst FloatingLinkEditRoot = createComponentAs<FloatingLinkProps>((props) => {\n const htmlProps = useFloatingLinkEdit(props);\n\n if (htmlProps.style?.display === 'none') {\n return null;\n }\n\n return createElementAs('div', htmlProps);\n});\n\nexport const FloatingLink = {\n EditRoot: FloatingLinkEditRoot,\n InsertRoot: FloatingLinkInsertRoot,\n EditModal,\n InsertModal,\n EditButton: FloatingLinkEditButton,\n UnlinkButton,\n OpenLinkButton,\n};\n"],"names":[],"mappings":";;;;;AAaA,MAAM,IAAyB,EAAqC,CAAC,MAAU;;AACrE,QAAA,IAAY,EAAsB,CAAK;AAEzC,SAAA,QAAU,UAAV,kBAAiB,aAAY,SACtB,OAGJ,EAAgB,OAAO,CAAS;AAC3C,CAAC,GAEK,IAAuB,EAAqC,CAAC,MAAU;;AACnE,QAAA,IAAY,EAAoB,CAAK;AAEvC,SAAA,QAAU,UAAV,kBAAiB,aAAY,SACtB,OAGJ,EAAgB,OAAO,CAAS;AAC3C,CAAC,GAEY,IAAe;AAAA,EACxB,UAAU;AAAA,EACV,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AACJ;"}
1
+ {"version":3,"file":"FloatingLink.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n FloatingLinkProps,\n FloatingLink as PlateFloatingLink,\n createComponentAs,\n createElementAs,\n useFloatingLinkInsert,\n} from '@udecode/plate';\nimport { useFloatingLinkEdit } from './EditLinkModal';\n\nconst FloatingLinkInsertRoot = createComponentAs<FloatingLinkProps>((props) => {\n const htmlProps = useFloatingLinkInsert(props);\n\n if (htmlProps.style?.display === 'none') {\n return null;\n }\n\n return createElementAs('div', htmlProps);\n});\n\nconst FloatingLinkEditRoot = createComponentAs<FloatingLinkProps>((props) => {\n const htmlProps = useFloatingLinkEdit(props);\n\n if (htmlProps.style?.display === 'none') {\n return null;\n }\n\n return createElementAs('div', htmlProps);\n});\n\nPlateFloatingLink.EditRoot = FloatingLinkEditRoot;\nPlateFloatingLink.InsertRoot = FloatingLinkInsertRoot;\n\nexport const FloatingLink = PlateFloatingLink;\n"],"names":["PlateFloatingLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,IAAyB,EAAqC,CAAC,MAAU;;AACrE,QAAA,IAAY,EAAsB,CAAK;AAEzC,SAAA,QAAU,UAAV,kBAAiB,aAAY,SACtB,OAGJ,EAAgB,OAAO,CAAS;AAC3C,CAAC,GAEK,IAAuB,EAAqC,CAAC,MAAU;;AACnE,QAAA,IAAY,EAAoB,CAAK;AAEvC,SAAA,QAAU,UAAV,kBAAiB,aAAY,SACtB,OAGJ,EAAgB,OAAO,CAAS;AAC3C,CAAC;AAEDA,EAAkB,WAAW;AAC7BA,EAAkB,aAAa;AAExB,MAAM,KAAeA;"}
@@ -1,2 +1 @@
1
1
  export * from './InsertModal';
2
- export * from './useFloatingLinkInsert';
@@ -1 +1 @@
1
- {"version":3,"file":"LinkMarkupElementNode.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { HTMLPropsAs, LinkRootProps, useElementProps } from '@udecode/plate';\nimport { getUrlFromLinkOrLegacyLink } from '../utils';\nimport { TLinkElement } from '../types';\nimport { useRichTextEditorContext } from '@components/RichTextEditor/context/RichTextEditorContext';\n\nconst useLink = (props: LinkRootProps): HTMLPropsAs<'a'> => {\n const _props = useElementProps<TLinkElement, 'a'>({\n ...props,\n elementToAttributes: (element) => ({\n href: getUrlFromLinkOrLegacyLink(element),\n target: element.target || '_blank',\n }),\n });\n\n return {\n ..._props,\n // quick fix: hovering <a> with href loses the editor focus\n onMouseOver: (e) => {\n e.stopPropagation();\n },\n };\n};\n\nexport const LinkMarkupElementNode = (props: LinkRootProps) => {\n const htmlProps = useLink(props);\n const { designTokens } = useRichTextEditorContext();\n const { attributes, children } = props;\n\n return (\n <a {...attributes} href={htmlProps.href} target={htmlProps.target} style={designTokens.link}>\n {children}\n </a>\n );\n};\n"],"names":[],"mappings":";;;;AAQA,MAAM,IAAU,CAAC,MASN;AAAA,EACH,GATW,EAAmC;AAAA,IAC9C,GAAG;AAAA,IACH,qBAAqB,CAAC,MAAa;AAAA,MAC/B,MAAM,EAA2B,CAAO;AAAA,MACxC,QAAQ,EAAQ,UAAU;AAAA,IAAA;AAAA,EAC9B,CACH;AAAA,EAKG,aAAa,CAAC,MAAM;AAChB,MAAE,gBAAgB;AAAA,EACtB;AAAA,IAIK,IAAwB,CAAC,MAAyB;AACrD,QAAA,IAAY,EAAQ,CAAK,GACzB,EAAE,oBAAiB,KACnB,EAAE,eAAY,gBAAa;AAEjC,SACK,kBAAA,cAAA,KAAA;AAAA,IAAG,GAAG;AAAA,IAAY,MAAM,EAAU;AAAA,IAAM,QAAQ,EAAU;AAAA,IAAQ,OAAO,EAAa;AAAA,EAAA,GAClF,CACL;AAER;"}
1
+ {"version":3,"file":"LinkMarkupElementNode.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { HTMLPropsAs, LinkRootProps, useElementProps } from '@udecode/plate';\nimport { getUrlFromLinkOrLegacyLink } from '../utils';\nimport { TLinkElement } from '../types';\nimport { useRichTextEditorContext } from '@components/RichTextEditor/context/RichTextEditorContext';\n\nconst useLink = (props: LinkRootProps): HTMLPropsAs<'a'> => {\n const _props = useElementProps<TLinkElement, 'a'>({\n ...props,\n elementToAttributes: (element) => ({\n href: getUrlFromLinkOrLegacyLink(element),\n target: element.target || '_blank',\n }),\n });\n\n return {\n ..._props,\n // quick fix: hovering <a> with href loses the editor focus\n onMouseOver: (e: MouseEvent) => {\n e.stopPropagation();\n },\n };\n};\n\nexport const LinkMarkupElementNode = (props: LinkRootProps) => {\n const htmlProps = useLink(props);\n const { designTokens } = useRichTextEditorContext();\n const { attributes, children } = props;\n\n return (\n <a {...attributes} href={htmlProps.href} target={htmlProps.target} style={designTokens.link}>\n {children}\n </a>\n );\n};\n"],"names":[],"mappings":";;;;AAQA,MAAM,IAAU,CAAC,MASN;AAAA,EACH,GATW,EAAmC;AAAA,IAC9C,GAAG;AAAA,IACH,qBAAqB,CAAC,MAAa;AAAA,MAC/B,MAAM,EAA2B,CAAO;AAAA,MACxC,QAAQ,EAAQ,UAAU;AAAA,IAAA;AAAA,EAC9B,CACH;AAAA,EAKG,aAAa,CAAC,MAAkB;AAC5B,MAAE,gBAAgB;AAAA,EACtB;AAAA,IAIK,IAAwB,CAAC,MAAyB;AACrD,QAAA,IAAY,EAAQ,CAAK,GACzB,EAAE,oBAAiB,KACnB,EAAE,eAAY,gBAAa;AAEjC,SACK,kBAAA,cAAA,KAAA;AAAA,IAAG,GAAG;AAAA,IAAY,MAAM,EAAU;AAAA,IAAM,QAAQ,EAAU;AAAA,IAAQ,OAAO,EAAa;AAAA,EAAA,GAClF,CACL;AAER;"}
@@ -1,31 +1,37 @@
1
1
  import { createPluginFactory as t, createLinkPlugin as i } from "@udecode/plate";
2
2
  import { LINK_PLUGIN as n } from "./id.es.js";
3
- import { LinkMarkupElement as o } from "./LinkMarkupElement/index.es.js";
4
- import { LinkButton as e } from "./LinkButton.es.js";
3
+ import { LinkMarkupElement as e } from "./LinkMarkupElement/index.es.js";
4
+ import { LinkButton as o } from "./LinkButton.es.js";
5
5
  import { CustomFloatingLink as m } from "./FloatingLink/CustomFloatingLink.es.js";
6
- import { Plugin as u } from "../Plugin.es.js";
6
+ import { Plugin as a } from "../Plugin.es.js";
7
7
  import { isUrlOrPath as l } from "./utils/isUrlOrPath.es.js";
8
- const p = t({
8
+ const u = t({
9
9
  ...i(),
10
10
  renderAfterEditable: m,
11
11
  options: {
12
- isUrl: l
12
+ isUrl: l,
13
+ rangeBeforeOptions: {
14
+ matchString: " ",
15
+ skipInvalid: !0,
16
+ afterMatch: !0
17
+ },
18
+ triggerFloatingLinkHotkeys: "command+k, ctrl+k"
13
19
  }
14
20
  });
15
- class d extends u {
21
+ class d extends a {
16
22
  constructor(r) {
17
23
  super(n, {
18
- button: e,
19
- markupElement: new o(),
24
+ button: o,
25
+ markupElement: new e(),
20
26
  ...r
21
27
  });
22
28
  }
23
29
  plugins() {
24
- return [p()];
30
+ return [u()];
25
31
  }
26
32
  }
27
33
  export {
28
34
  d as LinkPlugin,
29
- p as createLinkPlugin
35
+ u as createLinkPlugin
30
36
  };
31
37
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/index.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { createLinkPlugin as createPlateLinkPlugin, createPluginFactory } from '@udecode/plate';\nimport { LINK_PLUGIN } from './id';\nimport { LinkMarkupElement } from './LinkMarkupElement';\nimport { LinkButton } from './LinkButton';\nimport { CustomFloatingLink } from './FloatingLink/CustomFloatingLink';\nimport { Plugin, PluginProps } from '../Plugin';\nimport { isUrlOrPath } from './utils';\n\nexport const createLinkPlugin = createPluginFactory({\n ...createPlateLinkPlugin(),\n renderAfterEditable: CustomFloatingLink,\n options: {\n isUrl: isUrlOrPath,\n },\n});\n\nexport class LinkPlugin extends Plugin {\n constructor(props?: PluginProps) {\n super(LINK_PLUGIN, {\n button: LinkButton,\n markupElement: new LinkMarkupElement(),\n ...props,\n });\n }\n\n plugins() {\n return [createLinkPlugin()];\n }\n}\n"],"names":["createPlateLinkPlugin"],"mappings":";;;;;;;AAUO,MAAM,IAAmB,EAAoB;AAAA,EAChD,GAAGA,EAAsB;AAAA,EACzB,qBAAqB;AAAA,EACrB,SAAS;AAAA,IACL,OAAO;AAAA,EACX;AACJ,CAAC;AAEM,MAAM,UAAmB,EAAO;AAAA,EACnC,YAAY,GAAqB;AAC7B,UAAM,GAAa;AAAA,MACf,QAAQ;AAAA,MACR,eAAe,IAAI,EAAkB;AAAA,MACrC,GAAG;AAAA,IAAA,CACN;AAAA,EACL;AAAA,EAEA,UAAU;AACC,WAAA,CAAC,GAAkB;AAAA,EAC9B;AACJ;"}
1
+ {"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/index.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { createLinkPlugin as createPlateLinkPlugin, createPluginFactory } from '@udecode/plate';\nimport { LINK_PLUGIN } from './id';\nimport { LinkMarkupElement } from './LinkMarkupElement';\nimport { LinkButton } from './LinkButton';\nimport { CustomFloatingLink } from './FloatingLink/CustomFloatingLink';\nimport { Plugin, PluginProps } from '../Plugin';\nimport { isUrlOrPath } from './utils';\n\nexport const createLinkPlugin = createPluginFactory({\n ...createPlateLinkPlugin(),\n renderAfterEditable: CustomFloatingLink,\n options: {\n isUrl: isUrlOrPath,\n rangeBeforeOptions: {\n matchString: ' ',\n skipInvalid: true,\n afterMatch: true,\n },\n triggerFloatingLinkHotkeys: 'command+k, ctrl+k',\n },\n});\n\nexport class LinkPlugin extends Plugin {\n constructor(props?: PluginProps) {\n super(LINK_PLUGIN, {\n button: LinkButton,\n markupElement: new LinkMarkupElement(),\n ...props,\n });\n }\n\n plugins() {\n return [createLinkPlugin()];\n }\n}\n"],"names":["createPlateLinkPlugin"],"mappings":";;;;;;;AAUO,MAAM,IAAmB,EAAoB;AAAA,EAChD,GAAGA,EAAsB;AAAA,EACzB,qBAAqB;AAAA,EACrB,SAAS;AAAA,IACL,OAAO;AAAA,IACP,oBAAoB;AAAA,MAChB,aAAa;AAAA,MACb,aAAa;AAAA,MACb,YAAY;AAAA,IAChB;AAAA,IACA,4BAA4B;AAAA,EAChC;AACJ,CAAC;AAEM,MAAM,UAAmB,EAAO;AAAA,EACnC,YAAY,GAAqB;AAC7B,UAAM,GAAa;AAAA,MACf,QAAQ;AAAA,MACR,eAAe,IAAI,EAAkB;AAAA,MACrC,GAAG;AAAA,IAAA,CACN;AAAA,EACL;AAAA,EAEA,UAAU;AACC,WAAA,CAAC,GAAkB;AAAA,EAC9B;AACJ;"}
@@ -1,6 +1,6 @@
1
1
  import u from "react";
2
2
  import { useSelected as m, useFocused as b } from "slate-react";
3
- import { TCategory as t } from "../types.es.js";
3
+ import { MentionableCategory as t } from "../types.es.js";
4
4
  const y = (n) => {
5
5
  var o;
6
6
  const { attributes: r, children: l, element: e, nodeProps: c, prefix: d, renderLabel: a } = n, s = m(), i = b(), p = {
@@ -1 +1 @@
1
- {"version":3,"file":"MentionMarkupElementNode.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/MentionMarkupElement/MentionMarkupElementNode.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { useFocused, useSelected } from 'slate-react';\nimport { MentionElementProps, Value } from '@udecode/plate';\nimport { TCategory } from '../types';\n\nexport const MentionMarkupElementNode = (props: MentionElementProps<Value>) => {\n const { attributes, children, element, nodeProps, prefix, renderLabel } = props;\n\n const selected = useSelected();\n const focused = useFocused();\n\n const backgroundColor: Record<TCategory, string> = {\n [TCategory.GROUP]: '#00FF00',\n [TCategory.USER]: '#ff0000',\n [TCategory.ALL]: '#0000FF',\n };\n\n return (\n <span\n {...attributes}\n data-slate-value={element.value}\n data-slate-key={element.key}\n data-slate-category={element.category}\n contentEditable={false}\n data-cy={`mention-${element.value?.replaceAll(' ', '-')}`}\n style={{\n padding: '3px 3px 2px',\n margin: '0 1px',\n verticalAlign: 'baseline',\n display: 'inline-block',\n borderRadius: '4px',\n backgroundColor: backgroundColor[element.category as TCategory],\n fontSize: '0.9em',\n boxShadow: selected && focused ? '0 0 0 2px #B4D5FF' : 'none',\n }}\n {...nodeProps}\n >\n {prefix}\n {renderLabel ? renderLabel(element) : element.value}\n {children}\n </span>\n );\n};\n"],"names":[],"mappings":";;;AAOa,MAAA,IAA2B,CAAC,MAAsC;;AAC3E,QAAM,EAAE,eAAY,aAAU,YAAS,cAAW,WAAQ,mBAAgB,GAEpE,IAAW,KACX,IAAU,KAEV,IAA6C;AAAA,IAC/C,CAAC,EAAU,QAAQ;AAAA,IACnB,CAAC,EAAU,OAAO;AAAA,IAClB,CAAC,EAAU,MAAM;AAAA,EAAA;AAGrB,SACK,kBAAA,cAAA,QAAA;AAAA,IACI,GAAG;AAAA,IACJ,oBAAkB,EAAQ;AAAA,IAC1B,kBAAgB,EAAQ;AAAA,IACxB,uBAAqB,EAAQ;AAAA,IAC7B,iBAAiB;AAAA,IACjB,WAAS,WAAW,OAAQ,UAAR,kBAAe,WAAW,KAAK;AAAA,IACnD,OAAO;AAAA,MACH,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,eAAe;AAAA,MACf,SAAS;AAAA,MACT,cAAc;AAAA,MACd,iBAAiB,EAAgB,EAAQ;AAAA,MACzC,UAAU;AAAA,MACV,WAAW,KAAY,IAAU,sBAAsB;AAAA,IAC3D;AAAA,IACC,GAAG;AAAA,EAAA,GAEH,GACA,IAAc,EAAY,CAAO,IAAI,EAAQ,OAC7C,CACL;AAER;"}
1
+ {"version":3,"file":"MentionMarkupElementNode.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/MentionMarkupElement/MentionMarkupElementNode.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { useFocused, useSelected } from 'slate-react';\nimport { MentionElementProps, Value } from '@udecode/plate';\nimport { MentionableCategory } from '../types';\n\nexport const MentionMarkupElementNode = (props: MentionElementProps<Value>) => {\n const { attributes, children, element, nodeProps, prefix, renderLabel } = props;\n\n const selected = useSelected();\n const focused = useFocused();\n\n const backgroundColor: Record<MentionableCategory, string> = {\n [MentionableCategory.GROUP]: '#00FF00',\n [MentionableCategory.USER]: '#ff0000',\n [MentionableCategory.ALL]: '#0000FF',\n };\n\n return (\n <span\n {...attributes}\n data-slate-value={element.value}\n data-slate-key={element.key}\n data-slate-category={element.category}\n contentEditable={false}\n data-cy={`mention-${element.value?.replaceAll(' ', '-')}`}\n style={{\n padding: '3px 3px 2px',\n margin: '0 1px',\n verticalAlign: 'baseline',\n display: 'inline-block',\n borderRadius: '4px',\n backgroundColor: backgroundColor[element.category as MentionableCategory],\n fontSize: '0.9em',\n boxShadow: selected && focused ? '0 0 0 2px #B4D5FF' : 'none',\n }}\n {...nodeProps}\n >\n {prefix}\n {renderLabel ? renderLabel(element) : element.value}\n {children}\n </span>\n );\n};\n"],"names":[],"mappings":";;;AAOa,MAAA,IAA2B,CAAC,MAAsC;;AAC3E,QAAM,EAAE,eAAY,aAAU,YAAS,cAAW,WAAQ,mBAAgB,GAEpE,IAAW,KACX,IAAU,KAEV,IAAuD;AAAA,IACzD,CAAC,EAAoB,QAAQ;AAAA,IAC7B,CAAC,EAAoB,OAAO;AAAA,IAC5B,CAAC,EAAoB,MAAM;AAAA,EAAA;AAG/B,SACK,kBAAA,cAAA,QAAA;AAAA,IACI,GAAG;AAAA,IACJ,oBAAkB,EAAQ;AAAA,IAC1B,kBAAgB,EAAQ;AAAA,IACxB,uBAAqB,EAAQ;AAAA,IAC7B,iBAAiB;AAAA,IACjB,WAAS,WAAW,OAAQ,UAAR,kBAAe,WAAW,KAAK;AAAA,IACnD,OAAO;AAAA,MACH,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,eAAe;AAAA,MACf,SAAS;AAAA,MACT,cAAc;AAAA,MACd,iBAAiB,EAAgB,EAAQ;AAAA,MACzC,UAAU;AAAA,MACV,WAAW,KAAY,IAAU,sBAAsB;AAAA,IAC3D;AAAA,IACC,GAAG;AAAA,EAAA,GAEH,GACA,IAAc,EAAY,CAAO,IAAI,EAAQ,OAC7C,CACL;AAER;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createMentionPlugin.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/createMentionPlugin.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ELEMENT_MENTION,\n ELEMENT_MENTION_INPUT,\n createPluginFactory,\n mentionOnKeyDownHandler,\n withMention,\n} from '@udecode/plate';\nimport { TComboboxItemMention } from './types';\n\nexport const createMentionPlugin = createPluginFactory({\n key: ELEMENT_MENTION,\n isElement: true,\n isInline: true,\n isVoid: true,\n handlers: {\n onKeyDown: mentionOnKeyDownHandler(),\n },\n withOverrides: withMention,\n options: {\n trigger: '@',\n createMentionNode: (item: TComboboxItemMention) => ({\n value: item.text,\n key: item.key,\n category: item.category,\n }),\n },\n plugins: [\n {\n key: ELEMENT_MENTION_INPUT,\n isElement: true,\n isInline: true,\n },\n ],\n then: (editor, { key }) => ({\n options: {\n id: key,\n },\n }),\n});\n"],"names":[],"mappings":";AAWO,MAAM,IAAsB,EAAoB;AAAA,EACnD,KAAK;AAAA,EACL,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,IACN,WAAW,EAAwB;AAAA,EACvC;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,IACL,SAAS;AAAA,IACT,mBAAmB,CAAC,MAAgC;AAAA,MAChD,OAAO,EAAK;AAAA,MACZ,KAAK,EAAK;AAAA,MACV,UAAU,EAAK;AAAA,IAAA;AAAA,EAEvB;AAAA,EACA,SAAS;AAAA,IACL;AAAA,MACI,KAAK;AAAA,MACL,WAAW;AAAA,MACX,UAAU;AAAA,IACd;AAAA,EACJ;AAAA,EACA,MAAM,CAAC,GAAQ,EAAE,aAAW;AAAA,IACxB,SAAS;AAAA,MACL,IAAI;AAAA,IACR;AAAA,EAAA;AAER,CAAC;"}
1
+ {"version":3,"file":"createMentionPlugin.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/createMentionPlugin.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ELEMENT_MENTION,\n ELEMENT_MENTION_INPUT,\n createPluginFactory,\n mentionOnKeyDownHandler,\n withMention,\n} from '@udecode/plate';\nimport { MentionComboboxItem } from './types';\n\nexport const createMentionPlugin = createPluginFactory({\n key: ELEMENT_MENTION,\n isElement: true,\n isInline: true,\n isVoid: true,\n handlers: {\n onKeyDown: mentionOnKeyDownHandler(),\n },\n withOverrides: withMention,\n options: {\n trigger: '@',\n createMentionNode: (item: MentionComboboxItem) => ({\n value: item.text,\n key: item.key,\n category: item.category,\n }),\n },\n plugins: [\n {\n key: ELEMENT_MENTION_INPUT,\n isElement: true,\n isInline: true,\n },\n ],\n then: (editor, { key }) => ({\n options: {\n id: key,\n },\n }),\n});\n"],"names":[],"mappings":";AAWO,MAAM,IAAsB,EAAoB;AAAA,EACnD,KAAK;AAAA,EACL,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,IACN,WAAW,EAAwB;AAAA,EACvC;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,IACL,SAAS;AAAA,IACT,mBAAmB,CAAC,MAA+B;AAAA,MAC/C,OAAO,EAAK;AAAA,MACZ,KAAK,EAAK;AAAA,MACV,UAAU,EAAK;AAAA,IAAA;AAAA,EAEvB;AAAA,EACA,SAAS;AAAA,IACL;AAAA,MACI,KAAK;AAAA,MACL,WAAW;AAAA,MACX,UAAU;AAAA,IACd;AAAA,EACJ;AAAA,EACA,MAAM,CAAC,GAAQ,EAAE,aAAW;AAAA,IACxB,SAAS;AAAA,MACL,IAAI;AAAA,IACR;AAAA,EAAA;AAER,CAAC;"}
@@ -6,3 +6,5 @@ export declare class MentionPlugin extends Plugin<MentionPluginProps> {
6
6
  inline(): () => JSX.Element;
7
7
  plugins(): import("@udecode/plate").PlatePlugin<import("@udecode/plate").AnyObject, import("@udecode/plate").Value, import("@udecode/plate").PlateEditor<import("@udecode/plate").Value>>[];
8
8
  }
9
+ export { MentionableCategory } from './types';
10
+ export type { MentionableItems } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/index.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { createComboboxPlugin } from '@udecode/plate';\nimport { MENTION_PLUGIN } from './id';\nimport { MentionMarkupElement } from './MentionMarkupElement';\nimport { Plugin } from '../Plugin';\nimport { MentionInline } from './MentionInline';\nimport { createMentionPlugin } from './createMentionPlugin';\nimport { MentionPluginProps } from './types';\n\nexport class MentionPlugin extends Plugin<MentionPluginProps> {\n constructor(props: MentionPluginProps) {\n super(MENTION_PLUGIN, {\n markupElement: new MentionMarkupElement(),\n ...props,\n });\n }\n\n inline() {\n return MentionInline(this.props?.mentionableItems || []);\n }\n\n plugins() {\n return [createComboboxPlugin(), createMentionPlugin()];\n }\n}\n"],"names":[],"mappings":";;;;;;AAUO,MAAM,UAAsB,EAA2B;AAAA,EAC1D,YAAY,GAA2B;AACnC,UAAM,GAAgB;AAAA,MAClB,eAAe,IAAI,EAAqB;AAAA,MACxC,GAAG;AAAA,IAAA,CACN;AAAA,EACL;AAAA,EAEA,SAAS;;AACL,WAAO,EAAc,WAAK,UAAL,kBAAY,qBAAoB,CAAE,CAAA;AAAA,EAC3D;AAAA,EAEA,UAAU;AACN,WAAO,CAAC,EAAA,GAAwB,EAAA,CAAqB;AAAA,EACzD;AACJ;"}
1
+ {"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/index.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { createComboboxPlugin } from '@udecode/plate';\nimport { MENTION_PLUGIN } from './id';\nimport { MentionMarkupElement } from './MentionMarkupElement';\nimport { Plugin } from '../Plugin';\nimport { MentionInline } from './MentionInline';\nimport { createMentionPlugin } from './createMentionPlugin';\nimport { MentionPluginProps } from './types';\n\nexport class MentionPlugin extends Plugin<MentionPluginProps> {\n constructor(props: MentionPluginProps) {\n super(MENTION_PLUGIN, {\n markupElement: new MentionMarkupElement(),\n ...props,\n });\n }\n\n inline() {\n return MentionInline(this.props?.mentionableItems || []);\n }\n\n plugins() {\n return [createComboboxPlugin(), createMentionPlugin()];\n }\n}\n\nexport { MentionableCategory } from './types';\nexport type { MentionableItems } from './types';\n"],"names":[],"mappings":";;;;;;AAUO,MAAM,UAAsB,EAA2B;AAAA,EAC1D,YAAY,GAA2B;AACnC,UAAM,GAAgB;AAAA,MAClB,eAAe,IAAI,EAAqB;AAAA,MACxC,GAAG;AAAA,IAAA,CACN;AAAA,EACL;AAAA,EAEA,SAAS;;AACL,WAAO,EAAc,WAAK,UAAL,kBAAY,qBAAoB,CAAE,CAAA;AAAA,EAC3D;AAAA,EAEA,UAAU;AACN,WAAO,CAAC,EAAA,GAAwB,EAAA,CAAqB;AAAA,EACzD;AACJ;"}
@@ -1,19 +1,14 @@
1
1
  import { Data, TComboboxItemBase } from '@udecode/plate';
2
2
  import { PluginProps } from '../Plugin';
3
- interface MentionNodeData {
4
- value: string;
5
- }
6
- export declare type CreateMentionNode<TData extends Data> = (item: TComboboxItemMention<TData>) => MentionNodeData;
7
- export declare enum TCategory {
3
+ export declare enum MentionableCategory {
8
4
  GROUP = "group",
9
5
  ALL = "all",
10
6
  USER = "user"
11
7
  }
12
- export interface TComboboxItemMention<T extends Data = TCategory> extends TComboboxItemBase {
8
+ export interface MentionComboboxItem<T extends Data = MentionableCategory> extends TComboboxItemBase {
13
9
  category: T;
14
10
  }
15
- export declare type MentionableItems = TComboboxItemMention[];
11
+ export declare type MentionableItems = MentionComboboxItem[];
16
12
  export declare type MentionPluginProps = PluginProps & {
17
13
  mentionableItems: MentionableItems;
18
14
  };
19
- export {};
@@ -1,5 +1,5 @@
1
1
  var u = /* @__PURE__ */ ((r) => (r.GROUP = "group", r.ALL = "all", r.USER = "user", r))(u || {});
2
2
  export {
3
- u as TCategory
3
+ u as MentionableCategory
4
4
  };
5
5
  //# sourceMappingURL=types.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/types.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Data, TComboboxItemBase } from '@udecode/plate';\nimport { PluginProps } from '../Plugin';\n\ninterface MentionNodeData {\n value: string;\n}\n\nexport type CreateMentionNode<TData extends Data> = (item: TComboboxItemMention<TData>) => MentionNodeData;\n\nexport enum TCategory {\n GROUP = 'group',\n ALL = 'all',\n USER = 'user',\n}\n\nexport interface TComboboxItemMention<T extends Data = TCategory> extends TComboboxItemBase {\n category: T;\n}\n\nexport type MentionableItems = TComboboxItemMention[];\nexport type MentionPluginProps = PluginProps & {\n mentionableItems: MentionableItems;\n};\n"],"names":[],"mappings":"AAWY,IAAA,sBAAA,MACA,GAAA,QAAA,SACF,EAAA,MAAA,OACC,EAAA,OAAA,QAHC,IAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"types.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/types.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Data, TComboboxItemBase } from '@udecode/plate';\nimport { PluginProps } from '../Plugin';\n\nexport enum MentionableCategory {\n GROUP = 'group',\n ALL = 'all',\n USER = 'user',\n}\n\nexport interface MentionComboboxItem<T extends Data = MentionableCategory> extends TComboboxItemBase {\n category: T;\n}\n\nexport type MentionableItems = MentionComboboxItem[];\nexport type MentionPluginProps = PluginProps & {\n mentionableItems: MentionableItems;\n};\n"],"names":[],"mappings":"AAKY,IAAA,sBAAA,MACA,GAAA,QAAA,SACF,EAAA,MAAA,OACC,EAAA,OAAA,QAHC,IAAA,KAAA,CAAA,CAAA;"}
@@ -9,9 +9,9 @@ import { PaddingSizes as w } from "./types.es.js";
9
9
  import { defaultActions as x } from "./utils/actions.es.js";
10
10
  import "slate";
11
11
  import { ON_SAVE_DELAY_IN_MS as G } from "./utils/constants.es.js";
12
- import { defaultDesignTokens as d } from "./utils/defaultDesignTokens.es.js";
12
+ import { defaultDesignTokens as s } from "./utils/defaultDesignTokens.es.js";
13
13
  import { parseRawValue as M } from "./utils/parseRawValue.es.js";
14
- import { TextStyles as u } from "./Plugins/TextStylePlugin/TextStyles/textStyles.es.js";
14
+ import { TextStyles as d } from "./Plugins/TextStylePlugin/TextStyles/textStyles.es.js";
15
15
  import "./Plugins/TextStylePlugin/TextStyles/Custom1Plugin/createCustom1Plugin.es.js";
16
16
  import "./Plugins/TextStylePlugin/TextStyles/Custom2Plugin/createCustom2Plugin.es.js";
17
17
  import "./Plugins/TextStylePlugin/TextStyles/Custom3Plugin/createCustom3Plugin.es.js";
@@ -22,68 +22,68 @@ import "./Plugins/TextStylePlugin/TextStyles/Heading4Plugin/createHeading4Plugin
22
22
  import "./Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
23
23
  import "./EditorPositioningWrapper/index.es.js";
24
24
  import { getEditorConfig as z } from "./utils/editorConfig.es.js";
25
- import "./Plugins/index.es.js";
26
- import { forceTabOutOfActiveElement as H } from "./helpers/forceTabOutOfActiveElement.es.js";
27
- import { GeneratePlugins as J } from "./Plugins/GeneratePlugins.es.js";
28
- import { Position as Y } from "./EditorPositioningWrapper/types.es.js";
29
- const j = {
25
+ import { defaultPlugins as H } from "./Plugins/index.es.js";
26
+ import { forceTabOutOfActiveElement as J } from "./helpers/forceTabOutOfActiveElement.es.js";
27
+ import { GeneratePlugins as Y } from "./Plugins/GeneratePlugins.es.js";
28
+ import { Position as j } from "./EditorPositioningWrapper/types.es.js";
29
+ const F = {
30
30
  position: "relative",
31
31
  height: "0"
32
32
  }, At = ({
33
- id: E,
34
- value: g,
35
- placeholder: A = "",
36
- readonly: O = !1,
37
- clear: P = !1,
38
- designTokens: o = d,
39
- actions: a = x,
40
- onTextChange: f,
33
+ id: u,
34
+ value: E,
35
+ placeholder: g = "",
36
+ readonly: P = !1,
37
+ clear: A = !1,
38
+ designTokens: e = s,
39
+ actions: f = x,
40
+ onTextChange: a,
41
41
  onBlur: c,
42
- padding: b = w.None,
43
- position: N = Y.FLOATING,
44
- plugins: p
42
+ padding: O = w.None,
43
+ position: b = j.FLOATING,
44
+ plugins: N = H
45
45
  }) => {
46
- const e = v(E), { localValue: l } = V(e, P), S = {
47
- placeholder: A,
46
+ const o = v(u), { localValue: l } = V(o, A), S = {
47
+ placeholder: g,
48
48
  renderPlaceholder: ({ children: t, attributes: m }) => {
49
49
  const R = {
50
50
  ...m,
51
51
  style: {
52
52
  ...m.style,
53
- ...j
53
+ ...F
54
54
  }
55
55
  };
56
56
  return /* @__PURE__ */ n.createElement("span", {
57
57
  ...R
58
58
  }, t);
59
59
  },
60
- readOnly: O,
60
+ readOnly: P,
61
61
  onBlur: () => c && c(JSON.stringify(l.current)),
62
- className: b,
62
+ className: O,
63
63
  onKeyDown: (t) => {
64
- t.code === "Tab" && H();
64
+ t.code === "Tab" && J();
65
65
  }
66
66
  };
67
67
  L(() => {
68
- for (const t of Object.values(u).filter((m) => m !== u.ELEMENT_PARAGRAPH))
69
- o[t] || (o[t] = d[t]);
70
- }, [o]);
71
- const s = C((t) => {
72
- f && f(JSON.stringify(t));
68
+ for (const t of Object.values(d).filter((m) => m !== d.ELEMENT_PARAGRAPH))
69
+ e[t] || (e[t] = s[t]);
70
+ }, [e]);
71
+ const p = C((t) => {
72
+ a && a(JSON.stringify(t));
73
73
  }, G), h = T((t) => {
74
- s(t), l.current = t;
75
- }, [s, l]), r = J(e, p), i = !!r && a.length === 0 && !!p, y = i ? r.create() : z();
74
+ p(t), l.current = t;
75
+ }, [p, l]), r = Y(o, N), i = !!r && f.length === 0, y = i ? r.create() : z();
76
76
  return /* @__PURE__ */ n.createElement(I, {
77
- value: { designTokens: o, position: N }
77
+ value: { designTokens: e, position: b }
78
78
  }, /* @__PURE__ */ n.createElement(_, {
79
- id: e,
80
- initialValue: M(g),
79
+ id: o,
80
+ initialValue: M(o, E),
81
81
  onChange: h,
82
82
  editableProps: S,
83
83
  plugins: y
84
84
  }, i && r.toolbar(), i && r.inline(), !i && /* @__PURE__ */ n.createElement(D, {
85
- editorId: e,
86
- actions: a
85
+ editorId: o,
86
+ actions: f
87
87
  })));
88
88
  };
89
89
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditor.es.js","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { FC, useCallback, useEffect } from 'react';\nimport { Plate, TNode } from '@udecode/plate';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { debounce } from '@utilities/debounce';\nimport { EditableProps, RenderPlaceholderProps } from 'slate-react/dist/components/editable';\nimport { Toolbar } from './components/Toolbar/Toolbar';\nimport { RichTextEditorProvider } from './context/RichTextEditorContext';\nimport { useEditorState } from './hooks';\nimport { DesignTokens, PaddingSizes } from './types';\nimport { EditorActions, defaultActions } from './utils/actions';\nimport { ON_SAVE_DELAY_IN_MS } from './utils';\nimport { defaultDesignTokens } from './utils/defaultDesignTokens';\nimport { parseRawValue } from './utils/parseRawValue';\nimport { TextStyles } from './Plugins/TextStylePlugin/TextStyles';\nimport { Position } from './EditorPositioningWrapper';\nimport { getEditorConfig } from './utils/editorConfig';\nimport { GeneratePlugins, PluginComposer } from './Plugins';\nimport { forceTabOutOfActiveElement } from './helpers';\n\nconst PLACEHOLDER_STYLES: RenderPlaceholderProps['attributes']['style'] = {\n position: 'relative',\n height: '0',\n};\n\nexport type RichTextEditorProps = {\n id?: string;\n placeholder?: string;\n value?: string;\n onTextChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n readonly?: boolean;\n clear?: boolean;\n designTokens?: DesignTokens;\n actions?: EditorActions[][];\n padding?: PaddingSizes;\n position?: Position;\n plugins?: PluginComposer;\n};\n\nexport const RichTextEditor: FC<RichTextEditorProps> = ({\n id,\n value: initialValue,\n placeholder = '',\n readonly = false,\n clear = false,\n designTokens = defaultDesignTokens,\n actions = defaultActions,\n onTextChange,\n onBlur,\n padding = PaddingSizes.None,\n position = Position.FLOATING,\n plugins,\n}) => {\n const editorId = useMemoizedId(id);\n const { localValue } = useEditorState(editorId, clear);\n\n const editableProps: EditableProps = {\n placeholder,\n renderPlaceholder: ({ children, attributes }) => {\n const mergedAttributes = {\n ...attributes,\n style: {\n ...attributes.style,\n ...PLACEHOLDER_STYLES,\n },\n };\n return <span {...mergedAttributes}>{children}</span>;\n },\n readOnly: readonly,\n onBlur: () => onBlur && onBlur(JSON.stringify(localValue.current)),\n className: padding,\n onKeyDown: (event) => {\n if (event.code === 'Tab') {\n // Forcing a blur event because of accessibility\n forceTabOutOfActiveElement();\n }\n },\n };\n\n useEffect(() => {\n for (const element of Object.values(TextStyles).filter(\n (textStyle) => textStyle !== TextStyles.ELEMENT_PARAGRAPH,\n )) {\n if (!designTokens[element]) {\n designTokens[element] = defaultDesignTokens[element];\n }\n }\n }, [designTokens]);\n\n const debouncedOnChange = debounce((value: TNode[]) => {\n onTextChange && onTextChange(JSON.stringify(value));\n }, ON_SAVE_DELAY_IN_MS);\n\n const onChange = useCallback(\n (value) => {\n debouncedOnChange(value);\n localValue.current = value;\n },\n [debouncedOnChange, localValue],\n );\n\n const config = GeneratePlugins(editorId, plugins);\n const isNew = !!config && actions.length === 0 && !!plugins;\n const editorConfig = isNew ? config.create() : getEditorConfig();\n\n return (\n <RichTextEditorProvider value={{ designTokens, position }}>\n <Plate\n id={editorId}\n initialValue={parseRawValue(initialValue)}\n onChange={onChange}\n editableProps={editableProps}\n plugins={editorConfig}\n >\n {isNew && config.toolbar()}\n {isNew && config.inline()}\n {!isNew && <Toolbar editorId={editorId} actions={actions} />}\n </Plate>\n </RichTextEditorProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,IAAoE;AAAA,EACtE,UAAU;AAAA,EACV,QAAQ;AACZ,GAiBa,KAA0C,CAAC;AAAA,EACpD;AAAA,EACA,OAAO;AAAA,EACP,iBAAc;AAAA,EACd,cAAW;AAAA,EACX,WAAQ;AAAA,EACR,kBAAe;AAAA,EACf,aAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,aAAU,EAAa;AAAA,EACvB,cAAW,EAAS;AAAA,EACpB;AAAA,MACE;AACI,QAAA,IAAW,EAAc,CAAE,GAC3B,EAAE,kBAAe,EAAe,GAAU,CAAK,GAE/C,IAA+B;AAAA,IACjC;AAAA,IACA,mBAAmB,CAAC,EAAE,aAAU,oBAAiB;AAC7C,YAAM,IAAmB;AAAA,QACrB,GAAG;AAAA,QACH,OAAO;AAAA,UACH,GAAG,EAAW;AAAA,UACd,GAAG;AAAA,QACP;AAAA,MAAA;AAEJ,aAAQ,kBAAA,cAAA,QAAA;AAAA,QAAM,GAAG;AAAA,MAAA,GAAmB,CAAS;AAAA,IACjD;AAAA,IACA,UAAU;AAAA,IACV,QAAQ,MAAM,KAAU,EAAO,KAAK,UAAU,EAAW,OAAO,CAAC;AAAA,IACjE,WAAW;AAAA,IACX,WAAW,CAAC,MAAU;AACd,MAAA,EAAM,SAAS,SAEY;IAEnC;AAAA,EAAA;AAGJ,IAAU,MAAM;AACD,eAAA,KAAW,OAAO,OAAO,CAAU,EAAE,OAC5C,CAAC,MAAc,MAAc,EAAW,iBAC5C;AACQ,MAAC,EAAa,MACd,GAAa,KAAW,EAAoB;AAAA,EAEpD,GACD,CAAC,CAAY,CAAC;AAEX,QAAA,IAAoB,EAAS,CAAC,MAAmB;AACnD,SAAgB,EAAa,KAAK,UAAU,CAAK,CAAC;AAAA,KACnD,CAAmB,GAEhB,IAAW,EACb,CAAC,MAAU;AACP,MAAkB,CAAK,GACvB,EAAW,UAAU;AAAA,EAAA,GAEzB,CAAC,GAAmB,CAAU,CAClC,GAEM,IAAS,EAAgB,GAAU,CAAO,GAC1C,IAAQ,CAAC,CAAC,KAAU,EAAQ,WAAW,KAAK,CAAC,CAAC,GAC9C,IAAe,IAAQ,EAAO,WAAW,EAAgB;AAE/D,SACK,kBAAA,cAAA,GAAA;AAAA,IAAuB,OAAO,EAAE,iBAAc,YAAS;AAAA,EAAA,GACnD,kBAAA,cAAA,GAAA;AAAA,IACG,IAAI;AAAA,IACJ,cAAc,EAAc,CAAY;AAAA,IACxC;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EAER,GAAA,KAAS,EAAO,QAAA,GAChB,KAAS,EAAO,OAAO,GACvB,CAAC,KAAU,kBAAA,cAAA,GAAA;AAAA,IAAQ;AAAA,IAAoB;AAAA,EAAkB,CAAA,CAC9D,CACJ;AAER;"}
1
+ {"version":3,"file":"RichTextEditor.es.js","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { FC, useCallback, useEffect } from 'react';\nimport { Plate, TNode } from '@udecode/plate';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { debounce } from '@utilities/debounce';\nimport { EditableProps, RenderPlaceholderProps } from 'slate-react/dist/components/editable';\nimport { Toolbar } from './components/Toolbar/Toolbar';\nimport { RichTextEditorProvider } from './context/RichTextEditorContext';\nimport { useEditorState } from './hooks';\nimport { DesignTokens, PaddingSizes } from './types';\nimport { EditorActions, defaultActions } from './utils/actions';\nimport { ON_SAVE_DELAY_IN_MS } from './utils';\nimport { defaultDesignTokens } from './utils/defaultDesignTokens';\nimport { parseRawValue } from './utils/parseRawValue';\nimport { TextStyles } from './Plugins/TextStylePlugin/TextStyles';\nimport { Position } from './EditorPositioningWrapper';\nimport { getEditorConfig } from './utils/editorConfig';\nimport { GeneratePlugins, PluginComposer, defaultPlugins } from './Plugins';\nimport { forceTabOutOfActiveElement } from './helpers';\n\nconst PLACEHOLDER_STYLES: RenderPlaceholderProps['attributes']['style'] = {\n position: 'relative',\n height: '0',\n};\n\nexport type RichTextEditorProps = {\n id?: string;\n placeholder?: string;\n value?: string;\n onTextChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n readonly?: boolean;\n clear?: boolean;\n designTokens?: DesignTokens;\n actions?: EditorActions[][];\n padding?: PaddingSizes;\n position?: Position;\n plugins?: PluginComposer;\n};\n\nexport const RichTextEditor: FC<RichTextEditorProps> = ({\n id,\n value: initialValue,\n placeholder = '',\n readonly = false,\n clear = false,\n designTokens = defaultDesignTokens,\n actions = defaultActions,\n onTextChange,\n onBlur,\n padding = PaddingSizes.None,\n position = Position.FLOATING,\n plugins = defaultPlugins,\n}) => {\n const editorId = useMemoizedId(id);\n const { localValue } = useEditorState(editorId, clear);\n\n const editableProps: EditableProps = {\n placeholder,\n renderPlaceholder: ({ children, attributes }) => {\n const mergedAttributes = {\n ...attributes,\n style: {\n ...attributes.style,\n ...PLACEHOLDER_STYLES,\n },\n };\n return <span {...mergedAttributes}>{children}</span>;\n },\n readOnly: readonly,\n onBlur: () => onBlur && onBlur(JSON.stringify(localValue.current)),\n className: padding,\n onKeyDown: (event) => {\n if (event.code === 'Tab') {\n // Forcing a blur event because of accessibility\n forceTabOutOfActiveElement();\n }\n },\n };\n\n useEffect(() => {\n for (const element of Object.values(TextStyles).filter(\n (textStyle) => textStyle !== TextStyles.ELEMENT_PARAGRAPH,\n )) {\n if (!designTokens[element]) {\n designTokens[element] = defaultDesignTokens[element];\n }\n }\n }, [designTokens]);\n\n const debouncedOnChange = debounce((value: TNode[]) => {\n onTextChange && onTextChange(JSON.stringify(value));\n }, ON_SAVE_DELAY_IN_MS);\n\n const onChange = useCallback(\n (value) => {\n debouncedOnChange(value);\n localValue.current = value;\n },\n [debouncedOnChange, localValue],\n );\n\n const config = GeneratePlugins(editorId, plugins);\n const isNew = !!config && actions.length === 0;\n const editorConfig = isNew ? config.create() : getEditorConfig();\n\n return (\n <RichTextEditorProvider value={{ designTokens, position }}>\n <Plate\n id={editorId}\n initialValue={parseRawValue(editorId, initialValue)}\n onChange={onChange}\n editableProps={editableProps}\n plugins={editorConfig}\n >\n {isNew && config.toolbar()}\n {isNew && config.inline()}\n {!isNew && <Toolbar editorId={editorId} actions={actions} />}\n </Plate>\n </RichTextEditorProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,IAAoE;AAAA,EACtE,UAAU;AAAA,EACV,QAAQ;AACZ,GAiBa,KAA0C,CAAC;AAAA,EACpD;AAAA,EACA,OAAO;AAAA,EACP,iBAAc;AAAA,EACd,cAAW;AAAA,EACX,WAAQ;AAAA,EACR,kBAAe;AAAA,EACf,aAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,aAAU,EAAa;AAAA,EACvB,cAAW,EAAS;AAAA,EACpB,aAAU;AAAA,MACR;AACI,QAAA,IAAW,EAAc,CAAE,GAC3B,EAAE,kBAAe,EAAe,GAAU,CAAK,GAE/C,IAA+B;AAAA,IACjC;AAAA,IACA,mBAAmB,CAAC,EAAE,aAAU,oBAAiB;AAC7C,YAAM,IAAmB;AAAA,QACrB,GAAG;AAAA,QACH,OAAO;AAAA,UACH,GAAG,EAAW;AAAA,UACd,GAAG;AAAA,QACP;AAAA,MAAA;AAEJ,aAAQ,kBAAA,cAAA,QAAA;AAAA,QAAM,GAAG;AAAA,MAAA,GAAmB,CAAS;AAAA,IACjD;AAAA,IACA,UAAU;AAAA,IACV,QAAQ,MAAM,KAAU,EAAO,KAAK,UAAU,EAAW,OAAO,CAAC;AAAA,IACjE,WAAW;AAAA,IACX,WAAW,CAAC,MAAU;AACd,MAAA,EAAM,SAAS,SAEY;IAEnC;AAAA,EAAA;AAGJ,IAAU,MAAM;AACD,eAAA,KAAW,OAAO,OAAO,CAAU,EAAE,OAC5C,CAAC,MAAc,MAAc,EAAW,iBAC5C;AACQ,MAAC,EAAa,MACd,GAAa,KAAW,EAAoB;AAAA,EAEpD,GACD,CAAC,CAAY,CAAC;AAEX,QAAA,IAAoB,EAAS,CAAC,MAAmB;AACnD,SAAgB,EAAa,KAAK,UAAU,CAAK,CAAC;AAAA,KACnD,CAAmB,GAEhB,IAAW,EACb,CAAC,MAAU;AACP,MAAkB,CAAK,GACvB,EAAW,UAAU;AAAA,EAAA,GAEzB,CAAC,GAAmB,CAAU,CAClC,GAEM,IAAS,EAAgB,GAAU,CAAO,GAC1C,IAAQ,CAAC,CAAC,KAAU,EAAQ,WAAW,GACvC,IAAe,IAAQ,EAAO,WAAW,EAAgB;AAE/D,SACK,kBAAA,cAAA,GAAA;AAAA,IAAuB,OAAO,EAAE,iBAAc,YAAS;AAAA,EAAA,GACnD,kBAAA,cAAA,GAAA;AAAA,IACG,IAAI;AAAA,IACJ,cAAc,EAAc,GAAU,CAAY;AAAA,IAClD;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EAER,GAAA,KAAS,EAAO,QAAA,GAChB,KAAS,EAAO,OAAO,GACvB,CAAC,KAAU,kBAAA,cAAA,GAAA;AAAA,IAAQ;AAAA,IAAoB;AAAA,EAAkB,CAAA,CAC9D,CACJ;AAER;"}
@@ -5,7 +5,7 @@ declare type RichTextEditorContextProps = {
5
5
  designTokens: DesignTokens;
6
6
  position: Position;
7
7
  };
8
- export declare const useRichTextEditorContext: () => RichTextEditorContextProps;
8
+ export declare const useRichTextEditorContext: () => RichTextEditorContextProps | null;
9
9
  declare type RichTextEditorProviderProps = {
10
10
  children: React.ReactNode;
11
11
  value: {
@@ -1,22 +1,23 @@
1
- import e, { createContext as m, useContext as d } from "react";
2
- import { defaultDesignTokens as o } from "../utils/defaultDesignTokens.es.js";
1
+ import r, { createContext as c, useContext as d } from "react";
2
+ import { defaultDesignTokens as m } from "../utils/defaultDesignTokens.es.js";
3
3
  import "../EditorPositioningWrapper/index.es.js";
4
4
  import { EditorResizeContextProvider as x } from "./EditorResizeContext.es.js";
5
- import { Position as p } from "../EditorPositioningWrapper/types.es.js";
6
- const r = m({
7
- designTokens: o,
8
- position: p.FLOATING
9
- }), f = () => d(r), C = ({ children: i, value: n }) => {
10
- const { designTokens: t, position: s } = n, c = {
11
- designTokens: t != null ? t : o,
12
- position: s
5
+ import { Position as u } from "../EditorPositioningWrapper/types.es.js";
6
+ const o = c(null), T = () => {
7
+ if (!o)
8
+ throw new Error("useRichTextEditorContext must be used within a RichTextEditorProvider");
9
+ return d(o);
10
+ }, f = ({ children: i, value: n }) => {
11
+ const { designTokens: t, position: e } = n, s = {
12
+ designTokens: t != null ? t : m,
13
+ position: e != null ? e : u.FLOATING
13
14
  };
14
- return /* @__PURE__ */ e.createElement(r.Provider, {
15
- value: c
16
- }, /* @__PURE__ */ e.createElement(x, null, i));
15
+ return /* @__PURE__ */ r.createElement(o.Provider, {
16
+ value: s
17
+ }, /* @__PURE__ */ r.createElement(x, null, i));
17
18
  };
18
19
  export {
19
- C as RichTextEditorProvider,
20
- f as useRichTextEditorContext
20
+ f as RichTextEditorProvider,
21
+ T as useRichTextEditorContext
21
22
  };
22
23
  //# sourceMappingURL=RichTextEditorContext.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditorContext.es.js","sources":["../../../../src/components/RichTextEditor/context/RichTextEditorContext.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { createContext, useContext } from 'react';\nimport { DesignTokens } from '../types';\nimport { defaultDesignTokens } from '../utils/defaultDesignTokens';\nimport { Position } from '../EditorPositioningWrapper';\nimport { EditorResizeContextProvider } from './EditorResizeContext';\n\ntype RichTextEditorContextProps = {\n designTokens: DesignTokens;\n position: Position;\n};\n\nconst RichTextEditorContext = createContext<RichTextEditorContextProps>({\n designTokens: defaultDesignTokens,\n position: Position.FLOATING,\n});\nexport const useRichTextEditorContext = () => useContext(RichTextEditorContext);\n\ntype RichTextEditorProviderProps = {\n children: React.ReactNode;\n value: {\n designTokens: DesignTokens;\n position: Position;\n };\n};\n\nexport const RichTextEditorProvider = ({ children, value }: RichTextEditorProviderProps) => {\n const { designTokens, position } = value;\n\n const state = {\n designTokens: designTokens ?? defaultDesignTokens,\n position,\n };\n\n return (\n <RichTextEditorContext.Provider value={state}>\n <EditorResizeContextProvider>{children}</EditorResizeContextProvider>\n </RichTextEditorContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;AAcA,MAAM,IAAwB,EAA0C;AAAA,EACpE,cAAc;AAAA,EACd,UAAU,EAAS;AACvB,CAAC,GACY,IAA2B,MAAM,EAAW,CAAqB,GAUjE,IAAyB,CAAC,EAAE,aAAU,eAAyC;AAClF,QAAA,EAAE,iBAAc,gBAAa,GAE7B,IAAQ;AAAA,IACV,cAAc,gBAAgB;AAAA,IAC9B;AAAA,EAAA;AAIA,SAAA,kBAAA,cAAC,EAAsB,UAAtB;AAAA,IAA+B,OAAO;AAAA,EAAA,GACnC,kBAAA,cAAC,GAA6B,MAAA,CAAS,CAC3C;AAER;"}
1
+ {"version":3,"file":"RichTextEditorContext.es.js","sources":["../../../../src/components/RichTextEditor/context/RichTextEditorContext.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { createContext, useContext } from 'react';\nimport { DesignTokens } from '../types';\nimport { defaultDesignTokens } from '../utils/defaultDesignTokens';\nimport { Position } from '../EditorPositioningWrapper';\nimport { EditorResizeContextProvider } from './EditorResizeContext';\n\ntype RichTextEditorContextProps = {\n designTokens: DesignTokens;\n position: Position;\n};\n\nconst RichTextEditorContext = createContext<RichTextEditorContextProps | null>(null);\nexport const useRichTextEditorContext = () => {\n if (!RichTextEditorContext) {\n throw new Error('useRichTextEditorContext must be used within a RichTextEditorProvider');\n }\n return useContext(RichTextEditorContext);\n};\n\ntype RichTextEditorProviderProps = {\n children: React.ReactNode;\n value: {\n designTokens: DesignTokens;\n position: Position;\n };\n};\n\nexport const RichTextEditorProvider = ({ children, value }: RichTextEditorProviderProps) => {\n const { designTokens, position } = value;\n\n const state = {\n designTokens: designTokens ?? defaultDesignTokens,\n position: position ?? Position.FLOATING,\n };\n\n return (\n <RichTextEditorContext.Provider value={state}>\n <EditorResizeContextProvider>{children}</EditorResizeContextProvider>\n </RichTextEditorContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;AAcA,MAAM,IAAwB,EAAiD,IAAI,GACtE,IAA2B,MAAM;AAC1C,MAAI,CAAC;AACK,UAAA,IAAI,MAAM,uEAAuE;AAE3F,SAAO,EAAW,CAAqB;AAC3C,GAUa,IAAyB,CAAC,EAAE,aAAU,eAAyC;AAClF,QAAA,EAAE,iBAAc,gBAAa,GAE7B,IAAQ;AAAA,IACV,cAAc,gBAAgB;AAAA,IAC9B,UAAU,gBAAY,EAAS;AAAA,EAAA;AAI/B,SAAA,kBAAA,cAAC,EAAsB,UAAtB;AAAA,IAA+B,OAAO;AAAA,EAAA,GACnC,kBAAA,cAAC,GAA6B,MAAA,CAAS,CAC3C;AAER;"}
@@ -1,3 +1,3 @@
1
1
  import { Value } from '@udecode/plate';
2
2
  export declare const EMPTY_RICH_TEXT_VALUE: Value;
3
- export declare const parseRawValue: (raw?: string | undefined) => Value;
3
+ export declare const parseRawValue: (editorId: string, raw?: string | undefined) => Value;
@@ -1,22 +1,22 @@
1
- import { ELEMENT_PARAGRAPH as m, createPlateEditor as i, parseHtmlDocument as l, deserializeHtml as p } from "@udecode/plate";
2
- import { getEditorConfig as a } from "./editorConfig.es.js";
3
- const d = (t) => /^<\w+>.*<\/\w+>$/.test(t) ? t : `<p>${t}</p>`, u = [{ type: m, children: [{ text: "" }] }], h = (t) => {
4
- let e = u;
5
- if (!t)
6
- return e;
1
+ import { ELEMENT_PARAGRAPH as m, createPlateEditor as l, parseHtmlDocument as p, deserializeHtml as a } from "@udecode/plate";
2
+ import { getEditorConfig as d } from "./editorConfig.es.js";
3
+ const u = (t) => /^<\w+>.*<\/\w+>$/.test(t) ? t : `<p>${t}</p>`, E = [{ type: m, children: [{ text: "" }] }], H = (t, e) => {
4
+ let r = E;
5
+ if (!e)
6
+ return r;
7
7
  try {
8
- e = JSON.parse(t);
8
+ r = JSON.parse(e);
9
9
  } catch {
10
- const o = i({ plugins: a() }), n = t.trim().replace(/>\s+</g, "><"), c = d(n), s = l(c), r = p(o, {
11
- element: s.body,
10
+ const n = l({ id: t, plugins: d() }), c = e.trim().replace(/>\s+</g, "><"), s = u(c), i = p(s), o = a(n, {
11
+ element: i.body,
12
12
  stripWhitespace: !0
13
13
  });
14
- r && (e = r);
14
+ o && (r = o);
15
15
  }
16
- return e;
16
+ return r;
17
17
  };
18
18
  export {
19
- u as EMPTY_RICH_TEXT_VALUE,
20
- h as parseRawValue
19
+ E as EMPTY_RICH_TEXT_VALUE,
20
+ H as parseRawValue
21
21
  };
22
22
  //# sourceMappingURL=parseRawValue.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseRawValue.es.js","sources":["../../../../src/components/RichTextEditor/utils/parseRawValue.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { ELEMENT_PARAGRAPH, Value, createPlateEditor, deserializeHtml, parseHtmlDocument } from '@udecode/plate';\nimport { getEditorConfig } from './editorConfig';\n\nconst wrapTextInHtml = (text: string) => {\n const htmlDocRegex = /^<\\w+>.*<\\/\\w+>$/;\n\n return htmlDocRegex.test(text) ? text : `<p>${text}</p>`;\n};\n\nexport const EMPTY_RICH_TEXT_VALUE: Value = [{ type: ELEMENT_PARAGRAPH, children: [{ text: '' }] }];\n\nexport const parseRawValue = (raw?: string): Value => {\n let parsedValue = EMPTY_RICH_TEXT_VALUE;\n\n if (!raw) {\n return parsedValue;\n }\n\n try {\n parsedValue = JSON.parse(raw);\n } catch {\n const editor = createPlateEditor({ plugins: getEditorConfig() });\n const trimmed = raw.trim().replace(/>\\s+</g, '><');\n const htmlDocumentString = wrapTextInHtml(trimmed);\n const document = parseHtmlDocument(htmlDocumentString);\n const parsedHtml = deserializeHtml(editor, {\n element: document.body,\n stripWhitespace: true,\n }) as Value;\n if (parsedHtml) {\n parsedValue = parsedHtml;\n }\n }\n\n return parsedValue;\n};\n"],"names":[],"mappings":";;AAKA,MAAM,IAAiB,CAAC,MAGb,AAFc,mBAED,KAAK,CAAI,IAAI,IAAO,MAAM,SAGrC,IAA+B,CAAC,EAAE,MAAM,GAAmB,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA,GAAG,GAErF,IAAgB,CAAC,MAAwB;AAClD,MAAI,IAAc;AAElB,MAAI,CAAC;AACM,WAAA;AAGP,MAAA;AACc,QAAA,KAAK,MAAM,CAAG;AAAA,EAAA,QAC9B;AACE,UAAM,IAAS,EAAkB,EAAE,SAAS,EAAA,EAAmB,CAAA,GACzD,IAAU,EAAI,KAAA,EAAO,QAAQ,UAAU,IAAI,GAC3C,IAAqB,EAAe,CAAO,GAC3C,IAAW,EAAkB,CAAkB,GAC/C,IAAa,EAAgB,GAAQ;AAAA,MACvC,SAAS,EAAS;AAAA,MAClB,iBAAiB;AAAA,IAAA,CACpB;AACD,IAAI,KACc,KAAA;AAAA,EAEtB;AAEO,SAAA;AACX;"}
1
+ {"version":3,"file":"parseRawValue.es.js","sources":["../../../../src/components/RichTextEditor/utils/parseRawValue.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { ELEMENT_PARAGRAPH, Value, createPlateEditor, deserializeHtml, parseHtmlDocument } from '@udecode/plate';\nimport { getEditorConfig } from './editorConfig';\n\nconst wrapTextInHtml = (text: string) => {\n const htmlDocRegex = /^<\\w+>.*<\\/\\w+>$/;\n\n return htmlDocRegex.test(text) ? text : `<p>${text}</p>`;\n};\n\nexport const EMPTY_RICH_TEXT_VALUE: Value = [{ type: ELEMENT_PARAGRAPH, children: [{ text: '' }] }];\n\nexport const parseRawValue = (editorId: string, raw?: string): Value => {\n let parsedValue = EMPTY_RICH_TEXT_VALUE;\n\n if (!raw) {\n return parsedValue;\n }\n\n try {\n parsedValue = JSON.parse(raw);\n } catch {\n const editor = createPlateEditor({ id: editorId, plugins: getEditorConfig() });\n const trimmed = raw.trim().replace(/>\\s+</g, '><');\n const htmlDocumentString = wrapTextInHtml(trimmed);\n const document = parseHtmlDocument(htmlDocumentString);\n const parsedHtml = deserializeHtml(editor, {\n element: document.body,\n stripWhitespace: true,\n }) as Value;\n if (parsedHtml) {\n parsedValue = parsedHtml;\n }\n }\n\n return parsedValue;\n};\n"],"names":[],"mappings":";;AAKA,MAAM,IAAiB,CAAC,MAGb,AAFc,mBAED,KAAK,CAAI,IAAI,IAAO,MAAM,SAGrC,IAA+B,CAAC,EAAE,MAAM,GAAmB,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA,GAAG,GAErF,IAAgB,CAAC,GAAkB,MAAwB;AACpE,MAAI,IAAc;AAElB,MAAI,CAAC;AACM,WAAA;AAGP,MAAA;AACc,QAAA,KAAK,MAAM,CAAG;AAAA,EAAA,QAC9B;AACQ,UAAA,IAAS,EAAkB,EAAE,IAAI,GAAU,SAAS,KAAmB,GACvE,IAAU,EAAI,KAAA,EAAO,QAAQ,UAAU,IAAI,GAC3C,IAAqB,EAAe,CAAO,GAC3C,IAAW,EAAkB,CAAkB,GAC/C,IAAa,EAAgB,GAAQ;AAAA,MACvC,SAAS,EAAS;AAAA,MAClB,iBAAiB;AAAA,IAAA,CACpB;AACD,IAAI,KACc,KAAA;AAAA,EAEtB;AAEO,SAAA;AACX;"}