@payloadcms/richtext-lexical 3.79.0 → 3.79.1

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 (66) hide show
  1. package/dist/exports/client/bundled.css +1 -1
  2. package/dist/exports/client/index.js +22 -22
  3. package/dist/exports/client/index.js.map +4 -4
  4. package/dist/features/converters/lexicalToHtml/async/converters/heading.d.ts.map +1 -1
  5. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +3 -1
  6. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  7. package/dist/features/converters/lexicalToHtml/async/converters/link.d.ts.map +1 -1
  8. package/dist/features/converters/lexicalToHtml/async/converters/link.js +7 -2
  9. package/dist/features/converters/lexicalToHtml/async/converters/link.js.map +1 -1
  10. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  11. package/dist/features/converters/lexicalToHtml/async/converters/list.js +5 -1
  12. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  13. package/dist/features/converters/lexicalToHtml/async/converters/table.d.ts.map +1 -1
  14. package/dist/features/converters/lexicalToHtml/async/converters/table.js +2 -1
  15. package/dist/features/converters/lexicalToHtml/async/converters/table.js.map +1 -1
  16. package/dist/features/converters/lexicalToHtml/async/converters/text.d.ts.map +1 -1
  17. package/dist/features/converters/lexicalToHtml/async/converters/text.js +2 -1
  18. package/dist/features/converters/lexicalToHtml/async/converters/text.js.map +1 -1
  19. package/dist/features/converters/lexicalToHtml/async/converters/upload.d.ts.map +1 -1
  20. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +11 -10
  21. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  22. package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts +5 -0
  23. package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts.map +1 -0
  24. package/dist/features/converters/lexicalToHtml/shared/cssColors.js +8 -0
  25. package/dist/features/converters/lexicalToHtml/shared/cssColors.js.map +1 -0
  26. package/dist/features/converters/lexicalToHtml/sync/converters/heading.d.ts.map +1 -1
  27. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +3 -1
  28. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  29. package/dist/features/converters/lexicalToHtml/sync/converters/link.d.ts.map +1 -1
  30. package/dist/features/converters/lexicalToHtml/sync/converters/link.js +7 -2
  31. package/dist/features/converters/lexicalToHtml/sync/converters/link.js.map +1 -1
  32. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  33. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +5 -1
  34. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  35. package/dist/features/converters/lexicalToHtml/sync/converters/table.d.ts.map +1 -1
  36. package/dist/features/converters/lexicalToHtml/sync/converters/table.js +2 -1
  37. package/dist/features/converters/lexicalToHtml/sync/converters/table.js.map +1 -1
  38. package/dist/features/converters/lexicalToHtml/sync/converters/text.d.ts.map +1 -1
  39. package/dist/features/converters/lexicalToHtml/sync/converters/text.js +2 -1
  40. package/dist/features/converters/lexicalToHtml/sync/converters/text.js.map +1 -1
  41. package/dist/features/converters/lexicalToHtml/sync/converters/upload.d.ts.map +1 -1
  42. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +11 -10
  43. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  44. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  45. package/dist/features/toolbars/fixed/client/Toolbar/index.js +84 -141
  46. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  47. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  48. package/dist/features/toolbars/inline/client/Toolbar/index.js +46 -101
  49. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  50. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts +3 -1
  51. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  52. package/dist/features/toolbars/shared/ToolbarButton/index.js +38 -111
  53. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  54. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +4 -10
  55. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  56. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +10 -79
  57. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  58. package/dist/features/toolbars/shared/useToolbarStates.d.ts +22 -0
  59. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -0
  60. package/dist/features/toolbars/shared/useToolbarStates.js +127 -0
  61. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -0
  62. package/dist/field/Diff/converters/link.d.ts.map +1 -1
  63. package/dist/field/Diff/converters/link.js +7 -2
  64. package/dist/field/Diff/converters/link.js.map +1 -1
  65. package/dist/field/bundled.css +1 -1
  66. package/package.json +6 -6
@@ -1,3 +1,4 @@
1
+ import escapeHTML from 'escape-html';
1
2
  export const UploadHTMLConverter = {
2
3
  upload: ({
3
4
  node,
@@ -14,20 +15,20 @@ export const UploadHTMLConverter = {
14
15
  if (!uploadDoc) {
15
16
  return '';
16
17
  }
17
- const alt = node.fields?.alt || uploadDoc?.alt || '';
18
- const url = uploadDoc.url;
18
+ const alt = escapeHTML(node.fields?.alt || uploadDoc?.alt || '');
19
+ const url = escapeHTML(uploadDoc.url ?? '');
19
20
  // 1) If upload is NOT an image, return a link
20
21
  if (!uploadDoc.mimeType.startsWith('image')) {
21
- return `<a${providedStyleTag} href="${url}" rel="noopener noreferrer">${uploadDoc.filename}</a$>`;
22
+ return `<a${providedStyleTag} href="${url}" rel="noopener noreferrer">${escapeHTML(uploadDoc.filename ?? '')}</a>`;
22
23
  }
23
24
  // 2) If image has no different sizes, return a simple <img />
24
25
  if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {
25
26
  return `
26
27
  <img${providedStyleTag}
27
28
  alt="${alt}"
28
- height="${uploadDoc.height}"
29
+ height="${escapeHTML(String(uploadDoc.height ?? ''))}"
29
30
  src="${url}"
30
- width="${uploadDoc.width}"
31
+ width="${escapeHTML(String(uploadDoc.width ?? ''))}"
31
32
  />
32
33
  `;
33
34
  }
@@ -40,18 +41,18 @@ export const UploadHTMLConverter = {
40
41
  }
41
42
  pictureHTML += `
42
43
  <source
43
- media="(max-width: ${imageSize.width}px)"
44
- srcset="${imageSize.url}"
45
- type="${imageSize.mimeType}"
44
+ media="(max-width: ${escapeHTML(String(imageSize.width))}px)"
45
+ srcset="${escapeHTML(imageSize.url)}"
46
+ type="${escapeHTML(imageSize.mimeType)}"
46
47
  />
47
48
  `;
48
49
  }
49
50
  pictureHTML += `
50
51
  <img
51
52
  alt="${alt}"
52
- height="${uploadDoc.height}"
53
+ height="${escapeHTML(String(uploadDoc.height ?? ''))}"
53
54
  src="${url}"
54
- width="${uploadDoc.width}"
55
+ width="${escapeHTML(String(uploadDoc.width ?? ''))}"
55
56
  />
56
57
  `;
57
58
  return `<picture${providedStyleTag}>${pictureHTML}</picture>`;
@@ -1 +1 @@
1
- {"version":3,"file":"upload.js","names":["UploadHTMLConverter","upload","node","providedStyleTag","uploadNode","uploadDoc","undefined","value","alt","fields","url","mimeType","startsWith","filename","sizes","Object","keys","length","height","width","pictureHTML","size","imageSize","filesize"],"sources":["../../../../../../src/features/converters/lexicalToHtml/sync/converters/upload.ts"],"sourcesContent":["import type { FileData, FileSizeImproved, TypeWithID } from 'payload'\n\nimport type { SerializedUploadNode } from '../../../../../nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/nodes/UploadNode.js'\nimport type { HTMLConverters } from '../types.js'\n\nexport const UploadHTMLConverter: HTMLConverters<SerializedUploadNode> = {\n upload: ({ node, providedStyleTag }) => {\n const uploadNode = node as UploadDataImproved\n\n let uploadDoc: (FileData & TypeWithID) | undefined = undefined\n\n // If there's no valid upload data, populate return an empty string\n if (typeof uploadNode.value !== 'object') {\n return ''\n } else {\n uploadDoc = uploadNode.value as unknown as FileData & TypeWithID\n }\n\n if (!uploadDoc) {\n return ''\n }\n\n const alt = (node.fields?.alt as string) || (uploadDoc as { alt?: string })?.alt || ''\n\n const url = uploadDoc.url\n\n // 1) If upload is NOT an image, return a link\n if (!uploadDoc.mimeType.startsWith('image')) {\n return `<a${providedStyleTag} href=\"${url}\" rel=\"noopener noreferrer\">${uploadDoc.filename}</a$>`\n }\n\n // 2) If image has no different sizes, return a simple <img />\n if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {\n return `\n <img${providedStyleTag}\n alt=\"${alt}\"\n height=\"${uploadDoc.height}\"\n src=\"${url}\"\n width=\"${uploadDoc.width}\"\n />\n `\n }\n\n // 3) If image has different sizes, build a <picture> element with <source> tags\n let pictureHTML = ''\n\n for (const size in uploadDoc.sizes) {\n const imageSize = uploadDoc.sizes[size] as FileSizeImproved\n\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n\n pictureHTML += `\n <source\n media=\"(max-width: ${imageSize.width}px)\"\n srcset=\"${imageSize.url}\"\n type=\"${imageSize.mimeType}\"\n />\n `\n }\n\n pictureHTML += `\n <img\n alt=\"${alt}\"\n height=\"${uploadDoc.height}\"\n src=\"${url}\"\n width=\"${uploadDoc.width}\"\n />\n `\n\n return `<picture${providedStyleTag}>${pictureHTML}</picture>`\n },\n}\n"],"mappings":"AAMA,OAAO,MAAMA,mBAAA,GAA4D;EACvEC,MAAA,EAAQA,CAAC;IAAEC,IAAI;IAAEC;EAAgB,CAAE;IACjC,MAAMC,UAAA,GAAaF,IAAA;IAEnB,IAAIG,SAAA,GAAiDC,SAAA;IAErD;IACA,IAAI,OAAOF,UAAA,CAAWG,KAAK,KAAK,UAAU;MACxC,OAAO;IACT,OAAO;MACLF,SAAA,GAAYD,UAAA,CAAWG,KAAK;IAC9B;IAEA,IAAI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/D;AACF","ignoreList":[]}
1
+ {"version":3,"file":"upload.js","names":["escapeHTML","UploadHTMLConverter","upload","node","providedStyleTag","uploadNode","uploadDoc","undefined","value","alt","fields","url","mimeType","startsWith","filename","sizes","Object","keys","length","String","height","width","pictureHTML","size","imageSize","filesize"],"sources":["../../../../../../src/features/converters/lexicalToHtml/sync/converters/upload.ts"],"sourcesContent":["import type { FileData, FileSizeImproved, TypeWithID } from 'payload'\n\nimport escapeHTML from 'escape-html'\n\nimport type { SerializedUploadNode } from '../../../../../nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/nodes/UploadNode.js'\nimport type { HTMLConverters } from '../types.js'\n\nexport const UploadHTMLConverter: HTMLConverters<SerializedUploadNode> = {\n upload: ({ node, providedStyleTag }) => {\n const uploadNode = node as UploadDataImproved\n\n let uploadDoc: (FileData & TypeWithID) | undefined = undefined\n\n // If there's no valid upload data, populate return an empty string\n if (typeof uploadNode.value !== 'object') {\n return ''\n } else {\n uploadDoc = uploadNode.value as unknown as FileData & TypeWithID\n }\n\n if (!uploadDoc) {\n return ''\n }\n\n const alt = escapeHTML(\n (node.fields?.alt as string) || (uploadDoc as { alt?: string })?.alt || '',\n )\n\n const url = escapeHTML(uploadDoc.url ?? '')\n\n // 1) If upload is NOT an image, return a link\n if (!uploadDoc.mimeType.startsWith('image')) {\n return `<a${providedStyleTag} href=\"${url}\" rel=\"noopener noreferrer\">${escapeHTML(uploadDoc.filename ?? '')}</a>`\n }\n\n // 2) If image has no different sizes, return a simple <img />\n if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {\n return `\n <img${providedStyleTag}\n alt=\"${alt}\"\n height=\"${escapeHTML(String(uploadDoc.height ?? ''))}\"\n src=\"${url}\"\n width=\"${escapeHTML(String(uploadDoc.width ?? ''))}\"\n />\n `\n }\n\n // 3) If image has different sizes, build a <picture> element with <source> tags\n let pictureHTML = ''\n\n for (const size in uploadDoc.sizes) {\n const imageSize = uploadDoc.sizes[size] as FileSizeImproved\n\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n\n pictureHTML += `\n <source\n media=\"(max-width: ${escapeHTML(String(imageSize.width))}px)\"\n srcset=\"${escapeHTML(imageSize.url)}\"\n type=\"${escapeHTML(imageSize.mimeType)}\"\n />\n `\n }\n\n pictureHTML += `\n <img\n alt=\"${alt}\"\n height=\"${escapeHTML(String(uploadDoc.height ?? ''))}\"\n src=\"${url}\"\n width=\"${escapeHTML(String(uploadDoc.width ?? ''))}\"\n />\n `\n\n return `<picture${providedStyleTag}>${pictureHTML}</picture>`\n },\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AAMvB,OAAO,MAAMC,mBAAA,GAA4D;EACvEC,MAAA,EAAQA,CAAC;IAAEC,IAAI;IAAEC;EAAgB,CAAE;IACjC,MAAMC,UAAA,GAAaF,IAAA;IAEnB,IAAIG,SAAA,GAAiDC,SAAA;IAErD;IACA,IAAI,OAAOF,UAAA,CAAWG,KAAK,KAAK,UAAU;MACxC,OAAO;IACT,OAAO;MACLF,SAAA,GAAYD,UAAA,CAAWG,KAAK;IAC9B;IAEA,IAAI,CAACF,SAAA,EAAW;MACd,OAAO;IACT;IAEA,MAAMG,GAAA,GAAMT,UAAA,CACVG,IAAC,CAAKO,MAAM,EAAED,GAAA,IAAmBH,SAAA,EAAgCG,GAAA,IAAO;IAG1E,MAAME,GAAA,GAAMX,UAAA,CAAWM,SAAA,CAAUK,GAAG,IAAI;IAExC;IACA,IAAI,CAACL,SAAA,CAAUM,QAAQ,CAACC,UAAU,CAAC,UAAU;MAC3C,OAAO,KAAKT,gBAAA,UAA0BO,GAAA,+BAAkCX,UAAA,CAAWM,SAAA,CAAUQ,QAAQ,IAAI,SAAS;IACpH;IAEA;IACA,IAAI,CAACR,SAAA,CAAUS,KAAK,IAAI,CAACC,MAAA,CAAOC,IAAI,CAACX,SAAA,CAAUS,KAAK,EAAEG,MAAM,EAAE;MAC5D,OAAO;cACCd,gBAAA;iBACGK,GAAA;oBACGT,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUc,MAAM,IAAI;iBACzCT,GAAA;mBACEX,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUe,KAAK,IAAI;;OAEjD;IACH;IAEA;IACA,IAAIC,WAAA,GAAc;IAElB,KAAK,MAAMC,IAAA,IAAQjB,SAAA,CAAUS,KAAK,EAAE;MAClC,MAAMS,SAAA,GAAYlB,SAAA,CAAUS,KAAK,CAACQ,IAAA,CAAK;MAEvC,IACE,CAACC,SAAA,IACD,CAACA,SAAA,CAAUH,KAAK,IAChB,CAACG,SAAA,CAAUJ,MAAM,IACjB,CAACI,SAAA,CAAUZ,QAAQ,IACnB,CAACY,SAAA,CAAUC,QAAQ,IACnB,CAACD,SAAA,CAAUV,QAAQ,IACnB,CAACU,SAAA,CAAUb,GAAG,EACd;QACA;MACF;MAEAW,WAAA,IAAe;;+BAEUtB,UAAA,CAAWmB,MAAA,CAAOK,SAAA,CAAUH,KAAK;oBAC5CrB,UAAA,CAAWwB,SAAA,CAAUb,GAAG;kBAC1BX,UAAA,CAAWwB,SAAA,CAAUZ,QAAQ;;OAExC;IACH;IAEAU,WAAA,IAAe;;eAEJb,GAAA;kBACGT,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUc,MAAM,IAAI;eACzCT,GAAA;iBACEX,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUe,KAAK,IAAI;;KAEjD;IAED,OAAO,WAAWjB,gBAAA,IAAoBkB,WAAA,YAAuB;EAC/D;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAIrE,OAAO,cAAc,CAAA;AAuQrB,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAsCxE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAGjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,OAAO,cAAc,CAAA;AA2PrB,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAuCxE,CAAA"}
@@ -10,9 +10,12 @@ import { useMemo } from 'react';
10
10
  import { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js';
11
11
  import { ToolbarButton } from '../../../shared/ToolbarButton/index.js';
12
12
  import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
13
+ import { useToolbarStates } from '../../../shared/useToolbarStates.js';
13
14
  function ButtonGroupItem({
15
+ active,
14
16
  anchorElem,
15
17
  editor,
18
+ enabled,
16
19
  item
17
20
  }) {
18
21
  if (item.Component) {
@@ -26,155 +29,92 @@ function ButtonGroupItem({
26
29
  return null;
27
30
  }
28
31
  return /*#__PURE__*/_jsx(ToolbarButton, {
32
+ active: active,
29
33
  editor: editor,
34
+ enabled: enabled,
30
35
  item: item,
31
36
  children: /*#__PURE__*/_jsx(item.ChildComponent, {})
32
37
  }, item.key);
33
38
  }
34
- function ToolbarGroupComponent(t0) {
35
- const $ = _c(23);
36
- const {
37
- anchorElem,
38
- editor,
39
- editorConfig,
40
- group,
41
- index
42
- } = t0;
39
+ function ToolbarGroupComponent({
40
+ anchorElem,
41
+ editor,
42
+ editorConfig,
43
+ group,
44
+ index,
45
+ toolbarStates
46
+ }) {
43
47
  const {
44
48
  i18n
45
49
  } = useTranslation();
46
50
  const {
47
- fieldProps: t1
51
+ fieldProps: {
52
+ featureClientSchemaMap,
53
+ schemaPath
54
+ }
48
55
  } = useEditorConfigContext();
49
- const {
50
- featureClientSchemaMap,
51
- schemaPath
52
- } = t1;
53
- const [dropdownLabel, setDropdownLabel] = React.useState(undefined);
54
- const [DropdownIcon, setDropdownIcon] = React.useState(undefined);
55
- let t2;
56
- if ($[0] !== group.ChildComponent || $[1] !== group.items || $[2] !== group.type) {
57
- t2 = () => {
58
- if (group?.type === "dropdown" && group.items.length && group.ChildComponent) {
59
- setDropdownIcon(() => group.ChildComponent);
60
- } else {
61
- setDropdownIcon(undefined);
62
- }
63
- };
64
- $[0] = group.ChildComponent;
65
- $[1] = group.items;
66
- $[2] = group.type;
67
- $[3] = t2;
68
- } else {
69
- t2 = $[3];
70
- }
71
- let t3;
72
- if ($[4] !== group) {
73
- t3 = [group];
74
- $[4] = group;
75
- $[5] = t3;
76
- } else {
77
- t3 = $[5];
78
- }
79
- React.useEffect(t2, t3);
80
- let t4;
81
- if ($[6] !== featureClientSchemaMap || $[7] !== group.ChildComponent || $[8] !== group.items || $[9] !== group.type || $[10] !== i18n || $[11] !== schemaPath) {
82
- t4 = t5 => {
83
- const {
84
- activeItems
85
- } = t5;
86
- if (!activeItems.length) {
87
- if (group?.type === "dropdown" && group.items.length && group.ChildComponent) {
88
- setDropdownIcon(() => group.ChildComponent);
89
- setDropdownLabel(undefined);
90
- } else {
91
- setDropdownIcon(undefined);
92
- setDropdownLabel(undefined);
93
- }
94
- return;
95
- }
96
- const item = activeItems[0];
97
- let label = item.key;
98
- if (item.label) {
99
- label = typeof item.label === "function" ? item.label({
100
- featureClientSchemaMap,
101
- i18n,
102
- schemaPath
103
- }) : item.label;
104
- }
105
- if (label.length > 25) {
106
- label = label.substring(0, 25) + "...";
107
- }
108
- if (activeItems.length === 1) {
109
- setDropdownLabel(label);
110
- setDropdownIcon(() => item.ChildComponent);
111
- } else {
112
- setDropdownLabel(i18n.t("lexical:general:toolbarItemsActive", {
113
- count: activeItems.length
114
- }));
115
- if (group?.type === "dropdown" && group.items.length && group.ChildComponent) {
116
- setDropdownIcon(() => group.ChildComponent);
117
- } else {
118
- setDropdownIcon(undefined);
119
- }
120
- }
121
- };
122
- $[6] = featureClientSchemaMap;
123
- $[7] = group.ChildComponent;
124
- $[8] = group.items;
125
- $[9] = group.type;
126
- $[10] = i18n;
127
- $[11] = schemaPath;
128
- $[12] = t4;
129
- } else {
130
- t4 = $[12];
131
- }
132
- const onActiveChange = t4;
133
- const t5 = `fixed-toolbar__group fixed-toolbar__group-${group.key}`;
134
- let t6;
135
- if ($[13] !== DropdownIcon || $[14] !== anchorElem || $[15] !== dropdownLabel || $[16] !== editor || $[17] !== editorConfig.features.toolbarFixed?.groups.length || $[18] !== group || $[19] !== index || $[20] !== onActiveChange || $[21] !== t5) {
136
- t6 = _jsxs("div", {
137
- className: t5,
138
- "data-toolbar-group-key": group.key,
139
- children: [group.type === "dropdown" && group.items.length ? DropdownIcon ? _jsx(ToolbarDropdown, {
140
- anchorElem,
141
- editor,
142
- group,
143
- Icon: DropdownIcon,
144
- itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
145
- label: dropdownLabel,
146
- maxActiveItems: group.maxActiveItems ?? 1,
147
- onActiveChange
148
- }) : _jsx(ToolbarDropdown, {
149
- anchorElem,
150
- editor,
151
- group,
152
- itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
153
- label: dropdownLabel,
154
- maxActiveItems: group.maxActiveItems ?? 1,
155
- onActiveChange
156
- }) : null, group.type === "buttons" && group.items.length ? group.items.map(item_0 => _jsx(ButtonGroupItem, {
157
- anchorElem,
158
- editor,
56
+ const groupState = toolbarStates.groupStates.get(group.key);
57
+ const DropdownIcon = useMemo(() => {
58
+ if (group.type !== 'dropdown') {
59
+ return undefined;
60
+ }
61
+ const activeItem = groupState?.activeItems?.[0];
62
+ if (activeItem) {
63
+ return activeItem.ChildComponent;
64
+ }
65
+ return group.ChildComponent;
66
+ }, [group, groupState?.activeItems]);
67
+ const dropdownLabel = useMemo(() => {
68
+ if (group.type !== 'dropdown') {
69
+ return undefined;
70
+ }
71
+ const activeItems = groupState?.activeItems;
72
+ if (!activeItems?.length) {
73
+ return undefined;
74
+ }
75
+ if (activeItems.length > 1) {
76
+ return i18n.t('lexical:general:toolbarItemsActive', {
77
+ count: activeItems.length
78
+ });
79
+ }
80
+ const item = activeItems[0];
81
+ let label = item.key;
82
+ if (item.label) {
83
+ label = typeof item.label === 'function' ? item.label({
84
+ featureClientSchemaMap,
85
+ i18n,
86
+ schemaPath
87
+ }) : item.label;
88
+ }
89
+ if (label.length > 25) {
90
+ label = label.substring(0, 25) + '...';
91
+ }
92
+ return label;
93
+ }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath]);
94
+ return /*#__PURE__*/_jsxs("div", {
95
+ className: `fixed-toolbar__group fixed-toolbar__group-${group.key}`,
96
+ "data-toolbar-group-key": group.key,
97
+ children: [group.type === 'dropdown' && group.items.length && groupState ? /*#__PURE__*/_jsx(ToolbarDropdown, {
98
+ anchorElem: anchorElem,
99
+ editor: editor,
100
+ group: group,
101
+ groupState: groupState,
102
+ Icon: DropdownIcon,
103
+ itemsContainerClassNames: ['fixed-toolbar__dropdown-items'],
104
+ label: dropdownLabel
105
+ }) : null, group.type === 'buttons' && group.items.length ? group.items.map(item_0 => {
106
+ const itemState = toolbarStates.itemStates.get(item_0.key);
107
+ return /*#__PURE__*/_jsx(ButtonGroupItem, {
108
+ active: itemState?.active ?? false,
109
+ anchorElem: anchorElem,
110
+ editor: editor,
111
+ enabled: itemState?.enabled ?? true,
159
112
  item: item_0
160
- }, item_0.key)) : null, index < editorConfig.features.toolbarFixed?.groups.length - 1 && _jsx("div", {
161
- className: "divider"
162
- })]
163
- }, group.key);
164
- $[13] = DropdownIcon;
165
- $[14] = anchorElem;
166
- $[15] = dropdownLabel;
167
- $[16] = editor;
168
- $[17] = editorConfig.features.toolbarFixed?.groups.length;
169
- $[18] = group;
170
- $[19] = index;
171
- $[20] = onActiveChange;
172
- $[21] = t5;
173
- $[22] = t6;
174
- } else {
175
- t6 = $[22];
176
- }
177
- return t6;
113
+ }, item_0.key);
114
+ }) : null, index < editorConfig.features.toolbarFixed?.groups.length - 1 && /*#__PURE__*/_jsx("div", {
115
+ className: "divider"
116
+ })]
117
+ }, group.key);
178
118
  }
179
119
  function FixedToolbar({
180
120
  anchorElem,
@@ -188,6 +128,7 @@ function FixedToolbar({
188
128
  const {
189
129
  y
190
130
  } = useScrollInfo();
131
+ const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups);
191
132
  // Memoize the parent toolbar element
192
133
  const parentToolbarElem = useMemo(() => {
193
134
  if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {
@@ -246,7 +187,8 @@ function FixedToolbar({
246
187
  editor: editor,
247
188
  editorConfig: editorConfig,
248
189
  group: group,
249
- index: i
190
+ index: i,
191
+ toolbarStates: toolbarStates
250
192
  }, group.key);
251
193
  })
252
194
  })
@@ -282,7 +224,7 @@ export const FixedToolbarPlugin = t0 => {
282
224
  const editorConfig = clientProps.applyToFocusedEditor ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig : currentEditorConfig;
283
225
  let t1;
284
226
  let t2;
285
- if ($[0] !== clientProps.disableIfParentHasFixedToolbar || $[1] !== editor || $[2] !== editorConfig || $[3] !== editorConfigContext) {
227
+ if ($[0] !== clientProps || $[1] !== editor || $[2] !== editorConfig || $[3] !== editorConfigContext) {
286
228
  t2 = Symbol.for("react.early_return_sentinel");
287
229
  bb0: {
288
230
  const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext);
@@ -298,12 +240,13 @@ export const FixedToolbarPlugin = t0 => {
298
240
  }
299
241
  t1 = _jsx(FixedToolbar, {
300
242
  anchorElem: document.body,
243
+ clientProps,
301
244
  editor,
302
245
  editorConfig,
303
246
  parentWithFixedToolbar
304
247
  });
305
248
  }
306
- $[0] = clientProps.disableIfParentHasFixedToolbar;
249
+ $[0] = clientProps;
307
250
  $[1] = editor;
308
251
  $[2] = editorConfig;
309
252
  $[3] = editorConfigContext;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","t0","$","editorConfig","group","index","i18n","fieldProps","t1","featureClientSchemaMap","schemaPath","dropdownLabel","setDropdownLabel","useState","undefined","DropdownIcon","setDropdownIcon","t2","items","type","length","t3","useEffect","t4","t5","activeItems","label","substring","t","count","onActiveChange","t6","features","toolbarFixed","groups","_jsxs","className","children","Icon","itemsContainerClassNames","maxActiveItems","map","item_0","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","onFocus","event","stopPropagation","ref","Fragment","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","Symbol","for","bb0","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport './index.scss'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const [dropdownLabel, setDropdownLabel] = React.useState<string | undefined>(undefined)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | undefined>(undefined)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }, [group])\n\n const onActiveChange = React.useCallback(\n ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n setDropdownLabel(undefined)\n } else {\n setDropdownIcon(undefined)\n setDropdownLabel(undefined)\n }\n return\n }\n const item = activeItems[0]!\n\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n if (activeItems.length === 1) {\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n } else {\n setDropdownLabel(\n i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length }),\n )\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent!)\n } else {\n setDropdownIcon(undefined)\n }\n }\n },\n [group, i18n, featureClientSchemaMap, schemaPath],\n )\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length ? (\n DropdownIcon ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={group.maxActiveItems ?? 1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={group.maxActiveItems ?? 1}\n onActiveChange={onActiveChange}\n />\n )\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {isEditable && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,Y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D,CAAA,QAAAR,MAAA,IAAAQ,CAAA,QAAAC,YAAA,IAAAD,CAAA,QAAAyE,mBAAA;IAMO1D,EAAA,GAAAmE,MAAA,CAAAC,GAAA;IAAAC,GAAA;MAJX,MAAAzC,sBAAA,GAA+B6B,+BAAA,CAAgCC,mBAAA;MAAA,IAE3D/B,WAAA,EAAAO,8BAAA;QAAA,IACEN,sBAAA;UACK5B,EAAA;UAAA,MAAAqE,GAAA;QAAA;MAAA;MAAA,KAINnF,YAAA,EAAA6B,QAAA,EAAAC,YAAA,EAAAC,MAAA,EAAAd,MAAA;QACIH,EAAA;QAAA,MAAAqE,GAAA;MAAA;MAIP9E,EAAA,GAAAX,IAAA,CAAA8C,YAAA;QAAAlD,UAAA,EAAA8F,QAAA,CAAAC,IAAA;QAAA9F,MAAA;QAAAS,YAAA;QAAA0C;MAAA,C;;;;;;;;;;;;;;;SAAArC,E;CAOJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","useToolbarStates","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","toolbarStates","i18n","fieldProps","featureClientSchemaMap","schemaPath","groupState","groupStates","get","DropdownIcon","type","undefined","activeItem","activeItems","dropdownLabel","length","t","count","label","substring","_jsxs","className","items","Icon","itemsContainerClassNames","map","itemState","itemStates","features","toolbarFixed","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","onFocus","event","stopPropagation","ref","Fragment","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","t0","$","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","t1","t2","Symbol","for","bb0","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport './index.scss'\n\nfunction ButtonGroupItem({\n active,\n anchorElem,\n editor,\n enabled,\n item,\n}: {\n active: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled: boolean\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n if (activeItem) {\n return activeItem.ChildComponent\n }\n return group.ChildComponent\n }, [group, groupState?.activeItems])\n\n const dropdownLabel = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItems = groupState?.activeItems\n if (!activeItems?.length) {\n return undefined\n }\n if (activeItems.length > 1) {\n return i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length })\n }\n const item = activeItems[0]!\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n return label\n }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath])\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups)\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {isEditable && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n clientProps={clientProps}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AASxB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AAGjC,SAASC,gBAAgB;EACvBC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,OAAO;EACPC;AAAI,CAOL;EACC,IAAIA,IAAA,CAAKC,SAAS,EAAE;IAClB,OACED,IAAA,EAAMC,SAAA,iBACJC,IAAA,CAACF,IAAA,CAAKC,SAAS;MAACJ,UAAA,EAAYA,UAAA;MAAYC,MAAA,EAAQA,MAAA;MAAQE,IAAA,EAAMA;OAAWA,IAAA,CAAKG,GAAG;EAGvF;EAEA,IAAI,CAACH,IAAA,CAAKI,cAAc,EAAE;IACxB,OAAO;EACT;EAEA,oBACEF,IAAA,CAACV,aAAA;IAAcI,MAAA,EAAQA,MAAA;IAAQE,MAAA,EAAQA,MAAA;IAAQC,OAAA,EAASA,OAAA;IAASC,IAAA,EAAMA,IAAA;cACrE,aAAAE,IAAA,CAACF,IAAA,CAAKI,cAAc;KAD4DJ,IAAA,CAAKG,GAAG;AAI9F;AAEA,SAASE,sBAAsB;EAC7BR,UAAU;EACVC,MAAM;EACNQ,YAAY;EACZC,KAAK;EACLC,KAAK;EACLC;AAAa,CAQd;EACC,MAAM;IAAEC;EAAI,CAAE,GAAGtB,cAAA;EACjB,MAAM;IACJuB,UAAA,EAAY;MAAEC,sBAAsB;MAAEC;IAAU;EAAE,CACnD,GAAGtB,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A,CAAAC,IAAA;QAAAhD,WAAA;QAAA1C,MAAA;QAAAQ,YAAA;QAAAmC;MAAA,C;;;;;;;;;;;;;;;SAAAyC,E;CAQJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/inline/client/Toolbar/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAO3E,OAAO,cAAc,CAAA;AAwXrB,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,SAAS,CAIpE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/inline/client/Toolbar/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAU3E,OAAO,cAAc,CAAA;AA6WrB,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,SAAS,CAIpE,CAAA"}