@frontify/fondue 12.0.0-beta.13 → 12.0.0-beta.14
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/GeneratePlugins.d.ts +3 -3
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.es.js +12 -16
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.es.js.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.es.js +19 -19
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/components/RichTextEditor/Toolbar/index.d.ts +1 -1
- package/dist/components/RichTextEditor/Toolbar/index.es.js +19 -18
- package/dist/components/RichTextEditor/Toolbar/index.es.js.map +1 -1
- package/dist/components/RichTextEditor/Toolbar/types.d.ts +0 -2
- package/dist/components/RichTextEditor/context/RichTextEditorContext.d.ts +1 -1
- package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js +16 -17
- package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js.map +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/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { AnyObject, PlatePlugin } from '@udecode/plate';
|
|
3
3
|
import type { PluginComposer } from './PluginComposer';
|
|
4
4
|
declare type GeneratePluginsReturn = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
create: () => PlatePlugin<AnyObject>[];
|
|
6
|
+
toolbar: () => ReactNode;
|
|
7
|
+
inline: () => ReactNode;
|
|
8
8
|
};
|
|
9
9
|
export declare const createPlatePlugins: (pluginComposer: PluginComposer) => PlatePlugin<AnyObject, import("@udecode/plate").Value, import("@udecode/plate").PlateEditor<import("@udecode/plate").Value>>[];
|
|
10
10
|
export declare const GeneratePlugins: (editorId: string, pluginComposer?: PluginComposer | undefined) => GeneratePluginsReturn | null;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createPlugins as l, createPlateUI as c
|
|
1
|
+
import n from "react";
|
|
2
|
+
import { createPlugins as l, createPlateUI as c } from "@udecode/plate";
|
|
3
3
|
import { Toolbar as m } from "../Toolbar/index.es.js";
|
|
4
|
-
const
|
|
5
|
-
components: c(
|
|
6
|
-
}), P = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
editorId: t
|
|
14
|
-
}) : /* @__PURE__ */ e.createElement(e.Fragment, null);
|
|
15
|
-
},
|
|
16
|
-
Inline: () => /* @__PURE__ */ e.createElement(e.Fragment, null, n.inline.map((r, a) => /* @__PURE__ */ e.createElement(r, {
|
|
4
|
+
const o = (e) => l(e.plugins, {
|
|
5
|
+
components: c(e.elements)
|
|
6
|
+
}), P = (e, t) => t ? {
|
|
7
|
+
create: () => o(t),
|
|
8
|
+
toolbar: () => /* @__PURE__ */ n.createElement(m, {
|
|
9
|
+
buttons: t.buttons,
|
|
10
|
+
editorId: e
|
|
11
|
+
}),
|
|
12
|
+
inline: () => /* @__PURE__ */ n.createElement(n.Fragment, null, t.inline.map((r, a) => /* @__PURE__ */ n.createElement(r, {
|
|
17
13
|
key: a
|
|
18
14
|
})))
|
|
19
15
|
} : null;
|
|
20
16
|
export {
|
|
21
17
|
P as GeneratePlugins,
|
|
22
|
-
|
|
18
|
+
o as createPlatePlugins
|
|
23
19
|
};
|
|
24
20
|
//# sourceMappingURL=GeneratePlugins.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratePlugins.es.js","sources":["../../../../src/components/RichTextEditor/Plugins/GeneratePlugins.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { ReactNode } from 'react';\nimport { AnyObject, PlatePlugin, createPlateUI, createPlugins
|
|
1
|
+
{"version":3,"file":"GeneratePlugins.es.js","sources":["../../../../src/components/RichTextEditor/Plugins/GeneratePlugins.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { ReactNode } from 'react';\nimport { AnyObject, PlatePlugin, createPlateUI, createPlugins } from '@udecode/plate';\nimport { Toolbar } from '../Toolbar';\nimport type { PluginComposer } from './PluginComposer';\n\ntype GeneratePluginsReturn = {\n create: () => PlatePlugin<AnyObject>[];\n toolbar: () => ReactNode;\n inline: () => ReactNode;\n};\n\nexport const createPlatePlugins = (pluginComposer: PluginComposer) =>\n createPlugins(pluginComposer.plugins, {\n components: createPlateUI(pluginComposer.elements),\n });\n\nexport const GeneratePlugins = (editorId: string, pluginComposer?: PluginComposer): GeneratePluginsReturn | null => {\n if (!pluginComposer) {\n return null;\n }\n\n return {\n create: () => createPlatePlugins(pluginComposer),\n toolbar: () => <Toolbar buttons={pluginComposer.buttons} editorId={editorId} />,\n inline: () => (\n <>\n {pluginComposer.inline.map((Inline, index) => (\n <Inline key={index} />\n ))}\n </>\n ),\n };\n};\n"],"names":[],"mappings":";;;AAaO,MAAM,IAAqB,CAAC,MAC/B,EAAc,EAAe,SAAS;AAAA,EAClC,YAAY,EAAc,EAAe,QAAQ;AACrD,CAAC,GAEQ,IAAkB,CAAC,GAAkB,MACzC,IAIE;AAAA,EACH,QAAQ,MAAM,EAAmB,CAAc;AAAA,EAC/C,SAAS,MAAO,kBAAA,cAAA,GAAA;AAAA,IAAQ,SAAS,EAAe;AAAA,IAAS;AAAA,EAAA,CAAoB;AAAA,EAC7E,QAAQ,MAEC,kBAAA,cAAA,EAAA,UAAA,MAAA,EAAe,OAAO,IAAI,CAAC,GAAQ,MAC/B,kBAAA,cAAA,GAAA;AAAA,IAAO,KAAK;AAAA,EAAO,CAAA,CACvB,CACL;AAAA,IAXG;"}
|
|
@@ -2,16 +2,16 @@ import r from "react";
|
|
|
2
2
|
import { Plate as v } from "@udecode/plate";
|
|
3
3
|
import { useMemoizedId as y } from "../../hooks/useMemoizedId.es.js";
|
|
4
4
|
import { Toolbar as A } from "./components/Toolbar/Toolbar.es.js";
|
|
5
|
-
import { RichTextEditorProvider as
|
|
6
|
-
import { useEditorState as
|
|
7
|
-
import { PaddingSizes as
|
|
8
|
-
import { defaultActions as
|
|
9
|
-
import { defaultDesignTokens as
|
|
10
|
-
import { parseRawValue as
|
|
5
|
+
import { RichTextEditorProvider as N } from "./context/RichTextEditorContext.es.js";
|
|
6
|
+
import { useEditorState as R } from "./hooks/useEditorState.es.js";
|
|
7
|
+
import { PaddingSizes as S } from "./types.es.js";
|
|
8
|
+
import { defaultActions as w } from "./utils/actions.es.js";
|
|
9
|
+
import { defaultDesignTokens as C } from "./utils/defaultDesignTokens.es.js";
|
|
10
|
+
import { parseRawValue as L } from "./utils/parseRawValue.es.js";
|
|
11
11
|
import "./EditorPositioningWrapper/index.es.js";
|
|
12
|
-
import { getEditorConfig as
|
|
13
|
-
import { defaultPlugins as
|
|
14
|
-
import { forceTabOutOfActiveElement as
|
|
12
|
+
import { getEditorConfig as x } from "./utils/editorConfig.es.js";
|
|
13
|
+
import { defaultPlugins as D } from "./Plugins/index.es.js";
|
|
14
|
+
import { forceTabOutOfActiveElement as I } from "./helpers/forceTabOutOfActiveElement.es.js";
|
|
15
15
|
import { Position as V } from "./EditorPositioningWrapper/types.es.js";
|
|
16
16
|
import { GeneratePlugins as z } from "./Plugins/GeneratePlugins.es.js";
|
|
17
17
|
const G = {
|
|
@@ -22,15 +22,15 @@ const G = {
|
|
|
22
22
|
value: s,
|
|
23
23
|
placeholder: f = "",
|
|
24
24
|
readonly: c = !1,
|
|
25
|
-
designTokens: d =
|
|
26
|
-
actions: n =
|
|
25
|
+
designTokens: d = C,
|
|
26
|
+
actions: n = w,
|
|
27
27
|
onTextChange: p,
|
|
28
28
|
onBlur: m,
|
|
29
|
-
padding: u =
|
|
29
|
+
padding: u = S.None,
|
|
30
30
|
position: g = V.FLOATING,
|
|
31
|
-
plugins: E =
|
|
31
|
+
plugins: E = D
|
|
32
32
|
}) => {
|
|
33
|
-
const e = y(l), { localValue: P, onChange: T } =
|
|
33
|
+
const e = y(l), { localValue: P, onChange: T } = R(p), h = {
|
|
34
34
|
placeholder: f,
|
|
35
35
|
renderPlaceholder: ({ children: i, attributes: a }) => {
|
|
36
36
|
const b = {
|
|
@@ -48,18 +48,18 @@ const G = {
|
|
|
48
48
|
onBlur: () => m && m(JSON.stringify(P.current)),
|
|
49
49
|
className: u,
|
|
50
50
|
onKeyDown: (i) => {
|
|
51
|
-
i.code === "Tab" &&
|
|
51
|
+
i.code === "Tab" && I();
|
|
52
52
|
}
|
|
53
|
-
}, o = z(e, E), t = !!o && n.length === 0, O = t ? o.
|
|
54
|
-
return /* @__PURE__ */ r.createElement(
|
|
53
|
+
}, o = z(e, E), t = !!o && n.length === 0, O = t ? o.create() : x();
|
|
54
|
+
return /* @__PURE__ */ r.createElement(N, {
|
|
55
55
|
value: { designTokens: d, position: g }
|
|
56
56
|
}, /* @__PURE__ */ r.createElement(v, {
|
|
57
57
|
id: e,
|
|
58
|
-
initialValue:
|
|
58
|
+
initialValue: L({ editorId: e, raw: s }),
|
|
59
59
|
onChange: T,
|
|
60
60
|
editableProps: h,
|
|
61
61
|
plugins: O
|
|
62
|
-
}, t && o.
|
|
62
|
+
}, t && o.toolbar(), t && o.inline(), !t && /* @__PURE__ */ r.createElement(A, {
|
|
63
63
|
editorId: e,
|
|
64
64
|
actions: n
|
|
65
65
|
})));
|
|
@@ -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 } 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.
|
|
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,28 +1,29 @@
|
|
|
1
|
+
import { usePlateEditorRef as w } from "@udecode/plate";
|
|
1
2
|
import t from "react";
|
|
2
|
-
import { useEditorResizeContext as
|
|
3
|
-
import { useRichTextEditorContext as
|
|
4
|
-
import { EditorPositioningWrapper as
|
|
5
|
-
import { ButtonGroupWrapper as
|
|
6
|
-
import { getButtonGroupWidths as
|
|
7
|
-
const
|
|
8
|
-
const { editorWidth:
|
|
3
|
+
import { useEditorResizeContext as x } from "../context/EditorResizeContext.es.js";
|
|
4
|
+
import { useRichTextEditorContext as E } from "../context/RichTextEditorContext.es.js";
|
|
5
|
+
import { EditorPositioningWrapper as W } from "../EditorPositioningWrapper/index.es.js";
|
|
6
|
+
import { ButtonGroupWrapper as G } from "../Plugins/helper.es.js";
|
|
7
|
+
import { getButtonGroupWidths as R, getButtonGroupsPerRow as b } from "./utils.es.js";
|
|
8
|
+
const C = ({ buttons: p, editorId: o }) => {
|
|
9
|
+
const m = w(o), { editorWidth: e } = x(), { position: s } = E(), a = R(p), r = b(e || 0, a), u = W[s];
|
|
9
10
|
return /* @__PURE__ */ t.createElement(u.ToolbarWrapper, {
|
|
10
|
-
editorWidth:
|
|
11
|
-
toolbarButtonGroups:
|
|
12
|
-
},
|
|
11
|
+
editorWidth: e,
|
|
12
|
+
toolbarButtonGroups: r
|
|
13
|
+
}, r.map((d, c) => /* @__PURE__ */ t.createElement("div", {
|
|
13
14
|
className: "tw-divide-x tw-divide-line tw-flex tw-w-full tw-flex-wrap",
|
|
14
15
|
key: c
|
|
15
|
-
}, d.map(({ group: l, index:
|
|
16
|
-
index:
|
|
17
|
-
key:
|
|
18
|
-
}, l.map((
|
|
19
|
-
editor:
|
|
20
|
-
editorId:
|
|
21
|
-
id:
|
|
16
|
+
}, d.map(({ group: l, index: i }) => /* @__PURE__ */ t.createElement(G, {
|
|
17
|
+
index: i,
|
|
18
|
+
key: i
|
|
19
|
+
}, l.map((n, f) => /* @__PURE__ */ t.createElement(n.button, {
|
|
20
|
+
editor: m,
|
|
21
|
+
editorId: o,
|
|
22
|
+
id: n.id,
|
|
22
23
|
key: f.toString()
|
|
23
24
|
})))))));
|
|
24
25
|
};
|
|
25
26
|
export {
|
|
26
|
-
|
|
27
|
+
C as Toolbar
|
|
27
28
|
};
|
|
28
29
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../src/components/RichTextEditor/Toolbar/index.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { useEditorResizeContext } from '../context/EditorResizeContext';\nimport { useRichTextEditorContext } from '../context/RichTextEditorContext';\nimport { EditorPositioningWrapper } from '../EditorPositioningWrapper';\nimport { ButtonGroupWrapper } from '../Plugins/helper';\nimport { ToolbarProps } from './types';\nimport { getButtonGroupWidths, getButtonGroupsPerRow } from './utils';\n\nexport const Toolbar = ({ buttons,
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../src/components/RichTextEditor/Toolbar/index.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { usePlateEditorRef } from '@udecode/plate';\nimport React from 'react';\nimport { useEditorResizeContext } from '../context/EditorResizeContext';\nimport { useRichTextEditorContext } from '../context/RichTextEditorContext';\nimport { EditorPositioningWrapper } from '../EditorPositioningWrapper';\nimport { ButtonGroupWrapper } from '../Plugins/helper';\nimport { ToolbarProps } from './types';\nimport { getButtonGroupWidths, getButtonGroupsPerRow } from './utils';\n\nexport const Toolbar = ({ buttons, editorId }: ToolbarProps) => {\n const editor = usePlateEditorRef(editorId)!;\n const { editorWidth } = useEditorResizeContext();\n const { position } = useRichTextEditorContext();\n\n const buttonGroupWidths = getButtonGroupWidths(buttons);\n const buttonGroupsPerRow = getButtonGroupsPerRow(editorWidth || 0, buttonGroupWidths);\n\n const PositioningWrapper = EditorPositioningWrapper[position];\n\n return (\n <PositioningWrapper.ToolbarWrapper editorWidth={editorWidth} toolbarButtonGroups={buttonGroupsPerRow}>\n {buttonGroupsPerRow.map((row, index) => (\n <div className=\"tw-divide-x tw-divide-line tw-flex tw-w-full tw-flex-wrap\" key={index}>\n {row.map(({ group, index }) => (\n <ButtonGroupWrapper index={index} key={index}>\n {group.map((ToolbarButton, idx) => (\n <ToolbarButton.button\n editor={editor}\n editorId={editorId}\n id={ToolbarButton.id}\n key={idx.toString()}\n />\n ))}\n </ButtonGroupWrapper>\n ))}\n </div>\n ))}\n </PositioningWrapper.ToolbarWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAWO,MAAM,IAAU,CAAC,EAAE,YAAS,kBAA6B;AACtD,QAAA,IAAS,EAAkB,CAAQ,GACnC,EAAE,mBAAgB,KAClB,EAAE,gBAAa,KAEf,IAAoB,EAAqB,CAAO,GAChD,IAAqB,EAAsB,KAAe,GAAG,CAAiB,GAE9E,IAAqB,EAAyB;AAGhD,SAAA,kBAAA,cAAC,EAAmB,gBAAnB;AAAA,IAAkC;AAAA,IAA0B,qBAAqB;AAAA,EAAA,GAC7E,EAAmB,IAAI,CAAC,GAAK,MACzB,kBAAA,cAAA,OAAA;AAAA,IAAI,WAAU;AAAA,IAA4D,KAAK;AAAA,EAAA,GAC3E,EAAI,IAAI,CAAC,EAAE,UAAO,eACd,kBAAA,cAAA,GAAA;AAAA,IAAmB,OAAO;AAAA,IAAO,KAAK;AAAA,EAAA,GAClC,EAAM,IAAI,CAAC,GAAe,MACvB,kBAAA,cAAC,EAAc,QAAd;AAAA,IACG;AAAA,IACA;AAAA,IACA,IAAI,EAAc;AAAA,IAClB,KAAK,EAAI,SAAS;AAAA,EAAA,CACtB,CACH,CACL,CACH,CACL,CACH,CACL;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;
|
|
9
9
|
declare type RichTextEditorProviderProps = {
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
value: {
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { defaultDesignTokens as
|
|
1
|
+
import o, { createContext as d, useContext as x } from "react";
|
|
2
|
+
import { defaultDesignTokens as r } from "../utils/defaultDesignTokens.es.js";
|
|
3
3
|
import "../EditorPositioningWrapper/index.es.js";
|
|
4
|
-
import { EditorResizeContextProvider as
|
|
5
|
-
import { Position as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
position: e != null ? e : u.FLOATING
|
|
4
|
+
import { EditorResizeContextProvider as a } from "./EditorResizeContext.es.js";
|
|
5
|
+
import { Position as i } from "../EditorPositioningWrapper/types.es.js";
|
|
6
|
+
const n = d({
|
|
7
|
+
designTokens: r,
|
|
8
|
+
position: i.FLOATING
|
|
9
|
+
}), f = () => x(n), C = ({ children: s, value: c }) => {
|
|
10
|
+
const { designTokens: t, position: e } = c, m = {
|
|
11
|
+
designTokens: t != null ? t : r,
|
|
12
|
+
position: e != null ? e : i.FLOATING
|
|
14
13
|
};
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
value:
|
|
17
|
-
}, /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ o.createElement(n.Provider, {
|
|
15
|
+
value: m
|
|
16
|
+
}, /* @__PURE__ */ o.createElement(a, null, s));
|
|
18
17
|
};
|
|
19
18
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
C as RichTextEditorProvider,
|
|
20
|
+
f as useRichTextEditorContext
|
|
22
21
|
};
|
|
23
22
|
//# 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>({\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: 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,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,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;"}
|