Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: move all context toolbars to bottom on mobile

thecodrr43032331345d
diff --git a/packages/editor/dist/components/button.d.ts b/packages/editor/dist/components/button.d.ts
index bb68436e2..feeca8fb8 100644
--- a/packages/editor/dist/components/button.d.ts
+++ b/packages/editor/dist/components/button.d.ts
@@ -1,3 +1,3 @@
/// <reference types="react" />
import { ButtonProps } from "rebass";
-export declare const Button: import("react").ForwardRefExoticComponent<Pick<ButtonProps, "value" | "children" | "cite" | "data" | "form" | "label" | "p" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "name" | "onFocus" | "onBlur" | "fontSize" | "textAlign" | "fontFamily" | "color" | "dir" | "content" | "draggable" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "display" | "flex" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontStyle" | "fontWeight" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "margin" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflow" | "overflowX" | "overflowY" | "padding" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "verticalAlign" | "width" | "default" | "px" | "sizes" | "key" | "selected" | "download" | "placeholder" | "disabled" | "checked" | "size" | "sx" | "variant" | "tx" | "as" | "css" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "paddingX" | "py" | "paddingY" | "bg" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "defer" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "nonce" | "noValidate" | "open" | "optimum" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "shape" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "target" | "type" | "useMap" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "hidden" | "id" | "lang" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("react").RefAttributes<HTMLButtonElement>>;
+export declare const Button: import("react").ForwardRefExoticComponent<Pick<ButtonProps, "cite" | "data" | "dir" | "form" | "label" | "p" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "children" | "className" | "start" | "sizes" | "content" | "variant" | "tx" | "as" | "css" | "key" | "m" | "margin" | "mt" | "marginTop" | "mr" | "marginRight" | "mb" | "marginBottom" | "ml" | "marginLeft" | "mx" | "marginX" | "my" | "marginY" | "padding" | "pt" | "paddingTop" | "pr" | "paddingRight" | "pb" | "paddingBottom" | "pl" | "paddingLeft" | "px" | "paddingX" | "py" | "paddingY" | "width" | "height" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "display" | "verticalAlign" | "size" | "overflow" | "overflowX" | "overflowY" | "fontFamily" | "fontSize" | "fontWeight" | "lineHeight" | "letterSpacing" | "fontStyle" | "textAlign" | "color" | "bg" | "backgroundColor" | "opacity" | "alignItems" | "alignContent" | "justifyItems" | "justifyContent" | "flexWrap" | "flexDirection" | "flex" | "flexGrow" | "flexShrink" | "flexBasis" | "justifySelf" | "alignSelf" | "order" | "sx" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "src" | "srcDoc" | "srcLang" | "srcSet" | "step" | "target" | "type" | "useMap" | "value" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "id" | "lang" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("react").RefAttributes<HTMLButtonElement>>;
diff --git a/packages/editor/dist/extensions/attachment/attachment.d.ts b/packages/editor/dist/extensions/attachment/attachment.d.ts
index 6ed6db8aa..071d35323 100644
--- a/packages/editor/dist/extensions/attachment/attachment.d.ts
+++ b/packages/editor/dist/extensions/attachment/attachment.d.ts
@@ -23,6 +23,7 @@ declare module "@tiptap/core" {
attachment: {
openAttachmentPicker: (type: AttachmentType) => ReturnType;
insertAttachment: (attachment: Attachment) => ReturnType;
+ removeAttachment: () => ReturnType;
downloadAttachment: (attachment: Attachment) => ReturnType;
setAttachmentProgress: (progress: AttachmentProgress) => ReturnType;
};
diff --git a/packages/editor/dist/extensions/attachment/attachment.js b/packages/editor/dist/extensions/attachment/attachment.js
index f5e540bcf..8cb258c18 100644
--- a/packages/editor/dist/extensions/attachment/attachment.js
+++ b/packages/editor/dist/extensions/attachment/attachment.js
@@ -81,13 +81,18 @@ export var AttachmentNode = Node.create({
insertAttachment: function (attachment) {
return function (_a) {
var commands = _a.commands;
- console.log("HI!", attachment);
return commands.insertContent({
type: _this.name,
attrs: attachment,
});
};
},
+ removeAttachment: function () {
+ return function (_a) {
+ var commands = _a.commands;
+ return commands.deleteNode(_this.name);
+ };
+ },
downloadAttachment: function (attachment) {
return function (_a) {
var editor = _a.editor;
diff --git a/packages/editor/dist/extensions/attachment/component.js b/packages/editor/dist/extensions/attachment/component.js
index 124a6e090..0d02da5c2 100644
--- a/packages/editor/dist/extensions/attachment/component.js
+++ b/packages/editor/dist/extensions/attachment/component.js
@@ -11,11 +11,12 @@ var __assign = (this && this.__assign) || function () {
};
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Box, Flex, Text } from "rebass";
-import { ToolButton } from "../../toolbar/components/tool-button";
import { useRef } from "react";
// import { MenuPresenter } from "../../components/menu/menu";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
+import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
+import { DesktopOnly } from "../../components/responsive";
export function AttachmentComponent(props) {
var editor = props.editor, node = props.node, selected = props.selected;
var _a = node.attrs, hash = _a.hash, filename = _a.filename, size = _a.size, progress = _a.progress;
@@ -47,7 +48,7 @@ export function AttachmentComponent(props) {
fontSize: "0.65rem",
color: "fontTertiary",
flexShrink: 0,
- } }, { children: progress ? "".concat(progress, "%") : formatBytes(size) })), selected && (_jsx(Flex, __assign({ sx: { position: "absolute", top: -35 } }, { children: _jsx(AttachmentToolbar, { editor: editor }) })))] })) }));
+ } }, { children: progress ? "".concat(progress, "%") : formatBytes(size) })), _jsx(DesktopOnly, { children: selected && (_jsx(Flex, __assign({ sx: { position: "absolute", top: -35 } }, { children: _jsx(ToolbarGroup, { editor: editor, tools: ["removeAttachment", "downloadAttachment"] }) }))) })] })) }));
}
function formatBytes(bytes, decimals) {
if (decimals === void 0) { decimals = 1; }
@@ -59,13 +60,3 @@ function formatBytes(bytes, decimals) {
var i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + sizes[i];
}
-// TODO make this functional
-function AttachmentToolbar(props) {
- var editor = props.editor;
- return (_jsxs(Flex, __assign({ sx: {
- bg: "background",
- boxShadow: "menu",
- flexWrap: "nowrap",
- borderRadius: "default",
- } }, { children: [_jsx(ToolButton, { toggled: false, title: "Download", id: "download", icon: "download", onClick: function () { }, sx: { mr: 1 } }), _jsx(ToolButton, { toggled: false, title: "delete", id: "delete", icon: "delete", onClick: function () { }, sx: { mr: 0 } })] })));
-}
diff --git a/packages/editor/dist/extensions/embed/component.js b/packages/editor/dist/extensions/embed/component.js
index 240d9af68..8cb47f8ed 100644
--- a/packages/editor/dist/extensions/embed/component.js
+++ b/packages/editor/dist/extensions/embed/component.js
@@ -9,29 +9,12 @@ var __assign = (this && this.__assign) || function () {
};
return __assign.apply(this, arguments);
};
-var __read = (this && this.__read) || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
-};
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Box, Flex } from "rebass";
import { Resizable } from "re-resizable";
-import { ToolButton } from "../../toolbar/components/tool-button";
-import { useRef, useState } from "react";
-import { EmbedPopup } from "../../toolbar/popups/embed-popup";
-import { ResponsivePresenter } from "../../components/responsive";
+import { useRef } from "react";
+import { DesktopOnly } from "../../components/responsive";
+import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
export function EmbedComponent(props) {
var editor = props.editor, updateAttributes = props.updateAttributes, selected = props.selected, node = props.node;
var embedRef = useRef();
@@ -59,7 +42,21 @@ export function EmbedComponent(props) {
":hover": {
borderColor: "border",
},
- } }, { children: selected && (_jsx(EmbedToolbar, { editor: editor, align: align, height: height || 0, width: width || 0, src: src })) })), _jsx(Box, __assign({ as: "iframe", ref: embedRef, src: src, width: "100%", height: "100%", sx: {
+ } }, { children: _jsx(DesktopOnly, { children: selected && (_jsx(Flex, __assign({ sx: { position: "relative", justifyContent: "end" } }, { children: _jsx(Flex, __assign({ sx: {
+ position: "absolute",
+ top: -40,
+ mb: 2,
+ alignItems: "end",
+ } }, { children: _jsx(ToolbarGroup, { editor: editor, tools: [
+ "embedAlignLeft",
+ "embedAlignCenter",
+ "embedAlignRight",
+ "embedProperties",
+ ], sx: {
+ boxShadow: "menu",
+ borderRadius: "default",
+ bg: "background",
+ } }) })) }))) }) })), _jsx(Box, __assign({ as: "iframe", ref: embedRef, src: src, width: "100%", height: "100%", sx: {
border: "none",
// border: isActive
// ? "2px solid var(--primary)"
@@ -67,48 +64,3 @@ export function EmbedComponent(props) {
// borderRadius: "default",
} }, props))] })) })) }));
}
-function EmbedToolbar(props) {
- var editor = props.editor, height = props.height, width = props.width, src = props.src;
- var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];
- var ref = useRef();
- return (_jsxs(Flex, __assign({ ref: ref, sx: {
- flexDirection: "column",
- position: "absolute",
- top: -40,
- mb: 2,
- zIndex: 9999,
- alignItems: "end",
- } }, { children: [_jsxs(Flex, __assign({ sx: {
- bg: "background",
- boxShadow: "menu",
- flexWrap: "nowrap",
- borderRadius: "default",
- mb: 2,
- } }, { children: [_jsxs(Flex, __assign({ className: "toolbar-group", sx: {
- pr: 1,
- mr: 1,
- borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
- } }, { children: [_jsx(ToolButton, { toggled: false, title: "Align left", id: "alignLeft", icon: "alignLeft", onClick: function () {
- return editor.chain().focus().setEmbedAlignment({ align: "left" }).run();
- } }), _jsx(ToolButton, { toggled: false, title: "Align center", id: "alignCenter", icon: "alignCenter", onClick: function () {
- return editor
- .chain()
- .focus()
- .setEmbedAlignment({ align: "center" })
- .run();
- } }), _jsx(ToolButton, { toggled: false, title: "Align right", id: "alignRight", icon: "alignRight", onClick: function () {
- return editor.chain().focus().setEmbedAlignment({ align: "right" }).run();
- } })] })), _jsx(Flex, __assign({ className: "toolbar-group", sx: {
- pr: 1,
- mr: 1,
- borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
- } }, { children: _jsx(ToolButton, { toggled: isOpen, title: "Embed properties", id: "embedProperties", icon: "more", onClick: function () { return setIsOpen(function (s) { return !s; }); } }) }))] })), _jsx(ResponsivePresenter, __assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: function () { return setIsOpen(false); }, blocking: true, focusOnRender: false, position: {
- target: ref.current || "mouse",
- align: "start",
- location: "below",
- yOffset: 10,
- isTargetAbsolute: true,
- } }, { children: _jsx(EmbedPopup, { title: "Embed properties", onClose: function () { return setIsOpen(false); }, embed: props, onSourceChanged: function (src) { }, onSizeChanged: function (size) { return editor.commands.setEmbedSize(size); } }) }))] })));
-}
diff --git a/packages/editor/dist/extensions/embed/embed.d.ts b/packages/editor/dist/extensions/embed/embed.d.ts
index e03119824..969f00b5a 100644
--- a/packages/editor/dist/extensions/embed/embed.d.ts
+++ b/packages/editor/dist/extensions/embed/embed.d.ts
@@ -8,6 +8,7 @@ export declare type EmbedAttributes = Partial<EmbedSizeOptions> & {
export declare type EmbedAlignmentOptions = {
align?: "center" | "left" | "right";
};
+export declare type Embed = Required<EmbedAttributes> & EmbedAlignmentOptions;
export declare type EmbedSizeOptions = {
width: number;
height: number;
@@ -16,11 +17,12 @@ declare module "@tiptap/core" {
interface Commands<ReturnType> {
embed: {
/**
- * Add an image
+ * Add an embed
*/
insertEmbed: (options: EmbedAttributes) => ReturnType;
setEmbedAlignment: (options: EmbedAlignmentOptions) => ReturnType;
setEmbedSize: (options: EmbedSizeOptions) => ReturnType;
+ setEmbedSource: (src: string) => ReturnType;
};
}
}
diff --git a/packages/editor/dist/extensions/embed/embed.js b/packages/editor/dist/extensions/embed/embed.js
index 3d7beff7b..aab2ecb03 100644
--- a/packages/editor/dist/extensions/embed/embed.js
+++ b/packages/editor/dist/extensions/embed/embed.js
@@ -76,6 +76,12 @@ export var EmbedNode = Node.create({
return commands.updateAttributes(_this.name, __assign({}, options));
};
},
+ setEmbedSource: function (src) {
+ return function (_a) {
+ var commands = _a.commands;
+ return commands.updateAttributes(_this.name, { src: src });
+ };
+ },
};
},
});
diff --git a/packages/editor/dist/extensions/image/component.js b/packages/editor/dist/extensions/image/component.js
index cb0aaae9a..f5c89b106 100644
--- a/packages/editor/dist/extensions/image/component.js
+++ b/packages/editor/dist/extensions/image/component.js
@@ -49,9 +49,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
import { Box, Flex, Image } from "rebass";
import { Resizable } from "re-resizable";
import { useEffect, useRef } from "react";
+import { DesktopOnly } from "../../components/responsive";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
-import { ImageToolbar } from "../../toolbar/floatingmenus/image";
+import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
export function ImageComponent(props) {
var _this = this;
var editor = props.editor, updateAttributes = props.updateAttributes, node = props.node, selected = props.selected;
@@ -97,12 +98,21 @@ export function ImageComponent(props) {
width: ref.clientWidth,
height: ref.clientHeight,
});
- }, lockAspectRatio: true }, { children: [selected && (_jsx(Flex, __assign({ sx: { position: "relative", justifyContent: "end" } }, { children: _jsx(Flex, __assign({ sx: {
- position: "absolute",
- top: -40,
- mb: 2,
- alignItems: "end",
- } }, { children: _jsx(ImageToolbar, { editor: editor }) })) }))), _jsx(Icon, { className: "drag-handle", "data-drag-handle": true, draggable: true, path: Icons.dragHandle, sx: {
+ }, lockAspectRatio: true }, { children: [_jsx(DesktopOnly, { children: selected && (_jsx(Flex, __assign({ sx: { position: "relative", justifyContent: "end" } }, { children: _jsx(Flex, __assign({ sx: {
+ position: "absolute",
+ top: -40,
+ mb: 2,
+ alignItems: "end",
+ } }, { children: _jsx(ToolbarGroup, { editor: editor, tools: [
+ "imageAlignLeft",
+ "imageAlignCenter",
+ "imageAlignRight",
+ "imageProperties",
+ ], sx: {
+ boxShadow: "menu",
+ borderRadius: "default",
+ bg: "background",
+ } }) })) }))) }), _jsx(Icon, { className: "drag-handle", "data-drag-handle": true, draggable: true, path: Icons.dragHandle, sx: {
cursor: "grab",
position: "absolute",
top: 2,
diff --git a/packages/editor/dist/extensions/table/component.js b/packages/editor/dist/extensions/table/component.js
index e5a261cfe..399f949f6 100644
--- a/packages/editor/dist/extensions/table/component.js
+++ b/packages/editor/dist/extensions/table/component.js
@@ -33,6 +33,7 @@ import { InsertColumnRight, InsertRowBelow, RowProperties, TableProperties, } fr
import { getToolDefinition } from "../../toolbar/tool-definitions";
import { getPosition } from "../../utils/position";
import { findSelectedDOMNode } from "../../toolbar/utils/prosemirror";
+import { DesktopOnly } from "../../components/responsive";
export function TableComponent(props) {
var editor = props.editor, node = props.node, forwardRef = props.forwardRef;
var colgroupRef = useRef(null);
@@ -43,7 +44,7 @@ export function TableComponent(props) {
return;
updateColumnsOnResize(node, colgroupRef.current, tableRef.current, 50);
}, [node]);
- return (_jsxs(_Fragment, { children: [selected && (_jsxs(_Fragment, { children: [_jsx(TableRowToolbar, { editor: editor, table: tableRef.current }), _jsx(TableColumnToolbar, { editor: editor, table: tableRef.current })] })), _jsx("div", __assign({ className: "tableWrapper" }, { children: _jsx("table", __assign({ ref: function (ref) {
+ return (_jsxs(_Fragment, { children: [_jsx(DesktopOnly, { children: selected && (_jsxs(_Fragment, { children: [_jsx(TableRowToolbar, { editor: editor, table: tableRef.current }), _jsx(TableColumnToolbar, { editor: editor, table: tableRef.current })] })) }), _jsx("div", __assign({ className: "tableWrapper" }, { children: _jsx("table", __assign({ ref: function (ref) {
forwardRef === null || forwardRef === void 0 ? void 0 : forwardRef(ref);
tableRef.current = ref || undefined;
} }, { children: _jsx("colgroup", { ref: colgroupRef }) })) }))] }));
diff --git a/packages/editor/dist/index.d.ts b/packages/editor/dist/index.d.ts
index db2a76b64..7d395def8 100644
--- a/packages/editor/dist/index.d.ts
+++ b/packages/editor/dist/index.d.ts
@@ -1,3 +1,4 @@
+/// <reference types="react" />
import "./extensions";
import { EditorOptions } from "@tiptap/react";
import Toolbar from "./toolbar";
diff --git a/packages/editor/dist/toolbar/icons.d.ts b/packages/editor/dist/toolbar/icons.d.ts
index ae97caf98..201600fde 100644
--- a/packages/editor/dist/toolbar/icons.d.ts
+++ b/packages/editor/dist/toolbar/icons.d.ts
@@ -60,10 +60,12 @@ export declare const Icons: {
replaceOne: string;
replaceAll: string;
replace: string;
+ attachmentSettings: string;
caseSensitive: string;
wholeWord: string;
regex: string;
embed: string;
+ embedSettings: string;
palette: string;
tableSettings: string;
plus: string;
diff --git a/packages/editor/dist/toolbar/icons.js b/packages/editor/dist/toolbar/icons.js
index c7a4cab1f..310c4065f 100644
--- a/packages/editor/dist/toolbar/icons.js
+++ b/packages/editor/dist/toolbar/icons.js
@@ -1,4 +1,4 @@
-import { mdiAttachment, mdiBorderHorizontal, mdiCheck, mdiChevronDown, mdiCodeBraces, mdiCodeTags, mdiDotsVertical, mdiFormatAlignCenter, mdiFormatAlignJustify, mdiFormatAlignLeft, mdiFormatAlignRight, mdiFormatBold, mdiFormatClear, mdiFormatColorHighlight, mdiFormatColorText, mdiFormatItalic, mdiFormatListBulleted, mdiFormatListNumbered, mdiFormatQuoteClose, mdiFormatStrikethrough, mdiFormatSubscript, mdiFormatSuperscript, mdiFormatTextdirectionLToR, mdiFormatTextdirectionRToL, mdiFormatUnderline, mdiImage, mdiInvertColorsOff, mdiLinkPlus, mdiLoading, mdiTable, mdiTableBorder, mdiTableRowPlusAfter, mdiTableRowPlusBefore, mdiTableRowRemove, mdiTableColumnPlusAfter, mdiTableColumnPlusBefore, mdiTableColumnRemove, mdiUploadOutline, mdiPlus, mdiFormatColorFill, mdiClose, mdiSortDescending, mdiArrowExpandRight, mdiArrowExpandLeft, mdiArrowExpandDown, mdiArrowExpandUp, mdiTableMergeCells, mdiTableSplitCell, mdiDeleteOutline, mdiDownloadOutline, mdiFormatListCheckbox, mdiDrag, mdiCheckboxMarkedOutline, mdiChevronUp, mdiArrowUp, mdiArrowDown, mdiRegex, mdiFormatLetterCase, mdiFormatLetterMatches, mdiMoviePlusOutline, mdiLink, mdiChevronRight, mdiTableColumnWidth, mdiTableRowHeight, mdiMinus, mdiPaletteOutline, mdiCircle, mdiChevronLeft, mdiTableCog, mdiTableOff, mdiRectangle, mdiImageEditOutline, mdiArrowLeft, } from "@mdi/js";
+import { mdiAttachment, mdiBorderHorizontal, mdiCheck, mdiChevronDown, mdiCodeBraces, mdiCodeTags, mdiDotsVertical, mdiFormatAlignCenter, mdiFormatAlignJustify, mdiFormatAlignLeft, mdiFormatAlignRight, mdiFormatBold, mdiFormatClear, mdiFormatColorHighlight, mdiFormatColorText, mdiFormatItalic, mdiFormatListBulleted, mdiFormatListNumbered, mdiFormatQuoteClose, mdiFormatStrikethrough, mdiFormatSubscript, mdiFormatSuperscript, mdiFormatTextdirectionLToR, mdiFormatTextdirectionRToL, mdiFormatUnderline, mdiImage, mdiInvertColorsOff, mdiLinkPlus, mdiLoading, mdiTable, mdiTableBorder, mdiTableRowPlusAfter, mdiTableRowPlusBefore, mdiTableRowRemove, mdiTableColumnPlusAfter, mdiTableColumnPlusBefore, mdiTableColumnRemove, mdiUploadOutline, mdiPlus, mdiFormatColorFill, mdiClose, mdiSortDescending, mdiArrowExpandRight, mdiArrowExpandLeft, mdiArrowExpandDown, mdiArrowExpandUp, mdiTableMergeCells, mdiTableSplitCell, mdiDeleteOutline, mdiDownloadOutline, mdiFormatListCheckbox, mdiDrag, mdiCheckboxMarkedOutline, mdiChevronUp, mdiArrowUp, mdiArrowDown, mdiRegex, mdiFormatLetterCase, mdiFormatLetterMatches, mdiMoviePlusOutline, mdiLink, mdiChevronRight, mdiTableColumnWidth, mdiTableRowHeight, mdiMinus, mdiPaletteOutline, mdiCircle, mdiChevronLeft, mdiTableCog, mdiTableOff, mdiRectangle, mdiImageEditOutline, mdiArrowLeft, mdiMovieCogOutline, } from "@mdi/js";
export var Icons = {
bold: mdiFormatBold,
italic: mdiFormatItalic,
@@ -61,10 +61,12 @@ export var Icons = {
replaceOne: "m5.4 5.42 3.48 3.5 3.43-3.43-1.08-1.08-1.57 1.55V3.5a.8.8 0 0 1 .76-.81h2.35v-1.5h-2.35a2.29 2.29 0 0 0-2.28 2.3v2.5L6.48 4.33Zm10.3 2.77c.3.48.7.72 1.25.72.61 0 1.1-.26 1.45-.78.37-.51.55-1.2.55-2.05 0-.8-.15-1.41-.46-1.87a1.51 1.51 0 0 0-1.33-.68c-.63 0-1.11.3-1.45.9h-.02V1.19h-1.37v7.6h1.37v-.6Zm-.03-1.64v-.52c0-.39.09-.7.27-.93a.83.83 0 0 1 .69-.36.76.76 0 0 1 .67.36c.16.24.24.57.24 1 0 .5-.09.9-.26 1.18a.8.8 0 0 1-.73.42.76.76 0 0 1-.63-.33 1.32 1.32 0 0 1-.25-.82zm-1.35 12.82c-.4.23-.97.35-1.71.35-.87 0-1.58-.27-2.12-.82a2.9 2.9 0 0 1-.8-2.12c0-1 .28-1.8.86-2.37a3.12 3.12 0 0 1 2.31-.87c.67 0 1.16.1 1.46.28v1.54a1.95 1.95 0 0 0-1.23-.42c-.5 0-.9.15-1.2.46-.29.3-.43.72-.43 1.26 0 .52.14.93.42 1.23.28.3.67.44 1.16.44.43 0 .86-.14 1.28-.43zm-7.73-8.91L5.05 12v9.27l1.54 1.54h10.82l1.54-1.54V12l-1.54-1.54zm0 1.54h10.82v9.27H6.59Z",
replaceAll: "M16.53 4.22c.22-.45.52-.68.92-.68.36 0 .64.17.83.52.2.34.3.81.3 1.4a3.1 3.1 0 0 1-.35 1.57c-.22.39-.53.59-.91.59-.35 0-.61-.19-.79-.55h-.01v.45h-.87V1.77h.87v2.45h.01zm-.02 1.6a1.14 1.14 0 0 0 .15.63c.1.17.24.25.4.25.2 0 .35-.1.46-.32a2 2 0 0 0 .17-.9c0-.32-.05-.57-.15-.75-.1-.18-.24-.27-.43-.27-.17 0-.32.09-.43.27a1.3 1.3 0 0 0-.17.7ZM5.6 11.56l-3.1-3.1.97-.97 1.47 1.46v-2.2A2.03 2.03 0 0 1 6.96 4.7h3.43v1.32H6.96a.72.72 0 0 0-.68.73l.01 2.19 1.39-1.38.96.96-3.04 3.04Zm7.65-4.04h.94v-2.5c0-1.18-.46-1.78-1.38-1.78-.2 0-.41.04-.66.1a2.11 2.11 0 0 0-.56.25v.97c.34-.3.71-.44 1.1-.44.38 0 .57.23.57.68l-.88.16c-.74.12-1.11.59-1.11 1.4 0 .38.09.7.27.92a.9.9 0 0 0 .74.35c.42 0 .74-.24.96-.7h.01zm0-1.98v.28a1.1 1.1 0 0 1-.17.64.54.54 0 0 1-.46.25.4.4 0 0 1-.32-.14.56.56 0 0 1-.11-.36c0-.33.16-.51.48-.57l.59-.1zM9.82 19.21h-.94v-.6h-.02c-.21.46-.53.7-.96.7a.9.9 0 0 1-.74-.35 1.47 1.47 0 0 1-.27-.92c0-.8.38-1.28 1.12-1.4l.87-.15c0-.46-.19-.69-.57-.69-.38 0-.75.15-1.1.45v-.98c.14-.09.33-.17.57-.24.24-.07.46-.1.66-.1.92 0 1.38.59 1.38 1.78zm-.94-1.7v-.29l-.58.1c-.33.06-.49.25-.49.57 0 .15.04.27.12.36a.4.4 0 0 0 .32.14.54.54 0 0 0 .46-.25c.11-.17.17-.38.17-.63zm4.24 1.8c.47 0 .83-.09 1.08-.26v-1.03a1.32 1.32 0 0 1-.8.3.9.9 0 0 1-.74-.31c-.17-.22-.26-.5-.26-.88s.1-.68.28-.9a.94.94 0 0 1 .75-.32c.28 0 .54.1.77.3v-1.1c-.19-.12-.5-.19-.91-.19-.61 0-1.1.2-1.47.62-.36.4-.54.97-.54 1.68 0 .61.17 1.11.5 1.5.35.4.8.59 1.34.59zM2.5 13.46 3.96 12h13.16l1.46 1.46v7.3l-1.46 1.47H3.96L2.5 20.77Zm1.46 0v7.3h13.16v-7.3Zm4.39-2.92L9.8 9.08h10.23l1.46 1.46v7.3l-1.46 1.47v-8.77z",
replace: "M21 4.5000005V14.25a1.5000007 1.5000005 0 0 1-1.500007 1.500005h-8.999996v1.49999a.74999993.74999995 0 0 1-.459373.693747.79687482.79687478 0 0 1-.290624.056263.77812509.77812509 0 0 1-.534375-.215621l-2.25-2.25a.759375.759375 0 0 1 0-1.068763l2.25-2.25a.7875.7875 0 0 1 .824999-.159371.74999993.74999995 0 0 1 .459373.693745V14.25h8.999996V4.5000005H9.0000007v.7499997a.75000036.75000039 0 0 1-1.5000007 0v-.7499997A1.5000007 1.5000005 0 0 1 9.0000007 3H19.499993A1.5000007 1.5000005 0 0 1 21 4.5000005ZM15.750007 18.000005a.74999993.74999995 0 0 0-.750014.749995v.749995H4.5000007V9.7500002h9.0000063v1.5000048a.759375.759375 0 0 0 .459381.693745.79687482.79687478 0 0 0 .290612.05631.77812509.77812509 0 0 0 .534372-.215621l2.25-2.2500079a.759375.759375 0 0 0 0-1.06875l-2.25-2.25a.76875023.76875019 0 0 0-.824984-.1594227.74999993.74999995 0 0 0-.459381.6937502v1.4999978H4.5000007A1.5000007 1.5000005 0 0 0 3 9.7500002v9.7499948A1.5000007 1.5000005 0 0 0 4.5000007 21H14.999993A1.5000007 1.5000005 0 0 0 16.5 19.499995V18.75a.74999993.74999995 0 0 0-.749993-.749995z",
+ attachmentSettings: "m24.0138 20.223188-1.07-.82c.02-.17.04-.33.04-.5 0-.17-.01-.33-.04-.5l1.06-.82c.09258-.07939.117526-.212463.06-.32l-1-1.73c-.06-.13-.19-.13-.33-.13l-1.22.5c-.28-.18-.54-.35-.85-.47l-.19-1.32c-.01-.12-.12-.21-.24-.21h-2c-.12 0-.23.09-.25.21l-.19 1.32c-.3.13-.59.29-.85.47l-1.24-.5c-.11 0-.24 0-.31.13l-1 1.73c-.06.11-.04.24.06.32l1.06.82c-.03989.33214-.03989.66786 0 1l-1.06.82c-.09258.07939-.117526.212463-.06.32l1 1.73c.06.13.19.13.31.13l1.24-.5c.26.18.54.35.85.47l.19 1.32c.02.12.12.21.25.21h2c.12 0 .23-.09.25-.21l.19-1.32c.3-.13.56-.29.84-.47l1.22.5c.14 0 .27 0 .34-.13l1-1.73c.05753-.107537.03258-.240606-.06-.32m-4.78.18c-.83 0-1.5-.67-1.5-1.5s.68-1.5 1.5-1.5 1.5.67 1.5 1.5-.66 1.5-1.5 1.5zM16.61 13.5c-.8.35-1.5.86-2.07 1.5H9.5c-3.3333319 0-3.3333319-5 0-5H17v1.5H9.5c-.55 0-1 .45-1 1s.45 1 1 1h7.11m-13.11-1c0-2.21 1.79-4 4-4H18c2.434718-.00632 3.435847 3.121347 1.45 4.53.6.04 1.18.17 1.72.38.52-.67.83-1.5.83-2.41 0-2.21-1.79-4-4-4H7.5C4.46 7 2 9.46 2 12.5S4.46 18 7.5 18h5.59c.09-.53.25-1.03.46-1.5H7.5c-2.21 0-4-1.79-4-4",
caseSensitive: mdiFormatLetterCase,
wholeWord: mdiFormatLetterMatches,
regex: mdiRegex,
embed: mdiMoviePlusOutline,
+ embedSettings: mdiMovieCogOutline,
palette: mdiPaletteOutline,
tableSettings: mdiTableCog,
plus: mdiPlus,
diff --git a/packages/editor/dist/toolbar/popups/embedpopup.d.ts b/packages/editor/dist/toolbar/popups/embedpopup.d.ts
index 14571c5c5..384597e54 100644
--- a/packages/editor/dist/toolbar/popups/embedpopup.d.ts
+++ b/packages/editor/dist/toolbar/popups/embedpopup.d.ts
@@ -1,6 +1,5 @@
/// <reference types="react" />
-import { EmbedAlignmentOptions, EmbedAttributes, EmbedSizeOptions } from "../../extensions/embed";
-declare type Embed = Required<EmbedAttributes> & EmbedAlignmentOptions;
+import { Embed, EmbedSizeOptions } from "../../extensions/embed";
export declare type EmbedPopupProps = {
onClose: (embed?: Embed) => void;
title?: string;
@@ -9,4 +8,3 @@ export declare type EmbedPopupProps = {
onSourceChanged?: (src: string) => void;
};
export declare function EmbedPopup(props: EmbedPopupProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/toolbar/tooldefinitions.js b/packages/editor/dist/toolbar/tooldefinitions.js
index f77d66f67..ba9c7e55f 100644
--- a/packages/editor/dist/toolbar/tooldefinitions.js
+++ b/packages/editor/dist/toolbar/tooldefinitions.js
@@ -221,6 +221,46 @@ var tools = {
title: "Image properties",
conditional: true,
},
+ attachmentSettings: {
+ icon: "attachmentSettings",
+ title: "Attachment settings",
+ conditional: true,
+ },
+ downloadAttachment: {
+ icon: "download",
+ title: "Download attachment",
+ conditional: true,
+ },
+ removeAttachment: {
+ icon: "delete",
+ title: "Remove attachment",
+ conditional: true,
+ },
+ embedSettings: {
+ icon: "embedSettings",
+ title: "Embed settings",
+ conditional: true,
+ },
+ embedAlignCenter: {
+ icon: "alignCenter",
+ title: "Align center",
+ conditional: true,
+ },
+ embedAlignLeft: {
+ icon: "alignLeft",
+ title: "Align left",
+ conditional: true,
+ },
+ embedAlignRight: {
+ icon: "alignRight",
+ title: "Align right",
+ conditional: true,
+ },
+ embedProperties: {
+ icon: "more",
+ title: "Embed properties",
+ conditional: true,
+ },
};
export function getToolDefinition(id) {
return tools[id];
diff --git a/packages/editor/dist/toolbar/tools/attachment.d.ts b/packages/editor/dist/toolbar/tools/attachment.d.ts
new file mode 100644
index 000000000..6fb9c8012
--- /dev/null
+++ b/packages/editor/dist/toolbar/tools/attachment.d.ts
@@ -0,0 +1,5 @@
+/// <reference types="react" />
+import { ToolProps } from "../types";
+export declare function AttachmentSettings(props: ToolProps): JSX.Element | null;
+export declare function DownloadAttachment(props: ToolProps): JSX.Element;
+export declare function RemoveAttachment(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/toolbar/tools/attachment.js b/packages/editor/dist/toolbar/tools/attachment.js
new file mode 100644
index 000000000..c086123ca
--- /dev/null
+++ b/packages/editor/dist/toolbar/tools/attachment.js
@@ -0,0 +1,35 @@
+var __assign = (this && this.__assign) || function () {
+ __assign = Object.assign || function(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
+ t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+};
+import { jsx as _jsx } from "react/jsx-runtime";
+import { ToolButton } from "../components/tool-button";
+import { MoreTools } from "../components/more-tools";
+import { useToolbarLocation } from "../stores/toolbar-store";
+import { findSelectedNode } from "../utils/prosemirror";
+export function AttachmentSettings(props) {
+ var editor = props.editor;
+ var isBottom = useToolbarLocation() === "bottom";
+ if (!editor.isActive("attachment") || !isBottom)
+ return null;
+ return (_jsx(MoreTools, __assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: [] })));
+}
+export function DownloadAttachment(props) {
+ var editor = props.editor;
+ return (_jsx(ToolButton, __assign({}, props, { toggled: false, onClick: function () {
+ var attachmentNode = findSelectedNode(editor, "attachment");
+ var attachment = ((attachmentNode === null || attachmentNode === void 0 ? void 0 : attachmentNode.attrs) || {});
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().downloadAttachment(attachment).run();
+ } })));
+}
+export function RemoveAttachment(props) {
+ var editor = props.editor;
+ return (_jsx(ToolButton, __assign({}, props, { toggled: false, onClick: function () { return editor === null || editor === void 0 ? void 0 : editor.chain().focus().removeAttachment().run(); } })));
+}
diff --git a/packages/editor/dist/toolbar/tools/embed.d.ts b/packages/editor/dist/toolbar/tools/embed.d.ts
new file mode 100644
index 000000000..3c143f3c1
--- /dev/null
+++ b/packages/editor/dist/toolbar/tools/embed.d.ts
@@ -0,0 +1,7 @@
+/// <reference types="react" />
+import { ToolProps } from "../types";
+export declare function EmbedSettings(props: ToolProps): JSX.Element | null;
+export declare function EmbedAlignLeft(props: ToolProps): JSX.Element;
+export declare function EmbedAlignRight(props: ToolProps): JSX.Element;
+export declare function EmbedAlignCenter(props: ToolProps): JSX.Element;
+export declare function EmbedProperties(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/toolbar/tools/embed.js b/packages/editor/dist/toolbar/tools/embed.js
new file mode 100644
index 000000000..faa1f3157
--- /dev/null
+++ b/packages/editor/dist/toolbar/tools/embed.js
@@ -0,0 +1,77 @@
+var __assign = (this && this.__assign) || function () {
+ __assign = Object.assign || function(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
+ t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+};
+var __read = (this && this.__read) || function (o, n) {
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
+ if (!m) return o;
+ var i = m.call(o), r, ar = [], e;
+ try {
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
+ }
+ catch (error) { e = { error: error }; }
+ finally {
+ try {
+ if (r && !r.done && (m = i["return"])) m.call(i);
+ }
+ finally { if (e) throw e.error; }
+ }
+ return ar;
+};
+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";
+import { findSelectedNode } from "../utils/prosemirror";
+import { EmbedPopup } from "../popups/embed-popup";
+export function EmbedSettings(props) {
+ var editor = props.editor;
+ var isBottom = useToolbarLocation() === "bottom";
+ if (!editor.isActive("embed") || !isBottom)
+ return null;
+ return (_jsx(MoreTools, __assign({}, props, { autoCloseOnUnmount: true, popupId: "embedSettings", tools: [] })));
+}
+export function EmbedAlignLeft(props) {
+ var editor = props.editor;
+ return (_jsx(ToolButton, __assign({}, props, { toggled: false, onClick: function () {
+ return editor.chain().focus().setEmbedAlignment({ align: "left" }).run();
+ } })));
+}
+export function EmbedAlignRight(props) {
+ var editor = props.editor;
+ return (_jsx(ToolButton, __assign({}, props, { toggled: false, onClick: function () {
+ return editor.chain().focus().setEmbedAlignment({ align: "right" }).run();
+ } })));
+}
+export function EmbedAlignCenter(props) {
+ var editor = props.editor;
+ return (_jsx(ToolButton, __assign({}, props, { toggled: false, onClick: function () {
+ return editor.chain().focus().setEmbedAlignment({ align: "center" }).run();
+ } })));
+}
+export function EmbedProperties(props) {
+ var editor = props.editor;
+ var _a = __read(useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];
+ var buttonRef = useRef();
+ var embedNode = useMemo(function () { return findSelectedNode(editor, "embed"); }, []);
+ var embed = ((embedNode === null || embedNode === void 0 ? void 0 : embedNode.attrs) || {});
+ return (_jsxs(_Fragment, { children: [_jsx(ToolButton, __assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: function () { return setIsOpen(function (s) { return !s; }); } })), _jsx(ResponsivePresenter, __assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: function () { return setIsOpen(false); }, blocking: true, focusOnRender: false, position: {
+ target: buttonRef.current || "mouse",
+ align: "start",
+ 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); } }) })) }))] }));
+}
diff --git a/packages/editor/dist/toolbar/tools/index.d.ts b/packages/editor/dist/toolbar/tools/index.d.ts
index 50c623077..699577808 100644
--- a/packages/editor/dist/toolbar/tools/index.d.ts
+++ b/packages/editor/dist/toolbar/tools/index.d.ts
@@ -10,6 +10,8 @@ import { LeftToRight, RightToLeft } from "./text-direction";
import { Highlight, TextColor } from "./colors";
import { TableSettings, ColumnProperties, RowProperties, CellProperties, CellBackgroundColor, CellBorderColor, CellTextColor, CellBorderWidth } from "./table";
import { ImageSettings, ImageAlignCenter, ImageAlignLeft, ImageAlignRight, ImageProperties } from "./image";
+import { AttachmentSettings, DownloadAttachment, RemoveAttachment } from "./attachment";
+import { EmbedAlignCenter, EmbedAlignLeft, EmbedAlignRight, EmbedProperties, EmbedSettings } from "./embed";
export declare type ToolId = keyof typeof tools;
declare const tools: {
bold: typeof Bold;
@@ -40,6 +42,14 @@ declare const tools: {
imageAlignLeft: typeof ImageAlignLeft;
imageAlignRight: typeof ImageAlignRight;
imageProperties: typeof ImageProperties;
+ embedAlignCenter: typeof EmbedAlignCenter;
+ embedAlignLeft: typeof EmbedAlignLeft;
+ embedAlignRight: typeof EmbedAlignRight;
+ embedProperties: typeof EmbedProperties;
+ embedSettings: typeof EmbedSettings;
+ attachmentSettings: typeof AttachmentSettings;
+ downloadAttachment: typeof DownloadAttachment;
+ removeAttachment: typeof RemoveAttachment;
tableSettings: typeof TableSettings;
columnProperties: typeof ColumnProperties;
rowProperties: typeof RowProperties;
diff --git a/packages/editor/dist/toolbar/tools/index.js b/packages/editor/dist/toolbar/tools/index.js
index 44aa058c6..1e6ad1ef1 100644
--- a/packages/editor/dist/toolbar/tools/index.js
+++ b/packages/editor/dist/toolbar/tools/index.js
@@ -8,6 +8,8 @@ import { LeftToRight, RightToLeft } from "./text-direction";
import { Highlight, TextColor } from "./colors";
import { TableSettings, ColumnProperties, RowProperties, CellProperties, InsertColumnLeft, InsertColumnRight, MoveColumnLeft, MoveColumnRight, DeleteColumn, SplitCells, MergeCells, InsertRowAbove, InsertRowBelow, MoveRowUp, MoveRowDown, DeleteRow, DeleteTable, CellBackgroundColor, CellBorderColor, CellTextColor, CellBorderWidth, } from "./table";
import { ImageSettings, ImageAlignCenter, ImageAlignLeft, ImageAlignRight, ImageProperties, } from "./image";
+import { AttachmentSettings, DownloadAttachment, RemoveAttachment, } from "./attachment";
+import { EmbedAlignCenter, EmbedAlignLeft, EmbedAlignRight, EmbedProperties, EmbedSettings, } from "./embed";
var tools = {
bold: Bold,
italic: Italic,
@@ -37,6 +39,14 @@ var tools = {
imageAlignLeft: ImageAlignLeft,
imageAlignRight: ImageAlignRight,
imageProperties: ImageProperties,
+ embedAlignCenter: EmbedAlignCenter,
+ embedAlignLeft: EmbedAlignLeft,
+ embedAlignRight: EmbedAlignRight,
+ embedProperties: EmbedProperties,
+ embedSettings: EmbedSettings,
+ attachmentSettings: AttachmentSettings,
+ downloadAttachment: DownloadAttachment,
+ removeAttachment: RemoveAttachment,
tableSettings: TableSettings,
columnProperties: ColumnProperties,
rowProperties: RowProperties,
diff --git a/packages/editor/src/extensions/attachment/attachment.ts b/packages/editor/src/extensions/attachment/attachment.ts
index 373bbd0dc..4c1ab06a5 100644
--- a/packages/editor/src/extensions/attachment/attachment.ts
+++ b/packages/editor/src/extensions/attachment/attachment.ts
@@ -30,6 +30,7 @@ declare module "@tiptap/core" {
attachment: {
openAttachmentPicker: (type: AttachmentType) => ReturnType;
insertAttachment: (attachment: Attachment) => ReturnType;
+ removeAttachment: () => ReturnType;
downloadAttachment: (attachment: Attachment) => ReturnType;
setAttachmentProgress: (progress: AttachmentProgress) => ReturnType;
};
@@ -98,12 +99,15 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
insertAttachment:
(attachment) =>
({ commands }) => {
- console.log("HI!", attachment);
return commands.insertContent({
type: this.name,
attrs: attachment,
});
},
+ removeAttachment:
+ () =>
+ ({ commands }) =>
+ commands.deleteNode(this.name),
downloadAttachment:
(attachment) =>
({ editor }) => {
diff --git a/packages/editor/src/extensions/attachment/component.tsx b/packages/editor/src/extensions/attachment/component.tsx
index 27ecb2bc5..2385b5c77 100644
--- a/packages/editor/src/extensions/attachment/component.tsx
+++ b/packages/editor/src/extensions/attachment/component.tsx
@@ -1,5 +1,5 @@
import { Box, Flex, Text } from "rebass";
-import { AttachmentWithProgress } from "./attachment";
+import { Attachment, AttachmentWithProgress } from "./attachment";
import { ToolButton } from "../../toolbar/components/tool-button";
import { Editor } from "@tiptap/core";
import { useRef } from "react";
@@ -8,6 +8,8 @@ import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
import { SelectionBasedReactNodeViewProps } from "../react";
import { PopupPresenter } from "../../components/popup-presenter";
+import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
+import { DesktopOnly } from "../../components/responsive";
export function AttachmentComponent(
props: SelectionBasedReactNodeViewProps<AttachmentWithProgress>
@@ -66,11 +68,16 @@ export function AttachmentComponent(
>
{progress ? `${progress}%` : formatBytes(size)}
</Text>
- {selected && (
- <Flex sx={{ position: "absolute", top: -35 }}>
- <AttachmentToolbar editor={editor} />
- </Flex>
- )}
+ <DesktopOnly>
+ {selected && (
+ <Flex sx={{ position: "absolute", top: -35 }}>
+ <ToolbarGroup
+ editor={editor}
+ tools={["removeAttachment", "downloadAttachment"]}
+ />
+ </Flex>
+ )}
+ </DesktopOnly>
</Box>
</>
);
@@ -87,40 +94,3 @@ function formatBytes(bytes: number, decimals = 1) {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + sizes[i];
}
-
-type AttachmentToolbarProps = {
- editor: Editor;
-};
-
-// TODO make this functional
-function AttachmentToolbar(props: AttachmentToolbarProps) {
- const { editor } = props;
-
- return (
- <Flex
- sx={{
- bg: "background",
- boxShadow: "menu",
- flexWrap: "nowrap",
- borderRadius: "default",
- }}
- >
- <ToolButton
- toggled={false}
- title="Download"
- id="download"
- icon="download"
- onClick={() => {}}
- sx={{ mr: 1 }}
- />
- <ToolButton
- toggled={false}
- title="delete"
- id="delete"
- icon="delete"
- onClick={() => {}}
- sx={{ mr: 0 }}
- />
- </Flex>
- );
-}
diff --git a/packages/editor/src/extensions/embed/component.tsx b/packages/editor/src/extensions/embed/component.tsx
index 5ba98c1cd..172288fe8 100644
--- a/packages/editor/src/extensions/embed/component.tsx
+++ b/packages/editor/src/extensions/embed/component.tsx
@@ -1,14 +1,10 @@
import { Box, Flex } from "rebass";
-import { ThemeProvider } from "emotion-theming";
-import { Theme } from "@notesnook/theme";
import { Resizable } from "re-resizable";
-import { ToolButton } from "../../toolbar/components/tool-button";
-import { Editor } from "@tiptap/core";
-import { useEffect, useRef, useState } from "react";
+import { useRef } from "react";
import { EmbedAlignmentOptions, EmbedAttributes } from "./embed";
-import { EmbedPopup } from "../../toolbar/popups/embed-popup";
import { SelectionBasedReactNodeViewProps } from "../react";
-import { ResponsivePresenter } from "../../components/responsive";
+import { DesktopOnly } from "../../components/responsive";
+import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
export function EmbedComponent(
props: SelectionBasedReactNodeViewProps<
@@ -61,15 +57,35 @@ export function EmbedComponent(
},
}}
>
- {selected && (
- <EmbedToolbar
- editor={editor}
- align={align}
- height={height || 0}
- width={width || 0}
- src={src}
- />
- )}
+ <DesktopOnly>
+ {selected && (
+ <Flex sx={{ position: "relative", justifyContent: "end" }}>
+ <Flex
+ sx={{
+ position: "absolute",
+ top: -40,
+ mb: 2,
+ alignItems: "end",
+ }}
+ >
+ <ToolbarGroup
+ editor={editor}
+ tools={[
+ "embedAlignLeft",
+ "embedAlignCenter",
+ "embedAlignRight",
+ "embedProperties",
+ ]}
+ sx={{
+ boxShadow: "menu",
+ borderRadius: "default",
+ bg: "background",
+ }}
+ />
+ </Flex>
+ </Flex>
+ )}
+ </DesktopOnly>
</Flex>
<Box
as="iframe"
@@ -91,122 +107,3 @@ export function EmbedComponent(
</>
);
}
-
-type ImageToolbarProps = Required<EmbedAttributes> &
- EmbedAlignmentOptions & {
- editor: Editor;
- };
-
-function EmbedToolbar(props: ImageToolbarProps) {
- const { editor, height, width, src } = props;
- const [isOpen, setIsOpen] = useState(false);
- const ref = useRef<HTMLDivElement>();
-
- return (
- <Flex
- ref={ref}
- sx={{
- flexDirection: "column",
- position: "absolute",
- top: -40,
- mb: 2,
- zIndex: 9999,
- alignItems: "end",
- }}
- >
- <Flex
- sx={{
- bg: "background",
- boxShadow: "menu",
- flexWrap: "nowrap",
- borderRadius: "default",
- mb: 2,
- }}
- >
- <Flex
- className="toolbar-group"
- sx={{
- pr: 1,
- mr: 1,
- borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
- }}
- >
- <ToolButton
- toggled={false}
- title="Align left"
- id="alignLeft"
- icon="alignLeft"
- onClick={() =>
- editor.chain().focus().setEmbedAlignment({ align: "left" }).run()
- }
- />
-
- <ToolButton
- toggled={false}
- title="Align center"
- id="alignCenter"
- icon="alignCenter"
- onClick={() =>
- editor
- .chain()
- .focus()
- .setEmbedAlignment({ align: "center" })
- .run()
- }
- />
-
- <ToolButton
- toggled={false}
- title="Align right"
- id="alignRight"
- icon="alignRight"
- onClick={() =>
- editor.chain().focus().setEmbedAlignment({ align: "right" }).run()
- }
- />
- </Flex>
- <Flex
- className="toolbar-group"
- sx={{
- pr: 1,
- mr: 1,
- borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
- }}
- >
- <ToolButton
- toggled={isOpen}
- title="Embed properties"
- id="embedProperties"
- icon="more"
- onClick={() => setIsOpen((s) => !s)}
- />
- </Flex>
- </Flex>
- <ResponsivePresenter
- isOpen={isOpen}
- desktop="menu"
- mobile="sheet"
- onClose={() => setIsOpen(false)}
- blocking
- focusOnRender={false}
- position={{
- target: ref.current || "mouse",
- align: "start",
- location: "below",
- yOffset: 10,
- isTargetAbsolute: true,
- }}
- >
- <EmbedPopup
- title="Embed properties"
- onClose={() => setIsOpen(false)}
- embed={props}
- onSourceChanged={(src) => {}}
- onSizeChanged={(size) => editor.commands.setEmbedSize(size)}
- />
- </ResponsivePresenter>
- </Flex>
- );
-}
diff --git a/packages/editor/src/extensions/embed/embed.ts b/packages/editor/src/extensions/embed/embed.ts
index 1e44423c5..9bf0eb0c3 100644
--- a/packages/editor/src/extensions/embed/embed.ts
+++ b/packages/editor/src/extensions/embed/embed.ts
@@ -18,6 +18,8 @@ export type EmbedAlignmentOptions = {
align?: "center" | "left" | "right";
};
+export type Embed = Required<EmbedAttributes> & EmbedAlignmentOptions;
+
export type EmbedSizeOptions = {
width: number;
height: number;
@@ -27,11 +29,12 @@ declare module "@tiptap/core" {
interface Commands<ReturnType> {
embed: {
/**
- * Add an image
+ * Add an embed
*/
insertEmbed: (options: EmbedAttributes) => ReturnType;
setEmbedAlignment: (options: EmbedAlignmentOptions) => ReturnType;
setEmbedSize: (options: EmbedSizeOptions) => ReturnType;
+ setEmbedSource: (src: string) => ReturnType;
};
}
}
@@ -102,6 +105,11 @@ export const EmbedNode = Node.create<EmbedOptions>({
({ commands }) => {
return commands.updateAttributes(this.name, { ...options });
},
+ setEmbedSource:
+ (src) =>
+ ({ commands }) => {
+ return commands.updateAttributes(this.name, { src });
+ },
};
},
});
diff --git a/packages/editor/src/extensions/image/component.tsx b/packages/editor/src/extensions/image/component.tsx
index e540943c4..34dba856d 100644
--- a/packages/editor/src/extensions/image/component.tsx
+++ b/packages/editor/src/extensions/image/component.tsx
@@ -1,21 +1,12 @@
-import { Box, Flex, Image, ImageProps } from "rebass";
-import {
- ImageAlignmentOptions,
- ImageAttributes,
- ImageSizeOptions,
-} from "./image";
-import { Theme } from "@notesnook/theme";
+import { Box, Flex, Image } from "rebass";
+import { ImageAlignmentOptions, ImageAttributes } from "./image";
import { Resizable } from "re-resizable";
-import { ToolButton } from "../../toolbar/components/tool-button";
-import { Editor } from "@tiptap/core";
-import { useEffect, useRef, useState } from "react";
-import { ReactNodeViewProps, SelectionBasedReactNodeViewProps } from "../react";
-import { ResponsivePresenter } from "../../components/responsive";
-import { ImageProperties } from "../../toolbar/popups/image-properties";
-import { Popup } from "../../toolbar/components/popup";
+import { useEffect, useRef } from "react";
+import { SelectionBasedReactNodeViewProps } from "../react";
+import { DesktopOnly } from "../../components/responsive";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
-import { ImageToolbar } from "../../toolbar/floatingmenus/image";
+import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
export function ImageComponent(
props: SelectionBasedReactNodeViewProps<
@@ -69,20 +60,35 @@ export function ImageComponent(
}}
lockAspectRatio={true}
>
- {selected && (
- <Flex sx={{ position: "relative", justifyContent: "end" }}>
- <Flex
- sx={{
- position: "absolute",
- top: -40,
- mb: 2,
- alignItems: "end",
- }}
- >
- <ImageToolbar editor={editor} />
+ <DesktopOnly>
+ {selected && (
+ <Flex sx={{ position: "relative", justifyContent: "end" }}>
+ <Flex
+ sx={{
+ position: "absolute",
+ top: -40,
+ mb: 2,
+ alignItems: "end",
+ }}
+ >
+ <ToolbarGroup
+ editor={editor}
+ tools={[
+ "imageAlignLeft",
+ "imageAlignCenter",
+ "imageAlignRight",
+ "imageProperties",
+ ]}
+ sx={{
+ boxShadow: "menu",
+ borderRadius: "default",
+ bg: "background",
+ }}
+ />
+ </Flex>
</Flex>
- </Flex>
- )}
+ )}
+ </DesktopOnly>
<Icon
className="drag-handle"
data-drag-handle
diff --git a/packages/editor/src/extensions/table/component.tsx b/packages/editor/src/extensions/table/component.tsx
index f3c8d294d..7eacddb08 100644
--- a/packages/editor/src/extensions/table/component.tsx
+++ b/packages/editor/src/extensions/table/component.tsx
@@ -31,6 +31,7 @@ import {
import { getToolDefinition } from "../../toolbar/tool-definitions";
import { getPosition, PositionOptions } from "../../utils/position";
import { findSelectedDOMNode } from "../../toolbar/utils/prosemirror";
+import { DesktopOnly } from "../../components/responsive";
export function TableComponent(props: SelectionBasedReactNodeViewProps) {
const { editor, node, forwardRef } = props;
@@ -46,12 +47,14 @@ export function TableComponent(props: SelectionBasedReactNodeViewProps) {
return (
<>
- {selected && (
- <>
- <TableRowToolbar editor={editor} table={tableRef.current} />
- <TableColumnToolbar editor={editor} table={tableRef.current} />
- </>
- )}
+ <DesktopOnly>
+ {selected && (
+ <>
+ <TableRowToolbar editor={editor} table={tableRef.current} />
+ <TableColumnToolbar editor={editor} table={tableRef.current} />
+ </>
+ )}
+ </DesktopOnly>
<div className="tableWrapper">
<table
ref={(ref) => {
diff --git a/packages/editor/src/toolbar/floating-menus/image.tsx b/packages/editor/src/toolbar/floating-menus/image.tsx
deleted file mode 100644
index c9f00db6a..000000000
--- a/packages/editor/src/toolbar/floating-menus/image.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { ToolbarGroup } from "../components/toolbar-group";
-import { FloatingMenuProps } from "./types";
-
-export function ImageToolbar(props: FloatingMenuProps) {
- const { editor } = props;
-
- return (
- <ToolbarGroup
- editor={editor}
- tools={[
- "imageAlignLeft",
- "imageAlignCenter",
- "imageAlignRight",
- "imageProperties",
- ]}
- sx={{
- boxShadow: "menu",
- borderRadius: "default",
- bg: "background",
- }}
- />
- );
-}
diff --git a/packages/editor/src/toolbar/icons.ts b/packages/editor/src/toolbar/icons.ts
index 9bd90b1ab..7494d9199 100644
--- a/packages/editor/src/toolbar/icons.ts
+++ b/packages/editor/src/toolbar/icons.ts
@@ -95,6 +95,7 @@ import {
mdiImageEdit,
mdiImageEditOutline,
mdiArrowLeft,
+ mdiMovieCogOutline,
} from "@mdi/js";
export const Icons = {
@@ -164,10 +165,13 @@ export const Icons = {
"M16.53 4.22c.22-.45.52-.68.92-.68.36 0 .64.17.83.52.2.34.3.81.3 1.4a3.1 3.1 0 0 1-.35 1.57c-.22.39-.53.59-.91.59-.35 0-.61-.19-.79-.55h-.01v.45h-.87V1.77h.87v2.45h.01zm-.02 1.6a1.14 1.14 0 0 0 .15.63c.1.17.24.25.4.25.2 0 .35-.1.46-.32a2 2 0 0 0 .17-.9c0-.32-.05-.57-.15-.75-.1-.18-.24-.27-.43-.27-.17 0-.32.09-.43.27a1.3 1.3 0 0 0-.17.7ZM5.6 11.56l-3.1-3.1.97-.97 1.47 1.46v-2.2A2.03 2.03 0 0 1 6.96 4.7h3.43v1.32H6.96a.72.72 0 0 0-.68.73l.01 2.19 1.39-1.38.96.96-3.04 3.04Zm7.65-4.04h.94v-2.5c0-1.18-.46-1.78-1.38-1.78-.2 0-.41.04-.66.1a2.11 2.11 0 0 0-.56.25v.97c.34-.3.71-.44 1.1-.44.38 0 .57.23.57.68l-.88.16c-.74.12-1.11.59-1.11 1.4 0 .38.09.7.27.92a.9.9 0 0 0 .74.35c.42 0 .74-.24.96-.7h.01zm0-1.98v.28a1.1 1.1 0 0 1-.17.64.54.54 0 0 1-.46.25.4.4 0 0 1-.32-.14.56.56 0 0 1-.11-.36c0-.33.16-.51.48-.57l.59-.1zM9.82 19.21h-.94v-.6h-.02c-.21.46-.53.7-.96.7a.9.9 0 0 1-.74-.35 1.47 1.47 0 0 1-.27-.92c0-.8.38-1.28 1.12-1.4l.87-.15c0-.46-.19-.69-.57-.69-.38 0-.75.15-1.1.45v-.98c.14-.09.33-.17.57-.24.24-.07.46-.1.66-.1.92 0 1.38.59 1.38 1.78zm-.94-1.7v-.29l-.58.1c-.33.06-.49.25-.49.57 0 .15.04.27.12.36a.4.4 0 0 0 .32.14.54.54 0 0 0 .46-.25c.11-.17.17-.38.17-.63zm4.24 1.8c.47 0 .83-.09 1.08-.26v-1.03a1.32 1.32 0 0 1-.8.3.9.9 0 0 1-.74-.31c-.17-.22-.26-.5-.26-.88s.1-.68.28-.9a.94.94 0 0 1 .75-.32c.28 0 .54.1.77.3v-1.1c-.19-.12-.5-.19-.91-.19-.61 0-1.1.2-1.47.62-.36.4-.54.97-.54 1.68 0 .61.17 1.11.5 1.5.35.4.8.59 1.34.59zM2.5 13.46 3.96 12h13.16l1.46 1.46v7.3l-1.46 1.47H3.96L2.5 20.77Zm1.46 0v7.3h13.16v-7.3Zm4.39-2.92L9.8 9.08h10.23l1.46 1.46v7.3l-1.46 1.47v-8.77z",
replace:
"M21 4.5000005V14.25a1.5000007 1.5000005 0 0 1-1.500007 1.500005h-8.999996v1.49999a.74999993.74999995 0 0 1-.459373.693747.79687482.79687478 0 0 1-.290624.056263.77812509.77812509 0 0 1-.534375-.215621l-2.25-2.25a.759375.759375 0 0 1 0-1.068763l2.25-2.25a.7875.7875 0 0 1 .824999-.159371.74999993.74999995 0 0 1 .459373.693745V14.25h8.999996V4.5000005H9.0000007v.7499997a.75000036.75000039 0 0 1-1.5000007 0v-.7499997A1.5000007 1.5000005 0 0 1 9.0000007 3H19.499993A1.5000007 1.5000005 0 0 1 21 4.5000005ZM15.750007 18.000005a.74999993.74999995 0 0 0-.750014.749995v.749995H4.5000007V9.7500002h9.0000063v1.5000048a.759375.759375 0 0 0 .459381.693745.79687482.79687478 0 0 0 .290612.05631.77812509.77812509 0 0 0 .534372-.215621l2.25-2.2500079a.759375.759375 0 0 0 0-1.06875l-2.25-2.25a.76875023.76875019 0 0 0-.824984-.1594227.74999993.74999995 0 0 0-.459381.6937502v1.4999978H4.5000007A1.5000007 1.5000005 0 0 0 3 9.7500002v9.7499948A1.5000007 1.5000005 0 0 0 4.5000007 21H14.999993A1.5000007 1.5000005 0 0 0 16.5 19.499995V18.75a.74999993.74999995 0 0 0-.749993-.749995z",
+ attachmentSettings:
+ "m24.0138 20.223188-1.07-.82c.02-.17.04-.33.04-.5 0-.17-.01-.33-.04-.5l1.06-.82c.09258-.07939.117526-.212463.06-.32l-1-1.73c-.06-.13-.19-.13-.33-.13l-1.22.5c-.28-.18-.54-.35-.85-.47l-.19-1.32c-.01-.12-.12-.21-.24-.21h-2c-.12 0-.23.09-.25.21l-.19 1.32c-.3.13-.59.29-.85.47l-1.24-.5c-.11 0-.24 0-.31.13l-1 1.73c-.06.11-.04.24.06.32l1.06.82c-.03989.33214-.03989.66786 0 1l-1.06.82c-.09258.07939-.117526.212463-.06.32l1 1.73c.06.13.19.13.31.13l1.24-.5c.26.18.54.35.85.47l.19 1.32c.02.12.12.21.25.21h2c.12 0 .23-.09.25-.21l.19-1.32c.3-.13.56-.29.84-.47l1.22.5c.14 0 .27 0 .34-.13l1-1.73c.05753-.107537.03258-.240606-.06-.32m-4.78.18c-.83 0-1.5-.67-1.5-1.5s.68-1.5 1.5-1.5 1.5.67 1.5 1.5-.66 1.5-1.5 1.5zM16.61 13.5c-.8.35-1.5.86-2.07 1.5H9.5c-3.3333319 0-3.3333319-5 0-5H17v1.5H9.5c-.55 0-1 .45-1 1s.45 1 1 1h7.11m-13.11-1c0-2.21 1.79-4 4-4H18c2.434718-.00632 3.435847 3.121347 1.45 4.53.6.04 1.18.17 1.72.38.52-.67.83-1.5.83-2.41 0-2.21-1.79-4-4-4H7.5C4.46 7 2 9.46 2 12.5S4.46 18 7.5 18h5.59c.09-.53.25-1.03.46-1.5H7.5c-2.21 0-4-1.79-4-4",
caseSensitive: mdiFormatLetterCase,
wholeWord: mdiFormatLetterMatches,
regex: mdiRegex,
embed: mdiMoviePlusOutline,
+ embedSettings: mdiMovieCogOutline,
palette: mdiPaletteOutline,
tableSettings: mdiTableCog,
diff --git a/packages/editor/src/toolbar/popups/embed-popup.tsx b/packages/editor/src/toolbar/popups/embed-popup.tsx
index e9eff0431..802af360d 100644
--- a/packages/editor/src/toolbar/popups/embed-popup.tsx
+++ b/packages/editor/src/toolbar/popups/embed-popup.tsx
@@ -4,6 +4,7 @@ import { Popup } from "../components/popup";
import { Toggle } from "../../components/toggle";
import { Input, Textarea } from "@rebass/forms";
import {
+ Embed,
EmbedAlignmentOptions,
EmbedAttributes,
EmbedSizeOptions,
@@ -14,7 +15,6 @@ import { convertUrlToEmbedUrl } from "@social-embed/lib";
import { InlineInput } from "../../components/inline-input";
import { Tabs, Tab } from "../../components/tabs";
-type Embed = Required<EmbedAttributes> & EmbedAlignmentOptions;
type EmbedSource = "url" | "code";
export type EmbedPopupProps = {
onClose: (embed?: Embed) => void;
diff --git a/packages/editor/src/toolbar/tool-definitions.ts b/packages/editor/src/toolbar/tool-definitions.ts
index 43c9984d2..25220ecd1 100644
--- a/packages/editor/src/toolbar/tool-definitions.ts
+++ b/packages/editor/src/toolbar/tool-definitions.ts
@@ -226,6 +226,46 @@ const tools: Record<ToolId, ToolDefinition> = {
title: "Image properties",
conditional: true,
},
+ attachmentSettings: {
+ icon: "attachmentSettings",
+ title: "Attachment settings",
+ conditional: true,
+ },
+ downloadAttachment: {
+ icon: "download",
+ title: "Download attachment",
+ conditional: true,
+ },
+ removeAttachment: {
+ icon: "delete",
+ title: "Remove attachment",
+ conditional: true,
+ },
+ embedSettings: {
+ icon: "embedSettings",
+ title: "Embed settings",
+ conditional: true,
+ },
+ embedAlignCenter: {
+ icon: "alignCenter",
+ title: "Align center",
+ conditional: true,
+ },
+ embedAlignLeft: {
+ icon: "alignLeft",
+ title: "Align left",
+ conditional: true,
+ },
+ embedAlignRight: {
+ icon: "alignRight",
+ title: "Align right",
+ conditional: true,
+ },
+ embedProperties: {
+ icon: "more",
+ title: "Embed properties",
+ conditional: true,
+ },
};
export function getToolDefinition(id: ToolId) {
diff --git a/packages/editor/src/toolbar/tools/attachment.tsx b/packages/editor/src/toolbar/tools/attachment.tsx
new file mode 100644
index 000000000..7abae7359
--- /dev/null
+++ b/packages/editor/src/toolbar/tools/attachment.tsx
@@ -0,0 +1,48 @@
+import { ToolProps } from "../types";
+import { ToolButton } from "../components/tool-button";
+import { MoreTools } from "../components/more-tools";
+import { useToolbarLocation } from "../stores/toolbar-store";
+import { findSelectedNode } from "../utils/prosemirror";
+import { Attachment } from "../../extensions/attachment";
+
+export function AttachmentSettings(props: ToolProps) {
+ const { editor } = props;
+ const isBottom = useToolbarLocation() === "bottom";
+ if (!editor.isActive("attachment") || !isBottom) return null;
+
+ return (
+ <MoreTools
+ {...props}
+ autoCloseOnUnmount
+ popupId="attachmentSettings"
+ tools={[]}
+ />
+ );
+}
+
+export function DownloadAttachment(props: ToolProps) {
+ const { editor } = props;
+
+ return (
+ <ToolButton
+ {...props}
+ toggled={false}
+ onClick={() => {
+ const attachmentNode = findSelectedNode(editor, "attachment");
+ const attachment = (attachmentNode?.attrs || {}) as Attachment;
+ editor?.chain().focus().downloadAttachment(attachment).run();
+ }}
+ />
+ );
+}
+
+export function RemoveAttachment(props: ToolProps) {
+ const { editor } = props;
+ return (
+ <ToolButton
+ {...props}
+ toggled={false}
+ onClick={() => editor?.chain().focus().removeAttachment().run()}
+ />
+ );
+}
diff --git a/packages/editor/src/toolbar/tools/embed.tsx b/packages/editor/src/toolbar/tools/embed.tsx
new file mode 100644
index 000000000..274fd5082
--- /dev/null
+++ b/packages/editor/src/toolbar/tools/embed.tsx
@@ -0,0 +1,115 @@
+import { ToolProps } from "../types";
+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";
+import { findSelectedNode } from "../utils/prosemirror";
+import { Embed } from "../../extensions/embed";
+import { EmbedPopup } from "../popups/embed-popup";
+
+export function EmbedSettings(props: ToolProps) {
+ const { editor } = props;
+ const isBottom = useToolbarLocation() === "bottom";
+ if (!editor.isActive("embed") || !isBottom) return null;
+
+ return (
+ <MoreTools
+ {...props}
+ autoCloseOnUnmount
+ popupId="embedSettings"
+ tools={[]}
+ />
+ );
+}
+
+export function EmbedAlignLeft(props: ToolProps) {
+ const { editor } = props;
+ return (
+ <ToolButton
+ {...props}
+ toggled={false}
+ onClick={() =>
+ editor.chain().focus().setEmbedAlignment({ align: "left" }).run()
+ }
+ />
+ );
+}
+
+export function EmbedAlignRight(props: ToolProps) {
+ const { editor } = props;
+ return (
+ <ToolButton
+ {...props}
+ toggled={false}
+ onClick={() =>
+ editor.chain().focus().setEmbedAlignment({ align: "right" }).run()
+ }
+ />
+ );
+}
+
+export function EmbedAlignCenter(props: ToolProps) {
+ const { editor } = props;
+ return (
+ <ToolButton
+ {...props}
+ toggled={false}
+ onClick={() =>
+ editor.chain().focus().setEmbedAlignment({ align: "center" }).run()
+ }
+ />
+ );
+}
+
+export function EmbedProperties(props: ToolProps) {
+ const { editor } = props;
+ const [isOpen, setIsOpen] = useState(false);
+ const buttonRef = useRef<HTMLButtonElement>();
+
+ const embedNode = useMemo(() => findSelectedNode(editor, "embed"), []);
+ const embed = (embedNode?.attrs || {}) as Embed;
+
+ return (
+ <>
+ <ToolButton
+ buttonRef={buttonRef}
+ toggled={isOpen}
+ {...props}
+ onClick={() => setIsOpen((s) => !s)}
+ />
+
+ <ResponsivePresenter
+ isOpen={isOpen}
+ desktop="menu"
+ mobile="sheet"
+ onClose={() => setIsOpen(false)}
+ blocking
+ focusOnRender={false}
+ position={{
+ target: buttonRef.current || "mouse",
+ align: "start",
+ location: "below",
+ yOffset: 10,
+ isTargetAbsolute: true,
+ }}
+ >
+ <Popup
+ title="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>
+ </ResponsivePresenter>
+ </>
+ );
+}
diff --git a/packages/editor/src/toolbar/tools/index.ts b/packages/editor/src/toolbar/tools/index.ts
index 41b599dec..31d38882c 100644
--- a/packages/editor/src/toolbar/tools/index.ts
+++ b/packages/editor/src/toolbar/tools/index.ts
@@ -48,6 +48,18 @@ import {
ImageAlignRight,
ImageProperties,
} from "./image";
+import {
+ AttachmentSettings,
+ DownloadAttachment,
+ RemoveAttachment,
+} from "./attachment";
+import {
+ EmbedAlignCenter,
+ EmbedAlignLeft,
+ EmbedAlignRight,
+ EmbedProperties,
+ EmbedSettings,
+} from "./embed";
export type ToolId = keyof typeof tools;
const tools = {
@@ -81,6 +93,16 @@ const tools = {
imageAlignRight: ImageAlignRight,
imageProperties: ImageProperties,
+ embedAlignCenter: EmbedAlignCenter,
+ embedAlignLeft: EmbedAlignLeft,
+ embedAlignRight: EmbedAlignRight,
+ embedProperties: EmbedProperties,
+ embedSettings: EmbedSettings,
+
+ attachmentSettings: AttachmentSettings,
+ downloadAttachment: DownloadAttachment,
+ removeAttachment: RemoveAttachment,
+
tableSettings: TableSettings,
columnProperties: ColumnProperties,
rowProperties: RowProperties,