@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
|
@@ -12859,11 +12859,49 @@ import { filterWords } from "@platejs/combobox";
|
|
|
12859
12859
|
import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
|
|
12860
12860
|
import { cva as cva22 } from "class-variance-authority";
|
|
12861
12861
|
import { useComposedRef as useComposedRef2, useEditorRef as useEditorRef20 } from "platejs/react";
|
|
12862
|
-
import React37, { useEffect as
|
|
12862
|
+
import React37, { useEffect as useEffect32 } from "react";
|
|
12863
|
+
|
|
12864
|
+
// src/hooks/use-return-focus-to-editor-on-input-removal.ts
|
|
12865
|
+
import { useEffect as useEffect30, useLayoutEffect as useLayoutEffect2, useRef as useRef12 } from "react";
|
|
12866
|
+
var focusEditableAtEditorSelection = (editor) => {
|
|
12867
|
+
const editable = editor.api.toDOMNode(editor);
|
|
12868
|
+
if (!(editable == null ? void 0 : editable.isConnected)) {
|
|
12869
|
+
return;
|
|
12870
|
+
}
|
|
12871
|
+
const document2 = editable.ownerDocument;
|
|
12872
|
+
const activeElement = document2.activeElement;
|
|
12873
|
+
if (activeElement && activeElement !== document2.body) {
|
|
12874
|
+
return;
|
|
12875
|
+
}
|
|
12876
|
+
const domRange = editor.selection ? editor.api.toDOMRange(editor.selection) : void 0;
|
|
12877
|
+
editable.focus({ preventScroll: true });
|
|
12878
|
+
const domSelection = document2.getSelection();
|
|
12879
|
+
if (domRange && domSelection) {
|
|
12880
|
+
domSelection.removeAllRanges();
|
|
12881
|
+
domSelection.addRange(domRange);
|
|
12882
|
+
}
|
|
12883
|
+
};
|
|
12884
|
+
var useReturnFocusToEditorOnInputRemoval = (editor, inputRef) => {
|
|
12885
|
+
const inputHadFocusWhenRemoved = useRef12(false);
|
|
12886
|
+
useLayoutEffect2(() => {
|
|
12887
|
+
const input = inputRef.current;
|
|
12888
|
+
return () => {
|
|
12889
|
+
inputHadFocusWhenRemoved.current = !!input && input.ownerDocument.activeElement === input;
|
|
12890
|
+
};
|
|
12891
|
+
}, [inputRef]);
|
|
12892
|
+
useEffect30(
|
|
12893
|
+
() => () => {
|
|
12894
|
+
if (inputHadFocusWhenRemoved.current) {
|
|
12895
|
+
focusEditableAtEditorSelection(editor);
|
|
12896
|
+
}
|
|
12897
|
+
},
|
|
12898
|
+
[editor]
|
|
12899
|
+
);
|
|
12900
|
+
};
|
|
12863
12901
|
|
|
12864
12902
|
// src/hooks/use-shield-input-selection-from-editor.ts
|
|
12865
12903
|
import { RangeApi as RangeApi2 } from "platejs";
|
|
12866
|
-
import { useEffect as
|
|
12904
|
+
import { useEffect as useEffect31 } from "react";
|
|
12867
12905
|
var SLATE_TEXT_SELECTOR = "[data-slate-string], [data-slate-zero-width]";
|
|
12868
12906
|
var isCaretInEditorText = (node) => {
|
|
12869
12907
|
var _a;
|
|
@@ -12881,7 +12919,7 @@ var wouldPullCaretOutOfInput = (editor, input) => {
|
|
|
12881
12919
|
return !!range && RangeApi2.equals(range, editor.selection);
|
|
12882
12920
|
};
|
|
12883
12921
|
var useShieldInputSelectionFromEditor = (editor, inputRef) => {
|
|
12884
|
-
|
|
12922
|
+
useEffect31(() => {
|
|
12885
12923
|
const input = inputRef.current;
|
|
12886
12924
|
const view = input == null ? void 0 : input.ownerDocument.defaultView;
|
|
12887
12925
|
if (!input || !view) {
|
|
@@ -12945,7 +12983,7 @@ function InlineCombobox({
|
|
|
12945
12983
|
[setValueProp, hasValueProp]
|
|
12946
12984
|
);
|
|
12947
12985
|
const insertPoint = React37.useRef(null);
|
|
12948
|
-
|
|
12986
|
+
useEffect32(() => {
|
|
12949
12987
|
const path = editor.api.findPath(element);
|
|
12950
12988
|
if (!path) return;
|
|
12951
12989
|
const point = editor.api.before(path);
|
|
@@ -13011,6 +13049,7 @@ function InlineComboboxInput(_a) {
|
|
|
13011
13049
|
const editor = useEditorRef20();
|
|
13012
13050
|
const ref = useComposedRef2(refProp, contextRef);
|
|
13013
13051
|
useShieldInputSelectionFromEditor(editor, contextRef);
|
|
13052
|
+
useReturnFocusToEditorOnInputRemoval(editor, contextRef);
|
|
13014
13053
|
return /* @__PURE__ */ jsxs60(Fragment15, { children: [
|
|
13015
13054
|
showTrigger && trigger,
|
|
13016
13055
|
/* @__PURE__ */ jsxs60("span", { className: "relative min-h-lh", children: [
|
|
@@ -13110,7 +13149,7 @@ function InlineComboboxEmpty({ children, className }) {
|
|
|
13110
13149
|
const { setHasEmpty } = React37.useContext(InlineComboboxContext);
|
|
13111
13150
|
const store = Ariakit2.useComboboxContext();
|
|
13112
13151
|
const items = (_a = store == null ? void 0 : store.useState("items")) != null ? _a : [];
|
|
13113
|
-
|
|
13152
|
+
useEffect32(() => {
|
|
13114
13153
|
setHasEmpty(true);
|
|
13115
13154
|
return () => {
|
|
13116
13155
|
setHasEmpty(false);
|
|
@@ -13270,11 +13309,11 @@ import { ArrowUpRightIcon as ArrowUpRightIcon3, PencilIcon as PencilIcon5, Trash
|
|
|
13270
13309
|
|
|
13271
13310
|
// src/ui/smart-link-copy-button.tsx
|
|
13272
13311
|
import { CheckIcon as CheckIcon12, CopyIcon, XIcon as XIcon6 } from "lucide-react";
|
|
13273
|
-
import { useCallback as useCallback24, useEffect as
|
|
13312
|
+
import { useCallback as useCallback24, useEffect as useEffect33, useState as useState25 } from "react";
|
|
13274
13313
|
import { jsx as jsx108 } from "react/jsx-runtime";
|
|
13275
13314
|
function SmartLinkCopyButton({ disabled, onCopy }) {
|
|
13276
13315
|
const [feedback, setFeedback] = useState25("idle");
|
|
13277
|
-
|
|
13316
|
+
useEffect33(() => {
|
|
13278
13317
|
if (feedback === "idle") return;
|
|
13279
13318
|
const timeoutId = window.setTimeout(() => {
|
|
13280
13319
|
setFeedback("idle");
|
|
@@ -13619,12 +13658,12 @@ var PlainLinkElement = (props) => /* @__PURE__ */ jsx111(LinkElement, __spreadPr
|
|
|
13619
13658
|
|
|
13620
13659
|
// src/ui/link-toolbar.tsx
|
|
13621
13660
|
import { useEditorPlugin as useEditorPlugin12, useEditorSelector as useEditorSelector2, usePluginOption as usePluginOption17 } from "platejs/react";
|
|
13622
|
-
import { useCallback as useCallback29, useEffect as
|
|
13661
|
+
import { useCallback as useCallback29, useEffect as useEffect36, useState as useState29 } from "react";
|
|
13623
13662
|
|
|
13624
13663
|
// src/ui/link-search-panel.tsx
|
|
13625
13664
|
import { BookmarkIcon, LinkIcon as LinkIcon3 } from "lucide-react";
|
|
13626
13665
|
import { useEditorPlugin as useEditorPlugin10 } from "platejs/react";
|
|
13627
|
-
import { useCallback as useCallback27, useEffect as
|
|
13666
|
+
import { useCallback as useCallback27, useEffect as useEffect34, useState as useState27 } from "react";
|
|
13628
13667
|
|
|
13629
13668
|
// src/ui/link-toolbar-shared.ts
|
|
13630
13669
|
import { unwrapLink as unwrapLink2, upsertLink } from "@platejs/link";
|
|
@@ -13775,7 +13814,7 @@ function LinkSearchPanel({ initialUrl }) {
|
|
|
13775
13814
|
const safeUrl = trimmedQuery.length > 0 ? getSafeSmartLinkUrl(trimmedQuery) : null;
|
|
13776
13815
|
const searchTerm = isLikelySmartLinkUrl(query) ? "" : trimmedQuery;
|
|
13777
13816
|
const debouncedSearch = useDebounce(searchTerm, 200);
|
|
13778
|
-
|
|
13817
|
+
useEffect34(() => {
|
|
13779
13818
|
if (!canLinkPage) {
|
|
13780
13819
|
setPages([]);
|
|
13781
13820
|
setIsLoading(false);
|
|
@@ -13914,7 +13953,7 @@ import { CursorOverlayPlugin as CursorOverlayPlugin2 } from "@platejs/selection/
|
|
|
13914
13953
|
import { LinkIcon as LinkIcon4, Trash2Icon as Trash2Icon2 } from "lucide-react";
|
|
13915
13954
|
import { NodeApi as NodeApi15 } from "platejs";
|
|
13916
13955
|
import { useEditorPlugin as useEditorPlugin11, usePluginOption as usePluginOption16 } from "platejs/react";
|
|
13917
|
-
import { useCallback as useCallback28, useEffect as
|
|
13956
|
+
import { useCallback as useCallback28, useEffect as useEffect35, useState as useState28 } from "react";
|
|
13918
13957
|
import { jsx as jsx113, jsxs as jsxs66 } from "react/jsx-runtime";
|
|
13919
13958
|
function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
|
|
13920
13959
|
const [url, setUrl] = useState28(initialUrl);
|
|
@@ -13923,7 +13962,7 @@ function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
|
|
|
13923
13962
|
const { editor, setOption } = useEditorPlugin11(linkPlugin);
|
|
13924
13963
|
const activeLinkId = usePluginOption16(linkPlugin, "activeId");
|
|
13925
13964
|
const editingLinkEntry = useActiveLink();
|
|
13926
|
-
|
|
13965
|
+
useEffect35(() => {
|
|
13927
13966
|
var _a;
|
|
13928
13967
|
if (!editingLinkEntry) return;
|
|
13929
13968
|
setText(NodeApi15.string(editingLinkEntry[0]));
|
|
@@ -14047,10 +14086,10 @@ function LinkFloatingToolbar() {
|
|
|
14047
14086
|
const aboveUrl = (_a = aboveLink == null ? void 0 : aboveLink.url) != null ? _a : "";
|
|
14048
14087
|
const [initialUrl, setInitialUrl] = useState29(aboveUrl);
|
|
14049
14088
|
const open = mode === "insert" || mode === "edit" || mode === "cursor";
|
|
14050
|
-
|
|
14089
|
+
useEffect36(() => {
|
|
14051
14090
|
setInitialUrl(aboveUrl);
|
|
14052
14091
|
}, [aboveUrl]);
|
|
14053
|
-
|
|
14092
|
+
useEffect36(() => {
|
|
14054
14093
|
if (aboveLink) {
|
|
14055
14094
|
const timeoutId = window.setTimeout(() => {
|
|
14056
14095
|
var _a2;
|
|
@@ -14631,7 +14670,7 @@ import {
|
|
|
14631
14670
|
useReadOnly as useReadOnly12,
|
|
14632
14671
|
useSelected as useSelected3
|
|
14633
14672
|
} from "platejs/react";
|
|
14634
|
-
import React40, { useEffect as
|
|
14673
|
+
import React40, { useEffect as useEffect37 } from "react";
|
|
14635
14674
|
import { jsx as jsx128, jsxs as jsxs72 } from "react/jsx-runtime";
|
|
14636
14675
|
function EquationElement(props) {
|
|
14637
14676
|
const element = useElement9();
|
|
@@ -14692,7 +14731,7 @@ function InlineEquationElement(props) {
|
|
|
14692
14731
|
const selected = useSelected3();
|
|
14693
14732
|
const isCollapsed = useEditorSelector5((editor) => editor.api.isCollapsed(), []);
|
|
14694
14733
|
const [open, setOpen] = React40.useState(selected && isCollapsed);
|
|
14695
|
-
|
|
14734
|
+
useEffect37(() => {
|
|
14696
14735
|
if (selected && isCollapsed) {
|
|
14697
14736
|
setOpen(true);
|
|
14698
14737
|
}
|
|
@@ -14772,7 +14811,7 @@ function EquationPopoverContent(_a) {
|
|
|
14772
14811
|
const editor = useEditorRef28();
|
|
14773
14812
|
const readOnly = useReadOnly12();
|
|
14774
14813
|
const element = useElement9();
|
|
14775
|
-
|
|
14814
|
+
useEffect37(() => {
|
|
14776
14815
|
if (isInline && open) {
|
|
14777
14816
|
setOpen(true);
|
|
14778
14817
|
}
|
|
@@ -15617,7 +15656,7 @@ import { useDraggable as useDraggable2 } from "@platejs/dnd";
|
|
|
15617
15656
|
import { PlaceholderPlugin as PlaceholderPlugin2, useImage, useMediaState as useMediaState4 } from "@platejs/media/react";
|
|
15618
15657
|
import { ResizableProvider as ResizableProvider5 } from "@platejs/resizable";
|
|
15619
15658
|
import { PlateElement as PlateElement21, useEditorPlugin as useEditorPlugin16, withHOC as withHOC5 } from "platejs/react";
|
|
15620
|
-
import React45, { useEffect as
|
|
15659
|
+
import React45, { useEffect as useEffect39, useMemo as useMemo15 } from "react";
|
|
15621
15660
|
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
15622
15661
|
import { jsx as jsx139, jsxs as jsxs81 } from "react/jsx-runtime";
|
|
15623
15662
|
var ImageElement = withHOC5(
|
|
@@ -15758,7 +15797,7 @@ var ImageElement = withHOC5(
|
|
|
15758
15797
|
);
|
|
15759
15798
|
var ImagePlaceholder = ({ file }) => {
|
|
15760
15799
|
const objectUrl = useMemo15(() => file ? URL.createObjectURL(file) : null, [file]);
|
|
15761
|
-
|
|
15800
|
+
useEffect39(() => {
|
|
15762
15801
|
if (!objectUrl) return;
|
|
15763
15802
|
return () => URL.revokeObjectURL(objectUrl);
|
|
15764
15803
|
}, [objectUrl]);
|
|
@@ -15776,7 +15815,7 @@ import {
|
|
|
15776
15815
|
import { AudioLinesIcon, FileUpIcon as FileUpIcon2, FilmIcon, ImageIcon } from "lucide-react";
|
|
15777
15816
|
import { KEYS as KEYS29, nanoid as nanoid7 } from "platejs";
|
|
15778
15817
|
import { PlateElement as PlateElement22, useEditorPlugin as useEditorPlugin17, withHOC as withHOC6 } from "platejs/react";
|
|
15779
|
-
import { useCallback as useCallback40, useEffect as
|
|
15818
|
+
import { useCallback as useCallback40, useEffect as useEffect40, useRef as useRef13, useState as useState33 } from "react";
|
|
15780
15819
|
import { useFilePicker } from "use-file-picker";
|
|
15781
15820
|
|
|
15782
15821
|
// src/hooks/use-upload-file.ts
|
|
@@ -15950,8 +15989,8 @@ var PlaceholderElement = withHOC6(PlaceholderProvider, (props) => {
|
|
|
15950
15989
|
const isImage = mediaType === KEYS29.img;
|
|
15951
15990
|
const file = updatedFiles == null ? void 0 : updatedFiles[0];
|
|
15952
15991
|
const progress = file ? progresses == null ? void 0 : progresses[file.name] : void 0;
|
|
15953
|
-
const imageRef =
|
|
15954
|
-
|
|
15992
|
+
const imageRef = useRef13(null);
|
|
15993
|
+
useEffect40(() => {
|
|
15955
15994
|
if (!imageRef.current) return;
|
|
15956
15995
|
const { height, width } = imageRef.current;
|
|
15957
15996
|
setSize == null ? void 0 : setSize({
|
|
@@ -16052,15 +16091,15 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
16052
16091
|
}
|
|
16053
16092
|
}
|
|
16054
16093
|
});
|
|
16055
|
-
const isReplaced =
|
|
16056
|
-
|
|
16094
|
+
const isReplaced = useRef13(false);
|
|
16095
|
+
useEffect40(() => {
|
|
16057
16096
|
if (isReplaced.current) return;
|
|
16058
16097
|
isReplaced.current = true;
|
|
16059
16098
|
const currentFiles = api.placeholder.getUploadingFile(element.id);
|
|
16060
16099
|
if (!currentFiles) return;
|
|
16061
16100
|
replaceCurrentPlaceholder(currentFiles);
|
|
16062
16101
|
}, [isReplaced]);
|
|
16063
|
-
|
|
16102
|
+
useEffect40(() => {
|
|
16064
16103
|
if (!uploadedFile) return;
|
|
16065
16104
|
const path = editor.api.findPath(element);
|
|
16066
16105
|
setMediaNode(
|
|
@@ -16093,15 +16132,15 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
16093
16132
|
},
|
|
16094
16133
|
[editor, element, mediaType]
|
|
16095
16134
|
);
|
|
16096
|
-
|
|
16135
|
+
useEffect40(() => {
|
|
16097
16136
|
setOpen(selected);
|
|
16098
16137
|
}, [selected, setOpen]);
|
|
16099
|
-
|
|
16138
|
+
useEffect40(() => {
|
|
16100
16139
|
if (isUploading) {
|
|
16101
16140
|
setOpen(false);
|
|
16102
16141
|
}
|
|
16103
16142
|
}, [isUploading]);
|
|
16104
|
-
|
|
16143
|
+
useEffect40(() => {
|
|
16105
16144
|
var _a2;
|
|
16106
16145
|
setProgresses({ [(_a2 = uploadingFile == null ? void 0 : uploadingFile.name) != null ? _a2 : ""]: progress });
|
|
16107
16146
|
setIsUploading(isUploading);
|
|
@@ -16135,7 +16174,7 @@ function ImageProgress({
|
|
|
16135
16174
|
progress = 0
|
|
16136
16175
|
}) {
|
|
16137
16176
|
const [objectUrl, setObjectUrl] = useState33(null);
|
|
16138
|
-
|
|
16177
|
+
useEffect40(() => {
|
|
16139
16178
|
const url = URL.createObjectURL(file);
|
|
16140
16179
|
setObjectUrl(url);
|
|
16141
16180
|
return () => {
|
|
@@ -16294,13 +16333,13 @@ function ImagePreview() {
|
|
|
16294
16333
|
// src/ui/media-upload-toast.tsx
|
|
16295
16334
|
import { PlaceholderPlugin as PlaceholderPlugin5, UploadErrorCode } from "@platejs/media/react";
|
|
16296
16335
|
import { usePluginOption as usePluginOption21 } from "platejs/react";
|
|
16297
|
-
import { useEffect as
|
|
16336
|
+
import { useEffect as useEffect41 } from "react";
|
|
16298
16337
|
import { toast as toast4 } from "sonner";
|
|
16299
16338
|
|
|
16300
16339
|
// src/ui/use-placeholder-max-file-size.ts
|
|
16301
16340
|
import { PlaceholderPlugin as PlaceholderPlugin4 } from "@platejs/media/react";
|
|
16302
16341
|
import { useEditorRef as useEditorRef34 } from "platejs/react";
|
|
16303
|
-
import { useLayoutEffect as
|
|
16342
|
+
import { useLayoutEffect as useLayoutEffect3 } from "react";
|
|
16304
16343
|
var PLACEHOLDER_FILE_KIND_PATTERNS = {
|
|
16305
16344
|
audio: "audio/*",
|
|
16306
16345
|
blob: "*",
|
|
@@ -16333,7 +16372,7 @@ var acceptedFileTypesFromKey = (key) => {
|
|
|
16333
16372
|
};
|
|
16334
16373
|
var useEditorMaxFileSize = (editor, maxFileSize, acceptedFileTypes) => {
|
|
16335
16374
|
const acceptedFileTypesKey = acceptedFileTypes == null ? void 0 : acceptedFileTypes.join(FILE_TYPE_KEY_SEPARATOR);
|
|
16336
|
-
|
|
16375
|
+
useLayoutEffect3(() => {
|
|
16337
16376
|
var _a;
|
|
16338
16377
|
const previous = EDITOR_UPLOAD_CONFIGS.get(editor);
|
|
16339
16378
|
if (maxFileSize === void 0 && acceptedFileTypesKey === void 0) {
|
|
@@ -16372,7 +16411,7 @@ function MediaUploadToast() {
|
|
|
16372
16411
|
}
|
|
16373
16412
|
var useUploadErrorToast = () => {
|
|
16374
16413
|
const uploadError = usePluginOption21(PlaceholderPlugin5, "error");
|
|
16375
|
-
|
|
16414
|
+
useEffect41(() => {
|
|
16376
16415
|
if (!uploadError) return;
|
|
16377
16416
|
const { code, data } = uploadError;
|
|
16378
16417
|
switch (code) {
|
|
@@ -16835,13 +16874,13 @@ import { useCallback as useCallback44, useState as useState38 } from "react";
|
|
|
16835
16874
|
|
|
16836
16875
|
// src/ui/mention-page-combobox-group.tsx
|
|
16837
16876
|
import { FileTextIcon as FileTextIcon3 } from "lucide-react";
|
|
16838
|
-
import { useEffect as
|
|
16877
|
+
import { useEffect as useEffect42, useState as useState36 } from "react";
|
|
16839
16878
|
import { jsx as jsx146, jsxs as jsxs87 } from "react/jsx-runtime";
|
|
16840
16879
|
function PageComboboxGroup({ search, onPageHover, onPageSelect }) {
|
|
16841
16880
|
const adapter = useEditorAdapter();
|
|
16842
16881
|
const debouncedSearch = useDebounce(search, 250);
|
|
16843
16882
|
const [pages, setPages] = useState36([]);
|
|
16844
|
-
|
|
16883
|
+
useEffect42(() => {
|
|
16845
16884
|
if (!adapter.permissions.canLinkPage) {
|
|
16846
16885
|
setPages([]);
|
|
16847
16886
|
return;
|
|
@@ -16890,13 +16929,13 @@ function PageStatusBadge({ status }) {
|
|
|
16890
16929
|
}
|
|
16891
16930
|
|
|
16892
16931
|
// src/ui/mention-people-combobox-group.tsx
|
|
16893
|
-
import { useEffect as
|
|
16932
|
+
import { useEffect as useEffect43, useState as useState37 } from "react";
|
|
16894
16933
|
import { jsx as jsx147, jsxs as jsxs88 } from "react/jsx-runtime";
|
|
16895
16934
|
function PeopleComboboxGroup({ search, onUserHover, onUserSelect }) {
|
|
16896
16935
|
const adapter = useEditorAdapter();
|
|
16897
16936
|
const debouncedSearch = useDebounce(search, 150);
|
|
16898
16937
|
const [members, setMembers] = useState37([]);
|
|
16899
|
-
|
|
16938
|
+
useEffect43(() => {
|
|
16900
16939
|
if (!adapter.permissions.canMention) {
|
|
16901
16940
|
setMembers([]);
|
|
16902
16941
|
return;
|
|
@@ -17651,7 +17690,7 @@ import {
|
|
|
17651
17690
|
useSelected as useSelected6,
|
|
17652
17691
|
withHOC as withHOC8
|
|
17653
17692
|
} from "platejs/react";
|
|
17654
|
-
import { useRef as
|
|
17693
|
+
import { useRef as useRef14 } from "react";
|
|
17655
17694
|
|
|
17656
17695
|
// src/ui/table-icons.tsx
|
|
17657
17696
|
import { jsx as jsx150, jsxs as jsxs91 } from "react/jsx-runtime";
|
|
@@ -17855,7 +17894,7 @@ var TableElement = withHOC8(
|
|
|
17855
17894
|
const isSelectionAreaVisible = usePluginOption22(BlockSelectionPlugin10, "isSelectionAreaVisible");
|
|
17856
17895
|
const hasControls = !readOnly && !isSelectionAreaVisible;
|
|
17857
17896
|
const { marginLeft, props: tableProps } = useTableElement();
|
|
17858
|
-
const tableRef =
|
|
17897
|
+
const tableRef = useRef14(null);
|
|
17859
17898
|
useTableSelectionDom(tableRef);
|
|
17860
17899
|
const isSelectingTable = useBlockSelected2(props.element.id);
|
|
17861
17900
|
const content = /* @__PURE__ */ jsx151(
|
|
@@ -17296,11 +17296,49 @@ import { filterWords } from "@platejs/combobox";
|
|
|
17296
17296
|
import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
|
|
17297
17297
|
import { cva as cva26 } from "class-variance-authority";
|
|
17298
17298
|
import { useComposedRef as useComposedRef3, useEditorRef as useEditorRef29 } from "platejs/react";
|
|
17299
|
-
import React47, { useEffect as
|
|
17299
|
+
import React47, { useEffect as useEffect44 } from "react";
|
|
17300
|
+
|
|
17301
|
+
// src/hooks/use-return-focus-to-editor-on-input-removal.ts
|
|
17302
|
+
import { useEffect as useEffect42, useLayoutEffect as useLayoutEffect3, useRef as useRef16 } from "react";
|
|
17303
|
+
var focusEditableAtEditorSelection = (editor) => {
|
|
17304
|
+
const editable = editor.api.toDOMNode(editor);
|
|
17305
|
+
if (!(editable == null ? void 0 : editable.isConnected)) {
|
|
17306
|
+
return;
|
|
17307
|
+
}
|
|
17308
|
+
const document2 = editable.ownerDocument;
|
|
17309
|
+
const activeElement = document2.activeElement;
|
|
17310
|
+
if (activeElement && activeElement !== document2.body) {
|
|
17311
|
+
return;
|
|
17312
|
+
}
|
|
17313
|
+
const domRange = editor.selection ? editor.api.toDOMRange(editor.selection) : void 0;
|
|
17314
|
+
editable.focus({ preventScroll: true });
|
|
17315
|
+
const domSelection = document2.getSelection();
|
|
17316
|
+
if (domRange && domSelection) {
|
|
17317
|
+
domSelection.removeAllRanges();
|
|
17318
|
+
domSelection.addRange(domRange);
|
|
17319
|
+
}
|
|
17320
|
+
};
|
|
17321
|
+
var useReturnFocusToEditorOnInputRemoval = (editor, inputRef) => {
|
|
17322
|
+
const inputHadFocusWhenRemoved = useRef16(false);
|
|
17323
|
+
useLayoutEffect3(() => {
|
|
17324
|
+
const input = inputRef.current;
|
|
17325
|
+
return () => {
|
|
17326
|
+
inputHadFocusWhenRemoved.current = !!input && input.ownerDocument.activeElement === input;
|
|
17327
|
+
};
|
|
17328
|
+
}, [inputRef]);
|
|
17329
|
+
useEffect42(
|
|
17330
|
+
() => () => {
|
|
17331
|
+
if (inputHadFocusWhenRemoved.current) {
|
|
17332
|
+
focusEditableAtEditorSelection(editor);
|
|
17333
|
+
}
|
|
17334
|
+
},
|
|
17335
|
+
[editor]
|
|
17336
|
+
);
|
|
17337
|
+
};
|
|
17300
17338
|
|
|
17301
17339
|
// src/hooks/use-shield-input-selection-from-editor.ts
|
|
17302
17340
|
import { RangeApi as RangeApi2 } from "platejs";
|
|
17303
|
-
import { useEffect as
|
|
17341
|
+
import { useEffect as useEffect43 } from "react";
|
|
17304
17342
|
var SLATE_TEXT_SELECTOR = "[data-slate-string], [data-slate-zero-width]";
|
|
17305
17343
|
var isCaretInEditorText = (node) => {
|
|
17306
17344
|
var _a;
|
|
@@ -17318,7 +17356,7 @@ var wouldPullCaretOutOfInput = (editor, input) => {
|
|
|
17318
17356
|
return !!range && RangeApi2.equals(range, editor.selection);
|
|
17319
17357
|
};
|
|
17320
17358
|
var useShieldInputSelectionFromEditor = (editor, inputRef) => {
|
|
17321
|
-
|
|
17359
|
+
useEffect43(() => {
|
|
17322
17360
|
const input = inputRef.current;
|
|
17323
17361
|
const view = input == null ? void 0 : input.ownerDocument.defaultView;
|
|
17324
17362
|
if (!input || !view) {
|
|
@@ -17382,7 +17420,7 @@ function InlineCombobox({
|
|
|
17382
17420
|
[setValueProp, hasValueProp]
|
|
17383
17421
|
);
|
|
17384
17422
|
const insertPoint = React47.useRef(null);
|
|
17385
|
-
|
|
17423
|
+
useEffect44(() => {
|
|
17386
17424
|
const path = editor.api.findPath(element);
|
|
17387
17425
|
if (!path) return;
|
|
17388
17426
|
const point = editor.api.before(path);
|
|
@@ -17448,6 +17486,7 @@ function InlineComboboxInput(_a) {
|
|
|
17448
17486
|
const editor = useEditorRef29();
|
|
17449
17487
|
const ref = useComposedRef3(refProp, contextRef);
|
|
17450
17488
|
useShieldInputSelectionFromEditor(editor, contextRef);
|
|
17489
|
+
useReturnFocusToEditorOnInputRemoval(editor, contextRef);
|
|
17451
17490
|
return /* @__PURE__ */ jsxs86(Fragment21, { children: [
|
|
17452
17491
|
showTrigger && trigger,
|
|
17453
17492
|
/* @__PURE__ */ jsxs86("span", { className: "relative min-h-lh", children: [
|
|
@@ -17547,7 +17586,7 @@ function InlineComboboxEmpty({ children, className }) {
|
|
|
17547
17586
|
const { setHasEmpty } = React47.useContext(InlineComboboxContext);
|
|
17548
17587
|
const store = Ariakit2.useComboboxContext();
|
|
17549
17588
|
const items = (_a = store == null ? void 0 : store.useState("items")) != null ? _a : [];
|
|
17550
|
-
|
|
17589
|
+
useEffect44(() => {
|
|
17551
17590
|
setHasEmpty(true);
|
|
17552
17591
|
return () => {
|
|
17553
17592
|
setHasEmpty(false);
|
|
@@ -18332,13 +18371,13 @@ import { useCallback as useCallback46, useState as useState42 } from "react";
|
|
|
18332
18371
|
|
|
18333
18372
|
// src/ui/mention-page-combobox-group.tsx
|
|
18334
18373
|
import { FileTextIcon as FileTextIcon3 } from "lucide-react";
|
|
18335
|
-
import { useEffect as
|
|
18374
|
+
import { useEffect as useEffect45, useState as useState40 } from "react";
|
|
18336
18375
|
import { jsx as jsx155, jsxs as jsxs93 } from "react/jsx-runtime";
|
|
18337
18376
|
function PageComboboxGroup({ search, onPageHover, onPageSelect }) {
|
|
18338
18377
|
const adapter = useEditorAdapter();
|
|
18339
18378
|
const debouncedSearch = useDebounce(search, 250);
|
|
18340
18379
|
const [pages, setPages] = useState40([]);
|
|
18341
|
-
|
|
18380
|
+
useEffect45(() => {
|
|
18342
18381
|
if (!adapter.permissions.canLinkPage) {
|
|
18343
18382
|
setPages([]);
|
|
18344
18383
|
return;
|
|
@@ -18387,13 +18426,13 @@ function PageStatusBadge({ status }) {
|
|
|
18387
18426
|
}
|
|
18388
18427
|
|
|
18389
18428
|
// src/ui/mention-people-combobox-group.tsx
|
|
18390
|
-
import { useEffect as
|
|
18429
|
+
import { useEffect as useEffect46, useState as useState41 } from "react";
|
|
18391
18430
|
import { jsx as jsx156, jsxs as jsxs94 } from "react/jsx-runtime";
|
|
18392
18431
|
function PeopleComboboxGroup({ search, onUserHover, onUserSelect }) {
|
|
18393
18432
|
const adapter = useEditorAdapter();
|
|
18394
18433
|
const debouncedSearch = useDebounce(search, 150);
|
|
18395
18434
|
const [members, setMembers] = useState41([]);
|
|
18396
|
-
|
|
18435
|
+
useEffect46(() => {
|
|
18397
18436
|
if (!adapter.permissions.canMention) {
|
|
18398
18437
|
setMembers([]);
|
|
18399
18438
|
return;
|