diff --git a/node_modules/@emdash-cms/admin/dist/index.js b/node_modules/@emdash-cms/admin/dist/index.js index f3735f4..de2e843 100644 --- a/node_modules/@emdash-cms/admin/dist/index.js +++ b/node_modules/@emdash-cms/admin/dist/index.js @@ -6569,18 +6569,22 @@ function PortableTextEditor({ value, onChange, placeholder = "Start writing...", function EditorBubbleMenu({ editor }) { const [showLinkInput, setShowLinkInput] = React.useState(false); const [linkUrl, setLinkUrl] = React.useState(""); + const [newTab, setNewTab] = React.useState(false); const inputRef = React.useRef(null); React.useEffect(() => { if (showLinkInput) { - setLinkUrl(editor.getAttributes("link").href || ""); + const onLink = editor.isActive("link"); + setLinkUrl(onLink ? (editor.getAttributes("link").href || "") : ""); + setNewTab(onLink && editor.getAttributes("link").target === "_blank"); setTimeout(() => inputRef.current?.focus(), 0); } }, [showLinkInput, editor]); const handleSetLink = () => { if (linkUrl.trim() === "") editor.chain().focus().extendMarkRange("link").unsetLink().run(); - else editor.chain().focus().extendMarkRange("link").setLink({ href: linkUrl.trim() }).run(); + else editor.chain().focus().extendMarkRange("link").setLink({ href: linkUrl.trim(), target: newTab ? "_blank" : null }).run(); setShowLinkInput(false); setLinkUrl(""); + setNewTab(false); }; const handleRemoveLink = () => { editor.chain().focus().extendMarkRange("link").unsetLink().run(); @@ -6616,7 +6620,15 @@ function EditorBubbleMenu({ editor }) { value: linkUrl, onChange: (e) => setLinkUrl(e.target.value), onKeyDown: handleKeyDown, - className: "h-8 w-48 text-sm" + className: "h-8 w-44 text-sm" + }), + /* @__PURE__ */ jsxs("label", { + className: "flex items-center gap-1 px-1 text-xs whitespace-nowrap select-none cursor-pointer", + title: "Openen in nieuw tabblad", + children: [ + /* @__PURE__ */ jsx("input", { type: "checkbox", checked: newTab, onChange: (e) => setNewTab(e.target.checked) }), + "nieuw tab" + ] }), /* @__PURE__ */ jsx(Button, { type: "button", @@ -6702,6 +6714,7 @@ function EditorToolbar({ editor, focusMode, onFocusModeChange }) { const [mediaPickerOpen, setMediaPickerOpen] = React.useState(false); const [showLinkPopover, setShowLinkPopover] = React.useState(false); const [linkUrl, setLinkUrl] = React.useState(""); + const [newTab, setNewTab] = React.useState(false); const toolbarRef = React.useRef(null); const linkInputRef = React.useRef(null); const editorState = useEditorState({ @@ -6729,15 +6742,18 @@ function EditorToolbar({ editor, focusMode, onFocusModeChange }) { }); React.useEffect(() => { if (showLinkPopover) { - setLinkUrl(editor.getAttributes("link").href || ""); + const onLink = editor.isActive("link"); + setLinkUrl(onLink ? (editor.getAttributes("link").href || "") : ""); + setNewTab(onLink && editor.getAttributes("link").target === "_blank"); setTimeout(() => linkInputRef.current?.focus(), 0); } }, [showLinkPopover, editor]); const handleSetLink = () => { if (linkUrl.trim() === "") editor.chain().focus().extendMarkRange("link").unsetLink().run(); - else editor.chain().focus().extendMarkRange("link").setLink({ href: linkUrl.trim() }).run(); + else editor.chain().focus().extendMarkRange("link").setLink({ href: linkUrl.trim(), target: newTab ? "_blank" : null }).run(); setShowLinkPopover(false); setLinkUrl(""); + setNewTab(false); }; const handleRemoveLink = () => { editor.chain().focus().extendMarkRange("link").unsetLink().run(); @@ -6978,6 +6994,14 @@ function EditorToolbar({ editor, focusMode, onFocusModeChange }) { className: "h-8 w-52 text-sm" }) }), + /* @__PURE__ */ jsxs("label", { + className: "flex items-center gap-1.5 text-xs select-none cursor-pointer", + title: "Openen in nieuw tabblad", + children: [ + /* @__PURE__ */ jsx("input", { type: "checkbox", checked: newTab, onChange: (e) => setNewTab(e.target.checked) }), + "Openen in nieuw tabblad" + ] + }), /* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [/* @__PURE__ */ jsx(Button, { @@ -7892,16 +7916,20 @@ function ContentEditor({ collection, collectionLabel, item, fields, isNew, isSav })) ?? [] })); const itemDataString = React.useMemo(() => item ? JSON.stringify(item.data) : "", [item?.data]); + const loadedIdRef = React.useRef(null); React.useEffect(() => { if (item) { - setFormData(item.data); - setSlug(item.slug || ""); - setSlugTouched(!!item.slug); - setStatus(item.status); - setInternalBylines(item.bylines?.map((entry) => ({ - bylineId: entry.byline.id, - roleLabel: entry.roleLabel - })) ?? []); + if (item.id !== loadedIdRef.current) { + loadedIdRef.current = item.id; + setFormData(item.data); + setSlug(item.slug || ""); + setSlugTouched(!!item.slug); + setStatus(item.status); + setInternalBylines(item.bylines?.map((entry) => ({ + bylineId: entry.byline.id, + roleLabel: entry.roleLabel + })) ?? []); + } setLastSavedData(serializeEditorState({ data: item.data, slug: item.slug || "", @@ -7912,6 +7940,7 @@ function ContentEditor({ collection, collectionLabel, item, fields, isNew, isSav })); } }, [ + item?.id, item?.updatedAt, itemDataString, item?.slug, @@ -8658,7 +8687,7 @@ function ImageFieldRenderer({ label, description, value, onChange, required }) { }); }; const handleRemove = () => { - onChange(void 0); + onChange(null); }; return /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx(Label, { children: label }),