@delali/web-editor 0.4.1 → 0.4.3
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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/components/editor/create-editor-plugins.js +79 -40
- package/dist/components/editor/editor-kit.js +78 -39
- package/dist/components/editor/version-history/index.js +48 -9
- package/dist/components/editor/web-editor.js +88 -49
- package/dist/hooks/use-return-focus-to-editor-on-input-removal.d.ts +3 -0
- package/dist/lib/markdown-utils.js +79 -40
- package/dist/ui/icon-picker.d.ts +1 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
43
43
|
// src/components/editor/web-editor.tsx
|
|
44
44
|
import { createSlateEditor, normalizeNodeId } from "platejs";
|
|
45
45
|
import { Plate as Plate2, usePlateEditor as usePlateEditor3 } from "platejs/react";
|
|
46
|
-
import { useCallback as useCallback89, useEffect as
|
|
46
|
+
import { useCallback as useCallback89, useEffect as useEffect68, useMemo as useMemo28, useRef as useRef32 } from "react";
|
|
47
47
|
|
|
48
48
|
// src/context/editor-adapter-context.tsx
|
|
49
49
|
import { createContext, useContext } from "react";
|
|
@@ -12116,7 +12116,7 @@ function BadgeShapeButton({ shape, selected, setShape, updateElement }) {
|
|
|
12116
12116
|
|
|
12117
12117
|
// src/ui/icon-picker.tsx
|
|
12118
12118
|
import { icons as lucideIcons } from "lucide-react";
|
|
12119
|
-
import { dynamicIconImports } from "lucide-react/dynamic";
|
|
12119
|
+
import { dynamicIconImports } from "lucide-react/dynamic.mjs";
|
|
12120
12120
|
import * as React34 from "react";
|
|
12121
12121
|
import { Fragment as Fragment11, jsx as jsx92, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
12122
12122
|
var toPascalCase = (str) => str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
@@ -15849,11 +15849,49 @@ import { filterWords } from "@platejs/combobox";
|
|
|
15849
15849
|
import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
|
|
15850
15850
|
import { cva as cva22 } from "class-variance-authority";
|
|
15851
15851
|
import { useComposedRef as useComposedRef2, useEditorRef as useEditorRef26 } from "platejs/react";
|
|
15852
|
-
import React55, { useEffect as
|
|
15852
|
+
import React55, { useEffect as useEffect39 } from "react";
|
|
15853
|
+
|
|
15854
|
+
// src/hooks/use-return-focus-to-editor-on-input-removal.ts
|
|
15855
|
+
import { useEffect as useEffect37, useLayoutEffect as useLayoutEffect3, useRef as useRef16 } from "react";
|
|
15856
|
+
var focusEditableAtEditorSelection = (editor) => {
|
|
15857
|
+
const editable = editor.api.toDOMNode(editor);
|
|
15858
|
+
if (!(editable == null ? void 0 : editable.isConnected)) {
|
|
15859
|
+
return;
|
|
15860
|
+
}
|
|
15861
|
+
const document2 = editable.ownerDocument;
|
|
15862
|
+
const activeElement = document2.activeElement;
|
|
15863
|
+
if (activeElement && activeElement !== document2.body) {
|
|
15864
|
+
return;
|
|
15865
|
+
}
|
|
15866
|
+
const domRange = editor.selection ? editor.api.toDOMRange(editor.selection) : void 0;
|
|
15867
|
+
editable.focus({ preventScroll: true });
|
|
15868
|
+
const domSelection = document2.getSelection();
|
|
15869
|
+
if (domRange && domSelection) {
|
|
15870
|
+
domSelection.removeAllRanges();
|
|
15871
|
+
domSelection.addRange(domRange);
|
|
15872
|
+
}
|
|
15873
|
+
};
|
|
15874
|
+
var useReturnFocusToEditorOnInputRemoval = (editor, inputRef) => {
|
|
15875
|
+
const inputHadFocusWhenRemoved = useRef16(false);
|
|
15876
|
+
useLayoutEffect3(() => {
|
|
15877
|
+
const input = inputRef.current;
|
|
15878
|
+
return () => {
|
|
15879
|
+
inputHadFocusWhenRemoved.current = !!input && input.ownerDocument.activeElement === input;
|
|
15880
|
+
};
|
|
15881
|
+
}, [inputRef]);
|
|
15882
|
+
useEffect37(
|
|
15883
|
+
() => () => {
|
|
15884
|
+
if (inputHadFocusWhenRemoved.current) {
|
|
15885
|
+
focusEditableAtEditorSelection(editor);
|
|
15886
|
+
}
|
|
15887
|
+
},
|
|
15888
|
+
[editor]
|
|
15889
|
+
);
|
|
15890
|
+
};
|
|
15853
15891
|
|
|
15854
15892
|
// src/hooks/use-shield-input-selection-from-editor.ts
|
|
15855
15893
|
import { RangeApi as RangeApi2 } from "platejs";
|
|
15856
|
-
import { useEffect as
|
|
15894
|
+
import { useEffect as useEffect38 } from "react";
|
|
15857
15895
|
var SLATE_TEXT_SELECTOR = "[data-slate-string], [data-slate-zero-width]";
|
|
15858
15896
|
var isCaretInEditorText = (node) => {
|
|
15859
15897
|
var _a;
|
|
@@ -15871,7 +15909,7 @@ var wouldPullCaretOutOfInput = (editor, input) => {
|
|
|
15871
15909
|
return !!range && RangeApi2.equals(range, editor.selection);
|
|
15872
15910
|
};
|
|
15873
15911
|
var useShieldInputSelectionFromEditor = (editor, inputRef) => {
|
|
15874
|
-
|
|
15912
|
+
useEffect38(() => {
|
|
15875
15913
|
const input = inputRef.current;
|
|
15876
15914
|
const view = input == null ? void 0 : input.ownerDocument.defaultView;
|
|
15877
15915
|
if (!input || !view) {
|
|
@@ -15935,7 +15973,7 @@ function InlineCombobox({
|
|
|
15935
15973
|
[setValueProp, hasValueProp]
|
|
15936
15974
|
);
|
|
15937
15975
|
const insertPoint = React55.useRef(null);
|
|
15938
|
-
|
|
15976
|
+
useEffect39(() => {
|
|
15939
15977
|
const path = editor.api.findPath(element);
|
|
15940
15978
|
if (!path) return;
|
|
15941
15979
|
const point = editor.api.before(path);
|
|
@@ -16001,6 +16039,7 @@ function InlineComboboxInput(_a) {
|
|
|
16001
16039
|
const editor = useEditorRef26();
|
|
16002
16040
|
const ref = useComposedRef2(refProp, contextRef);
|
|
16003
16041
|
useShieldInputSelectionFromEditor(editor, contextRef);
|
|
16042
|
+
useReturnFocusToEditorOnInputRemoval(editor, contextRef);
|
|
16004
16043
|
return /* @__PURE__ */ jsxs79(Fragment19, { children: [
|
|
16005
16044
|
showTrigger && trigger,
|
|
16006
16045
|
/* @__PURE__ */ jsxs79("span", { className: "relative min-h-lh", children: [
|
|
@@ -16100,7 +16139,7 @@ function InlineComboboxEmpty({ children, className }) {
|
|
|
16100
16139
|
const { setHasEmpty } = React55.useContext(InlineComboboxContext);
|
|
16101
16140
|
const store = Ariakit2.useComboboxContext();
|
|
16102
16141
|
const items = (_a = store == null ? void 0 : store.useState("items")) != null ? _a : [];
|
|
16103
|
-
|
|
16142
|
+
useEffect39(() => {
|
|
16104
16143
|
setHasEmpty(true);
|
|
16105
16144
|
return () => {
|
|
16106
16145
|
setHasEmpty(false);
|
|
@@ -16260,11 +16299,11 @@ import { ArrowUpRightIcon as ArrowUpRightIcon3, PencilIcon as PencilIcon6, Trash
|
|
|
16260
16299
|
|
|
16261
16300
|
// src/ui/smart-link-copy-button.tsx
|
|
16262
16301
|
import { CheckIcon as CheckIcon15, CopyIcon as CopyIcon2, XIcon as XIcon7 } from "lucide-react";
|
|
16263
|
-
import { useCallback as useCallback40, useEffect as
|
|
16302
|
+
import { useCallback as useCallback40, useEffect as useEffect40, useState as useState40 } from "react";
|
|
16264
16303
|
import { jsx as jsx131 } from "react/jsx-runtime";
|
|
16265
16304
|
function SmartLinkCopyButton({ disabled, onCopy }) {
|
|
16266
16305
|
const [feedback, setFeedback] = useState40("idle");
|
|
16267
|
-
|
|
16306
|
+
useEffect40(() => {
|
|
16268
16307
|
if (feedback === "idle") return;
|
|
16269
16308
|
const timeoutId = window.setTimeout(() => {
|
|
16270
16309
|
setFeedback("idle");
|
|
@@ -16609,12 +16648,12 @@ var PlainLinkElement = (props) => /* @__PURE__ */ jsx134(LinkElement, __spreadPr
|
|
|
16609
16648
|
|
|
16610
16649
|
// src/ui/link-toolbar.tsx
|
|
16611
16650
|
import { useEditorPlugin as useEditorPlugin12, useEditorSelector as useEditorSelector2, usePluginOption as usePluginOption17 } from "platejs/react";
|
|
16612
|
-
import { useCallback as useCallback45, useEffect as
|
|
16651
|
+
import { useCallback as useCallback45, useEffect as useEffect43, useState as useState44 } from "react";
|
|
16613
16652
|
|
|
16614
16653
|
// src/ui/link-search-panel.tsx
|
|
16615
16654
|
import { BookmarkIcon, LinkIcon as LinkIcon4 } from "lucide-react";
|
|
16616
16655
|
import { useEditorPlugin as useEditorPlugin10 } from "platejs/react";
|
|
16617
|
-
import { useCallback as useCallback43, useEffect as
|
|
16656
|
+
import { useCallback as useCallback43, useEffect as useEffect41, useState as useState42 } from "react";
|
|
16618
16657
|
|
|
16619
16658
|
// src/ui/link-toolbar-shared.ts
|
|
16620
16659
|
import { unwrapLink as unwrapLink2, upsertLink } from "@platejs/link";
|
|
@@ -16765,7 +16804,7 @@ function LinkSearchPanel({ initialUrl }) {
|
|
|
16765
16804
|
const safeUrl = trimmedQuery.length > 0 ? getSafeSmartLinkUrl(trimmedQuery) : null;
|
|
16766
16805
|
const searchTerm = isLikelySmartLinkUrl(query) ? "" : trimmedQuery;
|
|
16767
16806
|
const debouncedSearch = useDebounce(searchTerm, 200);
|
|
16768
|
-
|
|
16807
|
+
useEffect41(() => {
|
|
16769
16808
|
if (!canLinkPage) {
|
|
16770
16809
|
setPages([]);
|
|
16771
16810
|
setIsLoading(false);
|
|
@@ -16904,7 +16943,7 @@ import { CursorOverlayPlugin as CursorOverlayPlugin2 } from "@platejs/selection/
|
|
|
16904
16943
|
import { LinkIcon as LinkIcon5, Trash2Icon as Trash2Icon4 } from "lucide-react";
|
|
16905
16944
|
import { NodeApi as NodeApi16 } from "platejs";
|
|
16906
16945
|
import { useEditorPlugin as useEditorPlugin11, usePluginOption as usePluginOption16 } from "platejs/react";
|
|
16907
|
-
import { useCallback as useCallback44, useEffect as
|
|
16946
|
+
import { useCallback as useCallback44, useEffect as useEffect42, useState as useState43 } from "react";
|
|
16908
16947
|
import { jsx as jsx136, jsxs as jsxs85 } from "react/jsx-runtime";
|
|
16909
16948
|
function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
|
|
16910
16949
|
const [url, setUrl] = useState43(initialUrl);
|
|
@@ -16913,7 +16952,7 @@ function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
|
|
|
16913
16952
|
const { editor, setOption } = useEditorPlugin11(linkPlugin);
|
|
16914
16953
|
const activeLinkId = usePluginOption16(linkPlugin, "activeId");
|
|
16915
16954
|
const editingLinkEntry = useActiveLink();
|
|
16916
|
-
|
|
16955
|
+
useEffect42(() => {
|
|
16917
16956
|
var _a;
|
|
16918
16957
|
if (!editingLinkEntry) return;
|
|
16919
16958
|
setText(NodeApi16.string(editingLinkEntry[0]));
|
|
@@ -17037,10 +17076,10 @@ function LinkFloatingToolbar() {
|
|
|
17037
17076
|
const aboveUrl = (_a = aboveLink == null ? void 0 : aboveLink.url) != null ? _a : "";
|
|
17038
17077
|
const [initialUrl, setInitialUrl] = useState44(aboveUrl);
|
|
17039
17078
|
const open = mode === "insert" || mode === "edit" || mode === "cursor";
|
|
17040
|
-
|
|
17079
|
+
useEffect43(() => {
|
|
17041
17080
|
setInitialUrl(aboveUrl);
|
|
17042
17081
|
}, [aboveUrl]);
|
|
17043
|
-
|
|
17082
|
+
useEffect43(() => {
|
|
17044
17083
|
if (aboveLink) {
|
|
17045
17084
|
const timeoutId = window.setTimeout(() => {
|
|
17046
17085
|
var _a2;
|
|
@@ -18104,7 +18143,7 @@ import {
|
|
|
18104
18143
|
useReadOnly as useReadOnly18,
|
|
18105
18144
|
useSelected as useSelected5
|
|
18106
18145
|
} from "platejs/react";
|
|
18107
|
-
import React62, { useEffect as
|
|
18146
|
+
import React62, { useEffect as useEffect46 } from "react";
|
|
18108
18147
|
import { jsx as jsx155, jsxs as jsxs95 } from "react/jsx-runtime";
|
|
18109
18148
|
function EquationElement(props) {
|
|
18110
18149
|
const element = useElement14();
|
|
@@ -18165,7 +18204,7 @@ function InlineEquationElement(props) {
|
|
|
18165
18204
|
const selected = useSelected5();
|
|
18166
18205
|
const isCollapsed = useEditorSelector5((editor) => editor.api.isCollapsed(), []);
|
|
18167
18206
|
const [open, setOpen] = React62.useState(selected && isCollapsed);
|
|
18168
|
-
|
|
18207
|
+
useEffect46(() => {
|
|
18169
18208
|
if (selected && isCollapsed) {
|
|
18170
18209
|
setOpen(true);
|
|
18171
18210
|
}
|
|
@@ -18245,7 +18284,7 @@ function EquationPopoverContent(_a) {
|
|
|
18245
18284
|
const editor = useEditorRef36();
|
|
18246
18285
|
const readOnly = useReadOnly18();
|
|
18247
18286
|
const element = useElement14();
|
|
18248
|
-
|
|
18287
|
+
useEffect46(() => {
|
|
18249
18288
|
if (isInline && open) {
|
|
18250
18289
|
setOpen(true);
|
|
18251
18290
|
}
|
|
@@ -19090,7 +19129,7 @@ import { useDraggable as useDraggable2 } from "@platejs/dnd";
|
|
|
19090
19129
|
import { PlaceholderPlugin as PlaceholderPlugin3, useImage, useMediaState as useMediaState4 } from "@platejs/media/react";
|
|
19091
19130
|
import { ResizableProvider as ResizableProvider5 } from "@platejs/resizable";
|
|
19092
19131
|
import { PlateElement as PlateElement27, useEditorPlugin as useEditorPlugin16, withHOC as withHOC5 } from "platejs/react";
|
|
19093
|
-
import React67, { useEffect as
|
|
19132
|
+
import React67, { useEffect as useEffect48, useMemo as useMemo18 } from "react";
|
|
19094
19133
|
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
19095
19134
|
import { jsx as jsx166, jsxs as jsxs104 } from "react/jsx-runtime";
|
|
19096
19135
|
var ImageElement = withHOC5(
|
|
@@ -19231,7 +19270,7 @@ var ImageElement = withHOC5(
|
|
|
19231
19270
|
);
|
|
19232
19271
|
var ImagePlaceholder = ({ file }) => {
|
|
19233
19272
|
const objectUrl = useMemo18(() => file ? URL.createObjectURL(file) : null, [file]);
|
|
19234
|
-
|
|
19273
|
+
useEffect48(() => {
|
|
19235
19274
|
if (!objectUrl) return;
|
|
19236
19275
|
return () => URL.revokeObjectURL(objectUrl);
|
|
19237
19276
|
}, [objectUrl]);
|
|
@@ -19249,7 +19288,7 @@ import {
|
|
|
19249
19288
|
import { AudioLinesIcon, FileUpIcon as FileUpIcon2, FilmIcon, ImageIcon as ImageIcon2 } from "lucide-react";
|
|
19250
19289
|
import { KEYS as KEYS29, nanoid as nanoid10 } from "platejs";
|
|
19251
19290
|
import { PlateElement as PlateElement28, useEditorPlugin as useEditorPlugin17, withHOC as withHOC6 } from "platejs/react";
|
|
19252
|
-
import { useCallback as useCallback60, useEffect as
|
|
19291
|
+
import { useCallback as useCallback60, useEffect as useEffect49, useRef as useRef17, useState as useState50 } from "react";
|
|
19253
19292
|
import { useFilePicker } from "use-file-picker";
|
|
19254
19293
|
|
|
19255
19294
|
// src/hooks/use-upload-file.ts
|
|
@@ -19361,8 +19400,8 @@ var PlaceholderElement = withHOC6(PlaceholderProvider, (props) => {
|
|
|
19361
19400
|
const isImage = mediaType === KEYS29.img;
|
|
19362
19401
|
const file = updatedFiles == null ? void 0 : updatedFiles[0];
|
|
19363
19402
|
const progress = file ? progresses == null ? void 0 : progresses[file.name] : void 0;
|
|
19364
|
-
const imageRef =
|
|
19365
|
-
|
|
19403
|
+
const imageRef = useRef17(null);
|
|
19404
|
+
useEffect49(() => {
|
|
19366
19405
|
if (!imageRef.current) return;
|
|
19367
19406
|
const { height, width } = imageRef.current;
|
|
19368
19407
|
setSize == null ? void 0 : setSize({
|
|
@@ -19463,15 +19502,15 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
19463
19502
|
}
|
|
19464
19503
|
}
|
|
19465
19504
|
});
|
|
19466
|
-
const isReplaced =
|
|
19467
|
-
|
|
19505
|
+
const isReplaced = useRef17(false);
|
|
19506
|
+
useEffect49(() => {
|
|
19468
19507
|
if (isReplaced.current) return;
|
|
19469
19508
|
isReplaced.current = true;
|
|
19470
19509
|
const currentFiles = api.placeholder.getUploadingFile(element.id);
|
|
19471
19510
|
if (!currentFiles) return;
|
|
19472
19511
|
replaceCurrentPlaceholder(currentFiles);
|
|
19473
19512
|
}, [isReplaced]);
|
|
19474
|
-
|
|
19513
|
+
useEffect49(() => {
|
|
19475
19514
|
if (!uploadedFile) return;
|
|
19476
19515
|
const path = editor.api.findPath(element);
|
|
19477
19516
|
setMediaNode(
|
|
@@ -19504,15 +19543,15 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
19504
19543
|
},
|
|
19505
19544
|
[editor, element, mediaType]
|
|
19506
19545
|
);
|
|
19507
|
-
|
|
19546
|
+
useEffect49(() => {
|
|
19508
19547
|
setOpen(selected);
|
|
19509
19548
|
}, [selected, setOpen]);
|
|
19510
|
-
|
|
19549
|
+
useEffect49(() => {
|
|
19511
19550
|
if (isUploading) {
|
|
19512
19551
|
setOpen(false);
|
|
19513
19552
|
}
|
|
19514
19553
|
}, [isUploading]);
|
|
19515
|
-
|
|
19554
|
+
useEffect49(() => {
|
|
19516
19555
|
var _a2;
|
|
19517
19556
|
setProgresses({ [(_a2 = uploadingFile == null ? void 0 : uploadingFile.name) != null ? _a2 : ""]: progress });
|
|
19518
19557
|
setIsUploading(isUploading);
|
|
@@ -19546,7 +19585,7 @@ function ImageProgress({
|
|
|
19546
19585
|
progress = 0
|
|
19547
19586
|
}) {
|
|
19548
19587
|
const [objectUrl, setObjectUrl] = useState50(null);
|
|
19549
|
-
|
|
19588
|
+
useEffect49(() => {
|
|
19550
19589
|
const url = URL.createObjectURL(file);
|
|
19551
19590
|
setObjectUrl(url);
|
|
19552
19591
|
return () => {
|
|
@@ -19705,7 +19744,7 @@ function ImagePreview() {
|
|
|
19705
19744
|
// src/ui/media-upload-toast.tsx
|
|
19706
19745
|
import { PlaceholderPlugin as PlaceholderPlugin5, UploadErrorCode } from "@platejs/media/react";
|
|
19707
19746
|
import { usePluginOption as usePluginOption21 } from "platejs/react";
|
|
19708
|
-
import { useEffect as
|
|
19747
|
+
import { useEffect as useEffect50 } from "react";
|
|
19709
19748
|
import { toast as toast4 } from "sonner";
|
|
19710
19749
|
function MediaUploadToast() {
|
|
19711
19750
|
usePlaceholderMaxFileSize();
|
|
@@ -19714,7 +19753,7 @@ function MediaUploadToast() {
|
|
|
19714
19753
|
}
|
|
19715
19754
|
var useUploadErrorToast = () => {
|
|
19716
19755
|
const uploadError = usePluginOption21(PlaceholderPlugin5, "error");
|
|
19717
|
-
|
|
19756
|
+
useEffect50(() => {
|
|
19718
19757
|
if (!uploadError) return;
|
|
19719
19758
|
const { code, data } = uploadError;
|
|
19720
19759
|
switch (code) {
|
|
@@ -20177,13 +20216,13 @@ import { useCallback as useCallback64, useState as useState55 } from "react";
|
|
|
20177
20216
|
|
|
20178
20217
|
// src/ui/mention-page-combobox-group.tsx
|
|
20179
20218
|
import { FileTextIcon as FileTextIcon3 } from "lucide-react";
|
|
20180
|
-
import { useEffect as
|
|
20219
|
+
import { useEffect as useEffect51, useState as useState53 } from "react";
|
|
20181
20220
|
import { jsx as jsx173, jsxs as jsxs110 } from "react/jsx-runtime";
|
|
20182
20221
|
function PageComboboxGroup({ search, onPageHover, onPageSelect }) {
|
|
20183
20222
|
const adapter = useEditorAdapter();
|
|
20184
20223
|
const debouncedSearch = useDebounce(search, 250);
|
|
20185
20224
|
const [pages, setPages] = useState53([]);
|
|
20186
|
-
|
|
20225
|
+
useEffect51(() => {
|
|
20187
20226
|
if (!adapter.permissions.canLinkPage) {
|
|
20188
20227
|
setPages([]);
|
|
20189
20228
|
return;
|
|
@@ -20232,13 +20271,13 @@ function PageStatusBadge({ status }) {
|
|
|
20232
20271
|
}
|
|
20233
20272
|
|
|
20234
20273
|
// src/ui/mention-people-combobox-group.tsx
|
|
20235
|
-
import { useEffect as
|
|
20274
|
+
import { useEffect as useEffect52, useState as useState54 } from "react";
|
|
20236
20275
|
import { jsx as jsx174, jsxs as jsxs111 } from "react/jsx-runtime";
|
|
20237
20276
|
function PeopleComboboxGroup({ search, onUserHover, onUserSelect }) {
|
|
20238
20277
|
const adapter = useEditorAdapter();
|
|
20239
20278
|
const debouncedSearch = useDebounce(search, 150);
|
|
20240
20279
|
const [members, setMembers] = useState54([]);
|
|
20241
|
-
|
|
20280
|
+
useEffect52(() => {
|
|
20242
20281
|
if (!adapter.permissions.canMention) {
|
|
20243
20282
|
setMembers([]);
|
|
20244
20283
|
return;
|
|
@@ -21863,7 +21902,7 @@ import {
|
|
|
21863
21902
|
useSelected as useSelected8,
|
|
21864
21903
|
withHOC as withHOC8
|
|
21865
21904
|
} from "platejs/react";
|
|
21866
|
-
import { useRef as
|
|
21905
|
+
import { useRef as useRef20 } from "react";
|
|
21867
21906
|
|
|
21868
21907
|
// src/ui/table-icons.tsx
|
|
21869
21908
|
import { jsx as jsx181, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
@@ -22067,7 +22106,7 @@ var TableElement = withHOC8(
|
|
|
22067
22106
|
const isSelectionAreaVisible = usePluginOption22(BlockSelectionPlugin10, "isSelectionAreaVisible");
|
|
22068
22107
|
const hasControls = !readOnly && !isSelectionAreaVisible;
|
|
22069
22108
|
const { marginLeft, props: tableProps } = useTableElement();
|
|
22070
|
-
const tableRef =
|
|
22109
|
+
const tableRef = useRef20(null);
|
|
22071
22110
|
useTableSelectionDom(tableRef);
|
|
22072
22111
|
const isSelectingTable = useBlockSelected2(props.element.id);
|
|
22073
22112
|
const content = /* @__PURE__ */ jsx182(
|
|
@@ -26991,16 +27030,16 @@ var createViewerPlugins = (features = DEFAULT_FEATURES) => {
|
|
|
26991
27030
|
};
|
|
26992
27031
|
|
|
26993
27032
|
// src/components/editor/use-typed-conversion-options.ts
|
|
26994
|
-
import { useLayoutEffect as
|
|
27033
|
+
import { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
26995
27034
|
var useTypedConversionOptions = (editor, features) => {
|
|
26996
27035
|
const { markShortcuts, textSubstitutions } = features;
|
|
26997
|
-
|
|
27036
|
+
useLayoutEffect4(() => {
|
|
26998
27037
|
editor.setOptions(TypedConversionPlugin, resolveTypedConversionOptions({ markShortcuts, textSubstitutions }));
|
|
26999
27038
|
}, [editor, markShortcuts, textSubstitutions]);
|
|
27000
27039
|
};
|
|
27001
27040
|
|
|
27002
27041
|
// src/ui/toc-sidebar.tsx
|
|
27003
|
-
import { useEffect as
|
|
27042
|
+
import { useEffect as useEffect67, useRef as useRef31 } from "react";
|
|
27004
27043
|
import { jsx as jsx228, jsxs as jsxs156 } from "react/jsx-runtime";
|
|
27005
27044
|
var depthStyles = {
|
|
27006
27045
|
1: "font-medium",
|
|
@@ -27009,8 +27048,8 @@ var depthStyles = {
|
|
|
27009
27048
|
};
|
|
27010
27049
|
var EditorTocSidebar = ({ className, maxShowCount = 20 }) => {
|
|
27011
27050
|
const tocContext = useEditorToc();
|
|
27012
|
-
const observerRef =
|
|
27013
|
-
const headingElementsRef =
|
|
27051
|
+
const observerRef = useRef31(null);
|
|
27052
|
+
const headingElementsRef = useRef31(/* @__PURE__ */ new Map());
|
|
27014
27053
|
const handleTocClick = (e, heading) => {
|
|
27015
27054
|
e.preventDefault();
|
|
27016
27055
|
if (tocContext) {
|
|
@@ -27024,7 +27063,7 @@ var EditorTocSidebar = ({ className, maxShowCount = 20 }) => {
|
|
|
27024
27063
|
window.history.pushState(null, "", `#${heading.id}`);
|
|
27025
27064
|
}
|
|
27026
27065
|
};
|
|
27027
|
-
|
|
27066
|
+
useEffect67(() => {
|
|
27028
27067
|
if (!tocContext || tocContext.headingList.length === 0) return;
|
|
27029
27068
|
const { headingList: headingList2, setActiveContentId } = tocContext;
|
|
27030
27069
|
const getActiveHeading = () => {
|
|
@@ -27156,7 +27195,7 @@ var WebEditor = (props) => {
|
|
|
27156
27195
|
theme = "editor"
|
|
27157
27196
|
} = props;
|
|
27158
27197
|
const menuFeatures = useMemo28(() => withUnloadedFeaturesOff(features), [features]);
|
|
27159
|
-
const portalContainerRef =
|
|
27198
|
+
const portalContainerRef = useRef32(null);
|
|
27160
27199
|
const isReadOnlyVariant = READ_ONLY_VARIANTS.includes(variant);
|
|
27161
27200
|
const useStaticViewer = isReadOnlyVariant;
|
|
27162
27201
|
const staticViewerValue = useMemo28(() => {
|
|
@@ -27185,7 +27224,7 @@ var WebEditor = (props) => {
|
|
|
27185
27224
|
},
|
|
27186
27225
|
[collab]
|
|
27187
27226
|
);
|
|
27188
|
-
const isCollabInitializedRef =
|
|
27227
|
+
const isCollabInitializedRef = useRef32(false);
|
|
27189
27228
|
useEditorMaxFileSize(editor, upload == null ? void 0 : upload.maxFileSize, upload == null ? void 0 : upload.acceptedFileTypes);
|
|
27190
27229
|
useTypedConversionOptions(editor, features);
|
|
27191
27230
|
const handleCollabInitialized = useCallback89((isInitialized) => {
|
|
@@ -27205,7 +27244,7 @@ var WebEditor = (props) => {
|
|
|
27205
27244
|
const handleBlur = useCallback89(() => {
|
|
27206
27245
|
onBlur == null ? void 0 : onBlur();
|
|
27207
27246
|
}, [onBlur]);
|
|
27208
|
-
|
|
27247
|
+
useEffect68(() => {
|
|
27209
27248
|
onEditorReady == null ? void 0 : onEditorReady(editor);
|
|
27210
27249
|
}, [editor, onEditorReady]);
|
|
27211
27250
|
if (useStaticViewer && viewerEditor) {
|
|
@@ -27273,7 +27312,7 @@ function StaticViewerWithToc({
|
|
|
27273
27312
|
const tocContext = useEditorToc();
|
|
27274
27313
|
const setHeadingList = tocContext == null ? void 0 : tocContext.setHeadingList;
|
|
27275
27314
|
const { headings, slugMap } = useMemo28(() => extractHeadingsFromValue(initialValue), [initialValue]);
|
|
27276
|
-
|
|
27315
|
+
useEffect68(() => {
|
|
27277
27316
|
if (!showToc || !features.toc || !setHeadingList) return;
|
|
27278
27317
|
setHeadingList(headings);
|
|
27279
27318
|
}, [headings, showToc, features.toc, setHeadingList]);
|