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
fix: adjust action sheets for mobile
thecodrr7aee1e0ec350
diff --git a/packages/editor/dist/toolbar/components/popup.d.ts b/packages/editor/dist/toolbar/components/popup.d.tsindex 49820f7e5..fb521b343 100644--- a/packages/editor/dist/toolbar/components/popup.d.ts+++ b/packages/editor/dist/toolbar/components/popup.d.ts@@ -3,10 +3,11 @@ declare type Action = {title: string;onClick: () => void;loading?: boolean;+ disabled?: boolean;};export declare type PopupProps = {title?: string;- onClose: () => void;+ onClose?: () => void;action?: Action;};export declare function Popup(props: PropsWithChildren<PopupProps>): JSX.Element;diff --git a/packages/editor/dist/toolbar/components/popup.js b/packages/editor/dist/toolbar/components/popup.jsindex a74b4734f..68e251c26 100644--- a/packages/editor/dist/toolbar/components/popup.js+++ b/packages/editor/dist/toolbar/components/popup.js@@ -24,9 +24,15 @@ export function Popup(props) {// border: "1px solid var(--border)",boxShadow: "menu",minWidth: 200,- } }, { children: [_jsxs(Flex, __assign({ className: "movable", sx: {+ } }, { children: [title && (_jsxs(Flex, __assign({ className: "movable", sx: {justifyContent: "space-between",alignItems: "center",p: 2,- } }, { children: [_jsx(Text, __assign({ variant: "title" }, { children: title })), _jsx(Button, __assign({ variant: "tool", sx: { p: 0, bg: "transparent" }, onClick: onClose }, { children: _jsx(Icon, { path: Icons.close, size: "big" }) }))] })), children, action && (_jsx(Flex, __assign({ sx: { justifyContent: "end" }, bg: "bgSecondary", p: 1, px: 2, mt: 2 }, { children: _jsx(Button, __assign({ variant: "dialog", onClick: action.loading ? undefined : action.onClick, disabled: action.loading }, { children: action.loading ? (_jsx(Icon, { path: Icons.loading, rotate: true, size: "medium" })) : (action.title) })) })))] })) }), _jsx(MobileOnly, { children: children })] }));+ } }, { children: [_jsx(Text, __assign({ variant: "title" }, { children: title })), _jsx(Button, __assign({ variant: "tool", sx: { p: 0, bg: "transparent" }, onClick: onClose }, { children: _jsx(Icon, { path: Icons.close, size: "big" }) }))] }))), children, title && action && (_jsx(Flex, __assign({ sx: { justifyContent: "end" }, bg: "bgSecondary", p: 1, px: 2, mt: 2 }, { children: _jsx(Button, __assign({ variant: "dialog", onClick: action.disabled || action.loading ? undefined : action.onClick, disabled: action.disabled || action.loading }, { children: action.loading ? (_jsx(Icon, { path: Icons.loading, rotate: true, size: "medium" })) : (action.title) })) })))] })) }), _jsxs(MobileOnly, { children: [children, action && (_jsx(Button, __assign({ variant: "primary", sx: {+ alignSelf: "stretch",+ mb: 1,+ mt: 2,+ mx: 1,+ py: 2,+ }, onClick: action.disabled ? undefined : action === null || action === void 0 ? void 0 : action.onClick, disabled: action.disabled }, { children: action.loading ? (_jsx(Icon, { path: Icons.loading, rotate: true, size: "medium" })) : (action.title) })))] })] }));}diff --git a/packages/editor/dist/toolbar/components/toolbutton.d.ts b/packages/editor/dist/toolbar/components/toolbutton.d.tsindex 3211820e0..debe4afa8 100644--- a/packages/editor/dist/toolbar/components/toolbutton.d.ts+++ b/packages/editor/dist/toolbar/components/toolbutton.d.ts@@ -14,8 +14,8 @@ export declare type ToolButtonProps = ButtonProps & {};export declare const ToolButton: React.NamedExoticComponent<ButtonProps & {icon: IconNames;- iconColor?: keyof import("@notesnook/theme/dist/theme/colorscheme/static").StaticColors | "primary" | "placeholder" | "background" | "bgTransparent" | "accent" | "bgSecondary" | "bgSecondaryText" | "border" | "hover" | "fontSecondary" | "fontTertiary" | "text" | "overlay" | "secondary" | "icon" | "disabled" | "checked" | "red" | "orange" | "yellow" | "green" | "blue" | "purple" | "gray" | undefined;- iconSize?: number | "small" | "medium" | "big" | undefined;+ iconColor?: "text" | "blue" | "gray" | "green" | "orange" | "purple" | "red" | "yellow" | "checked" | "disabled" | "placeholder" | "background" | "border" | "overlay" | "icon" | "hover" | keyof import("@notesnook/theme/dist/theme/colorscheme/static").StaticColors | "primary" | "bgTransparent" | "accent" | "bgSecondary" | "bgSecondaryText" | "fontSecondary" | "fontTertiary" | "secondary" | undefined;+ iconSize?: number | "big" | "small" | "medium" | undefined;toggled: boolean;buttonRef?: React.MutableRefObject<HTMLButtonElement | null | undefined> | undefined;variant?: ToolButtonVariant | undefined;diff --git a/packages/editor/dist/toolbar/popups/embedpopup.js b/packages/editor/dist/toolbar/popups/embedpopup.jsindex c5db2f8e2..256776f7e 100644--- a/packages/editor/dist/toolbar/popups/embedpopup.js+++ b/packages/editor/dist/toolbar/popups/embedpopup.js@@ -67,7 +67,7 @@ export function EmbedPopup(props) {color: "error",p: 1,borderRadius: "default",- } }, { children: ["Error: ", error] }))), _jsxs(Tabs, __assign({ activeIndex: 0, containerProps: { sx: { mx: 2, mb: 1, flexDirection: "column" } }, onTabChanged: function (index) { return setEmbedSource(index === 0 ? "url" : "code"); } }, { children: [_jsxs(Tab, __assign({ title: "From URL" }, { children: [_jsx(Input, { placeholder: "Enter embed source URL", value: src, autoFocus: true, onChange: function (e) { return setSrc(e.target.value); }, autoCapitalize: "none", sx: { fontSize: "body" } }), _jsxs(Flex, __assign({ sx: { alignItems: "center", mt: 1 } }, { children: [_jsx(InlineInput, { containerProps: { sx: { mr: 1 } }, label: "width", type: "number", placeholder: "Width", value: width, sx: {+ } }, { children: ["Error: ", error] }))), _jsxs(Tabs, __assign({ activeIndex: 0, containerProps: { sx: { mx: 1, flexDirection: "column" } }, onTabChanged: function (index) { return setEmbedSource(index === 0 ? "url" : "code"); } }, { children: [_jsxs(Tab, __assign({ title: "From URL" }, { children: [_jsx(Input, { placeholder: "Enter embed source URL", value: src, autoFocus: true, onChange: function (e) { return setSrc(e.target.value); }, autoCapitalize: "none", sx: { fontSize: "body" } }), _jsxs(Flex, __assign({ sx: { alignItems: "center", mt: 1 } }, { children: [_jsx(InlineInput, { containerProps: { sx: { mr: 1 } }, label: "width", type: "number", placeholder: "Width", value: width, sx: {mr: 1,fontSize: "body",}, onChange: function (e) { return onSizeChange(e.target.valueAsNumber); } }), _jsx(InlineInput, { label: "height", type: "number", placeholder: "Height", value: height, sx: { fontSize: "body" }, onChange: function (e) {diff --git a/packages/editor/dist/toolbar/popups/imageproperties.d.ts b/packages/editor/dist/toolbar/popups/imageproperties.d.tsindex 608647e46..5ed787264 100644--- a/packages/editor/dist/toolbar/popups/imageproperties.d.ts+++ b/packages/editor/dist/toolbar/popups/imageproperties.d.ts@@ -3,5 +3,6 @@ import { ImageAlignmentOptions, ImageSizeOptions } from "../../extensions/image"import { Editor } from "@tiptap/core";export declare type ImagePropertiesProps = ImageSizeOptions & ImageAlignmentOptions & {editor: Editor;+ onClose: () => void;};export declare function ImageProperties(props: ImagePropertiesProps): JSX.Element;diff --git a/packages/editor/dist/toolbar/popups/imageproperties.js b/packages/editor/dist/toolbar/popups/imageproperties.jsindex d25af3809..5a4ddf43f 100644--- a/packages/editor/dist/toolbar/popups/imageproperties.js+++ b/packages/editor/dist/toolbar/popups/imageproperties.js@@ -12,10 +12,11 @@ var __assign = (this && this.__assign) || function () {import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";import { Flex, Text } from "rebass";import { useCallback } from "react";+import { Popup } from "../components/popup";import { Toggle } from "../../components/toggle";import { InlineInput } from "../../components/inline-input";export function ImageProperties(props) {- var height = props.height, width = props.width, float = props.float, editor = props.editor;+ var height = props.height, width = props.width, float = props.float, editor = props.editor, onClose = props.onClose;var onSizeChange = useCallback(function (newWidth, newHeight) {var size = newWidth? {@@ -33,12 +34,12 @@ export function ImageProperties(props) {};editor.chain().setImageSize(size).run();}, [width, height]);- return (_jsxs(Flex, __assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsxs(Flex, __assign({ sx: { justifyContent: "space-between", alignItems: "center" } }, { children: [_jsx(Text, __assign({ variant: "body" }, { children: "Floating?" })), _jsx(Toggle, { checked: float, onClick: function () {- return editor- .chain()- .setImageAlignment({ float: !float, align: "left" })- .run();- } })] })), _jsxs(Flex, __assign({ sx: { alignItems: "center", mt: 2 } }, { children: [_jsx(InlineInput, { label: "width", type: "number", value: width, containerProps: {- sx: { mr: 1 },- }, onChange: function (e) { return onSizeChange(e.target.valueAsNumber); } }), _jsx(InlineInput, { label: "height", type: "number", value: height, onChange: function (e) { return onSizeChange(undefined, e.target.valueAsNumber); } })] }))] })));+ return (_jsx(Popup, __assign({ title: "Image properties", onClose: onClose }, { children: _jsxs(Flex, __assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsxs(Flex, __assign({ sx: { justifyContent: "space-between", alignItems: "center" } }, { children: [_jsx(Text, __assign({ variant: "body" }, { children: "Floating?" })), _jsx(Toggle, { checked: float, onClick: function () {+ return editor+ .chain()+ .setImageAlignment({ float: !float, align: "left" })+ .run();+ } })] })), _jsxs(Flex, __assign({ sx: { alignItems: "center", mt: 2 } }, { children: [_jsx(InlineInput, { label: "width", type: "number", value: width, containerProps: {+ sx: { mr: 1 },+ }, onChange: function (e) { return onSizeChange(e.target.valueAsNumber); } }), _jsx(InlineInput, { label: "height", type: "number", value: height, onChange: function (e) { return onSizeChange(undefined, e.target.valueAsNumber); } })] }))] })) })));}diff --git a/packages/editor/dist/toolbar/popups/imageupload.js b/packages/editor/dist/toolbar/popups/imageupload.jsindex bfc42a4ff..a0839695e 100644--- a/packages/editor/dist/toolbar/popups/imageupload.js+++ b/packages/editor/dist/toolbar/popups/imageupload.js@@ -75,6 +75,7 @@ export function ImageUploadPopup(props) {return (_jsx(Popup, __assign({ title: "Insert image from URL", onClose: onClose, action: {loading: isDownloading,title: "Insert image",+ disabled: !url,onClick: function () { return __awaiter(_this, void 0, void 0, function () {var response, contentType, contentLength, size, dataurl, _a, e_1;return __generator(this, function (_b) {@@ -117,7 +118,7 @@ export function ImageUploadPopup(props) {}});}); },- } }, { children: _jsxs(Flex, __assign({ sx: { px: 2, flexDirection: "column", width: ["auto", 350] } }, { children: [_jsx(Input, { type: "url", autoFocus: true, placeholder: "Paste Image URL here", value: url, onChange: function (e) {+ } }, { children: _jsxs(Flex, __assign({ sx: { px: 1, flexDirection: "column", width: ["auto", 350] } }, { children: [_jsx(Input, { type: "url", autoFocus: true, placeholder: "Paste Image URL here", value: url, onChange: function (e) {setUrl(e.target.value);setError(undefined);} }), error ? (_jsxs(Text, __assign({ variant: "error", sx: {diff --git a/packages/editor/dist/toolbar/popups/linkpopup.d.ts b/packages/editor/dist/toolbar/popups/linkpopup.d.tsindex 8d58e678d..1d6894848 100644--- a/packages/editor/dist/toolbar/popups/linkpopup.d.ts+++ b/packages/editor/dist/toolbar/popups/linkpopup.d.ts@@ -7,5 +7,6 @@ export declare type LinkPopupProps = {text: string;href: string;}) => void;+ onClose: () => void;};export declare function LinkPopup(props: LinkPopupProps): JSX.Element;diff --git a/packages/editor/dist/toolbar/popups/linkpopup.js b/packages/editor/dist/toolbar/popups/linkpopup.jsindex 116ff966d..dd3b39fd6 100644--- a/packages/editor/dist/toolbar/popups/linkpopup.js+++ b/packages/editor/dist/toolbar/popups/linkpopup.js@@ -28,14 +28,14 @@ var __read = (this && this.__read) || function (o, n) {import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";import { Input } from "@rebass/forms";import { useState } from "react";-import { Flex, Button } from "rebass";+import { Flex } from "rebass";+import { Popup } from "../components/popup";export function LinkPopup(props) {- var _text = props.text, _href = props.href, _a = props.isEditing, isEditing = _a === void 0 ? false : _a, onDone = props.onDone;+ var _text = props.text, _href = props.href, _a = props.isEditing, isEditing = _a === void 0 ? false : _a, onDone = props.onDone, onClose = props.onClose;var _b = __read(useState(_href || ""), 2), href = _b[0], setHref = _b[1];var _c = __read(useState(_text || ""), 2), text = _c[0], setText = _c[1];- return (_jsxs(Flex, __assign({ sx: { p: 1, flexDirection: "column", width: ["auto", 250] } }, { children: [_jsx(Input, { type: "text", placeholder: "Link text", value: text, onChange: function (e) { return setText(e.target.value); } }), _jsx(Input, { type: "url", sx: { mt: 1 }, autoFocus: true, placeholder: "https://example.com/", value: href, onChange: function (e) { return setHref(e.target.value); } }), _jsx(Button, __assign({ variant: "primary", sx: {- alignSelf: ["stretch", "end", "end"],- my: 1,- mr: 1,- }, onClick: function () { return onDone({ text: text, href: href }); } }, { children: isEditing ? "Save edits" : "Insert link" }))] })));+ return (_jsx(Popup, __assign({ title: isEditing ? "Edit link" : "Insert link", onClose: onClose, action: {+ title: isEditing ? "Save edits" : "Insert link",+ onClick: function () { return onDone({ text: text, href: href }); },+ } }, { children: _jsxs(Flex, __assign({ sx: { p: 1, flexDirection: "column", width: ["auto", 250] } }, { children: [_jsx(Input, { type: "text", placeholder: "Link text", value: text, onChange: function (e) { return setText(e.target.value); } }), _jsx(Input, { type: "url", sx: { mt: 1 }, autoFocus: true, placeholder: "https://example.com/", value: href, onChange: function (e) { return setHref(e.target.value); } })] })) })));}diff --git a/packages/editor/dist/toolbar/popups/tablepopup.js b/packages/editor/dist/toolbar/popups/tablepopup.jsindex 2bffe9c3a..c958f295c 100644--- a/packages/editor/dist/toolbar/popups/tablepopup.js+++ b/packages/editor/dist/toolbar/popups/tablepopup.js@@ -26,8 +26,9 @@ var __read = (this && this.__read) || function (o, n) {return ar;};import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";-import { Box, Button, Flex, Text } from "rebass";+import { Box, Flex, Text } from "rebass";import { useEffect, useState } from "react";+import { Popup } from "../components/popup";import { useIsMobile } from "../stores/toolbar-store";import { InlineInput } from "../../components/inline-input";var MAX_COLUMNS = 20;@@ -66,59 +67,59 @@ export function TablePopup(props) {};});}, [cellLocation, autoExpand]);- return (_jsxs(Flex, __assign({ sx: { p: 1, flexDirection: "column", alignItems: "center" } }, { children: [_jsx(Box, __assign({ sx: {- display: "grid",- gridTemplateColumns: "repeat(".concat(tableSize.columns, ", minmax(").concat(cellSize, "px, 1fr))"),- gap: "small",- bg: "background",- width: "100%",- }, onTouchMove: function (e) {- var touch = e.touches.item(0);- var element = document.elementFromPoint(touch.pageX, touch.pageY);- if (!element)- return;- var index = element.dataset.index;- if (!index)- return;- setCellLocation(getCellLocation(parseInt(index), tableSize));- } }, { children: Array(tableSize.columns * tableSize.rows)- .fill(0)- .map(function (_, index) { return (_jsx(Box, { "data-index": index, height: cellSize || 15, sx: {- border: "1px solid var(--disabled)",- borderRadius: "small",- bg: isCellHighlighted(index, cellLocation, tableSize)- ? "disabled"- : "transparent",- }, onTouchStart: function () {- setCellLocation(getCellLocation(index, tableSize));- }, onMouseEnter: function () {- setCellLocation(getCellLocation(index, tableSize));- }, onClick: function () {- onInsertTable({- columns: cellLocation.column,- rows: cellLocation.row,- });- } }, index)); }) })), _jsxs(Flex, __assign({ sx: {- display: ["flex", "none", "none"],- my: 1,- alignItems: "center",- justifyContent: "center",- } }, { children: [_jsx(InlineInput, { containerProps: { sx: { mr: 1 } }, label: "columns", placeholder: "".concat(cellLocation.column, " columns"), type: "number", value: cellLocation.column, onChange: function (e) {- setCellLocation(function (l) { return (__assign(__assign({}, l), { column: e.target.valueAsNumber || 0 })); });- } }), _jsx(InlineInput, { label: "rows", placeholder: "".concat(cellLocation.row, " rows"), type: "number", value: cellLocation.row, onChange: function (e) {- setCellLocation(function (l) { return (__assign(__assign({}, l), { row: e.target.valueAsNumber || 0 })); });- } })] })), _jsxs(Text, __assign({ variant: "body", sx: { mt: 1, display: ["none", "block", "block"] } }, { children: [cellLocation.column, " x ", cellLocation.row] })), _jsx(Button, __assign({ variant: "primary", sx: {- display: ["block", "none", "none"],- alignSelf: ["stretch", "end", "end"],- py: 2,- }, onClick: function () {- return onInsertTable({- columns: cellLocation.column,- rows: cellLocation.row,- });- }, disabled: !cellLocation.column || !cellLocation.row }, { children: !cellLocation.column || !cellLocation.row- ? "Please set a table size"- : "Insert a ".concat(cellLocation.column, " x ").concat(cellLocation.row, " table") }))] })));+ return (_jsx(Popup, __assign({ action: {+ title: !cellLocation.column || !cellLocation.row+ ? "Please set a table size"+ : "Insert a ".concat(cellLocation.column, " x ").concat(cellLocation.row, " table"),+ disabled: !cellLocation.column || !cellLocation.row,+ onClick: function () {+ return onInsertTable({+ columns: cellLocation.column,+ rows: cellLocation.row,+ });+ },+ } }, { children: _jsxs(Flex, __assign({ sx: { px: 1, flexDirection: "column", alignItems: "center" } }, { children: [_jsx(Box, __assign({ sx: {+ display: "grid",+ gridTemplateColumns: "repeat(".concat(tableSize.columns, ", minmax(").concat(cellSize, "px, 1fr))"),+ gap: "small",+ bg: "background",+ width: "100%",+ }, onTouchMove: function (e) {+ var touch = e.touches.item(0);+ var element = document.elementFromPoint(touch.pageX, touch.pageY);+ if (!element)+ return;+ var index = element.dataset.index;+ if (!index)+ return;+ setCellLocation(getCellLocation(parseInt(index), tableSize));+ } }, { children: Array(tableSize.columns * tableSize.rows)+ .fill(0)+ .map(function (_, index) { return (_jsx(Box, { "data-index": index, height: cellSize || 15, sx: {+ border: "1px solid var(--disabled)",+ borderRadius: "small",+ bg: isCellHighlighted(index, cellLocation, tableSize)+ ? "disabled"+ : "transparent",+ }, onTouchStart: function () {+ setCellLocation(getCellLocation(index, tableSize));+ }, onMouseEnter: function () {+ setCellLocation(getCellLocation(index, tableSize));+ }, onClick: function () {+ onInsertTable({+ columns: cellLocation.column,+ rows: cellLocation.row,+ });+ } }, index)); }) })), _jsxs(Flex, __assign({ sx: {+ display: ["flex", "none", "none"],+ mt: 1,+ alignItems: "center",+ justifyContent: "center",+ } }, { children: [_jsx(InlineInput, { containerProps: { sx: { mr: 1 } }, label: "columns", placeholder: "".concat(cellLocation.column, " columns"), type: "number", value: cellLocation.column, onChange: function (e) {+ setCellLocation(function (l) { return (__assign(__assign({}, l), { column: e.target.valueAsNumber || 0 })); });+ } }), _jsx(InlineInput, { label: "rows", placeholder: "".concat(cellLocation.row, " rows"), type: "number", value: cellLocation.row, onChange: function (e) {+ setCellLocation(function (l) { return (__assign(__assign({}, l), { row: e.target.valueAsNumber || 0 })); });+ } })] })), _jsxs(Text, __assign({ variant: "body", sx: { mt: 1, display: ["none", "block", "block"] } }, { children: [cellLocation.column, " x ", cellLocation.row] }))] })) })));}function getCellLocation(index, tableSize) {var cellIndex = index + 1;diff --git a/packages/editor/dist/toolbar/tools/embed.js b/packages/editor/dist/toolbar/tools/embed.jsindex 83b5990fa..d12c9ab41 100644--- a/packages/editor/dist/toolbar/tools/embed.js+++ b/packages/editor/dist/toolbar/tools/embed.js@@ -28,7 +28,6 @@ var __read = (this && this.__read) || function (o, n) {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 { Popup } from "../components/popup";import { ResponsivePresenter } from "../../components/responsive";import { MoreTools } from "../components/more-tools";import { useToolbarLocation } from "../stores/toolbar-store";@@ -76,7 +75,5 @@ export function EmbedProperties(props) {location: "below",yOffset: 10,isTargetAbsolute: true,- } }, { children: _jsx(Popup, __assign({ title: "Embed properties", onClose: function () {- setIsOpen(false);- } }, { children: _jsx(EmbedPopup, { title: "Embed properties", onClose: function () { return setIsOpen(false); }, embed: embed, onSourceChanged: function (src) { return editor.commands.setEmbedSource(src); }, onSizeChanged: function (size) { return editor.commands.setEmbedSize(size); } }) })) }))] }));+ } }, { children: _jsx(EmbedPopup, { title: "Embed properties", onClose: function () { return setIsOpen(false); }, embed: embed, onSourceChanged: function (src) { return editor.commands.setEmbedSource(src); }, onSizeChanged: function (size) { return editor.commands.setEmbedSize(size); } }) }))] }));}diff --git a/packages/editor/dist/toolbar/tools/image.js b/packages/editor/dist/toolbar/tools/image.jsindex 89fe5de34..889fe281f 100644--- a/packages/editor/dist/toolbar/tools/image.js+++ b/packages/editor/dist/toolbar/tools/image.js@@ -28,7 +28,6 @@ var __read = (this && this.__read) || function (o, n) {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 { Popup } from "../components/popup";import { ResponsivePresenter } from "../../components/responsive";import { MoreTools } from "../components/more-tools";import { useToolbarLocation } from "../stores/toolbar-store";@@ -85,7 +84,5 @@ export function ImageProperties(props) {location: "below",yOffset: 10,isTargetAbsolute: true,- } }, { children: _jsx(Popup, __assign({ title: "Image properties", onClose: function () {- setIsOpen(false);- } }, { children: _jsx(ImagePropertiesPopup, { editor: editor, height: height, width: width, align: align, float: float }) })) }))] }));+ } }, { children: _jsx(ImagePropertiesPopup, { editor: editor, height: height, width: width, align: align, float: float, onClose: function () { return setIsOpen(false); } }) }))] }));}diff --git a/packages/editor/dist/toolbar/tools/link.js b/packages/editor/dist/toolbar/tools/link.jsindex a9e0231d5..d4c51b841 100644--- a/packages/editor/dist/toolbar/tools/link.js+++ b/packages/editor/dist/toolbar/tools/link.js@@ -29,7 +29,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runimport { ToolButton } from "../components/tool-button";import { useCallback, useRef, useState } from "react";import { ResponsivePresenter } from "../../components/responsive";-import { Popup } from "../components/popup";import { LinkPopup } from "../popups/link-popup";import { useToolbarLocation } from "../stores/toolbar-store";import { MoreTools } from "../components/more-tools";@@ -141,9 +140,9 @@ function LinkTool(props) {location: "below",align: "center",yOffset: 5,- }, title: isEditing ? "Edit link" : "Insert link", isOpen: isOpen, items: [], onClose: function () { return setIsOpen(false); }, focusOnRender: false }, { children: _jsx(Popup, __assign({ title: isEditing ? "Edit link" : "Insert link", onClose: function () { return setIsOpen(false); } }, { children: _jsx(LinkPopup, { href: href, text: text, isEditing: isEditing, onDone: function (_a) {- var href = _a.href, text = _a.text;- onDone(href, text);- setIsOpen(false);- } }) })) }))] }));+ }, title: isEditing ? "Edit link" : "Insert link", isOpen: isOpen, items: [], onClose: function () { return setIsOpen(false); }, focusOnRender: false }, { children: _jsx(LinkPopup, { href: href, text: text, isEditing: isEditing, onClose: function () { return setIsOpen(false); }, onDone: function (_a) {+ var href = _a.href, text = _a.text;+ onDone(href, text);+ setIsOpen(false);+ } }) }))] }));}diff --git a/packages/editor/src/toolbar/components/popup.tsx b/packages/editor/src/toolbar/components/popup.tsxindex 2f90c8881..962c771ee 100644--- a/packages/editor/src/toolbar/components/popup.tsx+++ b/packages/editor/src/toolbar/components/popup.tsx@@ -9,10 +9,11 @@ type Action = {title: string;onClick: () => void;loading?: boolean;+ disabled?: boolean;};export type PopupProps = {title?: string;- onClose: () => void;+ onClose?: () => void;action?: Action;};@@ -33,25 +34,27 @@ export function Popup(props: PropsWithChildren<PopupProps>) {minWidth: 200,}}>- <Flex- className="movable"- sx={{- justifyContent: "space-between",- alignItems: "center",- p: 2,- }}- >- <Text variant={"title"}>{title}</Text>- <Button- variant={"tool"}- sx={{ p: 0, bg: "transparent" }}- onClick={onClose}+ {title && (+ <Flex+ className="movable"+ sx={{+ justifyContent: "space-between",+ alignItems: "center",+ p: 2,+ }}>- <Icon path={Icons.close} size={"big"} />- </Button>- </Flex>+ <Text variant={"title"}>{title}</Text>+ <Button+ variant={"tool"}+ sx={{ p: 0, bg: "transparent" }}+ onClick={onClose}+ >+ <Icon path={Icons.close} size={"big"} />+ </Button>+ </Flex>+ )}{children}- {action && (+ {title && action && (<Flexsx={{ justifyContent: "end" }}bg="bgSecondary"@@ -61,8 +64,10 @@ export function Popup(props: PropsWithChildren<PopupProps>) {><Buttonvariant="dialog"- onClick={action.loading ? undefined : action.onClick}- disabled={action.loading}+ onClick={+ action.disabled || action.loading ? undefined : action.onClick+ }+ disabled={action.disabled || action.loading}>{action.loading ? (<Icon path={Icons.loading} rotate size="medium" />@@ -74,7 +79,30 @@ export function Popup(props: PropsWithChildren<PopupProps>) {)}</Flex></DesktopOnly>- <MobileOnly>{children}</MobileOnly>+ <MobileOnly>+ {children}++ {action && (+ <Button+ variant={"primary"}+ sx={{+ alignSelf: "stretch",+ mb: 1,+ mt: 2,+ mx: 1,+ py: 2,+ }}+ onClick={action.disabled ? undefined : action?.onClick}+ disabled={action.disabled}+ >+ {action.loading ? (+ <Icon path={Icons.loading} rotate size="medium" />+ ) : (+ action.title+ )}+ </Button>+ )}+ </MobileOnly></>);}diff --git a/packages/editor/src/toolbar/popups/embed-popup.tsx b/packages/editor/src/toolbar/popups/embed-popup.tsxindex 8a8749f11..a0a92251c 100644--- a/packages/editor/src/toolbar/popups/embed-popup.tsx+++ b/packages/editor/src/toolbar/popups/embed-popup.tsx@@ -83,7 +83,7 @@ export function EmbedPopup(props: EmbedPopupProps) {<TabsactiveIndex={0}- containerProps={{ sx: { mx: 2, mb: 1, flexDirection: "column" } }}+ containerProps={{ sx: { mx: 1, flexDirection: "column" } }}onTabChanged={(index) => setEmbedSource(index === 0 ? "url" : "code")}><Tab title="From URL">diff --git a/packages/editor/src/toolbar/popups/image-properties.tsx b/packages/editor/src/toolbar/popups/image-properties.tsxindex 46a36bee7..0bfd5f430 100644--- a/packages/editor/src/toolbar/popups/image-properties.tsx+++ b/packages/editor/src/toolbar/popups/image-properties.tsx@@ -11,9 +11,9 @@ import { Editor } from "@tiptap/core";import { InlineInput } from "../../components/inline-input";export type ImagePropertiesProps = ImageSizeOptions &- ImageAlignmentOptions & { editor: Editor };+ ImageAlignmentOptions & { editor: Editor; onClose: () => void };export function ImageProperties(props: ImagePropertiesProps) {- const { height, width, float, editor } = props;+ const { height, width, float, editor, onClose } = props;const onSizeChange = useCallback((newWidth?: number, newHeight?: number) => {@@ -38,36 +38,38 @@ export function ImageProperties(props: ImagePropertiesProps) {);return (- <Flex sx={{ width: ["auto", 300], flexDirection: "column", p: 1 }}>- <Flex sx={{ justifyContent: "space-between", alignItems: "center" }}>- <Text variant={"body"}>Floating?</Text>- <Toggle- checked={float}- onClick={() =>- editor- .chain()- .setImageAlignment({ float: !float, align: "left" })- .run()- }- />- </Flex>- <Flex sx={{ alignItems: "center", mt: 2 }}>- <InlineInput- label="width"- type="number"- value={width}- containerProps={{- sx: { mr: 1 },- }}- onChange={(e) => onSizeChange(e.target.valueAsNumber)}- />- <InlineInput- label="height"- type="number"- value={height}- onChange={(e) => onSizeChange(undefined, e.target.valueAsNumber)}- />+ <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>+ <Toggle+ checked={float}+ onClick={() =>+ editor+ .chain()+ .setImageAlignment({ float: !float, align: "left" })+ .run()+ }+ />+ </Flex>+ <Flex sx={{ alignItems: "center", mt: 2 }}>+ <InlineInput+ label="width"+ type="number"+ value={width}+ containerProps={{+ sx: { mr: 1 },+ }}+ onChange={(e) => onSizeChange(e.target.valueAsNumber)}+ />+ <InlineInput+ label="height"+ type="number"+ value={height}+ onChange={(e) => onSizeChange(undefined, e.target.valueAsNumber)}+ />+ </Flex></Flex>- </Flex>+ </Popup>);}diff --git a/packages/editor/src/toolbar/popups/image-upload.tsx b/packages/editor/src/toolbar/popups/image-upload.tsxindex b2e86b48a..7cb6cf9c8 100644--- a/packages/editor/src/toolbar/popups/image-upload.tsx+++ b/packages/editor/src/toolbar/popups/image-upload.tsx@@ -22,6 +22,7 @@ export function ImageUploadPopup(props: ImageUploadPopupProps) {action={{loading: isDownloading,title: "Insert image",+ disabled: !url,onClick: async () => {setIsDownloading(true);setError(undefined);@@ -53,7 +54,7 @@ export function ImageUploadPopup(props: ImageUploadPopupProps) {},}}>- <Flex sx={{ px: 2, flexDirection: "column", width: ["auto", 350] }}>+ <Flex sx={{ px: 1, flexDirection: "column", width: ["auto", 350] }}><Inputtype="url"autoFocusdiff --git a/packages/editor/src/toolbar/popups/link-popup.tsx b/packages/editor/src/toolbar/popups/link-popup.tsxindex ddc721963..d9c668e44 100644--- a/packages/editor/src/toolbar/popups/link-popup.tsx+++ b/packages/editor/src/toolbar/popups/link-popup.tsx@@ -1,45 +1,51 @@import { Input } from "@rebass/forms";import { useState } from "react";import { Flex, Button } from "rebass";+import { Popup } from "../components/popup";export type LinkPopupProps = {text?: string;href?: string;isEditing?: boolean;onDone: (link: { text: string; href: string }) => void;+ onClose: () => void;};export function LinkPopup(props: LinkPopupProps) {- const { text: _text, href: _href, isEditing = false, onDone } = props;+ const {+ text: _text,+ href: _href,+ isEditing = false,+ onDone,+ onClose,+ } = props;const [href, setHref] = useState<string>(_href || "");const [text, setText] = useState<string>(_text || "");return (- <Flex sx={{ p: 1, flexDirection: "column", width: ["auto", 250] }}>- <Input- type="text"- placeholder="Link text"- value={text}- onChange={(e) => setText(e.target.value)}- />- <Input- type="url"- sx={{ mt: 1 }}- autoFocus- placeholder="https://example.com/"- value={href}- onChange={(e) => setHref(e.target.value)}- />- <Button- variant={"primary"}- sx={{- alignSelf: ["stretch", "end", "end"],- my: 1,- mr: 1,- }}- onClick={() => onDone({ text, href })}- >- {isEditing ? "Save edits" : "Insert link"}- </Button>- </Flex>+ <Popup+ title={isEditing ? "Edit link" : "Insert link"}+ onClose={onClose}+ action={{+ title: isEditing ? "Save edits" : "Insert link",+ onClick: () => onDone({ text, href }),+ }}+ >+ <Flex sx={{ p: 1, flexDirection: "column", width: ["auto", 250] }}>+ <Input+ type="text"+ placeholder="Link text"+ value={text}+ onChange={(e) => setText(e.target.value)}+ />+ <Input+ type="url"+ sx={{ mt: 1 }}+ autoFocus+ placeholder="https://example.com/"+ value={href}+ onChange={(e) => setHref(e.target.value)}+ />+ </Flex>+ </Popup>);}diff --git a/packages/editor/src/toolbar/popups/table-popup.tsx b/packages/editor/src/toolbar/popups/table-popup.tsxindex 12ed0a4e9..65984e414 100644--- a/packages/editor/src/toolbar/popups/table-popup.tsx+++ b/packages/editor/src/toolbar/popups/table-popup.tsx@@ -56,116 +56,112 @@ export function TablePopup(props: TablePopupProps) {}, [cellLocation, autoExpand]);return (- <Flex sx={{ p: 1, flexDirection: "column", alignItems: "center" }}>- <Box- sx={{- display: "grid",- gridTemplateColumns: `repeat(${tableSize.columns}, minmax(${cellSize}px, 1fr))`, // "1fr ".repeat(tableSize.columns),- gap: "small",- bg: "background",- width: "100%",- }}- onTouchMove={(e) => {- const touch = e.touches.item(0);- const element = document.elementFromPoint(- touch.pageX,- touch.pageY- ) as HTMLElement;- if (!element) return;- const index = element.dataset.index;- if (!index) return;- setCellLocation(getCellLocation(parseInt(index), tableSize));- }}- >- {Array(tableSize.columns * tableSize.rows)- .fill(0)- .map((_, index) => (- <Box- key={index}- data-index={index}- height={cellSize || 15}- sx={{- border: "1px solid var(--disabled)",- borderRadius: "small",- bg: isCellHighlighted(index, cellLocation, tableSize)- ? "disabled"- : "transparent",- }}- onTouchStart={() => {- setCellLocation(getCellLocation(index, tableSize));- }}- onMouseEnter={() => {- setCellLocation(getCellLocation(index, tableSize));- }}- onClick={() => {- onInsertTable({- columns: cellLocation.column,- rows: cellLocation.row,- });- }}- />- ))}- </Box>- <Flex- sx={{- display: ["flex", "none", "none"],- my: 1,- alignItems: "center",- justifyContent: "center",- }}- >- <InlineInput- containerProps={{ sx: { mr: 1 } }}- label="columns"- placeholder={`${cellLocation.column} columns`}- type="number"- value={cellLocation.column}- onChange={(e) => {- setCellLocation((l) => ({- ...l,- column: e.target.valueAsNumber || 0,- }));- }}- />- <InlineInput- label="rows"- placeholder={`${cellLocation.row} rows`}- type="number"- value={cellLocation.row}- onChange={(e) => {- setCellLocation((l) => ({- ...l,- row: e.target.valueAsNumber || 0,- }));- }}- />- </Flex>- <Text- variant={"body"}- sx={{ mt: 1, display: ["none", "block", "block"] }}- >- {cellLocation.column} x {cellLocation.row}- </Text>- <Button- variant={"primary"}- sx={{- display: ["block", "none", "none"],- alignSelf: ["stretch", "end", "end"],- py: 2,- }}- onClick={() =>+ <Popup+ action={{+ title:+ !cellLocation.column || !cellLocation.row+ ? "Please set a table size"+ : `Insert a ${cellLocation.column} x ${cellLocation.row} table`,+ disabled: !cellLocation.column || !cellLocation.row,+ onClick: () =>onInsertTable({columns: cellLocation.column,rows: cellLocation.row,- })- }- disabled={!cellLocation.column || !cellLocation.row}- >- {!cellLocation.column || !cellLocation.row- ? "Please set a table size"- : `Insert a ${cellLocation.column} x ${cellLocation.row} table`}- </Button>- </Flex>+ }),+ }}+ >+ <Flex sx={{ px: 1, flexDirection: "column", alignItems: "center" }}>+ <Box+ sx={{+ display: "grid",+ gridTemplateColumns: `repeat(${tableSize.columns}, minmax(${cellSize}px, 1fr))`, // "1fr ".repeat(tableSize.columns),+ gap: "small",+ bg: "background",+ width: "100%",+ }}+ onTouchMove={(e) => {+ const touch = e.touches.item(0);+ const element = document.elementFromPoint(+ touch.pageX,+ touch.pageY+ ) as HTMLElement;+ if (!element) return;+ const index = element.dataset.index;+ if (!index) return;+ setCellLocation(getCellLocation(parseInt(index), tableSize));+ }}+ >+ {Array(tableSize.columns * tableSize.rows)+ .fill(0)+ .map((_, index) => (+ <Box+ key={index}+ data-index={index}+ height={cellSize || 15}+ sx={{+ border: "1px solid var(--disabled)",+ borderRadius: "small",+ bg: isCellHighlighted(index, cellLocation, tableSize)+ ? "disabled"+ : "transparent",+ }}+ onTouchStart={() => {+ setCellLocation(getCellLocation(index, tableSize));+ }}+ onMouseEnter={() => {+ setCellLocation(getCellLocation(index, tableSize));+ }}+ onClick={() => {+ onInsertTable({+ columns: cellLocation.column,+ rows: cellLocation.row,+ });+ }}+ />+ ))}+ </Box>+ <Flex+ sx={{+ display: ["flex", "none", "none"],+ mt: 1,+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <InlineInput+ containerProps={{ sx: { mr: 1 } }}+ label="columns"+ placeholder={`${cellLocation.column} columns`}+ type="number"+ value={cellLocation.column}+ onChange={(e) => {+ setCellLocation((l) => ({+ ...l,+ column: e.target.valueAsNumber || 0,+ }));+ }}+ />+ <InlineInput+ label="rows"+ placeholder={`${cellLocation.row} rows`}+ type="number"+ value={cellLocation.row}+ onChange={(e) => {+ setCellLocation((l) => ({+ ...l,+ row: e.target.valueAsNumber || 0,+ }));+ }}+ />+ </Flex>+ <Text+ variant={"body"}+ sx={{ mt: 1, display: ["none", "block", "block"] }}+ >+ {cellLocation.column} x {cellLocation.row}+ </Text>+ </Flex>+ </Popup>);}diff --git a/packages/editor/src/toolbar/tools/embed.tsx b/packages/editor/src/toolbar/tools/embed.tsxindex 40fcc76fd..762a4b4d7 100644--- a/packages/editor/src/toolbar/tools/embed.tsx+++ b/packages/editor/src/toolbar/tools/embed.tsx@@ -109,20 +109,13 @@ export function EmbedProperties(props: ToolProps) {isTargetAbsolute: true,}}>- <Popup+ <EmbedPopuptitle="Embed properties"- onClose={() => {- setIsOpen(false);- }}- >- <EmbedPopup- title="Embed properties"- onClose={() => setIsOpen(false)}- embed={embed}- onSourceChanged={(src) => editor.commands.setEmbedSource(src)}- onSizeChanged={(size) => editor.commands.setEmbedSize(size)}- />- </Popup>+ onClose={() => setIsOpen(false)}+ embed={embed}+ onSourceChanged={(src) => editor.commands.setEmbedSource(src)}+ onSizeChanged={(size) => editor.commands.setEmbedSize(size)}+ /></ResponsivePresenter></>);diff --git a/packages/editor/src/toolbar/tools/image.tsx b/packages/editor/src/toolbar/tools/image.tsxindex 2bcd90f76..abc4ca4e4 100644--- a/packages/editor/src/toolbar/tools/image.tsx+++ b/packages/editor/src/toolbar/tools/image.tsx@@ -125,20 +125,14 @@ export function ImageProperties(props: ToolProps) {isTargetAbsolute: true,}}>- <Popup- title="Image properties"- onClose={() => {- setIsOpen(false);- }}- >- <ImagePropertiesPopup- editor={editor}- height={height}- width={width}- align={align}- float={float}- />- </Popup>+ <ImagePropertiesPopup+ editor={editor}+ height={height}+ width={width}+ align={align}+ float={float}+ onClose={() => setIsOpen(false)}+ /></ResponsivePresenter></>);diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsxindex e50609085..a5c53c8e7 100644--- a/packages/editor/src/toolbar/tools/link.tsx+++ b/packages/editor/src/toolbar/tools/link.tsx@@ -183,20 +183,16 @@ function LinkTool(props: LinkToolProps) {onClose={() => setIsOpen(false)}focusOnRender={false}>- <Popup- title={isEditing ? "Edit link" : "Insert link"}+ <LinkPopup+ href={href}+ text={text}+ isEditing={isEditing}onClose={() => setIsOpen(false)}- >- <LinkPopup- href={href}- text={text}- isEditing={isEditing}- onDone={({ href, text }) => {- onDone(href, text);- setIsOpen(false);- }}- />- </Popup>+ onDone={({ href, text }) => {+ onDone(href, text);+ setIsOpen(false);+ }}+ /></ResponsivePresenter></>);