@payloadcms/richtext-lexical 4.0.0-internal.a7ca468 → 4.0.0-internal.af6aad0

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.
@@ -0,0 +1,8 @@
1
+ export declare function getHorizontalScrollDelta({ clientWidth, deltaMode, deltaY, isRightToLeft, }: {
2
+ clientWidth: number;
3
+ deltaMode: number;
4
+ deltaY: number;
5
+ isRightToLeft: boolean;
6
+ }): number;
7
+ export declare function useRedirectVerticalWheelToHorizontalScroll(): void;
8
+ //# sourceMappingURL=horizontalWheelScroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"horizontalWheelScroll.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.ts"],"names":[],"mappings":"AASA,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,SAAS,EACT,MAAM,EACN,aAAa,GACd,EAAE;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,OAAO,CAAA;CACvB,GAAG,MAAM,CAOT;AA0CD,wBAAgB,0CAA0C,IAAI,IAAI,CAgBjE"}
@@ -0,0 +1,80 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { useEffect } from 'react';
5
+ const scrollContainerSelector = '.fixed-toolbar__scroll';
6
+ // A single notch on a classic (non-trackpad) wheel mouse reports deltaMode 1 with a
7
+ // deltaY of only 1-3, so it must be scaled up to a pixel value that actually moves the scroll.
8
+ const PIXELS_PER_LINE = 40;
9
+ export function getHorizontalScrollDelta({
10
+ clientWidth,
11
+ deltaMode,
12
+ deltaY,
13
+ isRightToLeft
14
+ }) {
15
+ const deltaInPixels = deltaMode === 1 ? deltaY * PIXELS_PER_LINE : deltaMode === 2 ? deltaY * clientWidth : deltaY;
16
+ // scrollLeft moves toward the inline-start edge for a given positive delta in RTL,
17
+ // the opposite of LTR, so the delta must be negated to keep the scroll direction consistent.
18
+ return isRightToLeft ? -deltaInPixels : deltaInPixels;
19
+ }
20
+ function redirectVerticalWheelToHorizontalScroll(event) {
21
+ const isPrimarilyVerticalWheelInput = Math.abs(event.deltaY) > Math.abs(event.deltaX);
22
+ if (!isPrimarilyVerticalWheelInput) {
23
+ return;
24
+ }
25
+ const target = event.target;
26
+ if (!(target instanceof Element)) {
27
+ return;
28
+ }
29
+ const scrollContainer = target.closest(scrollContainerSelector);
30
+ if (!scrollContainer) {
31
+ return;
32
+ }
33
+ const canScrollHorizontally = scrollContainer.scrollWidth > scrollContainer.clientWidth;
34
+ if (!canScrollHorizontally) {
35
+ return;
36
+ }
37
+ event.preventDefault();
38
+ scrollContainer.scrollLeft += getHorizontalScrollDelta({
39
+ clientWidth: scrollContainer.clientWidth,
40
+ deltaMode: event.deltaMode,
41
+ deltaY: event.deltaY,
42
+ isRightToLeft: getComputedStyle(scrollContainer).direction === 'rtl'
43
+ });
44
+ }
45
+ // A single page can render many fixed toolbars at once (e.g. rich text nested several
46
+ // layers deep inside blocks), so this listener is delegated to `document` and shared
47
+ // across every toolbar instance instead of being attached per instance. A wheel listener
48
+ // that can call preventDefault() must be non-passive, and non-passive listeners make the
49
+ // browser treat their element as a "non-fast-scrollable region" that every scroll gesture
50
+ // on the page has to be checked against, even ones nowhere near it. Attaching one instance
51
+ // per toolbar would multiply that bookkeeping by however many toolbars happen to be on the
52
+ // page; a single delegated listener keeps that cost constant no matter how many there are.
53
+ let toolbarsListeningForWheelEvents = 0;
54
+ export function useRedirectVerticalWheelToHorizontalScroll() {
55
+ const $ = _c(1);
56
+ let t0;
57
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
58
+ t0 = [];
59
+ $[0] = t0;
60
+ } else {
61
+ t0 = $[0];
62
+ }
63
+ useEffect(_temp2, t0);
64
+ }
65
+ function _temp2() {
66
+ if (toolbarsListeningForWheelEvents === 0) {
67
+ document.addEventListener("wheel", redirectVerticalWheelToHorizontalScroll, {
68
+ passive: false
69
+ });
70
+ }
71
+ toolbarsListeningForWheelEvents = toolbarsListeningForWheelEvents + 1;
72
+ return _temp;
73
+ }
74
+ function _temp() {
75
+ toolbarsListeningForWheelEvents = toolbarsListeningForWheelEvents - 1;
76
+ if (toolbarsListeningForWheelEvents === 0) {
77
+ document.removeEventListener("wheel", redirectVerticalWheelToHorizontalScroll);
78
+ }
79
+ }
80
+ //# sourceMappingURL=horizontalWheelScroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"horizontalWheelScroll.js","names":["c","_c","useEffect","scrollContainerSelector","PIXELS_PER_LINE","getHorizontalScrollDelta","clientWidth","deltaMode","deltaY","isRightToLeft","deltaInPixels","redirectVerticalWheelToHorizontalScroll","event","isPrimarilyVerticalWheelInput","Math","abs","deltaX","target","Element","scrollContainer","closest","canScrollHorizontally","scrollWidth","preventDefault","scrollLeft","getComputedStyle","direction","toolbarsListeningForWheelEvents","useRedirectVerticalWheelToHorizontalScroll","$","t0","Symbol","for","_temp2","document","addEventListener","passive","_temp","removeEventListener"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.ts"],"sourcesContent":["'use client'\nimport { useEffect } from 'react'\n\nconst scrollContainerSelector = '.fixed-toolbar__scroll'\n\n// A single notch on a classic (non-trackpad) wheel mouse reports deltaMode 1 with a\n// deltaY of only 1-3, so it must be scaled up to a pixel value that actually moves the scroll.\nconst PIXELS_PER_LINE = 40\n\nexport function getHorizontalScrollDelta({\n clientWidth,\n deltaMode,\n deltaY,\n isRightToLeft,\n}: {\n clientWidth: number\n deltaMode: number\n deltaY: number\n isRightToLeft: boolean\n}): number {\n const deltaInPixels =\n deltaMode === 1 ? deltaY * PIXELS_PER_LINE : deltaMode === 2 ? deltaY * clientWidth : deltaY\n\n // scrollLeft moves toward the inline-start edge for a given positive delta in RTL,\n // the opposite of LTR, so the delta must be negated to keep the scroll direction consistent.\n return isRightToLeft ? -deltaInPixels : deltaInPixels\n}\n\nfunction redirectVerticalWheelToHorizontalScroll(event: WheelEvent): void {\n const isPrimarilyVerticalWheelInput = Math.abs(event.deltaY) > Math.abs(event.deltaX)\n if (!isPrimarilyVerticalWheelInput) {\n return\n }\n\n const target = event.target\n if (!(target instanceof Element)) {\n return\n }\n\n const scrollContainer = target.closest<HTMLElement>(scrollContainerSelector)\n if (!scrollContainer) {\n return\n }\n\n const canScrollHorizontally = scrollContainer.scrollWidth > scrollContainer.clientWidth\n if (!canScrollHorizontally) {\n return\n }\n\n event.preventDefault()\n scrollContainer.scrollLeft += getHorizontalScrollDelta({\n clientWidth: scrollContainer.clientWidth,\n deltaMode: event.deltaMode,\n deltaY: event.deltaY,\n isRightToLeft: getComputedStyle(scrollContainer).direction === 'rtl',\n })\n}\n\n// A single page can render many fixed toolbars at once (e.g. rich text nested several\n// layers deep inside blocks), so this listener is delegated to `document` and shared\n// across every toolbar instance instead of being attached per instance. A wheel listener\n// that can call preventDefault() must be non-passive, and non-passive listeners make the\n// browser treat their element as a \"non-fast-scrollable region\" that every scroll gesture\n// on the page has to be checked against, even ones nowhere near it. Attaching one instance\n// per toolbar would multiply that bookkeeping by however many toolbars happen to be on the\n// page; a single delegated listener keeps that cost constant no matter how many there are.\nlet toolbarsListeningForWheelEvents = 0\n\nexport function useRedirectVerticalWheelToHorizontalScroll(): void {\n useEffect(() => {\n if (toolbarsListeningForWheelEvents === 0) {\n document.addEventListener('wheel', redirectVerticalWheelToHorizontalScroll, {\n passive: false,\n })\n }\n toolbarsListeningForWheelEvents += 1\n\n return () => {\n toolbarsListeningForWheelEvents -= 1\n if (toolbarsListeningForWheelEvents === 0) {\n document.removeEventListener('wheel', redirectVerticalWheelToHorizontalScroll)\n }\n }\n }, [])\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,SAAS,QAAQ;AAE1B,MAAMC,uBAAA,GAA0B;AAEhC;AACA;AACA,MAAMC,eAAA,GAA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AAD,CAAA,QAAAE,MAAA,CAAAC,GAAA;IAeFF,EAAA;IAAED,CAAA,MAAAC,EAAA;EAAA;IAAAA,EAAA,GAAAD,CAAA;EAAA;EAdL3B,SAAA,CAAA+B,MAAA,EAcGH,EAAE;AAAA;AAfA,SAAAG,OAAA;EAAA,IAECN,+BAAA,MAAoC;IACtCO,QAAA,CAAAC,gBAAA,CAA0B,SAAAxB,uCAAA;MAAAyB,OAAA;IAAA,CAE1B;EAAA;EAAAT,+BAAA,GAEFA,+BAAA,IAAmC;EAAA,OAAAU,KAAA;AAAA;AAPhC,SAAAA,MAAA;EAAAV,+BAAA,GAUDA,+BAAA,IAAmC;EAAA,IAC/BA,+BAAA,MAAoC;IACtCO,QAAA,CAAAI,mBAAA,CAA6B,SAAA3B,uCAAS;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,65 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getHorizontalScrollDelta } from './horizontalWheelScroll.js';
3
+ describe('getHorizontalScrollDelta', () => {
4
+ describe('deltaMode 0 (pixel)', () => {
5
+ it('should pass deltaY through unchanged for LTR', () => {
6
+ const delta = getHorizontalScrollDelta({
7
+ clientWidth: 300,
8
+ deltaMode: 0,
9
+ deltaY: 15,
10
+ isRightToLeft: false
11
+ });
12
+ expect(delta).toBe(15);
13
+ });
14
+ it('should negate deltaY for RTL', () => {
15
+ const delta = getHorizontalScrollDelta({
16
+ clientWidth: 300,
17
+ deltaMode: 0,
18
+ deltaY: 15,
19
+ isRightToLeft: true
20
+ });
21
+ expect(delta).toBe(-15);
22
+ });
23
+ });
24
+ describe('deltaMode 1 (line)', () => {
25
+ it('should scale deltaY by the pixels-per-line factor for LTR', () => {
26
+ const delta = getHorizontalScrollDelta({
27
+ clientWidth: 300,
28
+ deltaMode: 1,
29
+ deltaY: 3,
30
+ isRightToLeft: false
31
+ });
32
+ expect(delta).toBe(120);
33
+ });
34
+ it('should scale and negate deltaY for RTL', () => {
35
+ const delta = getHorizontalScrollDelta({
36
+ clientWidth: 300,
37
+ deltaMode: 1,
38
+ deltaY: 3,
39
+ isRightToLeft: true
40
+ });
41
+ expect(delta).toBe(-120);
42
+ });
43
+ });
44
+ describe('deltaMode 2 (page)', () => {
45
+ it('should scale deltaY by the scroll container width for LTR', () => {
46
+ const delta = getHorizontalScrollDelta({
47
+ clientWidth: 300,
48
+ deltaMode: 2,
49
+ deltaY: 2,
50
+ isRightToLeft: false
51
+ });
52
+ expect(delta).toBe(600);
53
+ });
54
+ it('should scale and negate deltaY for RTL', () => {
55
+ const delta = getHorizontalScrollDelta({
56
+ clientWidth: 300,
57
+ deltaMode: 2,
58
+ deltaY: 2,
59
+ isRightToLeft: true
60
+ });
61
+ expect(delta).toBe(-600);
62
+ });
63
+ });
64
+ });
65
+ //# sourceMappingURL=horizontalWheelScroll.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"horizontalWheelScroll.spec.js","names":["describe","expect","it","getHorizontalScrollDelta","delta","clientWidth","deltaMode","deltaY","isRightToLeft","toBe"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { getHorizontalScrollDelta } from './horizontalWheelScroll.js'\n\ndescribe('getHorizontalScrollDelta', () => {\n describe('deltaMode 0 (pixel)', () => {\n it('should pass deltaY through unchanged for LTR', () => {\n const delta = getHorizontalScrollDelta({\n clientWidth: 300,\n deltaMode: 0,\n deltaY: 15,\n isRightToLeft: false,\n })\n\n expect(delta).toBe(15)\n })\n\n it('should negate deltaY for RTL', () => {\n const delta = getHorizontalScrollDelta({\n clientWidth: 300,\n deltaMode: 0,\n deltaY: 15,\n isRightToLeft: true,\n })\n\n expect(delta).toBe(-15)\n })\n })\n\n describe('deltaMode 1 (line)', () => {\n it('should scale deltaY by the pixels-per-line factor for LTR', () => {\n const delta = getHorizontalScrollDelta({\n clientWidth: 300,\n deltaMode: 1,\n deltaY: 3,\n isRightToLeft: false,\n })\n\n expect(delta).toBe(120)\n })\n\n it('should scale and negate deltaY for RTL', () => {\n const delta = getHorizontalScrollDelta({\n clientWidth: 300,\n deltaMode: 1,\n deltaY: 3,\n isRightToLeft: true,\n })\n\n expect(delta).toBe(-120)\n })\n })\n\n describe('deltaMode 2 (page)', () => {\n it('should scale deltaY by the scroll container width for LTR', () => {\n const delta = getHorizontalScrollDelta({\n clientWidth: 300,\n deltaMode: 2,\n deltaY: 2,\n isRightToLeft: false,\n })\n\n expect(delta).toBe(600)\n })\n\n it('should scale and negate deltaY for RTL', () => {\n const delta = getHorizontalScrollDelta({\n clientWidth: 300,\n deltaMode: 2,\n deltaY: 2,\n isRightToLeft: true,\n })\n\n expect(delta).toBe(-600)\n })\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,wBAAwB,QAAQ;AAEzCH,QAAA,CAAS,4BAA4B;EACnCA,QAAA,CAAS,uBAAuB;IAC9BE,EAAA,CAAG,gDAAgD;MACjD,MAAME,KAAA,GAAQD,wBAAA,CAAyB;QACrCE,WAAA,EAAa;QACbC,SAAA,EAAW;QACXC,MAAA,EAAQ;QACRC,aAAA,EAAe;MACjB;MAEAP,MAAA,CAAOG,KAAA,EAAOK,IAAI,CAAC;IACrB;IAEAP,EAAA,CAAG,gCAAgC;MACjC,MAAME,KAAA,GAAQD,wBAAA,CAAyB;QACrCE,WAAA,EAAa;QACbC,SAAA,EAAW;QACXC,MAAA,EAAQ;QACRC,aAAA,EAAe;MACjB;MAEAP,MAAA,CAAOG,KAAA,EAAOK,IAAI,CAAC,CAAC;IACtB;EACF;EAEAT,QAAA,CAAS,sBAAsB;IAC7BE,EAAA,CAAG,6DAA6D;MAC9D,MAAME,KAAA,GAAQD,wBAAA,CAAyB;QACrCE,WAAA,EAAa;QACbC,SAAA,EAAW;QACXC,MAAA,EAAQ;QACRC,aAAA,EAAe;MACjB;MAEAP,MAAA,CAAOG,KAAA,EAAOK,IAAI,CAAC;IACrB;IAEAP,EAAA,CAAG,0CAA0C;MAC3C,MAAME,KAAA,GAAQD,wBAAA,CAAyB;QACrCE,WAAA,EAAa;QACbC,SAAA,EAAW;QACXC,MAAA,EAAQ;QACRC,aAAA,EAAe;MACjB;MAEAP,MAAA,CAAOG,KAAA,EAAOK,IAAI,CAAC,CAAC;IACtB;EACF;EAEAT,QAAA,CAAS,sBAAsB;IAC7BE,EAAA,CAAG,6DAA6D;MAC9D,MAAME,KAAA,GAAQD,wBAAA,CAAyB;QACrCE,WAAA,EAAa;QACbC,SAAA,EAAW;QACXC,MAAA,EAAQ;QACRC,aAAA,EAAe;MACjB;MAEAP,MAAA,CAAOG,KAAA,EAAOK,IAAI,CAAC;IACrB;IAEAP,EAAA,CAAG,0CAA0C;MAC3C,MAAME,KAAA,GAAQD,wBAAA,CAAyB;QACrCE,WAAA,EAAa;QACbC,SAAA,EAAW;QACXC,MAAA,EAAQ;QACRC,aAAA,EAAe;MACjB;MAEAP,MAAA,CAAOG,KAAA,EAAOK,IAAI,CAAC,CAAC;IACtB;EACF;AACF","ignoreList":[]}
@@ -1,3 +1,37 @@
1
+ @property --fixed-toolbar-fade-start {
2
+ syntax: '<length>';
3
+ inherits: false;
4
+ initial-value: 0px;
5
+ }
6
+
7
+ @property --fixed-toolbar-fade-end {
8
+ syntax: '<length>';
9
+ inherits: false;
10
+ initial-value: 0px;
11
+ }
12
+
13
+ /*
14
+ * Drives the fade widths off the toolbar's own scroll position: fully opaque at rest,
15
+ * fading in on whichever edge still has scrolled-off content once it overflows.
16
+ * Unsupported browsers (no animation-timeline) simply keep the initial 0px fade, i.e. no fade at all.
17
+ */
18
+ @keyframes fixed-toolbar-scroll-fade {
19
+ 0% {
20
+ --fixed-toolbar-fade-start: 0px;
21
+ }
22
+ 10%,
23
+ 100% {
24
+ --fixed-toolbar-fade-start: var(--spacer-5);
25
+ }
26
+ 0%,
27
+ 90% {
28
+ --fixed-toolbar-fade-end: var(--spacer-5);
29
+ }
30
+ 100% {
31
+ --fixed-toolbar-fade-end: 0px;
32
+ }
33
+ }
34
+
1
35
  @layer payload-default {
2
36
  .fixed-toolbar.fixed-toolbar--hide {
3
37
  visibility: hidden;
@@ -7,10 +41,8 @@
7
41
 
8
42
  .fixed-toolbar {
9
43
  display: flex;
10
- flex-wrap: wrap;
11
44
  align-items: center;
12
45
  padding: 0 var(--spacer-2);
13
- gap: var(--spacer-2);
14
46
  vertical-align: middle;
15
47
  position: sticky;
16
48
  z-index: 2;
@@ -55,13 +87,55 @@
55
87
  }
56
88
  }
57
89
 
90
+ .fixed-toolbar__scroll {
91
+ display: flex;
92
+ flex: 1 1 auto;
93
+ flex-wrap: nowrap;
94
+ align-items: center;
95
+ gap: var(--spacer-2);
96
+ min-width: 0;
97
+ overflow-x: auto;
98
+ scrollbar-width: none;
99
+ -ms-overflow-style: none;
100
+ position: relative;
101
+ z-index: 1;
102
+ animation: fixed-toolbar-scroll-fade linear;
103
+ animation-timeline: scroll(self inline);
104
+ mask: linear-gradient(
105
+ to right,
106
+ transparent,
107
+ black var(--fixed-toolbar-fade-start),
108
+ black calc(100% - var(--fixed-toolbar-fade-end)),
109
+ transparent
110
+ );
111
+
112
+ &::-webkit-scrollbar {
113
+ display: none;
114
+ }
115
+ }
116
+
117
+ [dir='rtl'] .fixed-toolbar__scroll {
118
+ mask: linear-gradient(
119
+ to left,
120
+ transparent,
121
+ black var(--fixed-toolbar-fade-start),
122
+ black calc(100% - var(--fixed-toolbar-fade-end)),
123
+ transparent
124
+ );
125
+ }
126
+
58
127
  .fixed-toolbar__group {
59
128
  display: flex;
60
- flex-wrap: wrap;
129
+ flex-wrap: nowrap;
61
130
  align-items: center;
62
131
  gap: var(--spacer-2);
63
132
  align-self: stretch;
64
133
  z-index: 1;
134
+ flex-shrink: 0;
135
+
136
+ > * {
137
+ flex-shrink: 0;
138
+ }
65
139
 
66
140
  .divider {
67
141
  width: var(--stroke-width-small);
@@ -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;AAGjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,OAAO,aAAa,CAAA;AA2PpB,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAuCxE,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;AAOrE,OAAO,aAAa,CAAA;AA6PpB,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAuCxE,CAAA"}
@@ -11,6 +11,7 @@ import { useEditorConfigContext } from '../../../../../lexical/config/client/Edi
11
11
  import { ToolbarButton } from '../../../shared/ToolbarButton/index.js';
12
12
  import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
13
13
  import { useToolbarStates } from '../../../shared/useToolbarStates.js';
14
+ import { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js';
14
15
  import './index.css';
15
16
  function ButtonGroupItem({
16
17
  active,
@@ -129,6 +130,7 @@ function FixedToolbar({
129
130
  const {
130
131
  y
131
132
  } = useScrollInfo();
133
+ useRedirectVerticalWheelToHorizontalScroll();
132
134
  const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups);
133
135
  // Memoize the parent toolbar element
134
136
  const parentToolbarElem = useMemo(() => {
@@ -181,7 +183,8 @@ function FixedToolbar({
181
183
  event.stopPropagation();
182
184
  },
183
185
  ref: currentToolbarRef,
184
- children: isEditable && /*#__PURE__*/_jsx(React.Fragment, {
186
+ children: isEditable && /*#__PURE__*/_jsx("div", {
187
+ className: "fixed-toolbar__scroll",
185
188
  children: editorConfig?.features && editorConfig.features?.toolbarFixed?.groups.map((group, i) => {
186
189
  return /*#__PURE__*/_jsx(ToolbarGroupComponent, {
187
190
  anchorElem: anchorElem,
@@ -1 +1 @@
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.css'\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;AA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;IAAAtC,YAAA,EAAAyE;EAAA,IAA8CR,mBAAA;EAE9C,MAAAzE,MAAA,GAAe0C,WAAA,CAAAwC,oBAAA,GACXT,mBAAA,CAAAU,aAAA,EAAAnF,MAAA,IAA6CgF,aAAA,GAC7CA,aAAA;EAEJ,MAAAxE,YAAA,GAAqBkC,WAAA,CAAAwC,oBAAA,GACjBT,mBAAA,CAAAU,aAAA,EAAA3E,YAAA,IAAmDyE,mBAAA,GACnDA,mBAAA;EAAA,IAAAG,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAN,CAAA,QAAArC,WAAA,IAAAqC,CAAA,QAAA/E,MAAA,IAAA+E,CAAA,QAAAvE,YAAA,IAAAuE,CAAA,QAAAN,mBAAA;IAMOY,EAAA,GAAAC,MAAA,CAAAC,GAAA;IAAAC,GAAA;MAJX,MAAA7C,sBAAA,GAA+B6B,+BAAA,CAAgCC,mBAAA;MAAA,IAE3D/B,WAAA,EAAAO,8BAAA;QAAA,IACEN,sBAAA;UACK0C,EAAA;UAAA,MAAAG,GAAA;QAAA;MAAA;MAAA,KAINhF,YAAA,EAAA8B,QAAA,EAAAC,YAAA,EAAAC,MAAA,EAAAf,MAAA;QACI4D,EAAA;QAAA,MAAAG,GAAA;MAAA;MAIPJ,EAAA,GAAAhF,IAAA,CAAAqC,YAAA;QAAA1C,UAAA,EAAA0F,QAAA,CAAAC,IAAA;QAAAhD,WAAA;QAAA1C,MAAA;QAAAQ,YAAA;QAAAmC;MAAA,C;;;;;;;;;;;;;;;SAAAyC,E;CAQJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","useToolbarStates","useRedirectVerticalWheelToHorizontalScroll","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","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 { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js'\nimport './index.css'\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 useRedirectVerticalWheelToHorizontalScroll()\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 <div className=\"fixed-toolbar__scroll\">\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 </div>\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;AACjC,SAASC,0CAA0C,QAAQ;AAC3D,OAAO;AAEP,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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