@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
|
@@ -4304,6 +4304,16 @@ var backgroundColorItems = [
|
|
|
4304
4304
|
|
|
4305
4305
|
// src/ui/input.tsx
|
|
4306
4306
|
import { cva as cva10 } from "class-variance-authority";
|
|
4307
|
+
|
|
4308
|
+
// src/context/text-field-attributes.ts
|
|
4309
|
+
import { createContext as createContext4, useContext as useContext4, useState as useState6 } from "react";
|
|
4310
|
+
var EMPTY_ATTRIBUTES = Object.freeze({});
|
|
4311
|
+
var TextFieldAttributesContext = createContext4(EMPTY_ATTRIBUTES);
|
|
4312
|
+
function useTextFieldAttributes() {
|
|
4313
|
+
return useContext4(TextFieldAttributesContext);
|
|
4314
|
+
}
|
|
4315
|
+
|
|
4316
|
+
// src/ui/input.tsx
|
|
4307
4317
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
4308
4318
|
var inputVariants = cva10(
|
|
4309
4319
|
cn(
|
|
@@ -4325,9 +4335,16 @@ var inputVariants = cva10(
|
|
|
4325
4335
|
}
|
|
4326
4336
|
}
|
|
4327
4337
|
);
|
|
4338
|
+
var TEXT_INPUT_TYPES = /* @__PURE__ */ new Set(["text", "search", "url", "email", "tel", "password"]);
|
|
4339
|
+
function UnstyledInput(_a) {
|
|
4340
|
+
var _b = _a, { type = "text" } = _b, props = __objRest(_b, ["type"]);
|
|
4341
|
+
const attributes = useTextFieldAttributes();
|
|
4342
|
+
const textFieldAttributes = TEXT_INPUT_TYPES.has(type.toLowerCase()) ? attributes : void 0;
|
|
4343
|
+
return /* @__PURE__ */ jsx22("input", __spreadValues(__spreadProps(__spreadValues({}, textFieldAttributes), { type }), props));
|
|
4344
|
+
}
|
|
4328
4345
|
function Input(_a) {
|
|
4329
4346
|
var _b = _a, { className, variant } = _b, props = __objRest(_b, ["className", "variant"]);
|
|
4330
|
-
return /* @__PURE__ */ jsx22(
|
|
4347
|
+
return /* @__PURE__ */ jsx22(UnstyledInput, __spreadValues({ className: cn(inputVariants({ variant }), className) }, props));
|
|
4331
4348
|
}
|
|
4332
4349
|
|
|
4333
4350
|
// src/ui/menu.tsx
|
|
@@ -5560,11 +5577,11 @@ import { PathApi as PathApi5 } from "platejs";
|
|
|
5560
5577
|
import { SlateElement as SlateElement2 } from "platejs/static";
|
|
5561
5578
|
|
|
5562
5579
|
// src/context/heading-slug-context.tsx
|
|
5563
|
-
import { createContext as
|
|
5580
|
+
import { createContext as createContext6, useContext as useContext6 } from "react";
|
|
5564
5581
|
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
5565
|
-
var HeadingSlugContext =
|
|
5582
|
+
var HeadingSlugContext = createContext6(null);
|
|
5566
5583
|
var useHeadingSlug = () => {
|
|
5567
|
-
return
|
|
5584
|
+
return useContext6(HeadingSlugContext);
|
|
5568
5585
|
};
|
|
5569
5586
|
|
|
5570
5587
|
// src/ui/heading-node-static.tsx
|
|
@@ -6197,20 +6214,20 @@ import { SlateElement as SlateElement9 } from "platejs/static";
|
|
|
6197
6214
|
|
|
6198
6215
|
// src/context/link-resolution-context.tsx
|
|
6199
6216
|
import {
|
|
6200
|
-
createContext as
|
|
6217
|
+
createContext as createContext8,
|
|
6201
6218
|
useCallback as useCallback5,
|
|
6202
|
-
useContext as
|
|
6219
|
+
useContext as useContext8,
|
|
6203
6220
|
useEffect as useEffect12,
|
|
6204
6221
|
useMemo as useMemo8,
|
|
6205
6222
|
useRef as useRef7,
|
|
6206
6223
|
useSyncExternalStore as useSyncExternalStore2
|
|
6207
6224
|
} from "react";
|
|
6208
6225
|
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
6209
|
-
var LinkResolutionContext =
|
|
6226
|
+
var LinkResolutionContext = createContext8(null);
|
|
6210
6227
|
var NOOP_UNSUBSCRIBE = () => {
|
|
6211
6228
|
};
|
|
6212
6229
|
var usePagePreview = (reference) => {
|
|
6213
|
-
const store =
|
|
6230
|
+
const store = useContext8(LinkResolutionContext);
|
|
6214
6231
|
const key = reference ? linkReferenceKey(reference) : null;
|
|
6215
6232
|
const subscribe2 = useCallback5(
|
|
6216
6233
|
(onChange) => {
|
|
@@ -6223,12 +6240,12 @@ var usePagePreview = (reference) => {
|
|
|
6223
6240
|
return useSyncExternalStore2(subscribe2, getSnapshot, getSnapshot);
|
|
6224
6241
|
};
|
|
6225
6242
|
var useHasLinkSeed = (url) => {
|
|
6226
|
-
const store =
|
|
6243
|
+
const store = useContext8(LinkResolutionContext);
|
|
6227
6244
|
if (!store || !url) return false;
|
|
6228
6245
|
return store.seededUrls.has(url);
|
|
6229
6246
|
};
|
|
6230
6247
|
var useLinkMetadata = (url) => {
|
|
6231
|
-
const store =
|
|
6248
|
+
const store = useContext8(LinkResolutionContext);
|
|
6232
6249
|
const subscribe2 = useCallback5(
|
|
6233
6250
|
(onChange) => {
|
|
6234
6251
|
if (!store || !url) return NOOP_UNSUBSCRIBE;
|
|
@@ -6364,11 +6381,11 @@ var getSmartLinkAnchorProps = (url) => {
|
|
|
6364
6381
|
|
|
6365
6382
|
// src/ui/smart-link-view.tsx
|
|
6366
6383
|
import { ArrowUpRightIcon, FileTextIcon, LinkIcon } from "lucide-react";
|
|
6367
|
-
import { useCallback as useCallback6, useState as
|
|
6384
|
+
import { useCallback as useCallback6, useState as useState11 } from "react";
|
|
6368
6385
|
import { jsx as jsx43, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
6369
6386
|
var PLAIN_LINK_CLASS_NAME = "inline font-medium text-primary underline decoration-primary/45 decoration-1 underline-offset-[0.2em] transition-colors hover:decoration-primary hover:decoration-2";
|
|
6370
6387
|
function SmartLinkIcon({ icon, faviconUrl, provider, className }) {
|
|
6371
|
-
const [failedSrc, setFailedSrc] =
|
|
6388
|
+
const [failedSrc, setFailedSrc] = useState11(null);
|
|
6372
6389
|
const isPageLike = provider === "Page" || provider === "Internal link";
|
|
6373
6390
|
const showFavicon = typeof faviconUrl === "string" && faviconUrl.length > 0 && failedSrc !== faviconUrl;
|
|
6374
6391
|
const handleFaviconError = useCallback6(() => {
|
|
@@ -6410,7 +6427,7 @@ function SmartLinkInlineContent({ link, className }) {
|
|
|
6410
6427
|
"span",
|
|
6411
6428
|
{
|
|
6412
6429
|
className: cn(
|
|
6413
|
-
"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-
|
|
6430
|
+
"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",
|
|
6414
6431
|
className
|
|
6415
6432
|
),
|
|
6416
6433
|
children: [
|
|
@@ -6426,7 +6443,7 @@ function SmartLinkUrlContent({ link, className }) {
|
|
|
6426
6443
|
"span",
|
|
6427
6444
|
{
|
|
6428
6445
|
className: cn(
|
|
6429
|
-
"inline max-w-full wrap-break-word border-
|
|
6446
|
+
"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!",
|
|
6430
6447
|
className
|
|
6431
6448
|
),
|
|
6432
6449
|
children: [
|
|
@@ -6458,7 +6475,7 @@ function SmartLinkCardContent({ link, className }) {
|
|
|
6458
6475
|
),
|
|
6459
6476
|
/* @__PURE__ */ jsxs20("span", { className: "min-w-0 flex-1", children: [
|
|
6460
6477
|
/* @__PURE__ */ jsxs20("span", { className: "flex min-w-0 items-start gap-3", children: [
|
|
6461
|
-
/* @__PURE__ */ jsx43("span", { className: "min-w-0 flex-1 truncate font-semibold text-
|
|
6478
|
+
/* @__PURE__ */ jsx43("span", { className: "min-w-0 flex-1 truncate font-semibold text-editor-link text-base leading-6", children: link.title }),
|
|
6462
6479
|
link.status ? /* @__PURE__ */ jsx43(SmartLinkStatus, { status: link.status }) : null
|
|
6463
6480
|
] }),
|
|
6464
6481
|
/* @__PURE__ */ jsxs20("span", { className: "mt-2 flex min-w-0 items-center gap-2 text-muted-foreground text-sm", children: [
|
|
@@ -6476,7 +6493,7 @@ function SmartLinkCardContent({ link, className }) {
|
|
|
6476
6493
|
{
|
|
6477
6494
|
faviconUrl: link.faviconUrl,
|
|
6478
6495
|
provider: link.provider,
|
|
6479
|
-
className: "size-5 rounded bg-
|
|
6496
|
+
className: "size-5 rounded bg-editor-link p-1 text-white dark-or-inherit:text-primary-foreground"
|
|
6480
6497
|
}
|
|
6481
6498
|
),
|
|
6482
6499
|
/* @__PURE__ */ jsx43("span", { className: "truncate", children: (_a = link.provider) != null ? _a : "Link" })
|
|
@@ -6491,7 +6508,7 @@ function SmartLinkCardContent({ link, className }) {
|
|
|
6491
6508
|
);
|
|
6492
6509
|
}
|
|
6493
6510
|
function SmartLinkCardImage({ src }) {
|
|
6494
|
-
const [hasFailed, setHasFailed] =
|
|
6511
|
+
const [hasFailed, setHasFailed] = useState11(false);
|
|
6495
6512
|
const handleError = useCallback6(() => {
|
|
6496
6513
|
setHasFailed(true);
|
|
6497
6514
|
}, []);
|
|
@@ -7039,6 +7056,7 @@ import { SlateElement as SlateElement13 } from "platejs/static";
|
|
|
7039
7056
|
// src/ui/media-file-display.ts
|
|
7040
7057
|
var FILE_DISPLAY_MODES = ["inline", "url", "embed"];
|
|
7041
7058
|
var DEFAULT_FILE_DISPLAY_MODE = "inline";
|
|
7059
|
+
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!";
|
|
7042
7060
|
var normalizeFileDisplayMode = (value) => {
|
|
7043
7061
|
return value === "url" || value === "embed" || value === "inline" ? value : DEFAULT_FILE_DISPLAY_MODE;
|
|
7044
7062
|
};
|
|
@@ -7075,20 +7093,10 @@ function MediaFileStaticBody({ canEmbed, displayMode, name, url }) {
|
|
|
7075
7093
|
);
|
|
7076
7094
|
}
|
|
7077
7095
|
if (displayMode === "url") {
|
|
7078
|
-
return /* @__PURE__ */ jsxs26(
|
|
7079
|
-
"
|
|
7080
|
-
{
|
|
7081
|
-
|
|
7082
|
-
contentEditable: false,
|
|
7083
|
-
href: url,
|
|
7084
|
-
rel: "noopener noreferrer",
|
|
7085
|
-
target: "_blank",
|
|
7086
|
-
children: [
|
|
7087
|
-
/* @__PURE__ */ jsx50(Link, { className: "size-4 shrink-0 text-muted-foreground" }),
|
|
7088
|
-
/* @__PURE__ */ jsx50("span", { className: "truncate", children: url })
|
|
7089
|
-
]
|
|
7090
|
-
}
|
|
7091
|
-
);
|
|
7096
|
+
return /* @__PURE__ */ jsxs26("a", { className: FILE_URL_CLASS_NAME, contentEditable: false, href: url, rel: "noopener noreferrer", target: "_blank", children: [
|
|
7097
|
+
/* @__PURE__ */ jsx50(Link, { className: "size-4 shrink-0 text-muted-foreground" }),
|
|
7098
|
+
/* @__PURE__ */ jsx50("span", { className: "truncate", children: url })
|
|
7099
|
+
] });
|
|
7092
7100
|
}
|
|
7093
7101
|
return /* @__PURE__ */ jsx50(
|
|
7094
7102
|
"a",
|
|
@@ -7128,7 +7136,7 @@ function MediaFileElementStatic(props) {
|
|
|
7128
7136
|
// src/ui/media-image-node-static.tsx
|
|
7129
7137
|
import { NodeApi as NodeApi6 } from "platejs";
|
|
7130
7138
|
import { SlateElement as SlateElement14 } from "platejs/static";
|
|
7131
|
-
import { useCallback as useCallback8, useRef as useRef8, useState as
|
|
7139
|
+
import { useCallback as useCallback8, useRef as useRef8, useState as useState12 } from "react";
|
|
7132
7140
|
|
|
7133
7141
|
// src/ui/media-image-lightbox.tsx
|
|
7134
7142
|
import { AnimatePresence as AnimatePresence2, motion as motion2 } from "framer-motion";
|
|
@@ -7250,8 +7258,8 @@ function ImageLightbox({ alt, isOpen, onClose, sourceRect, src }) {
|
|
|
7250
7258
|
import { jsx as jsx52, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
7251
7259
|
function ImageElementStatic(props) {
|
|
7252
7260
|
const { align = "center", caption, hint, hintIcon, url } = props.element;
|
|
7253
|
-
const [lightboxOpen, setLightboxOpen] =
|
|
7254
|
-
const [sourceRect, setSourceRect] =
|
|
7261
|
+
const [lightboxOpen, setLightboxOpen] = useState12(false);
|
|
7262
|
+
const [sourceRect, setSourceRect] = useState12(null);
|
|
7255
7263
|
const imgRef = useRef8(null);
|
|
7256
7264
|
const handleOpen = useCallback8(() => {
|
|
7257
7265
|
if (imgRef.current) {
|
|
@@ -7350,7 +7358,7 @@ import { BaseMentionPlugin } from "@platejs/mention";
|
|
|
7350
7358
|
// src/ui/mention-node-static.tsx
|
|
7351
7359
|
import { IS_APPLE } from "platejs";
|
|
7352
7360
|
import { SlateElement as SlateElement16 } from "platejs/static";
|
|
7353
|
-
import { useCallback as useCallback9, useState as
|
|
7361
|
+
import { useCallback as useCallback9, useState as useState15 } from "react";
|
|
7354
7362
|
|
|
7355
7363
|
// src/ui/member-profile-card.tsx
|
|
7356
7364
|
import { ArrowUpRight, Mail, MapPin, Users } from "lucide-react";
|
|
@@ -7454,9 +7462,9 @@ function MemberProfileCard({ profile, fallbackName, isLoading }) {
|
|
|
7454
7462
|
}
|
|
7455
7463
|
|
|
7456
7464
|
// src/ui/mention-document-link.ts
|
|
7457
|
-
import { useEffect as useEffect14, useState as
|
|
7465
|
+
import { useEffect as useEffect14, useState as useState13 } from "react";
|
|
7458
7466
|
var useDocumentPagePreview = ({ enabled, reference, resolvePage }) => {
|
|
7459
|
-
const [page, setPage] =
|
|
7467
|
+
const [page, setPage] = useState13(null);
|
|
7460
7468
|
const referenceKey = enabled && reference ? linkReferenceKey(reference) : null;
|
|
7461
7469
|
useEffect14(() => {
|
|
7462
7470
|
const nextReference = referenceKey ? linkReferenceFromKey(referenceKey) : null;
|
|
@@ -7496,10 +7504,10 @@ var getDocumentMentionLink = (element, page, displayMode) => {
|
|
|
7496
7504
|
};
|
|
7497
7505
|
|
|
7498
7506
|
// src/ui/use-member-profile.ts
|
|
7499
|
-
import { useEffect as useEffect15, useState as
|
|
7507
|
+
import { useEffect as useEffect15, useState as useState14 } from "react";
|
|
7500
7508
|
var IDLE_STATE = { profile: null, isLoading: false, hasResolved: false };
|
|
7501
7509
|
var useMemberProfile = ({ enabled, memberId, resolveMember }) => {
|
|
7502
|
-
const [state, setState] =
|
|
7510
|
+
const [state, setState] = useState14(IDLE_STATE);
|
|
7503
7511
|
useEffect15(() => {
|
|
7504
7512
|
if (!enabled || !resolveMember || memberId.length === 0) {
|
|
7505
7513
|
setState(IDLE_STATE);
|
|
@@ -7568,7 +7576,7 @@ function UserMentionElementStatic(_a) {
|
|
|
7568
7576
|
const resolveMember = adapter.mentions.resolveMember;
|
|
7569
7577
|
const memberId = (_a2 = element.key) != null ? _a2 : "";
|
|
7570
7578
|
const canShowCard = typeof resolveMember === "function" && memberId.length > 0;
|
|
7571
|
-
const [wantOpen, setWantOpen] =
|
|
7579
|
+
const [wantOpen, setWantOpen] = useState15(false);
|
|
7572
7580
|
const { profile, isLoading, hasResolved } = useMemberProfile({
|
|
7573
7581
|
enabled: canShowCard && wantOpen,
|
|
7574
7582
|
memberId,
|
|
@@ -8272,6 +8280,7 @@ function CommandInput(_a) {
|
|
|
8272
8280
|
"variant",
|
|
8273
8281
|
"wrapClassName"
|
|
8274
8282
|
]);
|
|
8283
|
+
const attributes = useTextFieldAttributes();
|
|
8275
8284
|
return /* @__PURE__ */ jsx65(
|
|
8276
8285
|
"div",
|
|
8277
8286
|
{
|
|
@@ -8280,10 +8289,10 @@ function CommandInput(_a) {
|
|
|
8280
8289
|
"data-slot": "command-input-wrapper",
|
|
8281
8290
|
children: /* @__PURE__ */ jsx65(
|
|
8282
8291
|
CommandPrimitive.Input,
|
|
8283
|
-
__spreadValues({
|
|
8292
|
+
__spreadValues(__spreadProps(__spreadValues({}, attributes), {
|
|
8284
8293
|
className: cn(inputVariants({ variant }), className),
|
|
8285
8294
|
"data-slot": "command-input"
|
|
8286
|
-
}, props)
|
|
8295
|
+
}), props)
|
|
8287
8296
|
)
|
|
8288
8297
|
}
|
|
8289
8298
|
);
|
|
@@ -8664,7 +8673,7 @@ function TabTrigger({
|
|
|
8664
8673
|
onKeyDown: handleTabKeyDown,
|
|
8665
8674
|
children: [
|
|
8666
8675
|
isEditing ? /* @__PURE__ */ jsx68(
|
|
8667
|
-
|
|
8676
|
+
UnstyledInput,
|
|
8668
8677
|
{
|
|
8669
8678
|
ref: inputRef,
|
|
8670
8679
|
className: cn(
|
|
@@ -9733,11 +9742,19 @@ var textareaVariants = cva19(
|
|
|
9733
9742
|
);
|
|
9734
9743
|
function Textarea(_a) {
|
|
9735
9744
|
var _b = _a, { className, variant } = _b, props = __objRest(_b, ["className", "variant"]);
|
|
9736
|
-
|
|
9745
|
+
const attributes = useTextFieldAttributes();
|
|
9746
|
+
return /* @__PURE__ */ jsx81("textarea", __spreadValues(__spreadProps(__spreadValues({}, attributes), { className: cn(textareaVariants({ variant }), className) }), props));
|
|
9737
9747
|
}
|
|
9738
9748
|
function TextareaAutosize(_a) {
|
|
9739
9749
|
var _b = _a, { children, className, variant } = _b, props = __objRest(_b, ["children", "className", "variant"]);
|
|
9740
|
-
|
|
9750
|
+
const attributes = useTextFieldAttributes();
|
|
9751
|
+
return /* @__PURE__ */ jsx81(
|
|
9752
|
+
ReactTextareaAutosize,
|
|
9753
|
+
__spreadValues(__spreadProps(__spreadValues({}, attributes), {
|
|
9754
|
+
autoComplete: "off",
|
|
9755
|
+
className: cn(textareaVariants({ variant }), className)
|
|
9756
|
+
}), props)
|
|
9757
|
+
);
|
|
9741
9758
|
}
|
|
9742
9759
|
|
|
9743
9760
|
// src/ui/ai-menu.tsx
|
|
@@ -11512,7 +11529,7 @@ function BadgeShapeButton({ shape, selected, setShape, updateElement }) {
|
|
|
11512
11529
|
|
|
11513
11530
|
// src/ui/icon-picker.tsx
|
|
11514
11531
|
import { icons as lucideIcons } from "lucide-react";
|
|
11515
|
-
import { dynamicIconImports } from "lucide-react/dynamic";
|
|
11532
|
+
import { dynamicIconImports } from "lucide-react/dynamic.mjs";
|
|
11516
11533
|
import * as React34 from "react";
|
|
11517
11534
|
import { Fragment as Fragment11, jsx as jsx91, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
11518
11535
|
var toPascalCase = (str) => str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
@@ -12788,15 +12805,14 @@ function EmojiPickerSearchBar({
|
|
|
12788
12805
|
}) {
|
|
12789
12806
|
return /* @__PURE__ */ jsx106("div", { className: "flex items-center px-2", children: /* @__PURE__ */ jsxs62("div", { className: "relative flex grow items-center", children: [
|
|
12790
12807
|
/* @__PURE__ */ jsx106(
|
|
12791
|
-
|
|
12808
|
+
UnstyledInput,
|
|
12792
12809
|
{
|
|
12793
12810
|
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",
|
|
12794
12811
|
value: searchValue,
|
|
12795
12812
|
onChange: (event) => setSearch(event.target.value),
|
|
12796
12813
|
placeholder: i18n.search,
|
|
12797
12814
|
"aria-label": "Search",
|
|
12798
|
-
autoComplete: "off"
|
|
12799
|
-
type: "text"
|
|
12815
|
+
autoComplete: "off"
|
|
12800
12816
|
}
|
|
12801
12817
|
),
|
|
12802
12818
|
children
|
|
@@ -13338,7 +13354,7 @@ function CardTitleRow({
|
|
|
13338
13354
|
}) {
|
|
13339
13355
|
if (isEditing) {
|
|
13340
13356
|
return /* @__PURE__ */ jsx111(
|
|
13341
|
-
|
|
13357
|
+
UnstyledInput,
|
|
13342
13358
|
{
|
|
13343
13359
|
ref: inputRef,
|
|
13344
13360
|
className: "min-w-30 bg-transparent font-semibold text-foreground outline-none",
|
|
@@ -15245,11 +15261,49 @@ import { filterWords } from "@platejs/combobox";
|
|
|
15245
15261
|
import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
|
|
15246
15262
|
import { cva as cva22 } from "class-variance-authority";
|
|
15247
15263
|
import { useComposedRef as useComposedRef2, useEditorRef as useEditorRef24 } from "platejs/react";
|
|
15248
|
-
import React55, { useEffect as
|
|
15264
|
+
import React55, { useEffect as useEffect37 } from "react";
|
|
15265
|
+
|
|
15266
|
+
// src/hooks/use-return-focus-to-editor-on-input-removal.ts
|
|
15267
|
+
import { useEffect as useEffect35, useLayoutEffect as useLayoutEffect2, useRef as useRef15 } from "react";
|
|
15268
|
+
var focusEditableAtEditorSelection = (editor) => {
|
|
15269
|
+
const editable = editor.api.toDOMNode(editor);
|
|
15270
|
+
if (!(editable == null ? void 0 : editable.isConnected)) {
|
|
15271
|
+
return;
|
|
15272
|
+
}
|
|
15273
|
+
const document2 = editable.ownerDocument;
|
|
15274
|
+
const activeElement = document2.activeElement;
|
|
15275
|
+
if (activeElement && activeElement !== document2.body) {
|
|
15276
|
+
return;
|
|
15277
|
+
}
|
|
15278
|
+
const domRange = editor.selection ? editor.api.toDOMRange(editor.selection) : void 0;
|
|
15279
|
+
editable.focus({ preventScroll: true });
|
|
15280
|
+
const domSelection = document2.getSelection();
|
|
15281
|
+
if (domRange && domSelection) {
|
|
15282
|
+
domSelection.removeAllRanges();
|
|
15283
|
+
domSelection.addRange(domRange);
|
|
15284
|
+
}
|
|
15285
|
+
};
|
|
15286
|
+
var useReturnFocusToEditorOnInputRemoval = (editor, inputRef) => {
|
|
15287
|
+
const inputHadFocusWhenRemoved = useRef15(false);
|
|
15288
|
+
useLayoutEffect2(() => {
|
|
15289
|
+
const input = inputRef.current;
|
|
15290
|
+
return () => {
|
|
15291
|
+
inputHadFocusWhenRemoved.current = !!input && input.ownerDocument.activeElement === input;
|
|
15292
|
+
};
|
|
15293
|
+
}, [inputRef]);
|
|
15294
|
+
useEffect35(
|
|
15295
|
+
() => () => {
|
|
15296
|
+
if (inputHadFocusWhenRemoved.current) {
|
|
15297
|
+
focusEditableAtEditorSelection(editor);
|
|
15298
|
+
}
|
|
15299
|
+
},
|
|
15300
|
+
[editor]
|
|
15301
|
+
);
|
|
15302
|
+
};
|
|
15249
15303
|
|
|
15250
15304
|
// src/hooks/use-shield-input-selection-from-editor.ts
|
|
15251
15305
|
import { RangeApi as RangeApi2 } from "platejs";
|
|
15252
|
-
import { useEffect as
|
|
15306
|
+
import { useEffect as useEffect36 } from "react";
|
|
15253
15307
|
var SLATE_TEXT_SELECTOR = "[data-slate-string], [data-slate-zero-width]";
|
|
15254
15308
|
var isCaretInEditorText = (node) => {
|
|
15255
15309
|
var _a;
|
|
@@ -15267,7 +15321,7 @@ var wouldPullCaretOutOfInput = (editor, input) => {
|
|
|
15267
15321
|
return !!range && RangeApi2.equals(range, editor.selection);
|
|
15268
15322
|
};
|
|
15269
15323
|
var useShieldInputSelectionFromEditor = (editor, inputRef) => {
|
|
15270
|
-
|
|
15324
|
+
useEffect36(() => {
|
|
15271
15325
|
const input = inputRef.current;
|
|
15272
15326
|
const view = input == null ? void 0 : input.ownerDocument.defaultView;
|
|
15273
15327
|
if (!input || !view) {
|
|
@@ -15331,7 +15385,7 @@ function InlineCombobox({
|
|
|
15331
15385
|
[setValueProp, hasValueProp]
|
|
15332
15386
|
);
|
|
15333
15387
|
const insertPoint = React55.useRef(null);
|
|
15334
|
-
|
|
15388
|
+
useEffect37(() => {
|
|
15335
15389
|
const path = editor.api.findPath(element);
|
|
15336
15390
|
if (!path) return;
|
|
15337
15391
|
const point = editor.api.before(path);
|
|
@@ -15397,6 +15451,7 @@ function InlineComboboxInput(_a) {
|
|
|
15397
15451
|
const editor = useEditorRef24();
|
|
15398
15452
|
const ref = useComposedRef2(refProp, contextRef);
|
|
15399
15453
|
useShieldInputSelectionFromEditor(editor, contextRef);
|
|
15454
|
+
useReturnFocusToEditorOnInputRemoval(editor, contextRef);
|
|
15400
15455
|
return /* @__PURE__ */ jsxs79(Fragment19, { children: [
|
|
15401
15456
|
showTrigger && trigger,
|
|
15402
15457
|
/* @__PURE__ */ jsxs79("span", { className: "relative min-h-lh", children: [
|
|
@@ -15405,6 +15460,7 @@ function InlineComboboxInput(_a) {
|
|
|
15405
15460
|
Ariakit2.Combobox,
|
|
15406
15461
|
__spreadValues(__spreadValues({
|
|
15407
15462
|
autoSelect: true,
|
|
15463
|
+
render: /* @__PURE__ */ jsx128(UnstyledInput, {}),
|
|
15408
15464
|
className: cn("absolute top-0 left-0 size-full bg-transparent outline-hidden", className),
|
|
15409
15465
|
ref,
|
|
15410
15466
|
value
|
|
@@ -15496,7 +15552,7 @@ function InlineComboboxEmpty({ children, className }) {
|
|
|
15496
15552
|
const { setHasEmpty } = React55.useContext(InlineComboboxContext);
|
|
15497
15553
|
const store = Ariakit2.useComboboxContext();
|
|
15498
15554
|
const items = (_a = store == null ? void 0 : store.useState("items")) != null ? _a : [];
|
|
15499
|
-
|
|
15555
|
+
useEffect37(() => {
|
|
15500
15556
|
setHasEmpty(true);
|
|
15501
15557
|
return () => {
|
|
15502
15558
|
setHasEmpty(false);
|
|
@@ -15618,7 +15674,7 @@ import { useLink } from "@platejs/link/react";
|
|
|
15618
15674
|
import { SuggestionPlugin as SuggestionPlugin3 } from "@platejs/suggestion/react";
|
|
15619
15675
|
import { NodeApi as NodeApi14 } from "platejs";
|
|
15620
15676
|
import { PlateElement as PlateElement20, useEditorPlugin as useEditorPlugin9, useElement as useElement11, useReadOnly as useReadOnly13 } from "platejs/react";
|
|
15621
|
-
import { useCallback as useCallback42, useMemo as useMemo16, useState as
|
|
15677
|
+
import { useCallback as useCallback42, useMemo as useMemo16, useState as useState41 } from "react";
|
|
15622
15678
|
|
|
15623
15679
|
// src/ui/smart-link-clipboard.ts
|
|
15624
15680
|
var copySmartLinkUrl = async (url) => {
|
|
@@ -15656,11 +15712,11 @@ import { ArrowUpRightIcon as ArrowUpRightIcon3, PencilIcon as PencilIcon6, Trash
|
|
|
15656
15712
|
|
|
15657
15713
|
// src/ui/smart-link-copy-button.tsx
|
|
15658
15714
|
import { CheckIcon as CheckIcon15, CopyIcon as CopyIcon2, XIcon as XIcon7 } from "lucide-react";
|
|
15659
|
-
import { useCallback as useCallback40, useEffect as
|
|
15715
|
+
import { useCallback as useCallback40, useEffect as useEffect38, useState as useState40 } from "react";
|
|
15660
15716
|
import { jsx as jsx130 } from "react/jsx-runtime";
|
|
15661
15717
|
function SmartLinkCopyButton({ disabled, onCopy }) {
|
|
15662
|
-
const [feedback, setFeedback] =
|
|
15663
|
-
|
|
15718
|
+
const [feedback, setFeedback] = useState40("idle");
|
|
15719
|
+
useEffect38(() => {
|
|
15664
15720
|
if (feedback === "idle") return;
|
|
15665
15721
|
const timeoutId = window.setTimeout(() => {
|
|
15666
15722
|
setFeedback("idle");
|
|
@@ -15827,8 +15883,8 @@ function LinkElement(_a) {
|
|
|
15827
15883
|
const { api, editor, setOption } = useEditorPlugin9(linkPlugin);
|
|
15828
15884
|
const adapter = useEditorAdapter();
|
|
15829
15885
|
const readOnly = useReadOnly13();
|
|
15830
|
-
const [isToolbarOpen, setIsToolbarOpen] =
|
|
15831
|
-
const [isModeMenuOpen, setIsModeMenuOpen] =
|
|
15886
|
+
const [isToolbarOpen, setIsToolbarOpen] = useState41(false);
|
|
15887
|
+
const [isModeMenuOpen, setIsModeMenuOpen] = useState41(false);
|
|
15832
15888
|
const displayMode = normalizeSmartLinkDisplayMode(element.displayMode);
|
|
15833
15889
|
const open = !readOnly && (isToolbarOpen || isModeMenuOpen);
|
|
15834
15890
|
const reference = useMemo16(() => readElementReference(element), [element]);
|
|
@@ -16005,12 +16061,12 @@ var PlainLinkElement = (props) => /* @__PURE__ */ jsx133(LinkElement, __spreadPr
|
|
|
16005
16061
|
|
|
16006
16062
|
// src/ui/link-toolbar.tsx
|
|
16007
16063
|
import { useEditorPlugin as useEditorPlugin12, useEditorSelector as useEditorSelector2, usePluginOption as usePluginOption17 } from "platejs/react";
|
|
16008
|
-
import { useCallback as useCallback45, useEffect as
|
|
16064
|
+
import { useCallback as useCallback45, useEffect as useEffect41, useState as useState44 } from "react";
|
|
16009
16065
|
|
|
16010
16066
|
// src/ui/link-search-panel.tsx
|
|
16011
16067
|
import { BookmarkIcon, LinkIcon as LinkIcon4 } from "lucide-react";
|
|
16012
16068
|
import { useEditorPlugin as useEditorPlugin10 } from "platejs/react";
|
|
16013
|
-
import { useCallback as useCallback43, useEffect as
|
|
16069
|
+
import { useCallback as useCallback43, useEffect as useEffect39, useState as useState42 } from "react";
|
|
16014
16070
|
|
|
16015
16071
|
// src/ui/link-toolbar-shared.ts
|
|
16016
16072
|
import { unwrapLink as unwrapLink2, upsertLink } from "@platejs/link";
|
|
@@ -16153,15 +16209,15 @@ function LinkSearchPanel({ initialUrl }) {
|
|
|
16153
16209
|
const adapter = useEditorAdapter();
|
|
16154
16210
|
const { editor } = useEditorPlugin10(linkPlugin);
|
|
16155
16211
|
const canLinkPage = adapter.permissions.canLinkPage;
|
|
16156
|
-
const [query, setQuery] =
|
|
16157
|
-
const [displayText, setDisplayText] =
|
|
16158
|
-
const [pages, setPages] =
|
|
16159
|
-
const [isLoading, setIsLoading] =
|
|
16212
|
+
const [query, setQuery] = useState42(initialUrl);
|
|
16213
|
+
const [displayText, setDisplayText] = useState42(() => readSelectionText(editor));
|
|
16214
|
+
const [pages, setPages] = useState42([]);
|
|
16215
|
+
const [isLoading, setIsLoading] = useState42(true);
|
|
16160
16216
|
const trimmedQuery = query.trim();
|
|
16161
16217
|
const safeUrl = trimmedQuery.length > 0 ? getSafeSmartLinkUrl(trimmedQuery) : null;
|
|
16162
16218
|
const searchTerm = isLikelySmartLinkUrl(query) ? "" : trimmedQuery;
|
|
16163
16219
|
const debouncedSearch = useDebounce(searchTerm, 200);
|
|
16164
|
-
|
|
16220
|
+
useEffect39(() => {
|
|
16165
16221
|
if (!canLinkPage) {
|
|
16166
16222
|
setPages([]);
|
|
16167
16223
|
setIsLoading(false);
|
|
@@ -16300,16 +16356,16 @@ import { CursorOverlayPlugin as CursorOverlayPlugin2 } from "@platejs/selection/
|
|
|
16300
16356
|
import { LinkIcon as LinkIcon5, Trash2Icon as Trash2Icon4 } from "lucide-react";
|
|
16301
16357
|
import { NodeApi as NodeApi16 } from "platejs";
|
|
16302
16358
|
import { useEditorPlugin as useEditorPlugin11, usePluginOption as usePluginOption16 } from "platejs/react";
|
|
16303
|
-
import { useCallback as useCallback44, useEffect as
|
|
16359
|
+
import { useCallback as useCallback44, useEffect as useEffect40, useState as useState43 } from "react";
|
|
16304
16360
|
import { jsx as jsx135, jsxs as jsxs85 } from "react/jsx-runtime";
|
|
16305
16361
|
function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
|
|
16306
|
-
const [url, setUrl] =
|
|
16307
|
-
const [text, setText] =
|
|
16362
|
+
const [url, setUrl] = useState43(initialUrl);
|
|
16363
|
+
const [text, setText] = useState43("");
|
|
16308
16364
|
const mode = usePluginOption16(linkPlugin, "mode");
|
|
16309
16365
|
const { editor, setOption } = useEditorPlugin11(linkPlugin);
|
|
16310
16366
|
const activeLinkId = usePluginOption16(linkPlugin, "activeId");
|
|
16311
16367
|
const editingLinkEntry = useActiveLink();
|
|
16312
|
-
|
|
16368
|
+
useEffect40(() => {
|
|
16313
16369
|
var _a;
|
|
16314
16370
|
if (!editingLinkEntry) return;
|
|
16315
16371
|
setText(NodeApi16.string(editingLinkEntry[0]));
|
|
@@ -16431,12 +16487,12 @@ function LinkFloatingToolbar() {
|
|
|
16431
16487
|
})) == null ? void 0 : _a2[0];
|
|
16432
16488
|
}, []);
|
|
16433
16489
|
const aboveUrl = (_a = aboveLink == null ? void 0 : aboveLink.url) != null ? _a : "";
|
|
16434
|
-
const [initialUrl, setInitialUrl] =
|
|
16490
|
+
const [initialUrl, setInitialUrl] = useState44(aboveUrl);
|
|
16435
16491
|
const open = mode === "insert" || mode === "edit" || mode === "cursor";
|
|
16436
|
-
|
|
16492
|
+
useEffect41(() => {
|
|
16437
16493
|
setInitialUrl(aboveUrl);
|
|
16438
16494
|
}, [aboveUrl]);
|
|
16439
|
-
|
|
16495
|
+
useEffect41(() => {
|
|
16440
16496
|
if (aboveLink) {
|
|
16441
16497
|
const timeoutId = window.setTimeout(() => {
|
|
16442
16498
|
var _a2;
|
|
@@ -17265,9 +17321,8 @@ function IconSettingsForm({
|
|
|
17265
17321
|
}
|
|
17266
17322
|
),
|
|
17267
17323
|
/* @__PURE__ */ jsx151(
|
|
17268
|
-
|
|
17324
|
+
UnstyledInput,
|
|
17269
17325
|
{
|
|
17270
|
-
type: "text",
|
|
17271
17326
|
value: colorValue,
|
|
17272
17327
|
onChange: handleColorChange,
|
|
17273
17328
|
placeholder: "Default",
|
|
@@ -17500,7 +17555,7 @@ import {
|
|
|
17500
17555
|
useReadOnly as useReadOnly18,
|
|
17501
17556
|
useSelected as useSelected5
|
|
17502
17557
|
} from "platejs/react";
|
|
17503
|
-
import React62, { useEffect as
|
|
17558
|
+
import React62, { useEffect as useEffect44 } from "react";
|
|
17504
17559
|
import { jsx as jsx154, jsxs as jsxs95 } from "react/jsx-runtime";
|
|
17505
17560
|
function EquationElement(props) {
|
|
17506
17561
|
const element = useElement14();
|
|
@@ -17561,7 +17616,7 @@ function InlineEquationElement(props) {
|
|
|
17561
17616
|
const selected = useSelected5();
|
|
17562
17617
|
const isCollapsed = useEditorSelector5((editor) => editor.api.isCollapsed(), []);
|
|
17563
17618
|
const [open, setOpen] = React62.useState(selected && isCollapsed);
|
|
17564
|
-
|
|
17619
|
+
useEffect44(() => {
|
|
17565
17620
|
if (selected && isCollapsed) {
|
|
17566
17621
|
setOpen(true);
|
|
17567
17622
|
}
|
|
@@ -17641,7 +17696,7 @@ function EquationPopoverContent(_a) {
|
|
|
17641
17696
|
const editor = useEditorRef34();
|
|
17642
17697
|
const readOnly = useReadOnly18();
|
|
17643
17698
|
const element = useElement14();
|
|
17644
|
-
|
|
17699
|
+
useEffect44(() => {
|
|
17645
17700
|
if (isInline && open) {
|
|
17646
17701
|
setOpen(true);
|
|
17647
17702
|
}
|
|
@@ -17731,9 +17786,10 @@ function Caption(_a) {
|
|
|
17731
17786
|
return /* @__PURE__ */ jsx155(CaptionPrimitive, __spreadProps(__spreadValues({}, props), { className: cn(captionVariants({ align }), "px-3 pb-2", className) }));
|
|
17732
17787
|
}
|
|
17733
17788
|
function CaptionTextarea(props) {
|
|
17789
|
+
const attributes = useTextFieldAttributes();
|
|
17734
17790
|
return /* @__PURE__ */ jsx155(
|
|
17735
17791
|
CaptionTextareaPrimitive,
|
|
17736
|
-
__spreadProps(__spreadValues({}, props), {
|
|
17792
|
+
__spreadProps(__spreadValues(__spreadValues({}, attributes), props), {
|
|
17737
17793
|
className: cn(
|
|
17738
17794
|
"mt-2 w-full resize-none border-none bg-inherit p-0 font-[inherit] text-inherit",
|
|
17739
17795
|
"focus:outline-none focus:placeholder:opacity-0",
|
|
@@ -18271,7 +18327,7 @@ import { useMediaState as useMediaState3 } from "@platejs/media/react";
|
|
|
18271
18327
|
import { ResizableProvider as ResizableProvider4 } from "@platejs/resizable";
|
|
18272
18328
|
import { ArrowUpRightIcon as ArrowUpRightIcon4, FileUpIcon, LinkIcon as LinkIcon7 } from "lucide-react";
|
|
18273
18329
|
import { PlateElement as PlateElement26, useEditorRef as useEditorRef38, useElement as useElement18, withHOC as withHOC4 } from "platejs/react";
|
|
18274
|
-
import { useCallback as useCallback59, useState as
|
|
18330
|
+
import { useCallback as useCallback59, useState as useState49 } from "react";
|
|
18275
18331
|
|
|
18276
18332
|
// src/ui/media-file-mode-dropdown.tsx
|
|
18277
18333
|
import { ChevronDownIcon as ChevronDownIcon9, FileIcon, FrameIcon, LinkIcon as LinkIcon6 } from "lucide-react";
|
|
@@ -18360,7 +18416,10 @@ function MediaFileBody({ canEmbed, displayMode, name, onAnchorClick, url }) {
|
|
|
18360
18416
|
return /* @__PURE__ */ jsxs103(
|
|
18361
18417
|
"a",
|
|
18362
18418
|
{
|
|
18363
|
-
className:
|
|
18419
|
+
className: cn(
|
|
18420
|
+
FILE_URL_CLASS_NAME,
|
|
18421
|
+
"cursor-pointer transition-colors hover:border-editor-link dark-or-inherit:hover:border-editor-link!"
|
|
18422
|
+
),
|
|
18364
18423
|
contentEditable: false,
|
|
18365
18424
|
href: url,
|
|
18366
18425
|
onClick: onAnchorClick,
|
|
@@ -18398,7 +18457,7 @@ var MediaFileElement = withHOC4(ResizableProvider4, function MediaFileElement2(p
|
|
|
18398
18457
|
const fileName = name != null ? name : "";
|
|
18399
18458
|
const fileUrl = unsafeUrl != null ? unsafeUrl : "";
|
|
18400
18459
|
const canEmbed = isEmbeddableFile(fileName, fileUrl);
|
|
18401
|
-
const [isModeMenuOpen, setIsModeMenuOpen] =
|
|
18460
|
+
const [isModeMenuOpen, setIsModeMenuOpen] = useState49(false);
|
|
18402
18461
|
const open = !readOnly && (selected || isModeMenuOpen);
|
|
18403
18462
|
const handleOpen = useCallback59(() => {
|
|
18404
18463
|
if (fileUrl.length === 0) return;
|
|
@@ -18486,7 +18545,7 @@ import { useDraggable as useDraggable2 } from "@platejs/dnd";
|
|
|
18486
18545
|
import { PlaceholderPlugin as PlaceholderPlugin2, useImage, useMediaState as useMediaState4 } from "@platejs/media/react";
|
|
18487
18546
|
import { ResizableProvider as ResizableProvider5 } from "@platejs/resizable";
|
|
18488
18547
|
import { PlateElement as PlateElement27, useEditorPlugin as useEditorPlugin16, withHOC as withHOC5 } from "platejs/react";
|
|
18489
|
-
import React67, { useEffect as
|
|
18548
|
+
import React67, { useEffect as useEffect46, useMemo as useMemo17 } from "react";
|
|
18490
18549
|
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
18491
18550
|
import { jsx as jsx165, jsxs as jsxs104 } from "react/jsx-runtime";
|
|
18492
18551
|
var ImageElement = withHOC5(
|
|
@@ -18627,7 +18686,7 @@ var ImageElement = withHOC5(
|
|
|
18627
18686
|
);
|
|
18628
18687
|
var ImagePlaceholder = ({ file }) => {
|
|
18629
18688
|
const objectUrl = useMemo17(() => file ? URL.createObjectURL(file) : null, [file]);
|
|
18630
|
-
|
|
18689
|
+
useEffect46(() => {
|
|
18631
18690
|
if (!objectUrl) return;
|
|
18632
18691
|
return () => URL.revokeObjectURL(objectUrl);
|
|
18633
18692
|
}, [objectUrl]);
|
|
@@ -18645,7 +18704,7 @@ import {
|
|
|
18645
18704
|
import { AudioLinesIcon, FileUpIcon as FileUpIcon2, FilmIcon, ImageIcon as ImageIcon2 } from "lucide-react";
|
|
18646
18705
|
import { KEYS as KEYS29, nanoid as nanoid10 } from "platejs";
|
|
18647
18706
|
import { PlateElement as PlateElement28, useEditorPlugin as useEditorPlugin17, withHOC as withHOC6 } from "platejs/react";
|
|
18648
|
-
import { useCallback as useCallback60, useEffect as
|
|
18707
|
+
import { useCallback as useCallback60, useEffect as useEffect47, useRef as useRef16, useState as useState50 } from "react";
|
|
18649
18708
|
import { useFilePicker } from "use-file-picker";
|
|
18650
18709
|
|
|
18651
18710
|
// src/hooks/use-upload-file.ts
|
|
@@ -18819,8 +18878,8 @@ var PlaceholderElement = withHOC6(PlaceholderProvider, (props) => {
|
|
|
18819
18878
|
const isImage = mediaType === KEYS29.img;
|
|
18820
18879
|
const file = updatedFiles == null ? void 0 : updatedFiles[0];
|
|
18821
18880
|
const progress = file ? progresses == null ? void 0 : progresses[file.name] : void 0;
|
|
18822
|
-
const imageRef =
|
|
18823
|
-
|
|
18881
|
+
const imageRef = useRef16(null);
|
|
18882
|
+
useEffect47(() => {
|
|
18824
18883
|
if (!imageRef.current) return;
|
|
18825
18884
|
const { height, width } = imageRef.current;
|
|
18826
18885
|
setSize == null ? void 0 : setSize({
|
|
@@ -18887,7 +18946,7 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
18887
18946
|
var _a, _b, _c;
|
|
18888
18947
|
const { api, editor, getOption, tf } = useEditorPlugin17(PlaceholderPlugin3);
|
|
18889
18948
|
const { id, element, mediaType, readOnly, selected, setIsUploading, setProgresses, setUpdatedFiles, size } = usePlaceholderPopoverState();
|
|
18890
|
-
const [open, setOpen] =
|
|
18949
|
+
const [open, setOpen] = useState50(false);
|
|
18891
18950
|
const currentMedia = MEDIA_CONFIG[mediaType];
|
|
18892
18951
|
const uploadConfig = useUploadConfig();
|
|
18893
18952
|
const adapter = useEditorAdapter();
|
|
@@ -18921,15 +18980,15 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
18921
18980
|
}
|
|
18922
18981
|
}
|
|
18923
18982
|
});
|
|
18924
|
-
const isReplaced =
|
|
18925
|
-
|
|
18983
|
+
const isReplaced = useRef16(false);
|
|
18984
|
+
useEffect47(() => {
|
|
18926
18985
|
if (isReplaced.current) return;
|
|
18927
18986
|
isReplaced.current = true;
|
|
18928
18987
|
const currentFiles = api.placeholder.getUploadingFile(element.id);
|
|
18929
18988
|
if (!currentFiles) return;
|
|
18930
18989
|
replaceCurrentPlaceholder(currentFiles);
|
|
18931
18990
|
}, [isReplaced]);
|
|
18932
|
-
|
|
18991
|
+
useEffect47(() => {
|
|
18933
18992
|
if (!uploadedFile) return;
|
|
18934
18993
|
const path = editor.api.findPath(element);
|
|
18935
18994
|
setMediaNode(
|
|
@@ -18947,7 +19006,7 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
18947
19006
|
{ at: path }
|
|
18948
19007
|
);
|
|
18949
19008
|
}, [uploadedFile, element.id, size]);
|
|
18950
|
-
const [embedValue, setEmbedValue] =
|
|
19009
|
+
const [embedValue, setEmbedValue] = useState50("");
|
|
18951
19010
|
const onEmbed = useCallback60(
|
|
18952
19011
|
(value) => {
|
|
18953
19012
|
const path = editor.api.findPath(element);
|
|
@@ -18962,15 +19021,15 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
18962
19021
|
},
|
|
18963
19022
|
[editor, element, mediaType]
|
|
18964
19023
|
);
|
|
18965
|
-
|
|
19024
|
+
useEffect47(() => {
|
|
18966
19025
|
setOpen(selected);
|
|
18967
19026
|
}, [selected, setOpen]);
|
|
18968
|
-
|
|
19027
|
+
useEffect47(() => {
|
|
18969
19028
|
if (isUploading) {
|
|
18970
19029
|
setOpen(false);
|
|
18971
19030
|
}
|
|
18972
19031
|
}, [isUploading]);
|
|
18973
|
-
|
|
19032
|
+
useEffect47(() => {
|
|
18974
19033
|
var _a2;
|
|
18975
19034
|
setProgresses({ [(_a2 = uploadingFile == null ? void 0 : uploadingFile.name) != null ? _a2 : ""]: progress });
|
|
18976
19035
|
setIsUploading(isUploading);
|
|
@@ -19003,8 +19062,8 @@ function ImageProgress({
|
|
|
19003
19062
|
imageRef,
|
|
19004
19063
|
progress = 0
|
|
19005
19064
|
}) {
|
|
19006
|
-
const [objectUrl, setObjectUrl] =
|
|
19007
|
-
|
|
19065
|
+
const [objectUrl, setObjectUrl] = useState50(null);
|
|
19066
|
+
useEffect47(() => {
|
|
19008
19067
|
const url = URL.createObjectURL(file);
|
|
19009
19068
|
setObjectUrl(url);
|
|
19010
19069
|
return () => {
|
|
@@ -19163,13 +19222,13 @@ function ImagePreview() {
|
|
|
19163
19222
|
// src/ui/media-upload-toast.tsx
|
|
19164
19223
|
import { PlaceholderPlugin as PlaceholderPlugin5, UploadErrorCode } from "@platejs/media/react";
|
|
19165
19224
|
import { usePluginOption as usePluginOption21 } from "platejs/react";
|
|
19166
|
-
import { useEffect as
|
|
19225
|
+
import { useEffect as useEffect48 } from "react";
|
|
19167
19226
|
import { toast as toast4 } from "sonner";
|
|
19168
19227
|
|
|
19169
19228
|
// src/ui/use-placeholder-max-file-size.ts
|
|
19170
19229
|
import { PlaceholderPlugin as PlaceholderPlugin4 } from "@platejs/media/react";
|
|
19171
19230
|
import { useEditorRef as useEditorRef40 } from "platejs/react";
|
|
19172
|
-
import { useLayoutEffect as
|
|
19231
|
+
import { useLayoutEffect as useLayoutEffect3 } from "react";
|
|
19173
19232
|
var PLACEHOLDER_FILE_KIND_PATTERNS = {
|
|
19174
19233
|
audio: "audio/*",
|
|
19175
19234
|
blob: "*",
|
|
@@ -19202,7 +19261,7 @@ var acceptedFileTypesFromKey = (key) => {
|
|
|
19202
19261
|
};
|
|
19203
19262
|
var useEditorMaxFileSize = (editor, maxFileSize, acceptedFileTypes) => {
|
|
19204
19263
|
const acceptedFileTypesKey = acceptedFileTypes == null ? void 0 : acceptedFileTypes.join(FILE_TYPE_KEY_SEPARATOR);
|
|
19205
|
-
|
|
19264
|
+
useLayoutEffect3(() => {
|
|
19206
19265
|
var _a;
|
|
19207
19266
|
const previous = EDITOR_UPLOAD_CONFIGS.get(editor);
|
|
19208
19267
|
if (maxFileSize === void 0 && acceptedFileTypesKey === void 0) {
|
|
@@ -19241,7 +19300,7 @@ function MediaUploadToast() {
|
|
|
19241
19300
|
}
|
|
19242
19301
|
var useUploadErrorToast = () => {
|
|
19243
19302
|
const uploadError = usePluginOption21(PlaceholderPlugin5, "error");
|
|
19244
|
-
|
|
19303
|
+
useEffect48(() => {
|
|
19245
19304
|
if (!uploadError) return;
|
|
19246
19305
|
const { code, data } = uploadError;
|
|
19247
19306
|
switch (code) {
|
|
@@ -19391,7 +19450,7 @@ import { KEYS as KEYS31 } from "platejs";
|
|
|
19391
19450
|
// src/ui/mention-element.tsx
|
|
19392
19451
|
import { IS_APPLE as IS_APPLE2 } from "platejs";
|
|
19393
19452
|
import { PlateElement as PlateElement31, useFocused as useFocused5, useHotkeys as useHotkeys4, useReadOnly as useReadOnly20, useSelected as useSelected7 } from "platejs/react";
|
|
19394
|
-
import { useCallback as useCallback63, useState as
|
|
19453
|
+
import { useCallback as useCallback63, useState as useState52 } from "react";
|
|
19395
19454
|
import { useMounted as useMounted2 } from "react-tweet";
|
|
19396
19455
|
|
|
19397
19456
|
// src/ui/mention-document-element.tsx
|
|
@@ -19403,7 +19462,7 @@ import {
|
|
|
19403
19462
|
useReadOnly as useReadOnly19,
|
|
19404
19463
|
useSelected as useSelected6
|
|
19405
19464
|
} from "platejs/react";
|
|
19406
|
-
import { useCallback as useCallback62, useMemo as useMemo18, useState as
|
|
19465
|
+
import { useCallback as useCallback62, useMemo as useMemo18, useState as useState51 } from "react";
|
|
19407
19466
|
|
|
19408
19467
|
// src/ui/mention-document-hover-card.tsx
|
|
19409
19468
|
import { useCallback as useCallback61 } from "react";
|
|
@@ -19455,8 +19514,8 @@ function DocumentMentionElement(props) {
|
|
|
19455
19514
|
const focused = useFocused4();
|
|
19456
19515
|
const editor = useEditorRef41();
|
|
19457
19516
|
const readOnly = useReadOnly19();
|
|
19458
|
-
const [isToolbarOpen, setIsToolbarOpen] =
|
|
19459
|
-
const [isModeMenuOpen, setIsModeMenuOpen] =
|
|
19517
|
+
const [isToolbarOpen, setIsToolbarOpen] = useState51(false);
|
|
19518
|
+
const [isModeMenuOpen, setIsModeMenuOpen] = useState51(false);
|
|
19460
19519
|
const adapter = useEditorAdapter();
|
|
19461
19520
|
const canLinkPage = adapter.permissions.canLinkPage;
|
|
19462
19521
|
const resolvePage = adapter.pageLinks.resolvePage;
|
|
@@ -19609,7 +19668,7 @@ function UserMentionElement(props) {
|
|
|
19609
19668
|
const resolveMember = adapter.mentions.resolveMember;
|
|
19610
19669
|
const memberId = (_a = element.key) != null ? _a : "";
|
|
19611
19670
|
const canShowCard = typeof resolveMember === "function" && memberId.length > 0;
|
|
19612
|
-
const [wantOpen, setWantOpen] =
|
|
19671
|
+
const [wantOpen, setWantOpen] = useState52(false);
|
|
19613
19672
|
const { profile, isLoading, hasResolved } = useMemberProfile({
|
|
19614
19673
|
enabled: canShowCard && wantOpen,
|
|
19615
19674
|
memberId,
|
|
@@ -19700,17 +19759,17 @@ function UserMentionElement(props) {
|
|
|
19700
19759
|
import { DatePlugin as DatePlugin2 } from "@platejs/date/react";
|
|
19701
19760
|
import { MentionPlugin } from "@platejs/mention/react";
|
|
19702
19761
|
import { PlateElement as PlateElement32 } from "platejs/react";
|
|
19703
|
-
import { useCallback as useCallback64, useState as
|
|
19762
|
+
import { useCallback as useCallback64, useState as useState55 } from "react";
|
|
19704
19763
|
|
|
19705
19764
|
// src/ui/mention-page-combobox-group.tsx
|
|
19706
19765
|
import { FileTextIcon as FileTextIcon3 } from "lucide-react";
|
|
19707
|
-
import { useEffect as
|
|
19766
|
+
import { useEffect as useEffect49, useState as useState53 } from "react";
|
|
19708
19767
|
import { jsx as jsx172, jsxs as jsxs110 } from "react/jsx-runtime";
|
|
19709
19768
|
function PageComboboxGroup({ search, onPageHover, onPageSelect }) {
|
|
19710
19769
|
const adapter = useEditorAdapter();
|
|
19711
19770
|
const debouncedSearch = useDebounce(search, 250);
|
|
19712
|
-
const [pages, setPages] =
|
|
19713
|
-
|
|
19771
|
+
const [pages, setPages] = useState53([]);
|
|
19772
|
+
useEffect49(() => {
|
|
19714
19773
|
if (!adapter.permissions.canLinkPage) {
|
|
19715
19774
|
setPages([]);
|
|
19716
19775
|
return;
|
|
@@ -19759,13 +19818,13 @@ function PageStatusBadge({ status }) {
|
|
|
19759
19818
|
}
|
|
19760
19819
|
|
|
19761
19820
|
// src/ui/mention-people-combobox-group.tsx
|
|
19762
|
-
import { useEffect as
|
|
19821
|
+
import { useEffect as useEffect50, useState as useState54 } from "react";
|
|
19763
19822
|
import { jsx as jsx173, jsxs as jsxs111 } from "react/jsx-runtime";
|
|
19764
19823
|
function PeopleComboboxGroup({ search, onUserHover, onUserSelect }) {
|
|
19765
19824
|
const adapter = useEditorAdapter();
|
|
19766
19825
|
const debouncedSearch = useDebounce(search, 150);
|
|
19767
|
-
const [members, setMembers] =
|
|
19768
|
-
|
|
19826
|
+
const [members, setMembers] = useState54([]);
|
|
19827
|
+
useEffect50(() => {
|
|
19769
19828
|
if (!adapter.permissions.canMention) {
|
|
19770
19829
|
setMembers([]);
|
|
19771
19830
|
return;
|
|
@@ -19818,8 +19877,8 @@ var DEFAULT_PLACEHOLDER = "Mention a person, page, or date";
|
|
|
19818
19877
|
var TODAY_PLACEHOLDER = "Today";
|
|
19819
19878
|
function MentionInputElement(props) {
|
|
19820
19879
|
const { children, editor, element } = props;
|
|
19821
|
-
const [search, setSearch] =
|
|
19822
|
-
const [placeholder, setPlaceholder] =
|
|
19880
|
+
const [search, setSearch] = useState55("");
|
|
19881
|
+
const [placeholder, setPlaceholder] = useState55(DEFAULT_PLACEHOLDER);
|
|
19823
19882
|
const handleDateFocus = useCallback64(() => {
|
|
19824
19883
|
setPlaceholder(TODAY_PLACEHOLDER);
|
|
19825
19884
|
}, []);
|
|
@@ -21265,7 +21324,7 @@ function StepElement(props) {
|
|
|
21265
21324
|
/* @__PURE__ */ jsxs117("div", { className: "flex-1 pt-0.5", children: [
|
|
21266
21325
|
/* @__PURE__ */ jsxs117("div", { className: "flex items-center gap-2", contentEditable: false, children: [
|
|
21267
21326
|
isEditingTitle ? /* @__PURE__ */ jsx179(
|
|
21268
|
-
|
|
21327
|
+
UnstyledInput,
|
|
21269
21328
|
{
|
|
21270
21329
|
ref: titleInputRef,
|
|
21271
21330
|
className: cn(titleClass, "min-w-30 bg-transparent outline-none"),
|
|
@@ -21390,7 +21449,7 @@ import {
|
|
|
21390
21449
|
useSelected as useSelected8,
|
|
21391
21450
|
withHOC as withHOC8
|
|
21392
21451
|
} from "platejs/react";
|
|
21393
|
-
import { useRef as
|
|
21452
|
+
import { useRef as useRef19 } from "react";
|
|
21394
21453
|
|
|
21395
21454
|
// src/ui/table-icons.tsx
|
|
21396
21455
|
import { jsx as jsx180, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
@@ -21594,7 +21653,7 @@ var TableElement = withHOC8(
|
|
|
21594
21653
|
const isSelectionAreaVisible = usePluginOption22(BlockSelectionPlugin10, "isSelectionAreaVisible");
|
|
21595
21654
|
const hasControls = !readOnly && !isSelectionAreaVisible;
|
|
21596
21655
|
const { marginLeft, props: tableProps } = useTableElement();
|
|
21597
|
-
const tableRef =
|
|
21656
|
+
const tableRef = useRef19(null);
|
|
21598
21657
|
useTableSelectionDom(tableRef);
|
|
21599
21658
|
const isSelectingTable = useBlockSelected2(props.element.id);
|
|
21600
21659
|
const content = /* @__PURE__ */ jsx181(
|
|
@@ -22236,7 +22295,7 @@ var TabTrigger2 = React73.forwardRef(
|
|
|
22236
22295
|
onKeyDown: handleTabKeyDown,
|
|
22237
22296
|
children: [
|
|
22238
22297
|
isEditing ? /* @__PURE__ */ jsx182(
|
|
22239
|
-
|
|
22298
|
+
UnstyledInput,
|
|
22240
22299
|
{
|
|
22241
22300
|
ref: inputRef,
|
|
22242
22301
|
className: cn(
|
|
@@ -22478,7 +22537,7 @@ function TileElement(props) {
|
|
|
22478
22537
|
),
|
|
22479
22538
|
children: [
|
|
22480
22539
|
/* @__PURE__ */ jsx184("div", { className: "flex items-start justify-between gap-2", contentEditable: false, children: /* @__PURE__ */ jsx184("div", { className: "flex-1", children: isEditingTitle ? /* @__PURE__ */ jsx184(
|
|
22481
|
-
|
|
22540
|
+
UnstyledInput,
|
|
22482
22541
|
{
|
|
22483
22542
|
ref: titleInputRef,
|
|
22484
22543
|
className: "w-full bg-transparent font-semibold text-foreground outline-none",
|
|
@@ -22879,7 +22938,7 @@ function DefaultToggleView({
|
|
|
22879
22938
|
children: [
|
|
22880
22939
|
/* @__PURE__ */ jsx187(ToggleChevron, { open }),
|
|
22881
22940
|
isEditing ? /* @__PURE__ */ jsx187(
|
|
22882
|
-
|
|
22941
|
+
UnstyledInput,
|
|
22883
22942
|
{
|
|
22884
22943
|
ref: inputRef,
|
|
22885
22944
|
className: "min-w-30 bg-transparent font-semibold text-foreground outline-none",
|
|
@@ -24945,7 +25004,7 @@ function UpdateElement(props) {
|
|
|
24945
25004
|
return /* @__PURE__ */ jsx203(PlateElement45, __spreadProps(__spreadValues({}, props), { className: "group/update relative", children: /* @__PURE__ */ jsxs137("div", { id: anchorId, className: "grid grid-cols-[140px_1fr] items-start gap-8 py-8", "data-plate-open-context-menu": true, children: [
|
|
24946
25005
|
/* @__PURE__ */ jsx203("div", { className: "sticky top-24", contentEditable: false, children: /* @__PURE__ */ jsxs137("div", { className: "flex flex-col items-start gap-2", children: [
|
|
24947
25006
|
isEditingLabel ? /* @__PURE__ */ jsx203(
|
|
24948
|
-
|
|
25007
|
+
UnstyledInput,
|
|
24949
25008
|
{
|
|
24950
25009
|
ref: labelInputRef,
|
|
24951
25010
|
className: "border-primary border-b bg-transparent text-sm font-medium text-primary outline-none",
|