@frontify/fondue 12.0.0-beta.11 → 12.0.0-beta.13
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/AssetInput/AssetInput.d.ts +2 -0
- package/dist/components/AssetInput/AssetInput.es.js +33 -29
- package/dist/components/AssetInput/AssetInput.es.js.map +1 -1
- package/dist/components/AssetInput/SingleAsset/AssetSubline.d.ts +1 -1
- package/dist/components/AssetInput/SingleAsset/AssetSubline.es.js +25 -16
- package/dist/components/AssetInput/SingleAsset/AssetSubline.es.js.map +1 -1
- package/dist/components/AssetInput/SingleAsset/SelectedAsset.d.ts +2 -2
- package/dist/components/AssetInput/SingleAsset/SelectedAsset.es.js +46 -44
- package/dist/components/AssetInput/SingleAsset/SelectedAsset.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.d.ts +3 -3
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.es.js +17 -17
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.es.js.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +0 -1
- package/dist/components/RichTextEditor/RichTextEditor.es.js +56 -78
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/components/RichTextEditor/context/EditorResizeContext.es.js +13 -25
- package/dist/components/RichTextEditor/context/EditorResizeContext.es.js.map +1 -1
- package/dist/components/RichTextEditor/hooks/useEditorState.d.ts +4 -1
- package/dist/components/RichTextEditor/hooks/useEditorState.es.js +12 -11
- package/dist/components/RichTextEditor/hooks/useEditorState.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js +1 -1
- package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js.map +1 -1
- package/dist/components/RichTextEditor/utils/parseRawValue.d.ts +6 -1
- package/dist/components/RichTextEditor/utils/parseRawValue.es.js +8 -8
- package/dist/components/RichTextEditor/utils/parseRawValue.es.js.map +1 -1
- package/dist/components/ScrollWrapper/ScrollWrapper.es.js +1 -1
- package/dist/components/Table/TableCell.es.js +1 -1
- package/dist/components/Table/TableColumnHeader.es.js +1 -1
- package/dist/components/Tree/utils/mocks.es.js +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,92 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Plate as
|
|
3
|
-
import { useMemoizedId as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import "
|
|
11
|
-
import { ON_SAVE_DELAY_IN_MS as G } from "./utils/constants.es.js";
|
|
12
|
-
import { defaultDesignTokens as s } from "./utils/defaultDesignTokens.es.js";
|
|
13
|
-
import { parseRawValue as M } from "./utils/parseRawValue.es.js";
|
|
14
|
-
import { TextStyles as d } from "./Plugins/TextStylePlugin/TextStyles/textStyles.es.js";
|
|
15
|
-
import "./Plugins/TextStylePlugin/TextStyles/Custom1Plugin/createCustom1Plugin.es.js";
|
|
16
|
-
import "./Plugins/TextStylePlugin/TextStyles/Custom2Plugin/createCustom2Plugin.es.js";
|
|
17
|
-
import "./Plugins/TextStylePlugin/TextStyles/Custom3Plugin/createCustom3Plugin.es.js";
|
|
18
|
-
import "./Plugins/TextStylePlugin/TextStyles/Heading1Plugin/createHeading1Plugin.es.js";
|
|
19
|
-
import "./Plugins/TextStylePlugin/TextStyles/Heading2Plugin/createHeading2Plugin.es.js";
|
|
20
|
-
import "./Plugins/TextStylePlugin/TextStyles/Heading3Plugin/createHeading3Plugin.es.js";
|
|
21
|
-
import "./Plugins/TextStylePlugin/TextStyles/Heading4Plugin/createHeading4Plugin.es.js";
|
|
22
|
-
import "./Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
1
|
+
import r from "react";
|
|
2
|
+
import { Plate as v } from "@udecode/plate";
|
|
3
|
+
import { useMemoizedId as y } from "../../hooks/useMemoizedId.es.js";
|
|
4
|
+
import { Toolbar as A } from "./components/Toolbar/Toolbar.es.js";
|
|
5
|
+
import { RichTextEditorProvider as C } from "./context/RichTextEditorContext.es.js";
|
|
6
|
+
import { useEditorState as N } from "./hooks/useEditorState.es.js";
|
|
7
|
+
import { PaddingSizes as R } from "./types.es.js";
|
|
8
|
+
import { defaultActions as S } from "./utils/actions.es.js";
|
|
9
|
+
import { defaultDesignTokens as w } from "./utils/defaultDesignTokens.es.js";
|
|
10
|
+
import { parseRawValue as I } from "./utils/parseRawValue.es.js";
|
|
23
11
|
import "./EditorPositioningWrapper/index.es.js";
|
|
24
|
-
import { getEditorConfig as
|
|
25
|
-
import { defaultPlugins as
|
|
26
|
-
import { forceTabOutOfActiveElement as
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
const
|
|
12
|
+
import { getEditorConfig as L } from "./utils/editorConfig.es.js";
|
|
13
|
+
import { defaultPlugins as x } from "./Plugins/index.es.js";
|
|
14
|
+
import { forceTabOutOfActiveElement as D } from "./helpers/forceTabOutOfActiveElement.es.js";
|
|
15
|
+
import { Position as V } from "./EditorPositioningWrapper/types.es.js";
|
|
16
|
+
import { GeneratePlugins as z } from "./Plugins/GeneratePlugins.es.js";
|
|
17
|
+
const G = {
|
|
30
18
|
position: "relative",
|
|
31
19
|
height: "0"
|
|
32
|
-
},
|
|
33
|
-
id:
|
|
34
|
-
value:
|
|
35
|
-
placeholder:
|
|
36
|
-
readonly:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
plugins: N = H
|
|
20
|
+
}, $ = ({
|
|
21
|
+
id: l,
|
|
22
|
+
value: s,
|
|
23
|
+
placeholder: f = "",
|
|
24
|
+
readonly: c = !1,
|
|
25
|
+
designTokens: d = w,
|
|
26
|
+
actions: n = S,
|
|
27
|
+
onTextChange: p,
|
|
28
|
+
onBlur: m,
|
|
29
|
+
padding: u = R.None,
|
|
30
|
+
position: g = V.FLOATING,
|
|
31
|
+
plugins: E = x
|
|
45
32
|
}) => {
|
|
46
|
-
const
|
|
47
|
-
placeholder:
|
|
48
|
-
renderPlaceholder: ({ children:
|
|
49
|
-
const
|
|
50
|
-
...
|
|
33
|
+
const e = y(l), { localValue: P, onChange: T } = N(p), h = {
|
|
34
|
+
placeholder: f,
|
|
35
|
+
renderPlaceholder: ({ children: i, attributes: a }) => {
|
|
36
|
+
const b = {
|
|
37
|
+
...a,
|
|
51
38
|
style: {
|
|
52
|
-
...
|
|
53
|
-
...
|
|
39
|
+
...a.style,
|
|
40
|
+
...G
|
|
54
41
|
}
|
|
55
42
|
};
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
...
|
|
58
|
-
},
|
|
43
|
+
return /* @__PURE__ */ r.createElement("span", {
|
|
44
|
+
...b
|
|
45
|
+
}, i);
|
|
59
46
|
},
|
|
60
|
-
readOnly:
|
|
61
|
-
onBlur: () =>
|
|
62
|
-
className:
|
|
63
|
-
onKeyDown: (
|
|
64
|
-
|
|
47
|
+
readOnly: c,
|
|
48
|
+
onBlur: () => m && m(JSON.stringify(P.current)),
|
|
49
|
+
className: u,
|
|
50
|
+
onKeyDown: (i) => {
|
|
51
|
+
i.code === "Tab" && D();
|
|
65
52
|
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}, /* @__PURE__ */ n.createElement(_, {
|
|
79
|
-
id: o,
|
|
80
|
-
initialValue: M(o, E),
|
|
81
|
-
onChange: h,
|
|
82
|
-
editableProps: S,
|
|
83
|
-
plugins: y
|
|
84
|
-
}, i && r.toolbar(), i && r.inline(), !i && /* @__PURE__ */ n.createElement(D, {
|
|
85
|
-
editorId: o,
|
|
86
|
-
actions: f
|
|
53
|
+
}, o = z(e, E), t = !!o && n.length === 0, O = t ? o.Create() : L();
|
|
54
|
+
return /* @__PURE__ */ r.createElement(C, {
|
|
55
|
+
value: { designTokens: d, position: g }
|
|
56
|
+
}, /* @__PURE__ */ r.createElement(v, {
|
|
57
|
+
id: e,
|
|
58
|
+
initialValue: I({ editorId: e, raw: s }),
|
|
59
|
+
onChange: T,
|
|
60
|
+
editableProps: h,
|
|
61
|
+
plugins: O
|
|
62
|
+
}, t && o.Toolbar(), t && o.Inline(), !t && /* @__PURE__ */ r.createElement(A, {
|
|
63
|
+
editorId: e,
|
|
64
|
+
actions: n
|
|
87
65
|
})));
|
|
88
66
|
};
|
|
89
67
|
export {
|
|
90
|
-
|
|
68
|
+
$ as RichTextEditor
|
|
91
69
|
};
|
|
92
70
|
//# sourceMappingURL=RichTextEditor.es.js.map
|
|
@@ -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
|
|
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 } from 'react';\nimport { Plate } from '@udecode/plate';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\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 { defaultDesignTokens } from './utils/defaultDesignTokens';\nimport { parseRawValue } from './utils/parseRawValue';\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 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 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, onChange } = useEditorState(onTextChange);\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 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, raw: 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":";;;;;;;;;;;;;;;;AAkBA,MAAM,IAAoE;AAAA,EACtE,UAAU;AAAA,EACV,QAAQ;AACZ,GAgBa,IAA0C,CAAC;AAAA,EACpD;AAAA,EACA,OAAO;AAAA,EACP,iBAAc;AAAA,EACd,cAAW;AAAA,EACX,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,eAAY,gBAAa,EAAe,CAAY,GAEtD,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,GAGE,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,EAAE,aAAU,KAAK,GAAc;AAAA,IAC3D;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,33 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t, { createContext as n, useContext as d } from "react";
|
|
2
2
|
import "@udecode/plate";
|
|
3
|
-
import "
|
|
4
|
-
import "../
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
import "../Plugins/TextStylePlugin/TextStyles/textStyles.es.js";
|
|
8
|
-
import "../Plugins/TextStylePlugin/TextStyles/Custom1Plugin/createCustom1Plugin.es.js";
|
|
9
|
-
import "../Plugins/TextStylePlugin/TextStyles/Custom2Plugin/createCustom2Plugin.es.js";
|
|
10
|
-
import "../Plugins/TextStylePlugin/TextStyles/Custom3Plugin/createCustom3Plugin.es.js";
|
|
11
|
-
import "../Plugins/TextStylePlugin/TextStyles/Heading1Plugin/createHeading1Plugin.es.js";
|
|
12
|
-
import "../Plugins/TextStylePlugin/TextStyles/Heading2Plugin/createHeading2Plugin.es.js";
|
|
13
|
-
import "../Plugins/TextStylePlugin/TextStyles/Heading3Plugin/createHeading3Plugin.es.js";
|
|
14
|
-
import "../Plugins/TextStylePlugin/TextStyles/Heading4Plugin/createHeading4Plugin.es.js";
|
|
15
|
-
import "../Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
16
|
-
import { useEditorResize as n } from "../hooks/useEditorResize.es.js";
|
|
17
|
-
import { PlateWrapper as d } from "../EditorPositioningWrapper/PlateWrapper.es.js";
|
|
18
|
-
const r = m({
|
|
3
|
+
import "slate";
|
|
4
|
+
import { useEditorResize as s } from "../hooks/useEditorResize.es.js";
|
|
5
|
+
import { PlateWrapper as m } from "../EditorPositioningWrapper/PlateWrapper.es.js";
|
|
6
|
+
const r = n({
|
|
19
7
|
editorWidth: 0,
|
|
20
8
|
editorRef: null
|
|
21
|
-
}),
|
|
22
|
-
const { editorWidth: i, editorRef:
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
value: { editorWidth: i, editorRef:
|
|
25
|
-
}, /* @__PURE__ */
|
|
26
|
-
ref:
|
|
9
|
+
}), l = () => d(r), u = ({ children: o }) => {
|
|
10
|
+
const { editorWidth: i, editorRef: e } = s();
|
|
11
|
+
return /* @__PURE__ */ t.createElement(r.Provider, {
|
|
12
|
+
value: { editorWidth: i, editorRef: e }
|
|
13
|
+
}, /* @__PURE__ */ t.createElement(m, {
|
|
14
|
+
ref: e
|
|
27
15
|
}, o));
|
|
28
16
|
};
|
|
29
17
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
u as EditorResizeContextProvider,
|
|
19
|
+
l as useEditorResizeContext
|
|
32
20
|
};
|
|
33
21
|
//# sourceMappingURL=EditorResizeContext.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorResizeContext.es.js","sources":["../../../../src/components/RichTextEditor/context/EditorResizeContext.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { createContext, useContext } from 'react';\nimport { useEditorResize } from '../hooks';\nimport { PlateWrapper } from '../EditorPositioningWrapper/PlateWrapper';\n\ntype EditorResizeContextProps = {\n editorWidth: number | undefined;\n editorRef: ((node: HTMLDivElement) => ResizeObserver | undefined) | null;\n};\nconst EditorResizeContext = createContext<EditorResizeContextProps>({\n editorWidth: 0,\n editorRef: null,\n});\nexport const useEditorResizeContext = () => useContext(EditorResizeContext);\n\ntype EditorResizeContextProviderProps = {\n children: React.ReactNode;\n};\n\nexport const EditorResizeContextProvider = ({ children }: EditorResizeContextProviderProps) => {\n const { editorWidth, editorRef } = useEditorResize();\n\n return (\n <EditorResizeContext.Provider value={{ editorWidth, editorRef }}>\n <PlateWrapper ref={editorRef}>{children}</PlateWrapper>\n </EditorResizeContext.Provider>\n );\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorResizeContext.es.js","sources":["../../../../src/components/RichTextEditor/context/EditorResizeContext.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { createContext, useContext } from 'react';\nimport { useEditorResize } from '../hooks';\nimport { PlateWrapper } from '../EditorPositioningWrapper/PlateWrapper';\n\ntype EditorResizeContextProps = {\n editorWidth: number | undefined;\n editorRef: ((node: HTMLDivElement) => ResizeObserver | undefined) | null;\n};\nconst EditorResizeContext = createContext<EditorResizeContextProps>({\n editorWidth: 0,\n editorRef: null,\n});\nexport const useEditorResizeContext = () => useContext(EditorResizeContext);\n\ntype EditorResizeContextProviderProps = {\n children: React.ReactNode;\n};\n\nexport const EditorResizeContextProvider = ({ children }: EditorResizeContextProviderProps) => {\n const { editorWidth, editorRef } = useEditorResize();\n\n return (\n <EditorResizeContext.Provider value={{ editorWidth, editorRef }}>\n <PlateWrapper ref={editorRef}>{children}</PlateWrapper>\n </EditorResizeContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;AAUA,MAAM,IAAsB,EAAwC;AAAA,EAChE,aAAa;AAAA,EACb,WAAW;AACf,CAAC,GACY,IAAyB,MAAM,EAAW,CAAmB,GAM7D,IAA8B,CAAC,EAAE,kBAAiD;AACrF,QAAA,EAAE,gBAAa,iBAAc,EAAgB;AAG/C,SAAA,kBAAA,cAAC,EAAoB,UAApB;AAAA,IAA6B,OAAO,EAAE,gBAAa,aAAU;AAAA,EAAA,GACzD,kBAAA,cAAA,GAAA;AAAA,IAAa,KAAK;AAAA,EAAA,GAAY,CAAS,CAC5C;AAER;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TNode } from '@udecode/plate';
|
|
3
|
-
|
|
3
|
+
declare type useEditorStateProps = ((value: string) => void) | undefined;
|
|
4
|
+
export declare const useEditorState: (onTextChange: useEditorStateProps) => {
|
|
4
5
|
localValue: import("react").MutableRefObject<TNode[] | null>;
|
|
6
|
+
onChange: (value: any) => void;
|
|
5
7
|
};
|
|
8
|
+
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, [
|
|
1
|
+
import { useRef as c, useCallback as i } from "react";
|
|
2
|
+
import { debounce as m } from "../../../utilities/debounce.es.js";
|
|
3
|
+
import "@udecode/plate";
|
|
4
|
+
import "slate";
|
|
5
|
+
import { ON_SAVE_DELAY_IN_MS as s } from "../utils/constants.es.js";
|
|
6
|
+
const d = (t) => {
|
|
7
|
+
const r = c(null), e = m((o) => {
|
|
8
|
+
t && t(JSON.stringify(o));
|
|
9
|
+
}, s), n = i((o) => {
|
|
10
|
+
e(o), r.current = o;
|
|
11
|
+
}, [e, r]);
|
|
12
|
+
return { localValue: r, onChange: n };
|
|
12
13
|
};
|
|
13
14
|
export {
|
|
14
15
|
d as useEditorState
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditorState.es.js","sources":["../../../../src/components/RichTextEditor/hooks/useEditorState.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {
|
|
1
|
+
{"version":3,"file":"useEditorState.es.js","sources":["../../../../src/components/RichTextEditor/hooks/useEditorState.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useCallback, useRef } from 'react';\nimport { TNode } from '@udecode/plate';\nimport { debounce } from '@utilities/debounce';\nimport { ON_SAVE_DELAY_IN_MS } from '../utils';\n\ntype useEditorStateProps = ((value: string) => void) | undefined;\n\nexport const useEditorState = (onTextChange: useEditorStateProps) => {\n const localValue = useRef<TNode[] | null>(null);\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 return { localValue, onChange };\n};\n"],"names":[],"mappings":";;;;;AASa,MAAA,IAAiB,CAAC,MAAsC;AAC3D,QAAA,IAAa,EAAuB,IAAI,GAExC,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;AAEO,SAAA,EAAE,eAAY;AACzB;"}
|
|
@@ -3,7 +3,7 @@ import { parseRawValue as i } from "../utils/parseRawValue.es.js";
|
|
|
3
3
|
import { serializeNodeToHtmlRecursive as n } from "./utils/serializeNodeToHtmlRecursive.es.js";
|
|
4
4
|
import { setDefaultDesignTokensIfNull as m } from "./utils/setDefaultDesignTokensIfNull.es.js";
|
|
5
5
|
const T = (e, o = s) => {
|
|
6
|
-
const r = i(e);
|
|
6
|
+
const r = i({ raw: e });
|
|
7
7
|
return l(r, o);
|
|
8
8
|
}, l = (e, o = s) => {
|
|
9
9
|
const r = m(s, o);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeToHtml.es.js","sources":["../../../../src/components/RichTextEditor/serializer/serializeToHtml.ts"],"sourcesContent":["import { TDescendant } from '@udecode/plate';\nimport { DesignTokens } from '../types';\nimport { defaultDesignTokens } from '../utils/defaultDesignTokens';\nimport { parseRawValue } from '../utils/parseRawValue';\nimport { serializeNodeToHtmlRecursive } from './utils/serializeNodeToHtmlRecursive';\nimport { setDefaultDesignTokensIfNull } from './utils/setDefaultDesignTokensIfNull';\n\nexport const serializeRawToHtml = (raw: string, designTokens: DesignTokens = defaultDesignTokens): string => {\n const nodes = parseRawValue(raw);\n return serializeNodesToHtml(nodes, designTokens);\n};\n\nexport const serializeNodesToHtml = (\n nodes: TDescendant[],\n designTokens: DesignTokens = defaultDesignTokens,\n): string => {\n const mergedDesignTokens = setDefaultDesignTokensIfNull(defaultDesignTokens, designTokens);\n return nodes.map((node) => serializeNodeToHtmlRecursive(node, mergedDesignTokens)).join('');\n};\n"],"names":[],"mappings":";;;;AAOO,MAAM,IAAqB,CAAC,GAAa,IAA6B,MAAgC;
|
|
1
|
+
{"version":3,"file":"serializeToHtml.es.js","sources":["../../../../src/components/RichTextEditor/serializer/serializeToHtml.ts"],"sourcesContent":["import { TDescendant } from '@udecode/plate';\nimport { DesignTokens } from '../types';\nimport { defaultDesignTokens } from '../utils/defaultDesignTokens';\nimport { parseRawValue } from '../utils/parseRawValue';\nimport { serializeNodeToHtmlRecursive } from './utils/serializeNodeToHtmlRecursive';\nimport { setDefaultDesignTokensIfNull } from './utils/setDefaultDesignTokensIfNull';\n\nexport const serializeRawToHtml = (raw: string, designTokens: DesignTokens = defaultDesignTokens): string => {\n const nodes = parseRawValue({ raw });\n return serializeNodesToHtml(nodes, designTokens);\n};\n\nexport const serializeNodesToHtml = (\n nodes: TDescendant[],\n designTokens: DesignTokens = defaultDesignTokens,\n): string => {\n const mergedDesignTokens = setDefaultDesignTokensIfNull(defaultDesignTokens, designTokens);\n return nodes.map((node) => serializeNodeToHtmlRecursive(node, mergedDesignTokens)).join('');\n};\n"],"names":[],"mappings":";;;;AAOO,MAAM,IAAqB,CAAC,GAAa,IAA6B,MAAgC;AACzG,QAAM,IAAQ,EAAc,EAAE,OAAK,CAAA;AAC5B,SAAA,EAAqB,GAAO,CAAY;AACnD,GAEa,IAAuB,CAChC,GACA,IAA6B,MACpB;AACH,QAAA,IAAqB,EAA6B,GAAqB,CAAY;AAClF,SAAA,EAAM,IAAI,CAAC,MAAS,EAA6B,GAAM,CAAkB,CAAC,EAAE,KAAK,EAAE;AAC9F;"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { Value } from '@udecode/plate';
|
|
2
2
|
export declare const EMPTY_RICH_TEXT_VALUE: Value;
|
|
3
|
-
|
|
3
|
+
declare type ParseRawValueOptions = {
|
|
4
|
+
editorId?: string;
|
|
5
|
+
raw?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const parseRawValue: ({ editorId, raw }: ParseRawValueOptions) => Value;
|
|
8
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ELEMENT_PARAGRAPH as
|
|
2
|
-
import { getEditorConfig as
|
|
3
|
-
const
|
|
1
|
+
import { ELEMENT_PARAGRAPH as i, createPlateEditor as l, parseHtmlDocument as m, deserializeHtml as p } from "@udecode/plate";
|
|
2
|
+
import { getEditorConfig as u } from "./editorConfig.es.js";
|
|
3
|
+
const d = (e) => /^<\w+>.*<\/\w+>$/.test(e) ? e : `<p>${e}</p>`, E = [{ type: i, children: [{ text: "" }] }], h = ({ editorId: e = "parseRawValue", raw: t }) => {
|
|
4
4
|
let r = E;
|
|
5
|
-
if (!
|
|
5
|
+
if (!t)
|
|
6
6
|
return r;
|
|
7
7
|
try {
|
|
8
|
-
r = JSON.parse(
|
|
8
|
+
r = JSON.parse(t);
|
|
9
9
|
} catch {
|
|
10
|
-
const
|
|
11
|
-
element:
|
|
10
|
+
const s = l({ id: `${e}_parseRawValue`, plugins: u() }), n = t.trim().replace(/>\s+</g, "><"), c = d(n), a = m(c), o = p(s, {
|
|
11
|
+
element: a.body,
|
|
12
12
|
stripWhitespace: !0
|
|
13
13
|
});
|
|
14
14
|
o && (r = o);
|
|
@@ -17,6 +17,6 @@ const u = (t) => /^<\w+>.*<\/\w+>$/.test(t) ? t : `<p>${t}</p>`, E = [{ type: m,
|
|
|
17
17
|
};
|
|
18
18
|
export {
|
|
19
19
|
E as EMPTY_RICH_TEXT_VALUE,
|
|
20
|
-
|
|
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 = (editorId
|
|
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\ntype ParseRawValueOptions = {\n editorId?: string;\n raw?: string;\n};\n\nexport const parseRawValue = ({ editorId = 'parseRawValue', raw }: ParseRawValueOptions): 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}_parseRawValue`, 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,GAOrF,IAAgB,CAAC,EAAE,cAAW,iBAAiB,aAAuC;AAC/F,MAAI,IAAc;AAElB,MAAI,CAAC;AACM,WAAA;AAGP,MAAA;AACc,QAAA,KAAK,MAAM,CAAG;AAAA,EAAA,QAC9B;AACQ,UAAA,IAAS,EAAkB,EAAE,IAAI,GAAG,mBAA0B,SAAS,EAAgB,EAAG,CAAA,GAC1F,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;"}
|
|
@@ -1727,10 +1727,10 @@ import "../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Heading4Plugin/crea
|
|
|
1727
1727
|
import "../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
1728
1728
|
import "../RichTextEditor/context/EditorResizeContext.es.js";
|
|
1729
1729
|
import "../RichTextEditor/EditorPositioningWrapper/index.es.js";
|
|
1730
|
+
import "slate";
|
|
1730
1731
|
import "../RichTextEditor/Plugins/CheckboxListPlugin/index.es.js";
|
|
1731
1732
|
import "slate-react";
|
|
1732
1733
|
import "../RichTextEditor/Plugins/LinkPlugin/index.es.js";
|
|
1733
|
-
import "slate";
|
|
1734
1734
|
import "../RichTextEditor/Plugins/index.es.js";
|
|
1735
1735
|
import { useScrollWrapper as g } from "./hooks/useScrollWrapper.es.js";
|
|
1736
1736
|
import { ScrollWrapperDirection as i, scrollWrapperDirections as h } from "./types.es.js";
|
|
@@ -1726,10 +1726,10 @@ import "../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Heading4Plugin/crea
|
|
|
1726
1726
|
import "../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
1727
1727
|
import "../RichTextEditor/context/EditorResizeContext.es.js";
|
|
1728
1728
|
import "../RichTextEditor/EditorPositioningWrapper/index.es.js";
|
|
1729
|
+
import "slate";
|
|
1729
1730
|
import "../RichTextEditor/Plugins/CheckboxListPlugin/index.es.js";
|
|
1730
1731
|
import "slate-react";
|
|
1731
1732
|
import "../RichTextEditor/Plugins/LinkPlugin/index.es.js";
|
|
1732
|
-
import "slate";
|
|
1733
1733
|
import "../RichTextEditor/Plugins/index.es.js";
|
|
1734
1734
|
import "../../styles.es.js";
|
|
1735
1735
|
import { SelectionMode as k } from "./Table.es.js";
|
|
@@ -1727,10 +1727,10 @@ import "../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Heading4Plugin/crea
|
|
|
1727
1727
|
import "../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
1728
1728
|
import "../RichTextEditor/context/EditorResizeContext.es.js";
|
|
1729
1729
|
import "../RichTextEditor/EditorPositioningWrapper/index.es.js";
|
|
1730
|
+
import "slate";
|
|
1730
1731
|
import "../RichTextEditor/Plugins/CheckboxListPlugin/index.es.js";
|
|
1731
1732
|
import "slate-react";
|
|
1732
1733
|
import "../RichTextEditor/Plugins/LinkPlugin/index.es.js";
|
|
1733
|
-
import "slate";
|
|
1734
1734
|
import "../RichTextEditor/Plugins/index.es.js";
|
|
1735
1735
|
import "../../styles.es.js";
|
|
1736
1736
|
import { SortDirection as O, SelectionMode as _ } from "./Table.es.js";
|
|
@@ -1728,10 +1728,10 @@ import "../../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Heading4Plugin/c
|
|
|
1728
1728
|
import "../../RichTextEditor/Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
1729
1729
|
import "../../RichTextEditor/context/EditorResizeContext.es.js";
|
|
1730
1730
|
import "../../RichTextEditor/EditorPositioningWrapper/index.es.js";
|
|
1731
|
+
import "slate";
|
|
1731
1732
|
import "../../RichTextEditor/Plugins/CheckboxListPlugin/index.es.js";
|
|
1732
1733
|
import "slate-react";
|
|
1733
1734
|
import "../../RichTextEditor/Plugins/LinkPlugin/index.es.js";
|
|
1734
|
-
import "slate";
|
|
1735
1735
|
import "../../RichTextEditor/Plugins/index.es.js";
|
|
1736
1736
|
import "@react-stately/table";
|
|
1737
1737
|
import "react-textarea-autosize";
|