A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
chore: publish
thecodrrd237c3955765
diff --git a/packages/editor/dist/cjs/components/actionsheet/index.js b/packages/editor/dist/cjs/components/actionsheet/index.jsindex 8eecd8fa5..24a41ebf5 100644--- a/packages/editor/dist/cjs/components/actionsheet/index.js+++ b/packages/editor/dist/cjs/components/actionsheet/index.js@@ -104,6 +104,7 @@ function ActionSheetPresenter(props) {if (!isOpen)return null;return ((0, jsx_runtime_1.jsx)(react_modal_1.default, Object.assign({ contentRef: (ref) => (contentRef.current = ref), className: "bottom-sheet-presenter", role: "menu", isOpen: isOpen, appElement: document.body, shouldCloseOnEsc: blocking, shouldReturnFocusAfterClose: focusOnRender, shouldCloseOnOverlayClick: blocking, shouldFocusAfterRender: focusOnRender, ariaHideApp: blocking, preventScroll: blocking, onRequestClose: () => onBeforeClose(), portalClassName: "bottom-sheet-presenter-portal", onAfterOpen: () => {+ console.log("OPEGN!");animation.start({ transition: TRANSITION, y: 0 });}, overlayElement: (props, contentEl) => {return ((0, jsx_runtime_1.jsxs)(rebass_1.Box, Object.assign({}, props, {diff --git a/packages/editor/dist/cjs/components/popuppresenter/index.d.ts b/packages/editor/dist/cjs/components/popuppresenter/index.d.tsindex e3ccee1b0..bb3b88ac2 100644--- a/packages/editor/dist/cjs/components/popuppresenter/index.d.ts+++ b/packages/editor/dist/cjs/components/popuppresenter/index.d.ts@@ -12,6 +12,7 @@ export declare type PopupPresenterProps = {};export declare function PopupPresenter(props: PropsWithChildren<PopupPresenterProps>): JSX.Element | null;export declare type PopupWrapperProps = UsePopupHandlerOptions & {+ autoCloseOnUnmount?: boolean;position: PositionOptions;renderPopup: (closePopup: () => void) => React.ReactNode;} & Partial<Omit<PopupPresenterProps, "onClose">>;@@ -20,9 +21,7 @@ declare type UsePopupHandlerOptions = {id: string;group: string;isOpen: boolean;- autoCloseOnUnmount?: boolean;onClosed?: () => void;- onClosePopup?: () => void;};export declare function usePopupHandler(options: UsePopupHandlerOptions): {isPopupOpen: boolean;diff --git a/packages/editor/dist/cjs/components/popuppresenter/index.js b/packages/editor/dist/cjs/components/popuppresenter/index.jsindex e1660ca91..aa434637f 100644--- a/packages/editor/dist/cjs/components/popuppresenter/index.js+++ b/packages/editor/dist/cjs/components/popuppresenter/index.js@@ -155,6 +155,13 @@ function PopupWrapper(props) {let { id, group, position, renderPopup, isOpen, onClosed, autoCloseOnUnmount } = props, presenterProps = __rest(props, ["id", "group", "position", "renderPopup", "isOpen", "onClosed", "autoCloseOnUnmount"]);const PopupRenderer = (0, popuprenderer_1.usePopupRenderer)();const { closePopup, isPopupOpen } = usePopupHandler(props);+ (0, react_1.useEffect)(() => {+ if (!autoCloseOnUnmount)+ return;+ return () => {+ PopupRenderer === null || PopupRenderer === void 0 ? void 0 : PopupRenderer.closePopup(id);+ };+ }, [autoCloseOnUnmount, id, PopupRenderer]);(0, react_1.useEffect)(() => {if (PopupRenderer && isPopupOpen) {PopupRenderer.openPopup(id, function Popup({ id }) {@@ -179,7 +186,7 @@ function PopupWrapper(props) {}exports.PopupWrapper = PopupWrapper;function usePopupHandler(options) {- let { autoCloseOnUnmount, group, isOpen, id, onClosed, onClosePopup } = options;+ let { group, isOpen, id, onClosed } = options;const isPopupOpen = (0, toolbarstore_1.useToolbarStore)((store) => !!store.openedPopups[id]);const openPopup = (0, toolbarstore_1.useToolbarStore)((store) => store.openPopup);const closePopup = (0, toolbarstore_1.useToolbarStore)((store) => store.closePopup);@@ -193,13 +200,6 @@ function usePopupHandler(options) {elseclosePopup(id);}, [isOpen, id, group, openPopup, closePopup]);- (0, react_1.useEffect)(() => {- if (!autoCloseOnUnmount)- return;- return () => {- onClosePopup === null || onClosePopup === void 0 ? void 0 : onClosePopup();- };- }, [autoCloseOnUnmount, onClosePopup]);(0, react_1.useEffect)(() => {if (!isPopupOpen)onClosed === null || onClosed === void 0 ? void 0 : onClosed();@@ -221,13 +221,17 @@ function showPopup(options) {function hide() {react_dom_1.default.unmountComponentAtNode((0, dom_1.getPopupContainer)());}- react_dom_1.default.render((0, jsx_runtime_1.jsx)(themeprovider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: true, onClose: hide, position: {+ react_dom_1.default.render((0, jsx_runtime_1.jsx)(themeprovider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: true, position: {target: (0, dom_1.getToolbarElement)(),isTargetAbsolute: true,location: "below",align: "end",yOffset: 10,- }, blocking: true, focusOnRender: true }, props, { children: popup(hide) })) }), (0, dom_1.getPopupContainer)());+ }, blocking: true, focusOnRender: true }, props, { onClose: () => {+ var _a;+ hide();+ (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);+ } }, { children: popup(hide) })) }), (0, dom_1.getPopupContainer)());return hide;}exports.showPopup = showPopup;diff --git a/packages/editor/dist/cjs/extensions/attachment/attachment.js b/packages/editor/dist/cjs/extensions/attachment/attachment.jsindex 15beea53d..d00fbf0d7 100644--- a/packages/editor/dist/cjs/extensions/attachment/attachment.js+++ b/packages/editor/dist/cjs/extensions/attachment/attachment.js@@ -61,7 +61,9 @@ exports.AttachmentNode = core_1.Node.create({attrs: attachment,});},- removeAttachment: () => ({ commands }) => commands.deleteNode(this.name),+ removeAttachment: () => ({ commands, tr }) => {+ return commands.deleteSelection();+ },downloadAttachment: (attachment) => ({ editor }) => {return this.options.onDownloadAttachment(editor, attachment);},diff --git a/packages/editor/dist/cjs/extensions/image/component.js b/packages/editor/dist/cjs/extensions/image/component.jsindex cae7f480a..1da22c567 100644--- a/packages/editor/dist/cjs/extensions/image/component.js+++ b/packages/editor/dist/cjs/extensions/image/component.js@@ -18,9 +18,11 @@ const responsive_1 = require("../../components/responsive");const icon_1 = require("../../toolbar/components/icon");const icons_1 = require("../../toolbar/icons");const toolbargroup_1 = require("../../toolbar/components/toolbargroup");+const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");function ImageComponent(props) {const { editor, updateAttributes, node, selected } = props;- const { src, alt, title, width, height, align, float } = node.attrs;+ const isMobile = (0, toolbarstore_1.useIsMobile)();+ let { src, alt, title, width, height, align, float } = node.attrs;const imageRef = (0, react_1.useRef)();(0, react_1.useEffect)(() => {(() => __awaiter(this, void 0, void 0, function* () {@@ -29,6 +31,8 @@ function ImageComponent(props) {imageRef.current.src = yield dataUriToBlobURL(src);}))();}, [src, imageRef]);+ if (isMobile)+ float = false;return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {display: float ? "block" : "flex",justifyContent: floatdiff --git a/packages/editor/dist/cjs/toolbar/components/dropdown.js b/packages/editor/dist/cjs/toolbar/components/dropdown.jsindex 54b6344cb..ea11b21ab 100644--- a/packages/editor/dist/cjs/toolbar/components/dropdown.js+++ b/packages/editor/dist/cjs/toolbar/components/dropdown.js@@ -23,7 +23,6 @@ function Dropdown(props) {id,isOpen,onClosed: () => setIsOpen(false),- onClosePopup: () => closePopup(id),});return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(button_1.Button, Object.assign({ ref: (ref) => {internalRef.current = ref;diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.js b/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.jsindex 235df0cd7..e5af2e808 100644--- a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.js+++ b/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.js@@ -6,7 +6,7 @@ const toolbargroup_1 = require("../../components/toolbargroup");function LinkHoverPopup(props) {const { editor, selectedNode } = props;const { node } = selectedNode;- if (!node.isText ||+ if (!(node === null || node === void 0 ? void 0 : node.isText) ||node.marks.length <= 0 ||!node.marks.some((mark) => mark.type.name === "link"))return null;diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/index.js b/packages/editor/dist/cjs/toolbar/floatingmenus/index.jsindex ba8dc358d..6bdbd3b46 100644--- a/packages/editor/dist/cjs/toolbar/floatingmenus/index.js+++ b/packages/editor/dist/cjs/toolbar/floatingmenus/index.js@@ -2,9 +2,10 @@Object.defineProperty(exports, "__esModule", { value: true });exports.EditorFloatingMenus = void 0;const jsx_runtime_1 = require("react/jsx-runtime");+const responsive_1 = require("../../components/responsive");const hoverpopup_1 = require("./hoverpopup");const searchreplace_1 = require("./searchreplace");function EditorFloatingMenus(props) {- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(searchreplace_1.SearchReplaceFloatingMenu, Object.assign({}, props)), (0, jsx_runtime_1.jsx)(hoverpopup_1.HoverPopupHandler, Object.assign({}, props))] }));+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(searchreplace_1.SearchReplaceFloatingMenu, Object.assign({}, props)), (0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: (0, jsx_runtime_1.jsx)(hoverpopup_1.HoverPopupHandler, Object.assign({}, props)) })] }));}exports.EditorFloatingMenus = EditorFloatingMenus;diff --git a/packages/editor/dist/cjs/toolbar/popups/imageproperties.js b/packages/editor/dist/cjs/toolbar/popups/imageproperties.jsindex 38e18364b..53f6fa79a 100644--- a/packages/editor/dist/cjs/toolbar/popups/imageproperties.js+++ b/packages/editor/dist/cjs/toolbar/popups/imageproperties.js@@ -7,6 +7,7 @@ const react_1 = require("react");const popup_1 = require("../components/popup");const forms_1 = require("@rebass/forms");const inlineinput_1 = require("../../components/inlineinput");+const responsive_1 = require("../../components/responsive");function ImageProperties(props) {const { height, width, float, editor, onClose } = props;const onSizeChange = (0, react_1.useCallback)((newWidth, newHeight) => {@@ -26,10 +27,10 @@ function ImageProperties(props) {};editor.chain().setImageSize(size).run();}, [width, height]);- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: "Image properties", onClose: onClose }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { justifyContent: "space-between", alignItems: "center" } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "body" }, { children: "Floating?" })), (0, jsx_runtime_1.jsx)(forms_1.Checkbox, { checked: float, onClick: () => editor- .chain()- .setImageAlignment({ float: !float, align: "left" })- .run() })] })), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center", mt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "width", type: "number", value: width, containerProps: {+ return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: "Image properties", onClose: onClose }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [(0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: (0, jsx_runtime_1.jsxs)(forms_1.Label, Object.assign({ variant: "text.body", sx: { justifyContent: "space-between", alignItems: "center" } }, { children: ["Float image", (0, jsx_runtime_1.jsx)(forms_1.Checkbox, { checked: float, onClick: () => editor+ .chain()+ .setImageAlignment({ float: !float, align: "left" })+ .run() })] })) }), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center", mt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "width", type: "number", value: width, containerProps: {sx: { mr: 1 },}, onChange: (e) => onSizeChange(e.target.valueAsNumber) }), (0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "height", type: "number", value: height, onChange: (e) => onSizeChange(undefined, e.target.valueAsNumber) })] }))] })) })));}diff --git a/packages/editor/dist/cjs/toolbar/tools/attachment.js b/packages/editor/dist/cjs/toolbar/tools/attachment.jsindex 192fa05bd..32af83795 100644--- a/packages/editor/dist/cjs/toolbar/tools/attachment.js+++ b/packages/editor/dist/cjs/toolbar/tools/attachment.js@@ -11,7 +11,7 @@ function AttachmentSettings(props) {const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";if (!editor.isActive("attachment") || !isBottom)return null;- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: [] })));+ return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: ["downloadAttachment", "removeAttachment"] })));}exports.AttachmentSettings = AttachmentSettings;function DownloadAttachment(props) {diff --git a/packages/editor/dist/cjs/toolbar/tools/image.js b/packages/editor/dist/cjs/toolbar/tools/image.jsindex 9dee47d86..fa2b8371d 100644--- a/packages/editor/dist/cjs/toolbar/tools/image.js+++ b/packages/editor/dist/cjs/toolbar/tools/image.js@@ -54,7 +54,7 @@ function ImageProperties(props) {const [isOpen, setIsOpen] = (0, react_1.useState)(false);const buttonRef = (0, react_1.useRef)();// TODO: defer until user opens the popup- const image = (0, react_1.useMemo)(() => (0, prosemirror_1.findSelectedNode)(editor, "image"), []);+ const image = (0, prosemirror_1.findSelectedNode)(editor, "image");const { float, align, width, height } = ((image === null || image === void 0 ? void 0 : image.attrs) ||{});return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: () => setIsOpen((s) => !s) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: () => setIsOpen(false), blocking: true, focusOnRender: false, position: {diff --git a/packages/editor/dist/cjs/toolbar/tools/link.js b/packages/editor/dist/cjs/toolbar/tools/link.jsindex 944f496fe..7dfc863c5 100644--- a/packages/editor/dist/cjs/toolbar/tools/link.js+++ b/packages/editor/dist/cjs/toolbar/tools/link.js@@ -61,11 +61,11 @@ function AddLink(props) {exports.AddLink = AddLink;function EditLink(props) {const { editor, selectedNode: _selectedNode } = props;- const selectedNode = (0, useRefValue_1.useRefValue)(_selectedNode || (0, prosemirror_1.selectionToOffset)(editor.state.selection));+ const selectedNode = (0, useRefValue_1.useRefValue)(_selectedNode || (0, prosemirror_1.selectionToOffset)(editor.state));const onDone = (0, react_1.useCallback)((href, text) => {- if (!href || !editor.current)- return;const { from, node, to } = selectedNode.current;+ if (!href || !editor.current || !node)+ return;const mark = (0, prosemirror_1.findMark)(node, "link");if (!mark)return;@@ -83,6 +83,8 @@ function EditLink(props) {}, []);return ((0, jsx_runtime_1.jsx)(LinkTool, Object.assign({}, props, { isEditing: true, onDone: onDone, onClick: () => {const { node } = selectedNode.current;+ if (!node)+ return;const selectedText = node.textContent;const mark = (0, prosemirror_1.findMark)(node, "link");if (!mark)@@ -102,9 +104,10 @@ function RemoveLink(props) {}exports.RemoveLink = RemoveLink;function OpenLink(props) {- const { editor, selectedNode } = props;- const node = (selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.node) || editor.state.selection.$anchor.node();- const link = selectedNode ? (0, prosemirror_1.findMark)(node, "link") : null;+ const { editor, selectedNode: _selectedNode } = props;+ const selectedNode = (0, useRefValue_1.useRefValue)(_selectedNode || (0, prosemirror_1.selectionToOffset)(editor.state));+ const { node } = selectedNode.current;+ const link = node ? (0, prosemirror_1.findMark)(node, "link") : null;if (!link)return null;const href = link === null || link === void 0 ? void 0 : link.attrs.href;diff --git a/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts b/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.tsindex d072ce375..f965c8484 100644--- a/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts+++ b/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts@@ -1,14 +1,14 @@import { Editor } from "@tiptap/core";import { Node as ProsemirrorNode, Mark } from "prosemirror-model";-import { Selection } from "prosemirror-state";+import { EditorState } from "prosemirror-state";export declare type NodeWithOffset = {- node: ProsemirrorNode;+ node?: ProsemirrorNode;from: number;to: number;};export declare function findSelectedDOMNode(editor: Editor, types: string[]): HTMLElement | null;export declare function findSelectedNode(editor: Editor, type: string): ProsemirrorNode | null;export declare function findMark(node: ProsemirrorNode, type: string): Mark | undefined;-export declare function selectionToOffset(selection: Selection): NodeWithOffset;+export declare function selectionToOffset(state: EditorState): NodeWithOffset;export declare function findListItemType(editor: Editor): string | null;export declare function isListActive(editor: Editor): boolean;diff --git a/packages/editor/dist/cjs/toolbar/utils/prosemirror.js b/packages/editor/dist/cjs/toolbar/utils/prosemirror.jsindex a72c34706..6e33ec125 100644--- a/packages/editor/dist/cjs/toolbar/utils/prosemirror.js+++ b/packages/editor/dist/cjs/toolbar/utils/prosemirror.js@@ -31,9 +31,13 @@ function findMark(node, type) {return mark;}exports.findMark = findMark;-function selectionToOffset(selection) {- const { $from, from } = selection;- return { node: $from.node(), from, to: from + $from.node().nodeSize };+function selectionToOffset(state) {+ const { $from, from } = state.selection;+ return {+ node: state.doc.nodeAt(from) || undefined,+ from,+ to: from + $from.node().nodeSize,+ };}exports.selectionToOffset = selectionToOffset;function findListItemType(editor) {diff --git a/packages/editor/dist/es/components/actionsheet/index.js b/packages/editor/dist/es/components/actionsheet/index.jsindex c434c9781..b32ae1990 100644--- a/packages/editor/dist/es/components/actionsheet/index.js+++ b/packages/editor/dist/es/components/actionsheet/index.js@@ -75,6 +75,7 @@ export function ActionSheetPresenter(props) {if (!isOpen)return null;return (_jsx(Modal, Object.assign({ contentRef: (ref) => (contentRef.current = ref), className: "bottom-sheet-presenter", role: "menu", isOpen: isOpen, appElement: document.body, shouldCloseOnEsc: blocking, shouldReturnFocusAfterClose: focusOnRender, shouldCloseOnOverlayClick: blocking, shouldFocusAfterRender: focusOnRender, ariaHideApp: blocking, preventScroll: blocking, onRequestClose: () => onBeforeClose(), portalClassName: "bottom-sheet-presenter-portal", onAfterOpen: () => {+ console.log("OPEGN!");animation.start({ transition: TRANSITION, y: 0 });}, overlayElement: (props, contentEl) => {return (_jsxs(Box, Object.assign({}, props, {diff --git a/packages/editor/dist/es/components/popuppresenter/index.d.ts b/packages/editor/dist/es/components/popuppresenter/index.d.tsindex e3ccee1b0..bb3b88ac2 100644--- a/packages/editor/dist/es/components/popuppresenter/index.d.ts+++ b/packages/editor/dist/es/components/popuppresenter/index.d.ts@@ -12,6 +12,7 @@ export declare type PopupPresenterProps = {};export declare function PopupPresenter(props: PropsWithChildren<PopupPresenterProps>): JSX.Element | null;export declare type PopupWrapperProps = UsePopupHandlerOptions & {+ autoCloseOnUnmount?: boolean;position: PositionOptions;renderPopup: (closePopup: () => void) => React.ReactNode;} & Partial<Omit<PopupPresenterProps, "onClose">>;@@ -20,9 +21,7 @@ declare type UsePopupHandlerOptions = {id: string;group: string;isOpen: boolean;- autoCloseOnUnmount?: boolean;onClosed?: () => void;- onClosePopup?: () => void;};export declare function usePopupHandler(options: UsePopupHandlerOptions): {isPopupOpen: boolean;diff --git a/packages/editor/dist/es/components/popuppresenter/index.js b/packages/editor/dist/es/components/popuppresenter/index.jsindex 3c6e22925..161ec516e 100644--- a/packages/editor/dist/es/components/popuppresenter/index.js+++ b/packages/editor/dist/es/components/popuppresenter/index.js@@ -148,6 +148,13 @@ export function PopupWrapper(props) {let { id, group, position, renderPopup, isOpen, onClosed, autoCloseOnUnmount } = props, presenterProps = __rest(props, ["id", "group", "position", "renderPopup", "isOpen", "onClosed", "autoCloseOnUnmount"]);const PopupRenderer = usePopupRenderer();const { closePopup, isPopupOpen } = usePopupHandler(props);+ useEffect(() => {+ if (!autoCloseOnUnmount)+ return;+ return () => {+ PopupRenderer === null || PopupRenderer === void 0 ? void 0 : PopupRenderer.closePopup(id);+ };+ }, [autoCloseOnUnmount, id, PopupRenderer]);useEffect(() => {if (PopupRenderer && isPopupOpen) {PopupRenderer.openPopup(id, function Popup({ id }) {@@ -171,7 +178,7 @@ export function PopupWrapper(props) {return null;}export function usePopupHandler(options) {- let { autoCloseOnUnmount, group, isOpen, id, onClosed, onClosePopup } = options;+ let { group, isOpen, id, onClosed } = options;const isPopupOpen = useToolbarStore((store) => !!store.openedPopups[id]);const openPopup = useToolbarStore((store) => store.openPopup);const closePopup = useToolbarStore((store) => store.closePopup);@@ -185,13 +192,6 @@ export function usePopupHandler(options) {elseclosePopup(id);}, [isOpen, id, group, openPopup, closePopup]);- useEffect(() => {- if (!autoCloseOnUnmount)- return;- return () => {- onClosePopup === null || onClosePopup === void 0 ? void 0 : onClosePopup();- };- }, [autoCloseOnUnmount, onClosePopup]);useEffect(() => {if (!isPopupOpen)onClosed === null || onClosed === void 0 ? void 0 : onClosed();@@ -212,12 +212,16 @@ export function showPopup(options) {function hide() {ReactDOM.unmountComponentAtNode(getPopupContainer());}- ReactDOM.render(_jsx(ThemeProvider, { children: _jsx(ResponsivePresenter, Object.assign({ isOpen: true, onClose: hide, position: {+ ReactDOM.render(_jsx(ThemeProvider, { children: _jsx(ResponsivePresenter, Object.assign({ isOpen: true, position: {target: getToolbarElement(),isTargetAbsolute: true,location: "below",align: "end",yOffset: 10,- }, blocking: true, focusOnRender: true }, props, { children: popup(hide) })) }), getPopupContainer());+ }, blocking: true, focusOnRender: true }, props, { onClose: () => {+ var _a;+ hide();+ (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);+ } }, { children: popup(hide) })) }), getPopupContainer());return hide;}diff --git a/packages/editor/dist/es/extensions/attachment/attachment.js b/packages/editor/dist/es/extensions/attachment/attachment.jsindex 8d681838e..be1094a10 100644--- a/packages/editor/dist/es/extensions/attachment/attachment.js+++ b/packages/editor/dist/es/extensions/attachment/attachment.js@@ -58,7 +58,9 @@ export const AttachmentNode = Node.create({attrs: attachment,});},- removeAttachment: () => ({ commands }) => commands.deleteNode(this.name),+ removeAttachment: () => ({ commands, tr }) => {+ return commands.deleteSelection();+ },downloadAttachment: (attachment) => ({ editor }) => {return this.options.onDownloadAttachment(editor, attachment);},diff --git a/packages/editor/dist/es/extensions/image/component.js b/packages/editor/dist/es/extensions/image/component.jsindex 2ab52eb76..df92b2fda 100644--- a/packages/editor/dist/es/extensions/image/component.js+++ b/packages/editor/dist/es/extensions/image/component.js@@ -15,9 +15,11 @@ import { DesktopOnly } from "../../components/responsive";import { Icon } from "../../toolbar/components/icon";import { Icons } from "../../toolbar/icons";import { ToolbarGroup } from "../../toolbar/components/toolbar-group";+import { useIsMobile } from "../../toolbar/stores/toolbar-store";export function ImageComponent(props) {const { editor, updateAttributes, node, selected } = props;- const { src, alt, title, width, height, align, float } = node.attrs;+ const isMobile = useIsMobile();+ let { src, alt, title, width, height, align, float } = node.attrs;const imageRef = useRef();useEffect(() => {(() => __awaiter(this, void 0, void 0, function* () {@@ -26,6 +28,8 @@ export function ImageComponent(props) {imageRef.current.src = yield dataUriToBlobURL(src);}))();}, [src, imageRef]);+ if (isMobile)+ float = false;return (_jsx(_Fragment, { children: _jsx(Box, Object.assign({ sx: {display: float ? "block" : "flex",justifyContent: floatdiff --git a/packages/editor/dist/es/toolbar/components/dropdown.js b/packages/editor/dist/es/toolbar/components/dropdown.jsindex 651cefe2e..443b25343 100644--- a/packages/editor/dist/es/toolbar/components/dropdown.js+++ b/packages/editor/dist/es/toolbar/components/dropdown.js@@ -20,7 +20,6 @@ export function Dropdown(props) {id,isOpen,onClosed: () => setIsOpen(false),- onClosePopup: () => closePopup(id),});return (_jsxs(_Fragment, { children: [_jsxs(Button, Object.assign({ ref: (ref) => {internalRef.current = ref;diff --git a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.js b/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.jsindex 85cd23066..4e63e0eaf 100644--- a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.js+++ b/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.js@@ -3,7 +3,7 @@ import { ToolbarGroup } from "../../components/toolbar-group";function LinkHoverPopup(props) {const { editor, selectedNode } = props;const { node } = selectedNode;- if (!node.isText ||+ if (!(node === null || node === void 0 ? void 0 : node.isText) ||node.marks.length <= 0 ||!node.marks.some((mark) => mark.type.name === "link"))return null;diff --git a/packages/editor/dist/es/toolbar/floatingmenus/index.js b/packages/editor/dist/es/toolbar/floatingmenus/index.jsindex 1be8629e8..dabfded55 100644--- a/packages/editor/dist/es/toolbar/floatingmenus/index.js+++ b/packages/editor/dist/es/toolbar/floatingmenus/index.js@@ -1,6 +1,7 @@import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";+import { DesktopOnly } from "../../components/responsive";import { HoverPopupHandler } from "./hover-popup";import { SearchReplaceFloatingMenu } from "./search-replace";export function EditorFloatingMenus(props) {- return (_jsxs(_Fragment, { children: [_jsx(SearchReplaceFloatingMenu, Object.assign({}, props)), _jsx(HoverPopupHandler, Object.assign({}, props))] }));+ return (_jsxs(_Fragment, { children: [_jsx(SearchReplaceFloatingMenu, Object.assign({}, props)), _jsx(DesktopOnly, { children: _jsx(HoverPopupHandler, Object.assign({}, props)) })] }));}diff --git a/packages/editor/dist/es/toolbar/popups/imageproperties.js b/packages/editor/dist/es/toolbar/popups/imageproperties.jsindex 50bc47da4..e72876ef2 100644--- a/packages/editor/dist/es/toolbar/popups/imageproperties.js+++ b/packages/editor/dist/es/toolbar/popups/imageproperties.js@@ -1,9 +1,10 @@import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";-import { Flex, Text } from "rebass";+import { Flex } from "rebass";import { useCallback } from "react";import { Popup } from "../components/popup";-import { Checkbox } from "@rebass/forms";+import { Checkbox, Label } from "@rebass/forms";import { InlineInput } from "../../components/inline-input";+import { DesktopOnly } from "../../components/responsive";export function ImageProperties(props) {const { height, width, float, editor, onClose } = props;const onSizeChange = useCallback((newWidth, newHeight) => {@@ -23,10 +24,10 @@ export function ImageProperties(props) {};editor.chain().setImageSize(size).run();}, [width, height]);- return (_jsx(Popup, Object.assign({ title: "Image properties", onClose: onClose }, { children: _jsxs(Flex, Object.assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsxs(Flex, Object.assign({ sx: { justifyContent: "space-between", alignItems: "center" } }, { children: [_jsx(Text, Object.assign({ variant: "body" }, { children: "Floating?" })), _jsx(Checkbox, { checked: float, onClick: () => editor- .chain()- .setImageAlignment({ float: !float, align: "left" })- .run() })] })), _jsxs(Flex, Object.assign({ sx: { alignItems: "center", mt: 2 } }, { children: [_jsx(InlineInput, { label: "width", type: "number", value: width, containerProps: {+ return (_jsx(Popup, Object.assign({ title: "Image properties", onClose: onClose }, { children: _jsxs(Flex, Object.assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsx(DesktopOnly, { children: _jsxs(Label, Object.assign({ variant: "text.body", sx: { justifyContent: "space-between", alignItems: "center" } }, { children: ["Float image", _jsx(Checkbox, { checked: float, onClick: () => editor+ .chain()+ .setImageAlignment({ float: !float, align: "left" })+ .run() })] })) }), _jsxs(Flex, Object.assign({ sx: { alignItems: "center", mt: 2 } }, { children: [_jsx(InlineInput, { label: "width", type: "number", value: width, containerProps: {sx: { mr: 1 },}, onChange: (e) => onSizeChange(e.target.valueAsNumber) }), _jsx(InlineInput, { label: "height", type: "number", value: height, onChange: (e) => onSizeChange(undefined, e.target.valueAsNumber) })] }))] })) })));}diff --git a/packages/editor/dist/es/toolbar/tools/attachment.js b/packages/editor/dist/es/toolbar/tools/attachment.jsindex 18fc7a2c7..55ffc07d1 100644--- a/packages/editor/dist/es/toolbar/tools/attachment.js+++ b/packages/editor/dist/es/toolbar/tools/attachment.js@@ -8,7 +8,7 @@ export function AttachmentSettings(props) {const isBottom = useToolbarLocation() === "bottom";if (!editor.isActive("attachment") || !isBottom)return null;- return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: [] })));+ return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: ["downloadAttachment", "removeAttachment"] })));}export function DownloadAttachment(props) {const { editor } = props;diff --git a/packages/editor/dist/es/toolbar/tools/image.js b/packages/editor/dist/es/toolbar/tools/image.jsindex d12812d01..3a46f836b 100644--- a/packages/editor/dist/es/toolbar/tools/image.js+++ b/packages/editor/dist/es/toolbar/tools/image.js@@ -1,6 +1,6 @@import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";import { ToolButton } from "../components/tool-button";-import { useMemo, useRef, useState } from "react";+import { useRef, useState } from "react";import { ResponsivePresenter } from "../../components/responsive";import { MoreTools } from "../components/more-tools";import { useToolbarLocation } from "../stores/toolbar-store";@@ -47,7 +47,7 @@ export function ImageProperties(props) {const [isOpen, setIsOpen] = useState(false);const buttonRef = useRef();// TODO: defer until user opens the popup- const image = useMemo(() => findSelectedNode(editor, "image"), []);+ const image = findSelectedNode(editor, "image");const { float, align, width, height } = ((image === null || image === void 0 ? void 0 : image.attrs) ||{});return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: () => setIsOpen((s) => !s) })), _jsx(ResponsivePresenter, Object.assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: () => setIsOpen(false), blocking: true, focusOnRender: false, position: {diff --git a/packages/editor/dist/es/toolbar/tools/link.js b/packages/editor/dist/es/toolbar/tools/link.jsindex 1f39026f2..e50d87d9a 100644--- a/packages/editor/dist/es/toolbar/tools/link.js+++ b/packages/editor/dist/es/toolbar/tools/link.js@@ -56,11 +56,11 @@ export function AddLink(props) {}export function EditLink(props) {const { editor, selectedNode: _selectedNode } = props;- const selectedNode = useRefValue(_selectedNode || selectionToOffset(editor.state.selection));+ const selectedNode = useRefValue(_selectedNode || selectionToOffset(editor.state));const onDone = useCallback((href, text) => {- if (!href || !editor.current)- return;const { from, node, to } = selectedNode.current;+ if (!href || !editor.current || !node)+ return;const mark = findMark(node, "link");if (!mark)return;@@ -78,6 +78,8 @@ export function EditLink(props) {}, []);return (_jsx(LinkTool, Object.assign({}, props, { isEditing: true, onDone: onDone, onClick: () => {const { node } = selectedNode.current;+ if (!node)+ return;const selectedText = node.textContent;const mark = findMark(node, "link");if (!mark)@@ -95,9 +97,10 @@ export function RemoveLink(props) {} })));}export function OpenLink(props) {- const { editor, selectedNode } = props;- const node = (selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.node) || editor.state.selection.$anchor.node();- const link = selectedNode ? findMark(node, "link") : null;+ const { editor, selectedNode: _selectedNode } = props;+ const selectedNode = useRefValue(_selectedNode || selectionToOffset(editor.state));+ const { node } = selectedNode.current;+ const link = node ? findMark(node, "link") : null;if (!link)return null;const href = link === null || link === void 0 ? void 0 : link.attrs.href;diff --git a/packages/editor/dist/es/toolbar/utils/prosemirror.d.ts b/packages/editor/dist/es/toolbar/utils/prosemirror.d.tsindex d072ce375..f965c8484 100644--- a/packages/editor/dist/es/toolbar/utils/prosemirror.d.ts+++ b/packages/editor/dist/es/toolbar/utils/prosemirror.d.ts@@ -1,14 +1,14 @@import { Editor } from "@tiptap/core";import { Node as ProsemirrorNode, Mark } from "prosemirror-model";-import { Selection } from "prosemirror-state";+import { EditorState } from "prosemirror-state";export declare type NodeWithOffset = {- node: ProsemirrorNode;+ node?: ProsemirrorNode;from: number;to: number;};export declare function findSelectedDOMNode(editor: Editor, types: string[]): HTMLElement | null;export declare function findSelectedNode(editor: Editor, type: string): ProsemirrorNode | null;export declare function findMark(node: ProsemirrorNode, type: string): Mark | undefined;-export declare function selectionToOffset(selection: Selection): NodeWithOffset;+export declare function selectionToOffset(state: EditorState): NodeWithOffset;export declare function findListItemType(editor: Editor): string | null;export declare function isListActive(editor: Editor): boolean;diff --git a/packages/editor/dist/es/toolbar/utils/prosemirror.js b/packages/editor/dist/es/toolbar/utils/prosemirror.jsindex 6aecf9e79..e786008f2 100644--- a/packages/editor/dist/es/toolbar/utils/prosemirror.js+++ b/packages/editor/dist/es/toolbar/utils/prosemirror.js@@ -25,9 +25,13 @@ export function findMark(node, type) {const mark = node.marks.find((m) => m.type.name === type);return mark;}-export function selectionToOffset(selection) {- const { $from, from } = selection;- return { node: $from.node(), from, to: from + $from.node().nodeSize };+export function selectionToOffset(state) {+ const { $from, from } = state.selection;+ return {+ node: state.doc.nodeAt(from) || undefined,+ from,+ to: from + $from.node().nodeSize,+ };}export function findListItemType(editor) {const isTaskList = editor.isActive("taskList");diff --git a/packages/editor/src/toolbar/popups/image-properties.tsx b/packages/editor/src/toolbar/popups/image-properties.tsxindex d4fa09d2e..baafeab7c 100644--- a/packages/editor/src/toolbar/popups/image-properties.tsx+++ b/packages/editor/src/toolbar/popups/image-properties.tsx@@ -1,13 +1,14 @@import { Flex, Text } from "rebass";-import { useCallback } from "react";+import { useCallback, useState } from "react";import { Popup } from "../components/popup";-import { Checkbox } from "@rebass/forms";+import { Checkbox, Label } from "@rebass/forms";import {ImageAlignmentOptions,ImageSizeOptions,} from "../../extensions/image";import { Editor } from "../../types";import { InlineInput } from "../../components/inline-input";+import { DesktopOnly } from "../../components/responsive";export type ImagePropertiesProps = ImageSizeOptions &ImageAlignmentOptions & { editor: Editor; onClose: () => void };@@ -39,18 +40,23 @@ export function ImageProperties(props: ImagePropertiesProps) {return (<Popup title="Image properties" onClose={onClose}><Flex sx={{ width: ["auto", 300], flexDirection: "column", p: 1 }}>- <Flex sx={{ justifyContent: "space-between", alignItems: "center" }}>- <Text variant={"body"}>Floating?</Text>- <Checkbox- checked={float}- onClick={() =>- editor- .chain()- .setImageAlignment({ float: !float, align: "left" })- .run()- }- />- </Flex>+ <DesktopOnly>+ <Label+ variant="text.body"+ sx={{ justifyContent: "space-between", alignItems: "center" }}+ >+ Float image+ <Checkbox+ checked={float}+ onClick={() =>+ editor+ .chain()+ .setImageAlignment({ float: !float, align: "left" })+ .run()+ }+ />+ </Label>+ </DesktopOnly><Flex sx={{ alignItems: "center", mt: 2 }}><InlineInputlabel="width"