@frontify/fondue 12.0.0-beta.13 → 12.0.0-beta.16
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/DatePicker/DatePickerTrigger.es.js +17 -16
- package/dist/components/DatePicker/DatePickerTrigger.es.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.es.js +41 -40
- package/dist/components/Dropdown/Dropdown.es.js.map +1 -1
- package/dist/components/LoadingBar/LoadingBar.d.ts +24 -0
- package/dist/components/LoadingBar/LoadingBar.es.js +50 -0
- package/dist/components/LoadingBar/LoadingBar.es.js.map +1 -0
- package/dist/components/LoadingBar/index.d.ts +1 -0
- package/dist/components/OverflowMenu/OverflowMenu.d.ts +6 -0
- package/dist/components/OverflowMenu/OverflowMenu.es.js +1721 -0
- package/dist/components/OverflowMenu/OverflowMenu.es.js.map +1 -0
- package/dist/components/OverflowMenu/OverflowMenuItem.d.ts +11 -0
- package/dist/components/OverflowMenu/OverflowMenuItem.es.js +1763 -0
- package/dist/components/OverflowMenu/OverflowMenuItem.es.js.map +1 -0
- package/dist/components/OverflowMenu/index.d.ts +1 -0
- package/dist/components/OverflowMenu/useOverflowMenuKeyboardNavigation.d.ts +1 -0
- package/dist/components/OverflowMenu/useOverflowMenuKeyboardNavigation.es.js +29 -0
- package/dist/components/OverflowMenu/useOverflowMenuKeyboardNavigation.es.js.map +1 -0
- 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/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.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/components/RichTextEditor/serializer/utils/serializeLeafToHtml.d.ts +1 -2
- package/dist/components/RichTextEditor/serializer/utils/serializeLeafToHtml.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.d.ts +1 -2
- package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.es.js +23 -19
- package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.es.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +2 -1
- package/dist/components/Tooltip/Tooltip.es.js +97 -92
- package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
- package/dist/components/Tree/Node.d.ts +4 -2
- package/dist/components/Tree/Node.es.js +105 -99
- package/dist/components/Tree/Node.es.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +2 -0
- package/dist/components/Tree/Tree.es.js +39 -35
- package/dist/components/Tree/Tree.es.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +3608 -3600
- 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/dist/utilities/dnd/DndWrapper.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverflowMenuItem.es.js","sources":["../../../src/components/OverflowMenu/OverflowMenuItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { MouseEvent, ReactElement } from 'react';\nimport { IconProps } from '@foundation/Icon/IconProps';\nimport { MenuItem } from '..';\nimport { getItemElementType } from '@utilities/elements';\n\nexport interface OverflowMenuItemProps {\n id?: string;\n label: string;\n link?: string;\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void;\n decorator?: ReactElement<IconProps>;\n disabled?: boolean;\n}\n\nexport const OverflowMenuItem = ({\n id = 'overflow-menu-item',\n label,\n link,\n onClick,\n disabled = false,\n}: OverflowMenuItemProps) => {\n const contentElementType = getItemElementType(link, onClick);\n\n const menuItemElement = <MenuItem title={label} disabled={disabled} />;\n\n return (\n <li id={id} data-test-id=\"overflow-menu-item\">\n {contentElementType === 'a' && <a href={link}>{menuItemElement}</a>}\n {contentElementType === 'button' && (\n <button onClick={onClick} type=\"button\" disabled={disabled}>\n {menuItemElement}\n </button>\n )}\n {contentElementType === 'span' && <span>{menuItemElement}</span>}\n </li>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,MAAM,KAAmB,CAAC;AAAA,EAC7B,QAAK;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAW;AAAA,MACc;AACnB,QAAA,IAAqB,EAAmB,GAAM,CAAO,GAErD,IAAmB,kBAAA,cAAA,GAAA;AAAA,IAAS,OAAO;AAAA,IAAO;AAAA,EAAA,CAAoB;AAEpE,SACK,kBAAA,cAAA,MAAA;AAAA,IAAG;AAAA,IAAQ,gBAAa;AAAA,EACpB,GAAA,MAAuB,OAAQ,kBAAA,cAAA,KAAA;AAAA,IAAE,MAAM;AAAA,EAAA,GAAO,CAAgB,GAC9D,MAAuB,YACnB,kBAAA,cAAA,UAAA;AAAA,IAAO;AAAA,IAAkB,MAAK;AAAA,IAAS;AAAA,EAAA,GACnC,CACL,GAEH,MAAuB,UAAW,kBAAA,cAAA,QAAA,MAAM,CAAgB,CAC7D;AAER;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './OverflowMenu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useOverflowMenuKeyboardNavigation: (isMenuOpened: boolean, menuContainerRef: HTMLElement | null, focusableElementsSelector?: string) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState as a, useCallback as k, useEffect as c } from "react";
|
|
2
|
+
const E = (r, i, f = "li > button:not(:disabled)") => {
|
|
3
|
+
const [s, n] = a(0), [t, l] = a(), [d, u] = a(""), y = k((o) => {
|
|
4
|
+
if (!t || !["Tab", "ArrowDown", "ArrowUp", "Escape"].includes(o.key))
|
|
5
|
+
return;
|
|
6
|
+
const e = o.key === "Tab" && !o.shiftKey, b = o.key === "Tab" && o.shiftKey, h = o.key === "Escape", m = e || o.key === "ArrowDown", w = b || o.key === "ArrowUp";
|
|
7
|
+
if (b && s <= 0 || e && s >= t.length - 1 || h) {
|
|
8
|
+
u("CLOSE_MENU");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
m ? n(Math.min(s + 1, t.length - 1)) : w && n(Math.max(s - 1, 0)), o.preventDefault();
|
|
12
|
+
}, [t, s]);
|
|
13
|
+
return c(() => {
|
|
14
|
+
if (!r || !i)
|
|
15
|
+
return;
|
|
16
|
+
const o = i.querySelectorAll(f);
|
|
17
|
+
for (const e of o)
|
|
18
|
+
e.onkeydown = y;
|
|
19
|
+
t || l(o);
|
|
20
|
+
}, [r, i, t, y, f]), c(() => {
|
|
21
|
+
!t || t[s] && t[s].focus();
|
|
22
|
+
}, [s, t]), c(() => {
|
|
23
|
+
r || (l(void 0), u("")), n(0);
|
|
24
|
+
}, [r]), d;
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
E as useOverflowMenuKeyboardNavigation
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=useOverflowMenuKeyboardNavigation.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverflowMenuKeyboardNavigation.es.js","sources":["../../../src/components/OverflowMenu/useOverflowMenuKeyboardNavigation.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nexport const useOverflowMenuKeyboardNavigation = (\n isMenuOpened: boolean,\n menuContainerRef: HTMLElement | null,\n focusableElementsSelector = 'li > button:not(:disabled)',\n) => {\n const [currentItemIndex, setCurrentItemIndex] = useState(0);\n const [itemsElements, setItemsElements] = useState<NodeList>();\n const [menuKeyboardNavigationAction, setMenuKeyboardNavigationAction] = useState('');\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (!itemsElements || !['Tab', 'ArrowDown', 'ArrowUp', 'Escape'].includes(event.key)) {\n return;\n }\n\n const isTab = event.key === 'Tab' && !event.shiftKey;\n const isShiftTab = event.key === 'Tab' && event.shiftKey;\n const isEsc = event.key === 'Escape';\n const shouldMoveDown = isTab || event.key === 'ArrowDown';\n const shouldMoveUp = isShiftTab || event.key === 'ArrowUp';\n\n if (\n (isShiftTab && currentItemIndex <= 0) ||\n (isTab && currentItemIndex >= itemsElements.length - 1) ||\n isEsc\n ) {\n setMenuKeyboardNavigationAction('CLOSE_MENU');\n return;\n }\n\n if (shouldMoveDown) {\n setCurrentItemIndex(Math.min(currentItemIndex + 1, itemsElements.length - 1));\n } else if (shouldMoveUp) {\n setCurrentItemIndex(Math.max(currentItemIndex - 1, 0));\n }\n\n event.preventDefault();\n },\n [itemsElements, currentItemIndex],\n );\n\n useEffect(() => {\n if (!isMenuOpened || !menuContainerRef) {\n return;\n }\n\n const focusableItems = menuContainerRef.querySelectorAll(focusableElementsSelector);\n\n for (const item of focusableItems) {\n (item as HTMLButtonElement | HTMLAnchorElement).onkeydown = handleKeyDown;\n }\n\n if (!itemsElements) {\n setItemsElements(focusableItems);\n }\n }, [isMenuOpened, menuContainerRef, itemsElements, handleKeyDown, focusableElementsSelector]);\n\n useEffect(() => {\n if (!itemsElements) {\n return;\n }\n\n if (itemsElements[currentItemIndex]) {\n (itemsElements[currentItemIndex] as HTMLButtonElement).focus();\n }\n }, [currentItemIndex, itemsElements]);\n\n useEffect(() => {\n if (!isMenuOpened) {\n setItemsElements(undefined);\n setMenuKeyboardNavigationAction('');\n }\n\n setCurrentItemIndex(0);\n }, [isMenuOpened]);\n\n return menuKeyboardNavigationAction;\n};\n"],"names":[],"mappings":";AAEO,MAAM,IAAoC,CAC7C,GACA,GACA,IAA4B,iCAC3B;AACD,QAAM,CAAC,GAAkB,KAAuB,EAAS,CAAC,GACpD,CAAC,GAAe,KAAoB,EAAmB,GACvD,CAAC,GAA8B,KAAmC,EAAS,EAAE,GAE7E,IAAgB,EAClB,CAAC,MAAyB;AACtB,QAAI,CAAC,KAAiB,CAAC,CAAC,OAAO,aAAa,WAAW,QAAQ,EAAE,SAAS,EAAM,GAAG;AAC/E;AAGJ,UAAM,IAAQ,EAAM,QAAQ,SAAS,CAAC,EAAM,UACtC,IAAa,EAAM,QAAQ,SAAS,EAAM,UAC1C,IAAQ,EAAM,QAAQ,UACtB,IAAiB,KAAS,EAAM,QAAQ,aACxC,IAAe,KAAc,EAAM,QAAQ;AAG5C,QAAA,KAAc,KAAoB,KAClC,KAAS,KAAoB,EAAc,SAAS,KACrD,GACF;AACE,QAAgC,YAAY;AAC5C;AAAA,IACJ;AAEA,IAAI,IACA,EAAoB,KAAK,IAAI,IAAmB,GAAG,EAAc,SAAS,CAAC,CAAC,IACrE,KACP,EAAoB,KAAK,IAAI,IAAmB,GAAG,CAAC,CAAC,GAGzD,EAAM,eAAe;AAAA,EAAA,GAEzB,CAAC,GAAe,CAAgB,CACpC;AAEA,WAAU,MAAM;AACR,QAAA,CAAC,KAAgB,CAAC;AAClB;AAGE,UAAA,IAAiB,EAAiB,iBAAiB,CAAyB;AAElF,eAAW,KAAQ;AACd,QAA+C,YAAY;AAGhE,IAAK,KACD,EAAiB,CAAc;AAAA,EACnC,GACD,CAAC,GAAc,GAAkB,GAAe,GAAe,CAAyB,CAAC,GAE5F,EAAU,MAAM;AACZ,IAAI,CAAC,KAID,EAAc,MACb,EAAc,GAAwC;EAC3D,GACD,CAAC,GAAkB,CAAa,CAAC,GAEpC,EAAU,MAAM;AACZ,IAAK,KACD,GAAiB,MAAS,GAC1B,EAAgC,EAAE,IAGtC,EAAoB,CAAC;AAAA,EAAA,GACtB,CAAC,CAAY,CAAC,GAEV;AACX;"}
|
|
@@ -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;"}
|
|
@@ -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: 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
|
+
{"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, { MouseEvent } 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;"}
|
|
@@ -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;"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const serializeLeafToHtml: (node: TDescendant) => string;
|
|
1
|
+
export declare const serializeLeafToHtml: (node: any) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeLeafToHtml.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/utils/serializeLeafToHtml.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {
|
|
1
|
+
{"version":3,"file":"serializeLeafToHtml.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/utils/serializeLeafToHtml.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n BOLD_CLASSES,\n CODE_CLASSES,\n ITALIC_CLASSES,\n STRIKETHROUGH_CLASSES,\n UNDERLINE_CLASSES,\n} from '@components/RichTextEditor/Plugins';\nimport escapeHtml from 'escape-html';\n\nexport const serializeLeafToHtml = (node: any): string => {\n let string = escapeHtml(node.text);\n if (node.bold) {\n string = `<span class=\"${BOLD_CLASSES}\">${string}</span>`;\n }\n if (node.italic) {\n string = `<span class=\"${ITALIC_CLASSES}\">${string}</span>`;\n }\n if (node.underline) {\n string = `<span class=\"${UNDERLINE_CLASSES}\">${string}</span>`;\n }\n if (node.strikethrough) {\n string = `<span class=\"${STRIKETHROUGH_CLASSES}\">${string}</span>`;\n }\n if (node.code) {\n string = `<span class=\"${CODE_CLASSES}\">${string}</span>`;\n }\n return string;\n};\n"],"names":["escapeHtml"],"mappings":";;;;;;;AAWa,MAAA,IAAsB,CAAC,MAAsB;AAClD,MAAA,IAASA,EAAW,EAAK,IAAI;AACjC,SAAI,EAAK,QACL,KAAS,gBAAgB,MAAiB,aAE1C,EAAK,UACL,KAAS,gBAAgB,MAAmB,aAE5C,EAAK,aACL,KAAS,gBAAgB,MAAsB,aAE/C,EAAK,iBACL,KAAS,gBAAgB,MAA0B,aAEnD,EAAK,QACL,KAAS,gBAAgB,MAAiB,aAEvC;AACX;"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { TDescendant } from '@udecode/plate';
|
|
2
1
|
import { DesignTokens } from '../../../RichTextEditor/types';
|
|
3
|
-
export declare const serializeNodeToHtmlRecursive: (node:
|
|
2
|
+
export declare const serializeNodeToHtmlRecursive: (node: any, designTokens: DesignTokens) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ELEMENT_LINK as c, ELEMENT_LI as
|
|
1
|
+
import { ELEMENT_LINK as c, ELEMENT_LI as m, ELEMENT_OL as i, ELEMENT_UL as s, ELEMENT_PARAGRAPH as $ } from "@udecode/plate";
|
|
2
2
|
import "../../Plugins/index.es.js";
|
|
3
|
-
import { TextStyles as
|
|
3
|
+
import { TextStyles as E } from "../../Plugins/TextStylePlugin/TextStyles/textStyles.es.js";
|
|
4
4
|
import "../../Plugins/TextStylePlugin/TextStyles/Custom1Plugin/createCustom1Plugin.es.js";
|
|
5
5
|
import "../../Plugins/TextStylePlugin/TextStyles/Custom2Plugin/createCustom2Plugin.es.js";
|
|
6
6
|
import "../../Plugins/TextStylePlugin/TextStyles/Custom3Plugin/createCustom3Plugin.es.js";
|
|
@@ -9,43 +9,47 @@ import "../../Plugins/TextStylePlugin/TextStyles/Heading2Plugin/createHeading2Pl
|
|
|
9
9
|
import "../../Plugins/TextStylePlugin/TextStyles/Heading3Plugin/createHeading3Plugin.es.js";
|
|
10
10
|
import "../../Plugins/TextStylePlugin/TextStyles/Heading4Plugin/createHeading4Plugin.es.js";
|
|
11
11
|
import "../../Plugins/TextStylePlugin/TextStyles/Quote/createQuotePlugin.es.js";
|
|
12
|
-
import
|
|
12
|
+
import p from "../../../../node_modules/escape-html/index.es.js";
|
|
13
13
|
import { reactCssPropsToCss as e } from "./reactCssPropsToCss.es.js";
|
|
14
14
|
import { serializeLeafToHtml as o } from "./serializeLeafToHtml.es.js";
|
|
15
15
|
import { ELEMENT_CHECK_ITEM as u } from "../../Plugins/CheckboxListPlugin/id.es.js";
|
|
16
16
|
import { OL_CLASSES as L } from "../../Plugins/ListPlugin/OrderedListPlugin/OrderedListMarkupElement.es.js";
|
|
17
17
|
import { UL_CLASSES as h } from "../../Plugins/ListPlugin/UnorderedListPlugin/UnorderedListMarkupElement.es.js";
|
|
18
|
-
const N = (
|
|
19
|
-
if (!
|
|
20
|
-
return o(
|
|
21
|
-
const r =
|
|
22
|
-
switch (
|
|
23
|
-
case
|
|
18
|
+
const N = (l, t) => {
|
|
19
|
+
if (!l.children)
|
|
20
|
+
return o(l);
|
|
21
|
+
const r = l.children.map((a) => N(a, t)).join("");
|
|
22
|
+
switch (l.type) {
|
|
23
|
+
case E.ELEMENT_HEADING1:
|
|
24
24
|
return `<h1 style="${e(t.heading1)}">${r}</h1>`;
|
|
25
|
-
case
|
|
25
|
+
case E.ELEMENT_HEADING2:
|
|
26
26
|
return `<h2 style="${e(t.heading2)}">${r}</h2>`;
|
|
27
|
-
case
|
|
27
|
+
case E.ELEMENT_HEADING3:
|
|
28
28
|
return `<h3 style="${e(t.heading3)}">${r}</h3>`;
|
|
29
|
-
case
|
|
29
|
+
case E.ELEMENT_HEADING4:
|
|
30
30
|
return `<h4 style="${e(t.heading4)}">${r}</h4>`;
|
|
31
|
-
case
|
|
31
|
+
case E.ELEMENT_CUSTOM1:
|
|
32
32
|
return `<p style="${e(t.custom1)}">${r}</p>`;
|
|
33
|
-
case
|
|
33
|
+
case E.ELEMENT_CUSTOM2:
|
|
34
34
|
return `<p style="${e(t.custom2)}">${r}</p>`;
|
|
35
|
-
case
|
|
35
|
+
case E.ELEMENT_CUSTOM3:
|
|
36
36
|
return `<p style="${e(t.custom3)}">${r}</p>`;
|
|
37
|
-
case
|
|
37
|
+
case E.ELEMENT_QUOTE:
|
|
38
38
|
return `<p style="${e(t.quote)}">${r}</p>`;
|
|
39
39
|
case $:
|
|
40
40
|
return `<p>${r}</p>`;
|
|
41
41
|
case s:
|
|
42
42
|
return `<ul class="${h}">${r}</ul>`;
|
|
43
|
-
case m:
|
|
44
|
-
return `<ol class="${L}">${r}</ol>`;
|
|
45
43
|
case i:
|
|
44
|
+
return `<ol class="${L}">${r}</ol>`;
|
|
45
|
+
case m:
|
|
46
46
|
return `<li>${r}</li>`;
|
|
47
47
|
case c:
|
|
48
|
-
|
|
48
|
+
if (l.chosenLink) {
|
|
49
|
+
const { chosenLink: a } = l;
|
|
50
|
+
return `<a style="${e(t.link)}" target=${a.openInNewTab ? "_blank" : "_self"} href="${p(a.searchResult.link)}">${r}</a>`;
|
|
51
|
+
}
|
|
52
|
+
return `<a style="${e(t.link)}" href="${p(l.url)}">${r}</a>`;
|
|
49
53
|
case u:
|
|
50
54
|
return `<input type="checkbox"/><label>${r}</label>`;
|
|
51
55
|
default:
|
package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeNodeToHtmlRecursive.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { ELEMENT_LI, ELEMENT_LINK, ELEMENT_OL, ELEMENT_PARAGRAPH, ELEMENT_UL, TDescendant } from '@udecode/plate';\nimport { ELEMENT_CHECK_ITEM, OL_CLASSES, UL_CLASSES } from '@components/RichTextEditor/Plugins';\nimport { DesignTokens } from '@components/RichTextEditor/types';\nimport { TextStyles } from '@components/RichTextEditor/Plugins/TextStylePlugin/TextStyles';\nimport escapeHtml from 'escape-html';\nimport { reactCssPropsToCss } from './reactCssPropsToCss';\nimport { serializeLeafToHtml } from './serializeLeafToHtml';\n\nexport const serializeNodeToHtmlRecursive = (node:
|
|
1
|
+
{"version":3,"file":"serializeNodeToHtmlRecursive.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { ELEMENT_LI, ELEMENT_LINK, ELEMENT_OL, ELEMENT_PARAGRAPH, ELEMENT_UL, TDescendant } from '@udecode/plate';\nimport { ELEMENT_CHECK_ITEM, OL_CLASSES, UL_CLASSES } from '@components/RichTextEditor/Plugins';\nimport { DesignTokens } from '@components/RichTextEditor/types';\nimport { TextStyles } from '@components/RichTextEditor/Plugins/TextStylePlugin/TextStyles';\nimport escapeHtml from 'escape-html';\nimport { reactCssPropsToCss } from './reactCssPropsToCss';\nimport { serializeLeafToHtml } from './serializeLeafToHtml';\n\nexport const serializeNodeToHtmlRecursive = (node: any, designTokens: DesignTokens): string => {\n if (!node.children) {\n return serializeLeafToHtml(node);\n }\n const children = node.children.map((n: TDescendant) => serializeNodeToHtmlRecursive(n, designTokens)).join('');\n\n switch (node.type) {\n case TextStyles.ELEMENT_HEADING1:\n return `<h1 style=\"${reactCssPropsToCss(designTokens.heading1)}\">${children}</h1>`;\n case TextStyles.ELEMENT_HEADING2:\n return `<h2 style=\"${reactCssPropsToCss(designTokens.heading2)}\">${children}</h2>`;\n case TextStyles.ELEMENT_HEADING3:\n return `<h3 style=\"${reactCssPropsToCss(designTokens.heading3)}\">${children}</h3>`;\n case TextStyles.ELEMENT_HEADING4:\n return `<h4 style=\"${reactCssPropsToCss(designTokens.heading4)}\">${children}</h4>`;\n case TextStyles.ELEMENT_CUSTOM1:\n return `<p style=\"${reactCssPropsToCss(designTokens.custom1)}\">${children}</p>`;\n case TextStyles.ELEMENT_CUSTOM2:\n return `<p style=\"${reactCssPropsToCss(designTokens.custom2)}\">${children}</p>`;\n case TextStyles.ELEMENT_CUSTOM3:\n return `<p style=\"${reactCssPropsToCss(designTokens.custom3)}\">${children}</p>`;\n case TextStyles.ELEMENT_QUOTE:\n return `<p style=\"${reactCssPropsToCss(designTokens.quote)}\">${children}</p>`;\n case ELEMENT_PARAGRAPH:\n return `<p>${children}</p>`;\n case ELEMENT_UL:\n return `<ul class=\"${UL_CLASSES}\">${children}</ul>`;\n case ELEMENT_OL:\n return `<ol class=\"${OL_CLASSES}\">${children}</ol>`;\n case ELEMENT_LI:\n return `<li>${children}</li>`;\n case ELEMENT_LINK:\n if (node.chosenLink) {\n const { chosenLink } = node;\n return `<a style=\"${reactCssPropsToCss(designTokens.link)}\" target=${\n chosenLink.openInNewTab ? '_blank' : '_self'\n } href=\"${escapeHtml(chosenLink.searchResult.link)}\">${children}</a>`;\n }\n return `<a style=\"${reactCssPropsToCss(designTokens.link)}\" href=\"${escapeHtml(node.url)}\">${children}</a>`;\n case ELEMENT_CHECK_ITEM:\n return `<input type=\"checkbox\"/><label>${children}</label>`;\n\n default:\n return children;\n }\n};\n"],"names":["escapeHtml"],"mappings":";;;;;;;;;;;;;;;;;AAUa,MAAA,IAA+B,CAAC,GAAW,MAAuC;AACvF,MAAA,CAAC,EAAK;AACN,WAAO,EAAoB,CAAI;AAEnC,QAAM,IAAW,EAAK,SAAS,IAAI,CAAC,MAAmB,EAA6B,GAAG,CAAY,CAAC,EAAE,KAAK,EAAE;AAE7G,UAAQ,EAAK;AAAA,SACJ,EAAW;AACZ,aAAO,cAAc,EAAmB,EAAa,QAAQ,MAAM;AAAA,SAClE,EAAW;AACZ,aAAO,cAAc,EAAmB,EAAa,QAAQ,MAAM;AAAA,SAClE,EAAW;AACZ,aAAO,cAAc,EAAmB,EAAa,QAAQ,MAAM;AAAA,SAClE,EAAW;AACZ,aAAO,cAAc,EAAmB,EAAa,QAAQ,MAAM;AAAA,SAClE,EAAW;AACZ,aAAO,aAAa,EAAmB,EAAa,OAAO,MAAM;AAAA,SAChE,EAAW;AACZ,aAAO,aAAa,EAAmB,EAAa,OAAO,MAAM;AAAA,SAChE,EAAW;AACZ,aAAO,aAAa,EAAmB,EAAa,OAAO,MAAM;AAAA,SAChE,EAAW;AACZ,aAAO,aAAa,EAAmB,EAAa,KAAK,MAAM;AAAA,SAC9D;AACD,aAAO,MAAM;AAAA,SACZ;AACD,aAAO,cAAc,MAAe;AAAA,SACnC;AACD,aAAO,cAAc,MAAe;AAAA,SACnC;AACD,aAAO,OAAO;AAAA,SACb;AACD,UAAI,EAAK,YAAY;AACjB,cAAM,EAAE,kBAAe;AACvB,eAAO,aAAa,EAAmB,EAAa,IAAI,aACpD,EAAW,eAAe,WAAW,iBAC/BA,EAAW,EAAW,aAAa,IAAI,MAAM;AAAA,MAC3D;AACO,aAAA,aAAa,EAAmB,EAAa,IAAI,YAAYA,EAAW,EAAK,GAAG,MAAM;AAAA,SAC5F;AACD,aAAO,kCAAkC;AAAA;AAGlC,aAAA;AAAA;AAEnB;"}
|
|
@@ -20,6 +20,7 @@ export declare type TooltipProps = PropsWithChildren<{
|
|
|
20
20
|
flip?: boolean;
|
|
21
21
|
withArrow?: boolean;
|
|
22
22
|
hoverDelay?: number;
|
|
23
|
+
enterDelay?: number;
|
|
23
24
|
open?: boolean;
|
|
24
25
|
disabled?: boolean;
|
|
25
26
|
hidden?: boolean;
|
|
@@ -35,4 +36,4 @@ export declare enum TooltipAlignment {
|
|
|
35
36
|
Middle = "Middle",
|
|
36
37
|
End = "End"
|
|
37
38
|
}
|
|
38
|
-
export declare const Tooltip: ({ content, tooltipIcon, heading, headingIcon, linkUrl, linkLabel, brightHeader, buttons, children, position, alignment, withArrow, flip, triggerElement, hoverDelay, open, disabled, hidden, }: TooltipProps) => JSX.Element;
|
|
39
|
+
export declare const Tooltip: ({ content, tooltipIcon, heading, headingIcon, linkUrl, linkLabel, brightHeader, buttons, children, position, alignment, withArrow, flip, triggerElement, hoverDelay, enterDelay, open, disabled, hidden, }: TooltipProps) => JSX.Element;
|