@uva-glass/component-library 1.52.1 → 1.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{Lexical.prod-zUeT_jIr.js → Lexical.prod-DNRTKPfN.js} +72 -66
  2. package/dist/Lexical.prod-DNRTKPfN.js.map +1 -0
  3. package/dist/{LexicalUtils.prod-DtRifALg.js → LexicalUtils.prod-D_BPEjfg.js} +2 -2
  4. package/dist/{LexicalUtils.prod-DtRifALg.js.map → LexicalUtils.prod-D_BPEjfg.js.map} +1 -1
  5. package/dist/{ListPlugin-CxyYg2bv.js → ListPlugin-CgNBzfIl.js} +4 -4
  6. package/dist/{ListPlugin-CxyYg2bv.js.map → ListPlugin-CgNBzfIl.js.map} +1 -1
  7. package/dist/RteEditor.module-BjGyWKhW.js +26 -0
  8. package/dist/RteEditor.module-BjGyWKhW.js.map +1 -0
  9. package/dist/assets/RteEditor.css +1 -1
  10. package/dist/components/Icon/icons/index.d.ts +9 -0
  11. package/dist/components/Icon/icons/index.js +52 -37
  12. package/dist/components/Icon/icons/index.js.map +1 -1
  13. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +2 -2
  14. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.d.ts +1 -0
  15. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +62 -0
  16. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js.map +1 -0
  17. package/dist/components/RteEditor/Plugins/HistoryPlugin/index.d.ts +1 -0
  18. package/dist/components/RteEditor/Plugins/HistoryPlugin/index.js +5 -0
  19. package/dist/components/RteEditor/Plugins/HistoryPlugin/index.js.map +1 -0
  20. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +3 -3
  21. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  22. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +3 -3
  23. package/dist/components/RteEditor/Plugins/ListPlugin/index.js +1 -1
  24. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +22 -20
  25. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js.map +1 -1
  26. package/dist/components/RteEditor/Plugins/index.d.ts +2 -0
  27. package/dist/components/RteEditor/Plugins/index.js +10 -6
  28. package/dist/components/RteEditor/Plugins/index.js.map +1 -1
  29. package/dist/components/RteEditor/RteEditor.js +567 -462
  30. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  31. package/dist/components/RteEditor/UvaTheme/UvaTheme.js +1 -1
  32. package/dist/{helpers-DpGAANJ8.js → helpers-TSjo3aAv.js} +3 -3
  33. package/dist/{helpers-DpGAANJ8.js.map → helpers-TSjo3aAv.js.map} +1 -1
  34. package/package.json +2 -2
  35. package/dist/Lexical.prod-zUeT_jIr.js.map +0 -1
  36. package/dist/RteEditor.module--4R0Ql6Y.js +0 -26
  37. package/dist/RteEditor.module--4R0Ql6Y.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { u as m, d as n } from "../../../../Lexical.prod-zUeT_jIr.js";
2
+ import { u as m, d as n } from "../../../../Lexical.prod-DNRTKPfN.js";
3
3
  import { c as s } from "../../../../clsx-OuTLNxxd.js";
4
4
  import { Icon as d } from "../../../Icon/Icon.js";
5
- import { s as t } from "../../../../RteEditor.module--4R0Ql6Y.js";
5
+ import { s as t } from "../../../../RteEditor.module-BjGyWKhW.js";
6
6
  const b = {
7
7
  bold: "FormatBold",
8
8
  italic: "FormatItalic"
@@ -0,0 +1 @@
1
+ export declare const HistoryPlugin: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,62 @@
1
+ import { jsxs as b, jsx as r } from "react/jsx-runtime";
2
+ import { c as i } from "../../../../clsx-OuTLNxxd.js";
3
+ import { u as f, $ as _, K as h, h as C, g as U } from "../../../../Lexical.prod-DNRTKPfN.js";
4
+ import { useState as n, useEffect as a } from "react";
5
+ import { Icon as m } from "../../../Icon/Icon.js";
6
+ import "../../../Buttons/Button.js";
7
+ import "../../../Buttons/LinkButton.js";
8
+ import "@react-aria/button";
9
+ import "@react-aria/dialog";
10
+ import "@react-aria/focus";
11
+ import "@react-aria/overlays";
12
+ import "../../../OverlayCloseButton/OverlayCloseButton.js";
13
+ import "../../../GridRow/GridRow.js";
14
+ import "../../../IconButton/IconButton.js";
15
+ import "../../../Input/Input.js";
16
+ import "../../../InputField/InputField.js";
17
+ import "react-router-dom";
18
+ import "../../../../MultiSelect-D1FnMER4.js";
19
+ import { s as t } from "../../../../RteEditor.module-BjGyWKhW.js";
20
+ import "../../../SelectListbox/SelectListbox.js";
21
+ import "../../../SelectListbox/SelectProvider.js";
22
+ const F = () => {
23
+ const [o] = f(), [s, d] = n(!1), [l, p] = n(!1), c = () => {
24
+ o.dispatchCommand(C, void 0);
25
+ }, u = () => {
26
+ o.dispatchCommand(U, void 0);
27
+ };
28
+ return a(() => o.registerCommand(
29
+ _,
30
+ (e) => (d(e), !1),
31
+ 1
32
+ ), [o]), a(() => o.registerCommand(
33
+ h,
34
+ (e) => (p(e), !1),
35
+ 1
36
+ ), [o]), /* @__PURE__ */ b("div", { className: t["editor__toolbar-button-group"], children: [
37
+ /* @__PURE__ */ r(
38
+ "button",
39
+ {
40
+ onClick: c,
41
+ className: i(t["editor__toolbar-button"], t["editor__toolbar-button--undo"]),
42
+ "aria-label": "Undo",
43
+ disabled: !s,
44
+ children: /* @__PURE__ */ r(m, { name: "Undo", size: 20 })
45
+ }
46
+ ),
47
+ /* @__PURE__ */ r(
48
+ "button",
49
+ {
50
+ onClick: u,
51
+ className: i(t["editor__toolbar-button"], t["editor__toolbar-button--redo"]),
52
+ "aria-label": "Undo",
53
+ disabled: !l,
54
+ children: /* @__PURE__ */ r(m, { name: "Redo", size: 20 })
55
+ }
56
+ )
57
+ ] });
58
+ };
59
+ export {
60
+ F as HistoryPlugin
61
+ };
62
+ //# sourceMappingURL=HistoryPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistoryPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { CAN_UNDO_COMMAND, CAN_REDO_COMMAND, UNDO_COMMAND, REDO_COMMAND } from 'lexical';\nimport { useEffect, useState } from 'react';\n\nimport { Icon } from 'components';\nimport styles from 'components/RteEditor/RteEditor.module.css';\n\nexport const HistoryPlugin = () => {\n const [editor] = useLexicalComposerContext();\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n const handleUndo = () => {\n editor.dispatchCommand(UNDO_COMMAND, undefined);\n };\n\n const handleRedo = () => {\n editor.dispatchCommand(REDO_COMMAND, undefined);\n };\n\n useEffect(() => {\n return editor.registerCommand<boolean>(\n CAN_UNDO_COMMAND,\n (payload) => {\n setCanUndo(payload);\n return false;\n },\n 1\n );\n }, [editor]);\n\n useEffect(() => {\n return editor.registerCommand<boolean>(\n CAN_REDO_COMMAND,\n (payload) => {\n setCanRedo(payload);\n return false;\n },\n 1\n );\n }, [editor]);\n\n return (\n <div className={styles['editor__toolbar-button-group']}>\n <button\n onClick={handleUndo}\n className={clsx(styles['editor__toolbar-button'], styles[`editor__toolbar-button--undo`])}\n aria-label={`Undo`}\n disabled={!canUndo}\n >\n <Icon name=\"Undo\" size={20} />\n </button>\n <button\n onClick={handleRedo}\n className={clsx(styles['editor__toolbar-button'], styles[`editor__toolbar-button--redo`])}\n aria-label={`Undo`}\n disabled={!canRedo}\n >\n <Icon name=\"Redo\" size={20} />\n </button>\n </div>\n );\n};\n"],"names":["HistoryPlugin","editor","useLexicalComposerContext","canUndo","setCanUndo","useState","canRedo","setCanRedo","handleUndo","UNDO_COMMAND","handleRedo","REDO_COMMAND","useEffect","CAN_UNDO_COMMAND","payload","CAN_REDO_COMMAND","jsxs","styles","jsx","clsx","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQO,MAAMA,IAAgB,MAAM;AAC3B,QAAA,CAACC,CAAM,IAAIC,KACX,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK,GACtC,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GAEtCG,IAAa,MAAM;AAChB,IAAAP,EAAA,gBAAgBQ,GAAc,MAAS;AAAA,EAAA,GAG1CC,IAAa,MAAM;AAChB,IAAAT,EAAA,gBAAgBU,GAAc,MAAS;AAAA,EAAA;AAGhD,SAAAC,EAAU,MACDX,EAAO;AAAA,IACZY;AAAAA,IACA,CAACC,OACCV,EAAWU,CAAO,GACX;AAAA,IAET;AAAA,EAAA,GAED,CAACb,CAAM,CAAC,GAEXW,EAAU,MACDX,EAAO;AAAA,IACZc;AAAAA,IACA,CAACD,OACCP,EAAWO,CAAO,GACX;AAAA,IAET;AAAA,EAAA,GAED,CAACb,CAAM,CAAC,GAGR,gBAAAe,EAAA,OAAA,EAAI,WAAWC,EAAO,8BAA8B,GACnD,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAASV;AAAA,QACT,WAAWW,EAAKF,EAAO,wBAAwB,GAAGA,EAAO,8BAA8B,CAAC;AAAA,QACxF,cAAY;AAAA,QACZ,UAAU,CAACd;AAAA,QAEX,UAAC,gBAAAe,EAAAE,GAAA,EAAK,MAAK,QAAO,MAAM,IAAI;AAAA,MAAA;AAAA,IAC9B;AAAA,IACA,gBAAAF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAASR;AAAA,QACT,WAAWS,EAAKF,EAAO,wBAAwB,GAAGA,EAAO,8BAA8B,CAAC;AAAA,QACxF,cAAY;AAAA,QACZ,UAAU,CAACX;AAAA,QAEX,UAAC,gBAAAY,EAAAE,GAAA,EAAK,MAAK,QAAO,MAAM,IAAI;AAAA,MAAA;AAAA,IAC9B;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -0,0 +1 @@
1
+ export * from './HistoryPlugin';
@@ -0,0 +1,5 @@
1
+ import { HistoryPlugin as i } from "./HistoryPlugin.js";
2
+ export {
3
+ i as HistoryPlugin
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,7 +1,7 @@
1
1
  import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
- import { u as S } from "../../../../Lexical.prod-zUeT_jIr.js";
2
+ import { u as S } from "../../../../Lexical.prod-DNRTKPfN.js";
3
3
  import { c as _ } from "../../../../clsx-OuTLNxxd.js";
4
- import { U as k, v as E } from "../../../../helpers-DpGAANJ8.js";
4
+ import { U as k, v as E } from "../../../../helpers-TSjo3aAv.js";
5
5
  import { useState as g, useRef as R, useEffect as f } from "react";
6
6
  import { useFlyout as T } from "../../hooks/useFlyout.js";
7
7
  import { Icon as v } from "../../../Icon/Icon.js";
@@ -22,7 +22,7 @@ import "../../../Input/Input.js";
22
22
  import { InputField as z } from "../../../InputField/InputField.js";
23
23
  import "react-router-dom";
24
24
  import "../../../../MultiSelect-D1FnMER4.js";
25
- import { s as t } from "../../../../RteEditor.module--4R0Ql6Y.js";
25
+ import { s as t } from "../../../../RteEditor.module-BjGyWKhW.js";
26
26
  import "../../../SelectListbox/SelectListbox.js";
27
27
  import "../../../SelectListbox/SelectProvider.js";
28
28
  const cr = ({ isLink: o = { active: !1, url: "", target: "_self" } }) => {
@@ -1,4 +1,4 @@
1
- import { M as o, b as r, v as t } from "../../../../helpers-DpGAANJ8.js";
1
+ import { M as o, b as r, v as t } from "../../../../helpers-TSjo3aAv.js";
2
2
  export {
3
3
  o as MATCHERS,
4
4
  r as validateUrl,
@@ -1,10 +1,10 @@
1
1
  import "react/jsx-runtime";
2
- import "../../../../Lexical.prod-zUeT_jIr.js";
3
- import { L as a } from "../../../../ListPlugin-CxyYg2bv.js";
2
+ import "../../../../Lexical.prod-DNRTKPfN.js";
3
+ import { L as a } from "../../../../ListPlugin-CgNBzfIl.js";
4
4
  import "react";
5
5
  import "../../../../clsx-OuTLNxxd.js";
6
6
  import "../../../Icon/Icon.js";
7
- import "../../../../RteEditor.module--4R0Ql6Y.js";
7
+ import "../../../../RteEditor.module-BjGyWKhW.js";
8
8
  export {
9
9
  a as ListPlugin
10
10
  };
@@ -1,4 +1,4 @@
1
- import { L as r } from "../../../../ListPlugin-CxyYg2bv.js";
1
+ import { L as r } from "../../../../ListPlugin-CgNBzfIl.js";
2
2
  export {
3
3
  r as ListPlugin
4
4
  };
@@ -1,11 +1,12 @@
1
- import { jsxs as _, jsx as a } from "react/jsx-runtime";
2
- import { u as I, I as k, m as N } from "../../../../Lexical.prod-zUeT_jIr.js";
3
- import { useState as r, useCallback as P, useEffect as b } from "react";
4
- import { L as B, H as h } from "../../../../ListPlugin-CxyYg2bv.js";
5
- import { g as v } from "../../../../helpers-DpGAANJ8.js";
6
- import { LinkPlugin as x } from "../LinkPlugin/LinkPlugin.js";
7
- import { BlockFormatPlugin as F } from "../BlockFormatPlugin/BlockFormatPlugin.js";
8
- import { s as U } from "../../../../RteEditor.module--4R0Ql6Y.js";
1
+ import { jsxs as _, jsx as l } from "react/jsx-runtime";
2
+ import { u as I, I as P, m as k } from "../../../../Lexical.prod-DNRTKPfN.js";
3
+ import { useState as r, useCallback as N, useEffect as b } from "react";
4
+ import { L as B, H as h } from "../../../../ListPlugin-CgNBzfIl.js";
5
+ import { g as v } from "../../../../helpers-TSjo3aAv.js";
6
+ import { BlockFormatPlugin as x } from "../BlockFormatPlugin/BlockFormatPlugin.js";
7
+ import { LinkPlugin as F } from "../LinkPlugin/LinkPlugin.js";
8
+ import { HistoryPlugin as U } from "../HistoryPlugin/HistoryPlugin.js";
9
+ import { s as j } from "../../../../RteEditor.module-BjGyWKhW.js";
9
10
  const n = (o, s) => {
10
11
  let t = o, i;
11
12
  for (; t !== null; ) {
@@ -16,13 +17,13 @@ const n = (o, s) => {
16
17
  t = t.getParent();
17
18
  }
18
19
  return !1;
19
- }, T = () => {
20
- const [o] = I(), [s, t] = r(!1), [i, c] = r(!1), [m, u] = r(!1), [d, g] = r(!1), [p, L] = r({ active: !1, url: "", target: "_self" }), f = P(() => {
21
- const e = k();
22
- if (N(e)) {
23
- t(e.hasFormat("bold")), c(e.hasFormat("italic"));
24
- const l = e.anchor.getNode();
25
- u(n(l, "ul")), g(n(l, "ol")), L(n(l, "a"));
20
+ }, z = () => {
21
+ const [o] = I(), [s, t] = r(!1), [i, m] = r(!1), [c, u] = r(!1), [g, d] = r(!1), [p, L] = r({ active: !1, url: "", target: "_self" }), f = N(() => {
22
+ const e = P();
23
+ if (k(e)) {
24
+ t(e.hasFormat("bold")), m(e.hasFormat("italic"));
25
+ const a = e.anchor.getNode();
26
+ u(n(a, "ul")), d(n(a, "ol")), L(n(a, "a"));
26
27
  }
27
28
  }, []);
28
29
  return b(() => {
@@ -31,13 +32,14 @@ const n = (o, s) => {
31
32
  f();
32
33
  });
33
34
  });
34
- }, [o, f]), /* @__PURE__ */ _("div", { className: U.editor__toolbar, children: [
35
- /* @__PURE__ */ a(F, { isBold: s, isItalic: i }),
36
- /* @__PURE__ */ a(B, { isUList: m, isOList: d }),
37
- /* @__PURE__ */ a(x, { isLink: p })
35
+ }, [o, f]), /* @__PURE__ */ _("div", { className: j.editor__toolbar, children: [
36
+ /* @__PURE__ */ l(x, { isBold: s, isItalic: i }),
37
+ /* @__PURE__ */ l(B, { isUList: c, isOList: g }),
38
+ /* @__PURE__ */ l(F, { isLink: p }),
39
+ /* @__PURE__ */ l(U, {})
38
40
  ] });
39
41
  };
40
42
  export {
41
- T as ToolBarPlugin
43
+ z as ToolBarPlugin
42
44
  };
43
45
  //# sourceMappingURL=ToolbarPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { $getSelection, $isRangeSelection } from 'lexical';\nimport { useCallback, useEffect, useState } from 'react';\nimport { $isListNode } from '@lexical/list';\nimport { $isLinkNode } from '@lexical/link';\n\nimport type { ElementNode, TextNode } from 'lexical';\n\nimport { LinkPlugin } from 'components/RteEditor/Plugins/LinkPlugin';\nimport { BlockFormatPlugin, ListPlugin } from 'components/RteEditor/Plugins';\nimport styles from 'components/RteEditor/RteEditor.module.css';\n\nexport type TargetType = '_blank' | '_self';\nexport interface LinkType {\n active: boolean;\n url: string;\n target: TargetType | string;\n}\n\nconst getNodeTag = (anchorNode: ElementNode | TextNode, tagToMatch: string): boolean | LinkType => {\n let currentNode: TextNode | ElementNode | null = anchorNode;\n let tag: string | null;\n\n while (currentNode !== null) {\n if (tagToMatch === 'a') {\n if ($isLinkNode(currentNode)) {\n return { active: true, url: currentNode.__url, target: !currentNode.__target ? '_self' : currentNode.__target };\n }\n }\n\n if (tagToMatch === 'ul' || tagToMatch === 'ol') {\n if ($isListNode(currentNode)) {\n tag = currentNode.getTag();\n return tag === tagToMatch;\n }\n }\n\n currentNode = currentNode.getParent();\n }\n\n return false;\n};\n\nexport const ToolBarPlugin = (): JSX.Element => {\n const [editor] = useLexicalComposerContext();\n const [isBold, setIsBold] = useState(false);\n const [isItalic, setIsItalic] = useState(false);\n const [isUList, setIsUList] = useState<boolean>(false);\n const [isOList, setIsOList] = useState<boolean>(false);\n const [isLink, setIsLink] = useState<LinkType>({ active: false, url: '', target: '_self' });\n\n const updateToolbar = useCallback(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n setIsBold(selection.hasFormat('bold'));\n setIsItalic(selection.hasFormat('italic'));\n\n const anchorNode = selection.anchor.getNode();\n setIsUList(getNodeTag(anchorNode, 'ul') as boolean);\n setIsOList(getNodeTag(anchorNode, 'ol') as boolean);\n setIsLink(getNodeTag(anchorNode, 'a') as LinkType);\n }\n }, []);\n\n useEffect(() => {\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateToolbar();\n });\n });\n }, [editor, updateToolbar]);\n\n return (\n <div className={styles['editor__toolbar']}>\n <BlockFormatPlugin isBold={isBold} isItalic={isItalic} />\n <ListPlugin isUList={isUList} isOList={isOList} />\n <LinkPlugin isLink={isLink} />\n </div>\n );\n};\n"],"names":["getNodeTag","anchorNode","tagToMatch","currentNode","tag","$isLinkNode","$isListNode","ToolBarPlugin","editor","useLexicalComposerContext","isBold","setIsBold","useState","isItalic","setIsItalic","isUList","setIsUList","isOList","setIsOList","isLink","setIsLink","updateToolbar","useCallback","selection","$getSelection","$isRangeSelection","useEffect","editorState","jsxs","styles","jsx","BlockFormatPlugin","ListPlugin","LinkPlugin"],"mappings":";;;;;;;;AAmBA,MAAMA,IAAa,CAACC,GAAoCC,MAA2C;AACjG,MAAIC,IAA6CF,GAC7CG;AAEJ,SAAOD,MAAgB,QAAM;AAC3B,QAAID,MAAe,OACbG,EAAYF,CAAW;AACzB,aAAO,EAAE,QAAQ,IAAM,KAAKA,EAAY,OAAO,QAASA,EAAY,WAAqBA,EAAY,WAAtB,QAA+B;AAI9G,SAAAD,MAAe,QAAQA,MAAe,SACpCI,EAAYH,CAAW;AACzB,aAAAC,IAAMD,EAAY,UACXC,MAAQF;AAInB,IAAAC,IAAcA,EAAY;EAC5B;AAEO,SAAA;AACT,GAEaI,IAAgB,MAAmB;AACxC,QAAA,CAACC,CAAM,IAAIC,KACX,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxC,CAACG,GAASC,CAAU,IAAIJ,EAAkB,EAAK,GAC/C,CAACK,GAASC,CAAU,IAAIN,EAAkB,EAAK,GAC/C,CAACO,GAAQC,CAAS,IAAIR,EAAmB,EAAE,QAAQ,IAAO,KAAK,IAAI,QAAQ,QAAS,CAAA,GAEpFS,IAAgBC,EAAY,MAAM;AACtC,UAAMC,IAAYC;AACd,QAAAC,EAAkBF,CAAS,GAAG;AACtB,MAAAZ,EAAAY,EAAU,UAAU,MAAM,CAAC,GACzBT,EAAAS,EAAU,UAAU,QAAQ,CAAC;AAEnC,YAAAtB,IAAasB,EAAU,OAAO,QAAQ;AACjC,MAAAP,EAAAhB,EAAWC,GAAY,IAAI,CAAY,GACvCiB,EAAAlB,EAAWC,GAAY,IAAI,CAAY,GACxCmB,EAAApB,EAAWC,GAAY,GAAG,CAAa;AAAA,IACnD;AAAA,EACF,GAAG,CAAE,CAAA;AAEL,SAAAyB,EAAU,MAAM;AACd,IAAAlB,EAAO,uBAAuB,CAAC,EAAE,aAAAmB,QAAkB;AACjD,MAAAA,EAAY,KAAK,MAAM;AACP,QAAAN;MAAA,CACf;AAAA,IAAA,CACF;AAAA,EAAA,GACA,CAACb,GAAQa,CAAa,CAAC,GAGvB,gBAAAO,EAAA,OAAA,EAAI,WAAWC,EAAO,iBACrB,UAAA;AAAA,IAAC,gBAAAC,EAAAC,GAAA,EAAkB,QAAArB,GAAgB,UAAAG,EAAoB,CAAA;AAAA,IACvD,gBAAAiB,EAACE,GAAW,EAAA,SAAAjB,GAAkB,SAAAE,EAAkB,CAAA;AAAA,IAChD,gBAAAa,EAACG,KAAW,QAAAd,GAAgB;AAAA,EAC9B,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"ToolbarPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { $getSelection, $isRangeSelection } from 'lexical';\nimport { useCallback, useEffect, useState } from 'react';\nimport { $isListNode } from '@lexical/list';\nimport { $isLinkNode } from '@lexical/link';\n\nimport type { ElementNode, TextNode } from 'lexical';\n\nimport { LinkPlugin, BlockFormatPlugin, ListPlugin, HistoryPlugin } from 'components/RteEditor/Plugins';\nimport styles from 'components/RteEditor/RteEditor.module.css';\n\nexport type TargetType = '_blank' | '_self';\nexport interface LinkType {\n active: boolean;\n url: string;\n target: TargetType | string;\n}\n\nconst getNodeTag = (anchorNode: ElementNode | TextNode, tagToMatch: string): boolean | LinkType => {\n let currentNode: TextNode | ElementNode | null = anchorNode;\n let tag: string | null;\n\n while (currentNode !== null) {\n if (tagToMatch === 'a') {\n if ($isLinkNode(currentNode)) {\n return { active: true, url: currentNode.__url, target: !currentNode.__target ? '_self' : currentNode.__target };\n }\n }\n\n if (tagToMatch === 'ul' || tagToMatch === 'ol') {\n if ($isListNode(currentNode)) {\n tag = currentNode.getTag();\n return tag === tagToMatch;\n }\n }\n\n currentNode = currentNode.getParent();\n }\n\n return false;\n};\n\nexport const ToolBarPlugin = (): JSX.Element => {\n const [editor] = useLexicalComposerContext();\n const [isBold, setIsBold] = useState(false);\n const [isItalic, setIsItalic] = useState(false);\n const [isUList, setIsUList] = useState<boolean>(false);\n const [isOList, setIsOList] = useState<boolean>(false);\n const [isLink, setIsLink] = useState<LinkType>({ active: false, url: '', target: '_self' });\n\n const updateToolbar = useCallback(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n setIsBold(selection.hasFormat('bold'));\n setIsItalic(selection.hasFormat('italic'));\n\n const anchorNode = selection.anchor.getNode();\n setIsUList(getNodeTag(anchorNode, 'ul') as boolean);\n setIsOList(getNodeTag(anchorNode, 'ol') as boolean);\n setIsLink(getNodeTag(anchorNode, 'a') as LinkType);\n }\n }, []);\n\n useEffect(() => {\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateToolbar();\n });\n });\n }, [editor, updateToolbar]);\n\n return (\n <div className={styles['editor__toolbar']}>\n <BlockFormatPlugin isBold={isBold} isItalic={isItalic} />\n <ListPlugin isUList={isUList} isOList={isOList} />\n <LinkPlugin isLink={isLink} />\n <HistoryPlugin />\n </div>\n );\n};\n"],"names":["getNodeTag","anchorNode","tagToMatch","currentNode","tag","$isLinkNode","$isListNode","ToolBarPlugin","editor","useLexicalComposerContext","isBold","setIsBold","useState","isItalic","setIsItalic","isUList","setIsUList","isOList","setIsOList","isLink","setIsLink","updateToolbar","useCallback","selection","$getSelection","$isRangeSelection","useEffect","editorState","jsxs","styles","jsx","BlockFormatPlugin","ListPlugin","LinkPlugin","HistoryPlugin"],"mappings":";;;;;;;;;AAkBA,MAAMA,IAAa,CAACC,GAAoCC,MAA2C;AACjG,MAAIC,IAA6CF,GAC7CG;AAEJ,SAAOD,MAAgB,QAAM;AAC3B,QAAID,MAAe,OACbG,EAAYF,CAAW;AACzB,aAAO,EAAE,QAAQ,IAAM,KAAKA,EAAY,OAAO,QAASA,EAAY,WAAqBA,EAAY,WAAtB,QAA+B;AAI9G,SAAAD,MAAe,QAAQA,MAAe,SACpCI,EAAYH,CAAW;AACzB,aAAAC,IAAMD,EAAY,UACXC,MAAQF;AAInB,IAAAC,IAAcA,EAAY;EAC5B;AAEO,SAAA;AACT,GAEaI,IAAgB,MAAmB;AACxC,QAAA,CAACC,CAAM,IAAIC,KACX,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxC,CAACG,GAASC,CAAU,IAAIJ,EAAkB,EAAK,GAC/C,CAACK,GAASC,CAAU,IAAIN,EAAkB,EAAK,GAC/C,CAACO,GAAQC,CAAS,IAAIR,EAAmB,EAAE,QAAQ,IAAO,KAAK,IAAI,QAAQ,QAAS,CAAA,GAEpFS,IAAgBC,EAAY,MAAM;AACtC,UAAMC,IAAYC;AACd,QAAAC,EAAkBF,CAAS,GAAG;AACtB,MAAAZ,EAAAY,EAAU,UAAU,MAAM,CAAC,GACzBT,EAAAS,EAAU,UAAU,QAAQ,CAAC;AAEnC,YAAAtB,IAAasB,EAAU,OAAO,QAAQ;AACjC,MAAAP,EAAAhB,EAAWC,GAAY,IAAI,CAAY,GACvCiB,EAAAlB,EAAWC,GAAY,IAAI,CAAY,GACxCmB,EAAApB,EAAWC,GAAY,GAAG,CAAa;AAAA,IACnD;AAAA,EACF,GAAG,CAAE,CAAA;AAEL,SAAAyB,EAAU,MAAM;AACd,IAAAlB,EAAO,uBAAuB,CAAC,EAAE,aAAAmB,QAAkB;AACjD,MAAAA,EAAY,KAAK,MAAM;AACP,QAAAN;MAAA,CACf;AAAA,IAAA,CACF;AAAA,EAAA,GACA,CAACb,GAAQa,CAAa,CAAC,GAGvB,gBAAAO,EAAA,OAAA,EAAI,WAAWC,EAAO,iBACrB,UAAA;AAAA,IAAC,gBAAAC,EAAAC,GAAA,EAAkB,QAAArB,GAAgB,UAAAG,EAAoB,CAAA;AAAA,IACvD,gBAAAiB,EAACE,GAAW,EAAA,SAAAjB,GAAkB,SAAAE,EAAkB,CAAA;AAAA,IAChD,gBAAAa,EAACG,KAAW,QAAAd,GAAgB;AAAA,sBAC3Be,GAAc,EAAA;AAAA,EACjB,EAAA,CAAA;AAEJ;"}
@@ -1,3 +1,5 @@
1
1
  export * from './ToolbarPlugin';
2
2
  export * from './BlockFormatPlugin';
3
3
  export * from './ListPlugin';
4
+ export * from './LinkPlugin';
5
+ export * from './HistoryPlugin';
@@ -1,9 +1,13 @@
1
- import { ToolBarPlugin as l } from "./ToolbarPlugin/ToolbarPlugin.js";
2
- import { BlockFormatPlugin as i } from "./BlockFormatPlugin/BlockFormatPlugin.js";
3
- import { L as a } from "../../../ListPlugin-CxyYg2bv.js";
1
+ import { ToolBarPlugin as i } from "./ToolbarPlugin/ToolbarPlugin.js";
2
+ import { BlockFormatPlugin as l } from "./BlockFormatPlugin/BlockFormatPlugin.js";
3
+ import { L as n } from "../../../ListPlugin-CgNBzfIl.js";
4
+ import { LinkPlugin as f } from "./LinkPlugin/LinkPlugin.js";
5
+ import { HistoryPlugin as p } from "./HistoryPlugin/HistoryPlugin.js";
4
6
  export {
5
- i as BlockFormatPlugin,
6
- a as ListPlugin,
7
- l as ToolBarPlugin
7
+ l as BlockFormatPlugin,
8
+ p as HistoryPlugin,
9
+ f as LinkPlugin,
10
+ n as ListPlugin,
11
+ i as ToolBarPlugin
8
12
  };
9
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}