@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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.3 (2026-11-26)
4
+
5
+ ### Fixes
6
+
7
+ - Import `lucide-react/dynamic.mjs` by its full file name, so Next.js with Turbopack, webpack, and Node resolve the icon picker's dynamic icons.
8
+ - Return focus to the editor when a writer picks a block from the slash menu, so the next words go into that block every time.
9
+
3
10
  ## 0.4.1 (2026-11-26)
4
11
 
5
12
  ### Breaking changes
package/README.md CHANGED
@@ -161,7 +161,7 @@ To try the editor in an app while you change it, run `pnpm dev` here and link th
161
161
 
162
162
  ## Releases
163
163
 
164
- The version in `package.json` is the version that the next release publishes, and [CHANGELOG.md](CHANGELOG.md) records each release. To release, update both in a commit on `main`, then push a tag that matches the version, such as `v0.4.0`. The publish workflow checks that the tag matches `package.json`, then lints, type-checks, builds, tests, and publishes the package to npm through trusted publishing, so the repository holds no npm token.
164
+ The version in `package.json` is the version that the next release publishes, and [CHANGELOG.md](CHANGELOG.md) records each release. To release, update both in a commit on `main`, then push a tag that matches the version, such as `v0.4.0`. The publish workflow checks that the tag matches `package.json`, then lints, type-checks, builds, and tests it. Finally, it stages the version on npm through trusted publishing, so the repository holds no npm token. A maintainer then approves the staged version in the Staged Packages tab on npmjs.com, or with `npm stage approve <stage-id>`, and the version goes live.
165
165
 
166
166
  ## License
167
167
 
@@ -11512,7 +11512,7 @@ function BadgeShapeButton({ shape, selected, setShape, updateElement }) {
11512
11512
 
11513
11513
  // src/ui/icon-picker.tsx
11514
11514
  import { icons as lucideIcons } from "lucide-react";
11515
- import { dynamicIconImports } from "lucide-react/dynamic";
11515
+ import { dynamicIconImports } from "lucide-react/dynamic.mjs";
11516
11516
  import * as React34 from "react";
11517
11517
  import { Fragment as Fragment11, jsx as jsx91, jsxs as jsxs54 } from "react/jsx-runtime";
11518
11518
  var toPascalCase = (str) => str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
@@ -15245,11 +15245,49 @@ import { filterWords } from "@platejs/combobox";
15245
15245
  import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
15246
15246
  import { cva as cva22 } from "class-variance-authority";
15247
15247
  import { useComposedRef as useComposedRef2, useEditorRef as useEditorRef24 } from "platejs/react";
15248
- import React55, { useEffect as useEffect36 } from "react";
15248
+ import React55, { useEffect as useEffect37 } from "react";
15249
+
15250
+ // src/hooks/use-return-focus-to-editor-on-input-removal.ts
15251
+ import { useEffect as useEffect35, useLayoutEffect as useLayoutEffect2, useRef as useRef15 } from "react";
15252
+ var focusEditableAtEditorSelection = (editor) => {
15253
+ const editable = editor.api.toDOMNode(editor);
15254
+ if (!(editable == null ? void 0 : editable.isConnected)) {
15255
+ return;
15256
+ }
15257
+ const document2 = editable.ownerDocument;
15258
+ const activeElement = document2.activeElement;
15259
+ if (activeElement && activeElement !== document2.body) {
15260
+ return;
15261
+ }
15262
+ const domRange = editor.selection ? editor.api.toDOMRange(editor.selection) : void 0;
15263
+ editable.focus({ preventScroll: true });
15264
+ const domSelection = document2.getSelection();
15265
+ if (domRange && domSelection) {
15266
+ domSelection.removeAllRanges();
15267
+ domSelection.addRange(domRange);
15268
+ }
15269
+ };
15270
+ var useReturnFocusToEditorOnInputRemoval = (editor, inputRef) => {
15271
+ const inputHadFocusWhenRemoved = useRef15(false);
15272
+ useLayoutEffect2(() => {
15273
+ const input = inputRef.current;
15274
+ return () => {
15275
+ inputHadFocusWhenRemoved.current = !!input && input.ownerDocument.activeElement === input;
15276
+ };
15277
+ }, [inputRef]);
15278
+ useEffect35(
15279
+ () => () => {
15280
+ if (inputHadFocusWhenRemoved.current) {
15281
+ focusEditableAtEditorSelection(editor);
15282
+ }
15283
+ },
15284
+ [editor]
15285
+ );
15286
+ };
15249
15287
 
15250
15288
  // src/hooks/use-shield-input-selection-from-editor.ts
15251
15289
  import { RangeApi as RangeApi2 } from "platejs";
15252
- import { useEffect as useEffect35 } from "react";
15290
+ import { useEffect as useEffect36 } from "react";
15253
15291
  var SLATE_TEXT_SELECTOR = "[data-slate-string], [data-slate-zero-width]";
15254
15292
  var isCaretInEditorText = (node) => {
15255
15293
  var _a;
@@ -15267,7 +15305,7 @@ var wouldPullCaretOutOfInput = (editor, input) => {
15267
15305
  return !!range && RangeApi2.equals(range, editor.selection);
15268
15306
  };
15269
15307
  var useShieldInputSelectionFromEditor = (editor, inputRef) => {
15270
- useEffect35(() => {
15308
+ useEffect36(() => {
15271
15309
  const input = inputRef.current;
15272
15310
  const view = input == null ? void 0 : input.ownerDocument.defaultView;
15273
15311
  if (!input || !view) {
@@ -15331,7 +15369,7 @@ function InlineCombobox({
15331
15369
  [setValueProp, hasValueProp]
15332
15370
  );
15333
15371
  const insertPoint = React55.useRef(null);
15334
- useEffect36(() => {
15372
+ useEffect37(() => {
15335
15373
  const path = editor.api.findPath(element);
15336
15374
  if (!path) return;
15337
15375
  const point = editor.api.before(path);
@@ -15397,6 +15435,7 @@ function InlineComboboxInput(_a) {
15397
15435
  const editor = useEditorRef24();
15398
15436
  const ref = useComposedRef2(refProp, contextRef);
15399
15437
  useShieldInputSelectionFromEditor(editor, contextRef);
15438
+ useReturnFocusToEditorOnInputRemoval(editor, contextRef);
15400
15439
  return /* @__PURE__ */ jsxs79(Fragment19, { children: [
15401
15440
  showTrigger && trigger,
15402
15441
  /* @__PURE__ */ jsxs79("span", { className: "relative min-h-lh", children: [
@@ -15496,7 +15535,7 @@ function InlineComboboxEmpty({ children, className }) {
15496
15535
  const { setHasEmpty } = React55.useContext(InlineComboboxContext);
15497
15536
  const store = Ariakit2.useComboboxContext();
15498
15537
  const items = (_a = store == null ? void 0 : store.useState("items")) != null ? _a : [];
15499
- useEffect36(() => {
15538
+ useEffect37(() => {
15500
15539
  setHasEmpty(true);
15501
15540
  return () => {
15502
15541
  setHasEmpty(false);
@@ -15656,11 +15695,11 @@ import { ArrowUpRightIcon as ArrowUpRightIcon3, PencilIcon as PencilIcon6, Trash
15656
15695
 
15657
15696
  // src/ui/smart-link-copy-button.tsx
15658
15697
  import { CheckIcon as CheckIcon15, CopyIcon as CopyIcon2, XIcon as XIcon7 } from "lucide-react";
15659
- import { useCallback as useCallback40, useEffect as useEffect37, useState as useState39 } from "react";
15698
+ import { useCallback as useCallback40, useEffect as useEffect38, useState as useState39 } from "react";
15660
15699
  import { jsx as jsx130 } from "react/jsx-runtime";
15661
15700
  function SmartLinkCopyButton({ disabled, onCopy }) {
15662
15701
  const [feedback, setFeedback] = useState39("idle");
15663
- useEffect37(() => {
15702
+ useEffect38(() => {
15664
15703
  if (feedback === "idle") return;
15665
15704
  const timeoutId = window.setTimeout(() => {
15666
15705
  setFeedback("idle");
@@ -16005,12 +16044,12 @@ var PlainLinkElement = (props) => /* @__PURE__ */ jsx133(LinkElement, __spreadPr
16005
16044
 
16006
16045
  // src/ui/link-toolbar.tsx
16007
16046
  import { useEditorPlugin as useEditorPlugin12, useEditorSelector as useEditorSelector2, usePluginOption as usePluginOption17 } from "platejs/react";
16008
- import { useCallback as useCallback45, useEffect as useEffect40, useState as useState43 } from "react";
16047
+ import { useCallback as useCallback45, useEffect as useEffect41, useState as useState43 } from "react";
16009
16048
 
16010
16049
  // src/ui/link-search-panel.tsx
16011
16050
  import { BookmarkIcon, LinkIcon as LinkIcon4 } from "lucide-react";
16012
16051
  import { useEditorPlugin as useEditorPlugin10 } from "platejs/react";
16013
- import { useCallback as useCallback43, useEffect as useEffect38, useState as useState41 } from "react";
16052
+ import { useCallback as useCallback43, useEffect as useEffect39, useState as useState41 } from "react";
16014
16053
 
16015
16054
  // src/ui/link-toolbar-shared.ts
16016
16055
  import { unwrapLink as unwrapLink2, upsertLink } from "@platejs/link";
@@ -16161,7 +16200,7 @@ function LinkSearchPanel({ initialUrl }) {
16161
16200
  const safeUrl = trimmedQuery.length > 0 ? getSafeSmartLinkUrl(trimmedQuery) : null;
16162
16201
  const searchTerm = isLikelySmartLinkUrl(query) ? "" : trimmedQuery;
16163
16202
  const debouncedSearch = useDebounce(searchTerm, 200);
16164
- useEffect38(() => {
16203
+ useEffect39(() => {
16165
16204
  if (!canLinkPage) {
16166
16205
  setPages([]);
16167
16206
  setIsLoading(false);
@@ -16300,7 +16339,7 @@ import { CursorOverlayPlugin as CursorOverlayPlugin2 } from "@platejs/selection/
16300
16339
  import { LinkIcon as LinkIcon5, Trash2Icon as Trash2Icon4 } from "lucide-react";
16301
16340
  import { NodeApi as NodeApi16 } from "platejs";
16302
16341
  import { useEditorPlugin as useEditorPlugin11, usePluginOption as usePluginOption16 } from "platejs/react";
16303
- import { useCallback as useCallback44, useEffect as useEffect39, useState as useState42 } from "react";
16342
+ import { useCallback as useCallback44, useEffect as useEffect40, useState as useState42 } from "react";
16304
16343
  import { jsx as jsx135, jsxs as jsxs85 } from "react/jsx-runtime";
16305
16344
  function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
16306
16345
  const [url, setUrl] = useState42(initialUrl);
@@ -16309,7 +16348,7 @@ function EditLinkCommand({ autoFocus, initialUrl, setInitialUrl }) {
16309
16348
  const { editor, setOption } = useEditorPlugin11(linkPlugin);
16310
16349
  const activeLinkId = usePluginOption16(linkPlugin, "activeId");
16311
16350
  const editingLinkEntry = useActiveLink();
16312
- useEffect39(() => {
16351
+ useEffect40(() => {
16313
16352
  var _a;
16314
16353
  if (!editingLinkEntry) return;
16315
16354
  setText(NodeApi16.string(editingLinkEntry[0]));
@@ -16433,10 +16472,10 @@ function LinkFloatingToolbar() {
16433
16472
  const aboveUrl = (_a = aboveLink == null ? void 0 : aboveLink.url) != null ? _a : "";
16434
16473
  const [initialUrl, setInitialUrl] = useState43(aboveUrl);
16435
16474
  const open = mode === "insert" || mode === "edit" || mode === "cursor";
16436
- useEffect40(() => {
16475
+ useEffect41(() => {
16437
16476
  setInitialUrl(aboveUrl);
16438
16477
  }, [aboveUrl]);
16439
- useEffect40(() => {
16478
+ useEffect41(() => {
16440
16479
  if (aboveLink) {
16441
16480
  const timeoutId = window.setTimeout(() => {
16442
16481
  var _a2;
@@ -17500,7 +17539,7 @@ import {
17500
17539
  useReadOnly as useReadOnly18,
17501
17540
  useSelected as useSelected5
17502
17541
  } from "platejs/react";
17503
- import React62, { useEffect as useEffect43 } from "react";
17542
+ import React62, { useEffect as useEffect44 } from "react";
17504
17543
  import { jsx as jsx154, jsxs as jsxs95 } from "react/jsx-runtime";
17505
17544
  function EquationElement(props) {
17506
17545
  const element = useElement14();
@@ -17561,7 +17600,7 @@ function InlineEquationElement(props) {
17561
17600
  const selected = useSelected5();
17562
17601
  const isCollapsed = useEditorSelector5((editor) => editor.api.isCollapsed(), []);
17563
17602
  const [open, setOpen] = React62.useState(selected && isCollapsed);
17564
- useEffect43(() => {
17603
+ useEffect44(() => {
17565
17604
  if (selected && isCollapsed) {
17566
17605
  setOpen(true);
17567
17606
  }
@@ -17641,7 +17680,7 @@ function EquationPopoverContent(_a) {
17641
17680
  const editor = useEditorRef34();
17642
17681
  const readOnly = useReadOnly18();
17643
17682
  const element = useElement14();
17644
- useEffect43(() => {
17683
+ useEffect44(() => {
17645
17684
  if (isInline && open) {
17646
17685
  setOpen(true);
17647
17686
  }
@@ -18486,7 +18525,7 @@ import { useDraggable as useDraggable2 } from "@platejs/dnd";
18486
18525
  import { PlaceholderPlugin as PlaceholderPlugin2, useImage, useMediaState as useMediaState4 } from "@platejs/media/react";
18487
18526
  import { ResizableProvider as ResizableProvider5 } from "@platejs/resizable";
18488
18527
  import { PlateElement as PlateElement27, useEditorPlugin as useEditorPlugin16, withHOC as withHOC5 } from "platejs/react";
18489
- import React67, { useEffect as useEffect45, useMemo as useMemo17 } from "react";
18528
+ import React67, { useEffect as useEffect46, useMemo as useMemo17 } from "react";
18490
18529
  import { LazyLoadImage } from "react-lazy-load-image-component";
18491
18530
  import { jsx as jsx165, jsxs as jsxs104 } from "react/jsx-runtime";
18492
18531
  var ImageElement = withHOC5(
@@ -18627,7 +18666,7 @@ var ImageElement = withHOC5(
18627
18666
  );
18628
18667
  var ImagePlaceholder = ({ file }) => {
18629
18668
  const objectUrl = useMemo17(() => file ? URL.createObjectURL(file) : null, [file]);
18630
- useEffect45(() => {
18669
+ useEffect46(() => {
18631
18670
  if (!objectUrl) return;
18632
18671
  return () => URL.revokeObjectURL(objectUrl);
18633
18672
  }, [objectUrl]);
@@ -18645,7 +18684,7 @@ import {
18645
18684
  import { AudioLinesIcon, FileUpIcon as FileUpIcon2, FilmIcon, ImageIcon as ImageIcon2 } from "lucide-react";
18646
18685
  import { KEYS as KEYS29, nanoid as nanoid10 } from "platejs";
18647
18686
  import { PlateElement as PlateElement28, useEditorPlugin as useEditorPlugin17, withHOC as withHOC6 } from "platejs/react";
18648
- import { useCallback as useCallback60, useEffect as useEffect46, useRef as useRef15, useState as useState49 } from "react";
18687
+ import { useCallback as useCallback60, useEffect as useEffect47, useRef as useRef16, useState as useState49 } from "react";
18649
18688
  import { useFilePicker } from "use-file-picker";
18650
18689
 
18651
18690
  // src/hooks/use-upload-file.ts
@@ -18819,8 +18858,8 @@ var PlaceholderElement = withHOC6(PlaceholderProvider, (props) => {
18819
18858
  const isImage = mediaType === KEYS29.img;
18820
18859
  const file = updatedFiles == null ? void 0 : updatedFiles[0];
18821
18860
  const progress = file ? progresses == null ? void 0 : progresses[file.name] : void 0;
18822
- const imageRef = useRef15(null);
18823
- useEffect46(() => {
18861
+ const imageRef = useRef16(null);
18862
+ useEffect47(() => {
18824
18863
  if (!imageRef.current) return;
18825
18864
  const { height, width } = imageRef.current;
18826
18865
  setSize == null ? void 0 : setSize({
@@ -18921,15 +18960,15 @@ function MediaPlaceholderPopover({ children }) {
18921
18960
  }
18922
18961
  }
18923
18962
  });
18924
- const isReplaced = useRef15(false);
18925
- useEffect46(() => {
18963
+ const isReplaced = useRef16(false);
18964
+ useEffect47(() => {
18926
18965
  if (isReplaced.current) return;
18927
18966
  isReplaced.current = true;
18928
18967
  const currentFiles = api.placeholder.getUploadingFile(element.id);
18929
18968
  if (!currentFiles) return;
18930
18969
  replaceCurrentPlaceholder(currentFiles);
18931
18970
  }, [isReplaced]);
18932
- useEffect46(() => {
18971
+ useEffect47(() => {
18933
18972
  if (!uploadedFile) return;
18934
18973
  const path = editor.api.findPath(element);
18935
18974
  setMediaNode(
@@ -18962,15 +19001,15 @@ function MediaPlaceholderPopover({ children }) {
18962
19001
  },
18963
19002
  [editor, element, mediaType]
18964
19003
  );
18965
- useEffect46(() => {
19004
+ useEffect47(() => {
18966
19005
  setOpen(selected);
18967
19006
  }, [selected, setOpen]);
18968
- useEffect46(() => {
19007
+ useEffect47(() => {
18969
19008
  if (isUploading) {
18970
19009
  setOpen(false);
18971
19010
  }
18972
19011
  }, [isUploading]);
18973
- useEffect46(() => {
19012
+ useEffect47(() => {
18974
19013
  var _a2;
18975
19014
  setProgresses({ [(_a2 = uploadingFile == null ? void 0 : uploadingFile.name) != null ? _a2 : ""]: progress });
18976
19015
  setIsUploading(isUploading);
@@ -19004,7 +19043,7 @@ function ImageProgress({
19004
19043
  progress = 0
19005
19044
  }) {
19006
19045
  const [objectUrl, setObjectUrl] = useState49(null);
19007
- useEffect46(() => {
19046
+ useEffect47(() => {
19008
19047
  const url = URL.createObjectURL(file);
19009
19048
  setObjectUrl(url);
19010
19049
  return () => {
@@ -19163,13 +19202,13 @@ function ImagePreview() {
19163
19202
  // src/ui/media-upload-toast.tsx
19164
19203
  import { PlaceholderPlugin as PlaceholderPlugin5, UploadErrorCode } from "@platejs/media/react";
19165
19204
  import { usePluginOption as usePluginOption21 } from "platejs/react";
19166
- import { useEffect as useEffect47 } from "react";
19205
+ import { useEffect as useEffect48 } from "react";
19167
19206
  import { toast as toast4 } from "sonner";
19168
19207
 
19169
19208
  // src/ui/use-placeholder-max-file-size.ts
19170
19209
  import { PlaceholderPlugin as PlaceholderPlugin4 } from "@platejs/media/react";
19171
19210
  import { useEditorRef as useEditorRef40 } from "platejs/react";
19172
- import { useLayoutEffect as useLayoutEffect2 } from "react";
19211
+ import { useLayoutEffect as useLayoutEffect3 } from "react";
19173
19212
  var PLACEHOLDER_FILE_KIND_PATTERNS = {
19174
19213
  audio: "audio/*",
19175
19214
  blob: "*",
@@ -19202,7 +19241,7 @@ var acceptedFileTypesFromKey = (key) => {
19202
19241
  };
19203
19242
  var useEditorMaxFileSize = (editor, maxFileSize, acceptedFileTypes) => {
19204
19243
  const acceptedFileTypesKey = acceptedFileTypes == null ? void 0 : acceptedFileTypes.join(FILE_TYPE_KEY_SEPARATOR);
19205
- useLayoutEffect2(() => {
19244
+ useLayoutEffect3(() => {
19206
19245
  var _a;
19207
19246
  const previous = EDITOR_UPLOAD_CONFIGS.get(editor);
19208
19247
  if (maxFileSize === void 0 && acceptedFileTypesKey === void 0) {
@@ -19241,7 +19280,7 @@ function MediaUploadToast() {
19241
19280
  }
19242
19281
  var useUploadErrorToast = () => {
19243
19282
  const uploadError = usePluginOption21(PlaceholderPlugin5, "error");
19244
- useEffect47(() => {
19283
+ useEffect48(() => {
19245
19284
  if (!uploadError) return;
19246
19285
  const { code, data } = uploadError;
19247
19286
  switch (code) {
@@ -19704,13 +19743,13 @@ import { useCallback as useCallback64, useState as useState54 } from "react";
19704
19743
 
19705
19744
  // src/ui/mention-page-combobox-group.tsx
19706
19745
  import { FileTextIcon as FileTextIcon3 } from "lucide-react";
19707
- import { useEffect as useEffect48, useState as useState52 } from "react";
19746
+ import { useEffect as useEffect49, useState as useState52 } from "react";
19708
19747
  import { jsx as jsx172, jsxs as jsxs110 } from "react/jsx-runtime";
19709
19748
  function PageComboboxGroup({ search, onPageHover, onPageSelect }) {
19710
19749
  const adapter = useEditorAdapter();
19711
19750
  const debouncedSearch = useDebounce(search, 250);
19712
19751
  const [pages, setPages] = useState52([]);
19713
- useEffect48(() => {
19752
+ useEffect49(() => {
19714
19753
  if (!adapter.permissions.canLinkPage) {
19715
19754
  setPages([]);
19716
19755
  return;
@@ -19759,13 +19798,13 @@ function PageStatusBadge({ status }) {
19759
19798
  }
19760
19799
 
19761
19800
  // src/ui/mention-people-combobox-group.tsx
19762
- import { useEffect as useEffect49, useState as useState53 } from "react";
19801
+ import { useEffect as useEffect50, useState as useState53 } from "react";
19763
19802
  import { jsx as jsx173, jsxs as jsxs111 } from "react/jsx-runtime";
19764
19803
  function PeopleComboboxGroup({ search, onUserHover, onUserSelect }) {
19765
19804
  const adapter = useEditorAdapter();
19766
19805
  const debouncedSearch = useDebounce(search, 150);
19767
19806
  const [members, setMembers] = useState53([]);
19768
- useEffect49(() => {
19807
+ useEffect50(() => {
19769
19808
  if (!adapter.permissions.canMention) {
19770
19809
  setMembers([]);
19771
19810
  return;
@@ -21390,7 +21429,7 @@ import {
21390
21429
  useSelected as useSelected8,
21391
21430
  withHOC as withHOC8
21392
21431
  } from "platejs/react";
21393
- import { useRef as useRef18 } from "react";
21432
+ import { useRef as useRef19 } from "react";
21394
21433
 
21395
21434
  // src/ui/table-icons.tsx
21396
21435
  import { jsx as jsx180, jsxs as jsxs118 } from "react/jsx-runtime";
@@ -21594,7 +21633,7 @@ var TableElement = withHOC8(
21594
21633
  const isSelectionAreaVisible = usePluginOption22(BlockSelectionPlugin10, "isSelectionAreaVisible");
21595
21634
  const hasControls = !readOnly && !isSelectionAreaVisible;
21596
21635
  const { marginLeft, props: tableProps } = useTableElement();
21597
- const tableRef = useRef18(null);
21636
+ const tableRef = useRef19(null);
21598
21637
  useTableSelectionDom(tableRef);
21599
21638
  const isSelectingTable = useBlockSelected2(props.element.id);
21600
21639
  const content = /* @__PURE__ */ jsx181(