@bbl-digital/snorre 4.1.18 → 4.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +47 -6
- package/esm/core/Modal/index.js +2 -1
- package/esm/core/QuillEditor/QuillEditor.stories.js +1 -0
- package/esm/core/QuillEditor/index.js +45 -5
- package/lib/core/Modal/index.d.ts +3 -1
- package/lib/core/Modal/index.d.ts.map +1 -1
- package/lib/core/Modal/index.js +2 -1
- package/lib/core/QuillEditor/QuillEditor.stories.d.ts.map +1 -1
- package/lib/core/QuillEditor/QuillEditor.stories.js +1 -0
- package/lib/core/QuillEditor/index.d.ts.map +1 -1
- package/lib/core/QuillEditor/index.js +45 -5
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -25790,6 +25790,7 @@
|
|
|
25790
25790
|
disableOutsideClick = true,
|
|
25791
25791
|
hideCloseButton,
|
|
25792
25792
|
disableScroll = true,
|
|
25793
|
+
disableRefFocus,
|
|
25793
25794
|
targetRefs,
|
|
25794
25795
|
disableScrollableContent,
|
|
25795
25796
|
headerCss,
|
|
@@ -25833,7 +25834,7 @@
|
|
|
25833
25834
|
}, []);
|
|
25834
25835
|
React.useEffect(() => {
|
|
25835
25836
|
if (!modalRef.current) return;
|
|
25836
|
-
if (isOpen) {
|
|
25837
|
+
if (isOpen && !disableRefFocus) {
|
|
25837
25838
|
modalRef.current.focus();
|
|
25838
25839
|
}
|
|
25839
25840
|
if (isOpen && disableScroll) {
|
|
@@ -35537,12 +35538,13 @@ to {top: 100vh;}
|
|
|
35537
35538
|
}
|
|
35538
35539
|
}
|
|
35539
35540
|
};
|
|
35540
|
-
const handleChange = React.useCallback((delta, _oldDelta, source,
|
|
35541
|
-
|
|
35541
|
+
const handleChange = React.useCallback((delta, _oldDelta, source, quill) => {
|
|
35542
|
+
if (!quill) return;
|
|
35543
|
+
const html = quill.root.innerHTML;
|
|
35542
35544
|
if (onChange) {
|
|
35543
|
-
onChange(html, delta, source,
|
|
35545
|
+
onChange(html, delta, source, quill);
|
|
35544
35546
|
}
|
|
35545
|
-
}, [onChange]);
|
|
35547
|
+
}, [onChange, quill]);
|
|
35546
35548
|
const applySizes = quill => {
|
|
35547
35549
|
if (!quill) return;
|
|
35548
35550
|
minHeight && (quill.root.style.minHeight = `${minHeight}px`);
|
|
@@ -35560,7 +35562,10 @@ to {top: 100vh;}
|
|
|
35560
35562
|
quillRef.current = new Quill__default["default"](`#editor${editorId.current}`, {
|
|
35561
35563
|
theme: 'snow',
|
|
35562
35564
|
modules: {
|
|
35563
|
-
...modules
|
|
35565
|
+
...modules,
|
|
35566
|
+
keyboard: {
|
|
35567
|
+
scrollingContainer: null
|
|
35568
|
+
}
|
|
35564
35569
|
},
|
|
35565
35570
|
formats,
|
|
35566
35571
|
placeholder,
|
|
@@ -35578,6 +35583,10 @@ to {top: 100vh;}
|
|
|
35578
35583
|
}, (range, context) => {
|
|
35579
35584
|
return handleBackspaceWithIndentetList(range, context, quillRef.current);
|
|
35580
35585
|
});
|
|
35586
|
+
quillRef.current.root.style.touchAction = 'pan-y';
|
|
35587
|
+
quillRef.current.root.style.overflowY = 'auto';
|
|
35588
|
+
quillRef.current.disable();
|
|
35589
|
+
quillRef.current.enable(true);
|
|
35581
35590
|
// Move the last binding in the list, to the top. Ensure that the custom binding is called first.
|
|
35582
35591
|
quillRef.current.keyboard.bindings['Backspace'].unshift(quillRef.current.keyboard.bindings['Backspace'].pop());
|
|
35583
35592
|
quillRef.current.keyboard.addBinding({
|
|
@@ -35607,6 +35616,38 @@ to {top: 100vh;}
|
|
|
35607
35616
|
quillRef.current = null;
|
|
35608
35617
|
};
|
|
35609
35618
|
}, [quillRef]);
|
|
35619
|
+
React.useEffect(() => {
|
|
35620
|
+
if (!quillRef.current) return;
|
|
35621
|
+
const handleBlur = () => {
|
|
35622
|
+
document.body.style.overflow = 'auto';
|
|
35623
|
+
};
|
|
35624
|
+
const handleFocus = () => {
|
|
35625
|
+
console.log('sets hidden', document);
|
|
35626
|
+
document.body.style.overflow = 'hidden';
|
|
35627
|
+
};
|
|
35628
|
+
quillRef.current.root.addEventListener('blur', handleBlur);
|
|
35629
|
+
quillRef.current.root.addEventListener('focus', handleFocus);
|
|
35630
|
+
return () => {
|
|
35631
|
+
if (quillRef.current) {
|
|
35632
|
+
quillRef.current.root.removeEventListener('blur', handleBlur);
|
|
35633
|
+
quillRef.current.root.removeEventListener('focus', handleFocus);
|
|
35634
|
+
}
|
|
35635
|
+
};
|
|
35636
|
+
}, [quillRef]);
|
|
35637
|
+
React.useEffect(() => {
|
|
35638
|
+
if (!quill) return;
|
|
35639
|
+
const resizeQuill = () => {
|
|
35640
|
+
const quillContainer = quill.container;
|
|
35641
|
+
quillContainer.style.height = `${window.innerHeight - 100}px`; // Adjust as needed
|
|
35642
|
+
quill.update();
|
|
35643
|
+
};
|
|
35644
|
+
window.addEventListener('resize', resizeQuill);
|
|
35645
|
+
window.addEventListener('orientationchange', resizeQuill);
|
|
35646
|
+
return () => {
|
|
35647
|
+
window.removeEventListener('resize', resizeQuill);
|
|
35648
|
+
window.removeEventListener('orientationchange', resizeQuill);
|
|
35649
|
+
};
|
|
35650
|
+
}, [quill]);
|
|
35610
35651
|
React.useEffect(() => {
|
|
35611
35652
|
if (!quill) return;
|
|
35612
35653
|
quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
|
package/esm/core/Modal/index.js
CHANGED
|
@@ -18,6 +18,7 @@ function Modal({
|
|
|
18
18
|
disableOutsideClick = true,
|
|
19
19
|
hideCloseButton,
|
|
20
20
|
disableScroll = true,
|
|
21
|
+
disableRefFocus,
|
|
21
22
|
targetRefs,
|
|
22
23
|
disableScrollableContent,
|
|
23
24
|
headerCss,
|
|
@@ -61,7 +62,7 @@ function Modal({
|
|
|
61
62
|
}, []);
|
|
62
63
|
useEffect(() => {
|
|
63
64
|
if (!modalRef.current) return;
|
|
64
|
-
if (isOpen) {
|
|
65
|
+
if (isOpen && !disableRefFocus) {
|
|
65
66
|
modalRef.current.focus();
|
|
66
67
|
}
|
|
67
68
|
if (isOpen && disableScroll) {
|
|
@@ -10,6 +10,7 @@ export const Default = {
|
|
|
10
10
|
onChange: e => console.log(e),
|
|
11
11
|
onBlur: html => console.log('blur', html),
|
|
12
12
|
onFocus: () => console.log('focus'),
|
|
13
|
+
maxHeight: 500,
|
|
13
14
|
initialValue: `<p>Beskrivelse av selve styremøtet.</p><p><br></p><ol><li data-list="ordered"><span class="ql-ui" contenteditable="false"></span>test</li><li data-list="ordered"><span class="ql-ui" contenteditable="false"></span>test</li><li data-list="ordered" style="margin-left: 1em;"><span class="ql-ui" contenteditable="false"></span>test</li></ol>`,
|
|
14
15
|
pasteAsText: true
|
|
15
16
|
});
|
|
@@ -134,12 +134,13 @@ const QuillEditor = ({
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
const handleChange = useCallback((delta, _oldDelta, source,
|
|
138
|
-
|
|
137
|
+
const handleChange = useCallback((delta, _oldDelta, source, quill) => {
|
|
138
|
+
if (!quill) return;
|
|
139
|
+
const html = quill.root.innerHTML;
|
|
139
140
|
if (onChange) {
|
|
140
|
-
onChange(html, delta, source,
|
|
141
|
+
onChange(html, delta, source, quill);
|
|
141
142
|
}
|
|
142
|
-
}, [onChange]);
|
|
143
|
+
}, [onChange, quill]);
|
|
143
144
|
const applySizes = quill => {
|
|
144
145
|
if (!quill) return;
|
|
145
146
|
minHeight && (quill.root.style.minHeight = `${minHeight}px`);
|
|
@@ -157,7 +158,10 @@ const QuillEditor = ({
|
|
|
157
158
|
quillRef.current = new Quill(`#editor${editorId.current}`, {
|
|
158
159
|
theme: 'snow',
|
|
159
160
|
modules: {
|
|
160
|
-
...modules
|
|
161
|
+
...modules,
|
|
162
|
+
keyboard: {
|
|
163
|
+
scrollingContainer: null
|
|
164
|
+
}
|
|
161
165
|
},
|
|
162
166
|
formats,
|
|
163
167
|
placeholder,
|
|
@@ -175,6 +179,10 @@ const QuillEditor = ({
|
|
|
175
179
|
}, (range, context) => {
|
|
176
180
|
return handleBackspaceWithIndentetList(range, context, quillRef.current);
|
|
177
181
|
});
|
|
182
|
+
quillRef.current.root.style.touchAction = 'pan-y';
|
|
183
|
+
quillRef.current.root.style.overflowY = 'auto';
|
|
184
|
+
quillRef.current.disable();
|
|
185
|
+
quillRef.current.enable(true);
|
|
178
186
|
// Move the last binding in the list, to the top. Ensure that the custom binding is called first.
|
|
179
187
|
quillRef.current.keyboard.bindings['Backspace'].unshift(quillRef.current.keyboard.bindings['Backspace'].pop());
|
|
180
188
|
quillRef.current.keyboard.addBinding({
|
|
@@ -204,6 +212,38 @@ const QuillEditor = ({
|
|
|
204
212
|
quillRef.current = null;
|
|
205
213
|
};
|
|
206
214
|
}, [quillRef]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (!quillRef.current) return;
|
|
217
|
+
const handleBlur = () => {
|
|
218
|
+
document.body.style.overflow = 'auto';
|
|
219
|
+
};
|
|
220
|
+
const handleFocus = () => {
|
|
221
|
+
console.log('sets hidden', document);
|
|
222
|
+
document.body.style.overflow = 'hidden';
|
|
223
|
+
};
|
|
224
|
+
quillRef.current.root.addEventListener('blur', handleBlur);
|
|
225
|
+
quillRef.current.root.addEventListener('focus', handleFocus);
|
|
226
|
+
return () => {
|
|
227
|
+
if (quillRef.current) {
|
|
228
|
+
quillRef.current.root.removeEventListener('blur', handleBlur);
|
|
229
|
+
quillRef.current.root.removeEventListener('focus', handleFocus);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}, [quillRef]);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (!quill) return;
|
|
235
|
+
const resizeQuill = () => {
|
|
236
|
+
const quillContainer = quill.container;
|
|
237
|
+
quillContainer.style.height = `${window.innerHeight - 100}px`; // Adjust as needed
|
|
238
|
+
quill.update();
|
|
239
|
+
};
|
|
240
|
+
window.addEventListener('resize', resizeQuill);
|
|
241
|
+
window.addEventListener('orientationchange', resizeQuill);
|
|
242
|
+
return () => {
|
|
243
|
+
window.removeEventListener('resize', resizeQuill);
|
|
244
|
+
window.removeEventListener('orientationchange', resizeQuill);
|
|
245
|
+
};
|
|
246
|
+
}, [quill]);
|
|
207
247
|
useEffect(() => {
|
|
208
248
|
if (!quill) return;
|
|
209
249
|
quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
|
|
@@ -12,6 +12,8 @@ interface IProps extends React.HTMLAttributes<HTMLDialogElement> {
|
|
|
12
12
|
width?: string;
|
|
13
13
|
/** Disable close on outside click */
|
|
14
14
|
disableOutsideClick?: boolean;
|
|
15
|
+
/** Disable focus on modal ref when opened */
|
|
16
|
+
disableRefFocus?: boolean;
|
|
15
17
|
/** Hide close button */
|
|
16
18
|
hideCloseButton?: boolean;
|
|
17
19
|
/** Refs of scrollable elements */
|
|
@@ -41,7 +43,7 @@ interface IProps extends React.HTMLAttributes<HTMLDialogElement> {
|
|
|
41
43
|
/** Children */
|
|
42
44
|
children?: React.ReactNode | React.ReactNode[];
|
|
43
45
|
}
|
|
44
|
-
declare function Modal({ open, header, actionButton, width, children, disableOutsideClick, hideCloseButton, disableScroll, targetRefs, disableScrollableContent, headerCss, contentCss, disableLocalClose, toggleFullscreen, defaultFullscreen, disableFocusTrap, onClose, onCollapse, onFullscreenToggle, ...restProps }: IProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
46
|
+
declare function Modal({ open, header, actionButton, width, children, disableOutsideClick, hideCloseButton, disableScroll, disableRefFocus, targetRefs, disableScrollableContent, headerCss, contentCss, disableLocalClose, toggleFullscreen, defaultFullscreen, disableFocusTrap, onClose, onCollapse, onFullscreenToggle, ...restProps }: IProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
45
47
|
declare namespace Modal {
|
|
46
48
|
var Actions: ({ children, className, spaceBetween }: {
|
|
47
49
|
children: React.ReactNode | React.ReactNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceR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AA2B;IAC3B,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,0BAA0B;IAC1B,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,0BAA0B;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,0DAA0D;IAC1D,kBAAkB,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,eAAe;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;CAC/C;AAED,iBAAS,KAAK,CAAC,EACb,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,KAAe,EACf,QAAQ,EACR,mBAA0B,EAC1B,eAAe,EACf,aAAoB,EACpB,eAAe,EACf,UAAU,EACV,wBAAwB,EACxB,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,GAAG,SAAS,EACb,EAAE,MAAM,oDAkLR;kBAxMQ,KAAK;;;;;;;AA4Md,eAAe,KAAK,CAAA"}
|
package/lib/core/Modal/index.js
CHANGED
|
@@ -18,6 +18,7 @@ function Modal({
|
|
|
18
18
|
disableOutsideClick = true,
|
|
19
19
|
hideCloseButton,
|
|
20
20
|
disableScroll = true,
|
|
21
|
+
disableRefFocus,
|
|
21
22
|
targetRefs,
|
|
22
23
|
disableScrollableContent,
|
|
23
24
|
headerCss,
|
|
@@ -61,7 +62,7 @@ function Modal({
|
|
|
61
62
|
}, []);
|
|
62
63
|
useEffect(() => {
|
|
63
64
|
if (!modalRef.current) return;
|
|
64
|
-
if (isOpen) {
|
|
65
|
+
if (isOpen && !disableRefFocus) {
|
|
65
66
|
modalRef.current.focus();
|
|
66
67
|
}
|
|
67
68
|
if (isOpen && disableScroll) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuillEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/packages/core/QuillEditor/QuillEditor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;wBAKlC,IAAI;AAHT,wBAGS;AAET,eAAO,MAAM,OAAO;;;
|
|
1
|
+
{"version":3,"file":"QuillEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/packages/core/QuillEditor/QuillEditor.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;wBAKlC,IAAI;AAHT,wBAGS;AAET,eAAO,MAAM,OAAO;;;CAcnB,CAAA;AAED,eAAO,MAAM,IAAI;;;CAGhB,CAAA;AAED,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AAED,eAAO,MAAM,UAAU;;;CAKtB,CAAA;AAED,eAAO,MAAM,WAAW;;;CAKvB,CAAA;AAED,eAAO,MAAM,SAAS;;;CAQrB,CAAA"}
|
|
@@ -10,6 +10,7 @@ export const Default = {
|
|
|
10
10
|
onChange: e => console.log(e),
|
|
11
11
|
onBlur: html => console.log('blur', html),
|
|
12
12
|
onFocus: () => console.log('focus'),
|
|
13
|
+
maxHeight: 500,
|
|
13
14
|
initialValue: `<p>Beskrivelse av selve styremøtet.</p><p><br></p><ol><li data-list="ordered"><span class="ql-ui" contenteditable="false"></span>test</li><li data-list="ordered"><span class="ql-ui" contenteditable="false"></span>test</li><li data-list="ordered" style="margin-left: 1em;"><span class="ql-ui" contenteditable="false"></span>test</li></ol>`,
|
|
14
15
|
pasteAsText: true
|
|
15
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/QuillEditor/index.tsx"],"names":[],"mappings":"AASA,OAAO,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AA+D3C,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/QuillEditor/index.tsx"],"names":[],"mappings":"AASA,OAAO,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AA+D3C,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA2S3C,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -134,12 +134,13 @@ const QuillEditor = ({
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
const handleChange = useCallback((delta, _oldDelta, source,
|
|
138
|
-
|
|
137
|
+
const handleChange = useCallback((delta, _oldDelta, source, quill) => {
|
|
138
|
+
if (!quill) return;
|
|
139
|
+
const html = quill.root.innerHTML;
|
|
139
140
|
if (onChange) {
|
|
140
|
-
onChange(html, delta, source,
|
|
141
|
+
onChange(html, delta, source, quill);
|
|
141
142
|
}
|
|
142
|
-
}, [onChange]);
|
|
143
|
+
}, [onChange, quill]);
|
|
143
144
|
const applySizes = quill => {
|
|
144
145
|
if (!quill) return;
|
|
145
146
|
minHeight && (quill.root.style.minHeight = `${minHeight}px`);
|
|
@@ -157,7 +158,10 @@ const QuillEditor = ({
|
|
|
157
158
|
quillRef.current = new Quill(`#editor${editorId.current}`, {
|
|
158
159
|
theme: 'snow',
|
|
159
160
|
modules: {
|
|
160
|
-
...modules
|
|
161
|
+
...modules,
|
|
162
|
+
keyboard: {
|
|
163
|
+
scrollingContainer: null
|
|
164
|
+
}
|
|
161
165
|
},
|
|
162
166
|
formats,
|
|
163
167
|
placeholder,
|
|
@@ -175,6 +179,10 @@ const QuillEditor = ({
|
|
|
175
179
|
}, (range, context) => {
|
|
176
180
|
return handleBackspaceWithIndentetList(range, context, quillRef.current);
|
|
177
181
|
});
|
|
182
|
+
quillRef.current.root.style.touchAction = 'pan-y';
|
|
183
|
+
quillRef.current.root.style.overflowY = 'auto';
|
|
184
|
+
quillRef.current.disable();
|
|
185
|
+
quillRef.current.enable(true);
|
|
178
186
|
// Move the last binding in the list, to the top. Ensure that the custom binding is called first.
|
|
179
187
|
quillRef.current.keyboard.bindings['Backspace'].unshift(quillRef.current.keyboard.bindings['Backspace'].pop());
|
|
180
188
|
quillRef.current.keyboard.addBinding({
|
|
@@ -204,6 +212,38 @@ const QuillEditor = ({
|
|
|
204
212
|
quillRef.current = null;
|
|
205
213
|
};
|
|
206
214
|
}, [quillRef]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (!quillRef.current) return;
|
|
217
|
+
const handleBlur = () => {
|
|
218
|
+
document.body.style.overflow = 'auto';
|
|
219
|
+
};
|
|
220
|
+
const handleFocus = () => {
|
|
221
|
+
console.log('sets hidden', document);
|
|
222
|
+
document.body.style.overflow = 'hidden';
|
|
223
|
+
};
|
|
224
|
+
quillRef.current.root.addEventListener('blur', handleBlur);
|
|
225
|
+
quillRef.current.root.addEventListener('focus', handleFocus);
|
|
226
|
+
return () => {
|
|
227
|
+
if (quillRef.current) {
|
|
228
|
+
quillRef.current.root.removeEventListener('blur', handleBlur);
|
|
229
|
+
quillRef.current.root.removeEventListener('focus', handleFocus);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}, [quillRef]);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (!quill) return;
|
|
235
|
+
const resizeQuill = () => {
|
|
236
|
+
const quillContainer = quill.container;
|
|
237
|
+
quillContainer.style.height = `${window.innerHeight - 100}px`; // Adjust as needed
|
|
238
|
+
quill.update();
|
|
239
|
+
};
|
|
240
|
+
window.addEventListener('resize', resizeQuill);
|
|
241
|
+
window.addEventListener('orientationchange', resizeQuill);
|
|
242
|
+
return () => {
|
|
243
|
+
window.removeEventListener('resize', resizeQuill);
|
|
244
|
+
window.removeEventListener('orientationchange', resizeQuill);
|
|
245
|
+
};
|
|
246
|
+
}, [quill]);
|
|
207
247
|
useEffect(() => {
|
|
208
248
|
if (!quill) return;
|
|
209
249
|
quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
|