@frontify/fondue 12.0.0-beta.10 → 12.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/RichTextEditor/Plugins/CheckboxListPlugin/CheckboxListButton/CheckboxListToolbarButton.es.js +8 -9
- package/dist/components/RichTextEditor/Plugins/CheckboxListPlugin/CheckboxListButton/CheckboxListToolbarButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js +7 -5
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.d.ts +3 -3
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.es.js +1678 -23
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/index.d.ts +0 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/index.es.js +16 -10
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/index.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/MentionMarkupElement/MentionMarkupElementNode.es.js +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/MentionMarkupElement/MentionMarkupElementNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/createMentionPlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/index.d.ts +2 -0
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/index.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.d.ts +3 -8
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.es.js +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.es.js.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.es.js +33 -33
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/components/RichTextEditor/context/RichTextEditorContext.d.ts +1 -1
- package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js +16 -15
- package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js.map +1 -1
- package/dist/components/Tree/Node.es.js +1795 -127
- package/dist/components/Tree/Node.es.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +2 -1
- package/dist/components/Tree/Tree.es.js.map +1 -1
- package/dist/components/Tree/utils/mocks.es.js +5 -4
- package/dist/components/Tree/utils/mocks.es.js.map +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +3332 -3330
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.d.ts +0 -2
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js +0 -36
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js.map +0 -1
package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/FloatingLink.es.js.map
CHANGED
|
@@ -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
|
|
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 +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,
|
|
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
|
|
4
|
-
import { LinkButton as
|
|
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
|
|
6
|
+
import { Plugin as a } from "../Plugin.es.js";
|
|
7
7
|
import { isUrlOrPath as l } from "./utils/isUrlOrPath.es.js";
|
|
8
|
-
const
|
|
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
|
|
21
|
+
class d extends a {
|
|
16
22
|
constructor(r) {
|
|
17
23
|
super(n, {
|
|
18
|
-
button:
|
|
19
|
-
markupElement: new
|
|
24
|
+
button: o,
|
|
25
|
+
markupElement: new e(),
|
|
20
26
|
...r
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
29
|
plugins() {
|
|
24
|
-
return [
|
|
30
|
+
return [u()];
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
export {
|
|
28
34
|
d as LinkPlugin,
|
|
29
|
-
|
|
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,
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
|
8
|
+
export interface MentionComboboxItem<T extends Data = MentionableCategory> extends TComboboxItemBase {
|
|
13
9
|
category: T;
|
|
14
10
|
}
|
|
15
|
-
export declare type MentionableItems =
|
|
11
|
+
export declare type MentionableItems = MentionComboboxItem[];
|
|
16
12
|
export declare type MentionPluginProps = PluginProps & {
|
|
17
13
|
mentionableItems: MentionableItems;
|
|
18
14
|
};
|
|
19
|
-
export {};
|
|
@@ -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\
|
|
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
|
|
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
|
|
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
|
|
27
|
-
import { GeneratePlugins as
|
|
28
|
-
import { Position as
|
|
29
|
-
const
|
|
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:
|
|
34
|
-
value:
|
|
35
|
-
placeholder:
|
|
36
|
-
readonly:
|
|
37
|
-
clear:
|
|
38
|
-
designTokens: o =
|
|
39
|
-
actions:
|
|
40
|
-
onTextChange:
|
|
33
|
+
id: u,
|
|
34
|
+
value: E,
|
|
35
|
+
placeholder: g = "",
|
|
36
|
+
readonly: P = !1,
|
|
37
|
+
clear: A = !1,
|
|
38
|
+
designTokens: o = s,
|
|
39
|
+
actions: f = x,
|
|
40
|
+
onTextChange: a,
|
|
41
41
|
onBlur: c,
|
|
42
|
-
padding:
|
|
43
|
-
position:
|
|
44
|
-
plugins:
|
|
42
|
+
padding: O = w.None,
|
|
43
|
+
position: b = j.FLOATING,
|
|
44
|
+
plugins: N = H
|
|
45
45
|
}) => {
|
|
46
|
-
const e = v(
|
|
47
|
-
placeholder:
|
|
46
|
+
const e = v(u), { localValue: l } = V(e, 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
|
-
...
|
|
53
|
+
...F
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
return /* @__PURE__ */ n.createElement("span", {
|
|
57
57
|
...R
|
|
58
58
|
}, t);
|
|
59
59
|
},
|
|
60
|
-
readOnly:
|
|
60
|
+
readOnly: P,
|
|
61
61
|
onBlur: () => c && c(JSON.stringify(l.current)),
|
|
62
|
-
className:
|
|
62
|
+
className: O,
|
|
63
63
|
onKeyDown: (t) => {
|
|
64
|
-
t.code === "Tab" &&
|
|
64
|
+
t.code === "Tab" && J();
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
L(() => {
|
|
68
|
-
for (const t of Object.values(
|
|
69
|
-
o[t] || (o[t] =
|
|
68
|
+
for (const t of Object.values(d).filter((m) => m !== d.ELEMENT_PARAGRAPH))
|
|
69
|
+
o[t] || (o[t] = s[t]);
|
|
70
70
|
}, [o]);
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
const p = C((t) => {
|
|
72
|
+
a && a(JSON.stringify(t));
|
|
73
73
|
}, G), h = T((t) => {
|
|
74
|
-
|
|
75
|
-
}, [
|
|
74
|
+
p(t), l.current = t;
|
|
75
|
+
}, [p, l]), r = Y(e, N), i = !!r && f.length === 0, y = i ? r.create() : z();
|
|
76
76
|
return /* @__PURE__ */ n.createElement(I, {
|
|
77
|
-
value: { designTokens: o, position:
|
|
77
|
+
value: { designTokens: o, position: b }
|
|
78
78
|
}, /* @__PURE__ */ n.createElement(_, {
|
|
79
79
|
id: e,
|
|
80
|
-
initialValue: M(
|
|
80
|
+
initialValue: M(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
85
|
editorId: e,
|
|
86
|
-
actions:
|
|
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
|
|
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(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,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;"}
|
|
@@ -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
|
|
2
|
-
import { defaultDesignTokens as
|
|
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
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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__ */
|
|
15
|
-
value:
|
|
16
|
-
}, /* @__PURE__ */
|
|
15
|
+
return /* @__PURE__ */ r.createElement(o.Provider, {
|
|
16
|
+
value: s
|
|
17
|
+
}, /* @__PURE__ */ r.createElement(x, null, i));
|
|
17
18
|
};
|
|
18
19
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
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>(
|
|
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;"}
|