@delali/web-editor 0.4.1 → 0.4.5
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 +17 -0
- package/README.md +3 -1
- package/dist/components/editor/collaboration/collaboration-starter.d.ts +5 -1
- package/dist/components/editor/create-editor-plugins.js +183 -124
- package/dist/components/editor/editor-base-kit.js +9 -18
- package/dist/components/editor/editor-kit.js +152 -93
- package/dist/components/editor/version-history/index.js +131 -72
- package/dist/components/editor/web-editor.d.ts +1 -1
- package/dist/components/editor/web-editor.js +2497 -2344
- package/dist/context/inspector-text-fields.d.ts +3 -0
- package/dist/context/text-field-attributes.d.ts +5 -0
- package/dist/hooks/use-return-focus-to-editor-on-input-removal.d.ts +3 -0
- package/dist/lib/markdown-utils.js +183 -124
- package/dist/styles.css +54 -20
- package/dist/types/editor.d.ts +2 -0
- package/dist/ui/icon-picker.d.ts +1 -1
- package/dist/ui/input.d.ts +1 -0
- package/dist/ui/media-file-display.d.ts +1 -0
- package/package.json +3 -3
|
@@ -294,7 +294,7 @@ var chunkDiffs = (blocks, { hasDiff: hasDiff2, paddingBlocks }) => {
|
|
|
294
294
|
import { computeDiff } from "@platejs/diff";
|
|
295
295
|
import { NodeApi as NodeApi14, TrailingBlockPlugin } from "platejs";
|
|
296
296
|
import { createPlateEditor, Plate as Plate2, usePlateEditor as usePlateEditor2 } from "platejs/react";
|
|
297
|
-
import { memo as memo2, useMemo as useMemo13, useState as
|
|
297
|
+
import { memo as memo2, useMemo as useMemo13, useState as useState33 } from "react";
|
|
298
298
|
|
|
299
299
|
// src/ui/editor.tsx
|
|
300
300
|
import { cva } from "class-variance-authority";
|
|
@@ -1450,7 +1450,7 @@ function SmartLinkInlineContent({ link, className }) {
|
|
|
1450
1450
|
"span",
|
|
1451
1451
|
{
|
|
1452
1452
|
className: cn2(
|
|
1453
|
-
"inline-flex max-w-full items-center gap-[0.2em] rounded-[0.25em] px-[0.4em] py-[0.1em] align-[-0.28em] font-medium text-
|
|
1453
|
+
"inline-flex max-w-full items-center gap-[0.2em] rounded-[0.25em] px-[0.4em] py-[0.1em] align-[-0.28em] font-medium text-editor-link leading-[1.3] outline outline-transparent transition-colors hover:bg-editor-link/5 hover:outline-editor-link/30",
|
|
1454
1454
|
className
|
|
1455
1455
|
),
|
|
1456
1456
|
children: [
|
|
@@ -1466,7 +1466,7 @@ function SmartLinkUrlContent({ link, className }) {
|
|
|
1466
1466
|
"span",
|
|
1467
1467
|
{
|
|
1468
1468
|
className: cn2(
|
|
1469
|
-
"inline max-w-full wrap-break-word border-
|
|
1469
|
+
"inline max-w-full wrap-break-word border-b border-editor-link/35 font-medium text-editor-link leading-[inherit] dark-or-inherit:border-editor-link/35!",
|
|
1470
1470
|
className
|
|
1471
1471
|
),
|
|
1472
1472
|
children: [
|
|
@@ -1498,7 +1498,7 @@ function SmartLinkCardContent({ link, className }) {
|
|
|
1498
1498
|
),
|
|
1499
1499
|
/* @__PURE__ */ jsxs6("span", { className: "min-w-0 flex-1", children: [
|
|
1500
1500
|
/* @__PURE__ */ jsxs6("span", { className: "flex min-w-0 items-start gap-3", children: [
|
|
1501
|
-
/* @__PURE__ */ jsx20("span", { className: "min-w-0 flex-1 truncate font-semibold text-
|
|
1501
|
+
/* @__PURE__ */ jsx20("span", { className: "min-w-0 flex-1 truncate font-semibold text-editor-link text-base leading-6", children: link.title }),
|
|
1502
1502
|
link.status ? /* @__PURE__ */ jsx20(SmartLinkStatus, { status: link.status }) : null
|
|
1503
1503
|
] }),
|
|
1504
1504
|
/* @__PURE__ */ jsxs6("span", { className: "mt-2 flex min-w-0 items-center gap-2 text-muted-foreground text-sm", children: [
|
|
@@ -1516,7 +1516,7 @@ function SmartLinkCardContent({ link, className }) {
|
|
|
1516
1516
|
{
|
|
1517
1517
|
faviconUrl: link.faviconUrl,
|
|
1518
1518
|
provider: link.provider,
|
|
1519
|
-
className: "size-5 rounded bg-
|
|
1519
|
+
className: "size-5 rounded bg-editor-link p-1 text-white dark-or-inherit:text-primary-foreground"
|
|
1520
1520
|
}
|
|
1521
1521
|
),
|
|
1522
1522
|
/* @__PURE__ */ jsx20("span", { className: "truncate", children: (_a = link.provider) != null ? _a : "Link" })
|
|
@@ -2079,6 +2079,7 @@ import { SlateElement as SlateElement13 } from "platejs/static";
|
|
|
2079
2079
|
// src/ui/media-file-display.ts
|
|
2080
2080
|
var FILE_DISPLAY_MODES = ["inline", "url", "embed"];
|
|
2081
2081
|
var DEFAULT_FILE_DISPLAY_MODE = "inline";
|
|
2082
|
+
var FILE_URL_CLASS_NAME = "inline-flex max-w-full items-center gap-1 break-all border-b border-editor-link/35 font-medium text-editor-link dark-or-inherit:border-editor-link/35!";
|
|
2082
2083
|
var normalizeFileDisplayMode = (value) => {
|
|
2083
2084
|
return value === "url" || value === "embed" || value === "inline" ? value : DEFAULT_FILE_DISPLAY_MODE;
|
|
2084
2085
|
};
|
|
@@ -2115,20 +2116,10 @@ function MediaFileStaticBody({ canEmbed, displayMode, name, url }) {
|
|
|
2115
2116
|
);
|
|
2116
2117
|
}
|
|
2117
2118
|
if (displayMode === "url") {
|
|
2118
|
-
return /* @__PURE__ */ jsxs12(
|
|
2119
|
-
"
|
|
2120
|
-
{
|
|
2121
|
-
|
|
2122
|
-
contentEditable: false,
|
|
2123
|
-
href: url,
|
|
2124
|
-
rel: "noopener noreferrer",
|
|
2125
|
-
target: "_blank",
|
|
2126
|
-
children: [
|
|
2127
|
-
/* @__PURE__ */ jsx27(Link, { className: "size-4 shrink-0 text-muted-foreground" }),
|
|
2128
|
-
/* @__PURE__ */ jsx27("span", { className: "truncate", children: url })
|
|
2129
|
-
]
|
|
2130
|
-
}
|
|
2131
|
-
);
|
|
2119
|
+
return /* @__PURE__ */ jsxs12("a", { className: FILE_URL_CLASS_NAME, contentEditable: false, href: url, rel: "noopener noreferrer", target: "_blank", children: [
|
|
2120
|
+
/* @__PURE__ */ jsx27(Link, { className: "size-4 shrink-0 text-muted-foreground" }),
|
|
2121
|
+
/* @__PURE__ */ jsx27("span", { className: "truncate", children: url })
|
|
2122
|
+
] });
|
|
2132
2123
|
}
|
|
2133
2124
|
return /* @__PURE__ */ jsx27(
|
|
2134
2125
|
"a",
|
|
@@ -6700,6 +6691,16 @@ var backgroundColorItems = [
|
|
|
6700
6691
|
|
|
6701
6692
|
// src/ui/input.tsx
|
|
6702
6693
|
import { cva as cva12 } from "class-variance-authority";
|
|
6694
|
+
|
|
6695
|
+
// src/context/text-field-attributes.ts
|
|
6696
|
+
import { createContext as createContext7, useContext as useContext7, useState as useState13 } from "react";
|
|
6697
|
+
var EMPTY_ATTRIBUTES = Object.freeze({});
|
|
6698
|
+
var TextFieldAttributesContext = createContext7(EMPTY_ATTRIBUTES);
|
|
6699
|
+
function useTextFieldAttributes() {
|
|
6700
|
+
return useContext7(TextFieldAttributesContext);
|
|
6701
|
+
}
|
|
6702
|
+
|
|
6703
|
+
// src/ui/input.tsx
|
|
6703
6704
|
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
6704
6705
|
var inputVariants = cva12(
|
|
6705
6706
|
cn2(
|
|
@@ -6721,9 +6722,16 @@ var inputVariants = cva12(
|
|
|
6721
6722
|
}
|
|
6722
6723
|
}
|
|
6723
6724
|
);
|
|
6725
|
+
var TEXT_INPUT_TYPES = /* @__PURE__ */ new Set(["text", "search", "url", "email", "tel", "password"]);
|
|
6726
|
+
function UnstyledInput(_a) {
|
|
6727
|
+
var _b = _a, { type = "text" } = _b, props = __objRest(_b, ["type"]);
|
|
6728
|
+
const attributes = useTextFieldAttributes();
|
|
6729
|
+
const textFieldAttributes = TEXT_INPUT_TYPES.has(type.toLowerCase()) ? attributes : void 0;
|
|
6730
|
+
return /* @__PURE__ */ jsx55("input", __spreadValues(__spreadProps(__spreadValues({}, textFieldAttributes), { type }), props));
|
|
6731
|
+
}
|
|
6724
6732
|
function Input(_a) {
|
|
6725
6733
|
var _b = _a, { className, variant } = _b, props = __objRest(_b, ["className", "variant"]);
|
|
6726
|
-
return /* @__PURE__ */ jsx55(
|
|
6734
|
+
return /* @__PURE__ */ jsx55(UnstyledInput, __spreadValues({ className: cn2(inputVariants({ variant }), className) }, props));
|
|
6727
6735
|
}
|
|
6728
6736
|
|
|
6729
6737
|
// src/ui/menu.tsx
|
|
@@ -8115,6 +8123,7 @@ function CommandInput(_a) {
|
|
|
8115
8123
|
"variant",
|
|
8116
8124
|
"wrapClassName"
|
|
8117
8125
|
]);
|
|
8126
|
+
const attributes = useTextFieldAttributes();
|
|
8118
8127
|
return /* @__PURE__ */ jsx66(
|
|
8119
8128
|
"div",
|
|
8120
8129
|
{
|
|
@@ -8123,10 +8132,10 @@ function CommandInput(_a) {
|
|
|
8123
8132
|
"data-slot": "command-input-wrapper",
|
|
8124
8133
|
children: /* @__PURE__ */ jsx66(
|
|
8125
8134
|
CommandPrimitive.Input,
|
|
8126
|
-
__spreadValues({
|
|
8135
|
+
__spreadValues(__spreadProps(__spreadValues({}, attributes), {
|
|
8127
8136
|
className: cn2(inputVariants({ variant }), className),
|
|
8128
8137
|
"data-slot": "command-input"
|
|
8129
|
-
}, props)
|
|
8138
|
+
}), props)
|
|
8130
8139
|
)
|
|
8131
8140
|
}
|
|
8132
8141
|
);
|
|
@@ -9900,15 +9909,14 @@ function EmojiPickerSearchBar({
|
|
|
9900
9909
|
}) {
|
|
9901
9910
|
return /* @__PURE__ */ jsx83("div", { className: "flex items-center px-2", children: /* @__PURE__ */ jsxs47("div", { className: "relative flex grow items-center", children: [
|
|
9902
9911
|
/* @__PURE__ */ jsx83(
|
|
9903
|
-
|
|
9912
|
+
UnstyledInput,
|
|
9904
9913
|
{
|
|
9905
9914
|
className: "block w-full appearance-none rounded-full border-0 bg-muted px-10 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:outline-none",
|
|
9906
9915
|
value: searchValue,
|
|
9907
9916
|
onChange: (event) => setSearch(event.target.value),
|
|
9908
9917
|
placeholder: i18n.search,
|
|
9909
9918
|
"aria-label": "Search",
|
|
9910
|
-
autoComplete: "off"
|
|
9911
|
-
type: "text"
|
|
9919
|
+
autoComplete: "off"
|
|
9912
9920
|
}
|
|
9913
9921
|
),
|
|
9914
9922
|
children
|
|
@@ -10682,7 +10690,7 @@ import { useLink } from "@platejs/link/react";
|
|
|
10682
10690
|
import { SuggestionPlugin as SuggestionPlugin3 } from "@platejs/suggestion/react";
|
|
10683
10691
|
import { NodeApi as NodeApi11 } from "platejs";
|
|
10684
10692
|
import { PlateElement as PlateElement10, useEditorPlugin as useEditorPlugin9, useElement as useElement3, useReadOnly as useReadOnly5 } from "platejs/react";
|
|
10685
|
-
import { useCallback as useCallback22, useMemo as useMemo11, useState as
|
|
10693
|
+
import { useCallback as useCallback22, useMemo as useMemo11, useState as useState23 } from "react";
|
|
10686
10694
|
|
|
10687
10695
|
// src/ui/smart-link-clipboard.ts
|
|
10688
10696
|
var copySmartLinkUrl = async (url) => {
|
|
@@ -10720,10 +10728,10 @@ import { ArrowUpRightIcon as ArrowUpRightIcon3, PencilIcon as PencilIcon4, Trash
|
|
|
10720
10728
|
|
|
10721
10729
|
// src/ui/smart-link-copy-button.tsx
|
|
10722
10730
|
import { CheckIcon as CheckIcon10, CopyIcon, XIcon as XIcon6 } from "lucide-react";
|
|
10723
|
-
import { useCallback as useCallback20, useEffect as useEffect21, useState as
|
|
10731
|
+
import { useCallback as useCallback20, useEffect as useEffect21, useState as useState22 } from "react";
|
|
10724
10732
|
import { jsx as jsx90 } from "react/jsx-runtime";
|
|
10725
10733
|
function SmartLinkCopyButton({ disabled, onCopy }) {
|
|
10726
|
-
const [feedback, setFeedback] =
|
|
10734
|
+
const [feedback, setFeedback] = useState22("idle");
|
|
10727
10735
|
useEffect21(() => {
|
|
10728
10736
|
if (feedback === "idle") return;
|
|
10729
10737
|
const timeoutId = window.setTimeout(() => {
|
|
@@ -10891,8 +10899,8 @@ function LinkElement(_a) {
|
|
|
10891
10899
|
const { api, editor, setOption } = useEditorPlugin9(linkPlugin);
|
|
10892
10900
|
const adapter = useEditorAdapter();
|
|
10893
10901
|
const readOnly = useReadOnly5();
|
|
10894
|
-
const [isToolbarOpen, setIsToolbarOpen] =
|
|
10895
|
-
const [isModeMenuOpen, setIsModeMenuOpen] =
|
|
10902
|
+
const [isToolbarOpen, setIsToolbarOpen] = useState23(false);
|
|
10903
|
+
const [isModeMenuOpen, setIsModeMenuOpen] = useState23(false);
|
|
10896
10904
|
const displayMode = normalizeSmartLinkDisplayMode(element.displayMode);
|
|
10897
10905
|
const open = !readOnly && (isToolbarOpen || isModeMenuOpen);
|
|
10898
10906
|
const reference = useMemo11(() => readElementReference(element), [element]);
|
|
@@ -11069,12 +11077,12 @@ var PlainLinkElement = (props) => /* @__PURE__ */ jsx93(LinkElement, __spreadPro
|
|
|
11069
11077
|
|
|
11070
11078
|
// src/ui/link-toolbar.tsx
|
|
11071
11079
|
import { useEditorPlugin as useEditorPlugin12, useEditorSelector as useEditorSelector2, usePluginOption as usePluginOption10 } from "platejs/react";
|
|
11072
|
-
import { useCallback as useCallback25, useEffect as useEffect25, useState as
|
|
11080
|
+
import { useCallback as useCallback25, useEffect as useEffect25, useState as useState26 } from "react";
|
|
11073
11081
|
|
|
11074
11082
|
// src/ui/link-search-panel.tsx
|
|
11075
11083
|
import { BookmarkIcon, LinkIcon as LinkIcon3 } from "lucide-react";
|
|
11076
11084
|
import { useEditorPlugin as useEditorPlugin10 } from "platejs/react";
|
|
11077
|
-
import { useCallback as useCallback23, useEffect as useEffect23, useState as
|
|
11085
|
+
import { useCallback as useCallback23, useEffect as useEffect23, useState as useState24 } from "react";
|
|
11078
11086
|
|
|
11079
11087
|
// src/hooks/use-debounce.ts
|
|
11080
11088
|
import React29, { useEffect as useEffect22 } from "react";
|
|
@@ -11234,10 +11242,10 @@ function LinkSearchPanel({ initialUrl }) {
|
|
|
11234
11242
|
const adapter = useEditorAdapter();
|
|
11235
11243
|
const { editor } = useEditorPlugin10(linkPlugin);
|
|
11236
11244
|
const canLinkPage = adapter.permissions.canLinkPage;
|
|
11237
|
-
const [query, setQuery] =
|
|
11238
|
-
const [displayText, setDisplayText] =
|
|
11239
|
-
const [pages, setPages] =
|
|
11240
|
-
const [isLoading, setIsLoading] =
|
|
11245
|
+
const [query, setQuery] = useState24(initialUrl);
|
|
11246
|
+
const [displayText, setDisplayText] = useState24(() => readSelectionText(editor));
|
|
11247
|
+
const [pages, setPages] = useState24([]);
|
|
11248
|
+
const [isLoading, setIsLoading] = useState24(true);
|
|
11241
11249
|
const trimmedQuery = query.trim();
|
|
11242
11250
|
const safeUrl = trimmedQuery.length > 0 ? getSafeSmartLinkUrl(trimmedQuery) : null;
|
|
11243
11251
|
const searchTerm = isLikelySmartLinkUrl(query) ? "" : trimmedQuery;
|
|
@@ -11381,11 +11389,11 @@ import { CursorOverlayPlugin } from "@platejs/selection/react";
|
|
|
11381
11389
|
import { LinkIcon as LinkIcon4, Trash2Icon as Trash2Icon2 } from "lucide-react";
|
|
11382
11390
|
import { NodeApi as NodeApi13 } from "platejs";
|
|
11383
11391
|
import { useEditorPlugin as useEditorPlugin11, usePluginOption as usePluginOption9 } from "platejs/react";
|
|
11384
|
-
import { useCallback as useCallback24, useEffect as useEffect24, useState as
|
|
11392
|
+
import { useCallback as useCallback24, useEffect as useEffect24, useState as useState25 } from "react";
|
|
11385
11393
|
import { jsx as jsx95, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
11386
11394
|
function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
|
|
11387
|
-
const [url, setUrl] =
|
|
11388
|
-
const [text, setText] =
|
|
11395
|
+
const [url, setUrl] = useState25(initialUrl);
|
|
11396
|
+
const [text, setText] = useState25("");
|
|
11389
11397
|
const mode = usePluginOption9(linkPlugin, "mode");
|
|
11390
11398
|
const { editor, setOption } = useEditorPlugin11(linkPlugin);
|
|
11391
11399
|
const activeLinkId = usePluginOption9(linkPlugin, "activeId");
|
|
@@ -11512,7 +11520,7 @@ function LinkFloatingToolbar() {
|
|
|
11512
11520
|
})) == null ? void 0 : _a2[0];
|
|
11513
11521
|
}, []);
|
|
11514
11522
|
const aboveUrl = (_a = aboveLink == null ? void 0 : aboveLink.url) != null ? _a : "";
|
|
11515
|
-
const [initialUrl, setInitialUrl] =
|
|
11523
|
+
const [initialUrl, setInitialUrl] = useState26(aboveUrl);
|
|
11516
11524
|
const open = mode === "insert" || mode === "edit" || mode === "cursor";
|
|
11517
11525
|
useEffect25(() => {
|
|
11518
11526
|
setInitialUrl(aboveUrl);
|
|
@@ -11769,7 +11777,14 @@ var textareaVariants = cva19(
|
|
|
11769
11777
|
);
|
|
11770
11778
|
function TextareaAutosize(_a) {
|
|
11771
11779
|
var _b = _a, { children, className, variant } = _b, props = __objRest(_b, ["children", "className", "variant"]);
|
|
11772
|
-
|
|
11780
|
+
const attributes = useTextFieldAttributes();
|
|
11781
|
+
return /* @__PURE__ */ jsx100(
|
|
11782
|
+
ReactTextareaAutosize,
|
|
11783
|
+
__spreadValues(__spreadProps(__spreadValues({}, attributes), {
|
|
11784
|
+
autoComplete: "off",
|
|
11785
|
+
className: cn2(textareaVariants({ variant }), className)
|
|
11786
|
+
}), props)
|
|
11787
|
+
);
|
|
11773
11788
|
}
|
|
11774
11789
|
|
|
11775
11790
|
// src/ui/equation-node.tsx
|
|
@@ -12003,9 +12018,10 @@ function Caption(_a) {
|
|
|
12003
12018
|
return /* @__PURE__ */ jsx102(CaptionPrimitive, __spreadProps(__spreadValues({}, props), { className: cn2(captionVariants({ align }), "px-3 pb-2", className) }));
|
|
12004
12019
|
}
|
|
12005
12020
|
function CaptionTextarea(props) {
|
|
12021
|
+
const attributes = useTextFieldAttributes();
|
|
12006
12022
|
return /* @__PURE__ */ jsx102(
|
|
12007
12023
|
CaptionTextareaPrimitive,
|
|
12008
|
-
__spreadProps(__spreadValues({}, props), {
|
|
12024
|
+
__spreadProps(__spreadValues(__spreadValues({}, attributes), props), {
|
|
12009
12025
|
className: cn2(
|
|
12010
12026
|
"mt-2 w-full resize-none border-none bg-inherit p-0 font-[inherit] text-inherit",
|
|
12011
12027
|
"focus:outline-none focus:placeholder:opacity-0",
|
|
@@ -12543,7 +12559,7 @@ import { useMediaState as useMediaState3 } from "@platejs/media/react";
|
|
|
12543
12559
|
import { ResizableProvider as ResizableProvider4 } from "@platejs/resizable";
|
|
12544
12560
|
import { ArrowUpRightIcon as ArrowUpRightIcon4, FileUpIcon, LinkIcon as LinkIcon6 } from "lucide-react";
|
|
12545
12561
|
import { PlateElement as PlateElement14, useEditorRef as useEditorRef16, useElement as useElement8, withHOC as withHOC4 } from "platejs/react";
|
|
12546
|
-
import { useCallback as useCallback31, useState as
|
|
12562
|
+
import { useCallback as useCallback31, useState as useState28 } from "react";
|
|
12547
12563
|
|
|
12548
12564
|
// src/ui/media-file-mode-dropdown.tsx
|
|
12549
12565
|
import { ChevronDownIcon as ChevronDownIcon8, FileIcon, FrameIcon, LinkIcon as LinkIcon5 } from "lucide-react";
|
|
@@ -12632,7 +12648,10 @@ function MediaFileBody({ canEmbed, displayMode, name, onAnchorClick, url }) {
|
|
|
12632
12648
|
return /* @__PURE__ */ jsxs68(
|
|
12633
12649
|
"a",
|
|
12634
12650
|
{
|
|
12635
|
-
className:
|
|
12651
|
+
className: cn2(
|
|
12652
|
+
FILE_URL_CLASS_NAME,
|
|
12653
|
+
"cursor-pointer transition-colors hover:border-editor-link dark-or-inherit:hover:border-editor-link!"
|
|
12654
|
+
),
|
|
12636
12655
|
contentEditable: false,
|
|
12637
12656
|
href: url,
|
|
12638
12657
|
onClick: onAnchorClick,
|
|
@@ -12670,7 +12689,7 @@ var MediaFileElement = withHOC4(ResizableProvider4, function MediaFileElement2(p
|
|
|
12670
12689
|
const fileName = name != null ? name : "";
|
|
12671
12690
|
const fileUrl = unsafeUrl != null ? unsafeUrl : "";
|
|
12672
12691
|
const canEmbed = isEmbeddableFile(fileName, fileUrl);
|
|
12673
|
-
const [isModeMenuOpen, setIsModeMenuOpen] =
|
|
12692
|
+
const [isModeMenuOpen, setIsModeMenuOpen] = useState28(false);
|
|
12674
12693
|
const open = !readOnly && (selected || isModeMenuOpen);
|
|
12675
12694
|
const handleOpen = useCallback31(() => {
|
|
12676
12695
|
if (fileUrl.length === 0) return;
|
|
@@ -12917,7 +12936,7 @@ import {
|
|
|
12917
12936
|
import { AudioLinesIcon, FileUpIcon as FileUpIcon2, FilmIcon, ImageIcon } from "lucide-react";
|
|
12918
12937
|
import { KEYS as KEYS22, nanoid as nanoid4 } from "platejs";
|
|
12919
12938
|
import { PlateElement as PlateElement16, useEditorPlugin as useEditorPlugin14, withHOC as withHOC6 } from "platejs/react";
|
|
12920
|
-
import { useCallback as useCallback32, useEffect as useEffect29, useRef as useRef11, useState as
|
|
12939
|
+
import { useCallback as useCallback32, useEffect as useEffect29, useRef as useRef11, useState as useState29 } from "react";
|
|
12921
12940
|
import { useFilePicker } from "use-file-picker";
|
|
12922
12941
|
|
|
12923
12942
|
// src/hooks/use-upload-file.ts
|
|
@@ -13159,7 +13178,7 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
13159
13178
|
var _a, _b, _c;
|
|
13160
13179
|
const { api, editor, getOption, tf } = useEditorPlugin14(PlaceholderPlugin2);
|
|
13161
13180
|
const { id, element, mediaType, readOnly, selected, setIsUploading, setProgresses, setUpdatedFiles, size } = usePlaceholderPopoverState();
|
|
13162
|
-
const [open, setOpen] =
|
|
13181
|
+
const [open, setOpen] = useState29(false);
|
|
13163
13182
|
const currentMedia = MEDIA_CONFIG[mediaType];
|
|
13164
13183
|
const uploadConfig = useUploadConfig();
|
|
13165
13184
|
const adapter = useEditorAdapter();
|
|
@@ -13219,7 +13238,7 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
13219
13238
|
{ at: path }
|
|
13220
13239
|
);
|
|
13221
13240
|
}, [uploadedFile, element.id, size]);
|
|
13222
|
-
const [embedValue, setEmbedValue] =
|
|
13241
|
+
const [embedValue, setEmbedValue] = useState29("");
|
|
13223
13242
|
const onEmbed = useCallback32(
|
|
13224
13243
|
(value) => {
|
|
13225
13244
|
const path = editor.api.findPath(element);
|
|
@@ -13275,7 +13294,7 @@ function ImageProgress({
|
|
|
13275
13294
|
imageRef,
|
|
13276
13295
|
progress = 0
|
|
13277
13296
|
}) {
|
|
13278
|
-
const [objectUrl, setObjectUrl] =
|
|
13297
|
+
const [objectUrl, setObjectUrl] = useState29(null);
|
|
13279
13298
|
useEffect29(() => {
|
|
13280
13299
|
const url = URL.createObjectURL(file);
|
|
13281
13300
|
setObjectUrl(url);
|
|
@@ -14488,7 +14507,7 @@ function DefaultToggleView({
|
|
|
14488
14507
|
children: [
|
|
14489
14508
|
/* @__PURE__ */ jsx120(ToggleChevron, { open }),
|
|
14490
14509
|
isEditing ? /* @__PURE__ */ jsx120(
|
|
14491
|
-
|
|
14510
|
+
UnstyledInput,
|
|
14492
14511
|
{
|
|
14493
14512
|
ref: inputRef,
|
|
14494
14513
|
className: "min-w-30 bg-transparent font-semibold text-foreground outline-none",
|
|
@@ -14817,9 +14836,9 @@ var ToggleKit = [
|
|
|
14817
14836
|
];
|
|
14818
14837
|
|
|
14819
14838
|
// src/components/editor/version-history/use-object-version.ts
|
|
14820
|
-
import { useEffect as useEffect32, useRef as useRef14, useState as
|
|
14839
|
+
import { useEffect as useEffect32, useRef as useRef14, useState as useState32 } from "react";
|
|
14821
14840
|
var useObjectVersion = (obj) => {
|
|
14822
|
-
const [version, setVersion] =
|
|
14841
|
+
const [version, setVersion] = useState32(0);
|
|
14823
14842
|
const prevObjRef = useRef14(obj);
|
|
14824
14843
|
useEffect32(() => {
|
|
14825
14844
|
if (prevObjRef.current !== obj) {
|
|
@@ -14890,7 +14909,7 @@ var DiffPlate = memo2(({ current = [], previous = [], showDiff }) => {
|
|
|
14890
14909
|
});
|
|
14891
14910
|
return diff;
|
|
14892
14911
|
}, [previous, current]);
|
|
14893
|
-
const [expandedChunks, setExpandedChunks] =
|
|
14912
|
+
const [expandedChunks, setExpandedChunks] = useState33([]);
|
|
14894
14913
|
const collapsedDiffValue = useMemo13(
|
|
14895
14914
|
() => collapseBlocksWithoutDiff(diffValue, {
|
|
14896
14915
|
expandedChunks
|
|
@@ -17296,11 +17315,49 @@ import { filterWords } from "@platejs/combobox";
|
|
|
17296
17315
|
import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
|
|
17297
17316
|
import { cva as cva26 } from "class-variance-authority";
|
|
17298
17317
|
import { useComposedRef as useComposedRef3, useEditorRef as useEditorRef29 } from "platejs/react";
|
|
17299
|
-
import React47, { useEffect as
|
|
17318
|
+
import React47, { useEffect as useEffect44 } from "react";
|
|
17319
|
+
|
|
17320
|
+
// src/hooks/use-return-focus-to-editor-on-input-removal.ts
|
|
17321
|
+
import { useEffect as useEffect42, useLayoutEffect as useLayoutEffect3, useRef as useRef16 } from "react";
|
|
17322
|
+
var focusEditableAtEditorSelection = (editor) => {
|
|
17323
|
+
const editable = editor.api.toDOMNode(editor);
|
|
17324
|
+
if (!(editable == null ? void 0 : editable.isConnected)) {
|
|
17325
|
+
return;
|
|
17326
|
+
}
|
|
17327
|
+
const document2 = editable.ownerDocument;
|
|
17328
|
+
const activeElement = document2.activeElement;
|
|
17329
|
+
if (activeElement && activeElement !== document2.body) {
|
|
17330
|
+
return;
|
|
17331
|
+
}
|
|
17332
|
+
const domRange = editor.selection ? editor.api.toDOMRange(editor.selection) : void 0;
|
|
17333
|
+
editable.focus({ preventScroll: true });
|
|
17334
|
+
const domSelection = document2.getSelection();
|
|
17335
|
+
if (domRange && domSelection) {
|
|
17336
|
+
domSelection.removeAllRanges();
|
|
17337
|
+
domSelection.addRange(domRange);
|
|
17338
|
+
}
|
|
17339
|
+
};
|
|
17340
|
+
var useReturnFocusToEditorOnInputRemoval = (editor, inputRef) => {
|
|
17341
|
+
const inputHadFocusWhenRemoved = useRef16(false);
|
|
17342
|
+
useLayoutEffect3(() => {
|
|
17343
|
+
const input = inputRef.current;
|
|
17344
|
+
return () => {
|
|
17345
|
+
inputHadFocusWhenRemoved.current = !!input && input.ownerDocument.activeElement === input;
|
|
17346
|
+
};
|
|
17347
|
+
}, [inputRef]);
|
|
17348
|
+
useEffect42(
|
|
17349
|
+
() => () => {
|
|
17350
|
+
if (inputHadFocusWhenRemoved.current) {
|
|
17351
|
+
focusEditableAtEditorSelection(editor);
|
|
17352
|
+
}
|
|
17353
|
+
},
|
|
17354
|
+
[editor]
|
|
17355
|
+
);
|
|
17356
|
+
};
|
|
17300
17357
|
|
|
17301
17358
|
// src/hooks/use-shield-input-selection-from-editor.ts
|
|
17302
17359
|
import { RangeApi as RangeApi2 } from "platejs";
|
|
17303
|
-
import { useEffect as
|
|
17360
|
+
import { useEffect as useEffect43 } from "react";
|
|
17304
17361
|
var SLATE_TEXT_SELECTOR = "[data-slate-string], [data-slate-zero-width]";
|
|
17305
17362
|
var isCaretInEditorText = (node) => {
|
|
17306
17363
|
var _a;
|
|
@@ -17318,7 +17375,7 @@ var wouldPullCaretOutOfInput = (editor, input) => {
|
|
|
17318
17375
|
return !!range && RangeApi2.equals(range, editor.selection);
|
|
17319
17376
|
};
|
|
17320
17377
|
var useShieldInputSelectionFromEditor = (editor, inputRef) => {
|
|
17321
|
-
|
|
17378
|
+
useEffect43(() => {
|
|
17322
17379
|
const input = inputRef.current;
|
|
17323
17380
|
const view = input == null ? void 0 : input.ownerDocument.defaultView;
|
|
17324
17381
|
if (!input || !view) {
|
|
@@ -17382,7 +17439,7 @@ function InlineCombobox({
|
|
|
17382
17439
|
[setValueProp, hasValueProp]
|
|
17383
17440
|
);
|
|
17384
17441
|
const insertPoint = React47.useRef(null);
|
|
17385
|
-
|
|
17442
|
+
useEffect44(() => {
|
|
17386
17443
|
const path = editor.api.findPath(element);
|
|
17387
17444
|
if (!path) return;
|
|
17388
17445
|
const point = editor.api.before(path);
|
|
@@ -17448,6 +17505,7 @@ function InlineComboboxInput(_a) {
|
|
|
17448
17505
|
const editor = useEditorRef29();
|
|
17449
17506
|
const ref = useComposedRef3(refProp, contextRef);
|
|
17450
17507
|
useShieldInputSelectionFromEditor(editor, contextRef);
|
|
17508
|
+
useReturnFocusToEditorOnInputRemoval(editor, contextRef);
|
|
17451
17509
|
return /* @__PURE__ */ jsxs86(Fragment21, { children: [
|
|
17452
17510
|
showTrigger && trigger,
|
|
17453
17511
|
/* @__PURE__ */ jsxs86("span", { className: "relative min-h-lh", children: [
|
|
@@ -17456,6 +17514,7 @@ function InlineComboboxInput(_a) {
|
|
|
17456
17514
|
Ariakit2.Combobox,
|
|
17457
17515
|
__spreadValues(__spreadValues({
|
|
17458
17516
|
autoSelect: true,
|
|
17517
|
+
render: /* @__PURE__ */ jsx139(UnstyledInput, {}),
|
|
17459
17518
|
className: cn2("absolute top-0 left-0 size-full bg-transparent outline-hidden", className),
|
|
17460
17519
|
ref,
|
|
17461
17520
|
value
|
|
@@ -17547,7 +17606,7 @@ function InlineComboboxEmpty({ children, className }) {
|
|
|
17547
17606
|
const { setHasEmpty } = React47.useContext(InlineComboboxContext);
|
|
17548
17607
|
const store = Ariakit2.useComboboxContext();
|
|
17549
17608
|
const items = (_a = store == null ? void 0 : store.useState("items")) != null ? _a : [];
|
|
17550
|
-
|
|
17609
|
+
useEffect44(() => {
|
|
17551
17610
|
setHasEmpty(true);
|
|
17552
17611
|
return () => {
|
|
17553
17612
|
setHasEmpty(false);
|
|
@@ -18019,7 +18078,7 @@ import { KEYS as KEYS33 } from "platejs";
|
|
|
18019
18078
|
// src/ui/mention-element.tsx
|
|
18020
18079
|
import { IS_APPLE as IS_APPLE2 } from "platejs";
|
|
18021
18080
|
import { PlateElement as PlateElement28, useFocused as useFocused3, useHotkeys as useHotkeys4, useReadOnly as useReadOnly16, useSelected as useSelected6 } from "platejs/react";
|
|
18022
|
-
import { useCallback as useCallback45, useState as
|
|
18081
|
+
import { useCallback as useCallback45, useState as useState40 } from "react";
|
|
18023
18082
|
import { useMounted as useMounted2 } from "react-tweet";
|
|
18024
18083
|
|
|
18025
18084
|
// src/ui/mention-document-element.tsx
|
|
@@ -18031,7 +18090,7 @@ import {
|
|
|
18031
18090
|
useReadOnly as useReadOnly15,
|
|
18032
18091
|
useSelected as useSelected5
|
|
18033
18092
|
} from "platejs/react";
|
|
18034
|
-
import { useCallback as useCallback44, useMemo as useMemo17, useState as
|
|
18093
|
+
import { useCallback as useCallback44, useMemo as useMemo17, useState as useState39 } from "react";
|
|
18035
18094
|
|
|
18036
18095
|
// src/ui/mention-document-hover-card.tsx
|
|
18037
18096
|
import { useCallback as useCallback43 } from "react";
|
|
@@ -18083,8 +18142,8 @@ function DocumentMentionElement(props) {
|
|
|
18083
18142
|
const focused = useFocused2();
|
|
18084
18143
|
const editor = useEditorRef37();
|
|
18085
18144
|
const readOnly = useReadOnly15();
|
|
18086
|
-
const [isToolbarOpen, setIsToolbarOpen] =
|
|
18087
|
-
const [isModeMenuOpen, setIsModeMenuOpen] =
|
|
18145
|
+
const [isToolbarOpen, setIsToolbarOpen] = useState39(false);
|
|
18146
|
+
const [isModeMenuOpen, setIsModeMenuOpen] = useState39(false);
|
|
18088
18147
|
const adapter = useEditorAdapter();
|
|
18089
18148
|
const canLinkPage = adapter.permissions.canLinkPage;
|
|
18090
18149
|
const resolvePage = adapter.pageLinks.resolvePage;
|
|
@@ -18237,7 +18296,7 @@ function UserMentionElement(props) {
|
|
|
18237
18296
|
const resolveMember = adapter.mentions.resolveMember;
|
|
18238
18297
|
const memberId = (_a = element.key) != null ? _a : "";
|
|
18239
18298
|
const canShowCard = typeof resolveMember === "function" && memberId.length > 0;
|
|
18240
|
-
const [wantOpen, setWantOpen] =
|
|
18299
|
+
const [wantOpen, setWantOpen] = useState40(false);
|
|
18241
18300
|
const { profile, isLoading, hasResolved } = useMemberProfile({
|
|
18242
18301
|
enabled: canShowCard && wantOpen,
|
|
18243
18302
|
memberId,
|
|
@@ -18328,17 +18387,17 @@ function UserMentionElement(props) {
|
|
|
18328
18387
|
import { DatePlugin as DatePlugin2 } from "@platejs/date/react";
|
|
18329
18388
|
import { MentionPlugin } from "@platejs/mention/react";
|
|
18330
18389
|
import { PlateElement as PlateElement29 } from "platejs/react";
|
|
18331
|
-
import { useCallback as useCallback46, useState as
|
|
18390
|
+
import { useCallback as useCallback46, useState as useState43 } from "react";
|
|
18332
18391
|
|
|
18333
18392
|
// src/ui/mention-page-combobox-group.tsx
|
|
18334
18393
|
import { FileTextIcon as FileTextIcon3 } from "lucide-react";
|
|
18335
|
-
import { useEffect as
|
|
18394
|
+
import { useEffect as useEffect45, useState as useState41 } from "react";
|
|
18336
18395
|
import { jsx as jsx155, jsxs as jsxs93 } from "react/jsx-runtime";
|
|
18337
18396
|
function PageComboboxGroup({ search, onPageHover, onPageSelect }) {
|
|
18338
18397
|
const adapter = useEditorAdapter();
|
|
18339
18398
|
const debouncedSearch = useDebounce(search, 250);
|
|
18340
|
-
const [pages, setPages] =
|
|
18341
|
-
|
|
18399
|
+
const [pages, setPages] = useState41([]);
|
|
18400
|
+
useEffect45(() => {
|
|
18342
18401
|
if (!adapter.permissions.canLinkPage) {
|
|
18343
18402
|
setPages([]);
|
|
18344
18403
|
return;
|
|
@@ -18387,13 +18446,13 @@ function PageStatusBadge({ status }) {
|
|
|
18387
18446
|
}
|
|
18388
18447
|
|
|
18389
18448
|
// src/ui/mention-people-combobox-group.tsx
|
|
18390
|
-
import { useEffect as
|
|
18449
|
+
import { useEffect as useEffect46, useState as useState42 } from "react";
|
|
18391
18450
|
import { jsx as jsx156, jsxs as jsxs94 } from "react/jsx-runtime";
|
|
18392
18451
|
function PeopleComboboxGroup({ search, onUserHover, onUserSelect }) {
|
|
18393
18452
|
const adapter = useEditorAdapter();
|
|
18394
18453
|
const debouncedSearch = useDebounce(search, 150);
|
|
18395
|
-
const [members, setMembers] =
|
|
18396
|
-
|
|
18454
|
+
const [members, setMembers] = useState42([]);
|
|
18455
|
+
useEffect46(() => {
|
|
18397
18456
|
if (!adapter.permissions.canMention) {
|
|
18398
18457
|
setMembers([]);
|
|
18399
18458
|
return;
|
|
@@ -18446,8 +18505,8 @@ var DEFAULT_PLACEHOLDER = "Mention a person, page, or date";
|
|
|
18446
18505
|
var TODAY_PLACEHOLDER = "Today";
|
|
18447
18506
|
function MentionInputElement(props) {
|
|
18448
18507
|
const { children, editor, element } = props;
|
|
18449
|
-
const [search, setSearch] =
|
|
18450
|
-
const [placeholder, setPlaceholder] =
|
|
18508
|
+
const [search, setSearch] = useState43("");
|
|
18509
|
+
const [placeholder, setPlaceholder] = useState43(DEFAULT_PLACEHOLDER);
|
|
18451
18510
|
const handleDateFocus = useCallback46(() => {
|
|
18452
18511
|
setPlaceholder(TODAY_PLACEHOLDER);
|
|
18453
18512
|
}, []);
|
|
@@ -3,4 +3,4 @@ export type { Value, PlateEditor, WebEditorProps, EditorFeatures, TocConfig };
|
|
|
3
3
|
export { EditorTocProvider, type TocHeading, useEditorToc } from '../../context/editor-toc-context';
|
|
4
4
|
export { extractHeadingsFromValue } from '../../lib/extract-headings';
|
|
5
5
|
export { EditorTocSidebar } from '../../ui/toc-sidebar';
|
|
6
|
-
export declare
|
|
6
|
+
export declare function WebEditor({ adapter, textFieldAttributes, ...props }: WebEditorProps): import("react").JSX.Element;
|