Skip to content

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

chore: remove dist folder

thecodrra6835cc76c67
diff --git a/packages/editor/.gitignore b/packages/editor/.gitignore
index 73334cba3..af7bbe5ac 100644
--- a/packages/editor/.gitignore
+++ b/packages/editor/.gitignore
@@ -1,2 +1,3 @@
node_modules/
-*.tsbuildinfo
\ No newline at end of file
+*.tsbuildinfo
+dist
\ No newline at end of file
diff --git a/packages/editor/dist/cjs/components/actionsheet/index.d.ts b/packages/editor/dist/cjs/components/actionsheet/index.d.ts
deleted file mode 100644
index b3a00090c..000000000
--- a/packages/editor/dist/cjs/components/actionsheet/index.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { PropsWithChildren } from "react";
-import { MenuItem } from "../menu/types";
-export declare type ActionSheetPresenterProps = {
- items?: MenuItem[];
- isOpen: boolean;
- onClose?: () => void;
- blocking?: boolean;
- focusOnRender?: boolean;
- draggable?: boolean;
- title?: string;
-};
-export declare function ActionSheetPresenter(props: PropsWithChildren<ActionSheetPresenterProps>): JSX.Element | null;
diff --git a/packages/editor/dist/cjs/components/actionsheet/index.js b/packages/editor/dist/cjs/components/actionsheet/index.js
deleted file mode 100644
index 24a41ebf5..000000000
--- a/packages/editor/dist/cjs/components/actionsheet/index.js
+++ /dev/null
@@ -1,206 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ActionSheetPresenter = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importStar(require("react"));
-const rebass_1 = require("rebass");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const menubutton_1 = require("../menu/menubutton");
-const menuseparator_1 = require("../menu/menuseparator");
-const react_modal_1 = __importDefault(require("react-modal"));
-const framer_motion_1 = require("framer-motion");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-const AnimatedFlex = (0, framer_motion_1.motion)(rebass_1.Flex);
-const TRANSITION = {
- type: "spring",
- stiffness: 300,
- damping: 30,
- mass: 0.2,
- duration: 300,
-};
-function useHistory(initial) {
- const [current, setCurrent] = (0, react_1.useState)(initial);
- const [canGoBack, setCanGoBack] = (0, react_1.useState)(false);
- const stack = (0, react_1.useRef)([initial]);
- const goBack = (0, react_1.useCallback)(() => {
- if (!canGoBack)
- return;
- const prev = stack.current.pop();
- setCurrent(prev);
- if (stack.current.length <= 1)
- setCanGoBack(false);
- }, [canGoBack]);
- const navigate = (0, react_1.useCallback)((state) => {
- console.log("NAVI", state);
- setCurrent((prev) => {
- if (prev)
- stack.current.push(prev);
- return state;
- });
- setCanGoBack(true);
- }, []);
- return { current, goBack, navigate, canGoBack };
-}
-function ActionSheetPresenter(props) {
- var _a;
- const { isOpen, title, items, onClose, blocking = true, focusOnRender = true, draggable = true, children, } = props;
- const theme = (0, toolbarstore_1.useTheme)();
- const contentRef = (0, react_1.useRef)();
- const y = (0, framer_motion_1.useMotionValue)(0);
- const opacity = (0, framer_motion_1.useTransform)(y, [0, ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || window.innerHeight], [1, 0]);
- const animation = (0, framer_motion_1.useAnimation)();
- const onBeforeClose = (0, react_1.useCallback)(() => {
- var _a;
- const height = ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || window.innerHeight;
- setTimeout(() => {
- onClose === null || onClose === void 0 ? void 0 : onClose();
- }, TRANSITION.duration - 50);
- animation.start({
- transition: TRANSITION,
- y: height + 100,
- });
- }, [animation, onClose, contentRef.current]);
- const handleBackPress = (0, react_1.useCallback)((event) => {
- if (!isOpen)
- return;
- event.preventDefault();
- onBeforeClose();
- }, [isOpen, onBeforeClose]);
- (0, react_1.useEffect)(() => {
- // Note: this is a custom event implemented on the React Native
- // side to handle back button when action sheet is opened.
- window.addEventListener("handleBackPress", handleBackPress);
- return () => {
- window.removeEventListener("handleBackPress", handleBackPress);
- };
- }, [handleBackPress]);
- if (!isOpen)
- return null;
- return ((0, jsx_runtime_1.jsx)(react_modal_1.default, Object.assign({ contentRef: (ref) => (contentRef.current = ref), className: "bottom-sheet-presenter", role: "menu", isOpen: isOpen, appElement: document.body, shouldCloseOnEsc: blocking, shouldReturnFocusAfterClose: focusOnRender, shouldCloseOnOverlayClick: blocking, shouldFocusAfterRender: focusOnRender, ariaHideApp: blocking, preventScroll: blocking, onRequestClose: () => onBeforeClose(), portalClassName: "bottom-sheet-presenter-portal", onAfterOpen: () => {
- console.log("OPEGN!");
- animation.start({ transition: TRANSITION, y: 0 });
- }, overlayElement: (props, contentEl) => {
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Box, Object.assign({}, props, {
- //@ts-ignore
- style: Object.assign(Object.assign({}, props.style), { position: blocking ? "fixed" : "sticky", zIndex: 1000, backgroundColor: !blocking ? "transparent" : "unset" }), tabIndex: -1 }, { children: [blocking && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { id: "action-sheet-overlay", style: {
- height: "100%",
- width: "100%",
- opacity,
- position: "absolute",
- backgroundColor: "var(--overlay)",
- }, tabIndex: -1 })), contentEl] })));
- }, contentElement: (props, children) => ((0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({}, props, { style: {}, sx: {
- // top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- display: "flex",
- width: "auto",
- height: "fit-content",
- position: "fixed",
- backgroundColor: undefined,
- padding: 0,
- zIndex: 0,
- outline: 0,
- isolation: "isolate",
- } }, { children: children }))) }, { children: (0, jsx_runtime_1.jsxs)(AnimatedFlex, Object.assign({ animate: animation, style: { y }, initial: { y: 1000 }, sx: {
- bg: "background",
- borderTopLeftRadius: 15,
- borderTopRightRadius: 15,
- boxShadow: (theme === null || theme === void 0 ? void 0 : theme.shadows.menu) || "none",
- flex: 1,
- flexDirection: "column",
- } }, { children: [draggable && ((0, jsx_runtime_1.jsx)(AnimatedFlex, Object.assign({ drag: "y",
- // @ts-ignore
- onDrag: (_, { delta }) => {
- y.set(Math.max(y.get() + delta.y, 0));
- },
- // @ts-ignore
- onDragEnd: (_, { velocity }) => {
- if (velocity.y >= 500) {
- onClose === null || onClose === void 0 ? void 0 : onClose();
- return;
- }
- const sheetEl = contentRef.current;
- const contentHeight = sheetEl.offsetHeight;
- const threshold = 30;
- const closingHeight = (contentHeight * threshold) / 100;
- if (y.get() >= closingHeight) {
- onBeforeClose();
- }
- else {
- animation.start({ transition: TRANSITION, y: 0 });
- }
- }, dragConstraints: { top: 0, bottom: 0 }, dragMomentum: false, dragElastic: false, sx: {
- bg: "transparent",
- alignItems: "center",
- justifyContent: "center",
- p: 2,
- } }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Box, { id: "pill", sx: {
- backgroundColor: "hover",
- width: 60,
- height: 8,
- borderRadius: 100,
- } }) }))), (0, jsx_runtime_1.jsx)(ContentContainer, Object.assign({ items: items, title: title, onClose: onClose }, { children: children }))] })) })));
-}
-exports.ActionSheetPresenter = ActionSheetPresenter;
-function ContentContainer(props) {
- var _a;
- const { title, items, onClose, children } = props;
- const { current, goBack, canGoBack, navigate } = useHistory({
- title,
- items,
- });
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { flexDirection: "column" } }, { children: [canGoBack || (current === null || current === void 0 ? void 0 : current.title) ? ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ id: "header", sx: { alignItems: "center", mx: 0, mb: 1 } }, { children: [canGoBack && ((0, jsx_runtime_1.jsx)(rebass_1.Button, Object.assign({ variant: "icon", sx: { p: 1, ml: 1 }, onClick: goBack }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.arrowLeft, size: "big" }) }))), (current === null || current === void 0 ? void 0 : current.title) && ((0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "title", sx: { ml: 1, fontSize: "title" } }, { children: current === null || current === void 0 ? void 0 : current.title })))] }))) : null, children
- ? children
- : (_a = current === null || current === void 0 ? void 0 : current.items) === null || _a === void 0 ? void 0 : _a.map((item) => {
- if (item.isHidden)
- return null;
- switch (item.type) {
- case "separator":
- return (0, jsx_runtime_1.jsx)(menuseparator_1.MenuSeparator, {}, item.key);
- case "button":
- return ((0, jsx_runtime_1.jsx)(menubutton_1.MenuButton, { item: item, onClick: (e) => {
- if (item.menu) {
- navigate(item.menu);
- }
- else if (item.onClick) {
- onClose === null || onClose === void 0 ? void 0 : onClose();
- setTimeout(() => {
- var _a;
- (_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item);
- }, 300);
- }
- } }, item.key));
- case "popup":
- return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(item.component, { onClick: onClose }) }, item.key));
- }
- })] })));
-}
diff --git a/packages/editor/dist/cjs/components/button.d.ts b/packages/editor/dist/cjs/components/button.d.ts
deleted file mode 100644
index 33c39b124..000000000
--- a/packages/editor/dist/cjs/components/button.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ButtonProps } from "rebass";
-export declare const Button: import("react").ForwardRefExoticComponent<Pick<ButtonProps, "name" | "onFocus" | "onBlur" | "fontSize" | "style" | "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" | "value" | "children" | "cite" | "data" | "form" | "label" | "p" | "slot" | "span" | "summary" | "title" | "pattern" | "key" | "selected" | "sizes" | "variant" | "tx" | "as" | "css" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "paddingX" | "py" | "paddingY" | "size" | "bg" | "sx" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "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" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "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>>;
diff --git a/packages/editor/dist/cjs/components/button.js b/packages/editor/dist/cjs/components/button.js
deleted file mode 100644
index 4c40a0a92..000000000
--- a/packages/editor/dist/cjs/components/button.js
+++ /dev/null
@@ -1,49 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Button = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const react_2 = require("react");
-const rebass_1 = require("rebass");
-exports.Button = (0, react_1.forwardRef)((props, forwardedRef) => {
- var _a;
- const { sx } = props, buttonProps = __rest(props, ["sx"]);
- const hoverBg = ((_a = sx === null || sx === void 0 ? void 0 : sx[":hover"]) === null || _a === void 0 ? void 0 : _a["bg"]) || "hover";
- const bg = (sx === null || sx === void 0 ? void 0 : sx["bg"]) || "unset";
- const buttonRef = (0, react_1.useRef)();
- (0, react_2.useEffect)(() => {
- if (!buttonRef.current)
- return;
- buttonRef.current.addEventListener("mousedown", onMouseDown, {
- passive: false,
- capture: true,
- });
- return () => {
- var _a;
- (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("mousedown", onMouseDown, {
- capture: true,
- });
- };
- }, []);
- const onMouseDown = (0, react_1.useCallback)((e) => {
- e.preventDefault();
- }, []);
- return ((0, jsx_runtime_1.jsx)(rebass_1.Button, Object.assign({}, buttonProps, { sx: Object.assign(Object.assign({}, sx), { ":hover": { bg: [bg, hoverBg] }, ":active": { bg: hoverBg } }), ref: (ref) => {
- buttonRef.current = ref;
- if (typeof forwardedRef === "function")
- forwardedRef(ref);
- else if (forwardedRef)
- forwardedRef.current = ref;
- }, onClick: props.onClick })));
-});
diff --git a/packages/editor/dist/cjs/components/inlineinput/index.d.ts b/packages/editor/dist/cjs/components/inlineinput/index.d.ts
deleted file mode 100644
index d9936bb07..000000000
--- a/packages/editor/dist/cjs/components/inlineinput/index.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/// <reference types="react" />
-import { InputProps } from "@rebass/forms";
-import { FlexProps } from "rebass";
-declare type LabelInputProps = InputProps & {
- label: string;
- containerProps?: FlexProps;
-};
-export declare function InlineInput(props: LabelInputProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/components/inlineinput/index.js b/packages/editor/dist/cjs/components/inlineinput/index.js
deleted file mode 100644
index 75a2f2e30..000000000
--- a/packages/editor/dist/cjs/components/inlineinput/index.js
+++ /dev/null
@@ -1,30 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.InlineInput = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const forms_1 = require("@rebass/forms");
-const rebass_1 = require("rebass");
-function InlineInput(props) {
- const { label, containerProps, sx } = props, inputProps = __rest(props, ["label", "containerProps", "sx"]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({}, containerProps, { sx: Object.assign(Object.assign({ flex: 1 }, containerProps === null || containerProps === void 0 ? void 0 : containerProps.sx), { outline: "1px solid var(--border)", p: 2, borderRadius: "default", ":focus-within": {
- outlineColor: "primary",
- outlineWidth: "1.8px",
- } }) }, { children: [(0, jsx_runtime_1.jsx)(forms_1.Input, Object.assign({ variant: "clean", sx: Object.assign(Object.assign({}, sx), { p: 0 }) }, inputProps)), (0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "body", sx: {
- flexShrink: 0,
- color: "fontTertiary",
- borderLeft: "1px solid var(--border)",
- pl: 1,
- } }, { children: label }))] })));
-}
-exports.InlineInput = InlineInput;
diff --git a/packages/editor/dist/cjs/components/menu/index.d.ts b/packages/editor/dist/cjs/components/menu/index.d.ts
deleted file mode 100644
index 70086f947..000000000
--- a/packages/editor/dist/cjs/components/menu/index.d.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { PropsWithChildren } from "react";
-import { FlexProps } from "rebass";
-import { MenuItem as MenuItemType } from "./types";
-import { PopupPresenterProps } from "../popup-presenter";
-declare type MenuProps = MenuContainerProps & {
- items?: MenuItemType[];
- onClose: () => void;
-};
-export declare function Menu(props: MenuProps): JSX.Element;
-declare type MenuContainerProps = FlexProps & {
- title?: string;
-};
-export declare type MenuPresenterProps = PopupPresenterProps & MenuProps;
-export declare function MenuPresenter(props: PropsWithChildren<MenuPresenterProps>): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/components/menu/index.js b/packages/editor/dist/cjs/components/menu/index.js
deleted file mode 100644
index 69ee647a5..000000000
--- a/packages/editor/dist/cjs/components/menu/index.js
+++ /dev/null
@@ -1,118 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MenuPresenter = exports.Menu = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const position_1 = require("../../utils/position");
-const usefocus_1 = require("./usefocus");
-const menuseparator_1 = require("./menuseparator");
-const menubutton_1 = require("./menubutton");
-const popuppresenter_1 = require("../popuppresenter");
-function Menu(props) {
- const { items = [], title, onClose } = props, containerProps = __rest(props, ["items", "title", "onClose"]);
- const hoverTimeout = (0, react_1.useRef)();
- const onAction = (0, react_1.useCallback)((e, item) => {
- e === null || e === void 0 ? void 0 : e.stopPropagation();
- if (item === null || item === void 0 ? void 0 : item.onClick) {
- item.onClick();
- }
- if (onClose)
- onClose();
- }, [onClose]);
- const { focusIndex, setFocusIndex, isSubmenuOpen, setIsSubmenuOpen } = (0, usefocus_1.useFocus)(items, (e) => {
- const item = items[focusIndex];
- if (item && item.type === "button")
- onAction(e, item);
- }, () => onClose());
- const focusedItem = items[focusIndex];
- const subMenuRef = (0, react_1.useRef)(null);
- (0, react_1.useEffect)(() => {
- const item = items[focusIndex];
- if (!item || !subMenuRef.current)
- return;
- const menuItemElement = document.getElementById(item.key);
- if (!menuItemElement)
- return;
- if (!isSubmenuOpen) {
- subMenuRef.current.style.visibility = "hidden";
- return;
- }
- const { top, left } = (0, position_1.getPosition)(subMenuRef.current, {
- // yOffset: menuItemElement.offsetHeight,
- target: menuItemElement,
- location: "right",
- });
- subMenuRef.current.style.visibility = "visible";
- subMenuRef.current.style.top = `${top}px`;
- subMenuRef.current.style.left = `${left}px`;
- }, [isSubmenuOpen, focusIndex, items]);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(MenuContainer, Object.assign({}, containerProps, { children: items.map((item, index) => {
- if (item.isHidden)
- return null;
- switch (item.type) {
- case "separator":
- return (0, jsx_runtime_1.jsx)(menuseparator_1.MenuSeparator, {}, item.key);
- case "button":
- return ((0, jsx_runtime_1.jsx)(menubutton_1.MenuButton, { item: item, onClick: (e) => {
- if (item.menu) {
- setFocusIndex(index);
- setIsSubmenuOpen(true);
- }
- else
- onAction(e, item);
- }, isFocused: focusIndex === index, onMouseEnter: () => {
- if (item.isDisabled) {
- setFocusIndex(-1);
- return;
- }
- if (hoverTimeout.current)
- clearTimeout(hoverTimeout.current);
- setFocusIndex(index);
- setIsSubmenuOpen(false);
- if (item.menu) {
- hoverTimeout.current = setTimeout(() => {
- setIsSubmenuOpen(true);
- }, 500);
- }
- }, onMouseLeave: () => {
- if (hoverTimeout.current)
- clearTimeout(hoverTimeout.current);
- } }, item.key));
- case "popup":
- return (0, jsx_runtime_1.jsx)(item.component, { onClick: (e) => onAction(e) });
- }
- }) })), (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.type) === "button" && (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.menu) && isSubmenuOpen && ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ ref: subMenuRef, style: { visibility: "hidden" }, sx: {
- position: "absolute",
- } }, { children: (0, jsx_runtime_1.jsx)(Menu, { items: focusedItem.menu.items, onClose: onClose }) })))] }));
-}
-exports.Menu = Menu;
-function MenuContainer(props) {
- const { children, title, sx } = props, flexProps = __rest(props, ["children", "title", "sx"]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Box, Object.assign({ className: "menuContainer", as: "ul", tabIndex: -1, sx: Object.assign({ bg: "background", py: 1, display: "flex", flexDirection: "column", position: "relative", listStyle: "none", padding: 0, margin: 0, borderRadius: "default", boxShadow: "menu", border: "1px solid var(--border)", minWidth: 220 }, sx) }, flexProps, { children: [title && ((0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ sx: {
- fontFamily: "body",
- fontSize: "subtitle",
- color: "primary",
- py: "8px",
- px: 3,
- borderBottom: "1px solid",
- borderBottomColor: "border",
- wordWrap: "break-word",
- } }, { children: title }))), children] })));
-}
-function MenuPresenter(props) {
- const { items = [] } = props, restProps = __rest(props, ["items"]);
- return ((0, jsx_runtime_1.jsx)(popuppresenter_1.PopupPresenter, Object.assign({}, restProps, { children: props.children ? props.children : (0, jsx_runtime_1.jsx)(Menu, Object.assign({ items: items }, restProps)) })));
-}
-exports.MenuPresenter = MenuPresenter;
diff --git a/packages/editor/dist/cjs/components/menu/menubutton.d.ts b/packages/editor/dist/cjs/components/menu/menubutton.d.ts
deleted file mode 100644
index 11b6437af..000000000
--- a/packages/editor/dist/cjs/components/menu/menubutton.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/// <reference types="react" />
-import { MenuButton } from "./types";
-declare type MenuButtonProps = {
- item: MenuButton;
- isFocused?: boolean;
- onMouseEnter?: () => void;
- onMouseLeave?: () => void;
- onClick: (e?: any) => void;
-};
-export declare function MenuButton(props: MenuButtonProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/components/menu/menubutton.js b/packages/editor/dist/cjs/components/menu/menubutton.js
deleted file mode 100644
index 7e1361688..000000000
--- a/packages/editor/dist/cjs/components/menu/menubutton.js
+++ /dev/null
@@ -1,25 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MenuButton = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-const button_1 = require("../button");
-function MenuButton(props) {
- const { item, isFocused, onMouseEnter, onMouseLeave, onClick } = props;
- const { title, key, icon, tooltip, isDisabled, isChecked, menu, modifier, styles, } = item;
- const itemRef = (0, react_1.useRef)(null);
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- const isBottom = toolbarLocation === "bottom";
- return ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ as: "li", sx: { flexShrink: 0, flexDirection: "column" }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, { children: (0, jsx_runtime_1.jsxs)(button_1.Button, Object.assign({ id: key, "data-test-id": `MenuButton-${key}`, ref: itemRef, tabIndex: -1, variant: "menuitem", title: tooltip, disabled: isDisabled, onClick: onClick, sx: Object.assign(Object.assign({}, styles), { bg: isFocused && !isBottom ? "hover" : "transparent", display: "flex", alignItems: "center", justifyContent: "space-between", ":hover": {
- bg: isBottom ? "transparent" : "hover",
- } }) }, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { fontSize: "inherit", fontFamily: "inherit" } }, { children: [icon && ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons[icon], color: "text", size: "medium", sx: { mr: 2 } })), (0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ as: "span", variant: "body", sx: { fontSize: "inherit", fontFamily: "inherit" } }, { children: title }))] })), isChecked || menu || modifier ? ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { ml: 4 } }, { children: [isChecked && (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.check, size: "small" }), menu && (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.chevronRight, size: "small" }), modifier && ((0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ as: "span", sx: {
- fontFamily: "body",
- fontSize: "menu",
- color: "fontTertiary",
- } }, { children: modifier })))] }))) : null] }), key) })));
-}
-exports.MenuButton = MenuButton;
diff --git a/packages/editor/dist/cjs/components/menu/menuseparator.d.ts b/packages/editor/dist/cjs/components/menu/menuseparator.d.ts
deleted file mode 100644
index 14ee7a7d6..000000000
--- a/packages/editor/dist/cjs/components/menu/menuseparator.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-/// <reference types="react" />
-export declare function MenuSeparator(): JSX.Element;
diff --git a/packages/editor/dist/cjs/components/menu/menuseparator.js b/packages/editor/dist/cjs/components/menu/menuseparator.js
deleted file mode 100644
index 420897f28..000000000
--- a/packages/editor/dist/cjs/components/menu/menuseparator.js
+++ /dev/null
@@ -1,15 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MenuSeparator = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-function MenuSeparator() {
- return ((0, jsx_runtime_1.jsx)(rebass_1.Box, { as: "li", sx: {
- width: "95%",
- height: "0.5px",
- bg: "border",
- my: 2,
- alignSelf: "center",
- } }));
-}
-exports.MenuSeparator = MenuSeparator;
diff --git a/packages/editor/dist/cjs/components/menu/types.d.ts b/packages/editor/dist/cjs/components/menu/types.d.ts
deleted file mode 100644
index c99c27c95..000000000
--- a/packages/editor/dist/cjs/components/menu/types.d.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/// <reference types="react" />
-import { SxStyleProp } from "rebass";
-import { IconNames } from "../../toolbar/icons";
-declare type MenuItemComponentProps = {
- onClick?: (e?: any) => void;
-};
-export declare type MenuItemTypes = "button" | "separator" | "popup";
-export declare type BaseMenuItem<TType extends MenuItemTypes> = {
- type: TType;
- key: string;
- isHidden?: boolean;
-};
-export declare type MenuSeperator = BaseMenuItem<"separator">;
-export declare type MenuPopup = BaseMenuItem<"popup"> & {
- component: (props: MenuItemComponentProps) => JSX.Element;
-};
-export declare type MenuButton = BaseMenuItem<"button"> & {
- onClick?: () => void;
- title: string;
- icon?: IconNames;
- tooltip?: string;
- isDisabled?: boolean;
- isChecked?: boolean;
- modifier?: string;
- menu?: {
- title: string;
- items: MenuItem[];
- };
- styles?: SxStyleProp;
-};
-export declare type MenuItem = MenuButton | MenuSeperator | MenuPopup;
-export {};
diff --git a/packages/editor/dist/cjs/components/menu/types.js b/packages/editor/dist/cjs/components/menu/types.js
deleted file mode 100644
index c8ad2e549..000000000
--- a/packages/editor/dist/cjs/components/menu/types.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/packages/editor/dist/cjs/components/menu/usefocus.d.ts b/packages/editor/dist/cjs/components/menu/usefocus.d.ts
deleted file mode 100644
index 36b4ee2ca..000000000
--- a/packages/editor/dist/cjs/components/menu/usefocus.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/// <reference types="react" />
-import { MenuItem } from "./types";
-export declare function useFocus(items: MenuItem[], onAction: (event: KeyboardEvent) => void, onClose: (event: KeyboardEvent) => void): {
- focusIndex: number;
- setFocusIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
- isSubmenuOpen: boolean;
- setIsSubmenuOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
-};
diff --git a/packages/editor/dist/cjs/components/menu/usefocus.js b/packages/editor/dist/cjs/components/menu/usefocus.js
deleted file mode 100644
index cbc30ce35..000000000
--- a/packages/editor/dist/cjs/components/menu/usefocus.js
+++ /dev/null
@@ -1,86 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.useFocus = void 0;
-const react_1 = require("react");
-function useFocus(items, onAction, onClose) {
- const [focusIndex, setFocusIndex] = (0, react_1.useState)(-1);
- const [isSubmenuOpen, setIsSubmenuOpen] = (0, react_1.useState)(false);
- const moveItemIntoView = (0, react_1.useCallback)((index) => {
- const item = items[index];
- if (!item)
- return;
- const element = document.getElementById(item.key);
- if (!element)
- return;
- element.scrollIntoView({
- behavior: "auto",
- });
- }, [items]);
- const onKeyDown = (0, react_1.useCallback)((e) => {
- const as = (i) => items[i];
- const isSeperator = (i) => {
- var _a, _b;
- return items &&
- (((_a = items[i]) === null || _a === void 0 ? void 0 : _a.type) === "separator" || ((_b = as(i)) === null || _b === void 0 ? void 0 : _b.isDisabled));
- };
- const moveDown = (i) => (i < items.length - 1 ? ++i : 0);
- const moveUp = (i) => (i > 0 ? --i : items.length - 1);
- const hasSubmenu = (i) => items && as(i).menu;
- const openSubmenu = (index) => {
- if (!hasSubmenu(index))
- return;
- setIsSubmenuOpen(true);
- };
- const closeSubmenu = (index) => {
- if (!hasSubmenu(index))
- return;
- setIsSubmenuOpen(false);
- };
- setFocusIndex((i) => {
- let nextIndex = i;
- switch (e.key) {
- case "ArrowUp":
- if (isSubmenuOpen)
- break;
- nextIndex = moveUp(i);
- while (isSeperator(nextIndex)) {
- nextIndex = moveUp(nextIndex);
- }
- break;
- case "ArrowDown":
- if (isSubmenuOpen)
- break;
- nextIndex = moveDown(i);
- while (isSeperator(nextIndex)) {
- nextIndex = moveDown(nextIndex);
- }
- break;
- case "ArrowRight":
- openSubmenu(i);
- break;
- case "ArrowLeft":
- closeSubmenu(i);
- break;
- case "Enter":
- onAction && onAction(e);
- break;
- case "Escape":
- onClose && onClose(e);
- break;
- default:
- break;
- }
- if (nextIndex !== i)
- moveItemIntoView(nextIndex);
- return nextIndex;
- });
- }, [items, isSubmenuOpen, moveItemIntoView, onAction]);
- (0, react_1.useEffect)(() => {
- window.addEventListener("keydown", onKeyDown);
- return () => {
- window.removeEventListener("keydown", onKeyDown);
- };
- }, [onKeyDown]);
- return { focusIndex, setFocusIndex, isSubmenuOpen, setIsSubmenuOpen };
-}
-exports.useFocus = useFocus;
diff --git a/packages/editor/dist/cjs/components/popuppresenter/index.d.ts b/packages/editor/dist/cjs/components/popuppresenter/index.d.ts
deleted file mode 100644
index bb3b88ac2..000000000
--- a/packages/editor/dist/cjs/components/popuppresenter/index.d.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { PropsWithChildren } from "react";
-import { PositionOptions } from "../../utils/position";
-import React from "react";
-import { ResponsivePresenterProps } from "../responsive";
-export declare type PopupPresenterProps = {
- isOpen: boolean;
- onClose: () => void;
- position: PositionOptions;
- blocking?: boolean;
- focusOnRender?: boolean;
- movable?: boolean;
-};
-export declare function PopupPresenter(props: PropsWithChildren<PopupPresenterProps>): JSX.Element | null;
-export declare type PopupWrapperProps = UsePopupHandlerOptions & {
- autoCloseOnUnmount?: boolean;
- position: PositionOptions;
- renderPopup: (closePopup: () => void) => React.ReactNode;
-} & Partial<Omit<PopupPresenterProps, "onClose">>;
-export declare function PopupWrapper(props: PopupWrapperProps): null;
-declare type UsePopupHandlerOptions = {
- id: string;
- group: string;
- isOpen: boolean;
- onClosed?: () => void;
-};
-export declare function usePopupHandler(options: UsePopupHandlerOptions): {
- isPopupOpen: boolean;
- closePopup: (popupId: string) => void;
-};
-declare type ShowPopupOptions = {
- popup: (closePopup: () => void) => React.ReactNode;
-} & Partial<ResponsivePresenterProps>;
-export declare function showPopup(options: ShowPopupOptions): () => void;
-export {};
diff --git a/packages/editor/dist/cjs/components/popuppresenter/index.js b/packages/editor/dist/cjs/components/popuppresenter/index.js
deleted file mode 100644
index aa434637f..000000000
--- a/packages/editor/dist/cjs/components/popuppresenter/index.js
+++ /dev/null
@@ -1,237 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.showPopup = exports.usePopupHandler = exports.PopupWrapper = exports.PopupPresenter = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const position_1 = require("../../utils/position");
-const react_modal_1 = __importDefault(require("react-modal"));
-const react_dom_1 = __importDefault(require("react-dom"));
-const dom_1 = require("../../toolbar/utils/dom");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-const popuprenderer_1 = require("./popuprenderer");
-const responsive_1 = require("../responsive");
-const themeprovider_1 = require("../themeprovider");
-function _PopupPresenter(props) {
- const { isOpen, position, onClose, blocking = true, focusOnRender = true, children, } = props;
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const contentRef = (0, react_1.useRef)();
- const observerRef = (0, react_1.useRef)();
- const repositionPopup = (0, react_1.useCallback)(() => {
- if (!contentRef.current || !position)
- return;
- const popup = contentRef.current;
- const popupPosition = (0, position_1.getPosition)(popup, position);
- popup.style.top = popupPosition.top + "px";
- popup.style.left = popupPosition.left + "px";
- }, [position]);
- (0, react_1.useEffect)(() => {
- repositionPopup();
- }, [position]);
- (0, react_1.useEffect)(() => {
- function onWindowResize() {
- repositionPopup();
- }
- window.addEventListener("resize", onWindowResize);
- return () => {
- window.removeEventListener("resize", onWindowResize);
- };
- }, []);
- const attachMoveHandlers = (0, react_1.useCallback)(() => {
- if (!contentRef.current || !isOpen)
- return;
- const movableBar = contentRef.current.querySelector(".movable");
- if (!movableBar)
- return;
- const popup = contentRef.current;
- var offset = { x: 0, y: 0 };
- function mouseDown(e) {
- offset.x = e.clientX - popup.offsetLeft;
- offset.y = e.clientY - popup.offsetTop;
- window.addEventListener("mousemove", mouseMove);
- }
- function mouseMove(e) {
- if (!e.buttons)
- mouseUp();
- var top = e.clientY - offset.y;
- var left = e.clientX - offset.x;
- requestAnimationFrame(() => {
- popup.style.top = top + "px";
- popup.style.left = left + "px";
- });
- }
- function mouseUp() {
- window.removeEventListener("mousemove", mouseMove);
- }
- movableBar.addEventListener("mousedown", mouseDown);
- window.addEventListener("mouseup", mouseUp);
- }, [isOpen]);
- const handleResize = (0, react_1.useCallback)(() => {
- const popup = contentRef.current;
- if (!popup)
- return;
- let oldHeight = popup.offsetHeight;
- observerRef.current = new ResizeObserver((e) => {
- if (isMobile) {
- repositionPopup();
- }
- else {
- const { height, y } = popup.getBoundingClientRect();
- const delta = height - oldHeight;
- if (delta > 0) {
- // means the new size is bigger so we need to adjust the position
- // if required. We only do this in case the newly resized popup
- // is going out of the window.
- const windowHeight = document.body.clientHeight - 20;
- if (y + height > windowHeight) {
- popup.style.top = windowHeight - height + "px";
- }
- }
- oldHeight = height;
- }
- });
- observerRef.current.observe(popup, { box: "border-box" });
- }, [isMobile]);
- return ((0, jsx_runtime_1.jsx)(react_modal_1.default, Object.assign({ contentRef: (ref) => (contentRef.current = ref), className: "popup-presenter", role: "menu", isOpen: isOpen, appElement: document.body, shouldCloseOnEsc: true, shouldReturnFocusAfterClose: true, shouldCloseOnOverlayClick: true, shouldFocusAfterRender: focusOnRender, ariaHideApp: blocking, preventScroll: blocking, onRequestClose: onClose, portalClassName: "popup-presenter-portal", onAfterOpen: (obj) => {
- if (!obj || !position)
- return;
- repositionPopup();
- handleResize();
- attachMoveHandlers();
- }, onAfterClose: () => { var _a; return (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect(); }, overlayElement: (props, contentEl) => {
- return ((0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({}, props, {
- //@ts-ignore
- style: Object.assign(Object.assign({}, props.style), { position: !blocking ? "initial" : "fixed", zIndex: 1000, backgroundColor: !blocking ? "transparent" : "unset" }) }, { children: contentEl })));
- }, contentElement: (props, children) => ((0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({}, props, { style: {},
- // TODO onMouseDown={(e) => {
- // console.log(e);
- // }}
- sx: {
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- display: "flex",
- width: "fit-content",
- height: "fit-content",
- position: "fixed",
- backgroundColor: undefined,
- padding: 0,
- zIndex: 0,
- outline: 0,
- isolation: "isolate",
- } }, { children: children }))), style: {
- content: {},
- overlay: {
- zIndex: 999,
- background: "transparent",
- },
- } }, { children: children })));
-}
-function PopupPresenter(props) {
- // HACK: we don't want to render the popup presenter for no reason
- // including it's effects etc. so we just wrap it and return null
- // if the popup is closed.
- if (!props.isOpen)
- return null;
- return (0, jsx_runtime_1.jsx)(_PopupPresenter, Object.assign({}, props));
-}
-exports.PopupPresenter = PopupPresenter;
-function PopupWrapper(props) {
- let { id, group, position, renderPopup, isOpen, onClosed, autoCloseOnUnmount } = props, presenterProps = __rest(props, ["id", "group", "position", "renderPopup", "isOpen", "onClosed", "autoCloseOnUnmount"]);
- const PopupRenderer = (0, popuprenderer_1.usePopupRenderer)();
- const { closePopup, isPopupOpen } = usePopupHandler(props);
- (0, react_1.useEffect)(() => {
- if (!autoCloseOnUnmount)
- return;
- return () => {
- PopupRenderer === null || PopupRenderer === void 0 ? void 0 : PopupRenderer.closePopup(id);
- };
- }, [autoCloseOnUnmount, id, PopupRenderer]);
- (0, react_1.useEffect)(() => {
- if (PopupRenderer && isPopupOpen) {
- PopupRenderer.openPopup(id, function Popup({ id }) {
- const isPopupOpen = (0, toolbarstore_1.useToolbarStore)((store) => !!store.openedPopups[id]);
- (0, react_1.useEffect)(() => {
- if (!isPopupOpen) {
- PopupRenderer.closePopup(id);
- }
- }, [isPopupOpen]);
- return ((0, jsx_runtime_1.jsx)(PopupPresenter, Object.assign({ isOpen: isPopupOpen, onClose: () => closePopup(id), position: position, blocking: true, focusOnRender: true }, presenterProps, { children: (0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {
- boxShadow: "menu",
- borderRadius: "default",
- overflow: "hidden",
- // width,
- } }, { children: (0, jsx_runtime_1.jsx)(popuprenderer_1.EditorContext.Consumer, { children: () => {
- return renderPopup(() => PopupRenderer.closePopup(id));
- } }) })) }), id));
- });
- }
- }, [PopupRenderer, isPopupOpen]);
- return null;
-}
-exports.PopupWrapper = PopupWrapper;
-function usePopupHandler(options) {
- let { group, isOpen, id, onClosed } = options;
- const isPopupOpen = (0, toolbarstore_1.useToolbarStore)((store) => !!store.openedPopups[id]);
- const openPopup = (0, toolbarstore_1.useToolbarStore)((store) => store.openPopup);
- const closePopup = (0, toolbarstore_1.useToolbarStore)((store) => store.closePopup);
- const closePopupGroup = (0, toolbarstore_1.useToolbarStore)((store) => store.closePopupGroup);
- const isBottom = (0, toolbarstore_1.useToolbarStore)((store) => store.toolbarLocation === "bottom");
- if (isBottom)
- group = "popup";
- (0, react_1.useEffect)(() => {
- if (isOpen)
- openPopup({ id, group });
- else
- closePopup(id);
- }, [isOpen, id, group, openPopup, closePopup]);
- (0, react_1.useEffect)(() => {
- if (!isPopupOpen)
- onClosed === null || onClosed === void 0 ? void 0 : onClosed();
- }, [isPopupOpen]);
- (0, react_1.useEffect)(() => {
- if (isPopupOpen) {
- closePopupGroup(group, [id]);
- }
- }, [onClosed, isPopupOpen, closePopupGroup, id, group]);
- (0, react_1.useEffect)(() => {
- if (!isOpen)
- closePopup(id);
- }, [isOpen, id, group, closePopup]);
- return { isPopupOpen, closePopup };
-}
-exports.usePopupHandler = usePopupHandler;
-function showPopup(options) {
- const { popup } = options, props = __rest(options, ["popup"]);
- function hide() {
- react_dom_1.default.unmountComponentAtNode((0, dom_1.getPopupContainer)());
- }
- react_dom_1.default.render((0, jsx_runtime_1.jsx)(themeprovider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: true, position: {
- target: (0, dom_1.getToolbarElement)(),
- isTargetAbsolute: true,
- location: "below",
- align: "end",
- yOffset: 10,
- }, blocking: true, focusOnRender: true }, props, { onClose: () => {
- var _a;
- hide();
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
- } }, { children: popup(hide) })) }), (0, dom_1.getPopupContainer)());
- return hide;
-}
-exports.showPopup = showPopup;
diff --git a/packages/editor/dist/cjs/components/popuppresenter/popuprenderer.d.ts b/packages/editor/dist/cjs/components/popuppresenter/popuprenderer.d.ts
deleted file mode 100644
index 6a837ff5f..000000000
--- a/packages/editor/dist/cjs/components/popuppresenter/popuprenderer.d.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import React, { PropsWithChildren } from "react";
-import { Editor } from "@tiptap/core";
-export declare const PopupRendererContext: React.Context<PopupRenderer | null>;
-export declare const EditorContext: React.Context<Editor | null>;
-export declare type PopupRendererProps = PropsWithChildren<{
- editor: Editor;
-}>;
-declare type PopupComponent = React.FunctionComponent<{
- id: string;
-}>;
-declare type PopupRendererState = {
- popups: {
- id: string;
- popup: PopupComponent;
- }[];
-};
-export declare class PopupRenderer extends React.Component<PopupRendererProps, PopupRendererState, PopupRendererState> {
- popupContainer: HTMLDivElement | null;
- state: PopupRendererState;
- openPopup: (id: string, popup: PopupComponent) => void;
- closePopup: (id: string) => void;
- render(): React.ReactNode;
-}
-export declare function usePopupRenderer(): PopupRenderer | null;
-export declare function useEditorContext(): Editor;
-export {};
diff --git a/packages/editor/dist/cjs/components/popuppresenter/popuprenderer.js b/packages/editor/dist/cjs/components/popuppresenter/popuprenderer.js
deleted file mode 100644
index ca65fed17..000000000
--- a/packages/editor/dist/cjs/components/popuppresenter/popuprenderer.js
+++ /dev/null
@@ -1,74 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.useEditorContext = exports.usePopupRenderer = exports.PopupRenderer = exports.EditorContext = exports.PopupRendererContext = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importStar(require("react"));
-exports.PopupRendererContext = react_1.default.createContext(null);
-exports.EditorContext = react_1.default.createContext(null);
-class PopupRenderer extends react_1.default.Component {
- constructor() {
- super(...arguments);
- this.popupContainer = null;
- this.state = {
- popups: [],
- };
- this.openPopup = (id, popup) => {
- if (!popup)
- return;
- this.setState((prev) => {
- return {
- popups: [...prev.popups, { id, popup }],
- };
- });
- };
- this.closePopup = (id) => {
- this.setState((prev) => {
- const index = prev.popups.findIndex((p) => p.id === id);
- if (index <= -1)
- return prev;
- const clone = prev.popups.slice();
- clone.splice(index, 1);
- return {
- popups: clone,
- };
- });
- };
- }
- render() {
- return ((0, jsx_runtime_1.jsxs)(exports.PopupRendererContext.Provider, Object.assign({ value: this }, { children: [this.props.children, (0, jsx_runtime_1.jsxs)(exports.EditorContext.Provider, Object.assign({ value: this.props.editor }, { children: [this.state.popups.map(({ id, popup: Popup }) => {
- return (0, jsx_runtime_1.jsx)(Popup, { id: id }, id);
- }), (0, jsx_runtime_1.jsx)("div", { id: "popup-container" })] }))] })));
- }
-}
-exports.PopupRenderer = PopupRenderer;
-function usePopupRenderer() {
- return (0, react_1.useContext)(exports.PopupRendererContext);
-}
-exports.usePopupRenderer = usePopupRenderer;
-function useEditorContext() {
- return (0, react_1.useContext)(exports.EditorContext);
-}
-exports.useEditorContext = useEditorContext;
diff --git a/packages/editor/dist/cjs/components/resizer/index.d.ts b/packages/editor/dist/cjs/components/resizer/index.d.ts
deleted file mode 100644
index 08792a319..000000000
--- a/packages/editor/dist/cjs/components/resizer/index.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { PropsWithChildren } from "react";
-import { Editor } from "../../types";
-declare type ResizerProps = {
- editor: Editor;
- selected: boolean;
- width?: number;
- height?: number;
- onResize: (width: number, height: number) => void;
-};
-export declare function Resizer(props: PropsWithChildren<ResizerProps>): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/components/resizer/index.js b/packages/editor/dist/cjs/components/resizer/index.js
deleted file mode 100644
index b9d41917f..000000000
--- a/packages/editor/dist/cjs/components/resizer/index.js
+++ /dev/null
@@ -1,39 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Resizer = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const re_resizable_1 = require("re-resizable");
-const toolbar_1 = require("../../toolbar");
-function Resizer(props) {
- const { editor, selected, onResize, width, height, children } = props;
- return ((0, jsx_runtime_1.jsx)(re_resizable_1.Resizable, Object.assign({ enable: {
- bottom: false,
- left: false,
- right: false,
- top: false,
- bottomLeft: false,
- bottomRight: editor.isEditable && selected,
- topLeft: false,
- topRight: false,
- }, size: {
- height: height || "auto",
- width: width || "auto",
- }, maxWidth: "100%", minWidth: 150, minHeight: 150, handleComponent: {
- bottomRight: ((0, jsx_runtime_1.jsx)(toolbar_1.Icon, { sx: {
- width: 25,
- height: 25,
- marginLeft: -17,
- marginTop: "3px",
- borderTopLeftRadius: "default",
- borderBottomRightRadius: "default",
- }, path: toolbar_1.Icons.resize, size: 25, color: "primary" })),
- }, onResizeStop: (e, direction, ref, d) => {
- try {
- onResize(ref.clientWidth, ref.clientHeight);
- }
- catch (_a) {
- // ignore
- }
- }, lockAspectRatio: true }, { children: children })));
-}
-exports.Resizer = Resizer;
diff --git a/packages/editor/dist/cjs/components/responsive/index.d.ts b/packages/editor/dist/cjs/components/responsive/index.d.ts
deleted file mode 100644
index f734f5329..000000000
--- a/packages/editor/dist/cjs/components/responsive/index.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { PropsWithChildren } from "react";
-import { ActionSheetPresenterProps } from "../action-sheet";
-import { MenuPresenterProps } from "../menu";
-declare type ResponsiveContainerProps = {
- mobile?: JSX.Element;
- desktop?: JSX.Element;
-};
-export declare function ResponsiveContainer(props: ResponsiveContainerProps): JSX.Element | null;
-export declare function DesktopOnly(props: PropsWithChildren<{}>): JSX.Element;
-export declare function MobileOnly(props: PropsWithChildren<{}>): JSX.Element;
-export declare type PopupType = "sheet" | "menu" | "none";
-export declare type ResponsivePresenterProps = MenuPresenterProps & ActionSheetPresenterProps & {
- mobile?: PopupType;
- desktop?: PopupType;
-};
-export declare function ResponsivePresenter(props: PropsWithChildren<ResponsivePresenterProps>): JSX.Element | null;
-export {};
diff --git a/packages/editor/dist/cjs/components/responsive/index.js b/packages/editor/dist/cjs/components/responsive/index.js
deleted file mode 100644
index 077e67540..000000000
--- a/packages/editor/dist/cjs/components/responsive/index.js
+++ /dev/null
@@ -1,45 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ResponsivePresenter = exports.MobileOnly = exports.DesktopOnly = exports.ResponsiveContainer = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-const actionsheet_1 = require("../actionsheet");
-const menu_1 = require("../menu");
-function ResponsiveContainer(props) {
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- if (isMobile)
- return props.mobile || null;
- else
- return props.desktop || null;
-}
-exports.ResponsiveContainer = ResponsiveContainer;
-function DesktopOnly(props) {
- return (0, jsx_runtime_1.jsx)(ResponsiveContainer, { desktop: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props.children }) });
-}
-exports.DesktopOnly = DesktopOnly;
-function MobileOnly(props) {
- return (0, jsx_runtime_1.jsx)(ResponsiveContainer, { mobile: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props.children }) });
-}
-exports.MobileOnly = MobileOnly;
-function ResponsivePresenter(props) {
- const { mobile = "menu", desktop = "menu" } = props, restProps = __rest(props, ["mobile", "desktop"]);
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- if (isMobile && mobile === "sheet")
- return (0, jsx_runtime_1.jsx)(actionsheet_1.ActionSheetPresenter, Object.assign({}, restProps));
- else if (mobile === "menu" || desktop === "menu")
- return (0, jsx_runtime_1.jsx)(menu_1.MenuPresenter, Object.assign({}, restProps));
- else
- return props.isOpen ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props.children }) : null;
-}
-exports.ResponsivePresenter = ResponsivePresenter;
diff --git a/packages/editor/dist/cjs/components/tabs/index.d.ts b/packages/editor/dist/cjs/components/tabs/index.d.ts
deleted file mode 100644
index 28e7a9dac..000000000
--- a/packages/editor/dist/cjs/components/tabs/index.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import React, { PropsWithChildren } from "react";
-import { FlexProps } from "rebass";
-export declare type TabProps = {
- title: string | React.ReactElement;
-};
-export declare function Tab(props: PropsWithChildren<TabProps>): JSX.Element;
-export declare type TabsProps = {
- activeIndex: number;
- containerProps?: FlexProps;
- onTabChanged?: (index: number) => void;
-};
-export declare function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element;
diff --git a/packages/editor/dist/cjs/components/tabs/index.js b/packages/editor/dist/cjs/components/tabs/index.js
deleted file mode 100644
index 08548201d..000000000
--- a/packages/editor/dist/cjs/components/tabs/index.js
+++ /dev/null
@@ -1,64 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Tabs = exports.Tab = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importStar(require("react"));
-const rebass_1 = require("rebass");
-function Tab(props) {
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props.children });
-}
-exports.Tab = Tab;
-function Tabs(props) {
- const { activeIndex, children, containerProps, onTabChanged } = props;
- const [activeTab, setActiveTab] = (0, react_1.useState)(activeIndex || 0);
- const tabs = (0, react_1.useMemo)(() => react_1.Children.map(children, (child) => {
- if (react_1.default.isValidElement(child))
- return { title: child.props.title, component: child };
- }), [children]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { flexDirection: "column" } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- mb: 1,
- } }, { children: tabs === null || tabs === void 0 ? void 0 : tabs.map((tab, index) => ((0, jsx_runtime_1.jsx)(rebass_1.Button, Object.assign({ sx: {
- flex: 1,
- p: 0,
- py: 1,
- borderRadius: 0,
- borderTopLeftRadius: "default",
- borderTopRightRadius: "default",
- bg: activeTab === index ? "bgSecondary" : "transparent",
- fontWeight: activeTab === index ? "bold" : "normal",
- color: "text",
- ":last-of-type": { mr: 0 },
- borderBottom: "2px solid",
- borderBottomColor: activeTab === index ? "primary" : "transparent",
- ":hover": {
- bg: "hover",
- },
- }, onClick: () => {
- setActiveTab(index);
- onTabChanged === null || onTabChanged === void 0 ? void 0 : onTabChanged(index);
- } }, { children: tab.title }), index.toString()))) })), (0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({}, containerProps, { children: tabs && tabs[activeTab].component }))] })));
-}
-exports.Tabs = Tabs;
diff --git a/packages/editor/dist/cjs/components/themeprovider/index.d.ts b/packages/editor/dist/cjs/components/themeprovider/index.d.ts
deleted file mode 100644
index 8941a4054..000000000
--- a/packages/editor/dist/cjs/components/themeprovider/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { PropsWithChildren } from "react";
-export declare function ThemeProvider(props: PropsWithChildren<{}>): JSX.Element;
diff --git a/packages/editor/dist/cjs/components/themeprovider/index.js b/packages/editor/dist/cjs/components/themeprovider/index.js
deleted file mode 100644
index 41390e34e..000000000
--- a/packages/editor/dist/cjs/components/themeprovider/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ThemeProvider = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const emotion_theming_1 = require("emotion-theming");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-function ThemeProvider(props) {
- const theme = (0, toolbarstore_1.useTheme)();
- return ((0, jsx_runtime_1.jsx)(emotion_theming_1.ThemeProvider, Object.assign({ theme: theme || {} }, { children: props.children })));
-}
-exports.ThemeProvider = ThemeProvider;
diff --git a/packages/editor/dist/cjs/extensions.d.ts b/packages/editor/dist/cjs/extensions.d.ts
deleted file mode 100644
index 04757fdce..000000000
--- a/packages/editor/dist/cjs/extensions.d.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import "@tiptap/extension-character-count";
-import "@tiptap/extension-placeholder";
-import "@tiptap/extension-underline";
-import "@tiptap/starter-kit";
-import "@tiptap/extension-text-align";
-import "@tiptap/extension-subscript";
-import "@tiptap/extension-superscript";
-import "./extensions/font-size";
-import "./extensions/text-direction";
-import "@tiptap/extension-text-style";
-import "@tiptap/extension-font-family";
-import "./extensions/bullet-list";
-import "./extensions/ordered-list";
-import "@tiptap/extension-highlight";
-import "@tiptap/extension-color";
-import "@tiptap/extension-table-row";
-import "./extensions/table-cell";
-import "@tiptap/extension-table-header";
-import "./extensions/image";
-import "./extensions/attachment";
-import "./extensions/task-list";
-import "./extensions/task-item";
-import "./extensions/drop-cursor";
-import "./extensions/search-replace";
-import "./extensions/embed";
-import "./extensions/code-block";
-import "./extensions/list-item";
-import "./extensions/outline-list";
-import "./extensions/outline-list-item";
-import "./extensions/table";
diff --git a/packages/editor/dist/cjs/extensions.js b/packages/editor/dist/cjs/extensions.js
deleted file mode 100644
index 76b45dbd7..000000000
--- a/packages/editor/dist/cjs/extensions.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-require("@tiptap/extension-character-count");
-require("@tiptap/extension-placeholder");
-require("@tiptap/extension-underline");
-require("@tiptap/starter-kit");
-require("@tiptap/extension-text-align");
-require("@tiptap/extension-subscript");
-require("@tiptap/extension-superscript");
-require("./extensions/fontsize");
-require("./extensions/textdirection");
-require("@tiptap/extension-text-style");
-require("@tiptap/extension-font-family");
-require("./extensions/bulletlist");
-require("./extensions/orderedlist");
-require("@tiptap/extension-highlight");
-require("@tiptap/extension-color");
-require("@tiptap/extension-table-row");
-require("./extensions/tablecell");
-require("@tiptap/extension-table-header");
-require("./extensions/image");
-require("./extensions/attachment");
-require("./extensions/tasklist");
-require("./extensions/taskitem");
-require("./extensions/dropcursor");
-require("./extensions/searchreplace");
-require("./extensions/embed");
-require("./extensions/codeblock");
-require("./extensions/listitem");
-require("./extensions/outlinelist");
-require("./extensions/outlinelistitem");
-require("./extensions/table");
diff --git a/packages/editor/dist/cjs/extensions/attachment/attachment.d.ts b/packages/editor/dist/cjs/extensions/attachment/attachment.d.ts
deleted file mode 100644
index cd34695f5..000000000
--- a/packages/editor/dist/cjs/extensions/attachment/attachment.d.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Node, Editor } from "@tiptap/core";
-import { Attribute } from "@tiptap/core";
-export declare type AttachmentType = "image" | "file" | "camera";
-export interface AttachmentOptions {
- HTMLAttributes: Record<string, any>;
- onDownloadAttachment: (editor: Editor, attachment: Attachment) => boolean;
- onOpenAttachmentPicker: (editor: Editor, type: AttachmentType) => boolean;
-}
-export declare type AttachmentWithProgress = AttachmentProgress & Attachment;
-export declare type Attachment = {
- hash: string;
- filename: string;
- type: string;
- size: number;
-};
-export declare type AttachmentProgress = {
- progress: number;
- type: "upload" | "download" | "encrypt";
- hash: string;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- attachment: {
- openAttachmentPicker: (type: AttachmentType) => ReturnType;
- insertAttachment: (attachment: Attachment) => ReturnType;
- removeAttachment: () => ReturnType;
- downloadAttachment: (attachment: Attachment) => ReturnType;
- setAttachmentProgress: (progress: AttachmentProgress) => ReturnType;
- };
- }
-}
-export declare const AttachmentNode: Node<AttachmentOptions, any>;
-export declare function getDataAttribute(name: string, def?: any | null): Partial<Attribute>;
diff --git a/packages/editor/dist/cjs/extensions/attachment/attachment.js b/packages/editor/dist/cjs/extensions/attachment/attachment.js
deleted file mode 100644
index d00fbf0d7..000000000
--- a/packages/editor/dist/cjs/extensions/attachment/attachment.js
+++ /dev/null
@@ -1,115 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.getDataAttribute = exports.AttachmentNode = void 0;
-const core_1 = require("@tiptap/core");
-const react_1 = require("../react");
-const component_1 = require("./component");
-exports.AttachmentNode = core_1.Node.create({
- name: "attachment",
- content: "inline*",
- marks: "",
- inline: true,
- atom: true,
- addOptions() {
- return {
- HTMLAttributes: {},
- onDownloadAttachment: () => false,
- onOpenAttachmentPicker: () => false,
- };
- },
- group() {
- return "inline";
- },
- draggable: true,
- addAttributes() {
- return {
- progress: {
- default: 0,
- rendered: false,
- },
- hash: getDataAttribute("hash"),
- filename: getDataAttribute("filename"),
- type: getDataAttribute("mime"),
- size: getDataAttribute("size"),
- };
- },
- parseHTML() {
- return [
- {
- tag: "span[data-hash]",
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "span",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
- ];
- },
- addNodeView() {
- return (0, react_1.createSelectionBasedNodeView)(component_1.AttachmentComponent, {
- shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
- return prev.progress !== next.progress;
- },
- });
- },
- addCommands() {
- return {
- insertAttachment: (attachment) => ({ commands }) => {
- return commands.insertContent({
- type: this.name,
- attrs: attachment,
- });
- },
- removeAttachment: () => ({ commands, tr }) => {
- return commands.deleteSelection();
- },
- downloadAttachment: (attachment) => ({ editor }) => {
- return this.options.onDownloadAttachment(editor, attachment);
- },
- openAttachmentPicker: (type) => ({ editor }) => {
- return this.options.onOpenAttachmentPicker(editor, type);
- },
- setAttachmentProgress: (options) => ({ state, tr, dispatch }) => {
- const { hash, progress, type } = options;
- const attachments = (0, core_1.findChildren)(state.doc, (node) => (node.type.name === this.name || node.type.name === "image") &&
- node.attrs.hash === hash);
- for (const attachment of attachments) {
- tr.setNodeMarkup(attachment.pos, attachment.node.type, Object.assign(Object.assign({}, attachment.node.attrs), { progress: progress === 100 ? null : progress }));
- }
- tr.setMeta("preventUpdate", true);
- tr.setMeta("addToHistory", false);
- if (dispatch)
- dispatch(tr);
- return true;
- },
- };
- },
- // addInputRules() {
- // return [
- // nodeInputRule({
- // find: inputRegex,
- // type: this.type,
- // getAttributes: (match) => {
- // const [, , alt, src, title] = match;
- // return { src, alt, title };
- // },
- // }),
- // ];
- // },
-});
-function getDataAttribute(name, def) {
- return {
- default: def,
- parseHTML: (element) => element.dataset[name],
- renderHTML: (attributes) => {
- if (!attributes[name]) {
- return {};
- }
- return {
- [`data-${name}`]: attributes[name],
- };
- },
- };
-}
-exports.getDataAttribute = getDataAttribute;
diff --git a/packages/editor/dist/cjs/extensions/attachment/component.d.ts b/packages/editor/dist/cjs/extensions/attachment/component.d.ts
deleted file mode 100644
index ea57c55f9..000000000
--- a/packages/editor/dist/cjs/extensions/attachment/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { AttachmentWithProgress } from "./attachment";
-import { SelectionBasedReactNodeViewProps } from "../react";
-export declare function AttachmentComponent(props: SelectionBasedReactNodeViewProps<AttachmentWithProgress>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/attachment/component.js b/packages/editor/dist/cjs/extensions/attachment/component.js
deleted file mode 100644
index 38ae1fc41..000000000
--- a/packages/editor/dist/cjs/extensions/attachment/component.js
+++ /dev/null
@@ -1,60 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.AttachmentComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-// import { MenuPresenter } from "../../components/menu/menu";
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const toolbargroup_1 = require("../../toolbar/components/toolbargroup");
-const responsive_1 = require("../../components/responsive");
-function AttachmentComponent(props) {
- const { editor, node, selected } = props;
- const { hash, filename, size, progress } = node.attrs;
- const elementRef = (0, react_1.useRef)();
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Box, Object.assign({ ref: elementRef, as: "span", contentEditable: false, variant: "body", sx: {
- display: "inline-flex",
- position: "relative",
- justifyContent: "center",
- userSelect: "none",
- alignItems: "center",
- backgroundColor: "bgSecondary",
- px: 1,
- borderRadius: "default",
- border: "1px solid var(--border)",
- cursor: "pointer",
- maxWidth: 250,
- borderColor: selected ? "primary" : "border",
- ":hover": {
- bg: "hover",
- },
- }, title: filename }, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.attachment, size: 14 }), (0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ as: "span", sx: {
- ml: "small",
- fontSize: "body",
- whiteSpace: "nowrap",
- textOverflow: "ellipsis",
- overflow: "hidden",
- } }, { children: filename })), (0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ as: "span", sx: {
- ml: 1,
- fontSize: "0.65rem",
- color: "fontTertiary",
- flexShrink: 0,
- } }, { children: progress ? `${progress}%` : formatBytes(size) })), (0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: selected && ((0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { editor: editor, tools: ["removeAttachment", "downloadAttachment"], sx: {
- boxShadow: "menu",
- borderRadius: "default",
- bg: "background",
- position: "absolute",
- top: -35,
- } })) })] })) }));
-}
-exports.AttachmentComponent = AttachmentComponent;
-function formatBytes(bytes, decimals = 1) {
- if (bytes === 0)
- return "0B";
- const k = 1024;
- const dm = decimals < 0 ? 0 : decimals;
- const sizes = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
- const i = Math.floor(Math.log(bytes) / Math.log(k));
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + sizes[i];
-}
diff --git a/packages/editor/dist/cjs/extensions/attachment/index.d.ts b/packages/editor/dist/cjs/extensions/attachment/index.d.ts
deleted file mode 100644
index 9f9f38860..000000000
--- a/packages/editor/dist/cjs/extensions/attachment/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./attachment";
diff --git a/packages/editor/dist/cjs/extensions/attachment/index.js b/packages/editor/dist/cjs/extensions/attachment/index.js
deleted file mode 100644
index 13ebc3eca..000000000
--- a/packages/editor/dist/cjs/extensions/attachment/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./attachment"), exports);
diff --git a/packages/editor/dist/cjs/extensions/bulletlist/bulletlist.d.ts b/packages/editor/dist/cjs/extensions/bulletlist/bulletlist.d.ts
deleted file mode 100644
index 803ad33bd..000000000
--- a/packages/editor/dist/cjs/extensions/bulletlist/bulletlist.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const BulletList: import("@tiptap/core").Node<import("@tiptap/extension-bullet-list").BulletListOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/bulletlist/bulletlist.js b/packages/editor/dist/cjs/extensions/bulletlist/bulletlist.js
deleted file mode 100644
index 17294e416..000000000
--- a/packages/editor/dist/cjs/extensions/bulletlist/bulletlist.js
+++ /dev/null
@@ -1,25 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.BulletList = void 0;
-const extension_bullet_list_1 = __importDefault(require("@tiptap/extension-bullet-list"));
-exports.BulletList = extension_bullet_list_1.default.extend({
- addAttributes() {
- return {
- listType: {
- default: null,
- parseHTML: (element) => element.style.listStyleType,
- renderHTML: (attributes) => {
- if (!attributes.listType) {
- return {};
- }
- return {
- style: `list-style-type: ${attributes.listType}`,
- };
- },
- },
- };
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/bulletlist/index.d.ts b/packages/editor/dist/cjs/extensions/bulletlist/index.d.ts
deleted file mode 100644
index c732326f2..000000000
--- a/packages/editor/dist/cjs/extensions/bulletlist/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { BulletList } from "./bullet-list";
-export * from "./bullet-list";
-export default BulletList;
diff --git a/packages/editor/dist/cjs/extensions/bulletlist/index.js b/packages/editor/dist/cjs/extensions/bulletlist/index.js
deleted file mode 100644
index d9a3f601a..000000000
--- a/packages/editor/dist/cjs/extensions/bulletlist/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const bulletlist_1 = require("./bulletlist");
-__exportStar(require("./bulletlist"), exports);
-exports.default = bulletlist_1.BulletList;
diff --git a/packages/editor/dist/cjs/extensions/codeblock/codeblock.d.ts b/packages/editor/dist/cjs/extensions/codeblock/codeblock.d.ts
deleted file mode 100644
index 19f8d3e16..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/codeblock.d.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { Node } from "@tiptap/core";
-import { Selection } from "prosemirror-state";
-import { Node as ProsemirrorNode } from "prosemirror-model";
-interface Indent {
- type: "tab" | "space";
- amount: number;
-}
-export declare type CodeBlockAttributes = {
- indentType: Indent["type"];
- indentLength: number;
- language: string;
- lines: CodeLine[];
- caretPosition?: CaretPosition;
-};
-export interface CodeBlockOptions {
- /**
- * Adds a prefix to language classes that are applied to code tags.
- * Defaults to `'language-'`.
- */
- languageClassPrefix: string;
- /**
- * Define whether the node should be exited on triple enter.
- * Defaults to `true`.
- */
- exitOnTripleEnter: boolean;
- /**
- * Define whether the node should be exited on arrow down if there is no node after it.
- * Defaults to `true`.
- */
- exitOnArrowDown: boolean;
- /**
- * Define whether the node should be exited on arrow up if there is no node before it.
- * Defaults to `true`.
- */
- exitOnArrowUp: boolean;
- /**
- * Custom HTML attributes that should be added to the rendered HTML tag.
- */
- HTMLAttributes: Record<string, any>;
-}
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- codeblock: {
- /**
- * Set a code block
- */
- setCodeBlock: (attributes?: {
- language: string;
- }) => ReturnType;
- /**
- * Toggle a code block
- */
- toggleCodeBlock: (attributes?: {
- language: string;
- }) => ReturnType;
- /**
- * Change code block indentation options
- */
- changeCodeBlockIndentation: (options: Indent) => ReturnType;
- };
- }
-}
-export declare const backtickInputRegex: RegExp;
-export declare const tildeInputRegex: RegExp;
-export declare const CodeBlock: Node<CodeBlockOptions, any>;
-export declare type CaretPosition = {
- column: number;
- line: number;
- selected?: number;
- total: number;
- from: number;
-};
-export declare function toCaretPosition(selection: Selection, lines?: CodeLine[]): CaretPosition | undefined;
-export declare function getLines(node: ProsemirrorNode): CodeLine[];
-declare type CodeLine = {
- index: number;
- from: number;
- to: number;
- length: number;
- text: (length?: number) => string;
-};
-export declare function toCodeLines(code: string, pos: number): CodeLine[];
-export {};
diff --git a/packages/editor/dist/cjs/extensions/codeblock/codeblock.js b/packages/editor/dist/cjs/extensions/codeblock/codeblock.js
deleted file mode 100644
index 897de81bf..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/codeblock.js
+++ /dev/null
@@ -1,531 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.toCodeLines = exports.getLines = exports.toCaretPosition = exports.CodeBlock = exports.tildeInputRegex = exports.backtickInputRegex = void 0;
-const core_1 = require("@tiptap/core");
-const core_2 = require("@tiptap/core");
-const prosemirror_state_1 = require("prosemirror-state");
-const component_1 = require("./component");
-const highlighter_1 = require("./highlighter");
-const react_1 = require("../react");
-const detect_indent_1 = __importDefault(require("detect-indent"));
-const redent_1 = __importDefault(require("redent"));
-const strip_indent_1 = __importDefault(require("strip-indent"));
-exports.backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
-exports.tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
-const ZERO_WIDTH_SPACE = "\u200b";
-const NEWLINE = "\n";
-exports.CodeBlock = core_2.Node.create({
- name: "codeblock",
- addOptions() {
- return {
- languageClassPrefix: "language-",
- exitOnTripleEnter: true,
- exitOnArrowDown: true,
- exitOnArrowUp: true,
- HTMLAttributes: {},
- };
- },
- content: "text*",
- marks: "",
- group: "block",
- code: true,
- defining: true,
- addAttributes() {
- return {
- caretPosition: {
- default: undefined,
- rendered: false,
- },
- lines: {
- default: [],
- rendered: false,
- },
- indentType: {
- default: "space",
- parseHTML: (element) => {
- const indentType = element.dataset.indentType;
- return indentType;
- },
- renderHTML: (attributes) => {
- if (!attributes.indentType) {
- return {};
- }
- return {
- "data-indent-type": attributes.indentType,
- };
- },
- },
- indentLength: {
- default: 2,
- parseHTML: (element) => {
- const indentLength = element.dataset.indentLength;
- return indentLength;
- },
- renderHTML: (attributes) => {
- if (!attributes.indentLength) {
- return {};
- }
- return {
- "data-indent-length": attributes.indentLength,
- };
- },
- },
- language: {
- default: null,
- parseHTML: (element) => {
- var _a;
- const { languageClassPrefix } = this.options;
- const classNames = [
- ...(element.classList || []),
- ...(((_a = element === null || element === void 0 ? void 0 : element.firstElementChild) === null || _a === void 0 ? void 0 : _a.classList) || []),
- ];
- const languages = classNames
- .filter((className) => className.startsWith(languageClassPrefix))
- .map((className) => className.replace(languageClassPrefix, ""));
- const language = languages[0];
- if (!language) {
- return null;
- }
- return language;
- },
- renderHTML: (attributes) => {
- if (!attributes.language) {
- return {};
- }
- return {
- class: `language-${attributes.language}`,
- };
- },
- },
- };
- },
- parseHTML() {
- return [
- {
- tag: "pre",
- preserveWhitespace: "full",
- // contentElement: (node) => {
- // if (node instanceof HTMLElement) {
- // node.innerText = node.innerText.replaceAll("\n\u200b\n", "\n\n");
- // }
- // return node;
- // },
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "pre",
- (0, core_2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
- ["code", {}, 0],
- ];
- },
- addCommands() {
- return {
- setCodeBlock: (attributes) => ({ commands }) => {
- return commands.setNode(this.name, attributes);
- },
- toggleCodeBlock: (attributes) => ({ commands }) => {
- console.log("TOGGLING!");
- return commands.toggleNode(this.name, "paragraph", attributes);
- },
- changeCodeBlockIndentation: (options) => ({ editor, tr, commands }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from } = selection;
- if ($from.parent.type !== this.type) {
- return false;
- }
- const { lines } = $from.parent.attrs;
- for (const line of lines) {
- const text = line.text();
- const whitespaceLength = text.length - text.trimStart().length;
- if (!whitespaceLength)
- continue;
- const indentLength = whitespaceLength;
- const indentToken = indent({
- type: options.type,
- amount: indentLength,
- });
- tr.insertText(indentToken, tr.mapping.map(line.from), tr.mapping.map(line.from + whitespaceLength));
- }
- commands.updateAttributes(this.type, {
- indentType: options.type,
- indentLength: options.amount,
- });
- return true;
- },
- };
- },
- addKeyboardShortcuts() {
- return {
- "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
- "Mod-a": ({ editor }) => {
- const { $anchor } = this.editor.state.selection;
- if ($anchor.parent.type.name !== this.name) {
- return false;
- }
- const codeblock = (0, core_1.findParentNodeClosestToPos)($anchor, (node) => node.type.name === this.type.name);
- if (!codeblock)
- return false;
- return editor.commands.setTextSelection({
- from: codeblock.pos + 1,
- to: codeblock.pos + codeblock.node.nodeSize - 1,
- });
- },
- // remove code block when at start of document or code block is empty
- Backspace: () => {
- const { empty, $anchor } = this.editor.state.selection;
- const currentNode = $anchor.parent;
- const nextNode = this.editor.state.doc.nodeAt($anchor.pos + 1);
- const isCodeBlock = (node) => node && node.type.name === this.name;
- const isAtStart = $anchor.pos === 1;
- if (!empty) {
- return false;
- }
- if (isAtStart ||
- (isCodeBlock(currentNode) && !currentNode.textContent.length)) {
- return this.editor.commands.deleteNode(this.type);
- }
- // on android due to composition issues with various keyboards,
- // sometimes backspace is detected one node behind. We need to
- // manually handle this case.
- else if (nextNode &&
- isCodeBlock(nextNode) &&
- !nextNode.textContent.length) {
- return this.editor.commands.command(({ tr }) => {
- tr.delete($anchor.pos + 1, $anchor.pos + 1 + nextNode.nodeSize);
- return true;
- });
- }
- return false;
- },
- // exit node on triple enter
- Enter: ({ editor }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from, empty } = selection;
- if (!empty || $from.parent.type !== this.type) {
- return false;
- }
- const indentation = parseIndentation($from.parent);
- return ((this.options.exitOnTripleEnter &&
- exitOnTripleEnter(editor, $from)) ||
- indentOnEnter(editor, $from, indentation));
- },
- // exit node on arrow up
- ArrowUp: ({ editor }) => {
- if (!this.options.exitOnArrowUp) {
- return false;
- }
- const { state } = editor;
- const { selection } = state;
- const { $anchor, empty } = selection;
- if (!empty || $anchor.parent.type !== this.type) {
- return false;
- }
- const isAtStart = $anchor.pos === 1;
- if (!isAtStart) {
- return false;
- }
- return editor.commands.insertContentAt(0, "<p></p>");
- },
- // exit node on arrow down
- ArrowDown: ({ editor }) => {
- if (!this.options.exitOnArrowDown) {
- return false;
- }
- const { state } = editor;
- const { selection, doc } = state;
- const { $from, empty } = selection;
- if (!empty || $from.parent.type !== this.type) {
- return false;
- }
- const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
- if (!isAtEnd) {
- return false;
- }
- const after = $from.after();
- if (after === undefined) {
- return false;
- }
- const nodeAfter = doc.nodeAt(after);
- if (nodeAfter) {
- editor.commands.setNodeSelection($from.before());
- return false;
- }
- return editor.commands.exitCode();
- },
- "Shift-Tab": ({ editor }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from } = selection;
- if ($from.parent.type !== this.type) {
- return false;
- }
- const indentation = parseIndentation($from.parent);
- const indentToken = indent(indentation);
- const { lines } = $from.parent.attrs;
- const selectedLines = getSelectedLines(lines, selection);
- return editor
- .chain()
- .command(({ tr }) => withSelection(tr, (tr) => {
- for (const line of selectedLines) {
- if (line.text(indentToken.length) !== indentToken)
- continue;
- tr.delete(tr.mapping.map(line.from), tr.mapping.map(line.from + indentation.amount));
- }
- }))
- .run();
- },
- Tab: ({ editor }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from } = selection;
- if ($from.parent.type !== this.type) {
- return false;
- }
- const { lines } = $from.parent.attrs;
- const selectedLines = getSelectedLines(lines, selection);
- return editor
- .chain()
- .command(({ tr }) => withSelection(tr, (tr) => {
- const indentToken = indent(parseIndentation($from.parent));
- if (selectedLines.length === 1)
- return tr.insertText(indentToken, $from.pos);
- for (const line of selectedLines) {
- tr.insertText(indentToken, tr.mapping.map(line.from));
- }
- }))
- .run();
- },
- };
- },
- addInputRules() {
- return [
- (0, core_2.textblockTypeInputRule)({
- find: exports.backtickInputRegex,
- type: this.type,
- getAttributes: (match) => ({
- language: match[1],
- }),
- }),
- (0, core_2.textblockTypeInputRule)({
- find: exports.tildeInputRegex,
- type: this.type,
- getAttributes: (match) => ({
- language: match[1],
- }),
- }),
- ];
- },
- addProseMirrorPlugins() {
- return [
- // this plugin creates a code block for pasted content from VS Code
- // we can also detect the copied code language
- new prosemirror_state_1.Plugin({
- key: new prosemirror_state_1.PluginKey("codeBlockVSCodeHandler"),
- props: {
- handlePaste: (view, event) => {
- if (!event.clipboardData) {
- return false;
- }
- const text = event.clipboardData.getData("text/plain");
- const vscode = event.clipboardData.getData("vscode-editor-data");
- const vscodeData = vscode ? JSON.parse(vscode) : undefined;
- const language = vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;
- if (!text || !language) {
- return false;
- }
- const indent = fixIndentation(text, parseIndentation(view.state.selection.$from.parent));
- const { tr } = view.state;
- // create an empty code block if not already within one
- if (!this.editor.isActive(this.type.name)) {
- tr.replaceSelectionWith(this.type.create({
- language,
- indentType: indent.type,
- indentLength: indent.amount,
- }));
- }
- // // put cursor inside the newly created code block
- // tr.setSelection(
- // TextSelection.near(
- // tr.doc.resolve(Math.max(0, tr.selection.from - 2))
- // )
- // );
- // add text to code block
- // strip carriage return chars from text pasted as code
- // see: https://github.com/ProseMirror/prosemirror-view/commit/a50a6bcceb4ce52ac8fcc6162488d8875613aacd
- tr.insertText(indent.code.replace(/\r\n?/g, "\n"));
- // store meta information
- // this is useful for other plugins that depends on the paste event
- // like the paste rule plugin
- tr.setMeta("paste", true);
- view.dispatch(tr);
- return true;
- },
- },
- }),
- (0, highlighter_1.HighlighterPlugin)({ name: this.name, defaultLanguage: "txt" }),
- ];
- },
- addNodeView() {
- return (0, react_1.createNodeView)(component_1.CodeblockComponent, {
- contentDOMFactory: () => {
- const content = document.createElement("div");
- content.classList.add("node-content-wrapper");
- content.style.whiteSpace = "inherit";
- // caret is not visible if content element width is 0px
- content.style.minWidth = `20px`;
- return { dom: content };
- },
- shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
- return (compareCaretPosition(prev.caretPosition, next.caretPosition) ||
- prev.language !== next.language ||
- prev.indentType !== next.indentType);
- },
- });
- },
-});
-function toCaretPosition(selection, lines) {
- const { $from, $to, $head } = selection;
- if ($from.parent.type.name !== exports.CodeBlock.name)
- return;
- lines = lines || getLines($from.parent);
- for (const line of lines) {
- if ($head.pos >= line.from && $head.pos <= line.to) {
- const lineLength = line.length + 1;
- return {
- line: line.index + 1,
- column: lineLength - (line.to - $head.pos),
- selected: $to.pos - $from.pos,
- total: lines.length,
- from: line.from,
- };
- }
- }
- return;
-}
-exports.toCaretPosition = toCaretPosition;
-function getLines(node) {
- const { lines } = node.attrs;
- return lines || [];
-}
-exports.getLines = getLines;
-function exitOnTripleEnter(editor, $from) {
- const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
- const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
- if (!isAtEnd || !endsWithDoubleNewline) {
- return false;
- }
- return editor
- .chain()
- .command(({ tr }) => {
- tr.delete($from.pos - 2, $from.pos);
- return true;
- })
- .exitCode()
- .run();
-}
-function indentOnEnter(editor, $from, options) {
- const { indentation, newline } = getNewline($from, options) || {};
- if (!newline)
- return false;
- return editor
- .chain()
- .insertContent(`${newline}${indentation}`, {
- parseOptions: { preserveWhitespace: "full" },
- })
- .focus()
- .run();
-}
-function getNewline($from, options) {
- const { lines } = $from.parent.attrs;
- const currentLine = getLineAt(lines, $from.pos);
- if (!currentLine)
- return false;
- const text = currentLine.text();
- const indentLength = text.length - text.trimStart().length;
- return {
- newline: NEWLINE,
- indentation: indent({ amount: indentLength, type: options.type }),
- };
-}
-function toCodeLines(code, pos) {
- const positions = [];
- let start = 0;
- let from = pos + 1;
- let index = 0;
- while (start <= code.length) {
- let end = code.indexOf("\n", start);
- if (end <= -1)
- end = code.length;
- const lineLength = end - start;
- const to = from + lineLength;
- const lineStart = start;
- positions.push({
- index,
- length: lineLength,
- from,
- to,
- text: (length) => {
- return code.slice(lineStart, length ? lineStart + length : lineStart + lineLength);
- },
- });
- from = to + 1;
- start = end + 1;
- ++index;
- }
- return positions;
-}
-exports.toCodeLines = toCodeLines;
-function getSelectedLines(lines, selection) {
- const { $from, $to } = selection;
- return lines.filter((line) => inRange(line.from, $from.pos, $to.pos) ||
- inRange(line.to, $from.pos, $to.pos) ||
- inRange($from.pos, line.from, line.to));
-}
-function parseIndentation(node) {
- if (node.type.name !== exports.CodeBlock.name)
- return undefined;
- const { indentType, indentLength } = node.attrs;
- return {
- type: indentType,
- amount: parseInt(indentLength),
- };
-}
-function getLineAt(lines, pos) {
- return lines.find((line) => pos >= line.from && pos <= line.to);
-}
-function inRange(x, a, b) {
- return x >= a && x <= b;
-}
-function indent(options) {
- const char = options.type === "space" ? " " : "\t";
- return char.repeat(options.amount);
-}
-function compareCaretPosition(prev, next) {
- return (next === undefined ||
- (prev === null || prev === void 0 ? void 0 : prev.column) !== (next === null || next === void 0 ? void 0 : next.column) ||
- (prev === null || prev === void 0 ? void 0 : prev.line) !== (next === null || next === void 0 ? void 0 : next.line));
-}
-/**
- * Persist selection between transaction steps
- */
-function withSelection(tr, callback) {
- const { $anchor, $head } = tr.selection;
- callback(tr);
- tr.setSelection(new prosemirror_state_1.TextSelection(tr.doc.resolve(tr.mapping.map($anchor.pos)), tr.doc.resolve(tr.mapping.map($head.pos))));
- return true;
-}
-function fixIndentation(code, indent) {
- const { amount, type = "space" } = indent || (0, detect_indent_1.default)(code);
- const fixed = (0, redent_1.default)(code, amount, {
- includeEmptyLines: false,
- indent: type === "space" ? " " : "\t",
- });
- return { code: (0, strip_indent_1.default)(fixed), amount, type };
-}
diff --git a/packages/editor/dist/cjs/extensions/codeblock/component.d.ts b/packages/editor/dist/cjs/extensions/codeblock/component.d.ts
deleted file mode 100644
index cb8de2a9a..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { CodeBlockAttributes } from "./code-block";
-import { ReactNodeViewProps } from "../react/types";
-export declare function CodeblockComponent(props: ReactNodeViewProps<CodeBlockAttributes>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/codeblock/component.js b/packages/editor/dist/cjs/extensions/codeblock/component.js
deleted file mode 100644
index d14db6862..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/component.js
+++ /dev/null
@@ -1,150 +0,0 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.CodeblockComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const loader_1 = require("./loader");
-const core_1 = require("refractor/lib/core");
-const rebass_1 = require("rebass");
-const languages_json_1 = __importDefault(require("./languages.json"));
-const forms_1 = require("@rebass/forms");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const responsive_1 = require("../../components/responsive");
-const popup_1 = require("../../toolbar/components/popup");
-const button_1 = require("../../components/button");
-function CodeblockComponent(props) {
- const { editor, updateAttributes, node, forwardRef } = props;
- const { language, indentLength, indentType, caretPosition } = node === null || node === void 0 ? void 0 : node.attrs;
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- // const [caretPosition, setCaretPosition] = useState<CaretPosition>();
- const toolbarRef = (0, react_1.useRef)(null);
- const languageDefinition = languages_json_1.default.find((l) => { var _a; return l.filename === language || ((_a = l.alias) === null || _a === void 0 ? void 0 : _a.some((a) => a === language)); });
- (0, react_1.useEffect)(() => {
- (function () {
- return __awaiter(this, void 0, void 0, function* () {
- if (!language || !languageDefinition || (0, loader_1.isLanguageLoaded)(language))
- return;
- const syntax = yield (0, loader_1.loadLanguage)(languageDefinition.filename);
- if (!syntax)
- return;
- core_1.refractor.register(syntax);
- const preventUpdate = language === languageDefinition.filename;
- updateAttributes({
- language: languageDefinition.filename
- }, { preventUpdate, addToHistory: false });
- });
- })();
- }, [language]);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- flexDirection: "column",
- borderRadius: "default",
- overflow: "hidden"
- } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, { ref: forwardRef, as: "pre", autoCorrect: "off", autoCapitalize: "none", sx: {
- "div, span.token, span.line-number-widget, span.line-number::before": {
- fontFamily: "monospace",
- fontSize: "code",
- whiteSpace: "pre !important",
- tabSize: 1
- },
- position: "relative",
- lineHeight: "20px",
- bg: "codeBg",
- color: "static",
- overflowX: "auto",
- display: "flex",
- px: 2,
- pt: 2,
- pb: 1
- }, spellCheck: false }), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ ref: toolbarRef, contentEditable: false, sx: {
- bg: "codeBg",
- alignItems: "center",
- justifyContent: "flex-end",
- borderTop: "1px solid var(--codeBorder)"
- } }, { children: [caretPosition ? ((0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "subBody", sx: { mr: 2, color: "codeFg" } }, { children: ["Line ", caretPosition.line, ", Column ", caretPosition.column, " ", caretPosition.selected
- ? `(${caretPosition.selected} selected)`
- : ""] }))) : null, (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ variant: "icon", sx: { p: 1, mr: 1, ":hover": { bg: "codeSelection" } }, title: "Toggle indentation mode", onClick: () => {
- editor.commands.changeCodeBlockIndentation({
- type: indentType === "space" ? "tab" : "space",
- amount: indentLength
- });
- } }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "subBody", sx: { color: "codeFg" } }, { children: [indentType === "space" ? "Spaces" : "Tabs", ": ", indentLength] })) })), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ variant: "icon", sx: {
- p: 1,
- mr: 1,
- bg: isOpen ? "codeSelection" : "transparent",
- ":hover": { bg: "codeSelection" }
- }, onClick: () => {
- setIsOpen(true);
- }, title: "Change language" }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "subBody", spellCheck: false, sx: { color: "codeFg" } }, { children: (languageDefinition === null || languageDefinition === void 0 ? void 0 : languageDefinition.title) || "Plaintext" })) }))] }))] })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: isOpen, onClose: () => {
- setIsOpen(false);
- // NOTE: for some reason the language selection action sheet
- // does not return focus to the last focused position after
- // closing. We have to set focusOnRender=false & manually
- // restore focus. I think this has something to do with custom
- // node views.
- // TRY: perhaps use SelectionBasedReactNodeView?
- editor.commands.focus();
- }, focusOnRender: false, mobile: "sheet", desktop: "menu", position: {
- target: toolbarRef.current || undefined,
- align: "end",
- isTargetAbsolute: true,
- location: "top",
- yOffset: 5
- }, title: "Change code block language" }, { children: (0, jsx_runtime_1.jsx)(LanguageSelector, { selectedLanguage: (languageDefinition === null || languageDefinition === void 0 ? void 0 : languageDefinition.filename) || "Plaintext", onLanguageSelected: (language) => {
- updateAttributes({ language }, { addToHistory: true, preventUpdate: false });
- setIsOpen(false);
- }, onClose: () => setIsOpen(false) }) }))] }));
-}
-exports.CodeblockComponent = CodeblockComponent;
-function LanguageSelector(props) {
- const { onLanguageSelected, selectedLanguage, onClose } = props;
- const [languages, setLanguages] = (0, react_1.useState)(languages_json_1.default);
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: "Select language", onClose: onClose }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- flexDirection: "column",
- height: 200,
- width: ["auto", 300],
- overflowY: "auto",
- bg: "background"
- } }, { children: [(0, jsx_runtime_1.jsx)(forms_1.Input, { onFocus: () => {
- console.log("EHLLO!");
- }, autoFocus: true, placeholder: "Search languages", sx: {
- width: "auto",
- position: "sticky",
- top: 0,
- bg: "background",
- mx: 2,
- p: "7px",
- zIndex: 999
- }, onChange: (e) => {
- if (!e.target.value)
- return setLanguages(languages_json_1.default);
- const query = e.target.value.toLowerCase();
- setLanguages(languages_json_1.default.filter((lang) => {
- var _a;
- return (lang.title.toLowerCase().indexOf(query) > -1 ||
- ((_a = lang.alias) === null || _a === void 0 ? void 0 : _a.some((alias) => alias.toLowerCase().indexOf(query) > -1)));
- }));
- } }), (0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- flexDirection: "column",
- pt: 1,
- mt: 1
- } }, { children: languages.map((lang) => ((0, jsx_runtime_1.jsxs)(button_1.Button, Object.assign({ variant: "menuitem", sx: {
- textAlign: "left",
- py: 1,
- display: "flex",
- justifyContent: "space-between",
- alignItems: "center"
- }, onClick: () => onLanguageSelected(lang.filename) }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "body" }, { children: lang.title })), selectedLanguage === lang.filename ? ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.check, size: "small" })) : lang.alias ? ((0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "subBody", sx: { fontSize: "10px" } }, { children: lang.alias.slice(0, 3).join(", ") }))) : null] }), lang.title))) }))] })) })));
-}
diff --git a/packages/editor/dist/cjs/extensions/codeblock/highlighter.d.ts b/packages/editor/dist/cjs/extensions/codeblock/highlighter.d.ts
deleted file mode 100644
index e42464534..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/highlighter.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Plugin } from "prosemirror-state";
-import { DecorationSet } from "prosemirror-view";
-import { AddMarkStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
-export declare type MergedStep = AddMarkStep | RemoveMarkStep | ReplaceAroundStep | ReplaceStep;
-export declare function HighlighterPlugin({ name, defaultLanguage, }: {
- name: string;
- defaultLanguage: string | null | undefined;
-}): Plugin<DecorationSet>;
diff --git a/packages/editor/dist/cjs/extensions/codeblock/highlighter.js b/packages/editor/dist/cjs/extensions/codeblock/highlighter.js
deleted file mode 100644
index ead12449e..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/highlighter.js
+++ /dev/null
@@ -1,195 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.HighlighterPlugin = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-const prosemirror_view_1 = require("prosemirror-view");
-const core_1 = require("@tiptap/core");
-const core_2 = require("refractor/lib/core");
-const codeblock_1 = require("./codeblock");
-function parseNodes(nodes, className = []) {
- return nodes.reduce((result, node) => {
- if (node.type === "comment" || node.type === "doctype")
- return result;
- const classes = [...className];
- if (node.type === "element" && node.properties)
- classes.push(...node.properties.className);
- // this is required so that even plain text is wrapped in a span
- // during highlighting. Without this, Prosemirror's selection acts
- // weird for the first highlighted node/span.
- else
- classes.push("token", "text");
- if (node.type === "element") {
- result.push(...parseNodes(node.children, classes));
- }
- else {
- result.push({ classes, text: node.value });
- }
- return result;
- }, []);
-}
-function getHighlightNodes(result) {
- return result.children || [];
-}
-function getLineDecoration(from, line, total, isActive) {
- const maxLength = String(total).length;
- const attributes = {
- class: `line-number ${isActive ? "active" : ""}`,
- "data-line": String(line).padEnd(maxLength, " "),
- };
- const spec = {
- line: line,
- active: isActive,
- total,
- from,
- };
- return prosemirror_view_1.Decoration.inline(from, from + 1, attributes, spec);
-}
-function getDecorations({ doc, name, defaultLanguage, caretPosition, }) {
- const decorations = [];
- const languages = core_2.refractor.listLanguages();
- (0, core_1.findChildren)(doc, (node) => node.type.name === name).forEach((block) => {
- const code = block.node.textContent;
- const lines = (0, codeblock_1.toCodeLines)(code, block.pos);
- for (const line of lines || []) {
- const lineNumber = line.index + 1;
- const isActive = lineNumber === (caretPosition === null || caretPosition === void 0 ? void 0 : caretPosition.line) && line.from === (caretPosition === null || caretPosition === void 0 ? void 0 : caretPosition.from);
- const decoration = getLineDecoration(line.from, lineNumber, (lines === null || lines === void 0 ? void 0 : lines.length) || 0, isActive);
- decorations.push(decoration);
- }
- const language = block.node.attrs.language || defaultLanguage;
- const nodes = languages.includes(language)
- ? getHighlightNodes(core_2.refractor.highlight(code, language))
- : null;
- if (!nodes)
- return;
- let from = block.pos + 1;
- parseNodes(nodes).forEach((node) => {
- const to = from + node.text.length;
- if (node.classes.length) {
- const decoration = prosemirror_view_1.Decoration.inline(from, to, {
- class: node.classes.join(" "),
- });
- decorations.push(decoration);
- }
- from = to;
- });
- });
- return prosemirror_view_1.DecorationSet.create(doc, decorations);
-}
-function HighlighterPlugin({ name, defaultLanguage, }) {
- const key = new prosemirror_state_1.PluginKey("highlighter");
- return new prosemirror_state_1.Plugin({
- key,
- state: {
- init: (config, state) => {
- return getDecorations({
- doc: state.doc,
- name,
- defaultLanguage,
- });
- },
- apply: (transaction, decorationSet, oldState, newState) => {
- const oldNodeName = oldState.selection.$head.parent.type.name;
- const newNodeName = newState.selection.$head.parent.type.name;
- const oldNodes = (0, core_1.findChildren)(oldState.doc, (node) => node.type.name === name);
- const newNodes = (0, core_1.findChildren)(newState.doc, (node) => node.type.name === name);
- const position = (0, codeblock_1.toCaretPosition)(newState.selection);
- // const isDocChanged =
- // transaction.docChanged &&
- // // TODO
- // !transaction.steps.every((step) => step instanceof ReplaceAroundStep);
- // console.log("Selection", transaction.docChanged, isDocChanged);
- if (transaction.docChanged &&
- // Apply decorations if:
- // selection includes named node,
- ([oldNodeName, newNodeName].includes(name) ||
- // OR transaction adds/removes named node,
- newNodes.length !== oldNodes.length ||
- // OR transaction has changes that completely encapsulte a node
- // (for example, a transaction that affects the entire document).
- // Such transactions can happen during collab syncing via y-prosemirror, for example.
- transaction.steps.some((step) => {
- return (step.from !== undefined &&
- step.to !== undefined &&
- oldNodes.some((node) => {
- return (node.pos >= step.from &&
- node.pos + node.node.nodeSize <= step.to);
- }));
- }))) {
- return getDecorations({
- doc: transaction.doc,
- name,
- defaultLanguage,
- caretPosition: position,
- });
- }
- decorationSet = getActiveLineDecorations(transaction.doc, decorationSet, position);
- return decorationSet.map(transaction.mapping, transaction.doc);
- },
- },
- props: {
- decorations(state) {
- return key.getState(state);
- },
- },
- appendTransaction: (transactions, prevState, nextState) => {
- const tr = nextState.tr;
- let modified = false;
- const docChanged = transactions.some((transaction) => transaction.docChanged);
- const selectionChanged = (nextState.selection.$from.parent.type.name === name ||
- prevState.selection.$from.parent.type.name === name) &&
- prevState.selection.$from.pos !== nextState.selection.$from.pos;
- (0, core_1.findChildren)(nextState.doc, (node) => node.type.name === name).forEach((block) => {
- var _a;
- const { node, pos } = block;
- const attributes = Object.assign({}, node.attrs);
- if (docChanged || !((_a = attributes.lines) === null || _a === void 0 ? void 0 : _a.length)) {
- const lines = (0, codeblock_1.toCodeLines)(node.textContent, pos);
- attributes.lines = lines.slice();
- }
- if (selectionChanged) {
- const position = (0, codeblock_1.toCaretPosition)(nextState.selection, docChanged ? (0, codeblock_1.toCodeLines)(node.textContent, pos) : undefined);
- attributes.caretPosition = position;
- }
- if (docChanged || selectionChanged) {
- tr.setNodeMarkup(pos, node.type, attributes);
- modified = true;
- }
- });
- return modified ? tr : null;
- },
- });
-}
-exports.HighlighterPlugin = HighlighterPlugin;
-/**
- * When `position` is undefined, all active line decorations
- * are reset (e.g. when you focus out of the code block).
- */
-function getActiveLineDecorations(doc, decorations, position) {
- const lineDecorations = decorations.find(undefined, undefined, ({ line, active, from }) => {
- const isSame = position
- ? line === position.line && from === position.from
- : false;
- return isSame || active;
- });
- if (!lineDecorations.length)
- return decorations;
- // we have to clone because prosemirror operates in-place
- const cloned = lineDecorations.slice();
- // remove old line decorations which inclue the current line decoration
- // and the previous current line decoration. We'll replace these with
- // new decorations.
- decorations = decorations.remove(lineDecorations);
- const newDecorations = [];
- for (const decoration of cloned) {
- const { from, spec: { line, total }, } = decoration;
- const isActive = line === (position === null || position === void 0 ? void 0 : position.line);
- const newDecoration = getLineDecoration(from, line, (position === null || position === void 0 ? void 0 : position.total) || total, isActive);
- newDecorations.push(newDecoration);
- }
- return decorations.add(doc, newDecorations);
-}
-function isAndroid() {
- var ua = navigator.userAgent.toLowerCase();
- return ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
-}
diff --git a/packages/editor/dist/cjs/extensions/codeblock/index.d.ts b/packages/editor/dist/cjs/extensions/codeblock/index.d.ts
deleted file mode 100644
index 80ea37c7c..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./code-block";
diff --git a/packages/editor/dist/cjs/extensions/codeblock/index.js b/packages/editor/dist/cjs/extensions/codeblock/index.js
deleted file mode 100644
index 63156ab53..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./codeblock"), exports);
diff --git a/packages/editor/dist/cjs/extensions/codeblock/languages.json b/packages/editor/dist/cjs/extensions/codeblock/languages.json
deleted file mode 100644
index d932b9f77..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/languages.json
+++ /dev/null
@@ -1 +0,0 @@
-[{ "filename": "markup", "title": "Markup", "alias": ["html", "xml", "svg", "mathml", "ssml", "atom", "rss"] }, { "filename": "css", "title": "CSS" }, { "filename": "clike", "title": "C-like" }, { "filename": "javascript", "title": "JavaScript", "alias": ["js"] }, { "filename": "abap", "title": "ABAP" }, { "filename": "abnf", "title": "ABNF" }, { "filename": "actionscript", "title": "ActionScript" }, { "filename": "ada", "title": "Ada" }, { "filename": "agda", "title": "Agda" }, { "filename": "al", "title": "AL" }, { "filename": "antlr4", "title": "ANTLR4", "alias": ["g4"] }, { "filename": "apacheconf", "title": "Apache Configuration" }, { "filename": "apex", "title": "Apex" }, { "filename": "apl", "title": "APL" }, { "filename": "applescript", "title": "AppleScript" }, { "filename": "aql", "title": "AQL" }, { "filename": "arduino", "title": "Arduino", "alias": ["ino"] }, { "filename": "arff", "title": "ARFF" }, { "filename": "armasm", "title": "ARM Assembly", "alias": ["arm-asm"] }, { "filename": "arturo", "title": "Arturo", "alias": ["art"] }, { "filename": "asciidoc", "title": "AsciiDoc", "alias": ["adoc"] }, { "filename": "aspnet", "title": "ASP.NET (C#)" }, { "filename": "asm6502", "title": "6502 Assembly" }, { "filename": "asmatmel", "title": "Atmel AVR Assembly" }, { "filename": "autohotkey", "title": "AutoHotkey" }, { "filename": "autoit", "title": "AutoIt" }, { "filename": "avisynth", "title": "AviSynth", "alias": ["avs"] }, { "filename": "avro-idl", "title": "Avro IDL", "alias": ["avdl"] }, { "filename": "awk", "title": "AWK", "alias": ["gawk"] }, { "filename": "bash", "title": "Bash", "alias": ["shell"] }, { "filename": "basic", "title": "BASIC" }, { "filename": "batch", "title": "Batch" }, { "filename": "bbcode", "title": "BBcode", "alias": ["shortcode"] }, { "filename": "bicep", "title": "Bicep" }, { "filename": "birb", "title": "Birb" }, { "filename": "bison", "title": "Bison" }, { "filename": "bnf", "title": "BNF", "alias": ["rbnf"] }, { "filename": "brainfuck", "title": "Brainfuck" }, { "filename": "brightscript", "title": "BrightScript" }, { "filename": "bro", "title": "Bro" }, { "filename": "bsl", "title": "BSL (1C:Enterprise)", "alias": ["oscript"] }, { "filename": "c", "title": "C" }, { "filename": "csharp", "title": "C#", "alias": ["cs", "dotnet"] }, { "filename": "cpp", "title": "C++" }, { "filename": "cfscript", "title": "CFScript", "alias": ["cfc"] }, { "filename": "chaiscript", "title": "ChaiScript" }, { "filename": "cil", "title": "CIL" }, { "filename": "clojure", "title": "Clojure" }, { "filename": "cmake", "title": "CMake" }, { "filename": "cobol", "title": "COBOL" }, { "filename": "coffeescript", "title": "CoffeeScript", "alias": ["coffee"] }, { "filename": "concurnas", "title": "Concurnas", "alias": ["conc"] }, { "filename": "csp", "title": "Content-Security-Policy" }, { "filename": "cooklang", "title": "Cooklang" }, { "filename": "coq", "title": "Coq" }, { "filename": "crystal", "title": "Crystal" }, { "filename": "css-extras", "title": "CSS Extras" }, { "filename": "csv", "title": "CSV" }, { "filename": "cue", "title": "CUE" }, { "filename": "cypher", "title": "Cypher" }, { "filename": "d", "title": "D" }, { "filename": "dart", "title": "Dart" }, { "filename": "dataweave", "title": "DataWeave" }, { "filename": "dax", "title": "DAX" }, { "filename": "dhall", "title": "Dhall" }, { "filename": "diff", "title": "Diff" }, { "filename": "django", "title": "Django/Jinja2", "alias": ["jinja2"] }, { "filename": "dns-zone-file", "title": "DNS zone file", "alias": ["dns-zone"] }, { "filename": "docker", "title": "Docker", "alias": ["dockerfile"] }, { "filename": "dot", "title": "DOT (Graphviz)", "alias": ["gv"] }, { "filename": "ebnf", "title": "EBNF" }, { "filename": "editorconfig", "title": "EditorConfig" }, { "filename": "eiffel", "title": "Eiffel" }, { "filename": "ejs", "title": "EJS", "alias": ["eta"] }, { "filename": "elixir", "title": "Elixir" }, { "filename": "elm", "title": "Elm" }, { "filename": "etlua", "title": "Embedded Lua templating" }, { "filename": "erb", "title": "ERB" }, { "filename": "erlang", "title": "Erlang" }, { "filename": "excel-formula", "title": "Excel Formula", "alias": ["xlsx", "xls"] }, { "filename": "fsharp", "title": "F#" }, { "filename": "factor", "title": "Factor" }, { "filename": "false", "title": "False" }, { "filename": "firestore-security-rules", "title": "Firestore security rules" }, { "filename": "flow", "title": "Flow" }, { "filename": "fortran", "title": "Fortran" }, { "filename": "ftl", "title": "FreeMarker Template Language" }, { "filename": "gml", "title": "GameMaker Language", "alias": ["gamemakerlanguage"] }, { "filename": "gap", "title": "GAP (CAS)" }, { "filename": "gcode", "title": "G-code" }, { "filename": "gdscript", "title": "GDScript" }, { "filename": "gedcom", "title": "GEDCOM" }, { "filename": "gettext", "title": "gettext", "alias": ["po"] }, { "filename": "gherkin", "title": "Gherkin" }, { "filename": "git", "title": "Git" }, { "filename": "glsl", "title": "GLSL" }, { "filename": "gn", "title": "GN", "alias": ["gni"] }, { "filename": "linker-script", "title": "GNU Linker Script", "alias": ["ld"] }, { "filename": "go", "title": "Go" }, { "filename": "go-module", "title": "Go module", "alias": ["go-mod"] }, { "filename": "gradle", "title": "Gradle" }, { "filename": "graphql", "title": "GraphQL" }, { "filename": "groovy", "title": "Groovy" }, { "filename": "haml", "title": "Haml" }, { "filename": "handlebars", "title": "Handlebars", "alias": ["hbs", "mustache"] }, { "filename": "haskell", "title": "Haskell", "alias": ["hs"] }, { "filename": "haxe", "title": "Haxe" }, { "filename": "hcl", "title": "HCL" }, { "filename": "hlsl", "title": "HLSL" }, { "filename": "hoon", "title": "Hoon" }, { "filename": "http", "title": "HTTP" }, { "filename": "hpkp", "title": "HTTP Public-Key-Pins" }, { "filename": "hsts", "title": "HTTP Strict-Transport-Security" }, { "filename": "ichigojam", "title": "IchigoJam" }, { "filename": "icon", "title": "Icon" }, { "filename": "icu-message-format", "title": "ICU Message Format" }, { "filename": "idris", "title": "Idris", "alias": ["idr"] }, { "filename": "ignore", "title": ".ignore", "alias": ["gitignore", "hgignore", "npmignore"] }, { "filename": "inform7", "title": "Inform 7" }, { "filename": "ini", "title": "Ini" }, { "filename": "io", "title": "Io" }, { "filename": "j", "title": "J" }, { "filename": "java", "title": "Java" }, { "filename": "javadoc", "title": "JavaDoc" }, { "filename": "javadoclike", "title": "JavaDoc-like" }, { "filename": "javastacktrace", "title": "Java stack trace" }, { "filename": "jexl", "title": "Jexl" }, { "filename": "jolie", "title": "Jolie" }, { "filename": "jq", "title": "JQ" }, { "filename": "jsdoc", "title": "JSDoc" }, { "filename": "js-extras", "title": "JS Extras" }, { "filename": "json", "title": "JSON", "alias": ["webmanifest"] }, { "filename": "json5", "title": "JSON5" }, { "filename": "jsonp", "title": "JSONP" }, { "filename": "jsstacktrace", "title": "JS stack trace" }, { "filename": "js-templates", "title": "JS Templates" }, { "filename": "julia", "title": "Julia" }, { "filename": "keepalived", "title": "Keepalived Configure" }, { "filename": "keyman", "title": "Keyman" }, { "filename": "kotlin", "title": "Kotlin", "alias": ["kt", "kts"] }, { "filename": "kumir", "title": "KuMir (КуМир)", "alias": ["kum"] }, { "filename": "kusto", "title": "Kusto" }, { "filename": "latex", "title": "LaTeX", "alias": ["tex", "context"] }, { "filename": "latte", "title": "Latte" }, { "filename": "less", "title": "Less" }, { "filename": "lilypond", "title": "LilyPond", "alias": ["ly"] }, { "filename": "liquid", "title": "Liquid" }, { "filename": "lisp", "title": "Lisp", "alias": ["emacs", "elisp", "emacs-lisp"] }, { "filename": "livescript", "title": "LiveScript" }, { "filename": "llvm", "title": "LLVM IR" }, { "filename": "log", "title": "Log file" }, { "filename": "lolcode", "title": "LOLCODE" }, { "filename": "lua", "title": "Lua" }, { "filename": "magma", "title": "Magma (CAS)" }, { "filename": "makefile", "title": "Makefile" }, { "filename": "markdown", "title": "Markdown", "alias": ["md"] }, { "filename": "markup-templating", "title": "Markup templating" }, { "filename": "mata", "title": "Mata" }, { "filename": "matlab", "title": "MATLAB" }, { "filename": "maxscript", "title": "MAXScript" }, { "filename": "mel", "title": "MEL" }, { "filename": "mermaid", "title": "Mermaid" }, { "filename": "mizar", "title": "Mizar" }, { "filename": "mongodb", "title": "MongoDB" }, { "filename": "monkey", "title": "Monkey" }, { "filename": "moonscript", "title": "MoonScript", "alias": ["moon"] }, { "filename": "n1ql", "title": "N1QL" }, { "filename": "n4js", "title": "N4JS", "alias": ["n4jsd"] }, { "filename": "nand2tetris-hdl", "title": "Nand To Tetris HDL" }, { "filename": "naniscript", "title": "Naninovel Script", "alias": ["nani"] }, { "filename": "nasm", "title": "NASM" }, { "filename": "neon", "title": "NEON" }, { "filename": "nevod", "title": "Nevod" }, { "filename": "nginx", "title": "nginx" }, { "filename": "nim", "title": "Nim" }, { "filename": "nix", "title": "Nix" }, { "filename": "nsis", "title": "NSIS" }, { "filename": "objectivec", "title": "Objective-C", "alias": ["objc"] }, { "filename": "ocaml", "title": "OCaml" }, { "filename": "odin", "title": "Odin" }, { "filename": "opencl", "title": "OpenCL" }, { "filename": "openqasm", "title": "OpenQasm", "alias": ["qasm"] }, { "filename": "oz", "title": "Oz" }, { "filename": "parigp", "title": "PARI/GP" }, { "filename": "parser", "title": "Parser" }, { "filename": "pascal", "title": "Pascal", "alias": ["objectpascal"] }, { "filename": "pascaligo", "title": "Pascaligo" }, { "filename": "psl", "title": "PATROL Scripting Language" }, { "filename": "pcaxis", "title": "PC-Axis", "alias": ["px"] }, { "filename": "peoplecode", "title": "PeopleCode", "alias": ["pcode"] }, { "filename": "perl", "title": "Perl" }, { "filename": "php", "title": "PHP" }, { "filename": "phpdoc", "title": "PHPDoc" }, { "filename": "php-extras", "title": "PHP Extras" }, { "filename": "plant-uml", "title": "PlantUML", "alias": ["plantuml"] }, { "filename": "plsql", "title": "PL/SQL" }, { "filename": "powerquery", "title": "PowerQuery", "alias": ["pq", "mscript"] }, { "filename": "powershell", "title": "PowerShell" }, { "filename": "processing", "title": "Processing" }, { "filename": "prolog", "title": "Prolog" }, { "filename": "promql", "title": "PromQL" }, { "filename": "properties", "title": ".properties" }, { "filename": "protobuf", "title": "Protocol Buffers" }, { "filename": "pug", "title": "Pug" }, { "filename": "puppet", "title": "Puppet" }, { "filename": "pure", "title": "Pure" }, { "filename": "purebasic", "title": "PureBasic", "alias": ["pbfasm"] }, { "filename": "purescript", "title": "PureScript", "alias": ["purs"] }, { "filename": "python", "title": "Python", "alias": ["py"] }, { "filename": "qsharp", "title": "Q#", "alias": ["qs"] }, { "filename": "q", "title": "Q (kdb+ database)" }, { "filename": "qml", "title": "QML" }, { "filename": "qore", "title": "Qore" }, { "filename": "r", "title": "R" }, { "filename": "racket", "title": "Racket", "alias": ["rkt"] }, { "filename": "cshtml", "title": "Razor C#", "alias": ["razor"] }, { "filename": "jsx", "title": "React JSX" }, { "filename": "tsx", "title": "React TSX" }, { "filename": "reason", "title": "Reason" }, { "filename": "regex", "title": "Regex" }, { "filename": "rego", "title": "Rego" }, { "filename": "renpy", "title": "Ren'py", "alias": ["rpy"] }, { "filename": "rescript", "title": "ReScript", "alias": ["res"] }, { "filename": "rest", "title": "reST (reStructuredText)" }, { "filename": "rip", "title": "Rip" }, { "filename": "roboconf", "title": "Roboconf" }, { "filename": "robotframework", "title": "Robot Framework", "alias": ["robot"] }, { "filename": "ruby", "title": "Ruby", "alias": ["rb"] }, { "filename": "rust", "title": "Rust" }, { "filename": "sas", "title": "SAS" }, { "filename": "sass", "title": "Sass (Sass)" }, { "filename": "scss", "title": "Sass (Scss)" }, { "filename": "scala", "title": "Scala" }, { "filename": "scheme", "title": "Scheme" }, { "filename": "shell-session", "title": "Shell session", "alias": ["sh-session", "shellsession"] }, { "filename": "smali", "title": "Smali" }, { "filename": "smalltalk", "title": "Smalltalk" }, { "filename": "smarty", "title": "Smarty" }, { "filename": "sml", "title": "SML", "alias": ["smlnj"] }, { "filename": "solidity", "title": "Solidity (Ethereum)", "alias": ["sol"] }, { "filename": "solution-file", "title": "Solution file", "alias": ["sln"] }, { "filename": "soy", "title": "Soy (Closure Template)" }, { "filename": "sparql", "title": "SPARQL", "alias": ["rq"] }, { "filename": "splunk-spl", "title": "Splunk SPL" }, { "filename": "sqf", "title": "SQF: Status Quo Function (Arma 3)" }, { "filename": "sql", "title": "SQL" }, { "filename": "squirrel", "title": "Squirrel" }, { "filename": "stan", "title": "Stan" }, { "filename": "stata", "title": "Stata Ado" }, { "filename": "iecst", "title": "Structured Text (IEC 61131-3)" }, { "filename": "stylus", "title": "Stylus" }, { "filename": "supercollider", "title": "SuperCollider", "alias": ["sclang"] }, { "filename": "swift", "title": "Swift" }, { "filename": "systemd", "title": "Systemd configuration file" }, { "filename": "t4-templating", "title": "T4 templating" }, { "filename": "t4-cs", "title": "T4 Text Templates (C#)", "alias": ["t4"] }, { "filename": "t4-vb", "title": "T4 Text Templates (VB)" }, { "filename": "tap", "title": "TAP" }, { "filename": "tcl", "title": "Tcl" }, { "filename": "tt2", "title": "Template Toolkit 2" }, { "filename": "textile", "title": "Textile" }, { "filename": "toml", "title": "TOML" }, { "filename": "tremor", "title": "Tremor", "alias": ["trickle", "troy"] }, { "filename": "turtle", "title": "Turtle", "alias": ["trig"] }, { "filename": "twig", "title": "Twig" }, { "filename": "typescript", "title": "TypeScript", "alias": ["ts"] }, { "filename": "typoscript", "title": "TypoScript", "alias": ["tsconfig"] }, { "filename": "unrealscript", "title": "UnrealScript", "alias": ["uscript", "uc"] }, { "filename": "uorazor", "title": "UO Razor Script" }, { "filename": "uri", "title": "URI", "alias": ["url"] }, { "filename": "v", "title": "V" }, { "filename": "vala", "title": "Vala" }, { "filename": "vbnet", "title": "VB.Net" }, { "filename": "velocity", "title": "Velocity" }, { "filename": "verilog", "title": "Verilog" }, { "filename": "vhdl", "title": "VHDL" }, { "filename": "vim", "title": "vim" }, { "filename": "visual-basic", "title": "Visual Basic", "alias": ["vb", "vba"] }, { "filename": "warpscript", "title": "WarpScript" }, { "filename": "wasm", "title": "WebAssembly" }, { "filename": "web-idl", "title": "Web IDL", "alias": ["webidl"] }, { "filename": "wgsl", "title": "WGSL" }, { "filename": "wiki", "title": "Wiki markup" }, { "filename": "wolfram", "title": "Wolfram language", "alias": ["mathematica", "nb", "wl"] }, { "filename": "wren", "title": "Wren" }, { "filename": "xeora", "title": "Xeora", "alias": ["xeoracube"] }, { "filename": "xml-doc", "title": "XML doc (.net)" }, { "filename": "xojo", "title": "Xojo (REALbasic)" }, { "filename": "xquery", "title": "XQuery" }, { "filename": "yaml", "title": "YAML", "alias": ["yml"] }, { "filename": "yang", "title": "YANG" }, { "filename": "zig", "title": "Zig" }]
diff --git a/packages/editor/dist/cjs/extensions/codeblock/loader.d.ts b/packages/editor/dist/cjs/extensions/codeblock/loader.d.ts
deleted file mode 100644
index 5162f1715..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/loader.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export declare function isLanguageLoaded(name: string): boolean;
-export declare function loadLanguage(shortName: string): Promise<import("refractor/lib/core").Syntax | undefined>;
diff --git a/packages/editor/dist/cjs/extensions/codeblock/loader.js b/packages/editor/dist/cjs/extensions/codeblock/loader.js
deleted file mode 100644
index d889fa1e7..000000000
--- a/packages/editor/dist/cjs/extensions/codeblock/loader.js
+++ /dev/null
@@ -1,50 +0,0 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.loadLanguage = exports.isLanguageLoaded = void 0;
-const loadedLanguages = {};
-function isLanguageLoaded(name) {
- return !!loadedLanguages[name];
-}
-exports.isLanguageLoaded = isLanguageLoaded;
-function loadLanguage(shortName) {
- return __awaiter(this, void 0, void 0, function* () {
- if (loadedLanguages[shortName])
- return loadedLanguages[shortName];
- const url = `https://esm.sh/[email protected]/lang/${shortName}.js?bundle=true`;
- const result = yield loadScript(shortName, url);
- loadedLanguages[shortName] = result;
- return result;
- });
-}
-exports.loadLanguage = loadLanguage;
-function loadScript(id, url) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- const callbackName = `on${id}Loaded`;
- const script = document.createElement("script");
- script.type = "module";
- script.innerHTML = `
- import LanguageDefinition from "${url}";
- if (window["${callbackName}"]) {
- window["${callbackName}"](LanguageDefinition)
- }
-`;
- window[callbackName] = (lang) => {
- script.remove();
- window[callbackName] = null;
- resolve(lang);
- };
- // Append to the `head` element
- document.head.appendChild(script);
- });
- });
-}
diff --git a/packages/editor/dist/cjs/extensions/codemark/codemark.d.ts b/packages/editor/dist/cjs/extensions/codemark/codemark.d.ts
deleted file mode 100644
index 003c47b2f..000000000
--- a/packages/editor/dist/cjs/extensions/codemark/codemark.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { Extension } from "@tiptap/core";
-export declare const Codemark: Extension<any, any>;
diff --git a/packages/editor/dist/cjs/extensions/codemark/codemark.js b/packages/editor/dist/cjs/extensions/codemark/codemark.js
deleted file mode 100644
index d4cc94490..000000000
--- a/packages/editor/dist/cjs/extensions/codemark/codemark.js
+++ /dev/null
@@ -1,14 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Codemark = void 0;
-const core_1 = require("@tiptap/core");
-const prosemirror_codemark_1 = __importDefault(require("prosemirror-codemark"));
-exports.Codemark = core_1.Extension.create({
- name: "codemarkPlugin",
- addProseMirrorPlugins() {
- return (0, prosemirror_codemark_1.default)({ markType: this.editor.schema.marks.code });
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/codemark/index.d.ts b/packages/editor/dist/cjs/extensions/codemark/index.d.ts
deleted file mode 100644
index 8c4911b98..000000000
--- a/packages/editor/dist/cjs/extensions/codemark/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./code-mark";
-export { Codemark as default } from "./code-mark";
diff --git a/packages/editor/dist/cjs/extensions/codemark/index.js b/packages/editor/dist/cjs/extensions/codemark/index.js
deleted file mode 100644
index 402f6b358..000000000
--- a/packages/editor/dist/cjs/extensions/codemark/index.js
+++ /dev/null
@@ -1,20 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.default = void 0;
-__exportStar(require("./codemark"), exports);
-var codemark_1 = require("./codemark");
-Object.defineProperty(exports, "default", { enumerable: true, get: function () { return codemark_1.Codemark; } });
diff --git a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.d.ts b/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.d.ts
deleted file mode 100644
index 5901f57f7..000000000
--- a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Extension } from "@tiptap/core";
-export interface DropcursorOptions {
- color?: string | null;
- width?: number | null;
- class?: string | null;
-}
-export declare const Dropcursor: Extension<DropcursorOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.js b/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.js
deleted file mode 100644
index a35f092a1..000000000
--- a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.js
+++ /dev/null
@@ -1,18 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Dropcursor = void 0;
-const core_1 = require("@tiptap/core");
-const dropcursor_pm_1 = require("./dropcursor.pm");
-exports.Dropcursor = core_1.Extension.create({
- name: "dropCursor",
- addOptions() {
- return {
- color: "currentColor",
- width: 1,
- class: null,
- };
- },
- addProseMirrorPlugins() {
- return [(0, dropcursor_pm_1.dropCursor)(this.options)];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.pm.d.ts b/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.pm.d.ts
deleted file mode 100644
index 169767489..000000000
--- a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.pm.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Plugin } from "prosemirror-state";
-import { DropcursorOptions } from "./drop-cursor";
-export declare function dropCursor(options?: DropcursorOptions): Plugin<any>;
diff --git a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.pm.js b/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.pm.js
deleted file mode 100644
index fe07d9ded..000000000
--- a/packages/editor/dist/cjs/extensions/dropcursor/dropcursor.pm.js
+++ /dev/null
@@ -1,173 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.dropCursor = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-const prosemirror_transform_1 = require("prosemirror-transform");
-// :: (options: ?Object) → Plugin
-// Create a plugin that, when added to a ProseMirror instance,
-// causes a decoration to show up at the drop position when something
-// is dragged over the editor.
-//
-// Nodes may add a `disableDropCursor` property to their spec to
-// control the showing of a drop cursor inside them. This may be a
-// boolean or a function, which will be called with a view and a
-// position, and should return a boolean.
-//
-// options::- These options are supported:
-//
-// color:: ?string
-// The color of the cursor. Defaults to `black`.
-//
-// width:: ?number
-// The precise width of the cursor in pixels. Defaults to 1.
-//
-// class:: ?string
-// A CSS class name to add to the cursor element.
-function dropCursor(options = {}) {
- return new prosemirror_state_1.Plugin({
- view(editorView) {
- return new DropCursorView(editorView, options);
- },
- });
-}
-exports.dropCursor = dropCursor;
-class DropCursorView {
- constructor(editorView, options) {
- this.editorView = editorView;
- this.width = options.width || 1;
- this.color = options.color || "black";
- this.class = options.class || "";
- this.cursorPos = null;
- this.element = null;
- this.timeout = null;
- this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((name) => {
- let handler = (e) => this[name](e);
- editorView.dom.addEventListener(name, handler);
- return { name, handler };
- });
- }
- destroy() {
- this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
- }
- update(editorView, prevState) {
- if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
- if (this.cursorPos > editorView.state.doc.content.size)
- this.setCursor(null);
- else
- this.updateOverlay();
- }
- }
- setCursor(pos) {
- if (pos == this.cursorPos)
- return;
- this.cursorPos = pos;
- if (pos == null && this.element && this.element.parentNode) {
- this.element.parentNode.removeChild(this.element);
- this.element = null;
- }
- else {
- this.updateOverlay();
- }
- }
- updateOverlay() {
- if (!this.cursorPos)
- return;
- let $pos = this.editorView.state.doc.resolve(this.cursorPos), rect;
- if (!$pos.parent.inlineContent) {
- let before = $pos.nodeBefore, after = $pos.nodeAfter;
- if (before || after) {
- const node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
- if (!node)
- return;
- let nodeRect = node.getBoundingClientRect();
- let top = before ? nodeRect.bottom : nodeRect.top;
- if (before && after) {
- const cursor = this.editorView.nodeDOM(this.cursorPos);
- if (!cursor)
- return;
- top = (top + cursor.getBoundingClientRect().top) / 2;
- }
- rect = {
- left: nodeRect.left,
- right: nodeRect.right,
- top: top - this.width / 2,
- bottom: top + this.width / 2,
- };
- }
- }
- if (!rect) {
- let coords = this.editorView.coordsAtPos(this.cursorPos);
- rect = {
- left: coords.left - this.width / 2,
- right: coords.left + this.width / 2,
- top: coords.top,
- bottom: coords.bottom,
- };
- }
- let parent = this.editorView.dom.offsetParent;
- if (!this.element && parent) {
- this.element = parent.appendChild(document.createElement("div"));
- if (this.class)
- this.element.className = this.class;
- this.element.style.cssText =
- "position: absolute; z-index: 50; pointer-events: none; background-color: " +
- this.color;
- }
- let parentLeft, parentTop;
- if (!parent ||
- (parent == document.body && getComputedStyle(parent).position == "static")) {
- parentLeft = -pageXOffset;
- parentTop = -pageYOffset;
- }
- else {
- let rect = parent.getBoundingClientRect();
- parentLeft = rect.left - parent.scrollLeft;
- parentTop = rect.top - parent.scrollTop;
- }
- if (!this.element)
- return;
- this.element.style.left = rect.left - parentLeft + "px";
- this.element.style.top = rect.top - parentTop + "px";
- this.element.style.width = rect.right - rect.left + "px";
- this.element.style.height = rect.bottom - rect.top + "px";
- }
- scheduleRemoval(timeout) {
- clearTimeout(this.timeout || undefined);
- this.timeout = (setTimeout(() => this.setCursor(null), timeout));
- }
- dragover(event) {
- if (!this.editorView.editable)
- return;
- let pos = this.editorView.posAtCoords({
- left: event.clientX,
- top: event.clientY,
- });
- let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
- let disableDropCursor = node && node.type.spec.disableDropCursor;
- let disabled = typeof disableDropCursor == "function"
- ? disableDropCursor(this.editorView, pos)
- : disableDropCursor;
- if (pos && !disabled) {
- let target = pos.pos;
- if (this.editorView.dragging && this.editorView.dragging.slice) {
- const point = (0, prosemirror_transform_1.dropPoint)(this.editorView.state.doc, target, this.editorView.dragging.slice);
- if (!point)
- return this.setCursor(null);
- target = point;
- }
- this.setCursor(target);
- this.scheduleRemoval(5000);
- }
- }
- dragend() {
- this.scheduleRemoval(20);
- }
- drop() {
- this.scheduleRemoval(20);
- }
- dragleave(event) {
- if (event.target == this.editorView.dom ||
- !this.editorView.dom.contains(event.relatedTarget))
- this.setCursor(null);
- }
-}
diff --git a/packages/editor/dist/cjs/extensions/dropcursor/index.d.ts b/packages/editor/dist/cjs/extensions/dropcursor/index.d.ts
deleted file mode 100644
index 8b3d7693d..000000000
--- a/packages/editor/dist/cjs/extensions/dropcursor/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Dropcursor } from "./drop-cursor";
-export * from "./drop-cursor";
-export default Dropcursor;
diff --git a/packages/editor/dist/cjs/extensions/dropcursor/index.js b/packages/editor/dist/cjs/extensions/dropcursor/index.js
deleted file mode 100644
index ca013fdf7..000000000
--- a/packages/editor/dist/cjs/extensions/dropcursor/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const dropcursor_1 = require("./dropcursor");
-__exportStar(require("./dropcursor"), exports);
-exports.default = dropcursor_1.Dropcursor;
diff --git a/packages/editor/dist/cjs/extensions/embed/component.d.ts b/packages/editor/dist/cjs/extensions/embed/component.d.ts
deleted file mode 100644
index 65b1ee648..000000000
--- a/packages/editor/dist/cjs/extensions/embed/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { EmbedAlignmentOptions, EmbedAttributes } from "./embed";
-import { SelectionBasedReactNodeViewProps } from "../react";
-export declare function EmbedComponent(props: SelectionBasedReactNodeViewProps<EmbedAttributes & EmbedAlignmentOptions>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/embed/component.js b/packages/editor/dist/cjs/extensions/embed/component.js
deleted file mode 100644
index 63920bdc2..000000000
--- a/packages/editor/dist/cjs/extensions/embed/component.js
+++ /dev/null
@@ -1,66 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EmbedComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const responsive_1 = require("../../components/responsive");
-const toolbargroup_1 = require("../../toolbar/components/toolbargroup");
-const toolbar_1 = require("../../toolbar");
-const resizer_1 = require("../../components/resizer");
-function EmbedComponent(props) {
- const { editor, updateAttributes, selected, node } = props;
- const [isLoading, setIsLoading] = (0, react_1.useState)(true);
- const embedRef = (0, react_1.useRef)();
- const { src, width, height, align } = node.attrs;
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {
- display: "flex",
- justifyContent: align === "center" ? "center" : align === "left" ? "start" : "end",
- position: "relative",
- } }, { children: (0, jsx_runtime_1.jsxs)(resizer_1.Resizer, Object.assign({ editor: editor, selected: selected, width: width, height: height, onResize: (width, height) => {
- updateAttributes({
- width,
- height,
- }, { addToHistory: true, preventUpdate: false });
- } }, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ width: "100%", sx: {
- position: "relative",
- justifyContent: "end",
- p: "small",
- bg: editor.isEditable ? "bgSecondary" : "transparent",
- borderTopLeftRadius: "default",
- borderTopRightRadius: "default",
- borderColor: selected ? "border" : "bgSecondary",
- cursor: "pointer",
- ":hover": {
- borderColor: "border",
- },
- } }, { children: [(0, jsx_runtime_1.jsx)(toolbar_1.Icon, { path: toolbar_1.Icons.dragHandle, size: "big" }), (0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: selected && ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: { position: "relative", justifyContent: "end" } }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- position: "absolute",
- top: -10,
- mb: 2,
- alignItems: "end",
- } }, { children: (0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { editor: editor, tools: [
- "embedAlignLeft",
- "embedAlignCenter",
- "embedAlignRight",
- "embedProperties",
- ], sx: {
- boxShadow: "menu",
- borderRadius: "default",
- bg: "background",
- } }) })) }))) })] })), (0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ as: "iframe", ref: embedRef, src: src, width: "100%", height: "100%", sx: {
- bg: "bgSecondary",
- border: selected
- ? "2px solid var(--primary)"
- : "2px solid transparent",
- borderRadius: "default",
- }, onLoad: () => setIsLoading(false) }, props)), isLoading && ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- position: "absolute",
- bottom: 0,
- width: "100%",
- height: "calc(100% - 20px)",
- alignItems: "center",
- justifyContent: "center",
- } }, { children: (0, jsx_runtime_1.jsx)(toolbar_1.Icon, { path: toolbar_1.Icons.loading, rotate: true, size: 32, color: "disabled" }) })))] })) })) }));
-}
-exports.EmbedComponent = EmbedComponent;
diff --git a/packages/editor/dist/cjs/extensions/embed/embed.d.ts b/packages/editor/dist/cjs/extensions/embed/embed.d.ts
deleted file mode 100644
index 969f00b5a..000000000
--- a/packages/editor/dist/cjs/extensions/embed/embed.d.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Node } from "@tiptap/core";
-export interface EmbedOptions {
- HTMLAttributes: Record<string, any>;
-}
-export declare type EmbedAttributes = Partial<EmbedSizeOptions> & {
- src: string;
-};
-export declare type EmbedAlignmentOptions = {
- align?: "center" | "left" | "right";
-};
-export declare type Embed = Required<EmbedAttributes> & EmbedAlignmentOptions;
-export declare type EmbedSizeOptions = {
- width: number;
- height: number;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- embed: {
- /**
- * Add an embed
- */
- insertEmbed: (options: EmbedAttributes) => ReturnType;
- setEmbedAlignment: (options: EmbedAlignmentOptions) => ReturnType;
- setEmbedSize: (options: EmbedSizeOptions) => ReturnType;
- setEmbedSource: (src: string) => ReturnType;
- };
- }
-}
-export declare const EmbedNode: Node<EmbedOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/embed/embed.js b/packages/editor/dist/cjs/extensions/embed/embed.js
deleted file mode 100644
index bd80544ad..000000000
--- a/packages/editor/dist/cjs/extensions/embed/embed.js
+++ /dev/null
@@ -1,65 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EmbedNode = void 0;
-const core_1 = require("@tiptap/core");
-const react_1 = require("../react");
-const component_1 = require("./component");
-exports.EmbedNode = core_1.Node.create({
- name: "embed",
- content: "",
- marks: "",
- draggable: true,
- addOptions() {
- return {
- HTMLAttributes: {},
- };
- },
- group() {
- return "block";
- },
- addAttributes() {
- return {
- src: {
- default: null,
- },
- width: { default: null },
- height: { default: null },
- align: { default: "left" },
- };
- },
- parseHTML() {
- return [
- {
- tag: "iframe[src]",
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "iframe",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
- ];
- },
- addNodeView() {
- return (0, react_1.createSelectionBasedNodeView)(component_1.EmbedComponent);
- },
- addCommands() {
- return {
- insertEmbed: (options) => ({ commands }) => {
- return commands.insertContent({
- type: this.name,
- attrs: options,
- });
- },
- setEmbedAlignment: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- setEmbedSize: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- setEmbedSource: (src) => ({ commands }) => {
- return commands.updateAttributes(this.name, { src });
- },
- };
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/embed/index.d.ts b/packages/editor/dist/cjs/extensions/embed/index.d.ts
deleted file mode 100644
index 12b3c5295..000000000
--- a/packages/editor/dist/cjs/extensions/embed/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./embed";
diff --git a/packages/editor/dist/cjs/extensions/embed/index.js b/packages/editor/dist/cjs/extensions/embed/index.js
deleted file mode 100644
index edd6e1a43..000000000
--- a/packages/editor/dist/cjs/extensions/embed/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./embed"), exports);
diff --git a/packages/editor/dist/cjs/extensions/fontsize/fontsize.d.ts b/packages/editor/dist/cjs/extensions/fontsize/fontsize.d.ts
deleted file mode 100644
index 5725a7a40..000000000
--- a/packages/editor/dist/cjs/extensions/fontsize/fontsize.d.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Extension } from "@tiptap/core";
-import "@tiptap/extension-text-style";
-declare type FontSizeOptions = {
- types: string[];
- defaultFontSize: number;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- fontSize: {
- /**
- * Set the font family
- */
- setFontSize: (fontSize: string) => ReturnType;
- /**
- * Unset the font family
- */
- unsetFontSize: () => ReturnType;
- };
- }
-}
-export declare const FontSize: Extension<FontSizeOptions, any>;
-export {};
diff --git a/packages/editor/dist/cjs/extensions/fontsize/fontsize.js b/packages/editor/dist/cjs/extensions/fontsize/fontsize.js
deleted file mode 100644
index 645d48a46..000000000
--- a/packages/editor/dist/cjs/extensions/fontsize/fontsize.js
+++ /dev/null
@@ -1,46 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.FontSize = void 0;
-const core_1 = require("@tiptap/core");
-require("@tiptap/extension-text-style");
-exports.FontSize = core_1.Extension.create({
- name: "fontSize",
- defaultOptions: {
- types: ["textStyle"],
- defaultFontSize: 16,
- },
- addGlobalAttributes() {
- return [
- {
- types: this.options.types,
- attributes: {
- fontSize: {
- default: `${this.options.defaultFontSize}px`,
- parseHTML: (element) => element.style.fontSize,
- renderHTML: (attributes) => {
- if (!attributes.fontSize) {
- return {};
- }
- return {
- style: `font-size: ${attributes.fontSize}`,
- };
- },
- },
- },
- },
- ];
- },
- addCommands() {
- return {
- setFontSize: (fontSize) => ({ chain }) => {
- return chain().setMark("textStyle", { fontSize }).run();
- },
- unsetFontSize: () => ({ chain }) => {
- return chain()
- .setMark("textStyle", { fontSize: null })
- .removeEmptyTextStyle()
- .run();
- },
- };
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/fontsize/index.d.ts b/packages/editor/dist/cjs/extensions/fontsize/index.d.ts
deleted file mode 100644
index 0424657fa..000000000
--- a/packages/editor/dist/cjs/extensions/fontsize/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { FontSize } from "./font-size";
-export * from "./font-size";
-export default FontSize;
diff --git a/packages/editor/dist/cjs/extensions/fontsize/index.js b/packages/editor/dist/cjs/extensions/fontsize/index.js
deleted file mode 100644
index 167f5a0cd..000000000
--- a/packages/editor/dist/cjs/extensions/fontsize/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const fontsize_1 = require("./fontsize");
-__exportStar(require("./fontsize"), exports);
-exports.default = fontsize_1.FontSize;
diff --git a/packages/editor/dist/cjs/extensions/image/component.d.ts b/packages/editor/dist/cjs/extensions/image/component.d.ts
deleted file mode 100644
index 0ae7c84cd..000000000
--- a/packages/editor/dist/cjs/extensions/image/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ImageAlignmentOptions, ImageAttributes } from "./image";
-import { SelectionBasedReactNodeViewProps } from "../react";
-export declare function ImageComponent(props: SelectionBasedReactNodeViewProps<ImageAttributes & ImageAlignmentOptions>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/image/component.js b/packages/editor/dist/cjs/extensions/image/component.js
deleted file mode 100644
index 12be6f6c9..000000000
--- a/packages/editor/dist/cjs/extensions/image/component.js
+++ /dev/null
@@ -1,90 +0,0 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ImageComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const responsive_1 = require("../../components/responsive");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const toolbargroup_1 = require("../../toolbar/components/toolbargroup");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-const resizer_1 = require("../../components/resizer");
-function ImageComponent(props) {
- const { editor, updateAttributes, node, selected } = props;
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- let { src, alt, title, width, height, align, float } = node.attrs;
- const imageRef = (0, react_1.useRef)();
- (0, react_1.useEffect)(() => {
- (() => __awaiter(this, void 0, void 0, function* () {
- if (!imageRef.current || !src)
- return;
- imageRef.current.src = yield dataUriToBlobURL(src);
- }))();
- }, [src, imageRef]);
- if (isMobile)
- float = false;
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {
- display: float ? "block" : "flex",
- justifyContent: float
- ? "stretch"
- : align === "center"
- ? "center"
- : align === "left"
- ? "start"
- : "end",
- ":hover .drag-handle, :active .drag-handle": {
- opacity: 1,
- },
- } }, { children: (0, jsx_runtime_1.jsxs)(resizer_1.Resizer, Object.assign({ editor: editor, selected: selected, width: width, height: height, onResize: (width, height) => {
- updateAttributes({
- width,
- height,
- }, { addToHistory: true, preventUpdate: false });
- } }, { children: [(0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: selected && ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: { position: "relative", justifyContent: "end" } }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- position: "absolute",
- top: -40,
- mb: 2,
- alignItems: "end",
- } }, { children: (0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { editor: editor, tools: [
- "imageAlignLeft",
- "imageAlignCenter",
- "imageAlignRight",
- "imageProperties",
- ], sx: {
- boxShadow: "menu",
- borderRadius: "default",
- bg: "background",
- } }) })) }))) }), selected && ((0, jsx_runtime_1.jsx)(icon_1.Icon, { className: "drag-handle", "data-drag-handle": true, draggable: true, path: icons_1.Icons.dragHandle, sx: {
- cursor: "grab",
- position: "absolute",
- top: 2,
- left: 2,
- zIndex: 999,
- } })), (0, jsx_runtime_1.jsx)(rebass_1.Image, Object.assign({ "data-drag-image": true, ref: imageRef, alt: alt, src: "/placeholder.svg", title: title, width: "100%", height: "100%", sx: {
- bg: "bgSecondary",
- border: selected
- ? "2px solid var(--primary)"
- : "2px solid transparent",
- borderRadius: "default",
- } }, props))] })) })) }));
-}
-exports.ImageComponent = ImageComponent;
-function dataUriToBlobURL(dataurl) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!dataurl.startsWith("data:image"))
- return dataurl;
- const response = yield fetch(dataurl);
- const blob = yield response.blob();
- return URL.createObjectURL(blob);
- });
-}
diff --git a/packages/editor/dist/cjs/extensions/image/image.d.ts b/packages/editor/dist/cjs/extensions/image/image.d.ts
deleted file mode 100644
index eb963ae33..000000000
--- a/packages/editor/dist/cjs/extensions/image/image.d.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Node } from "@tiptap/core";
-import { Attachment } from "../attachment";
-export interface ImageOptions {
- inline: boolean;
- allowBase64: boolean;
- HTMLAttributes: Record<string, any>;
-}
-export declare type ImageAttributes = Partial<ImageSizeOptions> & Partial<Attachment> & {
- src: string;
- alt?: string;
- title?: string;
-};
-export declare type ImageAlignmentOptions = {
- float?: boolean;
- align?: "center" | "left" | "right";
-};
-export declare type ImageSizeOptions = {
- width: number;
- height: number;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- image: {
- /**
- * Add an image
- */
- insertImage: (options: ImageAttributes) => ReturnType;
- updateImage: (options: ImageAttributes) => ReturnType;
- setImageAlignment: (options: ImageAlignmentOptions) => ReturnType;
- setImageSize: (options: ImageSizeOptions) => ReturnType;
- };
- }
-}
-export declare const inputRegex: RegExp;
-export declare const ImageNode: Node<ImageOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/image/image.js b/packages/editor/dist/cjs/extensions/image/image.js
deleted file mode 100644
index 5eed4a835..000000000
--- a/packages/editor/dist/cjs/extensions/image/image.js
+++ /dev/null
@@ -1,110 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ImageNode = exports.inputRegex = void 0;
-const core_1 = require("@tiptap/core");
-const attachment_1 = require("../attachment");
-const react_1 = require("../react");
-const component_1 = require("./component");
-exports.inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
-exports.ImageNode = core_1.Node.create({
- name: "image",
- addOptions() {
- return {
- inline: false,
- allowBase64: false,
- HTMLAttributes: {},
- };
- },
- inline() {
- return this.options.inline;
- },
- group() {
- return this.options.inline ? "inline" : "block";
- },
- draggable: true,
- addAttributes() {
- return {
- src: {
- default: null,
- },
- alt: {
- default: null,
- },
- title: {
- default: null,
- },
- width: { default: null },
- height: { default: null },
- // TODO: maybe these should be stored as styles?
- float: (0, attachment_1.getDataAttribute)("float", false),
- align: (0, attachment_1.getDataAttribute)("align", "left"),
- hash: (0, attachment_1.getDataAttribute)("hash"),
- filename: (0, attachment_1.getDataAttribute)("filename"),
- type: (0, attachment_1.getDataAttribute)("mime"),
- size: (0, attachment_1.getDataAttribute)("size"),
- };
- },
- parseHTML() {
- return [
- {
- tag: this.options.allowBase64 ? "img" : 'img:not([src^="data:"])',
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "img",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
- ];
- },
- addNodeView() {
- return (0, react_1.createSelectionBasedNodeView)(component_1.ImageComponent);
- },
- addCommands() {
- return {
- insertImage: (options) => ({ commands }) => {
- return commands.insertContent({
- type: this.name,
- attrs: options,
- });
- },
- setImageAlignment: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- setImageSize: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- updateImage: (options) => ({ state, tr, dispatch }) => {
- const query = options.hash
- ? { key: "hash", value: options.hash }
- : options.src
- ? { key: "src", value: options.src }
- : null;
- if (!query)
- return false;
- const images = (0, core_1.findChildren)(state.doc, (node) => node.type.name === this.name &&
- node.attrs[query.key] === query.value);
- for (const image of images) {
- tr.setNodeMarkup(image.pos, image.node.type, Object.assign(Object.assign({}, image.node.attrs), options));
- }
- tr.setMeta("preventUpdate", true);
- tr.setMeta("addToHistory", false);
- if (dispatch)
- dispatch(tr);
- return true;
- },
- };
- },
- addInputRules() {
- return [
- (0, core_1.nodeInputRule)({
- find: exports.inputRegex,
- type: this.type,
- getAttributes: (match) => {
- const [, , alt, src, title] = match;
- return { src, alt, title };
- },
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/image/index.d.ts b/packages/editor/dist/cjs/extensions/image/index.d.ts
deleted file mode 100644
index 0aa9b4bbd..000000000
--- a/packages/editor/dist/cjs/extensions/image/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./image";
diff --git a/packages/editor/dist/cjs/extensions/image/index.js b/packages/editor/dist/cjs/extensions/image/index.js
deleted file mode 100644
index e537e41bc..000000000
--- a/packages/editor/dist/cjs/extensions/image/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./image"), exports);
diff --git a/packages/editor/dist/cjs/extensions/keepinview/index.d.ts b/packages/editor/dist/cjs/extensions/keepinview/index.d.ts
deleted file mode 100644
index 7d6036306..000000000
--- a/packages/editor/dist/cjs/extensions/keepinview/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./keep-in-view";
diff --git a/packages/editor/dist/cjs/extensions/keepinview/index.js b/packages/editor/dist/cjs/extensions/keepinview/index.js
deleted file mode 100644
index 6520f8b36..000000000
--- a/packages/editor/dist/cjs/extensions/keepinview/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./keepinview"), exports);
diff --git a/packages/editor/dist/cjs/extensions/keepinview/keepinview.d.ts b/packages/editor/dist/cjs/extensions/keepinview/keepinview.d.ts
deleted file mode 100644
index 708121164..000000000
--- a/packages/editor/dist/cjs/extensions/keepinview/keepinview.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Editor, Extension } from "@tiptap/core";
-export declare const KeepInView: Extension<any, any>;
-export declare function keepLastLineInView(editor: Editor): void;
diff --git a/packages/editor/dist/cjs/extensions/keepinview/keepinview.js b/packages/editor/dist/cjs/extensions/keepinview/keepinview.js
deleted file mode 100644
index 1524bd800..000000000
--- a/packages/editor/dist/cjs/extensions/keepinview/keepinview.js
+++ /dev/null
@@ -1,67 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.keepLastLineInView = exports.KeepInView = void 0;
-const core_1 = require("@tiptap/core");
-let onWindowResize = undefined;
-exports.KeepInView = core_1.Extension.create({
- name: "keepinview",
- onCreate() {
- onWindowResize = () => {
- keepLastLineInView(this.editor);
- };
- window.addEventListener("resize", onWindowResize);
- },
- onDestroy() {
- if (!onWindowResize)
- return;
- window.removeEventListener("resize", onWindowResize);
- onWindowResize = undefined;
- },
- addKeyboardShortcuts() {
- return {
- Enter: ({ editor }) => {
- setTimeout(() => {
- keepLastLineInView(editor);
- });
- return false;
- },
- };
- },
-});
-function keepLastLineInView(editor) {
- const THRESHOLD = 100;
- const node = editor.state.selection.$from;
- const { top } = (0, core_1.posToDOMRect)(editor.view, node.pos, node.pos + 1);
- const isBelowThreshold = window.innerHeight - top < THRESHOLD;
- if (isBelowThreshold) {
- let { node: domNode } = editor.view.domAtPos(node.pos);
- if (domNode.nodeType === Node.TEXT_NODE && domNode.parentNode)
- domNode = domNode.parentNode;
- if (domNode instanceof HTMLElement) {
- const container = findScrollContainer(domNode);
- if (container) {
- container.scrollBy({ top: THRESHOLD, behavior: "smooth" });
- }
- else
- domNode.scrollIntoView({ behavior: "smooth", block: "center" });
- }
- }
-}
-exports.keepLastLineInView = keepLastLineInView;
-const findScrollContainer = (element) => {
- if (!element) {
- return undefined;
- }
- let parent = element.parentElement;
- while (parent) {
- const { overflow, overflowY } = parent.style;
- if (isOverlow(overflow) || isOverlow(overflowY)) {
- return parent;
- }
- parent = parent.parentElement;
- }
- return document.documentElement;
-};
-function isOverlow(str) {
- return str.split(" ").every((o) => o === "auto" || o === "scroll");
-}
diff --git a/packages/editor/dist/cjs/extensions/listitem/commands.d.ts b/packages/editor/dist/cjs/extensions/listitem/commands.d.ts
deleted file mode 100644
index 7ff452b25..000000000
--- a/packages/editor/dist/cjs/extensions/listitem/commands.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { NodeType } from "prosemirror-model";
-import { Editor } from "@tiptap/core";
-export declare function onBackspacePressed(editor: Editor, name: string, type: NodeType): boolean;
diff --git a/packages/editor/dist/cjs/extensions/listitem/commands.js b/packages/editor/dist/cjs/extensions/listitem/commands.js
deleted file mode 100644
index 7fb7016fe..000000000
--- a/packages/editor/dist/cjs/extensions/listitem/commands.js
+++ /dev/null
@@ -1,78 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.onBackspacePressed = void 0;
-const prosemirror_utils_1 = require("prosemirror-utils");
-// WORKAROUND: if we're at the start of a list item, we need to either
-// backspace directly to an empty list item above, or outdent this node
-function onBackspacePressed(editor, name, type) {
- const { selection } = editor.state;
- const { empty, $from } = selection;
- if (!empty ||
- !isInside(name, type, editor.state) ||
- $from.parentOffset !== 0 ||
- !isFirstChildOfParent(editor.state) ||
- !editor.can().liftListItem(type))
- return false;
- const isEmpty = isListItemEmpty(type, editor.state);
- if (isEmpty) {
- if (isFirstOfType(type, editor.state)) {
- const parentList = getListFromListItem(type, editor.state);
- if (!parentList)
- return false;
- return editor.commands.deleteNode(parentList.type);
- }
- return editor.commands.deleteNode(type);
- }
- else if (isFirstOfType(type, editor.state)) {
- return editor.commands.liftListItem(type);
- }
- else {
- // we have to run join backward twice because on the first join
- // the two list items are joined i.e., the editor just puts their
- // paragraphs next to each other. The next join merges the paragraphs
- // like it should be.
- return editor.chain().joinBackward().joinBackward().run();
- }
-}
-exports.onBackspacePressed = onBackspacePressed;
-function isInside(name, type, state) {
- const { $from } = state.selection;
- let node = type || state.schema.nodes[name];
- const { paragraph } = state.schema.nodes;
- return ((0, prosemirror_utils_1.hasParentNodeOfType)(node)(state.selection) &&
- $from.parent.type === paragraph);
-}
-function isFirstChildOfParent(state) {
- const { $from } = state.selection;
- return $from.depth > 1
- ? $from.parentOffset === 0 || $from.index($from.depth - 1) === 0
- : true;
-}
-const isFirstOfType = (type, state) => {
- const block = (0, prosemirror_utils_1.findParentNodeOfType)(type)(state.selection);
- if (!block)
- return false;
- const { pos } = block;
- const resolved = state.doc.resolve(pos);
- console.log("isFirstOfType", resolved);
- return !resolved.nodeBefore;
-};
-const getListFromListItem = (type, state) => {
- var _a;
- const block = (0, prosemirror_utils_1.findParentNodeOfType)(type)(state.selection);
- if (!block)
- return undefined;
- const { pos } = block;
- const resolved = state.doc.resolve(pos);
- if (!resolved.parent.type.spec.group ||
- ((_a = resolved.parent.type.spec.group) === null || _a === void 0 ? void 0 : _a.indexOf("list")) <= -1)
- return undefined;
- return resolved.parent;
-};
-function isListItemEmpty(type, state) {
- const block = (0, prosemirror_utils_1.findParentNodeOfType)(type)(state.selection);
- if (!block)
- return false;
- const { node } = block;
- return !node.textContent.length;
-}
diff --git a/packages/editor/dist/cjs/extensions/listitem/index.d.ts b/packages/editor/dist/cjs/extensions/listitem/index.d.ts
deleted file mode 100644
index 24950c4f2..000000000
--- a/packages/editor/dist/cjs/extensions/listitem/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./list-item";
diff --git a/packages/editor/dist/cjs/extensions/listitem/index.js b/packages/editor/dist/cjs/extensions/listitem/index.js
deleted file mode 100644
index 87fab5e24..000000000
--- a/packages/editor/dist/cjs/extensions/listitem/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./listitem"), exports);
diff --git a/packages/editor/dist/cjs/extensions/listitem/listitem.d.ts b/packages/editor/dist/cjs/extensions/listitem/listitem.d.ts
deleted file mode 100644
index 8160a725a..000000000
--- a/packages/editor/dist/cjs/extensions/listitem/listitem.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const ListItem: import("@tiptap/core").Node<import("@tiptap/extension-list-item").ListItemOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/listitem/listitem.js b/packages/editor/dist/cjs/extensions/listitem/listitem.js
deleted file mode 100644
index f3be4edf2..000000000
--- a/packages/editor/dist/cjs/extensions/listitem/listitem.js
+++ /dev/null
@@ -1,11 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ListItem = void 0;
-const extension_list_item_1 = require("@tiptap/extension-list-item");
-const commands_1 = require("./commands");
-exports.ListItem = extension_list_item_1.ListItem.extend({
- addKeyboardShortcuts() {
- var _a;
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { Backspace: ({ editor }) => (0, commands_1.onBackspacePressed)(editor, this.name, this.type) });
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/math/index.d.ts b/packages/editor/dist/cjs/extensions/math/index.d.ts
deleted file mode 100644
index 1331fdb01..000000000
--- a/packages/editor/dist/cjs/extensions/math/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { MathInline } from "./math-inline";
-export { MathBlock } from "./math-block";
diff --git a/packages/editor/dist/cjs/extensions/math/index.js b/packages/editor/dist/cjs/extensions/math/index.js
deleted file mode 100644
index 599726672..000000000
--- a/packages/editor/dist/cjs/extensions/math/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MathBlock = exports.MathInline = void 0;
-var mathinline_1 = require("./mathinline");
-Object.defineProperty(exports, "MathInline", { enumerable: true, get: function () { return mathinline_1.MathInline; } });
-var mathblock_1 = require("./mathblock");
-Object.defineProperty(exports, "MathBlock", { enumerable: true, get: function () { return mathblock_1.MathBlock; } });
diff --git a/packages/editor/dist/cjs/extensions/math/mathblock.d.ts b/packages/editor/dist/cjs/extensions/math/mathblock.d.ts
deleted file mode 100644
index 5c266e9e8..000000000
--- a/packages/editor/dist/cjs/extensions/math/mathblock.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Node } from "@tiptap/core";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- mathBlock: {
- insertMathBlock: () => ReturnType;
- };
- }
-}
-export declare const MathBlock: Node<any, any>;
diff --git a/packages/editor/dist/cjs/extensions/math/mathblock.js b/packages/editor/dist/cjs/extensions/math/mathblock.js
deleted file mode 100644
index d3786f64e..000000000
--- a/packages/editor/dist/cjs/extensions/math/mathblock.js
+++ /dev/null
@@ -1,40 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MathBlock = void 0;
-const core_1 = require("@tiptap/core");
-const prosemirror_inputrules_1 = require("prosemirror-inputrules");
-const plugin_1 = require("./plugin");
-exports.MathBlock = core_1.Node.create({
- name: "mathBlock",
- group: "block math",
- content: "text*",
- atom: true,
- code: true,
- parseHTML() {
- return [
- {
- tag: `div[class*='math-block']`, // important!
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "div",
- (0, core_1.mergeAttributes)({ class: "math-block math-node" }, HTMLAttributes),
- 0,
- ];
- },
- addCommands() {
- return {
- insertMathBlock: () => ({ state, dispatch, view }) => {
- return (0, plugin_1.insertMathNode)(this.type)(state, dispatch, view);
- },
- };
- },
- addProseMirrorPlugins() {
- const inputRulePlugin = (0, prosemirror_inputrules_1.inputRules)({
- rules: [(0, plugin_1.makeBlockMathInputRule)(plugin_1.REGEX_BLOCK_MATH_DOLLARS, this.type)],
- });
- return [inputRulePlugin];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/math/mathinline.d.ts b/packages/editor/dist/cjs/extensions/math/mathinline.d.ts
deleted file mode 100644
index 56a7ec49f..000000000
--- a/packages/editor/dist/cjs/extensions/math/mathinline.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Node } from "@tiptap/core";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- mathInline: {
- insertMathInline: () => ReturnType;
- };
- }
-}
-export declare const MathInline: Node<any, any>;
diff --git a/packages/editor/dist/cjs/extensions/math/mathinline.js b/packages/editor/dist/cjs/extensions/math/mathinline.js
deleted file mode 100644
index f7ef8eaed..000000000
--- a/packages/editor/dist/cjs/extensions/math/mathinline.js
+++ /dev/null
@@ -1,45 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MathInline = void 0;
-const core_1 = require("@tiptap/core");
-const prosemirror_inputrules_1 = require("prosemirror-inputrules");
-const plugin_1 = require("./plugin");
-exports.MathInline = core_1.Node.create({
- name: "mathInline",
- group: "inline math",
- content: "text*",
- inline: true,
- atom: true,
- code: true,
- parseHTML() {
- return [
- {
- tag: "span[class*='math-inline']", // important!,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "span",
- (0, core_1.mergeAttributes)({ class: "math-inline math-node" }, HTMLAttributes),
- 0,
- ];
- },
- addCommands() {
- return {
- insertMathInline: () => ({ chain, tr }) => {
- const { $from } = tr.selection;
- return chain()
- .insertContent({ type: this.name, attrs: {} })
- .setNodeSelection($from.pos)
- .run();
- },
- };
- },
- addProseMirrorPlugins() {
- const inputRulePlugin = (0, prosemirror_inputrules_1.inputRules)({
- rules: [(0, plugin_1.makeInlineMathInputRule)(plugin_1.REGEX_INLINE_MATH_DOLLARS, this.type)],
- });
- return [plugin_1.mathPlugin, inputRulePlugin];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/collapsemathnode.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/commands/collapsemathnode.d.ts
deleted file mode 100644
index a3210bd68..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/collapsemathnode.d.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Command } from "prosemirror-state";
-import { EditorView } from "prosemirror-view";
-/**
- * A ProseMirror command for determining whether to exit a math block, based on
- * specific conditions. Normally called when the user has
- *
- * @param outerView The main ProseMirror EditorView containing this math node.
- * @param dir Used to indicate desired cursor position upon closing a math node.
- * When set to -1, cursor will be placed BEFORE the math node.
- * When set to +1, cursor will be placed AFTER the math node.
- * @param borderMode An exit condition based on cursor position and direction.
- * @param requireEmptySelection When TRUE, only exit the math node when the
- * (inner) selection is empty.
- * @returns A new ProseMirror command based on the input configuration.
- */
-export declare function collapseMathNode(outerView: EditorView, dir: 1 | -1, requireOnBorder: boolean, requireEmptySelection?: boolean): Command;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/collapsemathnode.js b/packages/editor/dist/cjs/extensions/math/plugin/commands/collapsemathnode.js
deleted file mode 100644
index 2a9bce44e..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/collapsemathnode.js
+++ /dev/null
@@ -1,54 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.collapseMathNode = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-/**
- * A ProseMirror command for determining whether to exit a math block, based on
- * specific conditions. Normally called when the user has
- *
- * @param outerView The main ProseMirror EditorView containing this math node.
- * @param dir Used to indicate desired cursor position upon closing a math node.
- * When set to -1, cursor will be placed BEFORE the math node.
- * When set to +1, cursor will be placed AFTER the math node.
- * @param borderMode An exit condition based on cursor position and direction.
- * @param requireEmptySelection When TRUE, only exit the math node when the
- * (inner) selection is empty.
- * @returns A new ProseMirror command based on the input configuration.
- */
-function collapseMathNode(outerView, dir, requireOnBorder, requireEmptySelection = true) {
- // create a new ProseMirror command based on the input conditions
- return (innerState, dispatch) => {
- // get selection info
- let outerState = outerView.state;
- let { to: outerTo, from: outerFrom } = outerState.selection;
- let { to: innerTo, from: innerFrom } = innerState.selection;
- // only exit math node when selection is empty
- if (requireEmptySelection && innerTo !== innerFrom) {
- return false;
- }
- let currentPos = dir > 0 ? innerTo : innerFrom;
- // when requireOnBorder is TRUE, collapse only when cursor
- // is about to leave the bounds of the math node
- if (requireOnBorder) {
- // (subtract two from nodeSize to account for start and end tokens)
- let nodeSize = innerState.doc.nodeSize - 2;
- // early return if exit conditions not met
- if (dir > 0 && currentPos < nodeSize) {
- return false;
- }
- if (dir < 0 && currentPos > 0) {
- return false;
- }
- }
- // all exit conditions met, so close the math node by moving the cursor outside
- if (dispatch) {
- // set outer selection to be outside of the nodeview
- let targetPos = dir > 0 ? outerTo : outerFrom;
- outerView.dispatch(outerState.tr.setSelection(prosemirror_state_1.TextSelection.create(outerState.doc, targetPos)));
- // must return focus to the outer view, otherwise no cursor will appear
- outerView.focus();
- }
- return true;
- };
-}
-exports.collapseMathNode = collapseMathNode;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.d.ts
deleted file mode 100644
index 4d8ba65ba..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Command } from "prosemirror-state";
-import { NodeType } from "prosemirror-model";
-/**
- * Returns a new command that can be used to inserts a new math node at the
- * user's current document position, provided that the document schema actually
- * allows a math node to be placed there.
- *
- * @param mathNodeType An instance for either your math_inline or math_display
- * NodeType. Must belong to the same schema that your EditorState uses!
- * @param initialText (optional) The initial source content for the math editor.
- */
-export declare function insertMathNode(mathNodeType: NodeType, initialText?: string): Command;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js b/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js
deleted file mode 100644
index 2f5ebae6d..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js
+++ /dev/null
@@ -1,35 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.insertMathNode = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-////////////////////////////////////////////////////////////////////////////////
-/**
- * Returns a new command that can be used to inserts a new math node at the
- * user's current document position, provided that the document schema actually
- * allows a math node to be placed there.
- *
- * @param mathNodeType An instance for either your math_inline or math_display
- * NodeType. Must belong to the same schema that your EditorState uses!
- * @param initialText (optional) The initial source content for the math editor.
- */
-function insertMathNode(mathNodeType, initialText = "") {
- return function (state, dispatch) {
- let { $from, empty } = state.selection, index = $from.index();
- if (!empty && !$from.parent.canReplaceWith(index, index, mathNodeType)) {
- return false;
- }
- if (dispatch) {
- let mathNode = mathNodeType.create({}, initialText ? state.schema.text(initialText) : null);
- let tr = state.tr.replaceSelectionWith(mathNode);
- if (empty) {
- tr = tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, $from.pos + 1));
- }
- else {
- tr = tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, $from.pos));
- }
- dispatch(tr);
- }
- return true;
- };
-}
-exports.insertMathNode = insertMathNode;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/move-cursor-cmd.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/commands/move-cursor-cmd.d.ts
deleted file mode 100644
index d1361e53e..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/move-cursor-cmd.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Command } from "prosemirror-state";
-/**
- * Some browsers (cough firefox cough) don't properly handle cursor movement on
- * the edges of a NodeView, so we need to make the desired behavior explicit.
- *
- * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1252108
- */
-export declare function nudgeCursorCmd(dir: -1 | 0 | 1): Command;
-export declare const nudgeCursorForwardCmd: Command;
-export declare const nudgeCursorBackCmd: Command;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/move-cursor-cmd.js b/packages/editor/dist/cjs/extensions/math/plugin/commands/move-cursor-cmd.js
deleted file mode 100644
index 796cac8e1..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/move-cursor-cmd.js
+++ /dev/null
@@ -1,29 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.nudgeCursorBackCmd = exports.nudgeCursorForwardCmd = exports.nudgeCursorCmd = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-////////////////////////////////////////////////////////////////////////////////
-/**
- * Some browsers (cough firefox cough) don't properly handle cursor movement on
- * the edges of a NodeView, so we need to make the desired behavior explicit.
- *
- * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1252108
- */
-function nudgeCursorCmd(dir) {
- return (innerState, dispatch) => {
- let { to, from } = innerState.selection;
- // compute target position
- let emptySelection = to === from;
- let currentPos = dir < 0 ? from : to;
- let increment = emptySelection ? dir : 0;
- let nodeSize = innerState.doc.nodeSize;
- let targetPos = Math.max(0, Math.min(nodeSize, currentPos + increment));
- if (dispatch) {
- dispatch(innerState.tr.setSelection(prosemirror_state_1.TextSelection.create(innerState.doc, targetPos)));
- }
- return true;
- };
-}
-exports.nudgeCursorCmd = nudgeCursorCmd;
-exports.nudgeCursorForwardCmd = nudgeCursorCmd(+1);
-exports.nudgeCursorBackCmd = nudgeCursorCmd(-1);
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/index.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/index.d.ts
deleted file mode 100644
index 13e02011b..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/index.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export { MathView, type ICursorPosObserver } from "./math-node-view";
-export { mathPlugin, createMathView, type IMathPluginState, } from "./math-plugin";
-export { mathSchemaSpec, createMathSchema } from "./math-schema";
-export { mathBackspaceCmd } from "./plugins/math-backspace";
-export { makeBlockMathInputRule, makeInlineMathInputRule, REGEX_BLOCK_MATH_DOLLARS, REGEX_INLINE_MATH_DOLLARS, REGEX_INLINE_MATH_DOLLARS_ESCAPED, } from "./plugins/math-input-rules";
-export { mathSelectPlugin } from "./plugins/math-select";
-export { insertMathNode } from "./commands/insert-math-node";
-export { mathSerializer } from "./utils/text-serializer";
-export * from "./utils/types";
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/index.js b/packages/editor/dist/cjs/extensions/math/plugin/index.js
deleted file mode 100644
index 551d7bf05..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/index.js
+++ /dev/null
@@ -1,49 +0,0 @@
-"use strict";
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.mathSerializer = exports.insertMathNode = exports.mathSelectPlugin = exports.REGEX_INLINE_MATH_DOLLARS_ESCAPED = exports.REGEX_INLINE_MATH_DOLLARS = exports.REGEX_BLOCK_MATH_DOLLARS = exports.makeInlineMathInputRule = exports.makeBlockMathInputRule = exports.mathBackspaceCmd = exports.createMathSchema = exports.mathSchemaSpec = exports.createMathView = exports.mathPlugin = exports.MathView = void 0;
-// core functionality
-var math_nodeview_1 = require("./math-nodeview");
-Object.defineProperty(exports, "MathView", { enumerable: true, get: function () { return math_nodeview_1.MathView; } });
-var math_plugin_1 = require("./math-plugin");
-Object.defineProperty(exports, "mathPlugin", { enumerable: true, get: function () { return math_plugin_1.mathPlugin; } });
-Object.defineProperty(exports, "createMathView", { enumerable: true, get: function () { return math_plugin_1.createMathView; } });
-var math_schema_1 = require("./math-schema");
-Object.defineProperty(exports, "mathSchemaSpec", { enumerable: true, get: function () { return math_schema_1.mathSchemaSpec; } });
-Object.defineProperty(exports, "createMathSchema", { enumerable: true, get: function () { return math_schema_1.createMathSchema; } });
-// recommended plugins
-var math_backspace_1 = require("./plugins/math-backspace");
-Object.defineProperty(exports, "mathBackspaceCmd", { enumerable: true, get: function () { return math_backspace_1.mathBackspaceCmd; } });
-var math_inputrules_1 = require("./plugins/math-inputrules");
-Object.defineProperty(exports, "makeBlockMathInputRule", { enumerable: true, get: function () { return math_inputrules_1.makeBlockMathInputRule; } });
-Object.defineProperty(exports, "makeInlineMathInputRule", { enumerable: true, get: function () { return math_inputrules_1.makeInlineMathInputRule; } });
-Object.defineProperty(exports, "REGEX_BLOCK_MATH_DOLLARS", { enumerable: true, get: function () { return math_inputrules_1.REGEX_BLOCK_MATH_DOLLARS; } });
-Object.defineProperty(exports, "REGEX_INLINE_MATH_DOLLARS", { enumerable: true, get: function () { return math_inputrules_1.REGEX_INLINE_MATH_DOLLARS; } });
-Object.defineProperty(exports, "REGEX_INLINE_MATH_DOLLARS_ESCAPED", { enumerable: true, get: function () { return math_inputrules_1.REGEX_INLINE_MATH_DOLLARS_ESCAPED; } });
-// optional / experimental plugins
-var math_select_1 = require("./plugins/math-select");
-Object.defineProperty(exports, "mathSelectPlugin", { enumerable: true, get: function () { return math_select_1.mathSelectPlugin; } });
-// commands
-var insertmathnode_1 = require("./commands/insertmathnode");
-Object.defineProperty(exports, "insertMathNode", { enumerable: true, get: function () { return insertmathnode_1.insertMathNode; } });
-// utilities
-var text_serializer_1 = require("./utils/text-serializer");
-Object.defineProperty(exports, "mathSerializer", { enumerable: true, get: function () { return text_serializer_1.mathSerializer; } });
-__exportStar(require("./utils/types"), exports);
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.d.ts
deleted file mode 100644
index 9d1e9ae52..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.d.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Node as ProseNode } from "prosemirror-model";
-import { EditorState, Transaction, PluginKey } from "prosemirror-state";
-import { NodeView, EditorView, Decoration, DecorationSource } from "prosemirror-view";
-import { IMathPluginState } from "./math-plugin";
-import { MathRenderFn } from "./renderers/types";
-export interface ICursorPosObserver {
- /** indicates on which side cursor should appear when this node is selected */
- cursorSide: "start" | "end";
- /** */
- updateCursorPos(state: EditorState): void;
-}
-interface IMathViewOptions {
- /** Dom element name to use for this NodeView */
- tagName?: string;
- /** Used to render the Tex input */
- renderer: MathRenderFn;
- /** Should be true if node is inline */
- className?: string;
-}
-export declare class MathView implements NodeView, ICursorPosObserver {
- private _node;
- private _outerView;
- private _getPos;
- dom: HTMLElement;
- private _mathRenderElt;
- private _mathSrcElt;
- private _innerView;
- cursorSide: "start" | "end";
- private _tagName;
- private _isEditing;
- private _mathPluginKey;
- private options;
- /**
- * @param onDestroy Callback for when this NodeView is destroyed.
- * This NodeView should unregister itself from the list of ICursorPosObservers.
- *
- * Math Views support the following options:
- * @option displayMode If TRUE, will render math in display mode, otherwise in inline mode.
- * @option tagName HTML tag name to use for this NodeView. If none is provided,
- * will use the node name with underscores converted to hyphens.
- */
- constructor(node: ProseNode, view: EditorView, getPos: () => number, options: IMathViewOptions, mathPluginKey: PluginKey<IMathPluginState>, onDestroy?: () => void);
- destroy(): void;
- /**
- * Ensure focus on the inner editor whenever this node has focus.
- * This helps to prevent accidental deletions of math blocks.
- */
- ensureFocus(): void;
- update(node: ProseNode, _decorations: readonly Decoration[], _innerDecorations: DecorationSource): boolean;
- updateCursorPos(state: EditorState): void;
- selectNode(): void;
- deselectNode(): void;
- stopEvent(event: Event): boolean;
- ignoreMutation(): boolean;
- renderMath(): void;
- dispatchInner(tr: Transaction): void;
- openEditor(): void;
- /**
- * Called when the inner ProseMirror editor should close.
- *
- * @param render Optionally update the rendered math after closing. (which
- * is generally what we want to do, since the user is done editing!)
- */
- closeEditor(render?: boolean): void;
-}
-export {};
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js b/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js
deleted file mode 100644
index da571a1d2..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js
+++ /dev/null
@@ -1,284 +0,0 @@
-"use strict";
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MathView = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-const prosemirror_view_1 = require("prosemirror-view");
-const prosemirror_transform_1 = require("prosemirror-transform");
-const prosemirror_keymap_1 = require("prosemirror-keymap");
-const prosemirror_commands_1 = require("prosemirror-commands");
-const collapsemathnode_1 = require("./commands/collapsemathnode");
-class MathView {
- // == Lifecycle ===================================== //
- /**
- * @param onDestroy Callback for when this NodeView is destroyed.
- * This NodeView should unregister itself from the list of ICursorPosObservers.
- *
- * Math Views support the following options:
- * @option displayMode If TRUE, will render math in display mode, otherwise in inline mode.
- * @option tagName HTML tag name to use for this NodeView. If none is provided,
- * will use the node name with underscores converted to hyphens.
- */
- constructor(node, view, getPos, options, mathPluginKey, onDestroy) {
- // store arguments
- this.options = options;
- this._node = node;
- this._outerView = view;
- this._getPos = getPos;
- this._mathPluginKey = mathPluginKey;
- // editing state
- this.cursorSide = "start";
- this._isEditing = false;
- // options
- this._tagName = options.tagName || this._node.type.name.replace("_", "-");
- // create dom representation of nodeview
- this.dom = document.createElement(this._tagName);
- if (options.className)
- this.dom.classList.add(options.className);
- this.dom.classList.add("math-node");
- this._mathRenderElt = document.createElement("span");
- this._mathRenderElt.textContent = "";
- this._mathRenderElt.classList.add("math-render");
- this.dom.appendChild(this._mathRenderElt);
- this._mathSrcElt = document.createElement("span");
- this._mathSrcElt.classList.add("math-src");
- this.dom.appendChild(this._mathSrcElt);
- // ensure
- this.dom.addEventListener("click", () => this.ensureFocus());
- // render initial content
- this.renderMath();
- }
- destroy() {
- // close the inner editor without rendering
- this.closeEditor(false);
- // clean up dom elements
- if (this._mathRenderElt) {
- this._mathRenderElt.remove();
- delete this._mathRenderElt;
- }
- if (this._mathSrcElt) {
- this._mathSrcElt.remove();
- delete this._mathSrcElt;
- }
- this.dom.remove();
- }
- /**
- * Ensure focus on the inner editor whenever this node has focus.
- * This helps to prevent accidental deletions of math blocks.
- */
- ensureFocus() {
- if (this._innerView && this._outerView.hasFocus()) {
- this._innerView.focus();
- }
- }
- // == Updates ======================================= //
- update(node, _decorations, _innerDecorations) {
- if (!node.sameMarkup(this._node))
- return false;
- this._node = node;
- if (this._innerView) {
- let state = this._innerView.state;
- let start = node.content.findDiffStart(state.doc.content);
- if (start != null) {
- let diff = node.content.findDiffEnd(state.doc.content);
- if (diff) {
- let { a: endA, b: endB } = diff;
- let overlap = start - Math.min(endA, endB);
- if (overlap > 0) {
- endA += overlap;
- endB += overlap;
- }
- this._innerView.dispatch(state.tr
- .replace(start, endB, node.slice(start, endA))
- .setMeta("fromOutside", true));
- }
- }
- }
- if (!this._isEditing) {
- this.renderMath();
- }
- return true;
- }
- updateCursorPos(state) {
- const pos = this._getPos();
- const size = this._node.nodeSize;
- const inPmSelection = state.selection.from < pos + size && pos < state.selection.to;
- if (!inPmSelection) {
- this.cursorSide = pos < state.selection.from ? "end" : "start";
- }
- }
- // == Events ===================================== //
- selectNode() {
- if (!this._outerView.editable) {
- return;
- }
- this.dom.classList.add("ProseMirror-selectednode");
- if (!this._isEditing) {
- this.openEditor();
- }
- }
- deselectNode() {
- this.dom.classList.remove("ProseMirror-selectednode");
- if (this._isEditing) {
- this.closeEditor();
- }
- }
- stopEvent(event) {
- return (this._innerView !== undefined &&
- event.target !== undefined &&
- this._innerView.dom.contains(event.target));
- }
- ignoreMutation() {
- return true;
- }
- // == Rendering ===================================== //
- renderMath() {
- if (!this._mathRenderElt) {
- return;
- }
- // get tex string to render
- let content = this._node.content.content;
- let texString = "";
- if (content.length > 0 && content[0].textContent !== null) {
- texString = content[0].textContent.trim();
- }
- // empty math?
- if (texString.length < 1) {
- this.dom.classList.add("empty-math");
- // clear rendered math, since this node is in an invalid state
- while (this._mathRenderElt.firstChild) {
- this._mathRenderElt.firstChild.remove();
- }
- // do not render empty math
- return;
- }
- else {
- this.dom.classList.remove("empty-math");
- }
- // render katex, but fail gracefully
- try {
- this.options.renderer(texString, this._mathRenderElt);
- this._mathRenderElt.classList.remove("parse-error");
- this.dom.setAttribute("title", "");
- }
- catch (err) {
- if (err instanceof Error) {
- console.error(err);
- this._mathRenderElt.classList.add("parse-error");
- this.dom.setAttribute("title", err.toString());
- }
- }
- }
- // == Inner Editor ================================== //
- dispatchInner(tr) {
- if (!this._innerView) {
- return;
- }
- let { state, transactions } = this._innerView.state.applyTransaction(tr);
- this._innerView.updateState(state);
- if (!tr.getMeta("fromOutside")) {
- let outerTr = this._outerView.state.tr, offsetMap = prosemirror_transform_1.StepMap.offset(this._getPos() + 1);
- for (let i = 0; i < transactions.length; i++) {
- let steps = transactions[i].steps;
- for (let j = 0; j < steps.length; j++) {
- let mapped = steps[j].map(offsetMap);
- if (!mapped) {
- throw Error("step discarded!");
- }
- outerTr.step(mapped);
- }
- }
- if (outerTr.docChanged)
- this._outerView.dispatch(outerTr);
- }
- }
- openEditor() {
- var _a;
- if (this._innerView) {
- throw Error("inner view should not exist!");
- }
- if (!this._mathSrcElt)
- throw new Error("_mathSrcElt does not exist!");
- // create a nested ProseMirror view
- this._innerView = new prosemirror_view_1.EditorView(this._mathSrcElt, {
- state: prosemirror_state_1.EditorState.create({
- doc: this._node,
- plugins: [
- (0, prosemirror_keymap_1.keymap)({
- Tab: (state, dispatch) => {
- if (dispatch) {
- dispatch(state.tr.insertText("\t"));
- }
- return true;
- },
- Backspace: (0, prosemirror_commands_1.chainCommands)(prosemirror_commands_1.deleteSelection, (state, dispatch, tr_inner) => {
- // default backspace behavior for non-empty selections
- if (!state.selection.empty) {
- return false;
- }
- // default backspace behavior when math node is non-empty
- if (this._node.textContent.length > 0) {
- return false;
- }
- // otherwise, we want to delete the empty math node and focus the outer view
- this._outerView.dispatch(this._outerView.state.tr.insertText(""));
- this._outerView.focus();
- return true;
- }),
- // "Ctrl-Backspace": (state, dispatch, tr_inner) => {
- // // delete math node and focus the outer view
- // this._outerView.dispatch(this._outerView.state.tr.insertText(""));
- // this._outerView.focus();
- // return true;
- // },
- Enter: (0, prosemirror_commands_1.chainCommands)(prosemirror_commands_1.newlineInCode, (0, collapsemathnode_1.collapseMathNode)(this._outerView, +1, false)),
- "Ctrl-Enter": (0, collapsemathnode_1.collapseMathNode)(this._outerView, +1, false),
- ArrowLeft: (0, collapsemathnode_1.collapseMathNode)(this._outerView, -1, true),
- ArrowRight: (0, collapsemathnode_1.collapseMathNode)(this._outerView, +1, true),
- ArrowUp: (0, collapsemathnode_1.collapseMathNode)(this._outerView, -1, true),
- ArrowDown: (0, collapsemathnode_1.collapseMathNode)(this._outerView, +1, true),
- }),
- ],
- }),
- dispatchTransaction: this.dispatchInner.bind(this),
- });
- // focus element
- let innerState = this._innerView.state;
- this._innerView.focus();
- // request outer cursor position before math node was selected
- let maybePos = (_a = this._mathPluginKey.getState(this._outerView.state)) === null || _a === void 0 ? void 0 : _a.prevCursorPos;
- if (maybePos === null || maybePos === undefined) {
- console.error("[prosemirror-math] Error: Unable to fetch math plugin state from key.");
- }
- let prevCursorPos = maybePos !== null && maybePos !== void 0 ? maybePos : 0;
- // compute position that cursor should appear within the expanded math node
- let innerPos = prevCursorPos <= this._getPos() ? 0 : this._node.nodeSize - 2;
- setTimeout(() => {
- if (!this._innerView)
- return;
- this._innerView.focus();
- this._innerView.dispatch(innerState.tr.setSelection(prosemirror_state_1.TextSelection.create(innerState.doc, innerPos)));
- });
- this._isEditing = true;
- }
- /**
- * Called when the inner ProseMirror editor should close.
- *
- * @param render Optionally update the rendered math after closing. (which
- * is generally what we want to do, since the user is done editing!)
- */
- closeEditor(render = true) {
- if (this._innerView) {
- this._innerView.destroy();
- this._innerView = undefined;
- }
- if (render) {
- this.renderMath();
- }
- this._isEditing = false;
- }
-}
-exports.MathView = MathView;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-plugin.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/math-plugin.d.ts
deleted file mode 100644
index b7bd86a3f..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-plugin.d.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Node as ProseNode } from "prosemirror-model";
-import { Plugin as ProsePlugin } from "prosemirror-state";
-import { MathView } from "./math-node-view";
-import { EditorView } from "prosemirror-view";
-export interface IMathPluginState {
- macros: {
- [cmd: string]: string;
- };
- /** A list of currently active `NodeView`s, in insertion order. */
- activeNodeViews: MathView[];
- /**
- * Used to determine whether to place the cursor in the front- or back-most
- * position when expanding a math node, without overriding the default arrow
- * key behavior.
- */
- prevCursorPos: number;
-}
-/**
- * Returns a function suitable for passing as a field in `EditorProps.nodeViews`.
- * @param inline TRUE for block math, FALSE for inline math.
- * @see https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
- */
-export declare function createMathView(inline: boolean): (node: ProseNode, view: EditorView, getPos: boolean | (() => number)) => MathView;
-export declare const mathPlugin: ProsePlugin<IMathPluginState>;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-plugin.js b/packages/editor/dist/cjs/extensions/math/plugin/math-plugin.js
deleted file mode 100644
index bdb935e9d..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-plugin.js
+++ /dev/null
@@ -1,75 +0,0 @@
-"use strict";
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.mathPlugin = exports.createMathView = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-const math_nodeview_1 = require("./math-nodeview");
-const katex_1 = require("./renderers/katex");
-// uniquely identifies the prosemirror-math plugin
-const MATH_PLUGIN_KEY = new prosemirror_state_1.PluginKey("prosemirror-math");
-/**
- * Returns a function suitable for passing as a field in `EditorProps.nodeViews`.
- * @param inline TRUE for block math, FALSE for inline math.
- * @see https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
- */
-function createMathView(inline) {
- return (node, view, getPos) => {
- /** @todo is this necessary?
- * Docs says that for any function proprs, the current plugin instance
- * will be bound to `this`. However, the typings don't reflect this.
- */
- let pluginState = MATH_PLUGIN_KEY.getState(view.state);
- if (!pluginState) {
- throw new Error("no math plugin!");
- }
- let nodeViews = pluginState.activeNodeViews;
- // set up NodeView
- let nodeView = new math_nodeview_1.MathView(node, view, getPos, {
- className: inline ? "math-inline" : "math-block",
- renderer: inline ? katex_1.KatexRenderer.inline : katex_1.KatexRenderer.block,
- tagName: inline ? "span" : "div",
- }, MATH_PLUGIN_KEY, () => {
- nodeViews.splice(nodeViews.indexOf(nodeView));
- });
- nodeViews.push(nodeView);
- return nodeView;
- };
-}
-exports.createMathView = createMathView;
-let mathPluginSpec = {
- key: MATH_PLUGIN_KEY,
- state: {
- init(config, instance) {
- return {
- macros: {},
- activeNodeViews: [],
- prevCursorPos: 0,
- };
- },
- apply(tr, value, oldState, newState) {
- // produce updated state field for this plugin
- const newPos = newState.selection.from;
- const oldPos = oldState.selection.from;
- return {
- // these values are left unchanged
- activeNodeViews: value.activeNodeViews,
- macros: value.macros,
- // update with the second-most recent cursor pos
- prevCursorPos: oldPos !== newPos ? oldPos : value.prevCursorPos,
- };
- },
- /** @todo (8/21/20) implement serialization for math plugin */
- // toJSON(value) { },
- // fromJSON(config, value, state){ return {}; }
- },
- props: {
- nodeViews: {
- mathInline: createMathView(true),
- mathBlock: createMathView(false),
- },
- },
-};
-exports.mathPlugin = new prosemirror_state_1.Plugin(mathPluginSpec);
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-schema.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/math-schema.d.ts
deleted file mode 100644
index 1bf09c98a..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-schema.d.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { MarkSpec, NodeSpec, Schema, SchemaSpec } from "prosemirror-model";
-import { SchemaSpecMarkT, SchemaSpecNodeT } from "./utils/types";
-/**
- * Borrowed from ProseMirror typings, modified to exclude OrderedMaps in spec,
- * in order to help with the schema-building functions below.
- *
- * NOTE: TypeScript's typings for the spread operator { ...a, ...b } are only
- * an approximation to the true type, and have difficulty with optional fields.
- * So, unlike the SchemaSpec type, the `marks` field is NOT optional here.
- *
- * function example<T extends string>(x: { [name in T]: string; } | null) {
- * const s = { ...x }; // inferred to have type `{}`.
- * }
- *
- * @see https://github.com/microsoft/TypeScript/issues/10727
- */
-interface SchemaSpecJson<N extends string = any, M extends string = any> extends SchemaSpec<N, M> {
- nodes: {
- [name in N]: NodeSpec;
- };
- marks: {
- [name in M]: MarkSpec;
- };
- topNode?: string;
-}
-declare type MathSpecNodeT = SchemaSpecNodeT<typeof mathSchemaSpec>;
-declare type MathSpecMarkT = SchemaSpecMarkT<typeof mathSchemaSpec>;
-export declare const mathSchemaSpec: SchemaSpecJson<"paragraph" | "text" | "doc" | "math_inline" | "math_display", "math_select">;
-/**
- * Use the prosemirror-math default SchemaSpec to create a new Schema.
- */
-export declare function createMathSchema(): Schema<"paragraph" | "text" | "doc" | "math_inline" | "math_display", "math_select">;
-/**
- * Create a new SchemaSpec by adding math nodes to an existing spec.
-
- * @deprecated This function is included for demonstration/testing only. For the
- * time being, I highly recommend adding the math nodes manually to your own
- * ProseMirror spec to avoid unexpected interactions between the math nodes
- * and your own spec. Use the example spec for reference.
- *
- * @param baseSpec The SchemaSpec to extend. Must specify a `marks` field, and
- * must be a raw object (not an OrderedMap).
- */
-export declare function extendMathSchemaSpec<N extends string, M extends string>(baseSpec: SchemaSpecJson<N, M>): SchemaSpecJson<N | MathSpecNodeT, M | MathSpecMarkT>;
-export {};
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-schema.js b/packages/editor/dist/cjs/extensions/math/plugin/math-schema.js
deleted file mode 100644
index 8e31a309d..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-schema.js
+++ /dev/null
@@ -1,83 +0,0 @@
-"use strict";
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.extendMathSchemaSpec = exports.createMathSchema = exports.mathSchemaSpec = void 0;
-// prosemirror imports
-const prosemirror_model_1 = require("prosemirror-model");
-const math_paste_rules_1 = require("./plugins/math-paste-rules");
-////////////////////////////////////////////////////////////
-// force typescript to infer generic type arguments for SchemaSpec
-function createSchemaSpec(spec) {
- return spec;
-}
-// bare minimum ProseMirror schema for working with math nodes
-exports.mathSchemaSpec = createSchemaSpec({
- nodes: {
- // :: NodeSpec top-level document node
- doc: {
- content: "block+",
- },
- paragraph: {
- content: "inline*",
- group: "block",
- parseDOM: [{ tag: "p" }],
- toDOM() {
- return ["p", 0];
- },
- },
- math_inline: {
- group: "inline math",
- content: "text*",
- inline: true,
- atom: true,
- toDOM: () => ["math-inline", { class: "math-node" }, 0],
- parseDOM: [{ tag: "math-inline" }, ...math_paste_rules_1.defaultInlineMathParseRules],
- },
- math_display: {
- group: "block math",
- content: "text*",
- atom: true,
- code: true,
- toDOM: () => ["math-display", { class: "math-node" }, 0],
- parseDOM: [{ tag: "math-display" }, ...math_paste_rules_1.defaultBlockMathParseRules],
- },
- text: {
- group: "inline",
- },
- },
- marks: {
- math_select: {
- toDOM() {
- return ["math-select", 0];
- },
- parseDOM: [{ tag: "math-select" }],
- },
- },
-});
-/**
- * Use the prosemirror-math default SchemaSpec to create a new Schema.
- */
-function createMathSchema() {
- return new prosemirror_model_1.Schema(exports.mathSchemaSpec);
-}
-exports.createMathSchema = createMathSchema;
-/**
- * Create a new SchemaSpec by adding math nodes to an existing spec.
-
- * @deprecated This function is included for demonstration/testing only. For the
- * time being, I highly recommend adding the math nodes manually to your own
- * ProseMirror spec to avoid unexpected interactions between the math nodes
- * and your own spec. Use the example spec for reference.
- *
- * @param baseSpec The SchemaSpec to extend. Must specify a `marks` field, and
- * must be a raw object (not an OrderedMap).
- */
-function extendMathSchemaSpec(baseSpec) {
- let nodes = Object.assign(Object.assign({}, baseSpec.nodes), exports.mathSchemaSpec.nodes);
- let marks = Object.assign(Object.assign({}, baseSpec.marks), exports.mathSchemaSpec.marks);
- return { nodes, marks, topNode: baseSpec.topNode };
-}
-exports.extendMathSchemaSpec = extendMathSchemaSpec;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-backspace.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-backspace.d.ts
deleted file mode 100644
index 634f31931..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-backspace.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { Command as ProseCommand } from "prosemirror-state";
-export declare const mathBackspaceCmd: ProseCommand;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-backspace.js b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-backspace.js
deleted file mode 100644
index cfb9d7118..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-backspace.js
+++ /dev/null
@@ -1,29 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.mathBackspaceCmd = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-const mathBackspaceCmd = (state, dispatch) => {
- // check node before
- let { $from } = state.selection;
- let nodeBefore = $from.nodeBefore;
- if (!nodeBefore) {
- return false;
- }
- if (nodeBefore.type.name == "math_inline") {
- // select math node
- let index = $from.index($from.depth);
- let $beforePos = state.doc.resolve($from.posAtIndex(index - 1));
- if (dispatch) {
- dispatch(state.tr.setSelection(new prosemirror_state_1.NodeSelection($beforePos)));
- }
- return true;
- }
- else if (nodeBefore.type.name == "math_block") {
- /** @todo (8/1/20) implement backspace for math blocks
- * check how code blocks behave when pressing backspace
- */
- return false;
- }
- return false;
-};
-exports.mathBackspaceCmd = mathBackspaceCmd;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-inputrules.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-inputrules.d.ts
deleted file mode 100644
index 92f1be7e5..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-inputrules.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { InputRule } from "prosemirror-inputrules";
-import { NodeType } from "prosemirror-model";
-export declare const REGEX_INLINE_MATH_DOLLARS: RegExp;
-export declare const REGEX_INLINE_MATH_DOLLARS_ESCAPED: RegExp;
-export declare const REGEX_BLOCK_MATH_DOLLARS: RegExp;
-export declare function makeInlineMathInputRule(pattern: RegExp, nodeType: NodeType, getAttrs?: (match: string[]) => any): InputRule;
-export declare function makeBlockMathInputRule(pattern: RegExp, nodeType: NodeType, getAttrs?: (match: string[]) => any): InputRule;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-inputrules.js b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-inputrules.js
deleted file mode 100644
index 4bb70b42a..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-inputrules.js
+++ /dev/null
@@ -1,60 +0,0 @@
-"use strict";
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.makeBlockMathInputRule = exports.makeInlineMathInputRule = exports.REGEX_BLOCK_MATH_DOLLARS = exports.REGEX_INLINE_MATH_DOLLARS_ESCAPED = exports.REGEX_INLINE_MATH_DOLLARS = void 0;
-const prosemirror_inputrules_1 = require("prosemirror-inputrules");
-const prosemirror_state_1 = require("prosemirror-state");
-////////////////////////////////////////////////////////////
-// ---- Inline Input Rules ------------------------------ //
-// simple input rule for inline math
-exports.REGEX_INLINE_MATH_DOLLARS = /\$\$(.+)\$\$/; //new RegExp("\$(.+)\$", "i");
-// negative lookbehind regex notation allows for escaped \$ delimiters
-// (requires browser supporting ECMA2018 standard -- currently only Chrome / FF)
-// (see https://javascript.info/regexp-lookahead-lookbehind)
-exports.REGEX_INLINE_MATH_DOLLARS_ESCAPED = (() => {
- // attempt to create regex with negative lookbehind
- try {
- return new RegExp("(?<!\\\\)\\$(.+)(?<!\\\\)\\$");
- }
- catch (e) {
- return exports.REGEX_INLINE_MATH_DOLLARS;
- }
-})();
-// ---- Block Input Rules ------------------------------- //
-// simple inputrule for block math
-exports.REGEX_BLOCK_MATH_DOLLARS = /\$\$\$\s+$/; //new RegExp("\$\$\s+$", "i");
-////////////////////////////////////////////////////////////
-function makeInlineMathInputRule(pattern, nodeType, getAttrs) {
- return new prosemirror_inputrules_1.InputRule(pattern, (state, match, start, end) => {
- let $start = state.doc.resolve(start);
- let index = $start.index();
- let $end = state.doc.resolve(end);
- // get attrs
- let attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
- // check if replacement valid
- if (!$start.parent.canReplaceWith(index, $end.index(), nodeType)) {
- return null;
- }
- // perform replacement
- return state.tr.replaceRangeWith(start, end, nodeType.create(attrs, nodeType.schema.text(match[1])));
- });
-}
-exports.makeInlineMathInputRule = makeInlineMathInputRule;
-function makeBlockMathInputRule(pattern, nodeType, getAttrs) {
- return new prosemirror_inputrules_1.InputRule(pattern, (state, match, start, end) => {
- let $start = state.doc.resolve(start);
- let attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
- if (!$start
- .node(-1)
- .canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType))
- return null;
- let tr = state.tr
- .delete(start, end)
- .setBlockType(start, start, nodeType, attrs);
- return tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, tr.mapping.map($start.pos - 1)));
- });
-}
-exports.makeBlockMathInputRule = makeBlockMathInputRule;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-paste-rules.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-paste-rules.d.ts
deleted file mode 100644
index f6fb45c04..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-paste-rules.d.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Note that for some of the `ParseRule`s defined below,
- * we define a `getAttrs` function, which, other than
- * defining node attributes, can be used to describe complex
- * match conditions for a rule.
-
- * Returning `false` from `ParseRule.getAttrs` prevents the
- * rule from matching, while returning `null` indicates that
- * the default set of note attributes should be used.
- */
-import { ParseRule } from "prosemirror-model";
-/**
- * Wikipedia formats block math inside a <dl>...</dl> element, as below.
- *
- * - Evidently no CSS class is used to distinguish inline vs block math
- * - Sometimes the `\displaystyle` TeX command is present even in inline math
- *
- * ```html
- * <dl><dd><span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span></dd></dl>
- * ```
- */
-export declare const wikipediaBlockMathParseRule: ParseRule;
-/**
- * Parse rule for inline math content on Wikipedia of the following form:
- *
- * ```html
- * <span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span>
- * ```
- */
-export declare const wikipediaInlineMathParseRule: ParseRule;
-export declare const defaultInlineMathParseRules: ParseRule[];
-export declare const defaultBlockMathParseRules: ParseRule[];
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-paste-rules.js b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-paste-rules.js
deleted file mode 100644
index 31b773359..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-paste-rules.js
+++ /dev/null
@@ -1,174 +0,0 @@
-"use strict";
-/**
- * Note that for some of the `ParseRule`s defined below,
- * we define a `getAttrs` function, which, other than
- * defining node attributes, can be used to describe complex
- * match conditions for a rule.
-
- * Returning `false` from `ParseRule.getAttrs` prevents the
- * rule from matching, while returning `null` indicates that
- * the default set of note attributes should be used.
- */
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.defaultBlockMathParseRules = exports.defaultInlineMathParseRules = exports.wikipediaInlineMathParseRule = exports.wikipediaBlockMathParseRule = void 0;
-const prosemirror_model_1 = require("prosemirror-model");
-////////////////////////////////////////////////////////////
-function getFirstMatch(root, rules) {
- for (let rule of rules) {
- let match = rule(root);
- if (match !== false) {
- return match;
- }
- }
- return false;
-}
-function makeTextFragment(text, schema) {
- return prosemirror_model_1.Fragment.from(schema.text(text));
-}
-////////////////////////////////////////////////////////////
-// -- Wikipedia ----------------------------------------- //
-/**
- * Look for a child node that matches the following template:
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- */
-function texFromMediaWikiFallbackImage(root) {
- var _a;
- let match = root.querySelector("img.mwe-math-fallback-image-inline[alt]");
- return (_a = match === null || match === void 0 ? void 0 : match.getAttribute("alt")) !== null && _a !== void 0 ? _a : false;
-}
-/**
- * Look for a child node that matches the following template:
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- */
-function texFromMathML_01(root) {
- var _a;
- let match = root.querySelector("math[alttext]");
- return (_a = match === null || match === void 0 ? void 0 : match.getAttribute("alttext")) !== null && _a !== void 0 ? _a : false;
-}
-/**
- * Look for a child node that matches the following template:
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- */
-function texFromMathML_02(root) {
- var _a;
- let match = root.querySelector("math annotation[encoding='application/x-tex'");
- return (_a = match === null || match === void 0 ? void 0 : match.textContent) !== null && _a !== void 0 ? _a : false;
-}
-/**
- * Look for a child node that matches the following template:
- * <script type="math/tex"></script>
- */
-function texFromScriptTag(root) {
- var _a;
- let match = root.querySelector("script[type*='math/tex']");
- return (_a = match === null || match === void 0 ? void 0 : match.textContent) !== null && _a !== void 0 ? _a : false;
-}
-function matchWikipedia(root) {
- let match = getFirstMatch(root, [
- texFromMediaWikiFallbackImage,
- texFromMathML_01,
- texFromMathML_02,
- ]);
- // TODO: if no tex string was found, but we have MathML, try to parse it
- return match;
-}
-/**
- * Wikipedia formats block math inside a <dl>...</dl> element, as below.
- *
- * - Evidently no CSS class is used to distinguish inline vs block math
- * - Sometimes the `\displaystyle` TeX command is present even in inline math
- *
- * ```html
- * <dl><dd><span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span></dd></dl>
- * ```
- */
-exports.wikipediaBlockMathParseRule = {
- tag: "dl",
- getAttrs(p) {
- let dl = p;
- // <dl> must contain exactly one child
- if (dl.childElementCount !== 1) {
- return false;
- }
- let dd = dl.firstChild;
- if (dd.tagName !== "DD") {
- return false;
- }
- // <dd> must contain exactly one child
- if (dd.childElementCount !== 1) {
- return false;
- }
- let mweElt = dd.firstChild;
- if (!mweElt.classList.contains("mwe-math-element")) {
- return false;
- }
- // success! proceed to `getContent` for further processing
- return null;
- },
- getContent(p, schema) {
- // search the matched element for a TeX string
- let match = matchWikipedia(p);
- // return a fragment representing the math node's children
- let texString = match || "\\text{\\color{red}(paste error)}";
- return makeTextFragment(texString, schema);
- },
-};
-/**
- * Parse rule for inline math content on Wikipedia of the following form:
- *
- * ```html
- * <span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span>
- * ```
- */
-exports.wikipediaInlineMathParseRule = {
- tag: "span",
- getAttrs(p) {
- let span = p;
- if (!span.classList.contains("mwe-math-element")) {
- return false;
- }
- // success! proceed to `getContent` for further processing
- return null;
- },
- getContent(p, schema) {
- // search the matched element for a TeX string
- let match = matchWikipedia(p);
- // return a fragment representing the math node's children
- let texString = match || "\\text{\\color{red}(paste error)}";
- return makeTextFragment(texString, schema);
- },
-};
-// -- MathJax ------------------------------------------- //
-////////////////////////////////////////////////////////////
-exports.defaultInlineMathParseRules = [
- exports.wikipediaInlineMathParseRule,
-];
-exports.defaultBlockMathParseRules = [
- exports.wikipediaBlockMathParseRule,
-];
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-select.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-select.d.ts
deleted file mode 100644
index fa6e7915e..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-select.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Plugin as ProsePlugin } from "prosemirror-state";
-/**
- * Due to the internals of KaTeX, by default, selecting rendered
- * math will put a box around each individual character of a
- * math expression. This plugin attempts to make math selections
- * slightly prettier by instead setting a background color on the node.
- *
- * (remember to use the included math.css!)
- *
- * @todo (6/13/20) math selection rectangles are not quite even with text
- */
-export declare const mathSelectPlugin: ProsePlugin;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-select.js b/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-select.js
deleted file mode 100644
index 1a212d909..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/plugins/math-select.js
+++ /dev/null
@@ -1,65 +0,0 @@
-"use strict";
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.mathSelectPlugin = void 0;
-// prosemirror imports
-const prosemirror_state_1 = require("prosemirror-state");
-const prosemirror_view_1 = require("prosemirror-view");
-////////////////////////////////////////////////////////////
-/**
- * Uses the selection to determine which math_select decorations
- * should be applied to the given document.
- * @param arg Should be either a Transaction or an EditorState,
- * although any object with `selection` and `doc` will work.
- */
-const checkSelection = (arg) => {
- let { from, to } = arg.selection;
- let content = arg.selection.content().content;
- let result = [];
- content.descendants((node, pos, parent) => {
- if (node.type.name == "text") {
- return false;
- }
- if (node.type.name.startsWith("math_")) {
- result.push({
- start: Math.max(from + pos - 1, 0),
- end: from + pos + node.nodeSize - 1,
- });
- return false;
- }
- return true;
- });
- return prosemirror_view_1.DecorationSet.create(arg.doc, result.map(({ start, end }) => prosemirror_view_1.Decoration.node(start, end, { class: "math-select" })));
-};
-/**
- * Due to the internals of KaTeX, by default, selecting rendered
- * math will put a box around each individual character of a
- * math expression. This plugin attempts to make math selections
- * slightly prettier by instead setting a background color on the node.
- *
- * (remember to use the included math.css!)
- *
- * @todo (6/13/20) math selection rectangles are not quite even with text
- */
-exports.mathSelectPlugin = new prosemirror_state_1.Plugin({
- state: {
- init(config, partialState) {
- return checkSelection(partialState);
- },
- apply(tr, value, oldState, newState) {
- if (!tr.selection || !tr.selectionSet) {
- return oldState;
- }
- let sel = checkSelection(tr);
- return sel;
- },
- },
- props: {
- decorations: (state) => {
- return exports.mathSelectPlugin.getState(state);
- },
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/renderers/katex.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/renderers/katex.d.ts
deleted file mode 100644
index 0b716cff8..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/renderers/katex.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { MathRenderer } from "./types";
-export declare const KatexRenderer: MathRenderer;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/renderers/katex.js b/packages/editor/dist/cjs/extensions/math/plugin/renderers/katex.js
deleted file mode 100644
index db876e50c..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/renderers/katex.js
+++ /dev/null
@@ -1,65 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.KatexRenderer = void 0;
-function loadKatex() {
- return __awaiter(this, void 0, void 0, function* () {
- // @ts-ignore
- const { default: katex } = yield Promise.resolve().then(() => __importStar(require("katex")));
- // Chemistry formulas support
- // @ts-ignore
- yield Promise.resolve().then(() => __importStar(require("katex/contrib/mhchem/mhchem")));
- return katex;
- });
-}
-exports.KatexRenderer = {
- inline: (text, element) => {
- loadKatex().then((katex) => {
- katex.render(text, element, {
- displayMode: false,
- globalGroup: true,
- throwOnError: false,
- });
- });
- },
- block: (text, element) => {
- loadKatex().then((katex) => {
- katex.render(text, element, {
- displayMode: true,
- globalGroup: true,
- throwOnError: false,
- });
- });
- },
-};
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/renderers/types.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/renderers/types.d.ts
deleted file mode 100644
index 437b6338b..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/renderers/types.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export declare type MathRenderFn = (text: string, element: HTMLElement) => void;
-export declare type MathRenderer = {
- inline: MathRenderFn;
- block: MathRenderFn;
-};
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/renderers/types.js b/packages/editor/dist/cjs/extensions/math/plugin/renderers/types.js
deleted file mode 100644
index c8ad2e549..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/renderers/types.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/utils/text-serializer.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/utils/text-serializer.d.ts
deleted file mode 100644
index 4e03d2a81..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/utils/text-serializer.d.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Node as ProseNode, Mark, Slice, NodeType, MarkType, Fragment } from "prosemirror-model";
-declare type TypedNode<T extends string> = ProseNode & {
- type: NodeType & {
- name: T;
- };
-};
-declare type TypedMark<T extends string> = Mark & {
- type: MarkType & {
- name: T;
- };
-};
-declare type NodeSerializer<T extends string> = (node: TypedNode<T>) => string;
-declare type MarkSerializer<T extends string> = (mark: TypedMark<T>) => string;
-declare class ProseMirrorTextSerializer {
- nodes: {
- [name: string]: NodeSerializer<string> | undefined;
- };
- marks: {
- [name: string]: MarkSerializer<string> | undefined;
- };
- constructor(fns: {
- nodes?: {
- [name: string]: NodeSerializer<string> | undefined;
- };
- marks?: {
- [name: string]: MarkSerializer<string> | undefined;
- };
- }, base?: ProseMirrorTextSerializer);
- serializeFragment(fragment: Fragment): string;
- serializeSlice(slice: Slice): string;
- serializeNode(node: ProseNode): string | null;
-}
-export declare const mathSerializer: ProseMirrorTextSerializer;
-export {};
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/utils/text-serializer.js b/packages/editor/dist/cjs/extensions/math/plugin/utils/text-serializer.js
deleted file mode 100644
index 79f089921..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/utils/text-serializer.js
+++ /dev/null
@@ -1,61 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.mathSerializer = void 0;
-class ProseMirrorTextSerializer {
- constructor(fns, base) {
- // use base serializer as a fallback
- this.nodes = Object.assign(Object.assign({}, base === null || base === void 0 ? void 0 : base.nodes), fns.nodes);
- this.marks = Object.assign(Object.assign({}, base === null || base === void 0 ? void 0 : base.marks), fns.marks);
- }
- serializeFragment(fragment) {
- // adapted from the undocumented `Fragment.textBetween` function
- // https://github.com/ProseMirror/prosemirror-model/blob/eef20c8c6dbf841b1d70859df5d59c21b5108a4f/src/fragment.js#L46
- let blockSeparator = "\n\n";
- let leafText = undefined;
- let text = "";
- let separated = true;
- let from = 0;
- let to = fragment.size;
- fragment.nodesBetween(from, to, (node, pos) => {
- var _a;
- // check if one of our custom serializers handles this node
- let serialized = this.serializeNode(node);
- if (serialized !== null) {
- text += serialized;
- return false;
- }
- if (node.isText) {
- text += ((_a = node.text) === null || _a === void 0 ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos)) || "";
- separated = !blockSeparator;
- }
- else if (node.isLeaf && leafText) {
- text += leafText;
- separated = !blockSeparator;
- }
- else if (!separated && node.isBlock) {
- text += blockSeparator;
- separated = true;
- }
- }, 0);
- return text;
- }
- serializeSlice(slice) {
- return this.serializeFragment(slice.content);
- }
- serializeNode(node) {
- // check if one of our custom serializers handles this node
- let nodeSerializer = this.nodes[node.type.name];
- if (nodeSerializer !== undefined) {
- return nodeSerializer(node);
- }
- else {
- return null;
- }
- }
-}
-exports.mathSerializer = new ProseMirrorTextSerializer({
- nodes: {
- math_inline: (node) => `$${node.textContent}$`,
- math_display: (node) => `\n\n$$\n${node.textContent}\n$$`,
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/utils/types.d.ts b/packages/editor/dist/cjs/extensions/math/plugin/utils/types.d.ts
deleted file mode 100644
index 6792b9f33..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/utils/types.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { Schema, SchemaSpec } from "prosemirror-model";
-export declare type SchemaSpecNodeT<Spec> = Spec extends SchemaSpec<infer N, infer _> ? N : never;
-export declare type SchemaSpecMarkT<Spec> = Spec extends SchemaSpec<infer _, infer M> ? M : never;
-export declare type SchemaNodeT<S> = S extends Schema<infer N, infer _> ? N : never;
-export declare type SchemaMarkT<S> = S extends Schema<infer _, infer M> ? M : never;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/utils/types.js b/packages/editor/dist/cjs/extensions/math/plugin/utils/types.js
deleted file mode 100644
index c8ad2e549..000000000
--- a/packages/editor/dist/cjs/extensions/math/plugin/utils/types.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/packages/editor/dist/cjs/extensions/orderedlist/index.d.ts b/packages/editor/dist/cjs/extensions/orderedlist/index.d.ts
deleted file mode 100644
index e5d88c387..000000000
--- a/packages/editor/dist/cjs/extensions/orderedlist/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { OrderedList } from "./ordered-list";
-export * from "./ordered-list";
-export default OrderedList;
diff --git a/packages/editor/dist/cjs/extensions/orderedlist/index.js b/packages/editor/dist/cjs/extensions/orderedlist/index.js
deleted file mode 100644
index c06028c9a..000000000
--- a/packages/editor/dist/cjs/extensions/orderedlist/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const orderedlist_1 = require("./orderedlist");
-__exportStar(require("./orderedlist"), exports);
-exports.default = orderedlist_1.OrderedList;
diff --git a/packages/editor/dist/cjs/extensions/orderedlist/orderedlist.d.ts b/packages/editor/dist/cjs/extensions/orderedlist/orderedlist.d.ts
deleted file mode 100644
index 16afc3a43..000000000
--- a/packages/editor/dist/cjs/extensions/orderedlist/orderedlist.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const OrderedList: import("@tiptap/core").Node<import("@tiptap/extension-ordered-list").OrderedListOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/orderedlist/orderedlist.js b/packages/editor/dist/cjs/extensions/orderedlist/orderedlist.js
deleted file mode 100644
index f43da163c..000000000
--- a/packages/editor/dist/cjs/extensions/orderedlist/orderedlist.js
+++ /dev/null
@@ -1,25 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.OrderedList = void 0;
-const extension_ordered_list_1 = __importDefault(require("@tiptap/extension-ordered-list"));
-exports.OrderedList = extension_ordered_list_1.default.extend({
- addAttributes() {
- return {
- listType: {
- default: null,
- parseHTML: (element) => element.style.listStyleType,
- renderHTML: (attributes) => {
- if (!attributes.listType) {
- return {};
- }
- return {
- style: `list-style-type: ${attributes.listType}`,
- };
- },
- },
- };
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/component.d.ts b/packages/editor/dist/cjs/extensions/outlinelist/component.d.ts
deleted file mode 100644
index 2e64b6e02..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelist/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-import { OutlineListAttributes } from "./outline-list";
-export declare function OutlineListComponent(props: ReactNodeViewProps<OutlineListAttributes>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/component.js b/packages/editor/dist/cjs/extensions/outlinelist/component.js
deleted file mode 100644
index b0f91257c..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelist/component.js
+++ /dev/null
@@ -1,29 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.OutlineListComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const outlinelistitem_1 = require("../outlinelistitem");
-function OutlineListComponent(props) {
- const { editor, getPos, node, updateAttributes, forwardRef } = props;
- const { collapsed } = node.attrs;
- const isNested = (0, react_1.useMemo)(() => {
- var _a;
- const pos = editor.state.doc.resolve(getPos());
- return ((_a = pos.parent) === null || _a === void 0 ? void 0 : _a.type.name) === outlinelistitem_1.OutlineListItem.name;
- }, []);
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(rebass_1.Text, { className: "outline-list", as: "div", ref: forwardRef, sx: {
- ul: {
- display: collapsed ? "none" : "block",
- paddingInlineStart: 0,
- paddingLeft: 0,
- marginBlockStart: isNested ? 5 : 0,
- marginBlockEnd: 0
- },
- li: {
- listStyleType: "none"
- }
- } }) }));
-}
-exports.OutlineListComponent = OutlineListComponent;
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/index.d.ts b/packages/editor/dist/cjs/extensions/outlinelist/index.d.ts
deleted file mode 100644
index 5aec1c8aa..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./outline-list";
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/index.js b/packages/editor/dist/cjs/extensions/outlinelist/index.js
deleted file mode 100644
index 493cabb6c..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelist/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./outlinelist"), exports);
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/outlinelist.d.ts b/packages/editor/dist/cjs/extensions/outlinelist/outlinelist.d.ts
deleted file mode 100644
index 5c1a1f21f..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelist/outlinelist.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Node } from "@tiptap/core";
-export declare type OutlineListAttributes = {
- collapsed: boolean;
-};
-export interface OutlineListOptions {
- HTMLAttributes: Record<string, any>;
-}
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- outlineList: {
- /**
- * Toggle a bullet list
- */
- toggleOutlineList: () => ReturnType;
- };
- }
-}
-export declare const inputRegex: RegExp;
-export declare const OutlineList: Node<OutlineListOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/outlinelist.js b/packages/editor/dist/cjs/extensions/outlinelist/outlinelist.js
deleted file mode 100644
index f1221b053..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelist/outlinelist.js
+++ /dev/null
@@ -1,77 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.OutlineList = exports.inputRegex = void 0;
-const core_1 = require("@tiptap/core");
-const react_1 = require("../react");
-const component_1 = require("./component");
-exports.inputRegex = /^\s*(-o)\s$/;
-const outlineListItemName = `outlineListItem`;
-exports.OutlineList = core_1.Node.create({
- name: "outlineList",
- addOptions() {
- return {
- HTMLAttributes: {},
- };
- },
- addAttributes() {
- return {
- collapsed: {
- default: false,
- keepOnSplit: false,
- parseHTML: (element) => element.dataset.collapsed === "true",
- renderHTML: (attributes) => ({
- "data-collapsed": attributes.collapsed === true,
- }),
- },
- };
- },
- group: "block list",
- content: `${outlineListItemName}+`,
- parseHTML() {
- return [
- {
- tag: `ul[data-type="${this.name}"]`,
- priority: 52,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "ul",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
- "data-type": this.name,
- }),
- 0,
- ];
- },
- addCommands() {
- return {
- toggleOutlineList: () => ({ commands }) => {
- return commands.toggleList(this.name, outlineListItemName);
- },
- };
- },
- addKeyboardShortcuts() {
- return {
- "Mod-Shift-O": () => this.editor.commands.toggleOutlineList(),
- };
- },
- addInputRules() {
- return [
- (0, core_1.wrappingInputRule)({
- find: exports.inputRegex,
- type: this.type,
- }),
- ];
- },
- addNodeView() {
- return (0, react_1.createNodeView)(component_1.OutlineListComponent, {
- contentDOMFactory: () => {
- const content = document.createElement("ul");
- content.classList.add(`${this.name.toLowerCase()}-content-wrapper`);
- content.style.whiteSpace = "inherit";
- return { dom: content };
- },
- });
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/component.d.ts b/packages/editor/dist/cjs/extensions/outlinelistitem/component.d.ts
deleted file mode 100644
index 26d37f4a2..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/component.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-export declare function OutlineListItemComponent(props: ReactNodeViewProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/component.js b/packages/editor/dist/cjs/extensions/outlinelistitem/component.js
deleted file mode 100644
index 2230f05df..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/component.js
+++ /dev/null
@@ -1,64 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.OutlineListItemComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const core_1 = require("@tiptap/core");
-const outlinelist_1 = require("../outline-list/outlinelist");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-function OutlineListItemComponent(props) {
- var _a, _b;
- const { editor, updateAttributes, node, getPos, forwardRef } = props;
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const isNested = ((_a = node.lastChild) === null || _a === void 0 ? void 0 : _a.type.name) === outlinelist_1.OutlineList.name;
- const isCollapsed = isNested && ((_b = node.lastChild) === null || _b === void 0 ? void 0 : _b.attrs.collapsed);
- const onClick = () => {
- const [subList] = (0, core_1.findChildren)(node, (node) => node.type.name === outlinelist_1.OutlineList.name);
- if (!subList)
- return;
- const { pos } = subList;
- editor.commands.toggleOutlineCollapse(pos + getPos() + 1, !isCollapsed);
- };
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ className: "outline", sx: {
- flexDirection: "column",
- alignItems: "center",
- mt: isMobile ? "0px" : "3px"
- } }, { children: [isNested ? ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: isCollapsed ? icons_1.Icons.chevronRight : icons_1.Icons.chevronDown, title: isCollapsed
- ? "Click to uncollapse list"
- : "Click to collapse list", sx: {
- cursor: "pointer",
- transition: `all .2s ease-in-out`,
- ":hover": {
- transform: ["unset", "scale(1.3)"]
- },
- ":active": {
- transform: ["scale(1.3)", "unset"]
- },
- ".icon:hover path": {
- fill: "var(--checked) !important"
- }
- }, size: isMobile ? 24 : 18, onMouseDown: (e) => e.preventDefault(), onTouchEnd: (e) => {
- e.preventDefault();
- onClick();
- }, onClick: onClick })) : ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.circle, size: isMobile ? 24 : 18, sx: { transform: "scale(0.4)" } })), isNested && !isCollapsed && ((0, jsx_runtime_1.jsx)(rebass_1.Box, { sx: {
- flex: 1,
- width: 1,
- mt: 2,
- backgroundColor: "border",
- borderRadius: 50,
- flexShrink: 0,
- cursor: "pointer",
- transition: `all .2s ease-in-out`,
- ":hover": {
- backgroundColor: "fontTertiary",
- width: 4
- }
- }, contentEditable: false }))] })), (0, jsx_runtime_1.jsx)(rebass_1.Text, { ref: forwardRef, sx: {
- pl: 1,
- listStyleType: "none",
- flex: 1
- } })] }));
-}
-exports.OutlineListItemComponent = OutlineListItemComponent;
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/index.d.ts b/packages/editor/dist/cjs/extensions/outlinelistitem/index.d.ts
deleted file mode 100644
index 1b1e56bc7..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./outline-list-item";
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/index.js b/packages/editor/dist/cjs/extensions/outlinelistitem/index.js
deleted file mode 100644
index 81ad99aa5..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./outlinelistitem"), exports);
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.d.ts b/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.d.ts
deleted file mode 100644
index d9742f1d1..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Node } from "@tiptap/core";
-export interface ListItemOptions {
- HTMLAttributes: Record<string, any>;
-}
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- outlineListItem: {
- toggleOutlineCollapse: (subListPos: number, state: boolean) => ReturnType;
- };
- }
-}
-export declare const OutlineListItem: Node<ListItemOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js b/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js
deleted file mode 100644
index fb754aac0..000000000
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js
+++ /dev/null
@@ -1,102 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.OutlineListItem = void 0;
-const core_1 = require("@tiptap/core");
-const prosemirror_utils_1 = require("prosemirror-utils");
-const commands_1 = require("../list-item/commands");
-const outlinelist_1 = require("../outline-list/outlinelist");
-const react_1 = require("../react");
-const component_1 = require("./component");
-exports.OutlineListItem = core_1.Node.create({
- name: "outlineListItem",
- addOptions() {
- return {
- HTMLAttributes: {},
- };
- },
- content: "heading* paragraph block*",
- defining: true,
- parseHTML() {
- return [
- {
- tag: `li[data-type="${this.name}"]`,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "li",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
- "data-type": this.name,
- }),
- 0,
- ];
- },
- addKeyboardShortcuts() {
- return {
- "Mod-Space": ({ editor }) => {
- const subList = findSublist(editor, this.type);
- if (!subList)
- return false;
- const { isCollapsed, subListPos } = subList;
- return this.editor.commands.toggleOutlineCollapse(subListPos, !isCollapsed);
- },
- Enter: ({ editor }) => {
- // const subList = findSublist(editor, this.type);
- // if (!subList) return this.editor.commands.splitListItem(this.name);
- // const { isCollapsed, subListPos } = subList;
- // if (isCollapsed) {
- // return this.editor.commands.toggleOutlineCollapse(subListPos, false);
- // }
- return this.editor.commands.splitListItem(this.name);
- },
- Tab: () => this.editor.commands.sinkListItem(this.name),
- "Shift-Tab": () => this.editor.commands.liftListItem(this.name),
- Backspace: ({ editor }) => (0, commands_1.onBackspacePressed)(editor, this.name, this.type),
- };
- },
- addCommands() {
- return {
- toggleOutlineCollapse: (pos, state) => ({ tr }) => {
- tr.setNodeMarkup(pos, undefined, {
- collapsed: state,
- });
- return true;
- },
- };
- },
- addNodeView() {
- return (0, react_1.createNodeView)(component_1.OutlineListItemComponent, {
- contentDOMFactory: true,
- wrapperFactory: () => document.createElement("li"),
- });
- },
-});
-function findSublist(editor, type) {
- var _a, _b;
- const { selection } = editor.state;
- const { $from } = selection;
- const listItem = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($from, type);
- if (!listItem)
- return false;
- const [subList] = (0, core_1.findChildren)(listItem.node, (node) => node.type.name === outlinelist_1.OutlineList.name);
- if (!subList)
- return false;
- const isNested = ((_a = subList === null || subList === void 0 ? void 0 : subList.node) === null || _a === void 0 ? void 0 : _a.type.name) === outlinelist_1.OutlineList.name;
- const isCollapsed = (_b = subList === null || subList === void 0 ? void 0 : subList.node) === null || _b === void 0 ? void 0 : _b.attrs.collapsed;
- const subListPos = listItem.pos + subList.pos + 1;
- return { isCollapsed, isNested, subListPos };
- // return (
- // this.editor
- // .chain()
- // .command(({ tr }) => {
- // tr.setNodeMarkup(listItem.pos + subList.pos + 1, undefined, {
- // collapsed: !isCollapsed,
- // });
- // return true;
- // })
- // //.setTextSelection(listItem.pos + subList.pos + 1)
- // //.splitListItem(this.name)
- // .run()
- // );
-}
diff --git a/packages/editor/dist/cjs/extensions/react/eventdispatcher.d.ts b/packages/editor/dist/cjs/extensions/react/eventdispatcher.d.ts
deleted file mode 100644
index f9fba57a4..000000000
--- a/packages/editor/dist/cjs/extensions/react/eventdispatcher.d.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { PluginKey } from "prosemirror-state";
-export interface Listeners {
- [name: string]: Set<Listener>;
-}
-export declare type Listener<T = any> = (data: T) => void;
-export declare type Dispatch<T = any> = (eventName: PluginKey | string, data: T) => void;
-export declare class EventDispatcher<T = any> {
- private listeners;
- on(event: string, cb: Listener<T>): void;
- off(event: string, cb: Listener<T>): void;
- emit(event: string, data: T): void;
- destroy(): void;
-}
-/**
- * Creates a dispatch function that can be called inside ProseMirror Plugin
- * to notify listeners about that plugin's state change.
- */
-export declare function createDispatch<T>(eventDispatcher: EventDispatcher<T>): Dispatch<T>;
diff --git a/packages/editor/dist/cjs/extensions/react/eventdispatcher.js b/packages/editor/dist/cjs/extensions/react/eventdispatcher.js
deleted file mode 100644
index eb0bb40f3..000000000
--- a/packages/editor/dist/cjs/extensions/react/eventdispatcher.js
+++ /dev/null
@@ -1,48 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.createDispatch = exports.EventDispatcher = void 0;
-class EventDispatcher {
- constructor() {
- this.listeners = {};
- }
- on(event, cb) {
- if (!this.listeners[event]) {
- this.listeners[event] = new Set();
- }
- this.listeners[event].add(cb);
- }
- off(event, cb) {
- if (!this.listeners[event]) {
- return;
- }
- if (this.listeners[event].has(cb)) {
- this.listeners[event].delete(cb);
- }
- }
- emit(event, data) {
- if (!this.listeners[event]) {
- return;
- }
- this.listeners[event].forEach((cb) => cb(data));
- }
- destroy() {
- this.listeners = {};
- }
-}
-exports.EventDispatcher = EventDispatcher;
-/**
- * Creates a dispatch function that can be called inside ProseMirror Plugin
- * to notify listeners about that plugin's state change.
- */
-function createDispatch(eventDispatcher) {
- return (eventName, data) => {
- if (!eventName) {
- throw new Error("event name is required!");
- }
- const event = typeof eventName === "string"
- ? eventName
- : eventName.key;
- eventDispatcher.emit(event, data);
- };
-}
-exports.createDispatch = createDispatch;
diff --git a/packages/editor/dist/cjs/extensions/react/index.d.ts b/packages/editor/dist/cjs/extensions/react/index.d.ts
deleted file mode 100644
index db315768f..000000000
--- a/packages/editor/dist/cjs/extensions/react/index.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from "./react-node-view";
-export * from "./types";
-export * from "./react-portal-provider";
-export * from "./selection-based-react-node-view";
-export * from "./plugin";
-export * from "./event-dispatcher";
diff --git a/packages/editor/dist/cjs/extensions/react/index.js b/packages/editor/dist/cjs/extensions/react/index.js
deleted file mode 100644
index 1b463e88c..000000000
--- a/packages/editor/dist/cjs/extensions/react/index.js
+++ /dev/null
@@ -1,22 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./reactnodeview"), exports);
-__exportStar(require("./types"), exports);
-__exportStar(require("./reactportalprovider"), exports);
-__exportStar(require("./selectionbasedreactnodeview"), exports);
-__exportStar(require("./plugin"), exports);
-__exportStar(require("./eventdispatcher"), exports);
diff --git a/packages/editor/dist/cjs/extensions/react/plugin.d.ts b/packages/editor/dist/cjs/extensions/react/plugin.d.ts
deleted file mode 100644
index 032e5008b..000000000
--- a/packages/editor/dist/cjs/extensions/react/plugin.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Plugin, PluginKey } from "prosemirror-state";
-import { Extension } from "@tiptap/core";
-export declare type StateChangeHandler = (fromPos: number, toPos: number) => any;
-export declare class ReactNodeViewState {
- private changeHandlers;
- constructor();
- subscribe(cb: StateChangeHandler): void;
- unsubscribe(cb: StateChangeHandler): void;
- notifyNewSelection(fromPos: number, toPos: number): void;
-}
-export declare const stateKey: PluginKey<any>;
-export declare const NodeViewSelectionNotifierPlugin: Plugin<ReactNodeViewState>;
-export declare const NodeViewSelectionNotifier: Extension<any, any>;
diff --git a/packages/editor/dist/cjs/extensions/react/plugin.js b/packages/editor/dist/cjs/extensions/react/plugin.js
deleted file mode 100644
index 851e14f1d..000000000
--- a/packages/editor/dist/cjs/extensions/react/plugin.js
+++ /dev/null
@@ -1,48 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.NodeViewSelectionNotifier = exports.NodeViewSelectionNotifierPlugin = exports.stateKey = exports.ReactNodeViewState = void 0;
-const prosemirror_state_1 = require("prosemirror-state");
-const core_1 = require("@tiptap/core");
-class ReactNodeViewState {
- constructor() {
- this.changeHandlers = [];
- this.changeHandlers = [];
- }
- subscribe(cb) {
- this.changeHandlers.push(cb);
- }
- unsubscribe(cb) {
- this.changeHandlers = this.changeHandlers.filter((ch) => ch !== cb);
- }
- notifyNewSelection(fromPos, toPos) {
- this.changeHandlers.forEach((cb) => cb(fromPos, toPos));
- }
-}
-exports.ReactNodeViewState = ReactNodeViewState;
-exports.stateKey = new prosemirror_state_1.PluginKey("reactNodeView");
-exports.NodeViewSelectionNotifierPlugin = new prosemirror_state_1.Plugin({
- state: {
- init() {
- return new ReactNodeViewState();
- },
- apply(_tr, pluginState) {
- return pluginState;
- },
- },
- key: exports.stateKey,
- view: (view) => {
- const pluginState = exports.stateKey.getState(view.state);
- return {
- update: (view) => {
- const { from, to } = view.state.selection;
- pluginState.notifyNewSelection(from, to);
- },
- };
- },
-});
-exports.NodeViewSelectionNotifier = core_1.Extension.create({
- name: "node-view-selection-notifier",
- addProseMirrorPlugins() {
- return [exports.NodeViewSelectionNotifierPlugin];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/react/reactnodeview.d.ts b/packages/editor/dist/cjs/extensions/react/reactnodeview.d.ts
deleted file mode 100644
index 0fc1c6e89..000000000
--- a/packages/editor/dist/cjs/extensions/react/reactnodeview.d.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from "react";
-import { NodeView, Decoration, DecorationSource } from "prosemirror-view";
-import { Node as PMNode } from "prosemirror-model";
-import { PortalProviderAPI } from "./react-portal-provider";
-import { ReactNodeViewProps, ReactNodeViewOptions, GetPosNode, ForwardRef, ContentDOM } from "./types";
-import { NodeViewRendererProps } from "@tiptap/core";
-import { Editor } from "../../types";
-export declare class ReactNodeView<P extends ReactNodeViewProps> implements NodeView {
- protected readonly editor: Editor;
- protected readonly getPos: GetPosNode;
- protected readonly options: ReactNodeViewOptions<P>;
- private domRef;
- private contentDOMWrapper?;
- contentDOM: HTMLElement | undefined;
- node: PMNode;
- isDragging: boolean;
- portalProviderAPI: PortalProviderAPI;
- constructor(node: PMNode, editor: Editor, getPos: GetPosNode, options: ReactNodeViewOptions<P>);
- /**
- * This method exists to move initialization logic out of the constructor,
- * so object can be initialized properly before calling render first time.
- *
- * Example:
- * Instance properties get added to an object only after super call in
- * constructor, which leads to some methods being undefined during the
- * first render.
- */
- init(): this;
- private renderReactComponent;
- createDomRef(): HTMLElement;
- getContentDOM(): ContentDOM;
- handleRef: (node: HTMLElement | null) => void;
- private _handleRef;
- render(props?: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
- updateAttributes(attributes: any, pos: number, addToHistory?: boolean, preventUpdate?: boolean): void;
- update(node: PMNode, _decorations: readonly Decoration[], _innerDecorations: DecorationSource): boolean;
- onDragStart(event: DragEvent): void;
- stopEvent(event: Event): boolean;
- ignoreMutation(mutation: MutationRecord | {
- type: "selection";
- target: Element;
- }): boolean;
- viewShouldUpdate(nextNode: PMNode): boolean;
- /**
- * Copies the attributes from a ProseMirror Node to a DOM node.
- * @param node The Prosemirror Node from which to source the attributes
- */
- setDomAttrs(node: PMNode, element: HTMLElement): void;
- get dom(): HTMLElement;
- destroy(): void;
-}
-export declare function createNodeView<TProps extends ReactNodeViewProps>(component: React.ComponentType<TProps>, options?: Omit<ReactNodeViewOptions<TProps>, "component">): ({ node, getPos, editor }: NodeViewRendererProps) => ReactNodeView<TProps>;
diff --git a/packages/editor/dist/cjs/extensions/react/reactnodeview.js b/packages/editor/dist/cjs/extensions/react/reactnodeview.js
deleted file mode 100644
index dec0efeaf..000000000
--- a/packages/editor/dist/cjs/extensions/react/reactnodeview.js
+++ /dev/null
@@ -1,335 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.createNodeView = exports.ReactNodeView = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const prosemirror_state_1 = require("prosemirror-state");
-// @ts-ignore
-const prosemirror_view_1 = require("prosemirror-view");
-const themeprovider_1 = require("../../components/themeprovider");
-class ReactNodeView {
- constructor(node, editor, getPos, options) {
- this.editor = editor;
- this.getPos = getPos;
- this.options = options;
- this.isDragging = false;
- this.handleRef = (node) => this._handleRef(node);
- this.portalProviderAPI = editor.storage
- .portalProviderAPI;
- this.node = node;
- }
- /**
- * This method exists to move initialization logic out of the constructor,
- * so object can be initialized properly before calling render first time.
- *
- * Example:
- * Instance properties get added to an object only after super call in
- * constructor, which leads to some methods being undefined during the
- * first render.
- */
- init() {
- this.domRef = this.createDomRef();
- this.domRef.ondragstart = (ev) => this.onDragStart(ev);
- // this.setDomAttrs(this.node, this.domRef);
- const { dom: contentDOMWrapper, contentDOM } = this.getContentDOM() || {
- dom: undefined,
- contentDOM: undefined,
- };
- if (this.domRef && contentDOMWrapper) {
- this.domRef.appendChild(contentDOMWrapper);
- this.contentDOM = contentDOM ? contentDOM : contentDOMWrapper;
- this.contentDOMWrapper = contentDOMWrapper || contentDOM;
- }
- // @see ED-3790
- // something gets messed up during mutation processing inside of a
- // nodeView if DOM structure has nested plain "div"s, it doesn't see the
- // difference between them and it kills the nodeView
- this.domRef.classList.add(`${this.node.type.name}-view-content-wrap`);
- this.renderReactComponent(() => this.render(this.options.props, this.handleRef));
- return this;
- }
- renderReactComponent(component) {
- if (!this.domRef || !component || !this.portalProviderAPI) {
- console.warn("Cannot render node view", this.editor.storage);
- return;
- }
- this.portalProviderAPI.render(component, this.domRef);
- }
- createDomRef() {
- if (this.options.wrapperFactory)
- return this.options.wrapperFactory();
- if (!this.node.isInline) {
- return document.createElement("div");
- }
- const htmlElement = document.createElement("span");
- return htmlElement;
- }
- getContentDOM() {
- var _a, _b;
- if (!this.options.contentDOMFactory)
- return;
- if (this.options.contentDOMFactory === true) {
- const content = document.createElement("div");
- content.classList.add(`${this.node.type.name.toLowerCase()}-content-wrapper`);
- content.style.whiteSpace = "inherit";
- // caret is not visible if content element width is 0px
- content.style.minWidth = `20px`;
- return { dom: content };
- }
- return (_b = (_a = this.options).contentDOMFactory) === null || _b === void 0 ? void 0 : _b.call(_a);
- }
- _handleRef(node) {
- const contentDOM = this.contentDOMWrapper || this.contentDOM;
- // move the contentDOM node inside the inner reference after rendering
- if (node && contentDOM && !node.contains(contentDOM)) {
- node.appendChild(contentDOM);
- }
- }
- render(props = {}, forwardRef) {
- if (!this.options.component)
- return null;
- return ((0, jsx_runtime_1.jsx)(themeprovider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(this.options.component, Object.assign({}, props, { editor: this.editor, getPos: this.getPos, node: this.node, forwardRef: forwardRef, updateAttributes: (attr, options) => this.updateAttributes(attr, this.getPos(), options === null || options === void 0 ? void 0 : options.addToHistory, options === null || options === void 0 ? void 0 : options.preventUpdate) })) }));
- }
- updateAttributes(attributes, pos, addToHistory = false, preventUpdate = false) {
- this.editor.commands.command(({ tr }) => {
- tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), attributes));
- tr.setMeta("addToHistory", addToHistory);
- tr.setMeta("preventUpdate", preventUpdate);
- return true;
- });
- }
- update(node, _decorations, _innerDecorations
- // _innerDecorations?: Array<Decoration>,
- // validUpdate: (currentNode: PMNode, newNode: PMNode) => boolean = () => true
- ) {
- // @see https://github.com/ProseMirror/prosemirror/issues/648
- const isValidUpdate = this.node.type === node.type; // && validUpdate(this.node, node);
- if (!isValidUpdate) {
- return false;
- }
- // if (this.domRef && !this.node.sameMarkup(node)) {
- // this.setDomAttrs(node, this.domRef);
- // }
- // View should not process a re-render if this is false.
- // We dont want to destroy the view, so we return true.
- if (!this.viewShouldUpdate(node)) {
- this.node = node;
- return true;
- }
- this.node = node;
- this.renderReactComponent(() => this.render(this.options.props, this.handleRef));
- return true;
- }
- onDragStart(event) {
- var _a, _b, _c, _d, _e, _f, _g;
- const { view } = this.editor;
- const target = event.target;
- // get the drag handle element
- // `closest` is not available for text nodes so we may have to use its parent
- const dragHandle = target.nodeType === 3
- ? (_a = target.parentElement) === null || _a === void 0 ? void 0 : _a.closest("[data-drag-handle]")
- : target.closest("[data-drag-handle]");
- if (!this.dom || ((_b = this.contentDOM) === null || _b === void 0 ? void 0 : _b.contains(target)) || !dragHandle) {
- return;
- }
- const dragImage = this.dom.querySelector("[data-drag-image]") || this.dom;
- let x = 0;
- let y = 0;
- // calculate offset for drag element if we use a different drag handle element
- if (dragImage !== dragHandle) {
- const domBox = dragImage.getBoundingClientRect();
- const handleBox = dragHandle.getBoundingClientRect();
- // In React, we have to go through nativeEvent to reach offsetX/offsetY.
- const offsetX = (_c = event.offsetX) !== null && _c !== void 0 ? _c : (_d = event.nativeEvent) === null || _d === void 0 ? void 0 : _d.offsetX;
- const offsetY = (_e = event.offsetY) !== null && _e !== void 0 ? _e : (_f = event.nativeEvent) === null || _f === void 0 ? void 0 : _f.offsetY;
- x = handleBox.x - domBox.x + offsetX;
- y = handleBox.y - domBox.y + offsetY;
- }
- // we need to tell ProseMirror that we want to move the whole node
- // so we create a NodeSelection
- const selection = prosemirror_state_1.NodeSelection.create(view.state.doc, this.getPos());
- const transaction = view.state.tr.setSelection(selection);
- view.dispatch(transaction);
- (_g = event.dataTransfer) === null || _g === void 0 ? void 0 : _g.setDragImage(dragImage, x, y);
- forceHandleDrag(event, this.editor);
- }
- stopEvent(event) {
- var _a;
- if (!this.dom) {
- return false;
- }
- // if (typeof this.options.stopEvent === 'function') {
- // return this.options.stopEvent({ event })
- // }
- const target = event.target;
- const isInElement = this.dom.contains(target) && !((_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.contains(target));
- // any event from child nodes should be handled by ProseMirror
- if (!isInElement) {
- return false;
- }
- const isDropEvent = event.type === "drop";
- const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) ||
- target.isContentEditable;
- // any input event within node views should be ignored by ProseMirror
- if (isInput && !isDropEvent) {
- return true;
- }
- const { isEditable } = this.editor;
- const { isDragging } = this;
- const isDraggable = !!this.node.type.spec.draggable;
- const isSelectable = prosemirror_state_1.NodeSelection.isSelectable(this.node);
- const isCopyEvent = event.type === "copy";
- const isPasteEvent = event.type === "paste";
- const isCutEvent = event.type === "cut";
- const isClickEvent = event.type === "mousedown";
- const isDragEvent = event.type.startsWith("drag");
- // if (event instanceof DragEvent && event.dataTransfer) {
- // console.log(
- // `[${event.type}]:`,
- // this.editor.view.dragging,
- // event.dataTransfer.getData("Text"),
- // event.dataTransfer.getData("text/plain"),
- // event.dataTransfer.getData("text/html")
- // );
- // }
- // ProseMirror tries to drag selectable nodes
- // even if `draggable` is set to `false`
- // this fix prevents that
- if (!isDraggable && isSelectable && isDragEvent) {
- event.preventDefault();
- }
- if (isDraggable && isDragEvent && !isDragging) {
- event.preventDefault();
- return false;
- }
- // we have to store that dragging started
- if (isDraggable && isEditable && !isDragging && isClickEvent) {
- const dragHandle = target.closest("[data-drag-handle]");
- const isValidDragHandle = dragHandle &&
- (this.dom === dragHandle || this.dom.contains(dragHandle));
- if (isValidDragHandle) {
- this.isDragging = true;
- document.addEventListener("dragend", () => {
- this.isDragging = false;
- }, { once: true });
- document.addEventListener("mouseup", () => {
- this.isDragging = false;
- }, { once: true });
- }
- }
- // these events are handled by prosemirror
- if (isDragging ||
- isDropEvent ||
- isCopyEvent ||
- isPasteEvent ||
- isCutEvent ||
- (isClickEvent && isSelectable)) {
- return false;
- }
- return true;
- }
- ignoreMutation(mutation) {
- if (!this.dom || !this.contentDOM) {
- return true;
- }
- // TODO if (typeof this.options.ignoreMutation === 'function') {
- // return this.options.ignoreMutation({ mutation })
- // }
- // a leaf/atom node is like a black box for ProseMirror
- // and should be fully handled by the node view
- if (this.node.isLeaf || this.node.isAtom) {
- return true;
- }
- // ProseMirror should handle any selections
- if (mutation.type === "selection") {
- return false;
- }
- // try to prevent a bug on mobiles that will break node views on enter
- // this is because ProseMirror can’t preventDispatch on enter
- // this will lead to a re-render of the node view on enter
- // see: https://github.com/ueberdosis/tiptap/issues/1214
- if (this.dom.contains(mutation.target) &&
- mutation.type === "childList" &&
- this.editor.isFocused) {
- const changedNodes = [
- ...Array.from(mutation.addedNodes),
- ...Array.from(mutation.removedNodes),
- ];
- // we’ll check if every changed node is contentEditable
- // to make sure it’s probably mutated by ProseMirror
- if (changedNodes.every((node) => node.isContentEditable)) {
- return false;
- }
- }
- // we will allow mutation contentDOM with attributes
- // so we can for example adding classes within our node view
- if (this.contentDOM === mutation.target && mutation.type === "attributes") {
- return true;
- }
- // ProseMirror should handle any changes within contentDOM
- if (this.contentDOM.contains(mutation.target)) {
- return false;
- }
- return true;
- }
- viewShouldUpdate(nextNode) {
- if (this.options.shouldUpdate)
- return this.options.shouldUpdate(this.node, nextNode);
- return true;
- }
- /**
- * Copies the attributes from a ProseMirror Node to a DOM node.
- * @param node The Prosemirror Node from which to source the attributes
- */
- setDomAttrs(node, element) {
- Object.keys(node.attrs || {}).forEach((attr) => {
- element.setAttribute(attr, node.attrs[attr]);
- });
- }
- get dom() {
- return this.domRef;
- }
- destroy() {
- if (!this.domRef || !this.portalProviderAPI) {
- return;
- }
- this.portalProviderAPI.remove(this.domRef);
- // @ts-ignore NEW PM API
- this.domRef = undefined;
- this.contentDOM = undefined;
- }
-}
-exports.ReactNodeView = ReactNodeView;
-function createNodeView(component, options) {
- return ({ node, getPos, editor }) => {
- const _getPos = () => (typeof getPos === "boolean" ? -1 : getPos());
- return new ReactNodeView(node, editor, _getPos, Object.assign(Object.assign({}, options), { component })).init();
- };
-}
-exports.createNodeView = createNodeView;
-// function isiOS(): boolean {
-// return (
-// [
-// "iPad Simulator",
-// "iPhone Simulator",
-// "iPod Simulator",
-// "iPad",
-// "iPhone",
-// "iPod",
-// ].includes(navigator.platform) ||
-// // iPad on iOS 13 detection
-// (navigator.userAgent.includes("Mac") && "ontouchend" in document)
-// );
-// }
-function forceHandleDrag(event, editor) {
- if (!event.dataTransfer)
- return;
- const { view } = editor;
- const slice = view.state.selection.content();
- const { dom, text } = (0, prosemirror_view_1.__serializeForClipboard)(view, slice);
- event.dataTransfer.clearData();
- event.dataTransfer.setData("Text", text);
- event.dataTransfer.setData("text/plain", text);
- event.dataTransfer.setData("text/html", dom.innerHTML);
- event.dataTransfer.effectAllowed = "copyMove";
- view.dragging = { slice, move: true };
-}
diff --git a/packages/editor/dist/cjs/extensions/react/reactportalprovider.d.ts b/packages/editor/dist/cjs/extensions/react/reactportalprovider.d.ts
deleted file mode 100644
index a6a95fd3e..000000000
--- a/packages/editor/dist/cjs/extensions/react/reactportalprovider.d.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import React, { PropsWithChildren } from "react";
-import { EventDispatcher } from "./event-dispatcher";
-export declare type BasePortalProviderProps = PropsWithChildren<{}>;
-export declare type Portals = Map<HTMLElement, React.ReactChild>;
-export declare type PortalRendererState = {
- portals: Portals;
-};
-declare type MountedPortal = {
- children: () => React.ReactChild | null;
-};
-export declare class PortalProviderAPI extends EventDispatcher {
- portals: Map<HTMLElement, MountedPortal>;
- context: any;
- constructor();
- setContext: (context: any) => void;
- render(children: () => React.ReactChild | JSX.Element | null, container: HTMLElement): void;
- forceUpdate(): void;
- remove(container: HTMLElement): void;
-}
-export declare function usePortalProvider(): PortalProviderAPI | undefined;
-export declare class PortalProvider extends React.Component<BasePortalProviderProps> {
- static displayName: string;
- portalProviderAPI: PortalProviderAPI;
- constructor(props: BasePortalProviderProps);
- render(): JSX.Element;
- componentDidUpdate(): void;
-}
-export declare class PortalRenderer extends React.Component<{
- portalProviderAPI: PortalProviderAPI;
-}, PortalRendererState> {
- constructor(props: {
- portalProviderAPI: PortalProviderAPI;
- });
- handleUpdate: (portals: Portals) => void;
- render(): JSX.Element;
-}
-export {};
diff --git a/packages/editor/dist/cjs/extensions/react/reactportalprovider.js b/packages/editor/dist/cjs/extensions/react/reactportalprovider.js
deleted file mode 100644
index ee2d612b4..000000000
--- a/packages/editor/dist/cjs/extensions/react/reactportalprovider.js
+++ /dev/null
@@ -1,99 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.PortalRenderer = exports.PortalProvider = exports.usePortalProvider = exports.PortalProviderAPI = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importStar(require("react"));
-const react_dom_1 = require("react-dom");
-const eventdispatcher_1 = require("./eventdispatcher");
-class PortalProviderAPI extends eventdispatcher_1.EventDispatcher {
- constructor() {
- super();
- this.portals = new Map();
- this.setContext = (context) => {
- this.context = context;
- };
- }
- render(children, container) {
- this.portals.set(container, {
- children,
- });
- let wrappedChildren = children();
- (0, react_dom_1.unstable_renderSubtreeIntoContainer)(this.context, wrappedChildren, container);
- }
- // TODO: until https://product-fabric.atlassian.net/browse/ED-5013
- // we (unfortunately) need to re-render to pass down any updated context.
- // selectively do this for nodeviews that opt-in via `hasAnalyticsContext`
- forceUpdate() { }
- remove(container) {
- this.portals.delete(container);
- // There is a race condition that can happen caused by Prosemirror vs React,
- // where Prosemirror removes the container from the DOM before React gets
- // around to removing the child from the container
- // This will throw a NotFoundError: The node to be removed is not a child of this node
- // Both Prosemirror and React remove the elements asynchronously, and in edge
- // cases Prosemirror beats React
- try {
- (0, react_dom_1.unmountComponentAtNode)(container);
- }
- catch (error) {
- // IGNORE console.error(error);
- }
- }
-}
-exports.PortalProviderAPI = PortalProviderAPI;
-const PortalProviderContext = react_1.default.createContext(undefined);
-function usePortalProvider() {
- return (0, react_1.useContext)(PortalProviderContext);
-}
-exports.usePortalProvider = usePortalProvider;
-class PortalProvider extends react_1.default.Component {
- constructor(props) {
- super(props);
- this.portalProviderAPI = new PortalProviderAPI();
- }
- render() {
- return ((0, jsx_runtime_1.jsxs)(PortalProviderContext.Provider, Object.assign({ value: this.portalProviderAPI }, { children: [this.props.children, (0, jsx_runtime_1.jsx)(PortalRenderer, { portalProviderAPI: this.portalProviderAPI })] })));
- }
- componentDidUpdate() {
- this.portalProviderAPI.forceUpdate();
- }
-}
-exports.PortalProvider = PortalProvider;
-PortalProvider.displayName = "PortalProvider";
-class PortalRenderer extends react_1.default.Component {
- constructor(props) {
- super(props);
- this.handleUpdate = (portals) => this.setState({ portals });
- props.portalProviderAPI.setContext(this);
- props.portalProviderAPI.on("update", this.handleUpdate);
- this.state = { portals: new Map() };
- }
- render() {
- const { portals } = this.state;
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: Array.from(portals.entries()).map(([container, children]) => (0, react_dom_1.createPortal)(children, container)) }));
- }
-}
-exports.PortalRenderer = PortalRenderer;
diff --git a/packages/editor/dist/cjs/extensions/react/selectionbasedreactnodeview.d.ts b/packages/editor/dist/cjs/extensions/react/selectionbasedreactnodeview.d.ts
deleted file mode 100644
index fda86bb29..000000000
--- a/packages/editor/dist/cjs/extensions/react/selectionbasedreactnodeview.d.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import React from "react";
-import { Node as PMNode } from "prosemirror-model";
-import { ReactNodeViewOptions, GetPosNode, SelectionBasedReactNodeViewProps, ForwardRef } from "./types";
-import { ReactNodeView } from "./react-node-view";
-import { NodeViewRendererProps } from "@tiptap/core";
-import { Editor } from "../../types";
-/**
- * A ReactNodeView that handles React components sensitive
- * to selection changes.
- *
- * If the selection changes, it will attempt to re-render the
- * React component. Otherwise it does nothing.
- *
- * You can subclass `viewShouldUpdate` to include other
- * props that your component might want to consider before
- * entering the React lifecycle. These are usually props you
- * compare in `shouldComponentUpdate`.
- *
- * An example:
- *
- * ```
- * viewShouldUpdate(nextNode) {
- * if (nextNode.attrs !== this.node.attrs) {
- * return true;
- * }
- *
- * return super.viewShouldUpdate(nextNode);
- * }```
- */
-export declare class SelectionBasedNodeView<P extends SelectionBasedReactNodeViewProps> extends ReactNodeView<P> {
- private oldSelection;
- private selectionChangeState;
- pos: number;
- posEnd: number | undefined;
- constructor(node: PMNode, editor: Editor, getPos: GetPosNode, options: ReactNodeViewOptions<P>);
- render(props?: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
- /**
- * Update current node's start and end positions.
- *
- * Prefer `this.pos` rather than getPos(), because calling getPos is
- * expensive, unless you know you're definitely going to render.
- */
- private updatePos;
- private getPositionsWithDefault;
- isNodeInsideSelection: (from: number, to: number, pos?: number, posEnd?: number) => boolean;
- isSelectionInsideNode: (from: number, to: number, pos?: number, posEnd?: number) => boolean;
- private isSelectedNode;
- insideSelection: () => boolean;
- nodeInsideSelection: () => boolean;
- viewShouldUpdate(nextNode: PMNode): boolean;
- destroy(): void;
- private onSelectionChange;
-}
-export declare function createSelectionBasedNodeView<TProps extends SelectionBasedReactNodeViewProps>(component: React.ComponentType<TProps>, options?: Omit<ReactNodeViewOptions<TProps>, "component">): ({ node, getPos, editor }: NodeViewRendererProps) => SelectionBasedNodeView<TProps>;
diff --git a/packages/editor/dist/cjs/extensions/react/selectionbasedreactnodeview.js b/packages/editor/dist/cjs/extensions/react/selectionbasedreactnodeview.js
deleted file mode 100644
index 48663a010..000000000
--- a/packages/editor/dist/cjs/extensions/react/selectionbasedreactnodeview.js
+++ /dev/null
@@ -1,149 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.createSelectionBasedNodeView = exports.SelectionBasedNodeView = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const prosemirror_view_1 = require("prosemirror-view");
-const prosemirror_state_1 = require("prosemirror-state");
-const plugin_1 = require("./plugin");
-const reactnodeview_1 = require("./reactnodeview");
-const themeprovider_1 = require("../../components/themeprovider");
-/**
- * A ReactNodeView that handles React components sensitive
- * to selection changes.
- *
- * If the selection changes, it will attempt to re-render the
- * React component. Otherwise it does nothing.
- *
- * You can subclass `viewShouldUpdate` to include other
- * props that your component might want to consider before
- * entering the React lifecycle. These are usually props you
- * compare in `shouldComponentUpdate`.
- *
- * An example:
- *
- * ```
- * viewShouldUpdate(nextNode) {
- * if (nextNode.attrs !== this.node.attrs) {
- * return true;
- * }
- *
- * return super.viewShouldUpdate(nextNode);
- * }```
- */
-class SelectionBasedNodeView extends reactnodeview_1.ReactNodeView {
- constructor(node, editor, getPos, options) {
- super(node, editor, getPos, options);
- this.pos = -1;
- this.isNodeInsideSelection = (from, to, pos, posEnd) => {
- ({ pos, posEnd } = this.getPositionsWithDefault(pos, posEnd));
- if (typeof pos !== "number" || typeof posEnd !== "number") {
- return false;
- }
- return from <= pos && to >= posEnd;
- };
- this.isSelectionInsideNode = (from, to, pos, posEnd) => {
- ({ pos, posEnd } = this.getPositionsWithDefault(pos, posEnd));
- if (typeof pos !== "number" || typeof posEnd !== "number") {
- return false;
- }
- return pos < from && to < posEnd;
- };
- this.isSelectedNode = (selection) => {
- if (selection instanceof prosemirror_state_1.NodeSelection) {
- const { selection: { from, to }, } = this.editor.view.state;
- return (selection.node === this.node ||
- // If nodes are not the same object, we check if they are referring to the same document node
- (this.pos === from &&
- this.posEnd === to &&
- selection.node.eq(this.node)));
- }
- return false;
- };
- this.insideSelection = () => {
- const { selection: { from, to }, } = this.editor.view.state;
- return (this.isSelectedNode(this.editor.view.state.selection) ||
- this.isSelectionInsideNode(from, to));
- };
- this.nodeInsideSelection = () => {
- const { selection } = this.editor.view.state;
- const { from, to } = selection;
- return (this.isSelectedNode(selection) || this.isNodeInsideSelection(from, to));
- };
- this.onSelectionChange = () => {
- this.update(this.node, [], prosemirror_view_1.DecorationSet.empty);
- };
- this.updatePos();
- this.oldSelection = editor.view.state.selection;
- this.selectionChangeState = plugin_1.stateKey.getState(this.editor.view.state);
- this.selectionChangeState.subscribe(this.onSelectionChange);
- }
- render(props = {}, forwardRef) {
- if (!this.options.component)
- return null;
- const isSelected = this.editor.isEditable &&
- (this.insideSelection() || this.nodeInsideSelection());
- return ((0, jsx_runtime_1.jsx)(themeprovider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(this.options.component, Object.assign({}, props, { editor: this.editor, getPos: this.getPos, node: this.node, forwardRef: forwardRef, selected: isSelected, updateAttributes: (attr, options) => this.updateAttributes(attr, this.pos, options === null || options === void 0 ? void 0 : options.addToHistory, options === null || options === void 0 ? void 0 : options.preventUpdate) })) }));
- }
- /**
- * Update current node's start and end positions.
- *
- * Prefer `this.pos` rather than getPos(), because calling getPos is
- * expensive, unless you know you're definitely going to render.
- */
- updatePos() {
- if (typeof this.getPos === "boolean") {
- return;
- }
- this.pos = this.getPos();
- this.posEnd = this.pos + this.node.nodeSize;
- }
- getPositionsWithDefault(pos, posEnd) {
- return {
- pos: typeof pos !== "number" ? this.pos : pos,
- posEnd: typeof posEnd !== "number" ? this.posEnd : posEnd,
- };
- }
- viewShouldUpdate(nextNode) {
- if (super.viewShouldUpdate(nextNode))
- return true;
- const { state: { selection }, } = this.editor.view;
- // update selection
- const oldSelection = this.oldSelection;
- this.oldSelection = selection;
- // update cached positions
- const { pos: oldPos, posEnd: oldPosEnd } = this;
- this.updatePos();
- const { from, to } = selection;
- const { from: oldFrom, to: oldTo } = oldSelection;
- if (this.node.type.spec.selectable) {
- const newNodeSelection = selection instanceof prosemirror_state_1.NodeSelection && selection.from === this.pos;
- const oldNodeSelection = oldSelection instanceof prosemirror_state_1.NodeSelection && oldSelection.from === this.pos;
- if ((newNodeSelection && !oldNodeSelection) ||
- (oldNodeSelection && !newNodeSelection)) {
- return true;
- }
- }
- const movedInToSelection = this.isNodeInsideSelection(from, to) &&
- !this.isNodeInsideSelection(oldFrom, oldTo);
- const movedOutOfSelection = !this.isNodeInsideSelection(from, to) &&
- this.isNodeInsideSelection(oldFrom, oldTo);
- const moveOutFromOldSelection = this.isNodeInsideSelection(from, to, oldPos, oldPosEnd) &&
- !this.isNodeInsideSelection(from, to);
- if (movedInToSelection || movedOutOfSelection || moveOutFromOldSelection) {
- return true;
- }
- return false;
- }
- destroy() {
- this.selectionChangeState.unsubscribe(this.onSelectionChange);
- super.destroy();
- }
-}
-exports.SelectionBasedNodeView = SelectionBasedNodeView;
-function createSelectionBasedNodeView(component, options) {
- return ({ node, getPos, editor }) => {
- const _getPos = () => (typeof getPos === "boolean" ? -1 : getPos());
- return new SelectionBasedNodeView(node, editor, _getPos, Object.assign(Object.assign({}, options), { component })).init();
- };
-}
-exports.createSelectionBasedNodeView = createSelectionBasedNodeView;
diff --git a/packages/editor/dist/cjs/extensions/react/types.d.ts b/packages/editor/dist/cjs/extensions/react/types.d.ts
deleted file mode 100644
index 516fcf4af..000000000
--- a/packages/editor/dist/cjs/extensions/react/types.d.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-import { Node as PMNode, Attrs } from "prosemirror-model";
-export interface ReactNodeProps {
- selected: boolean;
-}
-export declare type NodeWithAttrs<T> = PMNode & {
- attrs: T;
-};
-export declare type GetPos = GetPosNode | boolean;
-export declare type GetPosNode = () => number;
-export declare type ForwardRef = (node: HTMLElement | null) => void;
-export declare type ShouldUpdate = (prevNode: PMNode, nextNode: PMNode) => boolean;
-export declare type UpdateAttributes<T> = (attributes: Partial<T>, options?: {
- addToHistory?: boolean;
- preventUpdate?: boolean;
-}) => void;
-export declare type ContentDOM = {
- dom: HTMLElement;
- contentDOM?: HTMLElement | null | undefined;
-} | undefined;
-export declare type ReactNodeViewProps<TAttributes = Attrs> = {
- getPos: GetPosNode;
- node: NodeWithAttrs<TAttributes>;
- editor: Editor;
- updateAttributes: UpdateAttributes<TAttributes>;
- forwardRef?: ForwardRef;
-};
-export declare type SelectionBasedReactNodeViewProps<TAttributes = Attrs> = ReactNodeViewProps<TAttributes> & {
- selected: boolean;
-};
-export declare type ReactNodeViewOptions<P> = {
- props?: P;
- component?: React.ComponentType<P>;
- shouldUpdate?: ShouldUpdate;
- contentDOMFactory?: (() => ContentDOM) | boolean;
- wrapperFactory?: () => HTMLElement;
-};
diff --git a/packages/editor/dist/cjs/extensions/react/types.js b/packages/editor/dist/cjs/extensions/react/types.js
deleted file mode 100644
index c8ad2e549..000000000
--- a/packages/editor/dist/cjs/extensions/react/types.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/packages/editor/dist/cjs/extensions/searchreplace/index.d.ts b/packages/editor/dist/cjs/extensions/searchreplace/index.d.ts
deleted file mode 100644
index 8a016dad8..000000000
--- a/packages/editor/dist/cjs/extensions/searchreplace/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./search-replace";
diff --git a/packages/editor/dist/cjs/extensions/searchreplace/index.js b/packages/editor/dist/cjs/extensions/searchreplace/index.js
deleted file mode 100644
index 00ce5837b..000000000
--- a/packages/editor/dist/cjs/extensions/searchreplace/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./searchreplace"), exports);
diff --git a/packages/editor/dist/cjs/extensions/searchreplace/searchreplace.d.ts b/packages/editor/dist/cjs/extensions/searchreplace/searchreplace.d.ts
deleted file mode 100644
index dc7b33bac..000000000
--- a/packages/editor/dist/cjs/extensions/searchreplace/searchreplace.d.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Extension } from "@tiptap/core";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- searchreplace: {
- startSearch: () => ReturnType;
- endSearch: () => ReturnType;
- search: (term: string, options?: SearchSettings) => ReturnType;
- moveToNextResult: () => ReturnType;
- moveToPreviousResult: () => ReturnType;
- replace: (term: string) => ReturnType;
- replaceAll: (term: string) => ReturnType;
- };
- }
-}
-interface Result {
- from: number;
- to: number;
-}
-interface SearchOptions {
- searchResultClass: string;
-}
-interface SearchSettings {
- matchCase: boolean;
- enableRegex: boolean;
- matchWholeWord: boolean;
-}
-export declare type SearchStorage = SearchSettings & {
- searchTerm: string;
- selectedIndex: number;
- isSearching: boolean;
- selectedText?: string;
- results?: Result[];
-};
-export declare const SearchReplace: Extension<SearchOptions, SearchStorage>;
-export {};
diff --git a/packages/editor/dist/cjs/extensions/searchreplace/searchreplace.js b/packages/editor/dist/cjs/extensions/searchreplace/searchreplace.js
deleted file mode 100644
index c07b5c02a..000000000
--- a/packages/editor/dist/cjs/extensions/searchreplace/searchreplace.js
+++ /dev/null
@@ -1,214 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SearchReplace = void 0;
-const core_1 = require("@tiptap/core");
-const prosemirror_view_1 = require("prosemirror-view");
-const prosemirror_state_1 = require("prosemirror-state");
-const updateView = (state, dispatch) => dispatch(state.tr);
-const regex = (s, settings) => {
- const { enableRegex, matchCase, matchWholeWord } = settings;
- const boundary = matchWholeWord ? "\\b" : "";
- console.log(boundary);
- return RegExp(boundary +
- (enableRegex ? s : s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")) +
- boundary, matchCase ? "gu" : "gui");
-};
-function searchDocument(doc, searchResultClass, searchTerm) {
- if (!searchTerm)
- return { decorationSet: prosemirror_view_1.DecorationSet.empty, results: [] };
- const decorations = [];
- const results = [];
- let index = 0;
- let textNodesWithPosition = [];
- doc === null || doc === void 0 ? void 0 : doc.descendants((node, pos) => {
- if (node.isText) {
- if (textNodesWithPosition[index]) {
- textNodesWithPosition[index] = {
- text: textNodesWithPosition[index].text + node.text,
- pos: textNodesWithPosition[index].pos,
- };
- }
- else {
- textNodesWithPosition[index] = {
- text: node.text || "",
- pos,
- };
- }
- }
- else {
- index += 1;
- }
- });
- textNodesWithPosition = textNodesWithPosition.filter(Boolean);
- for (const { text, pos } of textNodesWithPosition) {
- const matches = text.matchAll(searchTerm);
- for (const m of matches) {
- if (m[0] === "")
- break;
- if (m.index !== undefined) {
- results.push({
- from: pos + m.index,
- to: pos + m.index + m[0].length,
- });
- }
- }
- }
- for (const { from, to } of results) {
- decorations.push(prosemirror_view_1.Decoration.inline(from, to, { class: searchResultClass }));
- }
- return {
- decorationSet: prosemirror_view_1.DecorationSet.create(doc, decorations),
- results,
- };
-}
-const replaceAll = (replaceTerm, results, tr) => {
- let offset = 0;
- if (!results.length)
- return;
- const map = tr.mapping;
- for (let i = 0; i < results.length; i += 1) {
- const { from, to } = results[i];
- tr.insertText(replaceTerm, from, to);
- if (i + 1 < results.length) {
- const { from, to } = results[i + 1];
- results[i + 1] = {
- from: map.map(from),
- to: map.map(to),
- };
- }
- }
- return tr;
-};
-exports.SearchReplace = core_1.Extension.create({
- name: "searchreplace",
- addOptions() {
- return {
- searchResultClass: "search-result",
- };
- },
- addCommands() {
- return {
- startSearch: () => ({ state }) => {
- this.storage.isSearching = true;
- if (!state.selection.empty) {
- this.storage.selectedText = state.doc.textBetween(state.selection.$from.pos, state.selection.$to.pos);
- }
- return true;
- },
- endSearch: () => ({ state, dispatch }) => {
- this.storage.isSearching = false;
- this.storage.searchTerm = "";
- updateView(state, dispatch);
- return true;
- },
- search: (term, options) => ({ state, dispatch }) => {
- this.storage.searchTerm = term;
- this.storage.enableRegex = (options === null || options === void 0 ? void 0 : options.enableRegex) || false;
- this.storage.matchCase = (options === null || options === void 0 ? void 0 : options.matchCase) || false;
- this.storage.matchWholeWord = (options === null || options === void 0 ? void 0 : options.matchWholeWord) || false;
- this.storage.results = [];
- updateView(state, dispatch);
- return true;
- },
- moveToNextResult: () => ({ chain }) => {
- const { selectedIndex, results } = this.storage;
- if (!results || results.length <= 0)
- return false;
- let nextIndex = selectedIndex + 1;
- if (isNaN(nextIndex) || nextIndex >= results.length)
- nextIndex = 0;
- const { from, to } = results[nextIndex];
- console.log("[moveToNextResult]", from, to);
- const result = chain()
- .focus(undefined, { scrollIntoView: true })
- .setTextSelection({ from, to })
- .run();
- if (result)
- this.storage.selectedIndex = nextIndex;
- return result;
- },
- moveToPreviousResult: () => ({ chain }) => {
- const { selectedIndex, results } = this.storage;
- if (!results || results.length <= 0)
- return false;
- let prevIndex = selectedIndex - 1;
- if (isNaN(prevIndex) || prevIndex < 0)
- prevIndex = results.length - 1;
- const { from, to } = results[prevIndex];
- const result = chain()
- .focus(undefined, { scrollIntoView: true })
- .setTextSelection({ from, to })
- .run();
- if (result)
- this.storage.selectedIndex = prevIndex;
- return result;
- },
- replace: (term) => ({ commands, tr, dispatch }) => {
- const { selectedIndex, results } = this.storage;
- if (!dispatch || !results || results.length <= 0)
- return false;
- const index = selectedIndex === undefined ? 0 : selectedIndex;
- const { from, to } = results[index];
- tr.insertText(term, from, to);
- if (index + 1 < results.length) {
- const { from, to } = results[index + 1];
- const nextResult = (results[index + 1] = {
- from: tr.mapping.map(from),
- to: tr.mapping.map(to),
- });
- commands.focus();
- tr.setSelection(new prosemirror_state_1.TextSelection(tr.doc.resolve(nextResult.from), tr.doc.resolve(nextResult.to)));
- }
- dispatch(tr);
- results.splice(index, 1);
- return true;
- },
- replaceAll: (term) => ({ state, tr, dispatch }) => {
- if (!dispatch)
- return false;
- const { results } = this.storage;
- if (!dispatch || !results || results.length <= 0)
- return false;
- dispatch(replaceAll(term, results, tr));
- return true;
- },
- };
- },
- addKeyboardShortcuts() {
- return {
- "Mod-f": ({ editor }) => editor.commands.startSearch(),
- Escape: ({ editor }) => editor.commands.endSearch(),
- };
- },
- addProseMirrorPlugins() {
- const key = new prosemirror_state_1.PluginKey("searchreplace");
- return [
- new prosemirror_state_1.Plugin({
- key,
- state: {
- init() {
- return prosemirror_view_1.DecorationSet.empty;
- },
- apply: ({ doc, docChanged, setSelection }) => {
- const { searchTerm, enableRegex, matchCase, matchWholeWord } = this.storage;
- const { searchResultClass } = this.options;
- if (docChanged || searchTerm) {
- const searchRegex = searchTerm
- ? regex(searchTerm, { enableRegex, matchCase, matchWholeWord })
- : undefined;
- const { decorationSet, results } = searchDocument(doc, searchResultClass, searchRegex);
- this.storage.results = results;
- return decorationSet;
- }
- return prosemirror_view_1.DecorationSet.empty;
- },
- },
- props: {
- decorations(state) {
- return key.getState(state);
- },
- },
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/selectionpersist/index.d.ts b/packages/editor/dist/cjs/extensions/selectionpersist/index.d.ts
deleted file mode 100644
index 1bb64b085..000000000
--- a/packages/editor/dist/cjs/extensions/selectionpersist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./selection-persist";
diff --git a/packages/editor/dist/cjs/extensions/selectionpersist/index.js b/packages/editor/dist/cjs/extensions/selectionpersist/index.js
deleted file mode 100644
index 5562286cf..000000000
--- a/packages/editor/dist/cjs/extensions/selectionpersist/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./selectionpersist"), exports);
diff --git a/packages/editor/dist/cjs/extensions/selectionpersist/selectionpersist.d.ts b/packages/editor/dist/cjs/extensions/selectionpersist/selectionpersist.d.ts
deleted file mode 100644
index daad8ea1b..000000000
--- a/packages/editor/dist/cjs/extensions/selectionpersist/selectionpersist.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { Extension } from "@tiptap/core";
-export declare const SelectionPersist: Extension<any, any>;
diff --git a/packages/editor/dist/cjs/extensions/selectionpersist/selectionpersist.js b/packages/editor/dist/cjs/extensions/selectionpersist/selectionpersist.js
deleted file mode 100644
index b9d31a25f..000000000
--- a/packages/editor/dist/cjs/extensions/selectionpersist/selectionpersist.js
+++ /dev/null
@@ -1,55 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SelectionPersist = void 0;
-const core_1 = require("@tiptap/core");
-const prosemirror_state_1 = require("prosemirror-state");
-const prosemirror_view_1 = require("prosemirror-view");
-const key = new prosemirror_state_1.PluginKey("selection-persist-key");
-exports.SelectionPersist = core_1.Extension.create({
- name: "selection-persist",
- addProseMirrorPlugins() {
- let isFocused = false;
- let isBlurred = false;
- return [
- new prosemirror_state_1.Plugin({
- key,
- props: {
- decorations(state) {
- return key.getState(state);
- },
- },
- state: {
- init() {
- return prosemirror_view_1.DecorationSet.empty;
- },
- apply(tr, value, oldState, newState) {
- // isBlurred should remain true until isFocused becomes true
- // isFocused should remain true until isBlurred becomes true
- const _isBlurred = !!tr.getMeta("blur");
- const _isFocused = !!tr.getMeta("focus");
- if (_isFocused) {
- isBlurred = false;
- isFocused = true;
- }
- if (_isBlurred) {
- isBlurred = true;
- isFocused = false;
- }
- const { from, to } = oldState.selection;
- if (isBlurred) {
- return prosemirror_view_1.DecorationSet.create(tr.doc, [
- prosemirror_view_1.Decoration.inline(from, to, {
- style: `background-color: var(--dimPrimary)`,
- }),
- ]);
- }
- else if (isFocused) {
- return prosemirror_view_1.DecorationSet.empty;
- }
- return prosemirror_view_1.DecorationSet.empty;
- },
- },
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/table/actions.d.ts b/packages/editor/dist/cjs/extensions/table/actions.d.ts
deleted file mode 100644
index c4a829775..000000000
--- a/packages/editor/dist/cjs/extensions/table/actions.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Editor } from "@tiptap/core";
-declare function moveColumnRight(editor: Editor): void;
-declare function moveColumnLeft(editor: Editor): void;
-declare function moveRowDown(editor: Editor): void;
-declare function moveRowUp(editor: Editor): void;
-export { moveColumnLeft, moveColumnRight, moveRowDown, moveRowUp };
diff --git a/packages/editor/dist/cjs/extensions/table/actions.js b/packages/editor/dist/cjs/extensions/table/actions.js
deleted file mode 100644
index 878fcf1ae..000000000
--- a/packages/editor/dist/cjs/extensions/table/actions.js
+++ /dev/null
@@ -1,111 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.moveRowUp = exports.moveRowDown = exports.moveColumnRight = exports.moveColumnLeft = void 0;
-const prosemirror_tables_1 = require("@_ueberdosis/prosemirror-tables");
-function moveColumnRight(editor) {
- const { tr } = editor.state;
- const rect = (0, prosemirror_tables_1.selectedRect)(editor.state);
- if (rect.right === rect.map.width)
- return;
- const transaction = moveColumn(tr, rect, rect.left, rect.left + 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-exports.moveColumnRight = moveColumnRight;
-function moveColumnLeft(editor) {
- const { tr } = editor.state;
- const rect = (0, prosemirror_tables_1.selectedRect)(editor.state);
- if (rect.left === 0)
- return;
- const transaction = moveColumn(tr, rect, rect.left, rect.left - 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-exports.moveColumnLeft = moveColumnLeft;
-function moveRowDown(editor) {
- const { tr } = editor.state;
- const rect = (0, prosemirror_tables_1.selectedRect)(editor.state);
- if (rect.top + 1 === rect.map.height)
- return;
- const transaction = moveRow(tr, rect, rect.top, rect.top + 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-exports.moveRowDown = moveRowDown;
-function moveRowUp(editor) {
- const { tr } = editor.state;
- const rect = (0, prosemirror_tables_1.selectedRect)(editor.state);
- if (rect.top === 0)
- return;
- const transaction = moveRow(tr, rect, rect.top, rect.top - 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-exports.moveRowUp = moveRowUp;
-function moveColumn(tr, rect, from, to) {
- let fromCells = getColumnCells(rect, from);
- let toCells = getColumnCells(rect, to);
- return moveCells(tr, rect, fromCells, toCells);
-}
-function getColumnCells({ map, table }, col) {
- let cells = [];
- for (let row = 0; row < map.height;) {
- let index = row * map.width + col;
- if (index >= map.map.length)
- break;
- let pos = map.map[index];
- let cell = table.nodeAt(pos);
- if (!cell)
- continue;
- cells.push({ cell, pos });
- row += cell.attrs.rowspan;
- }
- return cells;
-}
-function moveRow(tr, rect, from, to) {
- let fromCells = getRowCells(rect, from);
- let toCells = getRowCells(rect, to);
- return moveCells(tr, rect, fromCells, toCells);
-}
-function getRowCells({ map, table }, row) {
- let cells = [];
- for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
- if (index >= map.map.length)
- break;
- let pos = map.map[index];
- let cell = table.nodeAt(pos);
- if (!cell)
- continue;
- cells.push({ cell, pos });
- col += cell.attrs.colspan - 1;
- }
- return cells;
-}
-function moveCells(tr, rect, fromCells, toCells) {
- if (fromCells.length !== toCells.length)
- return;
- let mapStart = tr.mapping.maps.length;
- for (let i = 0; i < toCells.length; ++i) {
- const fromCell = fromCells[i];
- const toCell = toCells[i];
- let fromStart = tr.mapping
- .slice(mapStart)
- .map(rect.tableStart + fromCell.pos);
- let fromEnd = fromStart + fromCell.cell.nodeSize;
- const fromSlice = tr.doc.slice(fromStart, fromEnd);
- const toStart = tr.mapping
- .slice(mapStart)
- .map(rect.tableStart + toCell.pos);
- const toEnd = toStart + toCell.cell.nodeSize;
- const toSlice = tr.doc.slice(toStart, toEnd);
- tr.replace(toStart, toEnd, fromSlice);
- fromStart = tr.mapping.slice(mapStart).map(rect.tableStart + fromCell.pos);
- fromEnd = fromStart + fromCell.cell.nodeSize;
- tr.replace(fromStart, fromEnd, toSlice);
- }
- return tr;
-}
diff --git a/packages/editor/dist/cjs/extensions/table/component.d.ts b/packages/editor/dist/cjs/extensions/table/component.d.ts
deleted file mode 100644
index 529809d1d..000000000
--- a/packages/editor/dist/cjs/extensions/table/component.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/// <reference types="react" />
-import { SelectionBasedReactNodeViewProps } from "../react";
-import { Editor } from "../../types";
-import { NodeView } from "prosemirror-view";
-export declare function TableComponent(props: SelectionBasedReactNodeViewProps): JSX.Element;
-export declare function TableNodeView(editor: Editor): NodeView;
diff --git a/packages/editor/dist/cjs/extensions/table/component.js b/packages/editor/dist/cjs/extensions/table/component.js
deleted file mode 100644
index 2e508c6e8..000000000
--- a/packages/editor/dist/cjs/extensions/table/component.js
+++ /dev/null
@@ -1,126 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TableNodeView = exports.TableComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("../react");
-const react_2 = require("react");
-const prosemirror_tables_1 = require("@_ueberdosis/prosemirror-tables");
-const table_1 = require("../../toolbar/tools/table");
-const tooldefinitions_1 = require("../../toolbar/tooldefinitions");
-const position_1 = require("../../utils/position");
-const prosemirror_1 = require("../../toolbar/utils/prosemirror");
-const responsive_1 = require("../../components/responsive");
-function TableComponent(props) {
- const { editor, node, forwardRef } = props;
- const colgroupRef = (0, react_2.useRef)(null);
- const tableRef = (0, react_2.useRef)();
- const selected = editor.isActive("table");
- (0, react_2.useEffect)(() => {
- if (!colgroupRef.current || !tableRef.current)
- return;
- (0, prosemirror_tables_1.updateColumnsOnResize)(node, colgroupRef.current, tableRef.current, 50);
- }, [node]);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: selected && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableRowToolbar, { editor: editor, table: tableRef.current }), (0, jsx_runtime_1.jsx)(TableColumnToolbar, { editor: editor, table: tableRef.current })] })) }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "tableWrapper" }, { children: (0, jsx_runtime_1.jsx)("table", Object.assign({ ref: (ref) => {
- forwardRef === null || forwardRef === void 0 ? void 0 : forwardRef(ref);
- tableRef.current = ref || undefined;
- } }, { children: (0, jsx_runtime_1.jsx)("colgroup", { ref: colgroupRef }) })) }))] }));
-}
-exports.TableComponent = TableComponent;
-function TableNodeView(editor) {
- class TableNode extends react_1.SelectionBasedNodeView {
- constructor(node, cellMinWidth) {
- super(node, editor, () => 0, // todo
- {
- component: TableComponent,
- shouldUpdate: (prev, next) => {
- return prev.type === next.type;
- },
- contentDOMFactory: () => {
- const dom = document.createElement("tbody");
- return { dom };
- },
- wrapperFactory: () => {
- const dom = document.createElement("div");
- dom.style.position = "relative";
- return dom;
- },
- });
- super.init();
- }
- }
- return TableNode;
-}
-exports.TableNodeView = TableNodeView;
-function TableRowToolbar(props) {
- const { editor } = props;
- const rowToolsRef = (0, react_2.useRef)(null);
- (0, react_2.useEffect)(() => {
- if (!rowToolsRef.current) {
- return;
- }
- const currentRow = (0, prosemirror_1.findSelectedDOMNode)(editor, ["tableRow"]);
- if (!currentRow)
- return;
- const pos = (0, position_1.getPosition)(rowToolsRef.current, {
- location: "left",
- target: currentRow,
- align: "start",
- xOffset: -5,
- yOffset: -3,
- });
- rowToolsRef.current.style.top = `${pos.top}px`;
- rowToolsRef.current.style.left = `${pos.left}px`;
- }, [editor.state.selection, rowToolsRef.current]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ ref: rowToolsRef, sx: {
- zIndex: 999,
- top: 0,
- left: 0,
- position: "absolute",
- bg: "background",
- flexWrap: "nowrap",
- borderRadius: "default",
- opacity: 0.3,
- ":hover": {
- opacity: 1,
- },
- } }, { children: [(0, jsx_runtime_1.jsx)(table_1.RowProperties, Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("rowProperties"), { icon: "more", variant: "small", editor: editor })), (0, jsx_runtime_1.jsx)(table_1.InsertRowBelow, Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("insertRowBelow"), { editor: editor, variant: "small" }))] })));
-}
-function TableColumnToolbar(props) {
- const { editor, table } = props;
- const columnToolsRef = (0, react_2.useRef)(null);
- (0, react_2.useEffect)(() => {
- if (!columnToolsRef.current || !table) {
- return;
- }
- const currentCell = (0, prosemirror_1.findSelectedDOMNode)(editor, [
- "tableCell",
- "tableHeader",
- ]);
- if (!currentCell)
- return;
- // tableRef.current
- const pos = (0, position_1.getPosition)(columnToolsRef.current, {
- location: "top",
- align: "center",
- target: currentCell,
- yAnchor: table,
- yOffset: 2,
- });
- columnToolsRef.current.style.left = `${pos.left}px`;
- columnToolsRef.current.style.top = `${pos.top}px`;
- }, [editor.state.selection, columnToolsRef.current, table]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ ref: columnToolsRef, sx: {
- zIndex: 999,
- top: 0,
- left: 0,
- position: "absolute",
- bg: "background",
- flexWrap: "nowrap",
- borderRadius: "default",
- opacity: 0.3,
- ":hover": {
- opacity: 1,
- },
- } }, { children: [(0, jsx_runtime_1.jsx)(table_1.TableProperties, { editor: editor, title: "tableProperties", icon: "more", variant: "small" }), (0, jsx_runtime_1.jsx)(table_1.InsertColumnRight, Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("insertColumnRight"), { editor: editor, variant: "small", icon: "plus" }))] })));
-}
diff --git a/packages/editor/dist/cjs/extensions/table/index.d.ts b/packages/editor/dist/cjs/extensions/table/index.d.ts
deleted file mode 100644
index 0e948df9e..000000000
--- a/packages/editor/dist/cjs/extensions/table/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./table";
diff --git a/packages/editor/dist/cjs/extensions/table/index.js b/packages/editor/dist/cjs/extensions/table/index.js
deleted file mode 100644
index 4590e5f03..000000000
--- a/packages/editor/dist/cjs/extensions/table/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./table"), exports);
diff --git a/packages/editor/dist/cjs/extensions/table/table.d.ts b/packages/editor/dist/cjs/extensions/table/table.d.ts
deleted file mode 100644
index e5a29b0de..000000000
--- a/packages/editor/dist/cjs/extensions/table/table.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { TableOptions } from "@tiptap/extension-table";
-export declare const Table: import("@tiptap/core").Node<TableOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/table/table.js b/packages/editor/dist/cjs/extensions/table/table.js
deleted file mode 100644
index 3ca8dcb2e..000000000
--- a/packages/editor/dist/cjs/extensions/table/table.js
+++ /dev/null
@@ -1,28 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Table = void 0;
-const extension_table_1 = require("@tiptap/extension-table");
-const prosemirror_tables_1 = require("@_ueberdosis/prosemirror-tables");
-const component_1 = require("./component");
-exports.Table = extension_table_1.Table.extend({
- addProseMirrorPlugins() {
- const isResizable = this.options.resizable && this.editor.isEditable;
- return [
- ...(isResizable
- ? [
- (0, prosemirror_tables_1.columnResizing)({
- handleWidth: this.options.handleWidth,
- cellMinWidth: this.options.cellMinWidth,
- View: (0, component_1.TableNodeView)(this.editor),
- // TODO: PR for @types/prosemirror-tables
- // @ts-ignore (incorrect type)
- lastColumnResizable: this.options.lastColumnResizable,
- }),
- ]
- : []),
- (0, prosemirror_tables_1.tableEditing)({
- allowTableNodeSelection: this.options.allowTableNodeSelection,
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/tablecell/index.d.ts b/packages/editor/dist/cjs/extensions/tablecell/index.d.ts
deleted file mode 100644
index a85cac945..000000000
--- a/packages/editor/dist/cjs/extensions/tablecell/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { TableCell } from "./table-cell";
-export * from "./table-cell";
-export default TableCell;
diff --git a/packages/editor/dist/cjs/extensions/tablecell/index.js b/packages/editor/dist/cjs/extensions/tablecell/index.js
deleted file mode 100644
index 9b43e4704..000000000
--- a/packages/editor/dist/cjs/extensions/tablecell/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const tablecell_1 = require("./tablecell");
-__exportStar(require("./tablecell"), exports);
-exports.default = tablecell_1.TableCell;
diff --git a/packages/editor/dist/cjs/extensions/tablecell/tablecell.d.ts b/packages/editor/dist/cjs/extensions/tablecell/tablecell.d.ts
deleted file mode 100644
index 16c4d1e28..000000000
--- a/packages/editor/dist/cjs/extensions/tablecell/tablecell.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const TableCell: import("@tiptap/core").Node<import("@tiptap/extension-table-cell").TableCellOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/tablecell/tablecell.js b/packages/editor/dist/cjs/extensions/tablecell/tablecell.js
deleted file mode 100644
index 2be64b0d2..000000000
--- a/packages/editor/dist/cjs/extensions/tablecell/tablecell.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TableCell = void 0;
-const extension_table_cell_1 = __importDefault(require("@tiptap/extension-table-cell"));
-exports.TableCell = extension_table_cell_1.default.extend({
- addAttributes() {
- var _a;
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { backgroundColor: addStyleAttribute("backgroundColor", "background-color"), color: addStyleAttribute("color", "color"), borderWidth: addStyleAttribute("borderWidth", "border-width", "px"), borderStyle: addStyleAttribute("borderStyle", "border-style"), borderColor: addStyleAttribute("borderColor", "border-color") });
- },
-});
-function addStyleAttribute(name, cssName, unit) {
- return {
- default: null,
- parseHTML: (element) => {
- var _a;
- return unit
- ? (_a = element.style[name]) === null || _a === void 0 ? void 0 : _a.toString().replace(unit, "")
- : element.style[name];
- },
- renderHTML: (attributes) => {
- if (!attributes[name]) {
- return {};
- }
- return {
- style: `${cssName}: ${attributes[name]}${unit || ""}`,
- };
- },
- };
-}
diff --git a/packages/editor/dist/cjs/extensions/taskitem/component.d.ts b/packages/editor/dist/cjs/extensions/taskitem/component.d.ts
deleted file mode 100644
index b01ab35de..000000000
--- a/packages/editor/dist/cjs/extensions/taskitem/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-import { TaskItemAttributes } from "./task-item";
-export declare function TaskItemComponent(props: ReactNodeViewProps<TaskItemAttributes>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/taskitem/component.js b/packages/editor/dist/cjs/extensions/taskitem/component.js
deleted file mode 100644
index b663deb5a..000000000
--- a/packages/editor/dist/cjs/extensions/taskitem/component.js
+++ /dev/null
@@ -1,98 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TaskItemComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const core_1 = require("@tiptap/core");
-const react_1 = require("react");
-const taskitem_1 = require("./taskitem");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-function TaskItemComponent(props) {
- const { editor, updateAttributes, node, getPos, forwardRef } = props;
- const { checked } = props.node.attrs;
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const toggle = (0, react_1.useCallback)(() => {
- var _a;
- if (!editor.isEditable)
- return false;
- updateAttributes({ checked: !checked });
- const pos = getPos();
- const node = (_a = editor.current) === null || _a === void 0 ? void 0 : _a.state.doc.nodeAt(pos);
- if (!node)
- return false;
- editor.commands.command(({ tr }) => {
- toggleChildren(node, tr, !checked, pos);
- return true;
- });
- return true;
- }, [editor, getPos, checked]);
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ "data-drag-image": true, sx: {
- bg: "background",
- borderRadius: "default",
- ":hover > .dragHandle": {
- opacity: editor.isEditable ? 1 : 0,
- },
- } }, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { className: "dragHandle", draggable: "true", "data-drag-handle": true, path: icons_1.Icons.dragHandle, sx: {
- opacity: [1, 1, 0],
- alignSelf: "start",
- mr: 2,
- bg: "transparent",
- cursor: "grab",
- ".icon:hover path": {
- fill: "var(--checked) !important",
- },
- }, size: isMobile ? 24 : 20 }), (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: checked ? icons_1.Icons.check : "", stroke: "1px", sx: {
- border: "2px solid",
- borderColor: checked ? "checked" : "icon",
- borderRadius: "default",
- alignSelf: "start",
- mr: 2,
- p: "1px",
- cursor: editor.isEditable ? "pointer" : "unset",
- ":hover": {
- borderColor: "checked",
- },
- ":hover .icon path": {
- fill: "var(--checked) !important",
- },
- }, onMouseDown: (e) => {
- e.preventDefault();
- toggle();
- }, onTouchEnd: (e) => {
- e.preventDefault();
- toggle();
- }, color: checked ? "checked" : "icon", size: isMobile ? 16 : 14 }), (0, jsx_runtime_1.jsx)(rebass_1.Text, { as: "div", ref: forwardRef, sx: {
- "> .taskitem-content-wrapper > p": {
- textDecorationLine: checked ? "line-through" : "none",
- opacity: checked ? 0.8 : 1,
- },
- flex: 1,
- } })] })) }));
-}
-exports.TaskItemComponent = TaskItemComponent;
-function toggleChildren(node, tr, toggleState, parentPos) {
- const children = (0, core_1.findChildren)(node, (node) => node.type.name === taskitem_1.TaskItemNode.name);
- for (const { pos } of children) {
- // need to add 1 to get inside the node
- const actualPos = pos + parentPos + 1;
- tr.setNodeMarkup(actualPos, undefined, {
- checked: toggleState,
- });
- }
- return tr;
-}
-function getChildren(node, parentPos) {
- const children = [];
- node.forEach((node, offset) => {
- children.push({ node, pos: parentPos + offset + 1 });
- });
- return children;
-}
-function areAllChecked(node) {
- const children = (0, core_1.findChildren)(node, (node) => node.type.name === taskitem_1.TaskItemNode.name);
- if (children.length <= 0)
- return undefined;
- return children.every((node) => node.node.attrs.checked);
-}
diff --git a/packages/editor/dist/cjs/extensions/taskitem/index.d.ts b/packages/editor/dist/cjs/extensions/taskitem/index.d.ts
deleted file mode 100644
index 3518ff3b2..000000000
--- a/packages/editor/dist/cjs/extensions/taskitem/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./task-item";
diff --git a/packages/editor/dist/cjs/extensions/taskitem/index.js b/packages/editor/dist/cjs/extensions/taskitem/index.js
deleted file mode 100644
index 088000612..000000000
--- a/packages/editor/dist/cjs/extensions/taskitem/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./taskitem"), exports);
diff --git a/packages/editor/dist/cjs/extensions/taskitem/taskitem.d.ts b/packages/editor/dist/cjs/extensions/taskitem/taskitem.d.ts
deleted file mode 100644
index 32494f7fa..000000000
--- a/packages/editor/dist/cjs/extensions/taskitem/taskitem.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export declare type TaskItemAttributes = {
- checked: boolean;
-};
-export declare const TaskItemNode: import("@tiptap/core").Node<import("@tiptap/extension-task-item").TaskItemOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/taskitem/taskitem.js b/packages/editor/dist/cjs/extensions/taskitem/taskitem.js
deleted file mode 100644
index 94c34cc19..000000000
--- a/packages/editor/dist/cjs/extensions/taskitem/taskitem.js
+++ /dev/null
@@ -1,63 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TaskItemNode = void 0;
-const core_1 = require("@tiptap/core");
-const commands_1 = require("../list-item/commands");
-const extension_task_item_1 = require("@tiptap/extension-task-item");
-const component_1 = require("./component");
-const react_1 = require("../react");
-exports.TaskItemNode = extension_task_item_1.TaskItem.extend({
- draggable: true,
- addAttributes() {
- return {
- checked: {
- default: false,
- keepOnSplit: false,
- parseHTML: (element) => element.classList.contains("checked"),
- renderHTML: (attributes) => ({
- class: attributes.checked ? "checked" : "",
- }),
- },
- };
- },
- renderHTML({ node, HTMLAttributes }) {
- return [
- "li",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
- class: "checklist--item",
- }),
- 0,
- ];
- },
- parseHTML() {
- return [
- {
- tag: `li`,
- getAttrs: (node) => {
- var _a;
- if (node instanceof Node && node instanceof HTMLElement) {
- return node.classList.contains("checklist--item") ||
- ((_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains("checklist"))
- ? null
- : false;
- }
- return false;
- },
- priority: 51,
- },
- ];
- },
- addKeyboardShortcuts() {
- var _a;
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { Backspace: ({ editor }) => (0, commands_1.onBackspacePressed)(editor, this.name, this.type) });
- },
- addNodeView() {
- return (0, react_1.createNodeView)(component_1.TaskItemComponent, {
- contentDOMFactory: true,
- wrapperFactory: () => document.createElement("li"),
- shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
- return (prev.checked !== next.checked || prev.collapsed !== next.collapsed);
- },
- });
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/tasklist/component.d.ts b/packages/editor/dist/cjs/extensions/tasklist/component.d.ts
deleted file mode 100644
index 5cc94955c..000000000
--- a/packages/editor/dist/cjs/extensions/tasklist/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-import { TaskListAttributes } from "./task-list";
-export declare function TaskListComponent(props: ReactNodeViewProps<TaskListAttributes>): JSX.Element;
diff --git a/packages/editor/dist/cjs/extensions/tasklist/component.js b/packages/editor/dist/cjs/extensions/tasklist/component.js
deleted file mode 100644
index 56fc8dc42..000000000
--- a/packages/editor/dist/cjs/extensions/tasklist/component.js
+++ /dev/null
@@ -1,113 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TaskListComponent = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const core_1 = require("@tiptap/core");
-const icon_1 = require("../../toolbar/components/icon");
-const icons_1 = require("../../toolbar/icons");
-const react_1 = require("react");
-const forms_1 = require("@rebass/forms");
-const taskitem_1 = require("../taskitem");
-const prosemirror_utils_1 = require("prosemirror-utils");
-const toolbarstore_1 = require("../../toolbar/stores/toolbarstore");
-function TaskListComponent(props) {
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const { editor, getPos, node, updateAttributes, forwardRef } = props;
- const taskItemType = (0, core_1.getNodeType)(taskitem_1.TaskItemNode.name, editor.schema);
- const { title, collapsed } = node.attrs;
- const [stats, setStats] = (0, react_1.useState)({ checked: 0, total: 0, percentage: 0 });
- const getParent = (0, react_1.useCallback)(() => {
- const pos = editor.state.doc.resolve(getPos());
- return (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(pos, taskItemType);
- }, []);
- const isNested = (0, react_1.useMemo)(() => {
- return !!getParent();
- }, [getParent]);
- (0, react_1.useEffect)(() => {
- const parent = getParent();
- if (!parent)
- return;
- const { node, pos } = parent;
- const allChecked = areAllChecked(node, pos, editor.state.doc);
- // no need to create a transaction if the check state is
- // not changed.
- if (node.attrs.checked === allChecked)
- return;
- // check parent item if all child items are checked.
- editor.commands.command(({ tr }) => {
- tr.setNodeMarkup(pos, undefined, { checked: allChecked });
- return true;
- });
- }, [node, node.childCount]);
- (0, react_1.useEffect)(() => {
- const children = (0, core_1.findChildren)(node, (node) => node.type.name === taskitem_1.TaskItemNode.name);
- const checked = children.filter((node) => node.node.attrs.checked).length;
- const total = children.length;
- const percentage = Math.round((checked / total) * 100);
- setStats({ checked, total, percentage });
- }, [isNested, node]);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- flexDirection: "column",
- ":hover > div > .toggleSublist": { opacity: 1 },
- } }, { children: isNested ? ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- position: "absolute",
- top: 0,
- right: 0,
- }, contentEditable: false }, { children: [collapsed && ((0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "body", sx: { color: "fontTertiary", mr: 35 } }, { children: [stats.checked, "/", stats.total] }))), (0, jsx_runtime_1.jsx)(icon_1.Icon, { className: "toggleSublist", path: collapsed ? icons_1.Icons.chevronDown : icons_1.Icons.chevronUp, sx: {
- opacity: isMobile || collapsed ? 1 : 0,
- position: "absolute",
- right: 0,
- alignSelf: "start",
- mr: 2,
- cursor: "pointer",
- ".icon:hover path": {
- fill: "var(--checked) !important",
- },
- }, size: isMobile ? 24 : 20, onClick: () => {
- updateAttributes({ collapsed: !collapsed }, { addToHistory: false, preventUpdate: true });
- } })] }))) : ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- position: "relative",
- bg: "bgSecondary",
- py: 1,
- borderRadius: "default",
- mb: 2,
- alignItems: "center",
- justifyContent: "end",
- overflow: "hidden",
- }, contentEditable: false }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Box, { sx: {
- height: "100%",
- width: `${stats.percentage}%`,
- position: "absolute",
- bg: "border",
- zIndex: 0,
- left: 0,
- transition: "width 250ms ease-out",
- } }), (0, jsx_runtime_1.jsx)(forms_1.Input, { readOnly: !editor.isEditable, value: title || "", variant: "clean", sx: { p: 0, px: 2, zIndex: 1, color: "fontTertiary" }, placeholder: "Untitled", onChange: (e) => {
- updateAttributes({ title: e.target.value }, { addToHistory: true, preventUpdate: false });
- } }), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { flexShrink: 0, pr: 2 } }, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.checkbox, size: 15, color: "fontTertiary" }), (0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "body", sx: { ml: 1, color: "fontTertiary" } }, { children: [stats.checked, "/", stats.total] }))] }))] }))) })), (0, jsx_runtime_1.jsx)(rebass_1.Text, { as: "div", ref: forwardRef, sx: {
- ul: {
- display: collapsed ? "none" : "block",
- paddingInlineStart: 0,
- marginBlockStart: isNested ? 10 : 0,
- marginBlockEnd: 0,
- marginLeft: isNested ? -35 : 0,
- },
- li: {
- listStyleType: "none",
- position: "relative",
- marginBottom: [2, "7px"],
- },
- } })] }));
-}
-exports.TaskListComponent = TaskListComponent;
-function areAllChecked(node, pos, doc) {
- const children = (0, core_1.findChildren)(node, (node) => node.type.name === taskitem_1.TaskItemNode.name);
- for (const child of children) {
- const childPos = pos + child.pos + 1;
- const node = doc.nodeAt(childPos);
- if (!(node === null || node === void 0 ? void 0 : node.attrs.checked))
- return false;
- }
- return true;
-}
diff --git a/packages/editor/dist/cjs/extensions/tasklist/index.d.ts b/packages/editor/dist/cjs/extensions/tasklist/index.d.ts
deleted file mode 100644
index 291e035cb..000000000
--- a/packages/editor/dist/cjs/extensions/tasklist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./task-list";
diff --git a/packages/editor/dist/cjs/extensions/tasklist/index.js b/packages/editor/dist/cjs/extensions/tasklist/index.js
deleted file mode 100644
index bbc38c126..000000000
--- a/packages/editor/dist/cjs/extensions/tasklist/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-__exportStar(require("./tasklist"), exports);
diff --git a/packages/editor/dist/cjs/extensions/tasklist/tasklist.d.ts b/packages/editor/dist/cjs/extensions/tasklist/tasklist.d.ts
deleted file mode 100644
index 46bdb2668..000000000
--- a/packages/editor/dist/cjs/extensions/tasklist/tasklist.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export declare type TaskListAttributes = {
- title: string;
- collapsed: boolean;
-};
-export declare const TaskListNode: import("@tiptap/core").Node<import("@tiptap/extension-task-list").TaskListOptions, any>;
diff --git a/packages/editor/dist/cjs/extensions/tasklist/tasklist.js b/packages/editor/dist/cjs/extensions/tasklist/tasklist.js
deleted file mode 100644
index e383b0d6f..000000000
--- a/packages/editor/dist/cjs/extensions/tasklist/tasklist.js
+++ /dev/null
@@ -1,87 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TaskListNode = void 0;
-const core_1 = require("@tiptap/core");
-const extension_task_list_1 = require("@tiptap/extension-task-list");
-const react_1 = require("../react");
-const component_1 = require("./component");
-exports.TaskListNode = extension_task_list_1.TaskList.extend({
- addAttributes() {
- return {
- collapsed: {
- default: false,
- keepOnSplit: false,
- parseHTML: (element) => element.dataset.collapsed === "true",
- renderHTML: (attributes) => ({
- "data-collapsed": attributes.collapsed === true,
- }),
- },
- title: {
- default: null,
- keepOnSplit: false,
- parseHTML: (element) => element.dataset.title,
- renderHTML: (attributes) => {
- if (!attributes.title || attributes.nested) {
- return {};
- }
- return {
- "data-title": attributes.title,
- };
- },
- },
- };
- },
- parseHTML() {
- return [
- {
- tag: `ul`,
- getAttrs: (node) => {
- if (node instanceof Node && node instanceof HTMLElement) {
- return node.classList.contains("checklist") && null;
- }
- return false;
- },
- priority: 51,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "ul",
- (0, core_1.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
- class: "checklist",
- }),
- 0,
- ];
- },
- addCommands() {
- return {
- toggleTaskList: () => ({ editor, commands, state, tr }) => {
- const { $from, $to } = state.selection;
- commands.toggleList(this.name, this.options.itemTypeName);
- const position = {
- from: tr.mapping.map($from.pos),
- to: tr.mapping.map($to.pos),
- };
- // There is a minor bug in Prosemirror or Tiptap where creating
- // nested node view causes the editor selection to act weird.
- // The solution is to manually force the editor back to the correct
- // position.
- // NOTE: We have to wrap this in setTimeout & use the editor
- // directly or else it won't run.
- setTimeout(() => editor.commands.setTextSelection(position), 0);
- return true;
- },
- };
- },
- addNodeView() {
- return (0, react_1.createNodeView)(component_1.TaskListComponent, {
- contentDOMFactory: () => {
- const content = document.createElement("ul");
- content.classList.add(`${this.name.toLowerCase()}-content-wrapper`);
- content.style.whiteSpace = "inherit";
- return { dom: content };
- },
- });
- },
-});
diff --git a/packages/editor/dist/cjs/extensions/textdirection/index.d.ts b/packages/editor/dist/cjs/extensions/textdirection/index.d.ts
deleted file mode 100644
index ea2fee63c..000000000
--- a/packages/editor/dist/cjs/extensions/textdirection/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { TextDirection } from "./text-direction";
-export * from "./text-direction";
-export default TextDirection;
diff --git a/packages/editor/dist/cjs/extensions/textdirection/index.js b/packages/editor/dist/cjs/extensions/textdirection/index.js
deleted file mode 100644
index e9313321a..000000000
--- a/packages/editor/dist/cjs/extensions/textdirection/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const textdirection_1 = require("./textdirection");
-__exportStar(require("./textdirection"), exports);
-exports.default = textdirection_1.TextDirection;
diff --git a/packages/editor/dist/cjs/extensions/textdirection/textdirection.d.ts b/packages/editor/dist/cjs/extensions/textdirection/textdirection.d.ts
deleted file mode 100644
index a29fdf91d..000000000
--- a/packages/editor/dist/cjs/extensions/textdirection/textdirection.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Extension } from "@tiptap/core";
-import "@tiptap/extension-text-style";
-declare type TextDirectionOptions = {
- types: string[];
- defaultDirection: TextDirections;
-};
-declare type TextDirections = "ltr" | "rtl";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- textDirection: {
- /**
- * Set the font family
- */
- setTextDirection: (direction: TextDirections) => ReturnType;
- };
- }
-}
-export declare const TextDirection: Extension<TextDirectionOptions, any>;
-export {};
diff --git a/packages/editor/dist/cjs/extensions/textdirection/textdirection.js b/packages/editor/dist/cjs/extensions/textdirection/textdirection.js
deleted file mode 100644
index 2094d2b0c..000000000
--- a/packages/editor/dist/cjs/extensions/textdirection/textdirection.js
+++ /dev/null
@@ -1,40 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TextDirection = void 0;
-const core_1 = require("@tiptap/core");
-require("@tiptap/extension-text-style");
-exports.TextDirection = core_1.Extension.create({
- name: "textDirection",
- defaultOptions: {
- types: ["paragraph", "heading"],
- defaultDirection: "ltr",
- },
- addGlobalAttributes() {
- return [
- {
- types: this.options.types,
- attributes: {
- textDirection: {
- default: this.options.defaultDirection,
- parseHTML: (element) => element.dir,
- renderHTML: (attributes) => {
- if (!attributes.textDirection) {
- return {};
- }
- return {
- dir: attributes.textDirection,
- };
- },
- },
- },
- },
- ];
- },
- addCommands() {
- return {
- setTextDirection: (direction) => ({ commands }) => {
- return this.options.types.every((type) => commands.updateAttributes(type, { textDirection: direction }));
- },
- };
- },
-});
diff --git a/packages/editor/dist/cjs/hooks/useEditor.d.ts b/packages/editor/dist/cjs/hooks/useEditor.d.ts
deleted file mode 100644
index 5b12357f0..000000000
--- a/packages/editor/dist/cjs/hooks/useEditor.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { EditorOptions } from "@tiptap/core";
-import { DependencyList } from "react";
-import { Editor } from "../types";
-export declare const useEditor: (options?: Partial<EditorOptions>, deps?: DependencyList) => Editor | null;
diff --git a/packages/editor/dist/cjs/hooks/useEditor.js b/packages/editor/dist/cjs/hooks/useEditor.js
deleted file mode 100644
index 205f6916a..000000000
--- a/packages/editor/dist/cjs/hooks/useEditor.js
+++ /dev/null
@@ -1,66 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.useEditor = void 0;
-const react_1 = require("react");
-const types_1 = require("../types");
-function useForceUpdate() {
- const [, setValue] = (0, react_1.useState)(0);
- return () => setValue((value) => value + 1);
-}
-const useEditor = (options = {}, deps = []) => {
- const [editor, setEditor] = (0, react_1.useState)(null);
- const forceUpdate = useForceUpdate();
- const editorRef = (0, react_1.useRef)(editor);
- (0, react_1.useEffect)(() => {
- let isMounted = true;
- const instance = new types_1.Editor(options);
- setEditor(instance);
- instance.on("transaction", () => {
- requestAnimationFrame(() => {
- requestAnimationFrame(() => {
- if (isMounted) {
- forceUpdate();
- }
- });
- });
- });
- return () => {
- instance.destroy();
- isMounted = false;
- };
- }, deps);
- (0, react_1.useEffect)(() => {
- editorRef.current = editor;
- if (!editor)
- return;
- if (!editor.current) {
- Object.defineProperty(editor, "current", {
- get: () => editorRef.current,
- });
- }
- // if (!editor.executor) {
- // Object.defineProperty(editor, "executor", {
- // get: () => (id?: string) => {
- // console.log(id);
- // return editorRef.current;
- // },
- // });
- // }
- }, [editor]);
- (0, react_1.useEffect)(() => {
- // this is required for the drag/drop to work properly
- // in the editor.
- function onDragEnter(event) {
- if (!!(editor === null || editor === void 0 ? void 0 : editor.view.dragging)) {
- event.preventDefault();
- return true;
- }
- }
- editor === null || editor === void 0 ? void 0 : editor.view.dom.addEventListener("dragenter", onDragEnter);
- return () => {
- editor === null || editor === void 0 ? void 0 : editor.view.dom.removeEventListener("dragenter", onDragEnter);
- };
- }, [editor === null || editor === void 0 ? void 0 : editor.view.dom]);
- return editor;
-};
-exports.useEditor = useEditor;
diff --git a/packages/editor/dist/cjs/hooks/usePermissionHandler.d.ts b/packages/editor/dist/cjs/hooks/usePermissionHandler.d.ts
deleted file mode 100644
index 7aa8fe0d6..000000000
--- a/packages/editor/dist/cjs/hooks/usePermissionHandler.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { UnionCommands } from "@tiptap/core";
-export declare type Claims = "premium";
-export declare type PermissionHandlerOptions = {
- claims: Record<Claims, boolean>;
- onPermissionDenied: (claim: Claims, id: keyof UnionCommands) => void;
-};
-export declare function usePermissionHandler(options: PermissionHandlerOptions): void;
diff --git a/packages/editor/dist/cjs/hooks/usePermissionHandler.js b/packages/editor/dist/cjs/hooks/usePermissionHandler.js
deleted file mode 100644
index 39551e1ce..000000000
--- a/packages/editor/dist/cjs/hooks/usePermissionHandler.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.usePermissionHandler = void 0;
-const react_1 = require("react");
-const ClaimsMap = {
- premium: ["insertImage"],
-};
-function usePermissionHandler(options) {
- const { claims, onPermissionDenied } = options;
- (0, react_1.useEffect)(() => {
- function onPermissionRequested(ev) {
- const { detail: { id }, } = ev;
- for (const key in ClaimsMap) {
- const claim = key;
- const commands = ClaimsMap[claim];
- if (commands.indexOf(id) <= -1)
- continue;
- if (claims[claim])
- continue;
- onPermissionDenied(claim, id);
- ev.preventDefault();
- break;
- }
- ev.preventDefault();
- }
- window.addEventListener("permissionrequest", onPermissionRequested);
- return () => {
- window.removeEventListener("permissionrequest", onPermissionRequested);
- };
- }, [claims, onPermissionDenied]);
-}
-exports.usePermissionHandler = usePermissionHandler;
diff --git a/packages/editor/dist/cjs/hooks/useRefValue.d.ts b/packages/editor/dist/cjs/hooks/useRefValue.d.ts
deleted file mode 100644
index de0bdea82..000000000
--- a/packages/editor/dist/cjs/hooks/useRefValue.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-/// <reference types="react" />
-export declare function useRefValue<T>(value: T): import("react").MutableRefObject<T>;
diff --git a/packages/editor/dist/cjs/hooks/useRefValue.js b/packages/editor/dist/cjs/hooks/useRefValue.js
deleted file mode 100644
index 5e12e9374..000000000
--- a/packages/editor/dist/cjs/hooks/useRefValue.js
+++ /dev/null
@@ -1,12 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.useRefValue = void 0;
-const react_1 = require("react");
-function useRefValue(value) {
- const refValue = (0, react_1.useRef)(value);
- (0, react_1.useEffect)(() => {
- refValue.current = value;
- }, [value]);
- return refValue;
-}
-exports.useRefValue = useRefValue;
diff --git a/packages/editor/dist/cjs/index.d.ts b/packages/editor/dist/cjs/index.d.ts
deleted file mode 100644
index 3c141a049..000000000
--- a/packages/editor/dist/cjs/index.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/// <reference types="react" />
-import "./extensions";
-import Toolbar from "./toolbar";
-import { Theme } from "@streetwriters/theme";
-import { AttachmentOptions } from "./extensions/attachment";
-import { EditorOptions } from "@tiptap/core";
-import { usePermissionHandler } from "./hooks/use-permission-handler";
-declare type TiptapOptions = EditorOptions & AttachmentOptions & {
- theme: Theme;
- isMobile?: boolean;
-};
-declare const useTiptap: (options?: Partial<TiptapOptions>, deps?: import("react").DependencyList) => import("./types").Editor | null;
-export { useTiptap, Toolbar, usePermissionHandler };
-export * from "./types";
-export * from "./extensions/react";
-export * from "./toolbar";
-export { type AttachmentType, type Attachment } from "./extensions/attachment";
diff --git a/packages/editor/dist/cjs/index.js b/packages/editor/dist/cjs/index.js
deleted file mode 100644
index f3c42deff..000000000
--- a/packages/editor/dist/cjs/index.js
+++ /dev/null
@@ -1,176 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.usePermissionHandler = exports.Toolbar = exports.useTiptap = void 0;
-require("./extensions");
-const extension_character_count_1 = __importDefault(require("@tiptap/extension-character-count"));
-const extension_placeholder_1 = __importDefault(require("@tiptap/extension-placeholder"));
-const extension_underline_1 = __importDefault(require("@tiptap/extension-underline"));
-const starter_kit_1 = __importDefault(require("@tiptap/starter-kit"));
-const react_1 = require("react");
-const prosemirror_view_1 = require("prosemirror-view");
-const toolbar_1 = __importDefault(require("./toolbar"));
-exports.Toolbar = toolbar_1.default;
-const extension_text_align_1 = __importDefault(require("@tiptap/extension-text-align"));
-const extension_subscript_1 = __importDefault(require("@tiptap/extension-subscript"));
-const extension_superscript_1 = __importDefault(require("@tiptap/extension-superscript"));
-const fontsize_1 = __importDefault(require("./extensions/fontsize"));
-const textdirection_1 = __importDefault(require("./extensions/textdirection"));
-const extension_text_style_1 = __importDefault(require("@tiptap/extension-text-style"));
-const extension_font_family_1 = __importDefault(require("@tiptap/extension-font-family"));
-const bulletlist_1 = __importDefault(require("./extensions/bulletlist"));
-const orderedlist_1 = __importDefault(require("./extensions/orderedlist"));
-const extension_highlight_1 = __importDefault(require("@tiptap/extension-highlight"));
-const extension_color_1 = __importDefault(require("@tiptap/extension-color"));
-const extension_table_row_1 = __importDefault(require("@tiptap/extension-table-row"));
-const tablecell_1 = __importDefault(require("./extensions/tablecell"));
-const extension_table_header_1 = __importDefault(require("@tiptap/extension-table-header"));
-const image_1 = require("./extensions/image");
-const attachment_1 = require("./extensions/attachment");
-const tasklist_1 = require("./extensions/tasklist");
-const taskitem_1 = require("./extensions/taskitem");
-const dropcursor_1 = require("./extensions/dropcursor");
-const searchreplace_1 = require("./extensions/searchreplace");
-const embed_1 = require("./extensions/embed");
-const codeblock_1 = require("./extensions/codeblock");
-const listitem_1 = require("./extensions/listitem");
-const extension_link_1 = require("@tiptap/extension-link");
-const codemark_1 = require("./extensions/codemark");
-const math_1 = require("./extensions/math");
-const react_2 = require("./extensions/react");
-const outlinelist_1 = require("./extensions/outlinelist");
-const outlinelistitem_1 = require("./extensions/outlinelistitem");
-const keepinview_1 = require("./extensions/keepinview");
-const selectionpersist_1 = require("./extensions/selectionpersist");
-const table_1 = require("./extensions/table");
-const toolbarstore_1 = require("./toolbar/stores/toolbarstore");
-const useEditor_1 = require("./hooks/useEditor");
-const usePermissionHandler_1 = require("./hooks/usePermissionHandler");
-Object.defineProperty(exports, "usePermissionHandler", { enumerable: true, get: function () { return usePermissionHandler_1.usePermissionHandler; } });
-prosemirror_view_1.EditorView.prototype.updateState = function updateState(state) {
- if (!this.docView)
- return; // This prevents the matchesNode error on hot reloads
- this.updateStateInner(state, this.state.plugins != state.plugins);
-};
-const useTiptap = (options = {}, deps = []) => {
- const { theme, isMobile, onDownloadAttachment, onOpenAttachmentPicker, onBeforeCreate } = options, restOptions = __rest(options, ["theme", "isMobile", "onDownloadAttachment", "onOpenAttachmentPicker", "onBeforeCreate"]);
- const PortalProviderAPI = (0, react_2.usePortalProvider)();
- const setIsMobile = (0, toolbarstore_1.useToolbarStore)((store) => store.setIsMobile);
- const setTheme = (0, toolbarstore_1.useToolbarStore)((store) => store.setTheme);
- (0, react_1.useEffect)(() => {
- setIsMobile(isMobile || false);
- setTheme(theme);
- }, [isMobile, theme]);
- const defaultOptions = (0, react_1.useMemo)(() => ({
- extensions: [
- react_2.NodeViewSelectionNotifier,
- searchreplace_1.SearchReplace,
- extension_text_style_1.default,
- starter_kit_1.default.configure({
- dropcursor: false,
- codeBlock: false,
- listItem: false,
- orderedList: false,
- bulletList: false,
- history: {
- depth: 200,
- newGroupDelay: 1000,
- },
- }),
- dropcursor_1.Dropcursor.configure({
- class: "drop-cursor",
- }),
- extension_character_count_1.default,
- extension_underline_1.default,
- extension_subscript_1.default,
- extension_superscript_1.default,
- fontsize_1.default,
- textdirection_1.default,
- extension_font_family_1.default,
- bulletlist_1.default,
- orderedlist_1.default,
- taskitem_1.TaskItemNode.configure({ nested: true }),
- tasklist_1.TaskListNode,
- extension_link_1.Link.configure({ openOnClick: !isMobile }),
- table_1.Table.configure({
- resizable: true,
- allowTableNodeSelection: true,
- cellMinWidth: 50,
- }),
- extension_table_row_1.default,
- tablecell_1.default,
- extension_table_header_1.default,
- extension_highlight_1.default.configure({
- multicolor: true,
- }),
- codeblock_1.CodeBlock,
- extension_color_1.default,
- extension_text_align_1.default.configure({
- types: ["heading", "paragraph"],
- alignments: ["left", "right", "center", "justify"],
- defaultAlignment: "left",
- }),
- extension_placeholder_1.default.configure({
- placeholder: "Start writing your note...",
- }),
- image_1.ImageNode,
- embed_1.EmbedNode,
- attachment_1.AttachmentNode.configure({
- onDownloadAttachment,
- onOpenAttachmentPicker,
- }),
- outlinelistitem_1.OutlineListItem,
- outlinelist_1.OutlineList,
- listitem_1.ListItem,
- codemark_1.Codemark,
- math_1.MathInline,
- math_1.MathBlock,
- keepinview_1.KeepInView,
- selectionpersist_1.SelectionPersist,
- ],
- onBeforeCreate: ({ editor }) => {
- editor.storage.portalProviderAPI = PortalProviderAPI;
- if (onBeforeCreate)
- onBeforeCreate({ editor });
- },
- injectCSS: false,
- }), [
- onDownloadAttachment,
- onOpenAttachmentPicker,
- PortalProviderAPI,
- onBeforeCreate,
- ]);
- const editor = (0, useEditor_1.useEditor)(Object.assign(Object.assign({}, defaultOptions), restOptions), deps);
- return editor;
-};
-exports.useTiptap = useTiptap;
-__exportStar(require("./types"), exports);
-__exportStar(require("./extensions/react"), exports);
-__exportStar(require("./toolbar"), exports);
diff --git a/packages/editor/dist/cjs/package.json b/packages/editor/dist/cjs/package.json
deleted file mode 100644
index 1cd945a3b..000000000
--- a/packages/editor/dist/cjs/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "type": "commonjs"
-}
diff --git a/packages/editor/dist/cjs/toolbar/components/counter.d.ts b/packages/editor/dist/cjs/toolbar/components/counter.d.ts
deleted file mode 100644
index bfbe39347..000000000
--- a/packages/editor/dist/cjs/toolbar/components/counter.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import React from "react";
-export declare type CounterProps = {
- title: string;
- onIncrease: () => void;
- onDecrease: () => void;
- onReset: () => void;
- value: string;
-};
-declare function _Counter(props: CounterProps): JSX.Element;
-export declare const Counter: React.MemoExoticComponent<typeof _Counter>;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/components/counter.js b/packages/editor/dist/cjs/toolbar/components/counter.js
deleted file mode 100644
index 6e7c793af..000000000
--- a/packages/editor/dist/cjs/toolbar/components/counter.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Counter = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importDefault(require("react"));
-const rebass_1 = require("rebass");
-const button_1 = require("../../components/button");
-const toolbutton_1 = require("./toolbutton");
-function _Counter(props) {
- const { title, onDecrease, onIncrease, onReset, value } = props;
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- alignItems: "center",
- mr: 1,
- ":last-of-type": {
- mr: 0,
- },
- } }, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: `Decrease ${title}`, icon: "minus", variant: "small", onClick: onDecrease }), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ sx: {
- color: "text",
- bg: "transparent",
- px: 0,
- fontSize: "subBody",
- mx: 1,
- textAlign: "center",
- ":hover": { bg: "transparent" },
- }, onClick: onReset, title: `Reset ${title}` }, { children: value })), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: `Increase ${title}`, icon: "plus", variant: "small", onClick: onIncrease })] })));
-}
-exports.Counter = react_1.default.memo(_Counter, (prev, next) => {
- return prev.value === next.value;
-});
diff --git a/packages/editor/dist/cjs/toolbar/components/dropdown.d.ts b/packages/editor/dist/cjs/toolbar/components/dropdown.d.ts
deleted file mode 100644
index d383ea4a0..000000000
--- a/packages/editor/dist/cjs/toolbar/components/dropdown.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-import { MenuItem } from "../../components/menu/types";
-declare type DropdownProps = {
- id: string;
- group: string;
- selectedItem: string | JSX.Element;
- items: MenuItem[];
- buttonRef?: React.MutableRefObject<HTMLButtonElement | undefined>;
- menuWidth?: number;
-};
-export declare function Dropdown(props: DropdownProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/components/dropdown.js b/packages/editor/dist/cjs/toolbar/components/dropdown.js
deleted file mode 100644
index ea11b21ab..000000000
--- a/packages/editor/dist/cjs/toolbar/components/dropdown.js
+++ /dev/null
@@ -1,61 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Dropdown = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const icon_1 = require("./icon");
-const icons_1 = require("../icons");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const menu_1 = require("../../components/menu");
-const dom_1 = require("../utils/dom");
-const button_1 = require("../../components/button");
-const popuppresenter_1 = require("../../components/popuppresenter");
-function Dropdown(props) {
- let { id, group, items, selectedItem, buttonRef, menuWidth } = props;
- const internalRef = (0, react_1.useRef)();
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const isBottom = toolbarLocation === "bottom";
- const { closePopup, isPopupOpen } = (0, popuppresenter_1.usePopupHandler)({
- group,
- id,
- isOpen,
- onClosed: () => setIsOpen(false),
- });
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(button_1.Button, Object.assign({ ref: (ref) => {
- internalRef.current = ref;
- if (buttonRef)
- buttonRef.current = ref || undefined;
- }, sx: {
- p: 1,
- m: 0,
- bg: isPopupOpen ? "hover" : "transparent",
- mr: 1,
- display: "flex",
- alignItems: "center",
- ":hover": { bg: "hover" },
- ":last-of-type": {
- mr: 0,
- },
- }, onClick: () => setIsOpen((s) => !s), onMouseDown: (e) => e.preventDefault() }, { children: [typeof selectedItem === "string" ? ((0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ sx: { fontSize: "subBody", mr: 1, color: "text" } }, { children: selectedItem }))) : (selectedItem), (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: isBottom ? icons_1.Icons.chevronUp : icons_1.Icons.chevronDown, size: "small", color: "text" })] })), (0, jsx_runtime_1.jsx)(menu_1.MenuPresenter, { isOpen: isPopupOpen, items: items, onClose: () => closePopup(id), position: {
- target: isBottom
- ? (0, dom_1.getToolbarElement)()
- : internalRef.current || "mouse",
- isTargetAbsolute: true,
- location: isBottom ? "top" : "below",
- align: "center",
- yOffset: 5,
- }, blocking: !isMobile, focusOnRender: !isMobile, sx: {
- minWidth: menuWidth,
- maxWidth: isBottom ? "95vw" : "auto",
- flexDirection: isBottom ? "row" : "column",
- overflowX: isBottom ? "auto" : "hidden",
- marginRight: isBottom ? "10px" : 0,
- display: "flex",
- alignItems: isBottom ? "center" : "unset",
- mr: isBottom ? 0 : 2,
- } })] }));
-}
-exports.Dropdown = Dropdown;
diff --git a/packages/editor/dist/cjs/toolbar/components/icon.d.ts b/packages/editor/dist/cjs/toolbar/components/icon.d.ts
deleted file mode 100644
index b7b4d5cb3..000000000
--- a/packages/editor/dist/cjs/toolbar/components/icon.d.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/// <reference types="react" />
-import { Theme } from "@streetwriters/theme";
-import { SchemeColors } from "@streetwriters/theme/dist/theme/colorscheme";
-import { FlexProps } from "rebass";
-declare type IconProps = {
- title?: string;
- path: string;
- size?: keyof Theme["iconSizes"] | number;
- color?: keyof SchemeColors;
- stroke?: string;
- rotate?: boolean;
-};
-export declare type NNIconProps = FlexProps & IconProps;
-export declare function Icon(props: NNIconProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/components/icon.js b/packages/editor/dist/cjs/toolbar/components/icon.js
deleted file mode 100644
index 8a2b85403..000000000
--- a/packages/editor/dist/cjs/toolbar/components/icon.js
+++ /dev/null
@@ -1,38 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Icon = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importDefault(require("@mdi/react"));
-const rebass_1 = require("rebass");
-const emotion_theming_1 = require("emotion-theming");
-function MDIIconWrapper({ title, path, size = 24, color = "icon", stroke, rotate, }) {
- const theme = (0, emotion_theming_1.useTheme)();
- const themedColor = (theme === null || theme === void 0 ? void 0 : theme.colors)
- ? theme.colors[color]
- : color;
- return ((0, jsx_runtime_1.jsx)(react_1.default, { className: "icon", title: title, path: path, size: typeof size === "string"
- ? `${(theme === null || theme === void 0 ? void 0 : theme.iconSizes[size]) || 24}px`
- : `${size}px`, style: {
- strokeWidth: stroke || "0px",
- stroke: themedColor,
- }, color: themedColor, spin: rotate }));
-}
-function Icon(props) {
- const { sx, title, color, size, stroke, rotate, path } = props, restProps = __rest(props, ["sx", "title", "color", "size", "stroke", "rotate", "path"]);
- return ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: Object.assign({ flexShrink: 0, justifyContent: "center", alignItems: "center" }, sx) }, restProps, { children: (0, jsx_runtime_1.jsx)(MDIIconWrapper, { title: title, path: path, rotate: rotate, color: color, stroke: stroke, size: size }) })));
-}
-exports.Icon = Icon;
diff --git a/packages/editor/dist/cjs/toolbar/components/moretools.d.ts b/packages/editor/dist/cjs/toolbar/components/moretools.d.ts
deleted file mode 100644
index f630e403e..000000000
--- a/packages/editor/dist/cjs/toolbar/components/moretools.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-import { ToolId } from "../tools";
-declare type MoreToolsProps = ToolProps & {
- popupId: string;
- tools: ToolId[];
- autoCloseOnUnmount?: boolean;
-};
-export declare function MoreTools(props: MoreToolsProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/components/moretools.js b/packages/editor/dist/cjs/toolbar/components/moretools.js
deleted file mode 100644
index 62b095be3..000000000
--- a/packages/editor/dist/cjs/toolbar/components/moretools.js
+++ /dev/null
@@ -1,36 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.MoreTools = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const popuppresenter_1 = require("../../components/popuppresenter");
-const toolbutton_1 = require("../components/toolbutton");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const dom_1 = require("../utils/dom");
-const toolbargroup_1 = require("./toolbargroup");
-function MoreTools(props) {
- const { popupId, editor, tools, autoCloseOnUnmount } = props;
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- const isBottom = toolbarLocation === "bottom";
- const buttonRef = (0, react_1.useRef)();
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: isOpen, buttonRef: buttonRef, onClick: () => setIsOpen((s) => !s) })), (0, jsx_runtime_1.jsx)(popuppresenter_1.PopupWrapper, { isOpen: isOpen, group: "toolbarGroup", id: popupId, onClosed: () => setIsOpen(false), position: {
- isTargetAbsolute: true,
- target: isBottom ? (0, dom_1.getToolbarElement)() : buttonRef.current || "mouse",
- align: "center",
- location: isBottom ? "top" : "below",
- yOffset: 10,
- }, autoCloseOnUnmount: autoCloseOnUnmount, focusOnRender: false, blocking: false, renderPopup: () => ((0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { tools: tools, editor: editor, sx: {
- flex: 1,
- // this is intentionally set to a fixed value
- // because we want the same padding on mobile
- // and web.
- p: "5px",
- boxShadow: "menu",
- bg: "background",
- borderRadius: "default",
- overflowX: "auto",
- maxWidth: "95vw",
- } })) })] }));
-}
-exports.MoreTools = MoreTools;
diff --git a/packages/editor/dist/cjs/toolbar/components/popup.d.ts b/packages/editor/dist/cjs/toolbar/components/popup.d.ts
deleted file mode 100644
index fb521b343..000000000
--- a/packages/editor/dist/cjs/toolbar/components/popup.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { PropsWithChildren } from "react";
-declare type Action = {
- title: string;
- onClick: () => void;
- loading?: boolean;
- disabled?: boolean;
-};
-export declare type PopupProps = {
- title?: string;
- onClose?: () => void;
- action?: Action;
-};
-export declare function Popup(props: PropsWithChildren<PopupProps>): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/components/popup.js b/packages/editor/dist/cjs/toolbar/components/popup.js
deleted file mode 100644
index 05d5c6e1e..000000000
--- a/packages/editor/dist/cjs/toolbar/components/popup.js
+++ /dev/null
@@ -1,31 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Popup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const icon_1 = require("./icon");
-const icons_1 = require("../icons");
-const responsive_1 = require("../../components/responsive");
-function Popup(props) {
- const { title, onClose, action, children } = props;
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- overflow: "hidden",
- bg: "background",
- flexDirection: "column",
- borderRadius: "default",
- // border: "1px solid var(--border)",
- boxShadow: "menu",
- minWidth: 200,
- } }, { children: [title && ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ className: "movable", sx: {
- justifyContent: "space-between",
- alignItems: "center",
- p: 2,
- } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "title" }, { children: title })), (0, jsx_runtime_1.jsx)(rebass_1.Button, Object.assign({ variant: "tool", sx: { p: 0, bg: "transparent" }, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.close, size: "big" }) }))] }))), children, title && action && ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: { justifyContent: "end" }, bg: "bgSecondary", p: 1, px: 2, mt: 2 }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Button, Object.assign({ variant: "dialog", onClick: action.disabled || action.loading ? undefined : action.onClick, disabled: action.disabled || action.loading }, { children: action.loading ? ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.loading, rotate: true, size: "medium" })) : (action.title) })) })))] })) }), (0, jsx_runtime_1.jsxs)(responsive_1.MobileOnly, { children: [children, action && ((0, jsx_runtime_1.jsx)(rebass_1.Button, Object.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 ? ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.loading, rotate: true, size: "medium" })) : (action.title) })))] })] }));
-}
-exports.Popup = Popup;
diff --git a/packages/editor/dist/cjs/toolbar/components/splitbutton.d.ts b/packages/editor/dist/cjs/toolbar/components/splitbutton.d.ts
deleted file mode 100644
index 0db2f1020..000000000
--- a/packages/editor/dist/cjs/toolbar/components/splitbutton.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { PropsWithChildren } from "react";
-import { ToolButtonProps } from "./tool-button";
-import React from "react";
-export declare type SplitButtonProps = ToolButtonProps & {
- onOpen: () => void;
-};
-declare function _SplitButton(props: PropsWithChildren<SplitButtonProps>): JSX.Element;
-export declare const SplitButton: React.MemoExoticComponent<typeof _SplitButton>;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/components/splitbutton.js b/packages/editor/dist/cjs/toolbar/components/splitbutton.js
deleted file mode 100644
index c780d5236..000000000
--- a/packages/editor/dist/cjs/toolbar/components/splitbutton.js
+++ /dev/null
@@ -1,48 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SplitButton = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const icons_1 = require("../icons");
-const icon_1 = require("./icon");
-const toolbutton_1 = require("./toolbutton");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const button_1 = require("../../components/button");
-const react_2 = __importDefault(require("react"));
-function _SplitButton(props) {
- const { children, toggled, onOpen } = props, toolButtonProps = __rest(props, ["children", "toggled", "onOpen"]);
- const ref = (0, react_1.useRef)(null);
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ ref: ref, sx: {
- borderRadius: "default",
- } }, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, toolButtonProps, { sx: { mr: 0, ":hover": { bg: "hover" } }, toggled: false })), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ sx: {
- flexShrink: 0,
- p: 0,
- m: 0,
- px: "3px",
- bg: "bgSecondary",
- ":hover": { bg: "hover" },
- ":last-of-type": {
- mr: 0,
- },
- }, onClick: onOpen }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: toolbarLocation === "bottom" ? icons_1.Icons.chevronUp : icons_1.Icons.chevronDown, color: "text", size: "small", sx: { flexShrink: 0 } }) }))] })), children] }));
-}
-exports.SplitButton = react_2.default.memo(_SplitButton, (prev, next) => {
- return (prev.toggled === next.toggled &&
- JSON.stringify(prev.sx) === JSON.stringify(next.sx));
-});
diff --git a/packages/editor/dist/cjs/toolbar/components/toolbargroup.d.ts b/packages/editor/dist/cjs/toolbar/components/toolbargroup.d.ts
deleted file mode 100644
index 94c8be6dd..000000000
--- a/packages/editor/dist/cjs/toolbar/components/toolbargroup.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/// <reference types="react" />
-import { ToolbarGroupDefinition, ToolButtonVariant } from "../types";
-import { FlexProps } from "rebass";
-import { Editor } from "../../types";
-import { NodeWithOffset } from "../utils/prosemirror";
-export declare type ToolbarGroupProps = FlexProps & {
- tools: ToolbarGroupDefinition;
- editor: Editor;
- variant?: ToolButtonVariant;
- force?: boolean;
- selectedNode?: NodeWithOffset;
-};
-export declare function ToolbarGroup(props: ToolbarGroupProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/components/toolbargroup.js b/packages/editor/dist/cjs/toolbar/components/toolbargroup.js
deleted file mode 100644
index 666079473..000000000
--- a/packages/editor/dist/cjs/toolbar/components/toolbargroup.js
+++ /dev/null
@@ -1,33 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ToolbarGroup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const tools_1 = require("../tools");
-const rebass_1 = require("rebass");
-const moretools_1 = require("./moretools");
-const tooldefinitions_1 = require("../tooldefinitions");
-function ToolbarGroup(props) {
- const { tools, editor, force, selectedNode } = props, flexProps = __rest(props, ["tools", "editor", "force", "selectedNode"]);
- return ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ className: "toolbar-group" }, flexProps, { children: tools.map((toolId) => {
- if (Array.isArray(toolId)) {
- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, { title: "More", icon: "more", popupId: toolId.join(""), tools: toolId, editor: editor }, "more-tools"));
- }
- else {
- const Component = (0, tools_1.findTool)(toolId);
- const toolDefinition = (0, tooldefinitions_1.getToolDefinition)(toolId);
- return ((0, jsx_runtime_1.jsx)(Component, Object.assign({ editor: editor, force: force, selectedNode: selectedNode }, toolDefinition), toolDefinition.title));
- }
- }) })));
-}
-exports.ToolbarGroup = ToolbarGroup;
diff --git a/packages/editor/dist/cjs/toolbar/components/toolbutton.d.ts b/packages/editor/dist/cjs/toolbar/components/toolbutton.d.ts
deleted file mode 100644
index 58c40f4ee..000000000
--- a/packages/editor/dist/cjs/toolbar/components/toolbutton.d.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Theme } from "@streetwriters/theme";
-import { SchemeColors } from "@streetwriters/theme/dist/theme/colorscheme";
-import React from "react";
-import { ButtonProps } from "rebass";
-import { IconNames } from "../icons";
-import { ToolButtonVariant } from "../types";
-export declare type ToolButtonProps = ButtonProps & {
- icon: IconNames;
- iconColor?: keyof SchemeColors;
- iconSize?: keyof Theme["iconSizes"] | number;
- toggled: boolean;
- buttonRef?: React.MutableRefObject<HTMLButtonElement | null | undefined>;
- variant?: ToolButtonVariant;
-};
-export declare const ToolButton: React.NamedExoticComponent<ButtonProps & {
- icon: IconNames;
- iconColor?: "background" | "border" | "text" | "blue" | "gray" | "green" | "orange" | "purple" | "red" | "yellow" | "checked" | "disabled" | "placeholder" | "icon" | keyof import("@streetwriters/theme/dist/theme/colorscheme/static").StaticColors | "primary" | "bgTransparent" | "accent" | "bgSecondary" | "bgSecondaryText" | "bgSecondaryHover" | "hover" | "fontSecondary" | "fontTertiary" | "overlay" | "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/cjs/toolbar/components/toolbutton.js b/packages/editor/dist/cjs/toolbar/components/toolbutton.js
deleted file mode 100644
index 59e33f114..000000000
--- a/packages/editor/dist/cjs/toolbar/components/toolbutton.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ToolButton = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = __importDefault(require("react"));
-const icons_1 = require("../icons");
-const button_1 = require("../../components/button");
-const icon_1 = require("./icon");
-exports.ToolButton = react_1.default.memo(function ToolButton(props) {
- const { id, icon, iconSize, iconColor, toggled, sx, buttonRef, variant = "normal" } = props, buttonProps = __rest(props, ["id", "icon", "iconSize", "iconColor", "toggled", "sx", "buttonRef", "variant"]);
- return ((0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ ref: buttonRef, tabIndex: -1, id: `tool-${id || icon}`, sx: Object.assign({ flexShrink: 0, p: variant === "small" ? "small" : 1, borderRadius: variant === "small" ? "small" : "default", m: 0, bg: toggled ? "hover" : "transparent", mr: variant === "small" ? 0 : 1, ":hover": { bg: "hover" }, ":last-of-type": {
- mr: 0,
- } }, sx), onMouseDown: (e) => e.preventDefault() }, buttonProps, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons[icon], color: iconColor || "icon", size: iconSize || (variant === "small" ? "medium" : "big") }) })));
-}, (prev, next) => {
- return (prev.toggled === next.toggled &&
- prev.icon === next.icon &&
- JSON.stringify(prev.sx) === JSON.stringify(next.sx));
-});
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/index.d.ts b/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/index.d.ts
deleted file mode 100644
index e23f86eea..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/index.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Editor } from "../../../types";
-import { NodeWithOffset } from "../../utils/prosemirror";
-import { FloatingMenuProps } from "../types";
-export declare type HoverPopupProps = {
- editor: Editor;
- selectedNode: NodeWithOffset;
-};
-export declare function HoverPopupHandler(props: FloatingMenuProps): null;
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/index.js b/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/index.js
deleted file mode 100644
index 462e9fc47..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/index.js
+++ /dev/null
@@ -1,69 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.HoverPopupHandler = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const popuppresenter_1 = require("../../../components/popuppresenter");
-const link_1 = require("./link");
-const handlers = Object.assign({}, link_1.LinkHoverPopupHandler);
-const HOVER_TIMEOUT = 500;
-function HoverPopupHandler(props) {
- const { editor } = props;
- const hoverTimeoutId = (0, react_1.useRef)();
- const activePopup = (0, react_1.useRef)();
- (0, react_1.useEffect)(() => {
- function onMouseOver(e) {
- if (!e.target ||
- !(e.target instanceof HTMLElement) ||
- e.target.classList.contains("ProseMirror"))
- return;
- const element = e.target;
- if (activePopup.current) {
- const isOutsideEditor = !element.closest(".ProseMirror");
- const isInsidePopup = element.closest(".popup-presenter-portal");
- const isActiveElement = activePopup.current.element === element;
- if (isInsidePopup)
- return;
- if (isOutsideEditor || !isActiveElement) {
- console.log("HIDING", isOutsideEditor, isActiveElement, element);
- activePopup.current.hide();
- activePopup.current = undefined;
- return;
- }
- }
- clearTimeout(hoverTimeoutId.current);
- hoverTimeoutId.current = setTimeout(() => {
- const nodeName = element.nodeName.toLowerCase();
- const PopupHandler = handlers[nodeName];
- if (!PopupHandler || !editor.current)
- return;
- const pos = editor.current.view.posAtDOM(element, 0);
- const node = editor.current.view.state.doc.nodeAt(pos);
- if (!node)
- return;
- const hidePopup = (0, popuppresenter_1.showPopup)({
- popup: () => ((0, jsx_runtime_1.jsx)(PopupHandler, { editor: editor, selectedNode: {
- node,
- from: pos,
- to: pos + node.nodeSize,
- } })),
- blocking: false,
- focusOnRender: false,
- position: {
- target: element,
- align: "center",
- location: "top",
- isTargetAbsolute: true,
- },
- });
- activePopup.current = { element, hide: hidePopup };
- }, HOVER_TIMEOUT, {});
- }
- window.addEventListener("mouseover", onMouseOver);
- return () => {
- window.removeEventListener("mouseover", onMouseOver);
- };
- }, []);
- return null;
-}
-exports.HoverPopupHandler = HoverPopupHandler;
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.d.ts b/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.d.ts
deleted file mode 100644
index 6463e2600..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { HoverPopupProps } from ".";
-declare function LinkHoverPopup(props: HoverPopupProps): JSX.Element | null;
-export declare const LinkHoverPopupHandler: {
- a: typeof LinkHoverPopup;
-};
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.js b/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.js
deleted file mode 100644
index e5af2e808..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/hoverpopup/link.js
+++ /dev/null
@@ -1,20 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.LinkHoverPopupHandler = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbargroup_1 = require("../../components/toolbargroup");
-function LinkHoverPopup(props) {
- const { editor, selectedNode } = props;
- const { node } = selectedNode;
- if (!(node === null || node === void 0 ? void 0 : node.isText) ||
- node.marks.length <= 0 ||
- !node.marks.some((mark) => mark.type.name === "link"))
- return null;
- return ((0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { force: true, tools: ["openLink", "editLink", "removeLink"], editor: editor, selectedNode: selectedNode, sx: {
- bg: "background",
- boxShadow: "menu",
- borderRadius: "default",
- p: 1,
- } }));
-}
-exports.LinkHoverPopupHandler = { a: LinkHoverPopup };
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/index.d.ts b/packages/editor/dist/cjs/toolbar/floatingmenus/index.d.ts
deleted file mode 100644
index b02c024c2..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { FloatingMenuProps } from "./types";
-export declare function EditorFloatingMenus(props: FloatingMenuProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/index.js b/packages/editor/dist/cjs/toolbar/floatingmenus/index.js
deleted file mode 100644
index 6bdbd3b46..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EditorFloatingMenus = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const responsive_1 = require("../../components/responsive");
-const hoverpopup_1 = require("./hoverpopup");
-const searchreplace_1 = require("./searchreplace");
-function EditorFloatingMenus(props) {
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(searchreplace_1.SearchReplaceFloatingMenu, Object.assign({}, props)), (0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: (0, jsx_runtime_1.jsx)(hoverpopup_1.HoverPopupHandler, Object.assign({}, props)) })] }));
-}
-exports.EditorFloatingMenus = EditorFloatingMenus;
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/searchreplace.d.ts b/packages/editor/dist/cjs/toolbar/floatingmenus/searchreplace.d.ts
deleted file mode 100644
index 66a0fa228..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/searchreplace.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { FloatingMenuProps } from "./types";
-export declare function SearchReplaceFloatingMenu(props: FloatingMenuProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/searchreplace.js b/packages/editor/dist/cjs/toolbar/floatingmenus/searchreplace.js
deleted file mode 100644
index a00bb207a..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/searchreplace.js
+++ /dev/null
@@ -1,19 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SearchReplaceFloatingMenu = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const searchreplace_1 = require("../popups/searchreplace");
-const responsive_1 = require("../../components/responsive");
-const dom_1 = require("../utils/dom");
-function SearchReplaceFloatingMenu(props) {
- const { editor } = props;
- const { isSearching } = editor.storage.searchreplace;
- return ((0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ mobile: "sheet", desktop: "menu", isOpen: isSearching, onClose: () => editor.commands.endSearch(), position: {
- target: (0, dom_1.getToolbarElement)(),
- isTargetAbsolute: true,
- location: "below",
- align: "end",
- yOffset: 5,
- }, blocking: false, focusOnRender: false, draggable: false }, { children: (0, jsx_runtime_1.jsx)(searchreplace_1.SearchReplacePopup, { editor: editor }) })));
-}
-exports.SearchReplaceFloatingMenu = SearchReplaceFloatingMenu;
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/types.d.ts b/packages/editor/dist/cjs/toolbar/floatingmenus/types.d.ts
deleted file mode 100644
index f3ea5ebf6..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/types.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { Editor } from "../../types";
-export declare type FloatingMenuProps = {
- editor: Editor;
-};
diff --git a/packages/editor/dist/cjs/toolbar/floatingmenus/types.js b/packages/editor/dist/cjs/toolbar/floatingmenus/types.js
deleted file mode 100644
index c8ad2e549..000000000
--- a/packages/editor/dist/cjs/toolbar/floatingmenus/types.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/packages/editor/dist/cjs/toolbar/icons.d.ts b/packages/editor/dist/cjs/toolbar/icons.d.ts
deleted file mode 100644
index 9a38e6591..000000000
--- a/packages/editor/dist/cjs/toolbar/icons.d.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-export declare const Icons: {
- bold: string;
- italic: string;
- underline: string;
- strikethrough: string;
- code: string;
- codeRemove: string;
- alignCenter: string;
- alignLeft: string;
- alignRight: string;
- alignJustify: string;
- subscript: string;
- superscript: string;
- horizontalRule: string;
- codeblock: string;
- blockquote: string;
- formatClear: string;
- ltr: string;
- rtl: string;
- numberedList: string;
- bulletList: string;
- highlight: string;
- textColor: string;
- link: string;
- linkRemove: string;
- openLink: string;
- linkEdit: string;
- linkSettings: string;
- url: string;
- image: string;
- imageSettings: string;
- colorClear: string;
- check: string;
- checkbox: string;
- loading: string;
- more: string;
- upload: string;
- camera: string;
- attachment: string;
- table: string;
- rowProperties: string;
- insertRowBelow: string;
- insertRowAbove: string;
- moveRowDown: string;
- moveRowUp: string;
- deleteRow: string;
- toggleHeaderRow: string;
- columnProperties: string;
- insertColumnRight: string;
- insertColumnLeft: string;
- moveColumnRight: string;
- moveColumnLeft: string;
- deleteColumn: string;
- cellProperties: string;
- cellBorderColor: string;
- backgroundColor: string;
- borderColor: string;
- sortDesc: string;
- deleteTable: string;
- mergeCells: string;
- splitCells: string;
- checklist: string;
- dragHandle: string;
- previousMatch: string;
- nextMatch: string;
- replaceOne: string;
- replaceAll: string;
- replace: string;
- attachmentSettings: string;
- caseSensitive: string;
- wholeWord: string;
- regex: string;
- embed: string;
- embedSettings: string;
- palette: string;
- tableSettings: string;
- math: string;
- mathBlock: string;
- outlineList: string;
- fontFamily: string;
- fontSize: string;
- heading: string;
- indent: string;
- outdent: string;
- plus: string;
- minus: string;
- close: string;
- delete: string;
- download: string;
- chevronDown: string;
- chevronUp: string;
- chevronRight: string;
- chevronLeft: string;
- circle: string;
- arrowLeft: string;
- resize: string;
- none: string;
-};
-export declare type IconNames = keyof typeof Icons;
diff --git a/packages/editor/dist/cjs/toolbar/icons.js b/packages/editor/dist/cjs/toolbar/icons.js
deleted file mode 100644
index 2bf9ed100..000000000
--- a/packages/editor/dist/cjs/toolbar/icons.js
+++ /dev/null
@@ -1,102 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Icons = void 0;
-const js_1 = require("@mdi/js");
-exports.Icons = {
- bold: js_1.mdiFormatBold,
- italic: js_1.mdiFormatItalic,
- underline: js_1.mdiFormatUnderline,
- strikethrough: js_1.mdiFormatStrikethrough,
- code: js_1.mdiCodeTags,
- codeRemove: `M3.62109375 1.83837892 2.26318358 3.13037107 6.46289063 7.536621 1.9995117 12l6.0000003 6 1.40039025-1.400391L4.80029295 12l3.0292968-3.0292965 7.0283205 7.371093-.2578125.2578125L16.000488 18l.224121-.224121 4.3125 4.52490225 1.35791025-1.29492225-4.34326125-4.55712825L22.000488 12l-6-6-1.40039025 1.40039063L19.19970675 12l-3.016113 3.016113L9.156738 7.6435545l.24316425-.24316387L7.999512 6l-.2109375.2109375Z`,
- alignCenter: js_1.mdiFormatAlignCenter,
- alignLeft: js_1.mdiFormatAlignLeft,
- alignRight: js_1.mdiFormatAlignRight,
- alignJustify: js_1.mdiFormatAlignJustify,
- subscript: js_1.mdiFormatSubscript,
- superscript: js_1.mdiFormatSuperscript,
- horizontalRule: js_1.mdiBorderHorizontal,
- codeblock: js_1.mdiCodeBraces,
- blockquote: js_1.mdiFormatQuoteClose,
- formatClear: js_1.mdiFormatClear,
- ltr: js_1.mdiFormatTextdirectionLToR,
- rtl: js_1.mdiFormatTextdirectionRToL,
- numberedList: js_1.mdiFormatListNumbered,
- bulletList: js_1.mdiFormatListBulleted,
- highlight: js_1.mdiFormatColorHighlight,
- textColor: js_1.mdiFormatColorText,
- link: js_1.mdiLinkPlus,
- linkRemove: js_1.mdiLinkOff,
- openLink: js_1.mdiOpenInNew,
- linkEdit: "m19 14 1.28 1.28c.22.21.22.56 0 .77l-1 1L17.23 15l1-1c.11-.11.25-.17.39-.17s.27.06.38.17m-.3 3.63-6.06 6.07h-2.06v-2.06l6.07-6.06zM7 7h4v2H7c-1.6568542 0-3 1.343146-3 3s1.3431458 3 3 3h4v2H7c-2.7614237 0-5-2.238576-5-5 0-2.7614237 2.2385763-5 5-5m10 0c2.761424 0 5 2.2385763 5 5h-2c0-1.656854-1.343146-3-3-3h-4V7h4m-9 4h8v2H8v-2",
- linkSettings: "M7 7h4v2H7c-1.6568542 0-3 1.343146-3 3s1.3431458 3 3 3h4v2H7c-2.7614237 0-5-2.238576-5-5 0-2.7614237 2.2385763-5 5-5m10 0c2.761424 0 5 2.2385763 5 5h-2c0-1.656854-1.343146-3-3-3h-4V7h4m-9 4h8v2H8v-2m15.119777 8.323608-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.212462-.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-.107538.03258-.240607-.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.5z",
- url: js_1.mdiLink,
- image: js_1.mdiImage,
- imageSettings: js_1.mdiImageEditOutline,
- colorClear: js_1.mdiInvertColorsOff,
- check: js_1.mdiCheck,
- checkbox: js_1.mdiCheckboxMarkedOutline,
- loading: js_1.mdiLoading,
- more: js_1.mdiDotsVertical,
- upload: js_1.mdiUploadOutline,
- camera: js_1.mdiCameraOutline,
- attachment: js_1.mdiAttachment,
- table: js_1.mdiTable,
- rowProperties: js_1.mdiTableRowHeight,
- insertRowBelow: js_1.mdiTableRowPlusAfter,
- insertRowAbove: js_1.mdiTableRowPlusBefore,
- moveRowDown: js_1.mdiArrowExpandDown,
- moveRowUp: js_1.mdiArrowExpandUp,
- deleteRow: js_1.mdiTableRowRemove,
- toggleHeaderRow: js_1.mdiTableBorder,
- columnProperties: js_1.mdiTableColumnWidth,
- insertColumnRight: js_1.mdiTableColumnPlusAfter,
- insertColumnLeft: js_1.mdiTableColumnPlusBefore,
- moveColumnRight: js_1.mdiArrowExpandRight,
- moveColumnLeft: js_1.mdiArrowExpandLeft,
- deleteColumn: js_1.mdiTableColumnRemove,
- cellProperties: js_1.mdiRectangle,
- cellBorderColor: "M4 24q-.825 0-1.412-.587Q2 22.825 2 22q0-.825.588-1.413Q3.175 20 4 20h16q.825 0 1.413.587Q22 21.175 22 22q0 .825-.587 1.413Q20.825 24 20 24Zm1-6q-.425 0-.713-.288Q4 17.425 4 17v-2.325q0-.2.075-.388q.075-.187.225-.337l8.75-8.75l3.75 3.75l-8.75 8.75q-.15.15-.337.225q-.188.075-.388.075Zm1-2h.9L14 8.95L13.05 8L6 15.1Zm11.925-8.15l-3.75-3.75l1.8-1.8q.275-.3.7-.288q.425.013.7.288l2.35 2.35q.275.275.275.688q0 .412-.275.712ZM6 16Z",
- backgroundColor: js_1.mdiFormatColorFill,
- borderColor: "M4 24q-.825 0-1.412-.587Q2 22.825 2 22q0-.825.588-1.413Q3.175 20 4 20h16q.825 0 1.413.587Q22 21.175 22 22q0 .825-.587 1.413Q20.825 24 20 24Zm1-6q-.425 0-.713-.288Q4 17.425 4 17v-2.325q0-.2.075-.388q.075-.187.225-.337l8.75-8.75l3.75 3.75l-8.75 8.75q-.15.15-.337.225q-.188.075-.388.075Zm1-2h.9L14 8.95L13.05 8L6 15.1Zm11.925-8.15l-3.75-3.75l1.8-1.8q.275-.3.7-.288q.425.013.7.288l2.35 2.35q.275.275.275.688q0 .412-.275.712ZM6 16Z",
- sortDesc: js_1.mdiSortDescending,
- deleteTable: js_1.mdiTableOff,
- mergeCells: js_1.mdiTableMergeCells,
- splitCells: js_1.mdiTableSplitCell,
- checklist: js_1.mdiFormatListCheckbox,
- dragHandle: js_1.mdiDrag,
- previousMatch: js_1.mdiArrowUp,
- nextMatch: js_1.mdiArrowDown,
- 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: js_1.mdiFormatLetterCase,
- wholeWord: js_1.mdiFormatLetterMatches,
- regex: js_1.mdiRegex,
- embed: js_1.mdiMoviePlusOutline,
- embedSettings: js_1.mdiMovieCogOutline,
- palette: js_1.mdiPaletteOutline,
- tableSettings: js_1.mdiTableCog,
- math: js_1.mdiFunctionVariant,
- mathBlock: js_1.mdiMathIntegral,
- outlineList: js_1.mdiFileTreeOutline,
- fontFamily: js_1.mdiFormatFont,
- fontSize: js_1.mdiFormatFontSizeIncrease,
- heading: js_1.mdiFormatHeaderPound,
- indent: js_1.mdiFormatIndentIncrease,
- outdent: js_1.mdiFormatIndentDecrease,
- plus: js_1.mdiPlus,
- minus: js_1.mdiMinus,
- close: js_1.mdiClose,
- delete: js_1.mdiDeleteOutline,
- download: js_1.mdiDownloadOutline,
- chevronDown: js_1.mdiChevronDown,
- chevronUp: js_1.mdiChevronUp,
- chevronRight: js_1.mdiChevronRight,
- chevronLeft: js_1.mdiChevronLeft,
- circle: js_1.mdiCircle,
- arrowLeft: js_1.mdiArrowLeft,
- resize: js_1.mdiResizeBottomRight,
- none: ""
-};
diff --git a/packages/editor/dist/cjs/toolbar/index.d.ts b/packages/editor/dist/cjs/toolbar/index.d.ts
deleted file mode 100644
index 37d1c1dbe..000000000
--- a/packages/editor/dist/cjs/toolbar/index.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Toolbar } from "./toolbar";
-export default Toolbar;
-export * from "./types";
-export * from "./icons";
-export * from "./components/icon";
-export * from "./tools";
-export * from "./tool-definitions";
diff --git a/packages/editor/dist/cjs/toolbar/index.js b/packages/editor/dist/cjs/toolbar/index.js
deleted file mode 100644
index dae96e0b8..000000000
--- a/packages/editor/dist/cjs/toolbar/index.js
+++ /dev/null
@@ -1,23 +0,0 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const toolbar_1 = require("./toolbar");
-exports.default = toolbar_1.Toolbar;
-__exportStar(require("./types"), exports);
-__exportStar(require("./icons"), exports);
-__exportStar(require("./components/icon"), exports);
-__exportStar(require("./tools"), exports);
-__exportStar(require("./tooldefinitions"), exports);
diff --git a/packages/editor/dist/cjs/toolbar/popups/cellproperties.d.ts b/packages/editor/dist/cjs/toolbar/popups/cellproperties.d.ts
deleted file mode 100644
index 7c0de5a61..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/cellproperties.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-declare type CellPropertiesProps = {
- editor: Editor;
- onClose: () => void;
-};
-export declare function CellProperties(props: CellPropertiesProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/popups/cellproperties.js b/packages/editor/dist/cjs/toolbar/popups/cellproperties.js
deleted file mode 100644
index 2d63b6395..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/cellproperties.js
+++ /dev/null
@@ -1,26 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.CellProperties = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const tabs_1 = require("../../components/tabs");
-const icon_1 = require("../components/icon");
-// import { MenuPresenter } from "../../components/menu/menu";
-const popup_1 = require("../components/popup");
-const icons_1 = require("../icons");
-const colorpicker_1 = require("./colorpicker");
-function CellProperties(props) {
- const { editor, onClose } = props;
- const attributes = editor.getAttributes("tableCell");
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: "Cell properties", onClose: onClose }, { children: (0, jsx_runtime_1.jsxs)(tabs_1.Tabs, Object.assign({ activeIndex: 0 }, { children: [(0, jsx_runtime_1.jsxs)(tabs_1.Tab, Object.assign({ title: (0, jsx_runtime_1.jsx)(icon_1.Icon, { title: "Cell background color", path: icons_1.Icons.backgroundColor, size: 16 }) }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Box, { mt: 2 }), (0, jsx_runtime_1.jsx)(colorpicker_1.ColorPicker, { expanded: true, color: attributes.backgroundColor, onChange: (color) => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("backgroundColor", color);
- }, onClear: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("backgroundColor", undefined);
- } })] })), (0, jsx_runtime_1.jsxs)(tabs_1.Tab, Object.assign({ title: (0, jsx_runtime_1.jsx)(icon_1.Icon, { title: "Cell text color", path: icons_1.Icons.textColor, size: 16 }) }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Box, { mt: 2 }), (0, jsx_runtime_1.jsx)(colorpicker_1.ColorPicker, { expanded: true, color: attributes.color, onChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("color", color); }, onClear: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("color", undefined); } })] })), (0, jsx_runtime_1.jsxs)(tabs_1.Tab, Object.assign({ title: (0, jsx_runtime_1.jsx)(icon_1.Icon, { title: "Cell border color", path: icons_1.Icons.cellBorderColor, size: 16 }) }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Box, { mt: 2 }), (0, jsx_runtime_1.jsx)(colorpicker_1.ColorPicker, { expanded: true, color: attributes.borderColor, onChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderColor", color); }, onClear: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderColor", undefined);
- } })] }))] })) })));
-}
-exports.CellProperties = CellProperties;
diff --git a/packages/editor/dist/cjs/toolbar/popups/colorpicker.d.ts b/packages/editor/dist/cjs/toolbar/popups/colorpicker.d.ts
deleted file mode 100644
index e9870067d..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/colorpicker.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/// <reference types="react" />
-export declare const DEFAULT_COLORS: string[];
-declare type ColorPickerProps = {
- colors?: string[];
- color?: string;
- onClear: () => void;
- expanded?: boolean;
- onChange: (color: string) => void;
- onClose?: () => void;
- title?: string;
-};
-export declare function ColorPicker(props: ColorPickerProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/popups/colorpicker.js b/packages/editor/dist/cjs/toolbar/popups/colorpicker.js
deleted file mode 100644
index f0d382f06..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/colorpicker.js
+++ /dev/null
@@ -1,128 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ColorPicker = exports.DEFAULT_COLORS = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const forms_1 = require("@rebass/forms");
-const icon_1 = require("../components/icon");
-const icons_1 = require("../icons");
-const react_1 = require("react");
-const tinycolor2_1 = __importDefault(require("tinycolor2"));
-const react_colorful_1 = require("react-colorful");
-const button_1 = require("../../components/button");
-const debounce_1 = require("../../utils/debounce");
-exports.DEFAULT_COLORS = [
- "#e91e63",
- "#9c27b0",
- "#673ab7",
- "#3f51b5",
- "#2196f3",
- "#03a9f4",
- "#00bcd4",
- "#009688",
- "#4caf50",
- "#8bc34a",
- "#cddc39",
- "#ffeb3b",
- "#ffc107",
- "#f44336",
-];
-const PALETTE_SIZE = [35, 35, 25];
-function ColorPicker(props) {
- const { colors = exports.DEFAULT_COLORS, color, onClear, onChange, title, onClose, expanded, } = props;
- const ref = (0, react_1.useRef)();
- const [isPickerOpen, setIsPickerOpen] = (0, react_1.useState)(expanded || false);
- const [currentColor, setCurrentColor] = (0, react_1.useState)((0, tinycolor2_1.default)(color || colors[0]).toHexString());
- const tColor = (0, tinycolor2_1.default)(currentColor);
- (0, react_1.useEffect)(() => {
- if (!ref.current)
- return;
- if (isPickerOpen)
- ref.current.focus({ preventScroll: true });
- }, [isPickerOpen]);
- const onColorChange = (0, react_1.useCallback)((0, debounce_1.debounce)((color) => {
- onChange(color);
- }, 500), [onChange]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ ref: ref, tabIndex: -1, sx: {
- bg: "background",
- flexDirection: "column",
- ".react-colorful": {
- width: "auto",
- height: 150,
- },
- ".react-colorful__saturation": {
- borderRadius: ["default", 0],
- },
- width: ["calc(100vw - 20px)", 250],
- // width: ["auto", 250],
- } }, { children: [onClose && ((0, jsx_runtime_1.jsxs)(rebass_1.Box, Object.assign({ sx: {
- display: ["none", "flex"],
- justifyContent: "space-between",
- p: 2,
- pb: isPickerOpen ? 2 : 0,
- //pb: 0,
- alignItems: "center",
- }, onClick: onClose }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "title" }, { children: title })), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ variant: "icon", sx: { p: 0 } }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.close, size: "big" }) }))] }))), isPickerOpen ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_colorful_1.HexColorPicker, { onChange: (color) => {
- setCurrentColor(color);
- onColorChange(color);
- }, onTouchEnd: () => onChange(currentColor), onMouseUp: () => onChange(currentColor) }), (0, jsx_runtime_1.jsx)(forms_1.Input, { variant: "clean", placeholder: "#000000", spellCheck: false, sx: {
- my: 2,
- p: 0,
- borderRadius: 0,
- fontSize: ["title", "title", "body"],
- color: "fontTertiary",
- textAlign: "center",
- letterSpacing: 1.5,
- }, value: currentColor.toUpperCase(), maxLength: 7, onChange: (e) => {
- const { value } = e.target;
- if (!value)
- return;
- if ((0, tinycolor2_1.default)(value, { format: "hex" }).isValid()) {
- setCurrentColor(value);
- onChange(value);
- }
- } })] })) : null, (0, jsx_runtime_1.jsxs)(rebass_1.Flex, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ className: "hide-scrollbar", sx: {
- flex: 1,
- p: 1,
- overflowX: ["auto", "hidden"],
- flexWrap: ["nowrap", "wrap"],
- } }, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ variant: "icon", sx: {
- flexShrink: 0,
- width: PALETTE_SIZE,
- height: PALETTE_SIZE,
- borderRadius: 50,
- boxShadow: "menu",
- p: 0,
- ml: [2, 2, 1],
- }, onClick: onClear }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.colorClear, color: "text", size: 15 }) })), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ variant: "secondary", sx: {
- flexShrink: 0,
- bg: currentColor,
- width: PALETTE_SIZE,
- height: PALETTE_SIZE,
- borderRadius: 50,
- // boxShadow: "menu",
- p: 0,
- ml: [2, 2, 1],
- ":hover": {
- bg: currentColor,
- },
- }, onClick: () => setIsPickerOpen((s) => !s) }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.palette, color: tColor.isDark() ? "static" : "icon", size: 18 }) })), colors.map((color) => ((0, jsx_runtime_1.jsx)(button_1.Button, { sx: {
- flex: "0 0 auto",
- bg: color,
- width: PALETTE_SIZE,
- height: PALETTE_SIZE,
- ml: [2, 1, 1],
- mb: [0, 1, 1],
- borderRadius: 50,
- ":hover": {
- bg: color,
- },
- }, onClick: () => {
- setCurrentColor(color);
- onChange(color);
- } }, color)))] })), onClose && ((0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ variant: "icon", sx: { display: ["block", "none"], px: 2 }, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.close, size: "big" }) })))] })] })));
-}
-exports.ColorPicker = ColorPicker;
diff --git a/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts b/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts
deleted file mode 100644
index 2b87a72e6..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/// <reference types="react" />
-import { Embed, EmbedSizeOptions } from "../../extensions/embed";
-export declare type EmbedPopupProps = {
- onClose: (embed?: Embed) => void;
- title: string;
- embed?: Embed;
- onSizeChanged?: (size: EmbedSizeOptions) => void;
-};
-export declare function EmbedPopup(props: EmbedPopupProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/popups/embedpopup.js b/packages/editor/dist/cjs/toolbar/popups/embedpopup.js
deleted file mode 100644
index db9298c23..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/embedpopup.js
+++ /dev/null
@@ -1,87 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EmbedPopup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const popup_1 = require("../components/popup");
-const forms_1 = require("@rebass/forms");
-const lib_1 = require("@social-embed/lib");
-const inlineinput_1 = require("../../components/inlineinput");
-const tabs_1 = require("../../components/tabs");
-function EmbedPopup(props) {
- const { onClose, onSizeChanged, title, embed } = props;
- const [width, setWidth] = (0, react_1.useState)((embed === null || embed === void 0 ? void 0 : embed.width) || 300);
- const [height, setHeight] = (0, react_1.useState)((embed === null || embed === void 0 ? void 0 : embed.height) || 150);
- const [src, setSrc] = (0, react_1.useState)((embed === null || embed === void 0 ? void 0 : embed.src) || "");
- const [embedSource, setEmbedSource] = (0, react_1.useState)("url");
- const [error, setError] = (0, react_1.useState)(null);
- const onSizeChange = (0, react_1.useCallback)((newWidth, newHeight) => {
- const size = newWidth
- ? {
- width: newWidth,
- height: newWidth * (height / width),
- }
- : newHeight
- ? {
- width: newHeight * (width / height),
- height: newHeight,
- }
- : {
- width: 0,
- height: 0,
- };
- setWidth(size.width);
- setHeight(size.height);
- if (onSizeChanged)
- onSizeChanged(size);
- }, [width, height]);
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: title, onClose: () => onClose(), action: {
- title: "Save",
- onClick: () => {
- setError(null);
- let _src = src;
- let _width = width;
- let _height = height;
- if (embedSource === "code") {
- const document = new DOMParser().parseFromString(src, "text/html");
- if (document.getElementsByTagName("iframe").length <= 0)
- return setError("Embed code must include an iframe.");
- const srcValue = getAttribute(document, "src");
- if (!srcValue)
- return setError("Embed code must include an iframe with an src attribute.");
- _src = srcValue;
- const widthValue = getAttribute(document, "width");
- if (widthValue && !isNaN(parseInt(widthValue)))
- _width = parseInt(widthValue);
- const heightValue = getAttribute(document, "height");
- if (heightValue && !isNaN(parseInt(heightValue)))
- _height = parseInt(heightValue);
- }
- const convertedUrl = (0, lib_1.convertUrlToEmbedUrl)(_src);
- if (!!convertedUrl)
- _src = convertedUrl;
- onClose({
- height: _height,
- width: _width,
- src: _src,
- });
- },
- } }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { flexDirection: "column", width: ["auto", 300] } }, { children: [error && ((0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "error", sx: {
- bg: "errorBg",
- color: "error",
- p: 1,
- borderRadius: "default",
- } }, { children: ["Error: ", error] }))), (0, jsx_runtime_1.jsxs)(tabs_1.Tabs, Object.assign({ activeIndex: 0, containerProps: { sx: { mx: 1, flexDirection: "column" } }, onTabChanged: (index) => setEmbedSource(index === 0 ? "url" : "code") }, { children: [(0, jsx_runtime_1.jsxs)(tabs_1.Tab, Object.assign({ title: "From URL" }, { children: [(0, jsx_runtime_1.jsx)(forms_1.Input, { placeholder: "Enter embed source URL", value: src, autoFocus: true, onChange: (e) => setSrc(e.target.value), autoCapitalize: "none", sx: { fontSize: "body" } }), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center", mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { containerProps: { sx: { mr: 1 } }, label: "width", type: "number", placeholder: "Width", value: width, sx: {
- mr: 1,
- fontSize: "body",
- }, onChange: (e) => onSizeChange(e.target.valueAsNumber) }), (0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "height", type: "number", placeholder: "Height", value: height, sx: { fontSize: "body" }, onChange: (e) => onSizeChange(undefined, e.target.valueAsNumber) })] }))] })), (0, jsx_runtime_1.jsx)(tabs_1.Tab, Object.assign({ title: "From code" }, { children: (0, jsx_runtime_1.jsx)(forms_1.Textarea, { autoFocus: true, variant: "forms.input", sx: { fontSize: "subBody", fontFamily: "monospace" }, minHeight: [200, 100], onChange: (e) => setSrc(e.target.value), placeholder: "Paste embed code here. Only iframes are supported." }) }))] }))] })) })));
-}
-exports.EmbedPopup = EmbedPopup;
-function getAttribute(document, id) {
- const element = document.querySelector(`[${id}]`);
- if (!element)
- return null;
- const attribute = element.getAttribute(id);
- return attribute;
-}
diff --git a/packages/editor/dist/cjs/toolbar/popups/imageproperties.d.ts b/packages/editor/dist/cjs/toolbar/popups/imageproperties.d.ts
deleted file mode 100644
index 19bf028a6..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/imageproperties.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/// <reference types="react" />
-import { ImageAlignmentOptions, ImageSizeOptions } from "../../extensions/image";
-import { Editor } from "../../types";
-export declare type ImagePropertiesProps = ImageSizeOptions & ImageAlignmentOptions & {
- editor: Editor;
- onClose: () => void;
-};
-export declare function ImageProperties(props: ImagePropertiesProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/popups/imageproperties.js b/packages/editor/dist/cjs/toolbar/popups/imageproperties.js
deleted file mode 100644
index 53f6fa79a..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/imageproperties.js
+++ /dev/null
@@ -1,37 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ImageProperties = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const popup_1 = require("../components/popup");
-const forms_1 = require("@rebass/forms");
-const inlineinput_1 = require("../../components/inlineinput");
-const responsive_1 = require("../../components/responsive");
-function ImageProperties(props) {
- const { height, width, float, editor, onClose } = props;
- const onSizeChange = (0, react_1.useCallback)((newWidth, newHeight) => {
- const size = newWidth
- ? {
- width: newWidth,
- height: newWidth * (height / width),
- }
- : newHeight
- ? {
- width: newHeight * (width / height),
- height: newHeight,
- }
- : {
- width: 0,
- height: 0,
- };
- editor.chain().setImageSize(size).run();
- }, [width, height]);
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: "Image properties", onClose: onClose }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [(0, jsx_runtime_1.jsx)(responsive_1.DesktopOnly, { children: (0, jsx_runtime_1.jsxs)(forms_1.Label, Object.assign({ variant: "text.body", sx: { justifyContent: "space-between", alignItems: "center" } }, { children: ["Float image", (0, jsx_runtime_1.jsx)(forms_1.Checkbox, { checked: float, onClick: () => editor
- .chain()
- .setImageAlignment({ float: !float, align: "left" })
- .run() })] })) }), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center", mt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "width", type: "number", value: width, containerProps: {
- sx: { mr: 1 },
- }, onChange: (e) => onSizeChange(e.target.valueAsNumber) }), (0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "height", type: "number", value: height, onChange: (e) => onSizeChange(undefined, e.target.valueAsNumber) })] }))] })) })));
-}
-exports.ImageProperties = ImageProperties;
diff --git a/packages/editor/dist/cjs/toolbar/popups/imageupload.d.ts b/packages/editor/dist/cjs/toolbar/popups/imageupload.d.ts
deleted file mode 100644
index 306f74f64..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/imageupload.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { ImageAttributes } from "../../extensions/image";
-export declare type ImageUploadPopupProps = {
- onInsert: (image: ImageAttributes) => void;
- onClose: () => void;
-};
-export declare function ImageUploadPopup(props: ImageUploadPopupProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/popups/imageupload.js b/packages/editor/dist/cjs/toolbar/popups/imageupload.js
deleted file mode 100644
index 2afbccfa4..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/imageupload.js
+++ /dev/null
@@ -1,78 +0,0 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ImageUploadPopup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const forms_1 = require("@rebass/forms");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const popup_1 = require("../components/popup");
-function ImageUploadPopup(props) {
- const { onInsert, onClose } = props;
- const [isDownloading, setIsDownloading] = (0, react_1.useState)(false);
- const [error, setError] = (0, react_1.useState)();
- const [url, setUrl] = (0, react_1.useState)("");
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: "Insert image from URL", onClose: onClose, action: {
- loading: isDownloading,
- title: "Insert image",
- disabled: !url,
- onClick: () => __awaiter(this, void 0, void 0, function* () {
- setIsDownloading(true);
- setError(undefined);
- try {
- const response = yield fetch(url);
- if (!response.ok)
- return setError(`invalid status code ${response.status}`);
- const contentType = response.headers.get("Content-Type");
- const contentLength = response.headers.get("Content-Length");
- if (!contentType ||
- !contentLength ||
- contentLength === "0" ||
- !contentType.startsWith("image/"))
- return setError("not an image");
- const size = parseInt(contentLength);
- const dataurl = yield toDataURL(yield response.blob());
- onInsert({ src: dataurl, type: contentType, size });
- }
- catch (e) {
- if (e instanceof Error)
- setError(e.message);
- }
- finally {
- setIsDownloading(false);
- }
- }),
- } }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { px: 1, flexDirection: "column", width: ["auto", 350] } }, { children: [(0, jsx_runtime_1.jsx)(forms_1.Input, { type: "url", autoFocus: true, placeholder: "Paste Image URL here", value: url, onChange: (e) => {
- setUrl(e.target.value);
- setError(undefined);
- } }), error ? ((0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "error", sx: {
- bg: "errorBg",
- mt: 1,
- p: 1,
- borderRadius: "default",
- } }, { children: ["Failed to download image: ", error.toLowerCase(), "."] }))) : ((0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "subBody", sx: {
- bg: "shade",
- color: "primary",
- mt: 1,
- p: 1,
- borderRadius: "default",
- } }, { children: "To protect your privacy, we will download the image & add it to your attachments." })))] })) })));
-}
-exports.ImageUploadPopup = ImageUploadPopup;
-function toDataURL(blob) {
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.onload = (_e) => resolve(reader.result);
- reader.onerror = (_e) => reject(reader.error);
- reader.onabort = (_e) => reject(new Error("Read aborted"));
- reader.readAsDataURL(blob);
- });
-}
diff --git a/packages/editor/dist/cjs/toolbar/popups/linkpopup.d.ts b/packages/editor/dist/cjs/toolbar/popups/linkpopup.d.ts
deleted file mode 100644
index 1d6894848..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/linkpopup.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-export declare type LinkPopupProps = {
- text?: string;
- href?: string;
- isEditing?: boolean;
- onDone: (link: {
- text: string;
- href: string;
- }) => void;
- onClose: () => void;
-};
-export declare function LinkPopup(props: LinkPopupProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/popups/linkpopup.js b/packages/editor/dist/cjs/toolbar/popups/linkpopup.js
deleted file mode 100644
index db4506749..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/linkpopup.js
+++ /dev/null
@@ -1,18 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.LinkPopup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const forms_1 = require("@rebass/forms");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const popup_1 = require("../components/popup");
-function LinkPopup(props) {
- const { text: _text, href: _href, isEditing = false, onDone, onClose, } = props;
- const [href, setHref] = (0, react_1.useState)(_href || "");
- const [text, setText] = (0, react_1.useState)(_text || "");
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: isEditing ? "Edit link" : "Insert link", onClose: onClose, action: {
- title: isEditing ? "Save edits" : "Insert link",
- onClick: () => onDone({ text, href }),
- } }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { p: 1, flexDirection: "column", width: ["auto", 250] } }, { children: [(0, jsx_runtime_1.jsx)(forms_1.Input, { type: "text", placeholder: "Link text", value: text, onChange: (e) => setText(e.target.value) }), (0, jsx_runtime_1.jsx)(forms_1.Input, { type: "url", sx: { mt: 1 }, autoFocus: true, placeholder: "https://example.com/", value: href, onChange: (e) => setHref(e.target.value) })] })) })));
-}
-exports.LinkPopup = LinkPopup;
diff --git a/packages/editor/dist/cjs/toolbar/popups/searchreplace.d.ts b/packages/editor/dist/cjs/toolbar/popups/searchreplace.d.ts
deleted file mode 100644
index 3fa70fe5f..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/searchreplace.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-export declare type SearchReplacePopupProps = {
- editor: Editor;
-};
-export declare function SearchReplacePopup(props: SearchReplacePopupProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/popups/searchreplace.js b/packages/editor/dist/cjs/toolbar/popups/searchreplace.js
deleted file mode 100644
index 8fcea7c56..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/searchreplace.js
+++ /dev/null
@@ -1,86 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SearchReplacePopup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const forms_1 = require("@rebass/forms");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const toolbutton_1 = require("../components/toolbutton");
-function SearchReplacePopup(props) {
- const { editor } = props;
- const { selectedText, results } = editor.storage
- .searchreplace;
- const [isReplacing, setIsReplacing] = (0, react_1.useState)(false);
- const [isExpanded, setIsExpanded] = (0, react_1.useState)(false);
- const [matchCase, setMatchCase] = (0, react_1.useState)(false);
- const [matchWholeWord, setMatchWholeWord] = (0, react_1.useState)(false);
- const [enableRegex, setEnableRegex] = (0, react_1.useState)(false);
- const replaceText = (0, react_1.useRef)("");
- const searchInputRef = (0, react_1.useRef)();
- const search = (0, react_1.useCallback)((term) => {
- editor.commands.search(term, {
- matchCase,
- enableRegex,
- matchWholeWord,
- });
- }, [matchCase, enableRegex, matchWholeWord]);
- (0, react_1.useEffect)(() => {
- if (!searchInputRef.current)
- return;
- search(searchInputRef.current.value);
- }, [search, matchCase, matchWholeWord, enableRegex]);
- (0, react_1.useEffect)(() => {
- if (selectedText) {
- if (searchInputRef.current) {
- const input = searchInputRef.current;
- setTimeout(() => {
- input.value = selectedText;
- input.focus();
- }, 0);
- }
- search(selectedText);
- }
- }, [selectedText, search]);
- return ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- p: 1,
- bg: "background",
- flexDirection: "column",
- boxShadow: ["none", "menu"],
- borderRadius: [0, "default"],
- } }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { flexDirection: "column", flex: 1, width: ["auto", 300], mr: 1 } }, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- flex: 1,
- position: "relative",
- alignItems: "center",
- outline: "1px solid var(--border)",
- borderRadius: "default",
- p: 1,
- py: 0,
- ":focus-within": {
- outlineColor: "primary",
- outlineWidth: "1.8px",
- },
- ":hover": {
- outlineColor: "primary",
- },
- } }, { children: [(0, jsx_runtime_1.jsx)(forms_1.Input, { variant: "clean", defaultValue: selectedText, ref: searchInputRef, autoFocus: true, placeholder: "Find", sx: { p: 0 }, onChange: (e) => {
- search(e.target.value);
- } }), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- flexShrink: 0,
- mr: 0,
- alignItems: "center",
- } }, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { sx: {
- mr: 0,
- }, toggled: isExpanded, title: "Expand", id: "expand", icon: isExpanded ? "chevronRight" : "chevronLeft", onClick: () => setIsExpanded((s) => !s), iconSize: "medium" }), isExpanded && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { sx: {
- mr: 0,
- }, toggled: matchCase, title: "Match case", id: "matchCase", icon: "caseSensitive", onClick: () => setMatchCase((s) => !s), iconSize: "medium" }), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { sx: {
- mr: 0,
- }, toggled: matchWholeWord, title: "Match whole word", id: "matchWholeWord", icon: "wholeWord", onClick: () => setMatchWholeWord((s) => !s), iconSize: "medium" }), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { sx: {
- mr: 0,
- }, toggled: enableRegex, title: "Enable regex", id: "enableRegex", icon: "regex", onClick: () => setEnableRegex((s) => !s), iconSize: "medium" })] })), (0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "subBody", sx: {
- flexShrink: 0,
- borderLeft: "1px solid var(--border)",
- color: "fontTertiary",
- px: 1,
- } }, { children: [results ? `${results.length}` : "0", isExpanded ? "" : " results"] }))] }))] })), isReplacing && ((0, jsx_runtime_1.jsx)(forms_1.Input, { sx: { mt: 1, p: "7px" }, placeholder: "Replace", onChange: (e) => (replaceText.current = e.target.value) }))] })), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { flexDirection: "column" } }, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center", height: "33.2px" } }, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: isReplacing, title: "Toggle replace", id: "toggleReplace", icon: "replace", onClick: () => setIsReplacing((s) => !s), sx: { mr: 0 }, iconSize: "big" }), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: "Previous match", id: "previousMatch", icon: "previousMatch", onClick: () => editor.commands.moveToPreviousResult(), sx: { mr: 0 }, iconSize: "big" }), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: "Next match", id: "nextMatch", icon: "nextMatch", onClick: () => editor.commands.moveToNextResult(), sx: { mr: 0 }, iconSize: "big" }), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: "Close", id: "close", icon: "close", onClick: () => editor.chain().focus().endSearch().run(), sx: { mr: 0 }, iconSize: "big" })] })), isReplacing && ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center", height: "33.2px", mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: "Replace", id: "replace", icon: "replaceOne", onClick: () => editor.commands.replace(replaceText.current), sx: { mr: 0 }, iconSize: 18 }), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, { toggled: false, title: "Replace all", id: "replaceAll", icon: "replaceAll", onClick: () => editor.commands.replaceAll(replaceText.current), sx: { mr: 0 }, iconSize: 18 })] })))] }))] }) })));
-}
-exports.SearchReplacePopup = SearchReplacePopup;
diff --git a/packages/editor/dist/cjs/toolbar/popups/tablepopup.d.ts b/packages/editor/dist/cjs/toolbar/popups/tablepopup.d.ts
deleted file mode 100644
index 0e35ac702..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/tablepopup.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/// <reference types="react" />
-declare type TableSize = {
- columns: number;
- rows: number;
-};
-export declare type TablePopupProps = {
- onInsertTable: (size: TableSize) => void;
-};
-export declare function TablePopup(props: TablePopupProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/popups/tablepopup.js b/packages/editor/dist/cjs/toolbar/popups/tablepopup.js
deleted file mode 100644
index 65d8584ff..000000000
--- a/packages/editor/dist/cjs/toolbar/popups/tablepopup.js
+++ /dev/null
@@ -1,113 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TablePopup = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const popup_1 = require("../components/popup");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const inlineinput_1 = require("../../components/inlineinput");
-const MAX_COLUMNS = 20;
-const MAX_ROWS = 20;
-const MIN_COLUMNS = 10;
-const MIN_ROWS = 6;
-function TablePopup(props) {
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const autoExpand = !isMobile;
- const cellSize = isMobile ? 30 : 15;
- const { onInsertTable } = props;
- const [cellLocation, setCellLocation] = (0, react_1.useState)({
- column: 0,
- row: 0
- });
- const [tableSize, setTableSize] = (0, react_1.useState)({
- columns: MIN_COLUMNS,
- rows: MIN_ROWS
- });
- (0, react_1.useEffect)(() => {
- if (!autoExpand)
- return;
- setTableSize((old) => {
- const { columns, rows } = old;
- const { column, row } = cellLocation;
- let isDecrease = row === rows - 2 || column === columns - 2;
- let rowFactor = Number(row === rows || row === rows - 2);
- let columnFactor = Number(column === columns || column === columns - 2);
- return {
- columns: isDecrease
- ? Math.max(column + columnFactor, MIN_COLUMNS)
- : Math.min(old.columns + columnFactor, MAX_COLUMNS),
- rows: isDecrease
- ? Math.max(row + rowFactor, MIN_ROWS)
- : Math.min(old.rows + rowFactor, MAX_ROWS)
- };
- });
- }, [cellLocation, autoExpand]);
- return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ 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
- })
- } }, { children: (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { px: 1, pt: 1, flexDirection: "column", alignItems: "center" } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {
- display: "grid",
- gridTemplateColumns: `repeat(${tableSize.columns}, minmax(${cellSize}px, 1fr))`,
- gap: "small",
- bg: "background",
- width: "100%"
- }, onTouchMove: (e) => {
- const touch = e.touches.item(0);
- const element = document.elementFromPoint(touch.pageX, touch.pageY);
- if (!element)
- return;
- const index = element.dataset.index;
- if (!index)
- return;
- setCellLocation(getCellLocation(parseInt(index), tableSize));
- } }, { children: Array(tableSize.columns * tableSize.rows)
- .fill(0)
- .map((_, index) => ((0, jsx_runtime_1.jsx)(rebass_1.Box, { "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));
- }, onTouchEnd: (e) => {
- e.preventDefault();
- }, onClick: () => {
- onInsertTable({
- columns: cellLocation.column,
- rows: cellLocation.row
- });
- } }, index))) })), (0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
- display: ["flex", "none", "none"],
- mt: 1,
- alignItems: "center",
- justifyContent: "center"
- } }, { children: [(0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { containerProps: { sx: { mr: 1 } }, label: "columns", placeholder: `${cellLocation.column} columns`, type: "number", value: cellLocation.column, onChange: (e) => {
- setCellLocation((l) => (Object.assign(Object.assign({}, l), { column: e.target.valueAsNumber || 0 })));
- } }), (0, jsx_runtime_1.jsx)(inlineinput_1.InlineInput, { label: "rows", placeholder: `${cellLocation.row} rows`, type: "number", value: cellLocation.row, onChange: (e) => {
- setCellLocation((l) => (Object.assign(Object.assign({}, l), { row: e.target.valueAsNumber || 0 })));
- } })] })), (0, jsx_runtime_1.jsxs)(rebass_1.Text, Object.assign({ variant: "body", sx: { mt: 1, display: ["none", "block", "block"] } }, { children: [cellLocation.column, " x ", cellLocation.row] }))] })) })));
-}
-exports.TablePopup = TablePopup;
-function getCellLocation(index, tableSize) {
- const cellIndex = index + 1;
- const column = cellIndex % tableSize.columns;
- let row = cellIndex / tableSize.columns;
- const flooredRow = Math.floor(row);
- row = row === flooredRow ? row : flooredRow + 1;
- return { column: column ? column : tableSize.columns, row };
-}
-function isCellHighlighted(index, currentCellLocation, tableSize) {
- const cellLocation = getCellLocation(index, tableSize);
- return (cellLocation.row <= currentCellLocation.row &&
- cellLocation.column <= currentCellLocation.column);
-}
diff --git a/packages/editor/dist/cjs/toolbar/stores/toolbarstore.d.ts b/packages/editor/dist/cjs/toolbar/stores/toolbarstore.d.ts
deleted file mode 100644
index 4b0f4bcc1..000000000
--- a/packages/editor/dist/cjs/toolbar/stores/toolbarstore.d.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Theme } from "@streetwriters/theme";
-export declare type ToolbarLocation = "top" | "bottom";
-export declare type PopupRef = {
- id: string;
- group: string;
-};
-interface ToolbarState {
- theme?: Theme;
- setTheme: (theme?: Theme) => void;
- isMobile: boolean;
- openedPopups: Record<string, PopupRef | false>;
- setIsMobile: (isMobile: boolean) => void;
- toolbarLocation: ToolbarLocation;
- setToolbarLocation: (location: ToolbarLocation) => void;
- isPopupOpen: (popupId: string) => boolean;
- openPopup: (ref: PopupRef) => void;
- closePopup: (popupId: string) => void;
- closePopupGroup: (groupId: string, excluded: string[]) => void;
-}
-export declare const useToolbarStore: import("zustand").UseBoundStore<ToolbarState, import("zustand").StoreApi<ToolbarState>>;
-export declare function useToolbarLocation(): ToolbarLocation;
-export declare function useIsMobile(): boolean;
-export declare const useTheme: (() => Theme | undefined) & {
- theme: Theme | undefined;
-};
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/stores/toolbarstore.js b/packages/editor/dist/cjs/toolbar/stores/toolbarstore.js
deleted file mode 100644
index 5dd7f7089..000000000
--- a/packages/editor/dist/cjs/toolbar/stores/toolbarstore.js
+++ /dev/null
@@ -1,50 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.useTheme = exports.useIsMobile = exports.useToolbarLocation = exports.useToolbarStore = void 0;
-const zustand_1 = __importDefault(require("zustand"));
-exports.useToolbarStore = (0, zustand_1.default)((set, get) => ({
- theme: undefined,
- isMobile: false,
- openedPopups: {},
- setIsMobile: (isMobile) => set((state) => {
- state.isMobile = isMobile;
- }),
- setTheme: (theme) => set((state) => {
- state.theme = theme;
- }),
- toolbarLocation: "top",
- setToolbarLocation: (location) => set((state) => {
- state.toolbarLocation = location;
- }),
- closePopup: (id) => set((state) => {
- state.openedPopups = Object.assign(Object.assign({}, state.openedPopups), { [id]: false });
- }),
- isPopupOpen: (id) => !!get().openedPopups[id],
- openPopup: (ref) => set((state) => {
- state.openedPopups = Object.assign(Object.assign({}, state.openedPopups), { [ref.id]: ref });
- }),
- closePopupGroup: (group, excluded) => set((state) => {
- for (const key in state.openedPopups) {
- const ref = state.openedPopups[key];
- if (ref && ref.group === group && !excluded.includes(ref.id)) {
- state.openedPopups[key] = false;
- }
- }
- }),
-}));
-function useToolbarLocation() {
- return (0, exports.useToolbarStore)((store) => store.toolbarLocation);
-}
-exports.useToolbarLocation = useToolbarLocation;
-function useIsMobile() {
- return (0, exports.useToolbarStore)((store) => store.isMobile);
-}
-exports.useIsMobile = useIsMobile;
-exports.useTheme = Object.defineProperty(() => {
- return (0, exports.useToolbarStore)((store) => store.theme);
-}, "theme", {
- get: () => exports.useToolbarStore.getState().theme,
-});
diff --git a/packages/editor/dist/cjs/toolbar/toolbar.d.ts b/packages/editor/dist/cjs/toolbar/toolbar.d.ts
deleted file mode 100644
index e7fd5f446..000000000
--- a/packages/editor/dist/cjs/toolbar/toolbar.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/// <reference types="react" />
-import { Theme } from "@streetwriters/theme";
-import { Editor } from "../types";
-import { FlexProps } from "rebass";
-import { ToolbarLocation } from "./stores/toolbar-store";
-import { ToolbarDefinition } from "./types";
-declare type ToolbarProps = FlexProps & {
- theme: Theme;
- editor: Editor | null;
- location: ToolbarLocation;
- tools?: ToolbarDefinition;
-};
-export declare function Toolbar(props: ToolbarProps): JSX.Element | null;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/toolbar.js b/packages/editor/dist/cjs/toolbar/toolbar.js
deleted file mode 100644
index 1025a0d19..000000000
--- a/packages/editor/dist/cjs/toolbar/toolbar.js
+++ /dev/null
@@ -1,44 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Toolbar = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const emotion_theming_1 = require("emotion-theming");
-const floatingmenus_1 = require("./floatingmenus");
-const tooldefinitions_1 = require("./tooldefinitions");
-const react_1 = require("react");
-const toolbarstore_1 = require("./stores/toolbarstore");
-const toolbargroup_1 = require("./components/toolbargroup");
-const popuprenderer_1 = require("../components/popup-presenter/popuprenderer");
-function Toolbar(props) {
- const { editor, theme, location, tools = (0, tooldefinitions_1.getDefaultPresets)().default, sx } = props, flexProps = __rest(props, ["editor", "theme", "location", "tools", "sx"]);
- const toolbarTools = (0, react_1.useMemo)(() => [...tooldefinitions_1.STATIC_TOOLBAR_GROUPS, ...tools], [tools]);
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const setToolbarLocation = (0, toolbarstore_1.useToolbarStore)((store) => store.setToolbarLocation);
- (0, react_1.useEffect)(() => {
- setToolbarLocation(location);
- }, [location]);
- if (!editor)
- return null;
- return ((0, jsx_runtime_1.jsx)(emotion_theming_1.ThemeProvider, Object.assign({ theme: theme }, { children: (0, jsx_runtime_1.jsx)(popuprenderer_1.EditorContext.Provider, Object.assign({ value: editor }, { children: (0, jsx_runtime_1.jsxs)(popuprenderer_1.PopupRenderer, Object.assign({ editor: editor }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ className: "editor-toolbar", sx: Object.assign(Object.assign({}, sx), { flexWrap: isMobile ? "nowrap" : "wrap", overflowX: isMobile ? "auto" : "hidden" }) }, flexProps, { children: toolbarTools.map((tools) => {
- return ((0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { tools: tools, editor: editor, sx: {
- flexShrink: 0,
- pr: 2,
- mr: 2,
- borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
- } }, tools.join("")));
- }) })), (0, jsx_runtime_1.jsx)(floatingmenus_1.EditorFloatingMenus, { editor: editor })] })) })) })));
-}
-exports.Toolbar = Toolbar;
diff --git a/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts b/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts
deleted file mode 100644
index aa2eba3f0..000000000
--- a/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { ToolbarDefinition, ToolDefinition } from "./types";
-import { ToolId } from "./tools";
-export declare function getToolDefinition(id: ToolId): ToolDefinition;
-export declare function getAllTools(): Record<"fontSize" | "underline" | "bold" | "bulletList" | "code" | "italic" | "subscript" | "superscript" | "textDirection" | "fontFamily" | "highlight" | "removeAttachment" | "downloadAttachment" | "deleteColumn" | "deleteRow" | "deleteTable" | "mergeCells" | "strikethrough" | "codeRemove" | "numberedList" | "textColor" | "openLink" | "linkSettings" | "imageSettings" | "rowProperties" | "insertRowBelow" | "insertRowAbove" | "moveRowDown" | "moveRowUp" | "columnProperties" | "insertColumnRight" | "insertColumnLeft" | "moveColumnRight" | "moveColumnLeft" | "cellProperties" | "cellBorderColor" | "splitCells" | "attachmentSettings" | "embedSettings" | "tableSettings" | "math" | "indent" | "outdent" | "clearformatting" | "addLink" | "editLink" | "removeLink" | "insertBlock" | "headings" | "alignment" | "imageAlignCenter" | "imageAlignLeft" | "imageAlignRight" | "imageProperties" | "embedAlignCenter" | "embedAlignLeft" | "embedAlignRight" | "embedProperties" | "cellBackgroundColor" | "cellTextColor" | "cellBorderWidth", ToolDefinition>;
-export declare function getDefaultPresets(): Record<"default" | "minimal", ToolbarDefinition>;
-export declare const STATIC_TOOLBAR_GROUPS: ToolbarDefinition;
diff --git a/packages/editor/dist/cjs/toolbar/tooldefinitions.js b/packages/editor/dist/cjs/toolbar/tooldefinitions.js
deleted file mode 100644
index 9ff539e7f..000000000
--- a/packages/editor/dist/cjs/toolbar/tooldefinitions.js
+++ /dev/null
@@ -1,343 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.STATIC_TOOLBAR_GROUPS = exports.getDefaultPresets = exports.getAllTools = exports.getToolDefinition = void 0;
-const tools = {
- bold: {
- icon: "bold",
- title: "Bold",
- },
- italic: {
- icon: "italic",
- title: "Italic",
- },
- underline: {
- icon: "underline",
- title: "Underline",
- },
- strikethrough: {
- icon: "strikethrough",
- title: "Strikethrough",
- },
- addLink: {
- icon: "link",
- title: "Link",
- },
- editLink: {
- icon: "linkEdit",
- title: "Edit link",
- conditional: true,
- },
- removeLink: {
- icon: "linkRemove",
- title: "Remove link",
- conditional: true,
- },
- openLink: {
- icon: "openLink",
- title: "Open link",
- conditional: true,
- },
- linkSettings: {
- icon: "linkSettings",
- title: "Link settings",
- conditional: true,
- },
- code: {
- icon: "code",
- title: "Code",
- },
- codeRemove: {
- icon: "codeRemove",
- title: "Code",
- conditional: true,
- },
- clearformatting: {
- icon: "formatClear",
- title: "Clear all formatting",
- },
- subscript: {
- icon: "subscript",
- title: "Subscript",
- },
- superscript: {
- icon: "superscript",
- title: "Superscript",
- },
- insertBlock: {
- icon: "plus",
- title: "Insert",
- conditional: true,
- },
- bulletList: {
- icon: "bulletList",
- title: "Bullet list",
- },
- numberedList: {
- icon: "numberedList",
- title: "Numbered list",
- },
- fontFamily: {
- icon: "fontFamily",
- title: "Font family",
- },
- fontSize: {
- icon: "fontSize",
- title: "Font size",
- },
- headings: {
- icon: "heading",
- title: "Headings",
- },
- alignment: {
- icon: "alignCenter",
- title: "Alignment",
- },
- textDirection: {
- icon: "ltr",
- title: "Text direction",
- },
- highlight: {
- icon: "highlight",
- title: "Highlight",
- },
- textColor: {
- icon: "textColor",
- title: "Text color",
- },
- math: {
- icon: "math",
- title: "Math (inline)",
- },
- tableSettings: {
- icon: "tableSettings",
- title: "Table settings",
- conditional: true,
- },
- columnProperties: {
- icon: "columnProperties",
- title: "Column properties",
- conditional: true,
- },
- rowProperties: {
- icon: "rowProperties",
- title: "Row properties",
- conditional: true,
- },
- cellProperties: {
- icon: "cellProperties",
- title: "Cell properties",
- conditional: true,
- },
- insertColumnLeft: {
- icon: "insertColumnLeft",
- title: "Insert column left",
- conditional: true,
- },
- insertColumnRight: {
- icon: "insertColumnRight",
- title: "Insert column right",
- conditional: true,
- },
- moveColumnLeft: {
- icon: "moveColumnLeft",
- title: "Move column left",
- conditional: true,
- },
- moveColumnRight: {
- icon: "moveColumnRight",
- title: "Move column right",
- conditional: true,
- },
- deleteColumn: {
- icon: "deleteColumn",
- title: "Delete column",
- conditional: true,
- },
- splitCells: {
- icon: "splitCells",
- title: "Split cells",
- conditional: true,
- },
- mergeCells: {
- icon: "mergeCells",
- title: "Merge cells",
- conditional: true,
- },
- insertRowAbove: {
- icon: "insertRowAbove",
- title: "Insert row above",
- conditional: true,
- },
- insertRowBelow: {
- icon: "insertRowBelow",
- title: "Insert row below",
- conditional: true,
- },
- moveRowUp: {
- icon: "moveRowUp",
- title: "Move row up",
- conditional: true,
- },
- moveRowDown: {
- icon: "moveRowDown",
- title: "Move row down",
- conditional: true,
- },
- deleteRow: {
- icon: "deleteRow",
- title: "Delete row",
- conditional: true,
- },
- deleteTable: {
- icon: "deleteTable",
- title: "Delete table",
- conditional: true,
- },
- cellBackgroundColor: {
- icon: "backgroundColor",
- title: "Cell background color",
- conditional: true,
- },
- cellBorderColor: {
- icon: "cellBorderColor",
- title: "Cell border color",
- conditional: true,
- },
- cellTextColor: {
- icon: "textColor",
- title: "Cell text color",
- conditional: true,
- },
- cellBorderWidth: {
- icon: "none",
- title: "Cell border width",
- conditional: true,
- },
- imageSettings: {
- icon: "imageSettings",
- title: "Image settings",
- conditional: true,
- },
- imageAlignCenter: {
- icon: "alignCenter",
- title: "Align center",
- conditional: true,
- },
- imageAlignLeft: {
- icon: "alignLeft",
- title: "Align left",
- conditional: true,
- },
- imageAlignRight: {
- icon: "alignRight",
- title: "Align right",
- conditional: true,
- },
- imageProperties: {
- icon: "more",
- 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,
- },
- outdent: {
- icon: "outdent",
- title: "Lift list item",
- },
- indent: {
- icon: "indent",
- title: "Sink list item",
- },
-};
-function getToolDefinition(id) {
- return tools[id];
-}
-exports.getToolDefinition = getToolDefinition;
-function getAllTools() {
- return tools;
-}
-exports.getAllTools = getAllTools;
-function getDefaultPresets() {
- return defaultPresets;
-}
-exports.getDefaultPresets = getDefaultPresets;
-exports.STATIC_TOOLBAR_GROUPS = [
- [
- "insertBlock",
- "tableSettings",
- "imageSettings",
- "embedSettings",
- "attachmentSettings",
- "linkSettings",
- "codeRemove",
- "outdent",
- "indent",
- ],
-];
-const defaultPresets = {
- default: [
- [
- "bold",
- "italic",
- "underline",
- [
- "strikethrough",
- "code",
- "subscript",
- "superscript",
- "highlight",
- "textColor",
- "math",
- ],
- ],
- ["fontSize"],
- ["headings", "fontFamily"],
- ["numberedList", "bulletList"],
- ["addLink"],
- ["alignment", "textDirection"],
- ["clearformatting"],
- ],
- minimal: [
- ["bold", "italic", "underline", "strikethrough", "code"],
- ["headings", "addLink"],
- ["clearformatting"],
- ],
-};
diff --git a/packages/editor/dist/cjs/toolbar/tools/alignment.d.ts b/packages/editor/dist/cjs/toolbar/tools/alignment.d.ts
deleted file mode 100644
index 198c68a56..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/alignment.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function Alignment(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/alignment.js b/packages/editor/dist/cjs/toolbar/tools/alignment.js
deleted file mode 100644
index 933469739..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/alignment.js
+++ /dev/null
@@ -1,47 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Alignment = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const useRefValue_1 = require("../../hooks/useRefValue");
-function AlignmentTool(props) {
- const { editor, alignment } = props, toolProps = __rest(props, ["editor", "alignment"]);
- const alignmentRef = (0, useRefValue_1.useRefValue)(alignment);
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, toolProps, { onClick: () => {
- var _a;
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setTextAlign(alignmentRef.current).run();
- }, toggled: false })));
-}
-function Alignment(props) {
- const { editor } = props;
- const { textAlign } = Object.assign(Object.assign({}, editor.getAttributes("paragraph")), editor.getAttributes("heading"));
- const newAlignment = textAlign === "left"
- ? "center"
- : textAlign === "center"
- ? "right"
- : textAlign === "right"
- ? "justify"
- : textAlign === "justify"
- ? "left"
- : "left";
- const icon = textAlign === "center"
- ? "alignCenter"
- : textAlign === "justify"
- ? "alignJustify"
- : textAlign === "right"
- ? "alignRight"
- : "alignLeft";
- return (0, jsx_runtime_1.jsx)(AlignmentTool, Object.assign({ alignment: newAlignment }, props, { icon: icon }));
-}
-exports.Alignment = Alignment;
diff --git a/packages/editor/dist/cjs/toolbar/tools/attachment.d.ts b/packages/editor/dist/cjs/toolbar/tools/attachment.d.ts
deleted file mode 100644
index 6fb9c8012..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/attachment.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/// <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/cjs/toolbar/tools/attachment.js b/packages/editor/dist/cjs/toolbar/tools/attachment.js
deleted file mode 100644
index 32af83795..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/attachment.js
+++ /dev/null
@@ -1,31 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.RemoveAttachment = exports.DownloadAttachment = exports.AttachmentSettings = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const moretools_1 = require("../components/moretools");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const prosemirror_1 = require("../utils/prosemirror");
-function AttachmentSettings(props) {
- const { editor } = props;
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- if (!editor.isActive("attachment") || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: ["downloadAttachment", "removeAttachment"] })));
-}
-exports.AttachmentSettings = AttachmentSettings;
-function DownloadAttachment(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- const attachmentNode = (0, prosemirror_1.findSelectedNode)(editor, "attachment");
- const attachment = ((attachmentNode === null || attachmentNode === void 0 ? void 0 : attachmentNode.attrs) || {});
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().downloadAttachment(attachment).run();
- } })));
-}
-exports.DownloadAttachment = DownloadAttachment;
-function RemoveAttachment(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().removeAttachment().run(); } })));
-}
-exports.RemoveAttachment = RemoveAttachment;
diff --git a/packages/editor/dist/cjs/toolbar/tools/block.d.ts b/packages/editor/dist/cjs/toolbar/tools/block.d.ts
deleted file mode 100644
index 9ab2e4d50..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/block.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function InsertBlock(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/block.js b/packages/editor/dist/cjs/toolbar/tools/block.js
deleted file mode 100644
index f0a216530..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/block.js
+++ /dev/null
@@ -1,241 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.InsertBlock = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const icons_1 = require("../icons");
-const react_1 = require("react");
-const icon_1 = require("../components/icon");
-const embedpopup_1 = require("../popups/embedpopup");
-const tablepopup_1 = require("../popups/tablepopup");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const responsive_1 = require("../../components/responsive");
-const popuppresenter_1 = require("../../components/popuppresenter");
-const imageupload_1 = require("../popups/imageupload");
-const button_1 = require("../../components/button");
-function InsertBlock(props) {
- const { editor } = props;
- const buttonRef = (0, react_1.useRef)(null);
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- const isMobile = (0, toolbarstore_1.useIsMobile)();
- const menuItems = (0, react_1.useMemo)(() => {
- return [
- tasklist(editor),
- outlinelist(editor),
- horizontalRule(editor),
- codeblock(editor),
- mathblock(editor),
- blockquote(editor),
- image(editor, isMobile),
- attachment(editor),
- isMobile ? embedMobile(editor) : embedDesktop(editor),
- table(editor),
- ];
- }, [isMobile]);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ ref: buttonRef, sx: {
- p: 1,
- m: 0,
- bg: isOpen ? "hover" : "transparent",
- mr: 1,
- display: "flex",
- alignItems: "center",
- ":hover": { bg: "hover" },
- ":last-of-type": {
- mr: 0,
- },
- }, onMouseDown: (e) => e.preventDefault(), onClick: () => setIsOpen((s) => !s) }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.plus, size: 18, color: "primary" }) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, { desktop: "menu", mobile: "sheet", title: "Choose a block to insert", isOpen: isOpen, items: menuItems, onClose: () => setIsOpen(false), position: {
- target: buttonRef.current || undefined,
- isTargetAbsolute: true,
- location: toolbarLocation === "bottom" ? "top" : "below",
- yOffset: 5,
- } })] }));
-}
-exports.InsertBlock = InsertBlock;
-const horizontalRule = (editor) => ({
- key: "hr",
- type: "button",
- title: "Horizontal rule",
- icon: "horizontalRule",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("horizontalRule"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setHorizontalRule().run(); },
-});
-const codeblock = (editor) => ({
- key: "codeblock",
- type: "button",
- title: "Code block",
- icon: "codeblock",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleCodeBlock().run(); },
-});
-const blockquote = (editor) => ({
- key: "blockquote",
- type: "button",
- title: "Quote",
- icon: "blockquote",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("blockQuote"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleBlockquote().run(); },
-});
-const mathblock = (editor) => ({
- key: "math",
- type: "button",
- title: "Math & formulas",
- icon: "mathBlock",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("mathBlock"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().insertMathBlock().run(); },
-});
-const image = (editor, isMobile) => ({
- key: "image",
- type: "button",
- title: "Image",
- icon: "image",
- menu: {
- title: "Insert an image",
- items: [
- {
- key: "upload-from-disk",
- type: "button",
- title: "Upload from disk",
- icon: "upload",
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().openAttachmentPicker("image").run(); },
- },
- {
- key: "camera",
- type: "button",
- title: "Take a photo using camera",
- icon: "camera",
- isHidden: !isMobile,
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().openAttachmentPicker("camera").run(); },
- },
- isMobile ? uploadImageFromURLMobile(editor) : uploadImageFromURL(editor),
- ],
- },
-});
-const table = (editor) => ({
- key: "table",
- type: "button",
- title: "Table",
- icon: "table",
- menu: {
- title: "Insert a table",
- items: [
- {
- key: "table-size-selector",
- type: "popup",
- component: (props) => ((0, jsx_runtime_1.jsx)(tablepopup_1.TablePopup, { onInsertTable: (size) => {
- var _a, _b;
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().insertTable({
- rows: size.rows,
- cols: size.columns,
- }).run();
- (_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props);
- } })),
- },
- ],
- },
-});
-const embedMobile = (editor) => ({
- key: "embed",
- type: "button",
- title: "Embed",
- icon: "embed",
- menu: {
- title: "Insert an embed",
- items: [
- {
- key: "embed-popup",
- type: "popup",
- component: function ({ onClick }) {
- return ((0, jsx_runtime_1.jsx)(embedpopup_1.EmbedPopup, { title: "Insert embed", onClose: (embed) => {
- var _a;
- if (!embed)
- return onClick === null || onClick === void 0 ? void 0 : onClick();
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().insertEmbed(embed).run();
- onClick === null || onClick === void 0 ? void 0 : onClick();
- } }));
- },
- },
- ],
- },
-});
-const embedDesktop = (editor) => ({
- key: "embed",
- type: "button",
- title: "Embed",
- icon: "embed",
- onClick: () => {
- if (!editor)
- return;
- (0, popuppresenter_1.showPopup)({
- popup: (hide) => ((0, jsx_runtime_1.jsx)(embedpopup_1.EmbedPopup, { title: "Insert embed", onClose: (embed) => {
- var _a;
- if (!embed)
- return hide();
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().insertEmbed(embed).run();
- hide();
- } })),
- });
- },
-});
-const attachment = (editor) => ({
- key: "attachment",
- type: "button",
- title: "Attachment",
- icon: "attachment",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("attachment"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().openAttachmentPicker("file").run(); },
-});
-const tasklist = (editor) => ({
- key: "tasklist",
- type: "button",
- title: "Task list",
- icon: "checkbox",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("taskList"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleTaskList().run(); },
-});
-const outlinelist = (editor) => ({
- key: "outlinelist",
- type: "button",
- title: "Outline list",
- icon: "outlineList",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("outlineList"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleOutlineList().run(); },
-});
-const uploadImageFromURLMobile = (editor) => ({
- key: "upload-from-url",
- type: "button",
- title: "Attach from URL",
- icon: "link",
- menu: {
- title: "Attach image from URL",
- items: [
- {
- key: "attach-image",
- type: "popup",
- component: ({ onClick }) => ((0, jsx_runtime_1.jsx)(imageupload_1.ImageUploadPopup, { onInsert: (image) => {
- var _a;
- (_a = editor
- .requestPermission("insertImage")) === null || _a === void 0 ? void 0 : _a.chain().focus().insertImage(image).run();
- onClick === null || onClick === void 0 ? void 0 : onClick();
- }, onClose: () => {
- onClick === null || onClick === void 0 ? void 0 : onClick();
- } })),
- },
- ],
- },
-});
-const uploadImageFromURL = (editor) => ({
- key: "upload-from-url",
- type: "button",
- title: "Attach from URL",
- icon: "link",
- onClick: () => {
- (0, popuppresenter_1.showPopup)({
- popup: (hide) => ((0, jsx_runtime_1.jsx)(imageupload_1.ImageUploadPopup, { onInsert: (image) => {
- var _a;
- (_a = editor
- .requestPermission("insertImage")) === null || _a === void 0 ? void 0 : _a.chain().focus().insertImage(image).run();
- hide();
- }, onClose: hide })),
- });
- },
-});
diff --git a/packages/editor/dist/cjs/toolbar/tools/colors.d.ts b/packages/editor/dist/cjs/toolbar/tools/colors.d.ts
deleted file mode 100644
index 68c8fa59f..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/colors.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-declare type ColorToolProps = ToolProps & {
- onColorChange: (color?: string) => void;
- getActiveColor: () => string;
- title: string;
- cacheKey: string;
-};
-export declare function ColorTool(props: ColorToolProps): JSX.Element;
-export declare function Highlight(props: ToolProps): JSX.Element;
-export declare function TextColor(props: ToolProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/tools/colors.js b/packages/editor/dist/cjs/toolbar/tools/colors.js
deleted file mode 100644
index 738087765..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/colors.js
+++ /dev/null
@@ -1,73 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TextColor = exports.Highlight = exports.ColorTool = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const tinycolor2_1 = __importDefault(require("tinycolor2"));
-const popuppresenter_1 = require("../../components/popuppresenter");
-const config_1 = require("../../utils/config");
-const splitbutton_1 = require("../components/splitbutton");
-const colorpicker_1 = require("../popups/colorpicker");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const dom_1 = require("../utils/dom");
-function ColorTool(props) {
- const { editor, onColorChange, getActiveColor, title, cacheKey } = props, toolProps = __rest(props, ["editor", "onColorChange", "getActiveColor", "title", "cacheKey"]);
- const activeColor = getActiveColor() || config_1.config.get(cacheKey);
- const tColor = (0, tinycolor2_1.default)(activeColor);
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- return ((0, jsx_runtime_1.jsx)(splitbutton_1.SplitButton, Object.assign({}, toolProps, { iconColor: activeColor && tColor.isDark() ? "static" : "icon", sx: {
- mr: 0,
- bg: activeColor || "transparent",
- ":hover": {
- bg: activeColor ? tColor.darken(5).toRgbString() : "transparent",
- },
- }, onOpen: () => setIsOpen((s) => !s), toggled: isOpen, onClick: () => onColorChange(activeColor) }, { children: (0, jsx_runtime_1.jsx)(popuppresenter_1.PopupWrapper, { isOpen: isOpen, id: props.icon, group: "color", position: {
- isTargetAbsolute: true,
- target: (0, dom_1.getToolbarElement)(),
- align: isBottom ? "center" : "end",
- location: isBottom ? "top" : "below",
- yOffset: 10,
- }, focusOnRender: false, blocking: false, renderPopup: (close) => ((0, jsx_runtime_1.jsx)(colorpicker_1.ColorPicker, { color: activeColor, onClear: () => {
- onColorChange();
- config_1.config.set(cacheKey, null);
- }, onChange: (color) => {
- onColorChange(color);
- config_1.config.set(cacheKey, color);
- }, onClose: close, title: title })) }) })));
-}
-exports.ColorTool = ColorTool;
-function Highlight(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(ColorTool, Object.assign({}, props, { cacheKey: "highlight", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("highlight").color; }, title: "Background color", onColorChange: (color) => {
- var _a, _b;
- return color
- ? (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleHighlight({ color }).run()
- : (_b = editor.current) === null || _b === void 0 ? void 0 : _b.chain().focus().unsetHighlight().run();
- } })));
-}
-exports.Highlight = Highlight;
-function TextColor(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(ColorTool, Object.assign({}, props, { cacheKey: "textColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("textStyle").color; }, title: "Text color", onColorChange: (color) => {
- var _a, _b;
- return color
- ? (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setColor(color).run()
- : (_b = editor.current) === null || _b === void 0 ? void 0 : _b.chain().focus().unsetColor().run();
- } })));
-}
-exports.TextColor = TextColor;
diff --git a/packages/editor/dist/cjs/toolbar/tools/embed.d.ts b/packages/editor/dist/cjs/toolbar/tools/embed.d.ts
deleted file mode 100644
index 3c143f3c1..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/embed.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <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/cjs/toolbar/tools/embed.js b/packages/editor/dist/cjs/toolbar/tools/embed.js
deleted file mode 100644
index 085567ec5..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/embed.js
+++ /dev/null
@@ -1,68 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EmbedProperties = exports.EmbedAlignCenter = exports.EmbedAlignRight = exports.EmbedAlignLeft = exports.EmbedSettings = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const react_1 = require("react");
-const responsive_1 = require("../../components/responsive");
-const moretools_1 = require("../components/moretools");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const prosemirror_1 = require("../utils/prosemirror");
-const embedpopup_1 = require("../popups/embedpopup");
-function EmbedSettings(props) {
- const { editor } = props;
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- if (!editor.isActive("embed") || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "embedSettings", tools: [] })));
-}
-exports.EmbedSettings = EmbedSettings;
-function EmbedAlignLeft(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setEmbedAlignment({ align: "left" }).run();
- } })));
-}
-exports.EmbedAlignLeft = EmbedAlignLeft;
-function EmbedAlignRight(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setEmbedAlignment({ align: "right" }).run();
- } })));
-}
-exports.EmbedAlignRight = EmbedAlignRight;
-function EmbedAlignCenter(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setEmbedAlignment({ align: "center" }).run();
- } })));
-}
-exports.EmbedAlignCenter = EmbedAlignCenter;
-// TODO: stop re-rendering
-function EmbedProperties(props) {
- const { editor } = props;
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- const buttonRef = (0, react_1.useRef)();
- // TODO: improve perf by deferring this until user opens the popup
- const embedNode = (0, react_1.useMemo)(() => (0, prosemirror_1.findSelectedNode)(editor, "embed"), []);
- const embed = ((embedNode === null || embedNode === void 0 ? void 0 : embedNode.attrs) || {});
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: () => setIsOpen((s) => !s) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: () => setIsOpen(false), blocking: true, focusOnRender: false, position: {
- target: buttonRef.current || "mouse",
- align: "start",
- location: "below",
- yOffset: 10,
- isTargetAbsolute: true,
- } }, { children: (0, jsx_runtime_1.jsx)(embedpopup_1.EmbedPopup, { title: "Embed properties", onClose: (newEmbed) => {
- var _a, _b;
- if (!newEmbed) {
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSize(embed);
- }
- else if (newEmbed.src !== embed.src)
- (_b = editor.current) === null || _b === void 0 ? void 0 : _b.commands.setEmbedSource(newEmbed.src);
- setIsOpen(false);
- }, embed: embed, onSizeChanged: (size) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSize(size); } }) }))] }));
-}
-exports.EmbedProperties = EmbedProperties;
diff --git a/packages/editor/dist/cjs/toolbar/tools/font.d.ts b/packages/editor/dist/cjs/toolbar/tools/font.d.ts
deleted file mode 100644
index e7818addd..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/font.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function FontSize(props: ToolProps): JSX.Element;
-export declare function FontFamily(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/font.js b/packages/editor/dist/cjs/toolbar/tools/font.js
deleted file mode 100644
index b230a86a5..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/font.js
+++ /dev/null
@@ -1,59 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.FontFamily = exports.FontSize = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const dropdown_1 = require("../components/dropdown");
-const react_1 = require("react");
-const counter_1 = require("../components/counter");
-const useRefValue_1 = require("../../hooks/useRefValue");
-function FontSize(props) {
- const { editor } = props;
- const { fontSize: _fontSize } = editor.getAttributes("textStyle");
- const fontSize = _fontSize || "16px";
- const fontSizeAsNumber = (0, useRefValue_1.useRefValue)(parseInt(fontSize.replace("px", "")));
- const decreaseFontSize = (0, react_1.useCallback)(() => {
- return Math.max(8, fontSizeAsNumber.current - 1);
- }, []);
- const increaseFontSize = (0, react_1.useCallback)(() => {
- return Math.min(120, fontSizeAsNumber.current + 1);
- }, []);
- return ((0, jsx_runtime_1.jsx)(counter_1.Counter, { title: "font size", onDecrease: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontSize(`${decreaseFontSize()}px`).run();
- }, onIncrease: () => {
- var _a;
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontSize(`${increaseFontSize()}px`).run();
- }, onReset: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontSize(`16px`).run(); }, value: fontSize }));
-}
-exports.FontSize = FontSize;
-const fontFamilies = {
- "Sans-serif": "Open Sans",
- Serif: "serif",
- Monospace: "monospace",
-};
-function FontFamily(props) {
- var _a, _b;
- const { editor } = props;
- const currentFontFamily = ((_b = (_a = Object.entries(fontFamilies)
- .find(([key, value]) => editor.isActive("textStyle", { fontFamily: value }))) === null || _a === void 0 ? void 0 : _a.map((a) => a)) === null || _b === void 0 ? void 0 : _b.at(0)) || "Sans-serif";
- const items = (0, react_1.useMemo)(() => toMenuItems(editor, currentFontFamily), [currentFontFamily]);
- return ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { id: "fontFamily", group: "font", selectedItem: currentFontFamily, items: items, menuWidth: 130 }));
-}
-exports.FontFamily = FontFamily;
-function toMenuItems(editor, currentFontFamily) {
- const menuItems = [];
- for (const key in fontFamilies) {
- const value = fontFamilies[key];
- menuItems.push({
- key,
- type: "button",
- title: key,
- isChecked: key === currentFontFamily,
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontFamily(value).run(); },
- styles: {
- fontFamily: value,
- },
- });
- }
- return menuItems;
-}
diff --git a/packages/editor/dist/cjs/toolbar/tools/headings.d.ts b/packages/editor/dist/cjs/toolbar/tools/headings.d.ts
deleted file mode 100644
index e237b7e5f..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/headings.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function Headings(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/headings.js b/packages/editor/dist/cjs/toolbar/tools/headings.js
deleted file mode 100644
index b43f7b60b..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/headings.js
+++ /dev/null
@@ -1,36 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Headings = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const dropdown_1 = require("../components/dropdown");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const react_1 = require("react");
-const defaultLevels = [1, 2, 3, 4, 5, 6];
-function Headings(props) {
- const { editor } = props;
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- const currentHeadingLevel = defaultLevels.find((level) => editor.isActive("heading", { level }));
- const items = (0, react_1.useMemo)(() => toMenuItems(editor, toolbarLocation, currentHeadingLevel), [currentHeadingLevel]);
- return ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { id: "headings", group: "headings", selectedItem: currentHeadingLevel ? `Heading ${currentHeadingLevel}` : "Paragraph", items: items, menuWidth: 130 }));
-}
-exports.Headings = Headings;
-function toMenuItems(editor, toolbarLocation, currentHeadingLevel) {
- const menuItems = defaultLevels.map((level) => ({
- type: "button",
- key: `heading-${level}`,
- title: toolbarLocation === "bottom" ? `H${level}` : `Heading ${level}`,
- isChecked: level === currentHeadingLevel,
- onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().updateAttributes("textStyle", { fontSize: null, fontStyle: null }).setHeading({ level: level }).run();
- },
- }));
- const paragraph = {
- key: "paragraph",
- type: "button",
- title: "Paragraph",
- isChecked: !currentHeadingLevel,
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setParagraph().run(); },
- };
- return [paragraph, ...menuItems];
-}
diff --git a/packages/editor/dist/cjs/toolbar/tools/image.d.ts b/packages/editor/dist/cjs/toolbar/tools/image.d.ts
deleted file mode 100644
index d192850d6..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/image.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function ImageSettings(props: ToolProps): JSX.Element | null;
-export declare function ImageAlignLeft(props: ToolProps): JSX.Element;
-export declare function ImageAlignRight(props: ToolProps): JSX.Element;
-export declare function ImageAlignCenter(props: ToolProps): JSX.Element;
-export declare function ImageProperties(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/image.js b/packages/editor/dist/cjs/toolbar/tools/image.js
deleted file mode 100644
index fa2b8371d..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/image.js
+++ /dev/null
@@ -1,68 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.ImageProperties = exports.ImageAlignCenter = exports.ImageAlignRight = exports.ImageAlignLeft = exports.ImageSettings = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const react_1 = require("react");
-const responsive_1 = require("../../components/responsive");
-const moretools_1 = require("../components/moretools");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const imageproperties_1 = require("../popups/imageproperties");
-const prosemirror_1 = require("../utils/prosemirror");
-function ImageSettings(props) {
- var _a, _b;
- const { editor } = props;
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- if (!editor.isActive("image") || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "imageSettings", tools: ((_b = (_a = (0, prosemirror_1.findSelectedNode)(editor, "image")) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.float)
- ? ["imageAlignLeft", "imageAlignRight", "imageProperties"]
- : [
- "imageAlignLeft",
- "imageAlignCenter",
- "imageAlignRight",
- "imageProperties",
- ] })));
-}
-exports.ImageSettings = ImageSettings;
-function ImageAlignLeft(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setImageAlignment({ align: "left" }).run();
- } })));
-}
-exports.ImageAlignLeft = ImageAlignLeft;
-function ImageAlignRight(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setImageAlignment({ align: "right" }).run();
- } })));
-}
-exports.ImageAlignRight = ImageAlignRight;
-function ImageAlignCenter(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setImageAlignment({ align: "center" }).run();
- } })));
-}
-exports.ImageAlignCenter = ImageAlignCenter;
-function ImageProperties(props) {
- const { editor } = props;
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- const buttonRef = (0, react_1.useRef)();
- // TODO: defer until user opens the popup
- const image = (0, prosemirror_1.findSelectedNode)(editor, "image");
- const { float, align, width, height } = ((image === null || image === void 0 ? void 0 : image.attrs) ||
- {});
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: () => setIsOpen((s) => !s) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: () => setIsOpen(false), blocking: true, focusOnRender: false, position: {
- target: buttonRef.current || "mouse",
- align: "start",
- location: "below",
- yOffset: 10,
- isTargetAbsolute: true,
- } }, { children: (0, jsx_runtime_1.jsx)(imageproperties_1.ImageProperties, { editor: editor, height: height, width: width, align: align, float: float, onClose: () => setIsOpen(false) }) }))] }));
-}
-exports.ImageProperties = ImageProperties;
diff --git a/packages/editor/dist/cjs/toolbar/tools/index.d.ts b/packages/editor/dist/cjs/toolbar/tools/index.d.ts
deleted file mode 100644
index 959c01b7c..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/index.d.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import React from "react";
-import { ToolProps } from "../types";
-import { Bold, Italic, Underline, Strikethrough, Code, Subscript, Superscript, ClearFormatting, CodeRemove, Math } from "./inline";
-import { InsertBlock } from "./block";
-import { FontSize, FontFamily } from "./font";
-import { Alignment } from "./alignment";
-import { Headings } from "./headings";
-import { NumberedList, BulletList, Outdent, Indent } from "./lists";
-import { TextDirection } 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";
-import { AddLink, EditLink, RemoveLink, LinkSettings, OpenLink } from "./link";
-export declare type ToolId = keyof typeof tools;
-declare const tools: {
- bold: typeof Bold;
- italic: typeof Italic;
- underline: typeof Underline;
- strikethrough: typeof Strikethrough;
- code: typeof Code;
- codeRemove: typeof CodeRemove;
- subscript: typeof Subscript;
- superscript: typeof Superscript;
- clearformatting: typeof ClearFormatting;
- addLink: typeof AddLink;
- editLink: typeof EditLink;
- removeLink: typeof RemoveLink;
- linkSettings: typeof LinkSettings;
- openLink: typeof OpenLink;
- insertBlock: typeof InsertBlock;
- numberedList: typeof NumberedList;
- bulletList: typeof BulletList;
- fontSize: typeof FontSize;
- fontFamily: typeof FontFamily;
- headings: typeof Headings;
- alignment: typeof Alignment;
- textDirection: typeof TextDirection;
- textColor: typeof TextColor;
- highlight: typeof Highlight;
- math: typeof Math;
- imageSettings: typeof ImageSettings;
- imageAlignCenter: typeof ImageAlignCenter;
- 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;
- cellProperties: typeof CellProperties;
- insertColumnLeft: (props: ToolProps) => JSX.Element;
- insertColumnRight: (props: ToolProps) => JSX.Element;
- moveColumnLeft: (props: ToolProps) => JSX.Element;
- moveColumnRight: (props: ToolProps) => JSX.Element;
- deleteColumn: (props: ToolProps) => JSX.Element;
- splitCells: (props: ToolProps) => JSX.Element;
- mergeCells: (props: ToolProps) => JSX.Element;
- cellBackgroundColor: typeof CellBackgroundColor;
- cellBorderColor: typeof CellBorderColor;
- cellTextColor: typeof CellTextColor;
- cellBorderWidth: typeof CellBorderWidth;
- insertRowAbove: (props: ToolProps) => JSX.Element;
- insertRowBelow: (props: ToolProps) => JSX.Element;
- moveRowUp: (props: ToolProps) => JSX.Element;
- moveRowDown: (props: ToolProps) => JSX.Element;
- deleteRow: (props: ToolProps) => JSX.Element;
- deleteTable: (props: ToolProps) => JSX.Element;
- outdent: typeof Outdent;
- indent: typeof Indent;
-};
-export declare function findTool(id: ToolId): React.FunctionComponent<ToolProps>;
-export {};
diff --git a/packages/editor/dist/cjs/toolbar/tools/index.js b/packages/editor/dist/cjs/toolbar/tools/index.js
deleted file mode 100644
index d61310321..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/index.js
+++ /dev/null
@@ -1,83 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.findTool = void 0;
-const inline_1 = require("./inline");
-const block_1 = require("./block");
-const font_1 = require("./font");
-const alignment_1 = require("./alignment");
-const headings_1 = require("./headings");
-const lists_1 = require("./lists");
-const textdirection_1 = require("./textdirection");
-const colors_1 = require("./colors");
-const table_1 = require("./table");
-const image_1 = require("./image");
-const attachment_1 = require("./attachment");
-const embed_1 = require("./embed");
-const link_1 = require("./link");
-const tools = {
- bold: inline_1.Bold,
- italic: inline_1.Italic,
- underline: inline_1.Underline,
- strikethrough: inline_1.Strikethrough,
- code: inline_1.Code,
- codeRemove: inline_1.CodeRemove,
- subscript: inline_1.Subscript,
- superscript: inline_1.Superscript,
- clearformatting: inline_1.ClearFormatting,
- addLink: link_1.AddLink,
- editLink: link_1.EditLink,
- removeLink: link_1.RemoveLink,
- linkSettings: link_1.LinkSettings,
- openLink: link_1.OpenLink,
- insertBlock: block_1.InsertBlock,
- numberedList: lists_1.NumberedList,
- bulletList: lists_1.BulletList,
- fontSize: font_1.FontSize,
- fontFamily: font_1.FontFamily,
- headings: headings_1.Headings,
- alignment: alignment_1.Alignment,
- textDirection: textdirection_1.TextDirection,
- textColor: colors_1.TextColor,
- highlight: colors_1.Highlight,
- math: inline_1.Math,
- imageSettings: image_1.ImageSettings,
- imageAlignCenter: image_1.ImageAlignCenter,
- imageAlignLeft: image_1.ImageAlignLeft,
- imageAlignRight: image_1.ImageAlignRight,
- imageProperties: image_1.ImageProperties,
- embedAlignCenter: embed_1.EmbedAlignCenter,
- embedAlignLeft: embed_1.EmbedAlignLeft,
- embedAlignRight: embed_1.EmbedAlignRight,
- embedProperties: embed_1.EmbedProperties,
- embedSettings: embed_1.EmbedSettings,
- attachmentSettings: attachment_1.AttachmentSettings,
- downloadAttachment: attachment_1.DownloadAttachment,
- removeAttachment: attachment_1.RemoveAttachment,
- tableSettings: table_1.TableSettings,
- columnProperties: table_1.ColumnProperties,
- rowProperties: table_1.RowProperties,
- cellProperties: table_1.CellProperties,
- insertColumnLeft: table_1.InsertColumnLeft,
- insertColumnRight: table_1.InsertColumnRight,
- moveColumnLeft: table_1.MoveColumnLeft,
- moveColumnRight: table_1.MoveColumnRight,
- deleteColumn: table_1.DeleteColumn,
- splitCells: table_1.SplitCells,
- mergeCells: table_1.MergeCells,
- cellBackgroundColor: table_1.CellBackgroundColor,
- cellBorderColor: table_1.CellBorderColor,
- cellTextColor: table_1.CellTextColor,
- cellBorderWidth: table_1.CellBorderWidth,
- insertRowAbove: table_1.InsertRowAbove,
- insertRowBelow: table_1.InsertRowBelow,
- moveRowUp: table_1.MoveRowUp,
- moveRowDown: table_1.MoveRowDown,
- deleteRow: table_1.DeleteRow,
- deleteTable: table_1.DeleteTable,
- outdent: lists_1.Outdent,
- indent: lists_1.Indent,
-};
-function findTool(id) {
- return tools[id];
-}
-exports.findTool = findTool;
diff --git a/packages/editor/dist/cjs/toolbar/tools/inline.d.ts b/packages/editor/dist/cjs/toolbar/tools/inline.d.ts
deleted file mode 100644
index f8a5deb2c..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/inline.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function Italic(props: ToolProps): JSX.Element;
-export declare function Strikethrough(props: ToolProps): JSX.Element;
-export declare function Underline(props: ToolProps): JSX.Element;
-export declare function Code(props: ToolProps): JSX.Element;
-export declare function Bold(props: ToolProps): JSX.Element;
-export declare function Subscript(props: ToolProps): JSX.Element;
-export declare function Superscript(props: ToolProps): JSX.Element;
-export declare function ClearFormatting(props: ToolProps): JSX.Element;
-export declare function CodeRemove(props: ToolProps): JSX.Element | null;
-export declare function Math(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/inline.js b/packages/editor/dist/cjs/toolbar/tools/inline.js
deleted file mode 100644
index 9010cc88a..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/inline.js
+++ /dev/null
@@ -1,62 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Math = exports.CodeRemove = exports.ClearFormatting = exports.Superscript = exports.Subscript = exports.Bold = exports.Code = exports.Underline = exports.Strikethrough = exports.Italic = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const toolbarstore_1 = require("../stores/toolbarstore");
-function Italic(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("italic"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleItalic().run(); } })));
-}
-exports.Italic = Italic;
-function Strikethrough(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("strike"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleStrike().run(); } })));
-}
-exports.Strikethrough = Strikethrough;
-function Underline(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("underline"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleUnderline().run(); } })));
-}
-exports.Underline = Underline;
-function Code(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("code"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleCode().run(); } })));
-}
-exports.Code = Code;
-function Bold(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("bold"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleBold().run(); } })));
-}
-exports.Bold = Bold;
-function Subscript(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("subscript"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleSubscript().run(); } })));
-}
-exports.Subscript = Subscript;
-function Superscript(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: editor.isActive("superscript"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleSuperscript().run(); } })));
-}
-exports.Superscript = Superscript;
-function ClearFormatting(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().clearNodes().unsetAllMarks().unsetMark("link").run();
- } })));
-}
-exports.ClearFormatting = ClearFormatting;
-function CodeRemove(props) {
- const { editor } = props;
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- if (!editor.isActive("code") || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().unsetMark("code").run(); } })));
-}
-exports.CodeRemove = CodeRemove;
-function Math(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().insertMathInline().run(); } })));
-}
-exports.Math = Math;
diff --git a/packages/editor/dist/cjs/toolbar/tools/link.d.ts b/packages/editor/dist/cjs/toolbar/tools/link.d.ts
deleted file mode 100644
index 58223feb4..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/link.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function LinkSettings(props: ToolProps): JSX.Element | null;
-export declare function AddLink(props: ToolProps): JSX.Element;
-export declare function EditLink(props: ToolProps): JSX.Element;
-export declare function RemoveLink(props: ToolProps): JSX.Element;
-export declare function OpenLink(props: ToolProps): JSX.Element | null;
diff --git a/packages/editor/dist/cjs/toolbar/tools/link.js b/packages/editor/dist/cjs/toolbar/tools/link.js
deleted file mode 100644
index f24b926b5..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/link.js
+++ /dev/null
@@ -1,149 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.OpenLink = exports.RemoveLink = exports.EditLink = exports.AddLink = exports.LinkSettings = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const react_1 = require("react");
-const responsive_1 = require("../../components/responsive");
-const linkpopup_1 = require("../popups/linkpopup");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const moretools_1 = require("../components/moretools");
-const useRefValue_1 = require("../../hooks/useRefValue");
-const prosemirror_1 = require("../utils/prosemirror");
-const prosemirror_utils_1 = require("prosemirror-utils");
-const rebass_1 = require("rebass");
-function LinkSettings(props) {
- const { editor } = props;
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- if (!editor.isActive("link") || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "linkSettings", tools: ["openLink", "editLink", "removeLink"] })));
-}
-exports.LinkSettings = LinkSettings;
-function AddLink(props) {
- const { editor } = props;
- const isActive = props.editor.isActive("link");
- const onDone = (0, react_1.useCallback)((href, text) => {
- var _a, _b;
- if (!href)
- return;
- let commandChain = (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus();
- if (!commandChain)
- return;
- const isSelection = !((_b = editor.current) === null || _b === void 0 ? void 0 : _b.state.selection.empty);
- commandChain
- .extendMarkRange("link")
- .toggleLink({ href, target: "_blank" })
- .insertContent(text || href)
- .focus();
- if (!isSelection)
- commandChain = commandChain.unsetMark("link").insertContent(" ");
- commandChain.run();
- }, []);
- if (isActive)
- return (0, jsx_runtime_1.jsx)(EditLink, Object.assign({}, props));
- return ((0, jsx_runtime_1.jsx)(LinkTool, Object.assign({}, props, { onDone: onDone, onClick: () => {
- if (!editor.current)
- return;
- const { state } = editor.current;
- let { from, to } = state.selection;
- const selectedText = state.doc.textBetween(from, to);
- return { text: selectedText };
- } })));
-}
-exports.AddLink = AddLink;
-function EditLink(props) {
- const { editor, selectedNode: _selectedNode } = props;
- const selectedNode = (0, useRefValue_1.useRefValue)(_selectedNode || (0, prosemirror_1.selectionToOffset)(editor.state));
- const onDone = (0, react_1.useCallback)((href, text) => {
- const { from, node, to } = selectedNode.current;
- if (!href || !editor.current || !node)
- return;
- const mark = (0, prosemirror_1.findMark)(node, "link");
- if (!mark)
- return;
- editor.current
- .chain()
- .command(({ tr }) => {
- tr.removeMark(from, to, mark.type);
- tr.addMark(from, to, mark.type.create({ href }));
- tr.insertText(text || node.textContent, from, to);
- (0, prosemirror_utils_1.setTextSelection)(tr.mapping.map(from))(tr);
- return true;
- })
- .focus(undefined, { scrollIntoView: true })
- .run();
- }, []);
- return ((0, jsx_runtime_1.jsx)(LinkTool, Object.assign({}, props, { isEditing: true, onDone: onDone, onClick: () => {
- const { node } = selectedNode.current;
- if (!node)
- return;
- const selectedText = node.textContent;
- const mark = (0, prosemirror_1.findMark)(node, "link");
- if (!mark)
- return;
- return { text: selectedText, href: mark.attrs.href };
- } })));
-}
-exports.EditLink = EditLink;
-function RemoveLink(props) {
- const { editor, selectedNode } = props;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a, _b;
- if (selectedNode)
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setTextSelection(selectedNode.from);
- (_b = editor.current) === null || _b === void 0 ? void 0 : _b.chain().focus().unsetLink().run();
- } })));
-}
-exports.RemoveLink = RemoveLink;
-function OpenLink(props) {
- const { editor, selectedNode: _selectedNode } = props;
- const selectedNode = (0, useRefValue_1.useRefValue)(_selectedNode || (0, prosemirror_1.selectionToOffset)(editor.state));
- const { node } = selectedNode.current;
- const link = node ? (0, prosemirror_1.findMark)(node, "link") : null;
- if (!link)
- return null;
- const href = link === null || link === void 0 ? void 0 : link.attrs.href;
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { alignItems: "center" } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ as: "a", href: href, target: "_blank", variant: "body", sx: { mr: 1 } }, { children: href })), (0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { toggled: false, onClick: () => window.open(href, "_blank") }))] })));
-}
-exports.OpenLink = OpenLink;
-function LinkTool(props) {
- const { isEditing, onClick, onDone, editor } = props, toolProps = __rest(props, ["isEditing", "onClick", "onDone", "editor"]);
- const buttonRef = (0, react_1.useRef)(null);
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- const [href, setHref] = (0, react_1.useState)();
- const [text, setText] = (0, react_1.useState)();
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, toolProps, { buttonRef: buttonRef, onClick: () => {
- const result = onClick();
- if (!result)
- return;
- const { text, href } = result;
- setHref(href);
- setText(text);
- setIsOpen(true);
- }, toggled: isOpen })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, Object.assign({ mobile: "sheet", desktop: "menu", position: {
- target: buttonRef.current || undefined,
- isTargetAbsolute: true,
- location: "below",
- align: "center",
- yOffset: 5,
- }, title: isEditing ? "Edit link" : "Insert link", isOpen: isOpen, items: [], onClose: () => {
- var _a;
- setIsOpen(false);
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.focus();
- }, focusOnRender: false }, { children: (0, jsx_runtime_1.jsx)(linkpopup_1.LinkPopup, { href: href, text: text, isEditing: isEditing, onClose: () => setIsOpen(false), onDone: ({ href, text }) => {
- onDone(href, text);
- setIsOpen(false);
- } }) }))] }));
-}
diff --git a/packages/editor/dist/cjs/toolbar/tools/lists.d.ts b/packages/editor/dist/cjs/toolbar/tools/lists.d.ts
deleted file mode 100644
index 551f6e925..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/lists.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function NumberedList(props: ToolProps): JSX.Element;
-export declare function BulletList(props: ToolProps): JSX.Element;
-export declare function Indent(props: ToolProps): JSX.Element | null;
-export declare function Outdent(props: ToolProps): JSX.Element | null;
diff --git a/packages/editor/dist/cjs/toolbar/tools/lists.js b/packages/editor/dist/cjs/toolbar/tools/lists.js
deleted file mode 100644
index 49299e16f..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/lists.js
+++ /dev/null
@@ -1,134 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Outdent = exports.Indent = exports.BulletList = exports.NumberedList = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const rebass_1 = require("rebass");
-const react_1 = require("react");
-const splitbutton_1 = require("../components/splitbutton");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const dom_1 = require("../utils/dom");
-const popuppresenter_1 = require("../../components/popuppresenter");
-const react_2 = __importDefault(require("react"));
-const toolbutton_1 = require("../components/toolbutton");
-const prosemirror_1 = require("../utils/prosemirror");
-function _ListTool(props) {
- const { editor, onClick, isActive, subTypes, type } = props, toolProps = __rest(props, ["editor", "onClick", "isActive", "subTypes", "type"]);
- const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
- const isBottom = toolbarLocation === "bottom";
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
- const buttonRef = (0, react_1.useRef)();
- return ((0, jsx_runtime_1.jsx)(splitbutton_1.SplitButton, Object.assign({}, toolProps, { buttonRef: buttonRef, onClick: onClick, toggled: isOpen, sx: { mr: 0 }, onOpen: () => setIsOpen((s) => !s) }, { children: (0, jsx_runtime_1.jsx)(popuppresenter_1.PopupWrapper, { isOpen: isOpen, group: "lists", id: toolProps.title, blocking: false, focusOnRender: false, position: {
- isTargetAbsolute: true,
- target: isBottom ? (0, dom_1.getToolbarElement)() : buttonRef.current || "mouse",
- align: "center",
- location: isBottom ? "top" : "below",
- yOffset: 10,
- }, onClosed: () => setIsOpen(false), renderPopup: () => ((0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {
- bg: "background",
- display: "grid",
- gridTemplateColumns: "1fr 1fr 1fr",
- p: 1,
- } }, { children: subTypes.map((item) => ((0, jsx_runtime_1.jsx)(rebass_1.Button, Object.assign({ variant: "menuitem", sx: { width: 80 }, onClick: () => {
- var _a;
- let chain = (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus();
- if (!chain || !editor.current)
- return;
- if (!(0, prosemirror_1.isListActive)(editor.current)) {
- if (type === "bulletList")
- chain = chain.toggleBulletList();
- else
- chain = chain.toggleOrderedList();
- }
- return chain
- .updateAttributes(type, { listType: item.type })
- .run();
- } }, { children: (0, jsx_runtime_1.jsx)(ListThumbnail, { listStyleType: item.type }) }), item.title))) }))) }) })));
-}
-const ListTool = react_2.default.memo(_ListTool, (prev, next) => {
- return prev.isActive === next.isActive;
-});
-function NumberedList(props) {
- const { editor } = props;
- const onClick = (0, react_1.useCallback)(() => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleOrderedList().run(); }, []);
- return ((0, jsx_runtime_1.jsx)(ListTool, Object.assign({}, props, { type: "orderedList", isActive: editor.isActive("orderedList"), onClick: onClick, subTypes: [
- { type: "decimal", title: "Decimal", items: ["1", "2", "3"] },
- { type: "upper-alpha", title: "Upper alpha", items: ["A", "B", "C"] },
- { type: "lower-alpha", title: "Lower alpha", items: ["a", "b", "c"] },
- {
- type: "upper-roman",
- title: "Upper Roman",
- items: ["I", "II", "III"],
- },
- {
- type: "lower-roman",
- title: "Lower Roman",
- items: ["i", "ii", "iii"],
- },
- { type: "lower-greek", title: "Lower Greek", items: ["α", "β", "γ"] },
- ] })));
-}
-exports.NumberedList = NumberedList;
-function BulletList(props) {
- const { editor } = props;
- const onClick = (0, react_1.useCallback)(() => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleBulletList().run(); }, []);
- return ((0, jsx_runtime_1.jsx)(ListTool, Object.assign({}, props, { type: "bulletList", onClick: onClick, isActive: editor.isActive("bulletList"), subTypes: [
- { type: "disc", title: "Decimal", items: ["1", "2", "3"] },
- { type: "circle", title: "Upper alpha", items: ["A", "B", "C"] },
- { type: "square", title: "Lower alpha", items: ["a", "b", "c"] },
- ] })));
-}
-exports.BulletList = BulletList;
-function Indent(props) {
- const { editor } = props, toolProps = __rest(props, ["editor"]);
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- const listItemType = (0, prosemirror_1.findListItemType)(editor);
- if (!listItemType || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, toolProps, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().sinkListItem(listItemType).run(); } })));
-}
-exports.Indent = Indent;
-function Outdent(props) {
- const { editor } = props, toolProps = __rest(props, ["editor"]);
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- const listItemType = (0, prosemirror_1.findListItemType)(editor);
- if (!listItemType || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, toolProps, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().liftListItem(listItemType).run(); } })));
-}
-exports.Outdent = Outdent;
-function ListThumbnail(props) {
- const { listStyleType } = props;
- return ((0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ as: "ul", sx: {
- flexDirection: "column",
- flex: 1,
- p: 0,
- listStyleType,
- }, onMouseDown: (e) => e.preventDefault() }, { children: [0, 1, 2].map((i) => ((0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ as: "li", sx: {
- display: "list-item",
- color: "text",
- fontSize: 8,
- mb: "1px",
- } }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ sx: {
- alignItems: "center",
- } }, { children: (0, jsx_runtime_1.jsx)(rebass_1.Box, { sx: {
- width: "100%",
- flexShrink: 0,
- height: 4,
- bg: "#cbcbcb",
- borderRadius: "small",
- } }) })) }), i.toString()))) })));
-}
diff --git a/packages/editor/dist/cjs/toolbar/tools/table.d.ts b/packages/editor/dist/cjs/toolbar/tools/table.d.ts
deleted file mode 100644
index 8a7280fd5..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/table.d.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function TableSettings(props: ToolProps): JSX.Element | null;
-export declare function RowProperties(props: ToolProps): JSX.Element;
-export declare function ColumnProperties(props: ToolProps): JSX.Element;
-export declare function TableProperties(props: ToolProps): JSX.Element;
-export declare function CellProperties(props: ToolProps): JSX.Element;
-export declare function CellBackgroundColor(props: ToolProps): JSX.Element;
-export declare function CellTextColor(props: ToolProps): JSX.Element;
-export declare function CellBorderColor(props: ToolProps): JSX.Element;
-export declare function CellBorderWidth(props: ToolProps): JSX.Element;
-export declare const InsertColumnLeft: (props: ToolProps) => JSX.Element;
-export declare const InsertColumnRight: (props: ToolProps) => JSX.Element;
-export declare const MoveColumnLeft: (props: ToolProps) => JSX.Element;
-export declare const MoveColumnRight: (props: ToolProps) => JSX.Element;
-export declare const DeleteColumn: (props: ToolProps) => JSX.Element;
-export declare const SplitCells: (props: ToolProps) => JSX.Element;
-export declare const MergeCells: (props: ToolProps) => JSX.Element;
-export declare const InsertRowAbove: (props: ToolProps) => JSX.Element;
-export declare const InsertRowBelow: (props: ToolProps) => JSX.Element;
-export declare const MoveRowUp: (props: ToolProps) => JSX.Element;
-export declare const MoveRowDown: (props: ToolProps) => JSX.Element;
-export declare const DeleteRow: (props: ToolProps) => JSX.Element;
-export declare const DeleteTable: (props: ToolProps) => JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/table.js b/packages/editor/dist/cjs/toolbar/tools/table.js
deleted file mode 100644
index 034fd2c95..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/table.js
+++ /dev/null
@@ -1,178 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.DeleteTable = exports.DeleteRow = exports.MoveRowDown = exports.MoveRowUp = exports.InsertRowBelow = exports.InsertRowAbove = exports.MergeCells = exports.SplitCells = exports.DeleteColumn = exports.MoveColumnRight = exports.MoveColumnLeft = exports.InsertColumnRight = exports.InsertColumnLeft = exports.CellBorderWidth = exports.CellBorderColor = exports.CellTextColor = exports.CellBackgroundColor = exports.CellProperties = exports.TableProperties = exports.ColumnProperties = exports.RowProperties = exports.TableSettings = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const react_1 = require("react");
-const rebass_1 = require("rebass");
-const responsive_1 = require("../../components/responsive");
-const actions_1 = require("../../extensions/table/actions");
-const moretools_1 = require("../components/moretools");
-const utils_1 = require("./utils");
-const tooldefinitions_1 = require("../tooldefinitions");
-const cellproperties_1 = require("../popups/cellproperties");
-const colors_1 = require("./colors");
-const counter_1 = require("../components/counter");
-const toolbarstore_1 = require("../stores/toolbarstore");
-const popuppresenter_1 = require("../../components/popuppresenter");
-function TableSettings(props) {
- const { editor } = props;
- const isBottom = (0, toolbarstore_1.useToolbarLocation)() === "bottom";
- if (!editor.isActive("table") || !isBottom)
- return null;
- return ((0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "tableSettings", tools: [
- "insertColumnLeft",
- "insertColumnRight",
- "insertRowAbove",
- "insertRowBelow",
- "cellProperties",
- "columnProperties",
- "rowProperties",
- "deleteRow",
- "deleteColumn",
- "deleteTable",
- ] })));
-}
-exports.TableSettings = TableSettings;
-function RowProperties(props) {
- const { editor } = props;
- const buttonRef = (0, react_1.useRef)();
- const [isMenuOpen, setIsMenuOpen] = (0, react_1.useState)(false);
- const items = (0, react_1.useMemo)(() => [
- insertRowAbove(editor),
- insertRowBelow(editor),
- moveRowUp(editor),
- moveRowDown(editor),
- deleteRow(editor),
- ], []);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { buttonRef: buttonRef, toggled: isMenuOpen, onClick: () => setIsMenuOpen(true) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, { title: "Row properties", mobile: "sheet", desktop: "menu", isOpen: isMenuOpen, onClose: () => setIsMenuOpen(false), position: {
- target: buttonRef.current,
- isTargetAbsolute: true,
- location: "below",
- yOffset: 5,
- }, items: items })] }));
-}
-exports.RowProperties = RowProperties;
-function ColumnProperties(props) {
- const { editor } = props;
- const buttonRef = (0, react_1.useRef)();
- const [isMenuOpen, setIsMenuOpen] = (0, react_1.useState)(false);
- const items = (0, react_1.useMemo)(() => [
- insertColumnLeft(editor),
- insertColumnRight(editor),
- moveColumnLeft(editor),
- moveColumnRight(editor),
- deleteColumn(editor),
- ], []);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { buttonRef: buttonRef, toggled: isMenuOpen, onClick: () => setIsMenuOpen(true) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, { title: "Column properties", mobile: "sheet", desktop: "menu", isOpen: isMenuOpen, onClose: () => setIsMenuOpen(false), position: {
- target: buttonRef.current,
- isTargetAbsolute: true,
- location: "below",
- yOffset: 5,
- }, items: items })] }));
-}
-exports.ColumnProperties = ColumnProperties;
-function TableProperties(props) {
- const { editor } = props;
- const buttonRef = (0, react_1.useRef)();
- const [isMenuOpen, setIsMenuOpen] = (0, react_1.useState)(false);
- const items = (0, react_1.useMemo)(() => [
- insertColumnLeft(editor),
- insertColumnRight(editor),
- moveColumnLeft(editor),
- moveColumnRight(editor),
- deleteColumn(editor),
- { type: "separator", key: "cellSeperator" },
- mergeCells(editor),
- splitCells(editor),
- cellProperties(editor),
- { type: "separator", key: "tableSeperator" },
- deleteTable(editor),
- ], []);
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { buttonRef: buttonRef, toggled: isMenuOpen, onClick: () => setIsMenuOpen(true) })), (0, jsx_runtime_1.jsx)(responsive_1.ResponsivePresenter, { title: "Table properties", mobile: "sheet", desktop: "menu", isOpen: isMenuOpen, onClose: () => setIsMenuOpen(false), position: {
- target: buttonRef.current,
- isTargetAbsolute: true,
- location: "below",
- yOffset: 5,
- }, items: items })] }));
-}
-exports.TableProperties = TableProperties;
-function CellProperties(props) {
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(moretools_1.MoreTools, Object.assign({}, props, { popupId: "cellProperties", tools: [
- "mergeCells",
- "splitCells",
- "cellBackgroundColor",
- "cellTextColor",
- "cellBorderColor",
- "cellBorderWidth",
- ] })) }));
-}
-exports.CellProperties = CellProperties;
-function CellBackgroundColor(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(colors_1.ColorTool, Object.assign({}, props, { cacheKey: "cellBackgroundColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("tableCell").backgroundColor; }, title: "Cell background color", onColorChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().setCellAttribute("backgroundColor", color).run(); } })));
-}
-exports.CellBackgroundColor = CellBackgroundColor;
-function CellTextColor(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(colors_1.ColorTool, Object.assign({}, props, { cacheKey: "cellTextColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("tableCell").color; }, title: "Cell text color", onColorChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setCellAttribute("color", color).run(); } })));
-}
-exports.CellTextColor = CellTextColor;
-function CellBorderColor(props) {
- const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(colors_1.ColorTool, Object.assign({}, props, { cacheKey: "cellBorderColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("tableCell").borderColor; }, title: "Cell border color", onColorChange: (color) => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setCellAttribute("borderColor", color).run();
- } })));
-}
-exports.CellBorderColor = CellBorderColor;
-function CellBorderWidth(props) {
- const { editor } = props;
- const { borderWidth: _borderWidth } = editor.getAttributes("tableCell");
- const borderWidth = _borderWidth ? _borderWidth : 1;
- const decreaseBorderWidth = (0, react_1.useCallback)(() => {
- return Math.max(1, borderWidth - 1);
- }, [borderWidth]);
- const increaseBorderWidth = (0, react_1.useCallback)(() => {
- return Math.min(10, borderWidth + 1);
- }, [borderWidth]);
- return ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: { justifyContent: "center", alignItems: "center" } }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Text, Object.assign({ variant: "subBody", sx: { mx: 1 } }, { children: "Border width:" })), (0, jsx_runtime_1.jsx)(counter_1.Counter, { title: "cell border width", onDecrease: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderWidth", decreaseBorderWidth());
- }, onIncrease: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderWidth", increaseBorderWidth());
- }, onReset: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderWidth", 1); }, value: borderWidth + "px" })] })));
-}
-exports.CellBorderWidth = CellBorderWidth;
-const insertColumnLeft = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("insertColumnLeft")), { key: "addColumnLeft", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addColumnBefore().run(); } }));
-const insertColumnRight = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("insertColumnRight")), { key: "addColumnRight", type: "button", title: "Add column right", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addColumnAfter().run(); }, icon: "insertColumnRight" }));
-const moveColumnLeft = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("moveColumnLeft")), { key: "moveColumnLeft", type: "button", onClick: () => (0, actions_1.moveColumnLeft)(editor) }));
-const moveColumnRight = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("moveColumnRight")), { key: "moveColumnRight", type: "button", onClick: () => (0, actions_1.moveColumnRight)(editor) }));
-const deleteColumn = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("deleteColumn")), { key: "deleteColumn", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().deleteColumn().run(); } }));
-const splitCells = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("splitCells")), { key: "splitCells", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().splitCell().run(); } }));
-const mergeCells = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("mergeCells")), { key: "mergeCells", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().mergeCells().run(); } }));
-const insertRowAbove = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("insertRowAbove")), { key: "insertRowAbove", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addRowBefore().run(); } }));
-const insertRowBelow = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("insertRowBelow")), { key: "insertRowBelow", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addRowAfter().run(); } }));
-const moveRowUp = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("moveRowUp")), { key: "moveRowUp", type: "button", onClick: () => (0, actions_1.moveRowUp)(editor) }));
-const moveRowDown = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("moveRowDown")), { key: "moveRowDown", type: "button", onClick: () => (0, actions_1.moveRowDown)(editor) }));
-const deleteRow = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("deleteRow")), { key: "deleteRow", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().deleteRow().run(); } }));
-const deleteTable = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("deleteTable")), { key: "deleteTable", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().deleteTable().run(); } }));
-const cellProperties = (editor) => (Object.assign(Object.assign({}, (0, tooldefinitions_1.getToolDefinition)("cellProperties")), { key: "cellProperties", type: "button", onClick: () => {
- (0, popuppresenter_1.showPopup)({
- popup: (hide) => (0, jsx_runtime_1.jsx)(cellproperties_1.CellProperties, { onClose: hide, editor: editor }),
- });
- } }));
-exports.InsertColumnLeft = (0, utils_1.menuButtonToTool)(insertColumnLeft);
-exports.InsertColumnRight = (0, utils_1.menuButtonToTool)(insertColumnRight);
-exports.MoveColumnLeft = (0, utils_1.menuButtonToTool)(moveColumnLeft);
-exports.MoveColumnRight = (0, utils_1.menuButtonToTool)(moveColumnRight);
-exports.DeleteColumn = (0, utils_1.menuButtonToTool)(deleteColumn);
-exports.SplitCells = (0, utils_1.menuButtonToTool)(splitCells);
-exports.MergeCells = (0, utils_1.menuButtonToTool)(mergeCells);
-exports.InsertRowAbove = (0, utils_1.menuButtonToTool)(insertRowAbove);
-exports.InsertRowBelow = (0, utils_1.menuButtonToTool)(insertRowBelow);
-exports.MoveRowUp = (0, utils_1.menuButtonToTool)(moveRowUp);
-exports.MoveRowDown = (0, utils_1.menuButtonToTool)(moveRowDown);
-exports.DeleteRow = (0, utils_1.menuButtonToTool)(deleteRow);
-exports.DeleteTable = (0, utils_1.menuButtonToTool)(deleteTable);
diff --git a/packages/editor/dist/cjs/toolbar/tools/textdirection.d.ts b/packages/editor/dist/cjs/toolbar/tools/textdirection.d.ts
deleted file mode 100644
index 1acbfbb23..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/textdirection.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function TextDirection(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/textdirection.js b/packages/editor/dist/cjs/toolbar/tools/textdirection.js
deleted file mode 100644
index 05ee1f1e6..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/textdirection.js
+++ /dev/null
@@ -1,33 +0,0 @@
-"use strict";
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.TextDirection = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-const useRefValue_1 = require("../../hooks/useRefValue");
-function TextDirectionTool(props) {
- const { editor, direction } = props, toolProps = __rest(props, ["editor", "direction"]);
- const directionRef = (0, useRefValue_1.useRefValue)(direction);
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, toolProps, { onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setTextDirection(directionRef.current).run();
- }, toggled: false })));
-}
-function TextDirection(props) {
- const { editor } = props;
- const { textDirection } = Object.assign(Object.assign({}, editor.getAttributes("paragraph")), editor.getAttributes("heading"));
- const newTextDirection = textDirection === "ltr" ? "rtl" : "ltr";
- const icon = textDirection === "ltr" ? "ltr" : "rtl";
- return ((0, jsx_runtime_1.jsx)(TextDirectionTool, Object.assign({ direction: newTextDirection }, props, { icon: icon })));
-}
-exports.TextDirection = TextDirection;
diff --git a/packages/editor/dist/cjs/toolbar/tools/utils.d.ts b/packages/editor/dist/cjs/toolbar/tools/utils.d.ts
deleted file mode 100644
index 6faea73ef..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/utils.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-import { MenuButton } from "../../components/menu/types";
-import { ToolProps } from "../types";
-export declare function menuButtonToTool(constructItem: (editor: Editor) => MenuButton): (props: ToolProps) => JSX.Element;
diff --git a/packages/editor/dist/cjs/toolbar/tools/utils.js b/packages/editor/dist/cjs/toolbar/tools/utils.js
deleted file mode 100644
index 6d30fe29c..000000000
--- a/packages/editor/dist/cjs/toolbar/tools/utils.js
+++ /dev/null
@@ -1,12 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.menuButtonToTool = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const toolbutton_1 = require("../components/toolbutton");
-function menuButtonToTool(constructItem) {
- return function (props) {
- const item = constructItem(props.editor);
- return ((0, jsx_runtime_1.jsx)(toolbutton_1.ToolButton, Object.assign({}, props, { icon: item.icon || props.icon, toggled: item.isChecked || false, title: item.title, onClick: item.onClick })));
- };
-}
-exports.menuButtonToTool = menuButtonToTool;
diff --git a/packages/editor/dist/cjs/toolbar/types.d.ts b/packages/editor/dist/cjs/toolbar/types.d.ts
deleted file mode 100644
index 08982355e..000000000
--- a/packages/editor/dist/cjs/toolbar/types.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Editor } from "../types";
-import { IconNames } from "./icons";
-import { ToolId } from "./tools";
-import { NodeWithOffset } from "./utils/prosemirror";
-export declare type ToolButtonVariant = "small" | "normal";
-export declare type ToolProps = ToolDefinition & {
- editor: Editor;
- variant?: ToolButtonVariant;
- force?: boolean;
- selectedNode?: NodeWithOffset;
-};
-export declare type ToolDefinition = {
- icon: IconNames;
- title: string;
- conditional?: boolean;
- description?: string;
-};
-export declare type ToolbarGroupDefinition = (ToolId | ToolId[])[];
-export declare type ToolbarDefinition = ToolbarGroupDefinition[];
diff --git a/packages/editor/dist/cjs/toolbar/types.js b/packages/editor/dist/cjs/toolbar/types.js
deleted file mode 100644
index c8ad2e549..000000000
--- a/packages/editor/dist/cjs/toolbar/types.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/packages/editor/dist/cjs/toolbar/utils/dom.d.ts b/packages/editor/dist/cjs/toolbar/utils/dom.d.ts
deleted file mode 100644
index e3fdd7ffb..000000000
--- a/packages/editor/dist/cjs/toolbar/utils/dom.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export declare function getToolbarElement(): HTMLElement;
-export declare function getPopupContainer(): HTMLElement;
-export declare function getEditorContainer(): HTMLElement;
-export declare function getEditorDOM(): HTMLElement;
diff --git a/packages/editor/dist/cjs/toolbar/utils/dom.js b/packages/editor/dist/cjs/toolbar/utils/dom.js
deleted file mode 100644
index 5256520c0..000000000
--- a/packages/editor/dist/cjs/toolbar/utils/dom.js
+++ /dev/null
@@ -1,21 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.getEditorDOM = exports.getEditorContainer = exports.getPopupContainer = exports.getToolbarElement = void 0;
-function getToolbarElement() {
- return (document.querySelector(".editor-toolbar") || undefined);
-}
-exports.getToolbarElement = getToolbarElement;
-function getPopupContainer() {
- return (document.getElementById("popup-container") || undefined);
-}
-exports.getPopupContainer = getPopupContainer;
-function getEditorContainer() {
- return (document.querySelector(".editor") ||
- getPopupContainer());
-}
-exports.getEditorContainer = getEditorContainer;
-function getEditorDOM() {
- return (document.querySelector(".ProseMirror") ||
- getEditorContainer()); // ProseMirror
-}
-exports.getEditorDOM = getEditorDOM;
diff --git a/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts b/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts
deleted file mode 100644
index f965c8484..000000000
--- a/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Editor } from "@tiptap/core";
-import { Node as ProsemirrorNode, Mark } from "prosemirror-model";
-import { EditorState } from "prosemirror-state";
-export declare type NodeWithOffset = {
- node?: ProsemirrorNode;
- from: number;
- to: number;
-};
-export declare function findSelectedDOMNode(editor: Editor, types: string[]): HTMLElement | null;
-export declare function findSelectedNode(editor: Editor, type: string): ProsemirrorNode | null;
-export declare function findMark(node: ProsemirrorNode, type: string): Mark | undefined;
-export declare function selectionToOffset(state: EditorState): NodeWithOffset;
-export declare function findListItemType(editor: Editor): string | null;
-export declare function isListActive(editor: Editor): boolean;
diff --git a/packages/editor/dist/cjs/toolbar/utils/prosemirror.js b/packages/editor/dist/cjs/toolbar/utils/prosemirror.js
deleted file mode 100644
index 6e33ec125..000000000
--- a/packages/editor/dist/cjs/toolbar/utils/prosemirror.js
+++ /dev/null
@@ -1,62 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.isListActive = exports.findListItemType = exports.selectionToOffset = exports.findMark = exports.findSelectedNode = exports.findSelectedDOMNode = void 0;
-const core_1 = require("@tiptap/core");
-function findSelectedDOMNode(editor, types) {
- var _a;
- const { $anchor } = editor.state.selection;
- const selectedNode = editor.state.doc.nodeAt($anchor.pos);
- const pos = types.includes((selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.type.name) || "")
- ? $anchor.pos
- : (_a = (0, core_1.findParentNode)((node) => types.includes(node.type.name))(editor.state.selection)) === null || _a === void 0 ? void 0 : _a.pos;
- if (!pos)
- return null;
- return editor.view.nodeDOM(pos) || null;
-}
-exports.findSelectedDOMNode = findSelectedDOMNode;
-function findSelectedNode(editor, type) {
- var _a;
- const { $anchor } = editor.state.selection;
- const selectedNode = editor.state.doc.nodeAt($anchor.pos);
- const pos = (selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.type.name) === type
- ? $anchor.pos
- : (_a = (0, core_1.findParentNode)((node) => node.type.name === type)(editor.state.selection)) === null || _a === void 0 ? void 0 : _a.pos;
- if (!pos)
- return null;
- return editor.state.doc.nodeAt(pos);
-}
-exports.findSelectedNode = findSelectedNode;
-function findMark(node, type) {
- const mark = node.marks.find((m) => m.type.name === type);
- return mark;
-}
-exports.findMark = findMark;
-function selectionToOffset(state) {
- const { $from, from } = state.selection;
- return {
- node: state.doc.nodeAt(from) || undefined,
- from,
- to: from + $from.node().nodeSize,
- };
-}
-exports.selectionToOffset = selectionToOffset;
-function findListItemType(editor) {
- const isTaskList = editor.isActive("taskList");
- const isOutlineList = editor.isActive("outlineList");
- const isList = editor.isActive("bulletList") || editor.isActive("orderedList");
- return isList
- ? "listItem"
- : isOutlineList
- ? "outlineListItem"
- : isTaskList
- ? "taskItem"
- : null;
-}
-exports.findListItemType = findListItemType;
-function isListActive(editor) {
- const isTaskList = editor.isActive("taskList");
- const isOutlineList = editor.isActive("outlineList");
- const isList = editor.isActive("bulletList") || editor.isActive("orderedList");
- return isTaskList || isOutlineList || isList;
-}
-exports.isListActive = isListActive;
diff --git a/packages/editor/dist/cjs/types.d.ts b/packages/editor/dist/cjs/types.d.ts
deleted file mode 100644
index ec55db8df..000000000
--- a/packages/editor/dist/cjs/types.d.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { UnionCommands, Editor as TiptapEditor } from "@tiptap/core";
-export interface PermissionRequestEvent extends CustomEvent<{
- id: keyof UnionCommands;
-}> {
-}
-export declare class Editor extends TiptapEditor {
- /**
- * Use this to get the latest instance of the editor.
- * This is required to reduce unnecessary rerenders of
- * toolbar elements.
- */
- current?: TiptapEditor;
- /**
- * Request permission before executing a command to make sure user
- * is allowed to perform the action.
- * @param id the command id to get permission for
- * @returns latest editor instance
- */
- requestPermission(id: keyof UnionCommands): TiptapEditor | undefined;
-}
diff --git a/packages/editor/dist/cjs/types.js b/packages/editor/dist/cjs/types.js
deleted file mode 100644
index 22070d5fc..000000000
--- a/packages/editor/dist/cjs/types.js
+++ /dev/null
@@ -1,22 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Editor = void 0;
-const core_1 = require("@tiptap/core");
-class Editor extends core_1.Editor {
- /**
- * Request permission before executing a command to make sure user
- * is allowed to perform the action.
- * @param id the command id to get permission for
- * @returns latest editor instance
- */
- requestPermission(id) {
- const event = new CustomEvent("permissionrequest", {
- detail: { id },
- cancelable: true,
- });
- if (!window.dispatchEvent(event))
- return undefined;
- return this.current;
- }
-}
-exports.Editor = Editor;
diff --git a/packages/editor/dist/cjs/utils/config.d.ts b/packages/editor/dist/cjs/utils/config.d.ts
deleted file mode 100644
index 737bfd7e4..000000000
--- a/packages/editor/dist/cjs/utils/config.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-declare function set<T>(key: string, value: T | null): void;
-declare function get<T>(key: string, def?: T): T | undefined;
-export declare const config: {
- set: typeof set;
- get: typeof get;
-};
-export {};
diff --git a/packages/editor/dist/cjs/utils/config.js b/packages/editor/dist/cjs/utils/config.js
deleted file mode 100644
index 9e9e639d9..000000000
--- a/packages/editor/dist/cjs/utils/config.js
+++ /dev/null
@@ -1,25 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.config = void 0;
-function set(key, value) {
- if (!value)
- return window.localStorage.removeItem(key);
- window.localStorage.setItem(key, JSON.stringify(value));
-}
-function get(key, def) {
- const value = window.localStorage.getItem(key);
- if (!value)
- return def;
- return tryParse(value);
-}
-exports.config = { set, get };
-function tryParse(val) {
- if (val === "undefined" || val === "null")
- return;
- try {
- return JSON.parse(val);
- }
- catch (e) {
- return val;
- }
-}
diff --git a/packages/editor/dist/cjs/utils/debounce.d.ts b/packages/editor/dist/cjs/utils/debounce.d.ts
deleted file mode 100644
index aa5951c17..000000000
--- a/packages/editor/dist/cjs/utils/debounce.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare function debounce<F extends (...args: any) => any>(func: F, waitFor: number): (...args: Parameters<F>) => ReturnType<F>;
diff --git a/packages/editor/dist/cjs/utils/debounce.js b/packages/editor/dist/cjs/utils/debounce.js
deleted file mode 100644
index dba6b5144..000000000
--- a/packages/editor/dist/cjs/utils/debounce.js
+++ /dev/null
@@ -1,13 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.debounce = void 0;
-function debounce(func, waitFor) {
- let timeout;
- const debounced = (...args) => {
- if (timeout)
- clearTimeout(timeout);
- timeout = setTimeout(() => func(...args), waitFor);
- };
- return debounced;
-}
-exports.debounce = debounce;
diff --git a/packages/editor/dist/cjs/utils/position.d.ts b/packages/editor/dist/cjs/utils/position.d.ts
deleted file mode 100644
index 85bee69bf..000000000
--- a/packages/editor/dist/cjs/utils/position.d.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-declare type PositionData = {
- x: number;
- y: number;
- actualX: number;
- actualY: number;
- width?: number;
- height?: number;
-};
-export declare type PositionOptions = {
- target?: HTMLElement | "mouse";
- isTargetAbsolute?: boolean;
- location?: "right" | "left" | "below" | "top";
- align?: "center" | "start" | "end";
- yOffset?: number;
- xOffset?: number;
- yAnchor?: HTMLElement;
- parent?: HTMLElement | Element;
-};
-export declare function getPosition(element: HTMLElement, options: PositionOptions): {
- top: number;
- left: number;
-};
-export declare function getElementPosition(element: HTMLElement, absolute: boolean): PositionData;
-export {};
diff --git a/packages/editor/dist/cjs/utils/position.js b/packages/editor/dist/cjs/utils/position.js
deleted file mode 100644
index 16c0fb978..000000000
--- a/packages/editor/dist/cjs/utils/position.js
+++ /dev/null
@@ -1,111 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.getElementPosition = exports.getPosition = void 0;
-const mousePosition = { x: 0, y: 0, actualX: 0, actualY: 0 };
-window.addEventListener("mousemove", (e) => {
- const { x, y, actualX, actualY } = getMousePosition(e);
- mousePosition.x = x;
- mousePosition.y = y;
- mousePosition.actualX = actualX;
- mousePosition.actualY = actualY;
-});
-function getPosition(element, options) {
- const { target = "mouse", isTargetAbsolute = false, location = undefined, yOffset = 0, xOffset = 0, align = "start", parent = document.body, yAnchor, } = options || {};
- const { x, y, width, height, actualX, actualY } = target === "mouse"
- ? mousePosition
- : getElementPosition(target, isTargetAbsolute);
- const elementWidth = element.offsetWidth;
- const elementHeight = element.offsetHeight;
- const windowWidth = parent.clientWidth;
- const windowHeight = parent.clientHeight;
- let position = { top: 0, left: 0 };
- if (windowWidth - actualX < elementWidth) {
- const xDiff = actualX - x;
- position.left = windowWidth - elementWidth;
- position.left -= xDiff;
- }
- else {
- position.left = x;
- }
- if (width && location === "right") {
- position.left += width;
- }
- else if (location === "left")
- position.left -= elementWidth;
- if (actualY + elementHeight > windowHeight) {
- position.top = windowHeight - elementHeight;
- }
- else {
- position.top = y;
- }
- if (height) {
- if (location === "below")
- position.top += height;
- else if (location === "top")
- position.top = y - elementHeight;
- }
- if (width && target !== "mouse" && align === "center" && elementWidth > 0) {
- position.left -= (elementWidth - width) / 2;
- }
- else if (width &&
- target !== "mouse" &&
- align === "end" &&
- elementWidth > 0) {
- position.left -= elementWidth - width;
- }
- // Adjust menu height
- if (elementHeight > windowHeight - position.top) {
- element.style.maxHeight = `${windowHeight - 20}px`;
- }
- if (yAnchor) {
- const anchorY = getElementPosition(yAnchor, isTargetAbsolute);
- position.top = anchorY.y - elementHeight;
- }
- position.top = isTargetAbsolute && position.top < 0 ? 0 : position.top;
- position.left = isTargetAbsolute && position.left < 0 ? 0 : position.left;
- position.top += location === "below" ? yOffset : -yOffset;
- position.left += xOffset;
- return position;
-}
-exports.getPosition = getPosition;
-function getMousePosition(e) {
- var posx = 0;
- var posy = 0;
- if (!e && window.event)
- e = window.event;
- if (e.pageX || e.pageY) {
- posx = e.pageX;
- posy = e.pageY;
- }
- else if (e.clientX || e.clientY) {
- posx =
- e.clientX +
- document.body.scrollLeft +
- document.documentElement.scrollLeft;
- posy =
- e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
- }
- return {
- x: posx,
- y: posy,
- actualY: posy,
- actualX: posx,
- };
-}
-function getElementPosition(element, absolute) {
- const rect = element.getBoundingClientRect();
- const position = {
- x: element.offsetLeft,
- y: element.offsetTop,
- width: rect.width,
- height: rect.height,
- actualY: rect.y,
- actualX: rect.x,
- };
- if (absolute) {
- position.x = position.actualX;
- position.y = position.actualY;
- }
- return position;
-}
-exports.getElementPosition = getElementPosition;
diff --git a/packages/editor/dist/es/components/actionsheet/index.d.ts b/packages/editor/dist/es/components/actionsheet/index.d.ts
deleted file mode 100644
index b3a00090c..000000000
--- a/packages/editor/dist/es/components/actionsheet/index.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { PropsWithChildren } from "react";
-import { MenuItem } from "../menu/types";
-export declare type ActionSheetPresenterProps = {
- items?: MenuItem[];
- isOpen: boolean;
- onClose?: () => void;
- blocking?: boolean;
- focusOnRender?: boolean;
- draggable?: boolean;
- title?: string;
-};
-export declare function ActionSheetPresenter(props: PropsWithChildren<ActionSheetPresenterProps>): JSX.Element | null;
diff --git a/packages/editor/dist/es/components/actionsheet/index.js b/packages/editor/dist/es/components/actionsheet/index.js
deleted file mode 100644
index b32ae1990..000000000
--- a/packages/editor/dist/es/components/actionsheet/index.js
+++ /dev/null
@@ -1,176 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import React, { useCallback, useRef, useState, useEffect, } from "react";
-import { Box, Button, Flex, Text } from "rebass";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { MenuButton } from "../menu/menu-button";
-import { MenuSeparator } from "../menu/menu-separator";
-import Modal from "react-modal";
-import { motion, useMotionValue, useTransform, useAnimation, } from "framer-motion";
-import { useTheme } from "../../toolbar/stores/toolbar-store";
-const AnimatedFlex = motion(Flex);
-const TRANSITION = {
- type: "spring",
- stiffness: 300,
- damping: 30,
- mass: 0.2,
- duration: 300,
-};
-function useHistory(initial) {
- const [current, setCurrent] = useState(initial);
- const [canGoBack, setCanGoBack] = useState(false);
- const stack = useRef([initial]);
- const goBack = useCallback(() => {
- if (!canGoBack)
- return;
- const prev = stack.current.pop();
- setCurrent(prev);
- if (stack.current.length <= 1)
- setCanGoBack(false);
- }, [canGoBack]);
- const navigate = useCallback((state) => {
- console.log("NAVI", state);
- setCurrent((prev) => {
- if (prev)
- stack.current.push(prev);
- return state;
- });
- setCanGoBack(true);
- }, []);
- return { current, goBack, navigate, canGoBack };
-}
-export function ActionSheetPresenter(props) {
- var _a;
- const { isOpen, title, items, onClose, blocking = true, focusOnRender = true, draggable = true, children, } = props;
- const theme = useTheme();
- const contentRef = useRef();
- const y = useMotionValue(0);
- const opacity = useTransform(y, [0, ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || window.innerHeight], [1, 0]);
- const animation = useAnimation();
- const onBeforeClose = useCallback(() => {
- var _a;
- const height = ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || window.innerHeight;
- setTimeout(() => {
- onClose === null || onClose === void 0 ? void 0 : onClose();
- }, TRANSITION.duration - 50);
- animation.start({
- transition: TRANSITION,
- y: height + 100,
- });
- }, [animation, onClose, contentRef.current]);
- const handleBackPress = useCallback((event) => {
- if (!isOpen)
- return;
- event.preventDefault();
- onBeforeClose();
- }, [isOpen, onBeforeClose]);
- useEffect(() => {
- // Note: this is a custom event implemented on the React Native
- // side to handle back button when action sheet is opened.
- window.addEventListener("handleBackPress", handleBackPress);
- return () => {
- window.removeEventListener("handleBackPress", handleBackPress);
- };
- }, [handleBackPress]);
- if (!isOpen)
- return null;
- return (_jsx(Modal, Object.assign({ contentRef: (ref) => (contentRef.current = ref), className: "bottom-sheet-presenter", role: "menu", isOpen: isOpen, appElement: document.body, shouldCloseOnEsc: blocking, shouldReturnFocusAfterClose: focusOnRender, shouldCloseOnOverlayClick: blocking, shouldFocusAfterRender: focusOnRender, ariaHideApp: blocking, preventScroll: blocking, onRequestClose: () => onBeforeClose(), portalClassName: "bottom-sheet-presenter-portal", onAfterOpen: () => {
- console.log("OPEGN!");
- animation.start({ transition: TRANSITION, y: 0 });
- }, overlayElement: (props, contentEl) => {
- return (_jsxs(Box, Object.assign({}, props, {
- //@ts-ignore
- style: Object.assign(Object.assign({}, props.style), { position: blocking ? "fixed" : "sticky", zIndex: 1000, backgroundColor: !blocking ? "transparent" : "unset" }), tabIndex: -1 }, { children: [blocking && (_jsx(motion.div, { id: "action-sheet-overlay", style: {
- height: "100%",
- width: "100%",
- opacity,
- position: "absolute",
- backgroundColor: "var(--overlay)",
- }, tabIndex: -1 })), contentEl] })));
- }, contentElement: (props, children) => (_jsx(Box, Object.assign({}, props, { style: {}, sx: {
- // top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- display: "flex",
- width: "auto",
- height: "fit-content",
- position: "fixed",
- backgroundColor: undefined,
- padding: 0,
- zIndex: 0,
- outline: 0,
- isolation: "isolate",
- } }, { children: children }))) }, { children: _jsxs(AnimatedFlex, Object.assign({ animate: animation, style: { y }, initial: { y: 1000 }, sx: {
- bg: "background",
- borderTopLeftRadius: 15,
- borderTopRightRadius: 15,
- boxShadow: (theme === null || theme === void 0 ? void 0 : theme.shadows.menu) || "none",
- flex: 1,
- flexDirection: "column",
- } }, { children: [draggable && (_jsx(AnimatedFlex, Object.assign({ drag: "y",
- // @ts-ignore
- onDrag: (_, { delta }) => {
- y.set(Math.max(y.get() + delta.y, 0));
- },
- // @ts-ignore
- onDragEnd: (_, { velocity }) => {
- if (velocity.y >= 500) {
- onClose === null || onClose === void 0 ? void 0 : onClose();
- return;
- }
- const sheetEl = contentRef.current;
- const contentHeight = sheetEl.offsetHeight;
- const threshold = 30;
- const closingHeight = (contentHeight * threshold) / 100;
- if (y.get() >= closingHeight) {
- onBeforeClose();
- }
- else {
- animation.start({ transition: TRANSITION, y: 0 });
- }
- }, dragConstraints: { top: 0, bottom: 0 }, dragMomentum: false, dragElastic: false, sx: {
- bg: "transparent",
- alignItems: "center",
- justifyContent: "center",
- p: 2,
- } }, { children: _jsx(Box, { id: "pill", sx: {
- backgroundColor: "hover",
- width: 60,
- height: 8,
- borderRadius: 100,
- } }) }))), _jsx(ContentContainer, Object.assign({ items: items, title: title, onClose: onClose }, { children: children }))] })) })));
-}
-function ContentContainer(props) {
- var _a;
- const { title, items, onClose, children } = props;
- const { current, goBack, canGoBack, navigate } = useHistory({
- title,
- items,
- });
- return (_jsxs(Flex, Object.assign({ sx: { flexDirection: "column" } }, { children: [canGoBack || (current === null || current === void 0 ? void 0 : current.title) ? (_jsxs(Flex, Object.assign({ id: "header", sx: { alignItems: "center", mx: 0, mb: 1 } }, { children: [canGoBack && (_jsx(Button, Object.assign({ variant: "icon", sx: { p: 1, ml: 1 }, onClick: goBack }, { children: _jsx(Icon, { path: Icons.arrowLeft, size: "big" }) }))), (current === null || current === void 0 ? void 0 : current.title) && (_jsx(Text, Object.assign({ variant: "title", sx: { ml: 1, fontSize: "title" } }, { children: current === null || current === void 0 ? void 0 : current.title })))] }))) : null, children
- ? children
- : (_a = current === null || current === void 0 ? void 0 : current.items) === null || _a === void 0 ? void 0 : _a.map((item) => {
- if (item.isHidden)
- return null;
- switch (item.type) {
- case "separator":
- return _jsx(MenuSeparator, {}, item.key);
- case "button":
- return (_jsx(MenuButton, { item: item, onClick: (e) => {
- if (item.menu) {
- navigate(item.menu);
- }
- else if (item.onClick) {
- onClose === null || onClose === void 0 ? void 0 : onClose();
- setTimeout(() => {
- var _a;
- (_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item);
- }, 300);
- }
- } }, item.key));
- case "popup":
- return (_jsx(React.Fragment, { children: _jsx(item.component, { onClick: onClose }) }, item.key));
- }
- })] })));
-}
diff --git a/packages/editor/dist/es/components/button.d.ts b/packages/editor/dist/es/components/button.d.ts
deleted file mode 100644
index 33c39b124..000000000
--- a/packages/editor/dist/es/components/button.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ButtonProps } from "rebass";
-export declare const Button: import("react").ForwardRefExoticComponent<Pick<ButtonProps, "name" | "onFocus" | "onBlur" | "fontSize" | "style" | "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" | "value" | "children" | "cite" | "data" | "form" | "label" | "p" | "slot" | "span" | "summary" | "title" | "pattern" | "key" | "selected" | "sizes" | "variant" | "tx" | "as" | "css" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "paddingX" | "py" | "paddingY" | "size" | "bg" | "sx" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "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" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "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>>;
diff --git a/packages/editor/dist/es/components/button.js b/packages/editor/dist/es/components/button.js
deleted file mode 100644
index 48c152c58..000000000
--- a/packages/editor/dist/es/components/button.js
+++ /dev/null
@@ -1,46 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { forwardRef, useCallback, useRef } from "react";
-import { useEffect } from "react";
-import { Button as RebassButton } from "rebass";
-export const Button = forwardRef((props, forwardedRef) => {
- var _a;
- const { sx } = props, buttonProps = __rest(props, ["sx"]);
- const hoverBg = ((_a = sx === null || sx === void 0 ? void 0 : sx[":hover"]) === null || _a === void 0 ? void 0 : _a["bg"]) || "hover";
- const bg = (sx === null || sx === void 0 ? void 0 : sx["bg"]) || "unset";
- const buttonRef = useRef();
- useEffect(() => {
- if (!buttonRef.current)
- return;
- buttonRef.current.addEventListener("mousedown", onMouseDown, {
- passive: false,
- capture: true,
- });
- return () => {
- var _a;
- (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("mousedown", onMouseDown, {
- capture: true,
- });
- };
- }, []);
- const onMouseDown = useCallback((e) => {
- e.preventDefault();
- }, []);
- return (_jsx(RebassButton, Object.assign({}, buttonProps, { sx: Object.assign(Object.assign({}, sx), { ":hover": { bg: [bg, hoverBg] }, ":active": { bg: hoverBg } }), ref: (ref) => {
- buttonRef.current = ref;
- if (typeof forwardedRef === "function")
- forwardedRef(ref);
- else if (forwardedRef)
- forwardedRef.current = ref;
- }, onClick: props.onClick })));
-});
diff --git a/packages/editor/dist/es/components/inlineinput/index.d.ts b/packages/editor/dist/es/components/inlineinput/index.d.ts
deleted file mode 100644
index d9936bb07..000000000
--- a/packages/editor/dist/es/components/inlineinput/index.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/// <reference types="react" />
-import { InputProps } from "@rebass/forms";
-import { FlexProps } from "rebass";
-declare type LabelInputProps = InputProps & {
- label: string;
- containerProps?: FlexProps;
-};
-export declare function InlineInput(props: LabelInputProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/components/inlineinput/index.js b/packages/editor/dist/es/components/inlineinput/index.js
deleted file mode 100644
index 619e320c8..000000000
--- a/packages/editor/dist/es/components/inlineinput/index.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Input } from "@rebass/forms";
-import { Flex, Text } from "rebass";
-export function InlineInput(props) {
- const { label, containerProps, sx } = props, inputProps = __rest(props, ["label", "containerProps", "sx"]);
- return (_jsxs(Flex, Object.assign({}, containerProps, { sx: Object.assign(Object.assign({ flex: 1 }, containerProps === null || containerProps === void 0 ? void 0 : containerProps.sx), { outline: "1px solid var(--border)", p: 2, borderRadius: "default", ":focus-within": {
- outlineColor: "primary",
- outlineWidth: "1.8px",
- } }) }, { children: [_jsx(Input, Object.assign({ variant: "clean", sx: Object.assign(Object.assign({}, sx), { p: 0 }) }, inputProps)), _jsx(Text, Object.assign({ variant: "body", sx: {
- flexShrink: 0,
- color: "fontTertiary",
- borderLeft: "1px solid var(--border)",
- pl: 1,
- } }, { children: label }))] })));
-}
diff --git a/packages/editor/dist/es/components/menu/index.d.ts b/packages/editor/dist/es/components/menu/index.d.ts
deleted file mode 100644
index 70086f947..000000000
--- a/packages/editor/dist/es/components/menu/index.d.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { PropsWithChildren } from "react";
-import { FlexProps } from "rebass";
-import { MenuItem as MenuItemType } from "./types";
-import { PopupPresenterProps } from "../popup-presenter";
-declare type MenuProps = MenuContainerProps & {
- items?: MenuItemType[];
- onClose: () => void;
-};
-export declare function Menu(props: MenuProps): JSX.Element;
-declare type MenuContainerProps = FlexProps & {
- title?: string;
-};
-export declare type MenuPresenterProps = PopupPresenterProps & MenuProps;
-export declare function MenuPresenter(props: PropsWithChildren<MenuPresenterProps>): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/components/menu/index.js b/packages/editor/dist/es/components/menu/index.js
deleted file mode 100644
index ad1ca07fc..000000000
--- a/packages/editor/dist/es/components/menu/index.js
+++ /dev/null
@@ -1,113 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { useCallback, useRef, useEffect, } from "react";
-import { Box, Flex, Text } from "rebass";
-import { getPosition } from "../../utils/position";
-import { useFocus } from "./use-focus";
-import { MenuSeparator } from "./menu-separator";
-import { MenuButton } from "./menu-button";
-import { PopupPresenter } from "../popup-presenter";
-export function Menu(props) {
- const { items = [], title, onClose } = props, containerProps = __rest(props, ["items", "title", "onClose"]);
- const hoverTimeout = useRef();
- const onAction = useCallback((e, item) => {
- e === null || e === void 0 ? void 0 : e.stopPropagation();
- if (item === null || item === void 0 ? void 0 : item.onClick) {
- item.onClick();
- }
- if (onClose)
- onClose();
- }, [onClose]);
- const { focusIndex, setFocusIndex, isSubmenuOpen, setIsSubmenuOpen } = useFocus(items, (e) => {
- const item = items[focusIndex];
- if (item && item.type === "button")
- onAction(e, item);
- }, () => onClose());
- const focusedItem = items[focusIndex];
- const subMenuRef = useRef(null);
- useEffect(() => {
- const item = items[focusIndex];
- if (!item || !subMenuRef.current)
- return;
- const menuItemElement = document.getElementById(item.key);
- if (!menuItemElement)
- return;
- if (!isSubmenuOpen) {
- subMenuRef.current.style.visibility = "hidden";
- return;
- }
- const { top, left } = getPosition(subMenuRef.current, {
- // yOffset: menuItemElement.offsetHeight,
- target: menuItemElement,
- location: "right",
- });
- subMenuRef.current.style.visibility = "visible";
- subMenuRef.current.style.top = `${top}px`;
- subMenuRef.current.style.left = `${left}px`;
- }, [isSubmenuOpen, focusIndex, items]);
- return (_jsxs(_Fragment, { children: [_jsx(MenuContainer, Object.assign({}, containerProps, { children: items.map((item, index) => {
- if (item.isHidden)
- return null;
- switch (item.type) {
- case "separator":
- return _jsx(MenuSeparator, {}, item.key);
- case "button":
- return (_jsx(MenuButton, { item: item, onClick: (e) => {
- if (item.menu) {
- setFocusIndex(index);
- setIsSubmenuOpen(true);
- }
- else
- onAction(e, item);
- }, isFocused: focusIndex === index, onMouseEnter: () => {
- if (item.isDisabled) {
- setFocusIndex(-1);
- return;
- }
- if (hoverTimeout.current)
- clearTimeout(hoverTimeout.current);
- setFocusIndex(index);
- setIsSubmenuOpen(false);
- if (item.menu) {
- hoverTimeout.current = setTimeout(() => {
- setIsSubmenuOpen(true);
- }, 500);
- }
- }, onMouseLeave: () => {
- if (hoverTimeout.current)
- clearTimeout(hoverTimeout.current);
- } }, item.key));
- case "popup":
- return _jsx(item.component, { onClick: (e) => onAction(e) });
- }
- }) })), (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.type) === "button" && (focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.menu) && isSubmenuOpen && (_jsx(Flex, Object.assign({ ref: subMenuRef, style: { visibility: "hidden" }, sx: {
- position: "absolute",
- } }, { children: _jsx(Menu, { items: focusedItem.menu.items, onClose: onClose }) })))] }));
-}
-function MenuContainer(props) {
- const { children, title, sx } = props, flexProps = __rest(props, ["children", "title", "sx"]);
- return (_jsxs(Box, Object.assign({ className: "menuContainer", as: "ul", tabIndex: -1, sx: Object.assign({ bg: "background", py: 1, display: "flex", flexDirection: "column", position: "relative", listStyle: "none", padding: 0, margin: 0, borderRadius: "default", boxShadow: "menu", border: "1px solid var(--border)", minWidth: 220 }, sx) }, flexProps, { children: [title && (_jsx(Text, Object.assign({ sx: {
- fontFamily: "body",
- fontSize: "subtitle",
- color: "primary",
- py: "8px",
- px: 3,
- borderBottom: "1px solid",
- borderBottomColor: "border",
- wordWrap: "break-word",
- } }, { children: title }))), children] })));
-}
-export function MenuPresenter(props) {
- const { items = [] } = props, restProps = __rest(props, ["items"]);
- return (_jsx(PopupPresenter, Object.assign({}, restProps, { children: props.children ? props.children : _jsx(Menu, Object.assign({ items: items }, restProps)) })));
-}
diff --git a/packages/editor/dist/es/components/menu/menubutton.d.ts b/packages/editor/dist/es/components/menu/menubutton.d.ts
deleted file mode 100644
index 11b6437af..000000000
--- a/packages/editor/dist/es/components/menu/menubutton.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/// <reference types="react" />
-import { MenuButton } from "./types";
-declare type MenuButtonProps = {
- item: MenuButton;
- isFocused?: boolean;
- onMouseEnter?: () => void;
- onMouseLeave?: () => void;
- onClick: (e?: any) => void;
-};
-export declare function MenuButton(props: MenuButtonProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/components/menu/menubutton.js b/packages/editor/dist/es/components/menu/menubutton.js
deleted file mode 100644
index 7652d40fc..000000000
--- a/packages/editor/dist/es/components/menu/menubutton.js
+++ /dev/null
@@ -1,21 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { useRef } from "react";
-import { Flex, Text } from "rebass";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { useToolbarLocation } from "../../toolbar/stores/toolbar-store";
-import { Button } from "../button";
-export function MenuButton(props) {
- const { item, isFocused, onMouseEnter, onMouseLeave, onClick } = props;
- const { title, key, icon, tooltip, isDisabled, isChecked, menu, modifier, styles, } = item;
- const itemRef = useRef(null);
- const toolbarLocation = useToolbarLocation();
- const isBottom = toolbarLocation === "bottom";
- return (_jsx(Flex, Object.assign({ as: "li", sx: { flexShrink: 0, flexDirection: "column" }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, { children: _jsxs(Button, Object.assign({ id: key, "data-test-id": `MenuButton-${key}`, ref: itemRef, tabIndex: -1, variant: "menuitem", title: tooltip, disabled: isDisabled, onClick: onClick, sx: Object.assign(Object.assign({}, styles), { bg: isFocused && !isBottom ? "hover" : "transparent", display: "flex", alignItems: "center", justifyContent: "space-between", ":hover": {
- bg: isBottom ? "transparent" : "hover",
- } }) }, { children: [_jsxs(Flex, Object.assign({ sx: { fontSize: "inherit", fontFamily: "inherit" } }, { children: [icon && (_jsx(Icon, { path: Icons[icon], color: "text", size: "medium", sx: { mr: 2 } })), _jsx(Text, Object.assign({ as: "span", variant: "body", sx: { fontSize: "inherit", fontFamily: "inherit" } }, { children: title }))] })), isChecked || menu || modifier ? (_jsxs(Flex, Object.assign({ sx: { ml: 4 } }, { children: [isChecked && _jsx(Icon, { path: Icons.check, size: "small" }), menu && _jsx(Icon, { path: Icons.chevronRight, size: "small" }), modifier && (_jsx(Text, Object.assign({ as: "span", sx: {
- fontFamily: "body",
- fontSize: "menu",
- color: "fontTertiary",
- } }, { children: modifier })))] }))) : null] }), key) })));
-}
diff --git a/packages/editor/dist/es/components/menu/menuseparator.d.ts b/packages/editor/dist/es/components/menu/menuseparator.d.ts
deleted file mode 100644
index 14ee7a7d6..000000000
--- a/packages/editor/dist/es/components/menu/menuseparator.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-/// <reference types="react" />
-export declare function MenuSeparator(): JSX.Element;
diff --git a/packages/editor/dist/es/components/menu/menuseparator.js b/packages/editor/dist/es/components/menu/menuseparator.js
deleted file mode 100644
index 8e610c345..000000000
--- a/packages/editor/dist/es/components/menu/menuseparator.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { Box } from "rebass";
-export function MenuSeparator() {
- return (_jsx(Box, { as: "li", sx: {
- width: "95%",
- height: "0.5px",
- bg: "border",
- my: 2,
- alignSelf: "center",
- } }));
-}
diff --git a/packages/editor/dist/es/components/menu/types.d.ts b/packages/editor/dist/es/components/menu/types.d.ts
deleted file mode 100644
index c99c27c95..000000000
--- a/packages/editor/dist/es/components/menu/types.d.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/// <reference types="react" />
-import { SxStyleProp } from "rebass";
-import { IconNames } from "../../toolbar/icons";
-declare type MenuItemComponentProps = {
- onClick?: (e?: any) => void;
-};
-export declare type MenuItemTypes = "button" | "separator" | "popup";
-export declare type BaseMenuItem<TType extends MenuItemTypes> = {
- type: TType;
- key: string;
- isHidden?: boolean;
-};
-export declare type MenuSeperator = BaseMenuItem<"separator">;
-export declare type MenuPopup = BaseMenuItem<"popup"> & {
- component: (props: MenuItemComponentProps) => JSX.Element;
-};
-export declare type MenuButton = BaseMenuItem<"button"> & {
- onClick?: () => void;
- title: string;
- icon?: IconNames;
- tooltip?: string;
- isDisabled?: boolean;
- isChecked?: boolean;
- modifier?: string;
- menu?: {
- title: string;
- items: MenuItem[];
- };
- styles?: SxStyleProp;
-};
-export declare type MenuItem = MenuButton | MenuSeperator | MenuPopup;
-export {};
diff --git a/packages/editor/dist/es/components/menu/types.js b/packages/editor/dist/es/components/menu/types.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/packages/editor/dist/es/components/menu/types.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/editor/dist/es/components/menu/usefocus.d.ts b/packages/editor/dist/es/components/menu/usefocus.d.ts
deleted file mode 100644
index 36b4ee2ca..000000000
--- a/packages/editor/dist/es/components/menu/usefocus.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/// <reference types="react" />
-import { MenuItem } from "./types";
-export declare function useFocus(items: MenuItem[], onAction: (event: KeyboardEvent) => void, onClose: (event: KeyboardEvent) => void): {
- focusIndex: number;
- setFocusIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
- isSubmenuOpen: boolean;
- setIsSubmenuOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
-};
diff --git a/packages/editor/dist/es/components/menu/usefocus.js b/packages/editor/dist/es/components/menu/usefocus.js
deleted file mode 100644
index a5362f4e5..000000000
--- a/packages/editor/dist/es/components/menu/usefocus.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import { useCallback, useEffect, useState } from "react";
-export function useFocus(items, onAction, onClose) {
- const [focusIndex, setFocusIndex] = useState(-1);
- const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
- const moveItemIntoView = useCallback((index) => {
- const item = items[index];
- if (!item)
- return;
- const element = document.getElementById(item.key);
- if (!element)
- return;
- element.scrollIntoView({
- behavior: "auto",
- });
- }, [items]);
- const onKeyDown = useCallback((e) => {
- const as = (i) => items[i];
- const isSeperator = (i) => {
- var _a, _b;
- return items &&
- (((_a = items[i]) === null || _a === void 0 ? void 0 : _a.type) === "separator" || ((_b = as(i)) === null || _b === void 0 ? void 0 : _b.isDisabled));
- };
- const moveDown = (i) => (i < items.length - 1 ? ++i : 0);
- const moveUp = (i) => (i > 0 ? --i : items.length - 1);
- const hasSubmenu = (i) => items && as(i).menu;
- const openSubmenu = (index) => {
- if (!hasSubmenu(index))
- return;
- setIsSubmenuOpen(true);
- };
- const closeSubmenu = (index) => {
- if (!hasSubmenu(index))
- return;
- setIsSubmenuOpen(false);
- };
- setFocusIndex((i) => {
- let nextIndex = i;
- switch (e.key) {
- case "ArrowUp":
- if (isSubmenuOpen)
- break;
- nextIndex = moveUp(i);
- while (isSeperator(nextIndex)) {
- nextIndex = moveUp(nextIndex);
- }
- break;
- case "ArrowDown":
- if (isSubmenuOpen)
- break;
- nextIndex = moveDown(i);
- while (isSeperator(nextIndex)) {
- nextIndex = moveDown(nextIndex);
- }
- break;
- case "ArrowRight":
- openSubmenu(i);
- break;
- case "ArrowLeft":
- closeSubmenu(i);
- break;
- case "Enter":
- onAction && onAction(e);
- break;
- case "Escape":
- onClose && onClose(e);
- break;
- default:
- break;
- }
- if (nextIndex !== i)
- moveItemIntoView(nextIndex);
- return nextIndex;
- });
- }, [items, isSubmenuOpen, moveItemIntoView, onAction]);
- useEffect(() => {
- window.addEventListener("keydown", onKeyDown);
- return () => {
- window.removeEventListener("keydown", onKeyDown);
- };
- }, [onKeyDown]);
- return { focusIndex, setFocusIndex, isSubmenuOpen, setIsSubmenuOpen };
-}
diff --git a/packages/editor/dist/es/components/popuppresenter/index.d.ts b/packages/editor/dist/es/components/popuppresenter/index.d.ts
deleted file mode 100644
index bb3b88ac2..000000000
--- a/packages/editor/dist/es/components/popuppresenter/index.d.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { PropsWithChildren } from "react";
-import { PositionOptions } from "../../utils/position";
-import React from "react";
-import { ResponsivePresenterProps } from "../responsive";
-export declare type PopupPresenterProps = {
- isOpen: boolean;
- onClose: () => void;
- position: PositionOptions;
- blocking?: boolean;
- focusOnRender?: boolean;
- movable?: boolean;
-};
-export declare function PopupPresenter(props: PropsWithChildren<PopupPresenterProps>): JSX.Element | null;
-export declare type PopupWrapperProps = UsePopupHandlerOptions & {
- autoCloseOnUnmount?: boolean;
- position: PositionOptions;
- renderPopup: (closePopup: () => void) => React.ReactNode;
-} & Partial<Omit<PopupPresenterProps, "onClose">>;
-export declare function PopupWrapper(props: PopupWrapperProps): null;
-declare type UsePopupHandlerOptions = {
- id: string;
- group: string;
- isOpen: boolean;
- onClosed?: () => void;
-};
-export declare function usePopupHandler(options: UsePopupHandlerOptions): {
- isPopupOpen: boolean;
- closePopup: (popupId: string) => void;
-};
-declare type ShowPopupOptions = {
- popup: (closePopup: () => void) => React.ReactNode;
-} & Partial<ResponsivePresenterProps>;
-export declare function showPopup(options: ShowPopupOptions): () => void;
-export {};
diff --git a/packages/editor/dist/es/components/popuppresenter/index.js b/packages/editor/dist/es/components/popuppresenter/index.js
deleted file mode 100644
index 161ec516e..000000000
--- a/packages/editor/dist/es/components/popuppresenter/index.js
+++ /dev/null
@@ -1,227 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { useCallback, useRef, useEffect, } from "react";
-import { Box } from "rebass";
-import { getPosition } from "../../utils/position";
-import Modal from "react-modal";
-import ReactDOM from "react-dom";
-import { getPopupContainer, getToolbarElement } from "../../toolbar/utils/dom";
-import { useIsMobile, useToolbarStore, } from "../../toolbar/stores/toolbar-store";
-import { EditorContext, usePopupRenderer, } from "./popuprenderer";
-import { ResponsivePresenter } from "../responsive";
-import { ThemeProvider } from "../theme-provider";
-function _PopupPresenter(props) {
- const { isOpen, position, onClose, blocking = true, focusOnRender = true, children, } = props;
- const isMobile = useIsMobile();
- const contentRef = useRef();
- const observerRef = useRef();
- const repositionPopup = useCallback(() => {
- if (!contentRef.current || !position)
- return;
- const popup = contentRef.current;
- const popupPosition = getPosition(popup, position);
- popup.style.top = popupPosition.top + "px";
- popup.style.left = popupPosition.left + "px";
- }, [position]);
- useEffect(() => {
- repositionPopup();
- }, [position]);
- useEffect(() => {
- function onWindowResize() {
- repositionPopup();
- }
- window.addEventListener("resize", onWindowResize);
- return () => {
- window.removeEventListener("resize", onWindowResize);
- };
- }, []);
- const attachMoveHandlers = useCallback(() => {
- if (!contentRef.current || !isOpen)
- return;
- const movableBar = contentRef.current.querySelector(".movable");
- if (!movableBar)
- return;
- const popup = contentRef.current;
- var offset = { x: 0, y: 0 };
- function mouseDown(e) {
- offset.x = e.clientX - popup.offsetLeft;
- offset.y = e.clientY - popup.offsetTop;
- window.addEventListener("mousemove", mouseMove);
- }
- function mouseMove(e) {
- if (!e.buttons)
- mouseUp();
- var top = e.clientY - offset.y;
- var left = e.clientX - offset.x;
- requestAnimationFrame(() => {
- popup.style.top = top + "px";
- popup.style.left = left + "px";
- });
- }
- function mouseUp() {
- window.removeEventListener("mousemove", mouseMove);
- }
- movableBar.addEventListener("mousedown", mouseDown);
- window.addEventListener("mouseup", mouseUp);
- }, [isOpen]);
- const handleResize = useCallback(() => {
- const popup = contentRef.current;
- if (!popup)
- return;
- let oldHeight = popup.offsetHeight;
- observerRef.current = new ResizeObserver((e) => {
- if (isMobile) {
- repositionPopup();
- }
- else {
- const { height, y } = popup.getBoundingClientRect();
- const delta = height - oldHeight;
- if (delta > 0) {
- // means the new size is bigger so we need to adjust the position
- // if required. We only do this in case the newly resized popup
- // is going out of the window.
- const windowHeight = document.body.clientHeight - 20;
- if (y + height > windowHeight) {
- popup.style.top = windowHeight - height + "px";
- }
- }
- oldHeight = height;
- }
- });
- observerRef.current.observe(popup, { box: "border-box" });
- }, [isMobile]);
- return (_jsx(Modal, Object.assign({ contentRef: (ref) => (contentRef.current = ref), className: "popup-presenter", role: "menu", isOpen: isOpen, appElement: document.body, shouldCloseOnEsc: true, shouldReturnFocusAfterClose: true, shouldCloseOnOverlayClick: true, shouldFocusAfterRender: focusOnRender, ariaHideApp: blocking, preventScroll: blocking, onRequestClose: onClose, portalClassName: "popup-presenter-portal", onAfterOpen: (obj) => {
- if (!obj || !position)
- return;
- repositionPopup();
- handleResize();
- attachMoveHandlers();
- }, onAfterClose: () => { var _a; return (_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect(); }, overlayElement: (props, contentEl) => {
- return (_jsx(Box, Object.assign({}, props, {
- //@ts-ignore
- style: Object.assign(Object.assign({}, props.style), { position: !blocking ? "initial" : "fixed", zIndex: 1000, backgroundColor: !blocking ? "transparent" : "unset" }) }, { children: contentEl })));
- }, contentElement: (props, children) => (_jsx(Box, Object.assign({}, props, { style: {},
- // TODO onMouseDown={(e) => {
- // console.log(e);
- // }}
- sx: {
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- display: "flex",
- width: "fit-content",
- height: "fit-content",
- position: "fixed",
- backgroundColor: undefined,
- padding: 0,
- zIndex: 0,
- outline: 0,
- isolation: "isolate",
- } }, { children: children }))), style: {
- content: {},
- overlay: {
- zIndex: 999,
- background: "transparent",
- },
- } }, { children: children })));
-}
-export function PopupPresenter(props) {
- // HACK: we don't want to render the popup presenter for no reason
- // including it's effects etc. so we just wrap it and return null
- // if the popup is closed.
- if (!props.isOpen)
- return null;
- return _jsx(_PopupPresenter, Object.assign({}, props));
-}
-export function PopupWrapper(props) {
- let { id, group, position, renderPopup, isOpen, onClosed, autoCloseOnUnmount } = props, presenterProps = __rest(props, ["id", "group", "position", "renderPopup", "isOpen", "onClosed", "autoCloseOnUnmount"]);
- const PopupRenderer = usePopupRenderer();
- const { closePopup, isPopupOpen } = usePopupHandler(props);
- useEffect(() => {
- if (!autoCloseOnUnmount)
- return;
- return () => {
- PopupRenderer === null || PopupRenderer === void 0 ? void 0 : PopupRenderer.closePopup(id);
- };
- }, [autoCloseOnUnmount, id, PopupRenderer]);
- useEffect(() => {
- if (PopupRenderer && isPopupOpen) {
- PopupRenderer.openPopup(id, function Popup({ id }) {
- const isPopupOpen = useToolbarStore((store) => !!store.openedPopups[id]);
- useEffect(() => {
- if (!isPopupOpen) {
- PopupRenderer.closePopup(id);
- }
- }, [isPopupOpen]);
- return (_jsx(PopupPresenter, Object.assign({ isOpen: isPopupOpen, onClose: () => closePopup(id), position: position, blocking: true, focusOnRender: true }, presenterProps, { children: _jsx(Box, Object.assign({ sx: {
- boxShadow: "menu",
- borderRadius: "default",
- overflow: "hidden",
- // width,
- } }, { children: _jsx(EditorContext.Consumer, { children: () => {
- return renderPopup(() => PopupRenderer.closePopup(id));
- } }) })) }), id));
- });
- }
- }, [PopupRenderer, isPopupOpen]);
- return null;
-}
-export function usePopupHandler(options) {
- let { group, isOpen, id, onClosed } = options;
- const isPopupOpen = useToolbarStore((store) => !!store.openedPopups[id]);
- const openPopup = useToolbarStore((store) => store.openPopup);
- const closePopup = useToolbarStore((store) => store.closePopup);
- const closePopupGroup = useToolbarStore((store) => store.closePopupGroup);
- const isBottom = useToolbarStore((store) => store.toolbarLocation === "bottom");
- if (isBottom)
- group = "popup";
- useEffect(() => {
- if (isOpen)
- openPopup({ id, group });
- else
- closePopup(id);
- }, [isOpen, id, group, openPopup, closePopup]);
- useEffect(() => {
- if (!isPopupOpen)
- onClosed === null || onClosed === void 0 ? void 0 : onClosed();
- }, [isPopupOpen]);
- useEffect(() => {
- if (isPopupOpen) {
- closePopupGroup(group, [id]);
- }
- }, [onClosed, isPopupOpen, closePopupGroup, id, group]);
- useEffect(() => {
- if (!isOpen)
- closePopup(id);
- }, [isOpen, id, group, closePopup]);
- return { isPopupOpen, closePopup };
-}
-export function showPopup(options) {
- const { popup } = options, props = __rest(options, ["popup"]);
- function hide() {
- ReactDOM.unmountComponentAtNode(getPopupContainer());
- }
- ReactDOM.render(_jsx(ThemeProvider, { children: _jsx(ResponsivePresenter, Object.assign({ isOpen: true, position: {
- target: getToolbarElement(),
- isTargetAbsolute: true,
- location: "below",
- align: "end",
- yOffset: 10,
- }, blocking: true, focusOnRender: true }, props, { onClose: () => {
- var _a;
- hide();
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
- } }, { children: popup(hide) })) }), getPopupContainer());
- return hide;
-}
diff --git a/packages/editor/dist/es/components/popuppresenter/popuprenderer.d.ts b/packages/editor/dist/es/components/popuppresenter/popuprenderer.d.ts
deleted file mode 100644
index 6a837ff5f..000000000
--- a/packages/editor/dist/es/components/popuppresenter/popuprenderer.d.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import React, { PropsWithChildren } from "react";
-import { Editor } from "@tiptap/core";
-export declare const PopupRendererContext: React.Context<PopupRenderer | null>;
-export declare const EditorContext: React.Context<Editor | null>;
-export declare type PopupRendererProps = PropsWithChildren<{
- editor: Editor;
-}>;
-declare type PopupComponent = React.FunctionComponent<{
- id: string;
-}>;
-declare type PopupRendererState = {
- popups: {
- id: string;
- popup: PopupComponent;
- }[];
-};
-export declare class PopupRenderer extends React.Component<PopupRendererProps, PopupRendererState, PopupRendererState> {
- popupContainer: HTMLDivElement | null;
- state: PopupRendererState;
- openPopup: (id: string, popup: PopupComponent) => void;
- closePopup: (id: string) => void;
- render(): React.ReactNode;
-}
-export declare function usePopupRenderer(): PopupRenderer | null;
-export declare function useEditorContext(): Editor;
-export {};
diff --git a/packages/editor/dist/es/components/popuppresenter/popuprenderer.js b/packages/editor/dist/es/components/popuppresenter/popuprenderer.js
deleted file mode 100644
index fc2126d58..000000000
--- a/packages/editor/dist/es/components/popuppresenter/popuprenderer.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import React, { useContext } from "react";
-export const PopupRendererContext = React.createContext(null);
-export const EditorContext = React.createContext(null);
-export class PopupRenderer extends React.Component {
- constructor() {
- super(...arguments);
- this.popupContainer = null;
- this.state = {
- popups: [],
- };
- this.openPopup = (id, popup) => {
- if (!popup)
- return;
- this.setState((prev) => {
- return {
- popups: [...prev.popups, { id, popup }],
- };
- });
- };
- this.closePopup = (id) => {
- this.setState((prev) => {
- const index = prev.popups.findIndex((p) => p.id === id);
- if (index <= -1)
- return prev;
- const clone = prev.popups.slice();
- clone.splice(index, 1);
- return {
- popups: clone,
- };
- });
- };
- }
- render() {
- return (_jsxs(PopupRendererContext.Provider, Object.assign({ value: this }, { children: [this.props.children, _jsxs(EditorContext.Provider, Object.assign({ value: this.props.editor }, { children: [this.state.popups.map(({ id, popup: Popup }) => {
- return _jsx(Popup, { id: id }, id);
- }), _jsx("div", { id: "popup-container" })] }))] })));
- }
-}
-export function usePopupRenderer() {
- return useContext(PopupRendererContext);
-}
-export function useEditorContext() {
- return useContext(EditorContext);
-}
diff --git a/packages/editor/dist/es/components/resizer/index.d.ts b/packages/editor/dist/es/components/resizer/index.d.ts
deleted file mode 100644
index 08792a319..000000000
--- a/packages/editor/dist/es/components/resizer/index.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { PropsWithChildren } from "react";
-import { Editor } from "../../types";
-declare type ResizerProps = {
- editor: Editor;
- selected: boolean;
- width?: number;
- height?: number;
- onResize: (width: number, height: number) => void;
-};
-export declare function Resizer(props: PropsWithChildren<ResizerProps>): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/components/resizer/index.js b/packages/editor/dist/es/components/resizer/index.js
deleted file mode 100644
index 3de68f90b..000000000
--- a/packages/editor/dist/es/components/resizer/index.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { Resizable } from "re-resizable";
-import { Icon, Icons } from "../../toolbar";
-export function Resizer(props) {
- const { editor, selected, onResize, width, height, children } = props;
- return (_jsx(Resizable, Object.assign({ enable: {
- bottom: false,
- left: false,
- right: false,
- top: false,
- bottomLeft: false,
- bottomRight: editor.isEditable && selected,
- topLeft: false,
- topRight: false,
- }, size: {
- height: height || "auto",
- width: width || "auto",
- }, maxWidth: "100%", minWidth: 150, minHeight: 150, handleComponent: {
- bottomRight: (_jsx(Icon, { sx: {
- width: 25,
- height: 25,
- marginLeft: -17,
- marginTop: "3px",
- borderTopLeftRadius: "default",
- borderBottomRightRadius: "default",
- }, path: Icons.resize, size: 25, color: "primary" })),
- }, onResizeStop: (e, direction, ref, d) => {
- try {
- onResize(ref.clientWidth, ref.clientHeight);
- }
- catch (_a) {
- // ignore
- }
- }, lockAspectRatio: true }, { children: children })));
-}
diff --git a/packages/editor/dist/es/components/responsive/index.d.ts b/packages/editor/dist/es/components/responsive/index.d.ts
deleted file mode 100644
index f734f5329..000000000
--- a/packages/editor/dist/es/components/responsive/index.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { PropsWithChildren } from "react";
-import { ActionSheetPresenterProps } from "../action-sheet";
-import { MenuPresenterProps } from "../menu";
-declare type ResponsiveContainerProps = {
- mobile?: JSX.Element;
- desktop?: JSX.Element;
-};
-export declare function ResponsiveContainer(props: ResponsiveContainerProps): JSX.Element | null;
-export declare function DesktopOnly(props: PropsWithChildren<{}>): JSX.Element;
-export declare function MobileOnly(props: PropsWithChildren<{}>): JSX.Element;
-export declare type PopupType = "sheet" | "menu" | "none";
-export declare type ResponsivePresenterProps = MenuPresenterProps & ActionSheetPresenterProps & {
- mobile?: PopupType;
- desktop?: PopupType;
-};
-export declare function ResponsivePresenter(props: PropsWithChildren<ResponsivePresenterProps>): JSX.Element | null;
-export {};
diff --git a/packages/editor/dist/es/components/responsive/index.js b/packages/editor/dist/es/components/responsive/index.js
deleted file mode 100644
index b8a4be0c8..000000000
--- a/packages/editor/dist/es/components/responsive/index.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
-import { useIsMobile, } from "../../toolbar/stores/toolbar-store";
-import { ActionSheetPresenter, } from "../action-sheet";
-import { MenuPresenter } from "../menu";
-export function ResponsiveContainer(props) {
- const isMobile = useIsMobile();
- if (isMobile)
- return props.mobile || null;
- else
- return props.desktop || null;
-}
-export function DesktopOnly(props) {
- return _jsx(ResponsiveContainer, { desktop: _jsx(_Fragment, { children: props.children }) });
-}
-export function MobileOnly(props) {
- return _jsx(ResponsiveContainer, { mobile: _jsx(_Fragment, { children: props.children }) });
-}
-export function ResponsivePresenter(props) {
- const { mobile = "menu", desktop = "menu" } = props, restProps = __rest(props, ["mobile", "desktop"]);
- const isMobile = useIsMobile();
- if (isMobile && mobile === "sheet")
- return _jsx(ActionSheetPresenter, Object.assign({}, restProps));
- else if (mobile === "menu" || desktop === "menu")
- return _jsx(MenuPresenter, Object.assign({}, restProps));
- else
- return props.isOpen ? _jsx(_Fragment, { children: props.children }) : null;
-}
diff --git a/packages/editor/dist/es/components/tabs/index.d.ts b/packages/editor/dist/es/components/tabs/index.d.ts
deleted file mode 100644
index 28e7a9dac..000000000
--- a/packages/editor/dist/es/components/tabs/index.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import React, { PropsWithChildren } from "react";
-import { FlexProps } from "rebass";
-export declare type TabProps = {
- title: string | React.ReactElement;
-};
-export declare function Tab(props: PropsWithChildren<TabProps>): JSX.Element;
-export declare type TabsProps = {
- activeIndex: number;
- containerProps?: FlexProps;
- onTabChanged?: (index: number) => void;
-};
-export declare function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element;
diff --git a/packages/editor/dist/es/components/tabs/index.js b/packages/editor/dist/es/components/tabs/index.js
deleted file mode 100644
index a0b1262a3..000000000
--- a/packages/editor/dist/es/components/tabs/index.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import React, { Children, useMemo, useState } from "react";
-import { Button, Flex } from "rebass";
-export function Tab(props) {
- return _jsx(_Fragment, { children: props.children });
-}
-export function Tabs(props) {
- const { activeIndex, children, containerProps, onTabChanged } = props;
- const [activeTab, setActiveTab] = useState(activeIndex || 0);
- const tabs = useMemo(() => Children.map(children, (child) => {
- if (React.isValidElement(child))
- return { title: child.props.title, component: child };
- }), [children]);
- return (_jsxs(Flex, Object.assign({ sx: { flexDirection: "column" } }, { children: [_jsx(Flex, Object.assign({ sx: {
- mb: 1,
- } }, { children: tabs === null || tabs === void 0 ? void 0 : tabs.map((tab, index) => (_jsx(Button, Object.assign({ sx: {
- flex: 1,
- p: 0,
- py: 1,
- borderRadius: 0,
- borderTopLeftRadius: "default",
- borderTopRightRadius: "default",
- bg: activeTab === index ? "bgSecondary" : "transparent",
- fontWeight: activeTab === index ? "bold" : "normal",
- color: "text",
- ":last-of-type": { mr: 0 },
- borderBottom: "2px solid",
- borderBottomColor: activeTab === index ? "primary" : "transparent",
- ":hover": {
- bg: "hover",
- },
- }, onClick: () => {
- setActiveTab(index);
- onTabChanged === null || onTabChanged === void 0 ? void 0 : onTabChanged(index);
- } }, { children: tab.title }), index.toString()))) })), _jsx(Flex, Object.assign({}, containerProps, { children: tabs && tabs[activeTab].component }))] })));
-}
diff --git a/packages/editor/dist/es/components/themeprovider/index.d.ts b/packages/editor/dist/es/components/themeprovider/index.d.ts
deleted file mode 100644
index 8941a4054..000000000
--- a/packages/editor/dist/es/components/themeprovider/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { PropsWithChildren } from "react";
-export declare function ThemeProvider(props: PropsWithChildren<{}>): JSX.Element;
diff --git a/packages/editor/dist/es/components/themeprovider/index.js b/packages/editor/dist/es/components/themeprovider/index.js
deleted file mode 100644
index c14262159..000000000
--- a/packages/editor/dist/es/components/themeprovider/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { ThemeProvider as EmotionThemeProvider } from "emotion-theming";
-import { useTheme } from "../../toolbar/stores/toolbar-store";
-export function ThemeProvider(props) {
- const theme = useTheme();
- return (_jsx(EmotionThemeProvider, Object.assign({ theme: theme || {} }, { children: props.children })));
-}
diff --git a/packages/editor/dist/es/extensions.d.ts b/packages/editor/dist/es/extensions.d.ts
deleted file mode 100644
index 04757fdce..000000000
--- a/packages/editor/dist/es/extensions.d.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import "@tiptap/extension-character-count";
-import "@tiptap/extension-placeholder";
-import "@tiptap/extension-underline";
-import "@tiptap/starter-kit";
-import "@tiptap/extension-text-align";
-import "@tiptap/extension-subscript";
-import "@tiptap/extension-superscript";
-import "./extensions/font-size";
-import "./extensions/text-direction";
-import "@tiptap/extension-text-style";
-import "@tiptap/extension-font-family";
-import "./extensions/bullet-list";
-import "./extensions/ordered-list";
-import "@tiptap/extension-highlight";
-import "@tiptap/extension-color";
-import "@tiptap/extension-table-row";
-import "./extensions/table-cell";
-import "@tiptap/extension-table-header";
-import "./extensions/image";
-import "./extensions/attachment";
-import "./extensions/task-list";
-import "./extensions/task-item";
-import "./extensions/drop-cursor";
-import "./extensions/search-replace";
-import "./extensions/embed";
-import "./extensions/code-block";
-import "./extensions/list-item";
-import "./extensions/outline-list";
-import "./extensions/outline-list-item";
-import "./extensions/table";
diff --git a/packages/editor/dist/es/extensions.js b/packages/editor/dist/es/extensions.js
deleted file mode 100644
index 04757fdce..000000000
--- a/packages/editor/dist/es/extensions.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import "@tiptap/extension-character-count";
-import "@tiptap/extension-placeholder";
-import "@tiptap/extension-underline";
-import "@tiptap/starter-kit";
-import "@tiptap/extension-text-align";
-import "@tiptap/extension-subscript";
-import "@tiptap/extension-superscript";
-import "./extensions/font-size";
-import "./extensions/text-direction";
-import "@tiptap/extension-text-style";
-import "@tiptap/extension-font-family";
-import "./extensions/bullet-list";
-import "./extensions/ordered-list";
-import "@tiptap/extension-highlight";
-import "@tiptap/extension-color";
-import "@tiptap/extension-table-row";
-import "./extensions/table-cell";
-import "@tiptap/extension-table-header";
-import "./extensions/image";
-import "./extensions/attachment";
-import "./extensions/task-list";
-import "./extensions/task-item";
-import "./extensions/drop-cursor";
-import "./extensions/search-replace";
-import "./extensions/embed";
-import "./extensions/code-block";
-import "./extensions/list-item";
-import "./extensions/outline-list";
-import "./extensions/outline-list-item";
-import "./extensions/table";
diff --git a/packages/editor/dist/es/extensions/attachment/attachment.d.ts b/packages/editor/dist/es/extensions/attachment/attachment.d.ts
deleted file mode 100644
index cd34695f5..000000000
--- a/packages/editor/dist/es/extensions/attachment/attachment.d.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Node, Editor } from "@tiptap/core";
-import { Attribute } from "@tiptap/core";
-export declare type AttachmentType = "image" | "file" | "camera";
-export interface AttachmentOptions {
- HTMLAttributes: Record<string, any>;
- onDownloadAttachment: (editor: Editor, attachment: Attachment) => boolean;
- onOpenAttachmentPicker: (editor: Editor, type: AttachmentType) => boolean;
-}
-export declare type AttachmentWithProgress = AttachmentProgress & Attachment;
-export declare type Attachment = {
- hash: string;
- filename: string;
- type: string;
- size: number;
-};
-export declare type AttachmentProgress = {
- progress: number;
- type: "upload" | "download" | "encrypt";
- hash: string;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- attachment: {
- openAttachmentPicker: (type: AttachmentType) => ReturnType;
- insertAttachment: (attachment: Attachment) => ReturnType;
- removeAttachment: () => ReturnType;
- downloadAttachment: (attachment: Attachment) => ReturnType;
- setAttachmentProgress: (progress: AttachmentProgress) => ReturnType;
- };
- }
-}
-export declare const AttachmentNode: Node<AttachmentOptions, any>;
-export declare function getDataAttribute(name: string, def?: any | null): Partial<Attribute>;
diff --git a/packages/editor/dist/es/extensions/attachment/attachment.js b/packages/editor/dist/es/extensions/attachment/attachment.js
deleted file mode 100644
index be1094a10..000000000
--- a/packages/editor/dist/es/extensions/attachment/attachment.js
+++ /dev/null
@@ -1,111 +0,0 @@
-import { Node, mergeAttributes, findChildren } from "@tiptap/core";
-import { createSelectionBasedNodeView } from "../react";
-import { AttachmentComponent } from "./component";
-export const AttachmentNode = Node.create({
- name: "attachment",
- content: "inline*",
- marks: "",
- inline: true,
- atom: true,
- addOptions() {
- return {
- HTMLAttributes: {},
- onDownloadAttachment: () => false,
- onOpenAttachmentPicker: () => false,
- };
- },
- group() {
- return "inline";
- },
- draggable: true,
- addAttributes() {
- return {
- progress: {
- default: 0,
- rendered: false,
- },
- hash: getDataAttribute("hash"),
- filename: getDataAttribute("filename"),
- type: getDataAttribute("mime"),
- size: getDataAttribute("size"),
- };
- },
- parseHTML() {
- return [
- {
- tag: "span[data-hash]",
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "span",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
- ];
- },
- addNodeView() {
- return createSelectionBasedNodeView(AttachmentComponent, {
- shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
- return prev.progress !== next.progress;
- },
- });
- },
- addCommands() {
- return {
- insertAttachment: (attachment) => ({ commands }) => {
- return commands.insertContent({
- type: this.name,
- attrs: attachment,
- });
- },
- removeAttachment: () => ({ commands, tr }) => {
- return commands.deleteSelection();
- },
- downloadAttachment: (attachment) => ({ editor }) => {
- return this.options.onDownloadAttachment(editor, attachment);
- },
- openAttachmentPicker: (type) => ({ editor }) => {
- return this.options.onOpenAttachmentPicker(editor, type);
- },
- setAttachmentProgress: (options) => ({ state, tr, dispatch }) => {
- const { hash, progress, type } = options;
- const attachments = findChildren(state.doc, (node) => (node.type.name === this.name || node.type.name === "image") &&
- node.attrs.hash === hash);
- for (const attachment of attachments) {
- tr.setNodeMarkup(attachment.pos, attachment.node.type, Object.assign(Object.assign({}, attachment.node.attrs), { progress: progress === 100 ? null : progress }));
- }
- tr.setMeta("preventUpdate", true);
- tr.setMeta("addToHistory", false);
- if (dispatch)
- dispatch(tr);
- return true;
- },
- };
- },
- // addInputRules() {
- // return [
- // nodeInputRule({
- // find: inputRegex,
- // type: this.type,
- // getAttributes: (match) => {
- // const [, , alt, src, title] = match;
- // return { src, alt, title };
- // },
- // }),
- // ];
- // },
-});
-export function getDataAttribute(name, def) {
- return {
- default: def,
- parseHTML: (element) => element.dataset[name],
- renderHTML: (attributes) => {
- if (!attributes[name]) {
- return {};
- }
- return {
- [`data-${name}`]: attributes[name],
- };
- },
- };
-}
diff --git a/packages/editor/dist/es/extensions/attachment/component.d.ts b/packages/editor/dist/es/extensions/attachment/component.d.ts
deleted file mode 100644
index ea57c55f9..000000000
--- a/packages/editor/dist/es/extensions/attachment/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { AttachmentWithProgress } from "./attachment";
-import { SelectionBasedReactNodeViewProps } from "../react";
-export declare function AttachmentComponent(props: SelectionBasedReactNodeViewProps<AttachmentWithProgress>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/attachment/component.js b/packages/editor/dist/es/extensions/attachment/component.js
deleted file mode 100644
index 11590223b..000000000
--- a/packages/editor/dist/es/extensions/attachment/component.js
+++ /dev/null
@@ -1,56 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { Box, Text } from "rebass";
-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) {
- const { editor, node, selected } = props;
- const { hash, filename, size, progress } = node.attrs;
- const elementRef = useRef();
- return (_jsx(_Fragment, { children: _jsxs(Box, Object.assign({ ref: elementRef, as: "span", contentEditable: false, variant: "body", sx: {
- display: "inline-flex",
- position: "relative",
- justifyContent: "center",
- userSelect: "none",
- alignItems: "center",
- backgroundColor: "bgSecondary",
- px: 1,
- borderRadius: "default",
- border: "1px solid var(--border)",
- cursor: "pointer",
- maxWidth: 250,
- borderColor: selected ? "primary" : "border",
- ":hover": {
- bg: "hover",
- },
- }, title: filename }, { children: [_jsx(Icon, { path: Icons.attachment, size: 14 }), _jsx(Text, Object.assign({ as: "span", sx: {
- ml: "small",
- fontSize: "body",
- whiteSpace: "nowrap",
- textOverflow: "ellipsis",
- overflow: "hidden",
- } }, { children: filename })), _jsx(Text, Object.assign({ as: "span", sx: {
- ml: 1,
- fontSize: "0.65rem",
- color: "fontTertiary",
- flexShrink: 0,
- } }, { children: progress ? `${progress}%` : formatBytes(size) })), _jsx(DesktopOnly, { children: selected && (_jsx(ToolbarGroup, { editor: editor, tools: ["removeAttachment", "downloadAttachment"], sx: {
- boxShadow: "menu",
- borderRadius: "default",
- bg: "background",
- position: "absolute",
- top: -35,
- } })) })] })) }));
-}
-function formatBytes(bytes, decimals = 1) {
- if (bytes === 0)
- return "0B";
- const k = 1024;
- const dm = decimals < 0 ? 0 : decimals;
- const sizes = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
- const i = Math.floor(Math.log(bytes) / Math.log(k));
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + sizes[i];
-}
diff --git a/packages/editor/dist/es/extensions/attachment/index.d.ts b/packages/editor/dist/es/extensions/attachment/index.d.ts
deleted file mode 100644
index 9f9f38860..000000000
--- a/packages/editor/dist/es/extensions/attachment/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./attachment";
diff --git a/packages/editor/dist/es/extensions/attachment/index.js b/packages/editor/dist/es/extensions/attachment/index.js
deleted file mode 100644
index 9f9f38860..000000000
--- a/packages/editor/dist/es/extensions/attachment/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./attachment";
diff --git a/packages/editor/dist/es/extensions/bulletlist/bulletlist.d.ts b/packages/editor/dist/es/extensions/bulletlist/bulletlist.d.ts
deleted file mode 100644
index 803ad33bd..000000000
--- a/packages/editor/dist/es/extensions/bulletlist/bulletlist.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const BulletList: import("@tiptap/core").Node<import("@tiptap/extension-bullet-list").BulletListOptions, any>;
diff --git a/packages/editor/dist/es/extensions/bulletlist/bulletlist.js b/packages/editor/dist/es/extensions/bulletlist/bulletlist.js
deleted file mode 100644
index 6c4c889b0..000000000
--- a/packages/editor/dist/es/extensions/bulletlist/bulletlist.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import TiptapBulletList from "@tiptap/extension-bullet-list";
-export const BulletList = TiptapBulletList.extend({
- addAttributes() {
- return {
- listType: {
- default: null,
- parseHTML: (element) => element.style.listStyleType,
- renderHTML: (attributes) => {
- if (!attributes.listType) {
- return {};
- }
- return {
- style: `list-style-type: ${attributes.listType}`,
- };
- },
- },
- };
- },
-});
diff --git a/packages/editor/dist/es/extensions/bulletlist/index.d.ts b/packages/editor/dist/es/extensions/bulletlist/index.d.ts
deleted file mode 100644
index c732326f2..000000000
--- a/packages/editor/dist/es/extensions/bulletlist/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { BulletList } from "./bullet-list";
-export * from "./bullet-list";
-export default BulletList;
diff --git a/packages/editor/dist/es/extensions/bulletlist/index.js b/packages/editor/dist/es/extensions/bulletlist/index.js
deleted file mode 100644
index c732326f2..000000000
--- a/packages/editor/dist/es/extensions/bulletlist/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { BulletList } from "./bullet-list";
-export * from "./bullet-list";
-export default BulletList;
diff --git a/packages/editor/dist/es/extensions/codeblock/codeblock.d.ts b/packages/editor/dist/es/extensions/codeblock/codeblock.d.ts
deleted file mode 100644
index 19f8d3e16..000000000
--- a/packages/editor/dist/es/extensions/codeblock/codeblock.d.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { Node } from "@tiptap/core";
-import { Selection } from "prosemirror-state";
-import { Node as ProsemirrorNode } from "prosemirror-model";
-interface Indent {
- type: "tab" | "space";
- amount: number;
-}
-export declare type CodeBlockAttributes = {
- indentType: Indent["type"];
- indentLength: number;
- language: string;
- lines: CodeLine[];
- caretPosition?: CaretPosition;
-};
-export interface CodeBlockOptions {
- /**
- * Adds a prefix to language classes that are applied to code tags.
- * Defaults to `'language-'`.
- */
- languageClassPrefix: string;
- /**
- * Define whether the node should be exited on triple enter.
- * Defaults to `true`.
- */
- exitOnTripleEnter: boolean;
- /**
- * Define whether the node should be exited on arrow down if there is no node after it.
- * Defaults to `true`.
- */
- exitOnArrowDown: boolean;
- /**
- * Define whether the node should be exited on arrow up if there is no node before it.
- * Defaults to `true`.
- */
- exitOnArrowUp: boolean;
- /**
- * Custom HTML attributes that should be added to the rendered HTML tag.
- */
- HTMLAttributes: Record<string, any>;
-}
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- codeblock: {
- /**
- * Set a code block
- */
- setCodeBlock: (attributes?: {
- language: string;
- }) => ReturnType;
- /**
- * Toggle a code block
- */
- toggleCodeBlock: (attributes?: {
- language: string;
- }) => ReturnType;
- /**
- * Change code block indentation options
- */
- changeCodeBlockIndentation: (options: Indent) => ReturnType;
- };
- }
-}
-export declare const backtickInputRegex: RegExp;
-export declare const tildeInputRegex: RegExp;
-export declare const CodeBlock: Node<CodeBlockOptions, any>;
-export declare type CaretPosition = {
- column: number;
- line: number;
- selected?: number;
- total: number;
- from: number;
-};
-export declare function toCaretPosition(selection: Selection, lines?: CodeLine[]): CaretPosition | undefined;
-export declare function getLines(node: ProsemirrorNode): CodeLine[];
-declare type CodeLine = {
- index: number;
- from: number;
- to: number;
- length: number;
- text: (length?: number) => string;
-};
-export declare function toCodeLines(code: string, pos: number): CodeLine[];
-export {};
diff --git a/packages/editor/dist/es/extensions/codeblock/codeblock.js b/packages/editor/dist/es/extensions/codeblock/codeblock.js
deleted file mode 100644
index 396ef5428..000000000
--- a/packages/editor/dist/es/extensions/codeblock/codeblock.js
+++ /dev/null
@@ -1,522 +0,0 @@
-import { findParentNodeClosestToPos } from "@tiptap/core";
-import { Node, textblockTypeInputRule, mergeAttributes } from "@tiptap/core";
-import { Plugin, PluginKey, TextSelection, } from "prosemirror-state";
-import { CodeblockComponent } from "./component";
-import { HighlighterPlugin } from "./highlighter";
-import { createNodeView } from "../react";
-import detectIndent from "detect-indent";
-import redent from "redent";
-import stripIndent from "strip-indent";
-export const backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
-export const tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
-const ZERO_WIDTH_SPACE = "\u200b";
-const NEWLINE = "\n";
-export const CodeBlock = Node.create({
- name: "codeblock",
- addOptions() {
- return {
- languageClassPrefix: "language-",
- exitOnTripleEnter: true,
- exitOnArrowDown: true,
- exitOnArrowUp: true,
- HTMLAttributes: {},
- };
- },
- content: "text*",
- marks: "",
- group: "block",
- code: true,
- defining: true,
- addAttributes() {
- return {
- caretPosition: {
- default: undefined,
- rendered: false,
- },
- lines: {
- default: [],
- rendered: false,
- },
- indentType: {
- default: "space",
- parseHTML: (element) => {
- const indentType = element.dataset.indentType;
- return indentType;
- },
- renderHTML: (attributes) => {
- if (!attributes.indentType) {
- return {};
- }
- return {
- "data-indent-type": attributes.indentType,
- };
- },
- },
- indentLength: {
- default: 2,
- parseHTML: (element) => {
- const indentLength = element.dataset.indentLength;
- return indentLength;
- },
- renderHTML: (attributes) => {
- if (!attributes.indentLength) {
- return {};
- }
- return {
- "data-indent-length": attributes.indentLength,
- };
- },
- },
- language: {
- default: null,
- parseHTML: (element) => {
- var _a;
- const { languageClassPrefix } = this.options;
- const classNames = [
- ...(element.classList || []),
- ...(((_a = element === null || element === void 0 ? void 0 : element.firstElementChild) === null || _a === void 0 ? void 0 : _a.classList) || []),
- ];
- const languages = classNames
- .filter((className) => className.startsWith(languageClassPrefix))
- .map((className) => className.replace(languageClassPrefix, ""));
- const language = languages[0];
- if (!language) {
- return null;
- }
- return language;
- },
- renderHTML: (attributes) => {
- if (!attributes.language) {
- return {};
- }
- return {
- class: `language-${attributes.language}`,
- };
- },
- },
- };
- },
- parseHTML() {
- return [
- {
- tag: "pre",
- preserveWhitespace: "full",
- // contentElement: (node) => {
- // if (node instanceof HTMLElement) {
- // node.innerText = node.innerText.replaceAll("\n\u200b\n", "\n\n");
- // }
- // return node;
- // },
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "pre",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
- ["code", {}, 0],
- ];
- },
- addCommands() {
- return {
- setCodeBlock: (attributes) => ({ commands }) => {
- return commands.setNode(this.name, attributes);
- },
- toggleCodeBlock: (attributes) => ({ commands }) => {
- console.log("TOGGLING!");
- return commands.toggleNode(this.name, "paragraph", attributes);
- },
- changeCodeBlockIndentation: (options) => ({ editor, tr, commands }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from } = selection;
- if ($from.parent.type !== this.type) {
- return false;
- }
- const { lines } = $from.parent.attrs;
- for (const line of lines) {
- const text = line.text();
- const whitespaceLength = text.length - text.trimStart().length;
- if (!whitespaceLength)
- continue;
- const indentLength = whitespaceLength;
- const indentToken = indent({
- type: options.type,
- amount: indentLength,
- });
- tr.insertText(indentToken, tr.mapping.map(line.from), tr.mapping.map(line.from + whitespaceLength));
- }
- commands.updateAttributes(this.type, {
- indentType: options.type,
- indentLength: options.amount,
- });
- return true;
- },
- };
- },
- addKeyboardShortcuts() {
- return {
- "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
- "Mod-a": ({ editor }) => {
- const { $anchor } = this.editor.state.selection;
- if ($anchor.parent.type.name !== this.name) {
- return false;
- }
- const codeblock = findParentNodeClosestToPos($anchor, (node) => node.type.name === this.type.name);
- if (!codeblock)
- return false;
- return editor.commands.setTextSelection({
- from: codeblock.pos + 1,
- to: codeblock.pos + codeblock.node.nodeSize - 1,
- });
- },
- // remove code block when at start of document or code block is empty
- Backspace: () => {
- const { empty, $anchor } = this.editor.state.selection;
- const currentNode = $anchor.parent;
- const nextNode = this.editor.state.doc.nodeAt($anchor.pos + 1);
- const isCodeBlock = (node) => node && node.type.name === this.name;
- const isAtStart = $anchor.pos === 1;
- if (!empty) {
- return false;
- }
- if (isAtStart ||
- (isCodeBlock(currentNode) && !currentNode.textContent.length)) {
- return this.editor.commands.deleteNode(this.type);
- }
- // on android due to composition issues with various keyboards,
- // sometimes backspace is detected one node behind. We need to
- // manually handle this case.
- else if (nextNode &&
- isCodeBlock(nextNode) &&
- !nextNode.textContent.length) {
- return this.editor.commands.command(({ tr }) => {
- tr.delete($anchor.pos + 1, $anchor.pos + 1 + nextNode.nodeSize);
- return true;
- });
- }
- return false;
- },
- // exit node on triple enter
- Enter: ({ editor }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from, empty } = selection;
- if (!empty || $from.parent.type !== this.type) {
- return false;
- }
- const indentation = parseIndentation($from.parent);
- return ((this.options.exitOnTripleEnter &&
- exitOnTripleEnter(editor, $from)) ||
- indentOnEnter(editor, $from, indentation));
- },
- // exit node on arrow up
- ArrowUp: ({ editor }) => {
- if (!this.options.exitOnArrowUp) {
- return false;
- }
- const { state } = editor;
- const { selection } = state;
- const { $anchor, empty } = selection;
- if (!empty || $anchor.parent.type !== this.type) {
- return false;
- }
- const isAtStart = $anchor.pos === 1;
- if (!isAtStart) {
- return false;
- }
- return editor.commands.insertContentAt(0, "<p></p>");
- },
- // exit node on arrow down
- ArrowDown: ({ editor }) => {
- if (!this.options.exitOnArrowDown) {
- return false;
- }
- const { state } = editor;
- const { selection, doc } = state;
- const { $from, empty } = selection;
- if (!empty || $from.parent.type !== this.type) {
- return false;
- }
- const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
- if (!isAtEnd) {
- return false;
- }
- const after = $from.after();
- if (after === undefined) {
- return false;
- }
- const nodeAfter = doc.nodeAt(after);
- if (nodeAfter) {
- editor.commands.setNodeSelection($from.before());
- return false;
- }
- return editor.commands.exitCode();
- },
- "Shift-Tab": ({ editor }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from } = selection;
- if ($from.parent.type !== this.type) {
- return false;
- }
- const indentation = parseIndentation($from.parent);
- const indentToken = indent(indentation);
- const { lines } = $from.parent.attrs;
- const selectedLines = getSelectedLines(lines, selection);
- return editor
- .chain()
- .command(({ tr }) => withSelection(tr, (tr) => {
- for (const line of selectedLines) {
- if (line.text(indentToken.length) !== indentToken)
- continue;
- tr.delete(tr.mapping.map(line.from), tr.mapping.map(line.from + indentation.amount));
- }
- }))
- .run();
- },
- Tab: ({ editor }) => {
- const { state } = editor;
- const { selection } = state;
- const { $from } = selection;
- if ($from.parent.type !== this.type) {
- return false;
- }
- const { lines } = $from.parent.attrs;
- const selectedLines = getSelectedLines(lines, selection);
- return editor
- .chain()
- .command(({ tr }) => withSelection(tr, (tr) => {
- const indentToken = indent(parseIndentation($from.parent));
- if (selectedLines.length === 1)
- return tr.insertText(indentToken, $from.pos);
- for (const line of selectedLines) {
- tr.insertText(indentToken, tr.mapping.map(line.from));
- }
- }))
- .run();
- },
- };
- },
- addInputRules() {
- return [
- textblockTypeInputRule({
- find: backtickInputRegex,
- type: this.type,
- getAttributes: (match) => ({
- language: match[1],
- }),
- }),
- textblockTypeInputRule({
- find: tildeInputRegex,
- type: this.type,
- getAttributes: (match) => ({
- language: match[1],
- }),
- }),
- ];
- },
- addProseMirrorPlugins() {
- return [
- // this plugin creates a code block for pasted content from VS Code
- // we can also detect the copied code language
- new Plugin({
- key: new PluginKey("codeBlockVSCodeHandler"),
- props: {
- handlePaste: (view, event) => {
- if (!event.clipboardData) {
- return false;
- }
- const text = event.clipboardData.getData("text/plain");
- const vscode = event.clipboardData.getData("vscode-editor-data");
- const vscodeData = vscode ? JSON.parse(vscode) : undefined;
- const language = vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;
- if (!text || !language) {
- return false;
- }
- const indent = fixIndentation(text, parseIndentation(view.state.selection.$from.parent));
- const { tr } = view.state;
- // create an empty code block if not already within one
- if (!this.editor.isActive(this.type.name)) {
- tr.replaceSelectionWith(this.type.create({
- language,
- indentType: indent.type,
- indentLength: indent.amount,
- }));
- }
- // // put cursor inside the newly created code block
- // tr.setSelection(
- // TextSelection.near(
- // tr.doc.resolve(Math.max(0, tr.selection.from - 2))
- // )
- // );
- // add text to code block
- // strip carriage return chars from text pasted as code
- // see: https://github.com/ProseMirror/prosemirror-view/commit/a50a6bcceb4ce52ac8fcc6162488d8875613aacd
- tr.insertText(indent.code.replace(/\r\n?/g, "\n"));
- // store meta information
- // this is useful for other plugins that depends on the paste event
- // like the paste rule plugin
- tr.setMeta("paste", true);
- view.dispatch(tr);
- return true;
- },
- },
- }),
- HighlighterPlugin({ name: this.name, defaultLanguage: "txt" }),
- ];
- },
- addNodeView() {
- return createNodeView(CodeblockComponent, {
- contentDOMFactory: () => {
- const content = document.createElement("div");
- content.classList.add("node-content-wrapper");
- content.style.whiteSpace = "inherit";
- // caret is not visible if content element width is 0px
- content.style.minWidth = `20px`;
- return { dom: content };
- },
- shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
- return (compareCaretPosition(prev.caretPosition, next.caretPosition) ||
- prev.language !== next.language ||
- prev.indentType !== next.indentType);
- },
- });
- },
-});
-export function toCaretPosition(selection, lines) {
- const { $from, $to, $head } = selection;
- if ($from.parent.type.name !== CodeBlock.name)
- return;
- lines = lines || getLines($from.parent);
- for (const line of lines) {
- if ($head.pos >= line.from && $head.pos <= line.to) {
- const lineLength = line.length + 1;
- return {
- line: line.index + 1,
- column: lineLength - (line.to - $head.pos),
- selected: $to.pos - $from.pos,
- total: lines.length,
- from: line.from,
- };
- }
- }
- return;
-}
-export function getLines(node) {
- const { lines } = node.attrs;
- return lines || [];
-}
-function exitOnTripleEnter(editor, $from) {
- const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
- const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
- if (!isAtEnd || !endsWithDoubleNewline) {
- return false;
- }
- return editor
- .chain()
- .command(({ tr }) => {
- tr.delete($from.pos - 2, $from.pos);
- return true;
- })
- .exitCode()
- .run();
-}
-function indentOnEnter(editor, $from, options) {
- const { indentation, newline } = getNewline($from, options) || {};
- if (!newline)
- return false;
- return editor
- .chain()
- .insertContent(`${newline}${indentation}`, {
- parseOptions: { preserveWhitespace: "full" },
- })
- .focus()
- .run();
-}
-function getNewline($from, options) {
- const { lines } = $from.parent.attrs;
- const currentLine = getLineAt(lines, $from.pos);
- if (!currentLine)
- return false;
- const text = currentLine.text();
- const indentLength = text.length - text.trimStart().length;
- return {
- newline: NEWLINE,
- indentation: indent({ amount: indentLength, type: options.type }),
- };
-}
-export function toCodeLines(code, pos) {
- const positions = [];
- let start = 0;
- let from = pos + 1;
- let index = 0;
- while (start <= code.length) {
- let end = code.indexOf("\n", start);
- if (end <= -1)
- end = code.length;
- const lineLength = end - start;
- const to = from + lineLength;
- const lineStart = start;
- positions.push({
- index,
- length: lineLength,
- from,
- to,
- text: (length) => {
- return code.slice(lineStart, length ? lineStart + length : lineStart + lineLength);
- },
- });
- from = to + 1;
- start = end + 1;
- ++index;
- }
- return positions;
-}
-function getSelectedLines(lines, selection) {
- const { $from, $to } = selection;
- return lines.filter((line) => inRange(line.from, $from.pos, $to.pos) ||
- inRange(line.to, $from.pos, $to.pos) ||
- inRange($from.pos, line.from, line.to));
-}
-function parseIndentation(node) {
- if (node.type.name !== CodeBlock.name)
- return undefined;
- const { indentType, indentLength } = node.attrs;
- return {
- type: indentType,
- amount: parseInt(indentLength),
- };
-}
-function getLineAt(lines, pos) {
- return lines.find((line) => pos >= line.from && pos <= line.to);
-}
-function inRange(x, a, b) {
- return x >= a && x <= b;
-}
-function indent(options) {
- const char = options.type === "space" ? " " : "\t";
- return char.repeat(options.amount);
-}
-function compareCaretPosition(prev, next) {
- return (next === undefined ||
- (prev === null || prev === void 0 ? void 0 : prev.column) !== (next === null || next === void 0 ? void 0 : next.column) ||
- (prev === null || prev === void 0 ? void 0 : prev.line) !== (next === null || next === void 0 ? void 0 : next.line));
-}
-/**
- * Persist selection between transaction steps
- */
-function withSelection(tr, callback) {
- const { $anchor, $head } = tr.selection;
- callback(tr);
- tr.setSelection(new TextSelection(tr.doc.resolve(tr.mapping.map($anchor.pos)), tr.doc.resolve(tr.mapping.map($head.pos))));
- return true;
-}
-function fixIndentation(code, indent) {
- const { amount, type = "space" } = indent || detectIndent(code);
- const fixed = redent(code, amount, {
- includeEmptyLines: false,
- indent: type === "space" ? " " : "\t",
- });
- return { code: stripIndent(fixed), amount, type };
-}
diff --git a/packages/editor/dist/es/extensions/codeblock/component.d.ts b/packages/editor/dist/es/extensions/codeblock/component.d.ts
deleted file mode 100644
index cb8de2a9a..000000000
--- a/packages/editor/dist/es/extensions/codeblock/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { CodeBlockAttributes } from "./code-block";
-import { ReactNodeViewProps } from "../react/types";
-export declare function CodeblockComponent(props: ReactNodeViewProps<CodeBlockAttributes>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/codeblock/component.js b/packages/editor/dist/es/extensions/codeblock/component.js
deleted file mode 100644
index 11264b527..000000000
--- a/packages/editor/dist/es/extensions/codeblock/component.js
+++ /dev/null
@@ -1,143 +0,0 @@
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { useEffect, useRef, useState } from "react";
-import { isLanguageLoaded, loadLanguage } from "./loader";
-import { refractor } from "refractor/lib/core";
-import { Flex, Text } from "rebass";
-import Languages from "./languages.json";
-import { Input } from "@rebass/forms";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { ResponsivePresenter } from "../../components/responsive";
-import { Popup } from "../../toolbar/components/popup";
-import { Button } from "../../components/button";
-export function CodeblockComponent(props) {
- const { editor, updateAttributes, node, forwardRef } = props;
- const { language, indentLength, indentType, caretPosition } = node === null || node === void 0 ? void 0 : node.attrs;
- const [isOpen, setIsOpen] = useState(false);
- // const [caretPosition, setCaretPosition] = useState<CaretPosition>();
- const toolbarRef = useRef(null);
- const languageDefinition = Languages.find((l) => { var _a; return l.filename === language || ((_a = l.alias) === null || _a === void 0 ? void 0 : _a.some((a) => a === language)); });
- useEffect(() => {
- (function () {
- return __awaiter(this, void 0, void 0, function* () {
- if (!language || !languageDefinition || isLanguageLoaded(language))
- return;
- const syntax = yield loadLanguage(languageDefinition.filename);
- if (!syntax)
- return;
- refractor.register(syntax);
- const preventUpdate = language === languageDefinition.filename;
- updateAttributes({
- language: languageDefinition.filename
- }, { preventUpdate, addToHistory: false });
- });
- })();
- }, [language]);
- return (_jsxs(_Fragment, { children: [_jsxs(Flex, Object.assign({ sx: {
- flexDirection: "column",
- borderRadius: "default",
- overflow: "hidden"
- } }, { children: [_jsx(Text, { ref: forwardRef, as: "pre", autoCorrect: "off", autoCapitalize: "none", sx: {
- "div, span.token, span.line-number-widget, span.line-number::before": {
- fontFamily: "monospace",
- fontSize: "code",
- whiteSpace: "pre !important",
- tabSize: 1
- },
- position: "relative",
- lineHeight: "20px",
- bg: "codeBg",
- color: "static",
- overflowX: "auto",
- display: "flex",
- px: 2,
- pt: 2,
- pb: 1
- }, spellCheck: false }), _jsxs(Flex, Object.assign({ ref: toolbarRef, contentEditable: false, sx: {
- bg: "codeBg",
- alignItems: "center",
- justifyContent: "flex-end",
- borderTop: "1px solid var(--codeBorder)"
- } }, { children: [caretPosition ? (_jsxs(Text, Object.assign({ variant: "subBody", sx: { mr: 2, color: "codeFg" } }, { children: ["Line ", caretPosition.line, ", Column ", caretPosition.column, " ", caretPosition.selected
- ? `(${caretPosition.selected} selected)`
- : ""] }))) : null, _jsx(Button, Object.assign({ variant: "icon", sx: { p: 1, mr: 1, ":hover": { bg: "codeSelection" } }, title: "Toggle indentation mode", onClick: () => {
- editor.commands.changeCodeBlockIndentation({
- type: indentType === "space" ? "tab" : "space",
- amount: indentLength
- });
- } }, { children: _jsxs(Text, Object.assign({ variant: "subBody", sx: { color: "codeFg" } }, { children: [indentType === "space" ? "Spaces" : "Tabs", ": ", indentLength] })) })), _jsx(Button, Object.assign({ variant: "icon", sx: {
- p: 1,
- mr: 1,
- bg: isOpen ? "codeSelection" : "transparent",
- ":hover": { bg: "codeSelection" }
- }, onClick: () => {
- setIsOpen(true);
- }, title: "Change language" }, { children: _jsx(Text, Object.assign({ variant: "subBody", spellCheck: false, sx: { color: "codeFg" } }, { children: (languageDefinition === null || languageDefinition === void 0 ? void 0 : languageDefinition.title) || "Plaintext" })) }))] }))] })), _jsx(ResponsivePresenter, Object.assign({ isOpen: isOpen, onClose: () => {
- setIsOpen(false);
- // NOTE: for some reason the language selection action sheet
- // does not return focus to the last focused position after
- // closing. We have to set focusOnRender=false & manually
- // restore focus. I think this has something to do with custom
- // node views.
- // TRY: perhaps use SelectionBasedReactNodeView?
- editor.commands.focus();
- }, focusOnRender: false, mobile: "sheet", desktop: "menu", position: {
- target: toolbarRef.current || undefined,
- align: "end",
- isTargetAbsolute: true,
- location: "top",
- yOffset: 5
- }, title: "Change code block language" }, { children: _jsx(LanguageSelector, { selectedLanguage: (languageDefinition === null || languageDefinition === void 0 ? void 0 : languageDefinition.filename) || "Plaintext", onLanguageSelected: (language) => {
- updateAttributes({ language }, { addToHistory: true, preventUpdate: false });
- setIsOpen(false);
- }, onClose: () => setIsOpen(false) }) }))] }));
-}
-function LanguageSelector(props) {
- const { onLanguageSelected, selectedLanguage, onClose } = props;
- const [languages, setLanguages] = useState(Languages);
- return (_jsx(Popup, Object.assign({ title: "Select language", onClose: onClose }, { children: _jsxs(Flex, Object.assign({ sx: {
- flexDirection: "column",
- height: 200,
- width: ["auto", 300],
- overflowY: "auto",
- bg: "background"
- } }, { children: [_jsx(Input, { onFocus: () => {
- console.log("EHLLO!");
- }, autoFocus: true, placeholder: "Search languages", sx: {
- width: "auto",
- position: "sticky",
- top: 0,
- bg: "background",
- mx: 2,
- p: "7px",
- zIndex: 999
- }, onChange: (e) => {
- if (!e.target.value)
- return setLanguages(Languages);
- const query = e.target.value.toLowerCase();
- setLanguages(Languages.filter((lang) => {
- var _a;
- return (lang.title.toLowerCase().indexOf(query) > -1 ||
- ((_a = lang.alias) === null || _a === void 0 ? void 0 : _a.some((alias) => alias.toLowerCase().indexOf(query) > -1)));
- }));
- } }), _jsx(Flex, Object.assign({ sx: {
- flexDirection: "column",
- pt: 1,
- mt: 1
- } }, { children: languages.map((lang) => (_jsxs(Button, Object.assign({ variant: "menuitem", sx: {
- textAlign: "left",
- py: 1,
- display: "flex",
- justifyContent: "space-between",
- alignItems: "center"
- }, onClick: () => onLanguageSelected(lang.filename) }, { children: [_jsx(Text, Object.assign({ variant: "body" }, { children: lang.title })), selectedLanguage === lang.filename ? (_jsx(Icon, { path: Icons.check, size: "small" })) : lang.alias ? (_jsx(Text, Object.assign({ variant: "subBody", sx: { fontSize: "10px" } }, { children: lang.alias.slice(0, 3).join(", ") }))) : null] }), lang.title))) }))] })) })));
-}
diff --git a/packages/editor/dist/es/extensions/codeblock/highlighter.d.ts b/packages/editor/dist/es/extensions/codeblock/highlighter.d.ts
deleted file mode 100644
index e42464534..000000000
--- a/packages/editor/dist/es/extensions/codeblock/highlighter.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Plugin } from "prosemirror-state";
-import { DecorationSet } from "prosemirror-view";
-import { AddMarkStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
-export declare type MergedStep = AddMarkStep | RemoveMarkStep | ReplaceAroundStep | ReplaceStep;
-export declare function HighlighterPlugin({ name, defaultLanguage, }: {
- name: string;
- defaultLanguage: string | null | undefined;
-}): Plugin<DecorationSet>;
diff --git a/packages/editor/dist/es/extensions/codeblock/highlighter.js b/packages/editor/dist/es/extensions/codeblock/highlighter.js
deleted file mode 100644
index 59de5f0bb..000000000
--- a/packages/editor/dist/es/extensions/codeblock/highlighter.js
+++ /dev/null
@@ -1,191 +0,0 @@
-import { Plugin, PluginKey } from "prosemirror-state";
-import { Decoration, DecorationSet } from "prosemirror-view";
-import { findChildren } from "@tiptap/core";
-import { refractor } from "refractor/lib/core";
-import { toCaretPosition, toCodeLines, } from "./code-block";
-function parseNodes(nodes, className = []) {
- return nodes.reduce((result, node) => {
- if (node.type === "comment" || node.type === "doctype")
- return result;
- const classes = [...className];
- if (node.type === "element" && node.properties)
- classes.push(...node.properties.className);
- // this is required so that even plain text is wrapped in a span
- // during highlighting. Without this, Prosemirror's selection acts
- // weird for the first highlighted node/span.
- else
- classes.push("token", "text");
- if (node.type === "element") {
- result.push(...parseNodes(node.children, classes));
- }
- else {
- result.push({ classes, text: node.value });
- }
- return result;
- }, []);
-}
-function getHighlightNodes(result) {
- return result.children || [];
-}
-function getLineDecoration(from, line, total, isActive) {
- const maxLength = String(total).length;
- const attributes = {
- class: `line-number ${isActive ? "active" : ""}`,
- "data-line": String(line).padEnd(maxLength, " "),
- };
- const spec = {
- line: line,
- active: isActive,
- total,
- from,
- };
- return Decoration.inline(from, from + 1, attributes, spec);
-}
-function getDecorations({ doc, name, defaultLanguage, caretPosition, }) {
- const decorations = [];
- const languages = refractor.listLanguages();
- findChildren(doc, (node) => node.type.name === name).forEach((block) => {
- const code = block.node.textContent;
- const lines = toCodeLines(code, block.pos);
- for (const line of lines || []) {
- const lineNumber = line.index + 1;
- const isActive = lineNumber === (caretPosition === null || caretPosition === void 0 ? void 0 : caretPosition.line) && line.from === (caretPosition === null || caretPosition === void 0 ? void 0 : caretPosition.from);
- const decoration = getLineDecoration(line.from, lineNumber, (lines === null || lines === void 0 ? void 0 : lines.length) || 0, isActive);
- decorations.push(decoration);
- }
- const language = block.node.attrs.language || defaultLanguage;
- const nodes = languages.includes(language)
- ? getHighlightNodes(refractor.highlight(code, language))
- : null;
- if (!nodes)
- return;
- let from = block.pos + 1;
- parseNodes(nodes).forEach((node) => {
- const to = from + node.text.length;
- if (node.classes.length) {
- const decoration = Decoration.inline(from, to, {
- class: node.classes.join(" "),
- });
- decorations.push(decoration);
- }
- from = to;
- });
- });
- return DecorationSet.create(doc, decorations);
-}
-export function HighlighterPlugin({ name, defaultLanguage, }) {
- const key = new PluginKey("highlighter");
- return new Plugin({
- key,
- state: {
- init: (config, state) => {
- return getDecorations({
- doc: state.doc,
- name,
- defaultLanguage,
- });
- },
- apply: (transaction, decorationSet, oldState, newState) => {
- const oldNodeName = oldState.selection.$head.parent.type.name;
- const newNodeName = newState.selection.$head.parent.type.name;
- const oldNodes = findChildren(oldState.doc, (node) => node.type.name === name);
- const newNodes = findChildren(newState.doc, (node) => node.type.name === name);
- const position = toCaretPosition(newState.selection);
- // const isDocChanged =
- // transaction.docChanged &&
- // // TODO
- // !transaction.steps.every((step) => step instanceof ReplaceAroundStep);
- // console.log("Selection", transaction.docChanged, isDocChanged);
- if (transaction.docChanged &&
- // Apply decorations if:
- // selection includes named node,
- ([oldNodeName, newNodeName].includes(name) ||
- // OR transaction adds/removes named node,
- newNodes.length !== oldNodes.length ||
- // OR transaction has changes that completely encapsulte a node
- // (for example, a transaction that affects the entire document).
- // Such transactions can happen during collab syncing via y-prosemirror, for example.
- transaction.steps.some((step) => {
- return (step.from !== undefined &&
- step.to !== undefined &&
- oldNodes.some((node) => {
- return (node.pos >= step.from &&
- node.pos + node.node.nodeSize <= step.to);
- }));
- }))) {
- return getDecorations({
- doc: transaction.doc,
- name,
- defaultLanguage,
- caretPosition: position,
- });
- }
- decorationSet = getActiveLineDecorations(transaction.doc, decorationSet, position);
- return decorationSet.map(transaction.mapping, transaction.doc);
- },
- },
- props: {
- decorations(state) {
- return key.getState(state);
- },
- },
- appendTransaction: (transactions, prevState, nextState) => {
- const tr = nextState.tr;
- let modified = false;
- const docChanged = transactions.some((transaction) => transaction.docChanged);
- const selectionChanged = (nextState.selection.$from.parent.type.name === name ||
- prevState.selection.$from.parent.type.name === name) &&
- prevState.selection.$from.pos !== nextState.selection.$from.pos;
- findChildren(nextState.doc, (node) => node.type.name === name).forEach((block) => {
- var _a;
- const { node, pos } = block;
- const attributes = Object.assign({}, node.attrs);
- if (docChanged || !((_a = attributes.lines) === null || _a === void 0 ? void 0 : _a.length)) {
- const lines = toCodeLines(node.textContent, pos);
- attributes.lines = lines.slice();
- }
- if (selectionChanged) {
- const position = toCaretPosition(nextState.selection, docChanged ? toCodeLines(node.textContent, pos) : undefined);
- attributes.caretPosition = position;
- }
- if (docChanged || selectionChanged) {
- tr.setNodeMarkup(pos, node.type, attributes);
- modified = true;
- }
- });
- return modified ? tr : null;
- },
- });
-}
-/**
- * When `position` is undefined, all active line decorations
- * are reset (e.g. when you focus out of the code block).
- */
-function getActiveLineDecorations(doc, decorations, position) {
- const lineDecorations = decorations.find(undefined, undefined, ({ line, active, from }) => {
- const isSame = position
- ? line === position.line && from === position.from
- : false;
- return isSame || active;
- });
- if (!lineDecorations.length)
- return decorations;
- // we have to clone because prosemirror operates in-place
- const cloned = lineDecorations.slice();
- // remove old line decorations which inclue the current line decoration
- // and the previous current line decoration. We'll replace these with
- // new decorations.
- decorations = decorations.remove(lineDecorations);
- const newDecorations = [];
- for (const decoration of cloned) {
- const { from, spec: { line, total }, } = decoration;
- const isActive = line === (position === null || position === void 0 ? void 0 : position.line);
- const newDecoration = getLineDecoration(from, line, (position === null || position === void 0 ? void 0 : position.total) || total, isActive);
- newDecorations.push(newDecoration);
- }
- return decorations.add(doc, newDecorations);
-}
-function isAndroid() {
- var ua = navigator.userAgent.toLowerCase();
- return ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
-}
diff --git a/packages/editor/dist/es/extensions/codeblock/index.d.ts b/packages/editor/dist/es/extensions/codeblock/index.d.ts
deleted file mode 100644
index 80ea37c7c..000000000
--- a/packages/editor/dist/es/extensions/codeblock/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./code-block";
diff --git a/packages/editor/dist/es/extensions/codeblock/index.js b/packages/editor/dist/es/extensions/codeblock/index.js
deleted file mode 100644
index 80ea37c7c..000000000
--- a/packages/editor/dist/es/extensions/codeblock/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./code-block";
diff --git a/packages/editor/dist/es/extensions/codeblock/languages.json b/packages/editor/dist/es/extensions/codeblock/languages.json
deleted file mode 100644
index d932b9f77..000000000
--- a/packages/editor/dist/es/extensions/codeblock/languages.json
+++ /dev/null
@@ -1 +0,0 @@
-[{ "filename": "markup", "title": "Markup", "alias": ["html", "xml", "svg", "mathml", "ssml", "atom", "rss"] }, { "filename": "css", "title": "CSS" }, { "filename": "clike", "title": "C-like" }, { "filename": "javascript", "title": "JavaScript", "alias": ["js"] }, { "filename": "abap", "title": "ABAP" }, { "filename": "abnf", "title": "ABNF" }, { "filename": "actionscript", "title": "ActionScript" }, { "filename": "ada", "title": "Ada" }, { "filename": "agda", "title": "Agda" }, { "filename": "al", "title": "AL" }, { "filename": "antlr4", "title": "ANTLR4", "alias": ["g4"] }, { "filename": "apacheconf", "title": "Apache Configuration" }, { "filename": "apex", "title": "Apex" }, { "filename": "apl", "title": "APL" }, { "filename": "applescript", "title": "AppleScript" }, { "filename": "aql", "title": "AQL" }, { "filename": "arduino", "title": "Arduino", "alias": ["ino"] }, { "filename": "arff", "title": "ARFF" }, { "filename": "armasm", "title": "ARM Assembly", "alias": ["arm-asm"] }, { "filename": "arturo", "title": "Arturo", "alias": ["art"] }, { "filename": "asciidoc", "title": "AsciiDoc", "alias": ["adoc"] }, { "filename": "aspnet", "title": "ASP.NET (C#)" }, { "filename": "asm6502", "title": "6502 Assembly" }, { "filename": "asmatmel", "title": "Atmel AVR Assembly" }, { "filename": "autohotkey", "title": "AutoHotkey" }, { "filename": "autoit", "title": "AutoIt" }, { "filename": "avisynth", "title": "AviSynth", "alias": ["avs"] }, { "filename": "avro-idl", "title": "Avro IDL", "alias": ["avdl"] }, { "filename": "awk", "title": "AWK", "alias": ["gawk"] }, { "filename": "bash", "title": "Bash", "alias": ["shell"] }, { "filename": "basic", "title": "BASIC" }, { "filename": "batch", "title": "Batch" }, { "filename": "bbcode", "title": "BBcode", "alias": ["shortcode"] }, { "filename": "bicep", "title": "Bicep" }, { "filename": "birb", "title": "Birb" }, { "filename": "bison", "title": "Bison" }, { "filename": "bnf", "title": "BNF", "alias": ["rbnf"] }, { "filename": "brainfuck", "title": "Brainfuck" }, { "filename": "brightscript", "title": "BrightScript" }, { "filename": "bro", "title": "Bro" }, { "filename": "bsl", "title": "BSL (1C:Enterprise)", "alias": ["oscript"] }, { "filename": "c", "title": "C" }, { "filename": "csharp", "title": "C#", "alias": ["cs", "dotnet"] }, { "filename": "cpp", "title": "C++" }, { "filename": "cfscript", "title": "CFScript", "alias": ["cfc"] }, { "filename": "chaiscript", "title": "ChaiScript" }, { "filename": "cil", "title": "CIL" }, { "filename": "clojure", "title": "Clojure" }, { "filename": "cmake", "title": "CMake" }, { "filename": "cobol", "title": "COBOL" }, { "filename": "coffeescript", "title": "CoffeeScript", "alias": ["coffee"] }, { "filename": "concurnas", "title": "Concurnas", "alias": ["conc"] }, { "filename": "csp", "title": "Content-Security-Policy" }, { "filename": "cooklang", "title": "Cooklang" }, { "filename": "coq", "title": "Coq" }, { "filename": "crystal", "title": "Crystal" }, { "filename": "css-extras", "title": "CSS Extras" }, { "filename": "csv", "title": "CSV" }, { "filename": "cue", "title": "CUE" }, { "filename": "cypher", "title": "Cypher" }, { "filename": "d", "title": "D" }, { "filename": "dart", "title": "Dart" }, { "filename": "dataweave", "title": "DataWeave" }, { "filename": "dax", "title": "DAX" }, { "filename": "dhall", "title": "Dhall" }, { "filename": "diff", "title": "Diff" }, { "filename": "django", "title": "Django/Jinja2", "alias": ["jinja2"] }, { "filename": "dns-zone-file", "title": "DNS zone file", "alias": ["dns-zone"] }, { "filename": "docker", "title": "Docker", "alias": ["dockerfile"] }, { "filename": "dot", "title": "DOT (Graphviz)", "alias": ["gv"] }, { "filename": "ebnf", "title": "EBNF" }, { "filename": "editorconfig", "title": "EditorConfig" }, { "filename": "eiffel", "title": "Eiffel" }, { "filename": "ejs", "title": "EJS", "alias": ["eta"] }, { "filename": "elixir", "title": "Elixir" }, { "filename": "elm", "title": "Elm" }, { "filename": "etlua", "title": "Embedded Lua templating" }, { "filename": "erb", "title": "ERB" }, { "filename": "erlang", "title": "Erlang" }, { "filename": "excel-formula", "title": "Excel Formula", "alias": ["xlsx", "xls"] }, { "filename": "fsharp", "title": "F#" }, { "filename": "factor", "title": "Factor" }, { "filename": "false", "title": "False" }, { "filename": "firestore-security-rules", "title": "Firestore security rules" }, { "filename": "flow", "title": "Flow" }, { "filename": "fortran", "title": "Fortran" }, { "filename": "ftl", "title": "FreeMarker Template Language" }, { "filename": "gml", "title": "GameMaker Language", "alias": ["gamemakerlanguage"] }, { "filename": "gap", "title": "GAP (CAS)" }, { "filename": "gcode", "title": "G-code" }, { "filename": "gdscript", "title": "GDScript" }, { "filename": "gedcom", "title": "GEDCOM" }, { "filename": "gettext", "title": "gettext", "alias": ["po"] }, { "filename": "gherkin", "title": "Gherkin" }, { "filename": "git", "title": "Git" }, { "filename": "glsl", "title": "GLSL" }, { "filename": "gn", "title": "GN", "alias": ["gni"] }, { "filename": "linker-script", "title": "GNU Linker Script", "alias": ["ld"] }, { "filename": "go", "title": "Go" }, { "filename": "go-module", "title": "Go module", "alias": ["go-mod"] }, { "filename": "gradle", "title": "Gradle" }, { "filename": "graphql", "title": "GraphQL" }, { "filename": "groovy", "title": "Groovy" }, { "filename": "haml", "title": "Haml" }, { "filename": "handlebars", "title": "Handlebars", "alias": ["hbs", "mustache"] }, { "filename": "haskell", "title": "Haskell", "alias": ["hs"] }, { "filename": "haxe", "title": "Haxe" }, { "filename": "hcl", "title": "HCL" }, { "filename": "hlsl", "title": "HLSL" }, { "filename": "hoon", "title": "Hoon" }, { "filename": "http", "title": "HTTP" }, { "filename": "hpkp", "title": "HTTP Public-Key-Pins" }, { "filename": "hsts", "title": "HTTP Strict-Transport-Security" }, { "filename": "ichigojam", "title": "IchigoJam" }, { "filename": "icon", "title": "Icon" }, { "filename": "icu-message-format", "title": "ICU Message Format" }, { "filename": "idris", "title": "Idris", "alias": ["idr"] }, { "filename": "ignore", "title": ".ignore", "alias": ["gitignore", "hgignore", "npmignore"] }, { "filename": "inform7", "title": "Inform 7" }, { "filename": "ini", "title": "Ini" }, { "filename": "io", "title": "Io" }, { "filename": "j", "title": "J" }, { "filename": "java", "title": "Java" }, { "filename": "javadoc", "title": "JavaDoc" }, { "filename": "javadoclike", "title": "JavaDoc-like" }, { "filename": "javastacktrace", "title": "Java stack trace" }, { "filename": "jexl", "title": "Jexl" }, { "filename": "jolie", "title": "Jolie" }, { "filename": "jq", "title": "JQ" }, { "filename": "jsdoc", "title": "JSDoc" }, { "filename": "js-extras", "title": "JS Extras" }, { "filename": "json", "title": "JSON", "alias": ["webmanifest"] }, { "filename": "json5", "title": "JSON5" }, { "filename": "jsonp", "title": "JSONP" }, { "filename": "jsstacktrace", "title": "JS stack trace" }, { "filename": "js-templates", "title": "JS Templates" }, { "filename": "julia", "title": "Julia" }, { "filename": "keepalived", "title": "Keepalived Configure" }, { "filename": "keyman", "title": "Keyman" }, { "filename": "kotlin", "title": "Kotlin", "alias": ["kt", "kts"] }, { "filename": "kumir", "title": "KuMir (КуМир)", "alias": ["kum"] }, { "filename": "kusto", "title": "Kusto" }, { "filename": "latex", "title": "LaTeX", "alias": ["tex", "context"] }, { "filename": "latte", "title": "Latte" }, { "filename": "less", "title": "Less" }, { "filename": "lilypond", "title": "LilyPond", "alias": ["ly"] }, { "filename": "liquid", "title": "Liquid" }, { "filename": "lisp", "title": "Lisp", "alias": ["emacs", "elisp", "emacs-lisp"] }, { "filename": "livescript", "title": "LiveScript" }, { "filename": "llvm", "title": "LLVM IR" }, { "filename": "log", "title": "Log file" }, { "filename": "lolcode", "title": "LOLCODE" }, { "filename": "lua", "title": "Lua" }, { "filename": "magma", "title": "Magma (CAS)" }, { "filename": "makefile", "title": "Makefile" }, { "filename": "markdown", "title": "Markdown", "alias": ["md"] }, { "filename": "markup-templating", "title": "Markup templating" }, { "filename": "mata", "title": "Mata" }, { "filename": "matlab", "title": "MATLAB" }, { "filename": "maxscript", "title": "MAXScript" }, { "filename": "mel", "title": "MEL" }, { "filename": "mermaid", "title": "Mermaid" }, { "filename": "mizar", "title": "Mizar" }, { "filename": "mongodb", "title": "MongoDB" }, { "filename": "monkey", "title": "Monkey" }, { "filename": "moonscript", "title": "MoonScript", "alias": ["moon"] }, { "filename": "n1ql", "title": "N1QL" }, { "filename": "n4js", "title": "N4JS", "alias": ["n4jsd"] }, { "filename": "nand2tetris-hdl", "title": "Nand To Tetris HDL" }, { "filename": "naniscript", "title": "Naninovel Script", "alias": ["nani"] }, { "filename": "nasm", "title": "NASM" }, { "filename": "neon", "title": "NEON" }, { "filename": "nevod", "title": "Nevod" }, { "filename": "nginx", "title": "nginx" }, { "filename": "nim", "title": "Nim" }, { "filename": "nix", "title": "Nix" }, { "filename": "nsis", "title": "NSIS" }, { "filename": "objectivec", "title": "Objective-C", "alias": ["objc"] }, { "filename": "ocaml", "title": "OCaml" }, { "filename": "odin", "title": "Odin" }, { "filename": "opencl", "title": "OpenCL" }, { "filename": "openqasm", "title": "OpenQasm", "alias": ["qasm"] }, { "filename": "oz", "title": "Oz" }, { "filename": "parigp", "title": "PARI/GP" }, { "filename": "parser", "title": "Parser" }, { "filename": "pascal", "title": "Pascal", "alias": ["objectpascal"] }, { "filename": "pascaligo", "title": "Pascaligo" }, { "filename": "psl", "title": "PATROL Scripting Language" }, { "filename": "pcaxis", "title": "PC-Axis", "alias": ["px"] }, { "filename": "peoplecode", "title": "PeopleCode", "alias": ["pcode"] }, { "filename": "perl", "title": "Perl" }, { "filename": "php", "title": "PHP" }, { "filename": "phpdoc", "title": "PHPDoc" }, { "filename": "php-extras", "title": "PHP Extras" }, { "filename": "plant-uml", "title": "PlantUML", "alias": ["plantuml"] }, { "filename": "plsql", "title": "PL/SQL" }, { "filename": "powerquery", "title": "PowerQuery", "alias": ["pq", "mscript"] }, { "filename": "powershell", "title": "PowerShell" }, { "filename": "processing", "title": "Processing" }, { "filename": "prolog", "title": "Prolog" }, { "filename": "promql", "title": "PromQL" }, { "filename": "properties", "title": ".properties" }, { "filename": "protobuf", "title": "Protocol Buffers" }, { "filename": "pug", "title": "Pug" }, { "filename": "puppet", "title": "Puppet" }, { "filename": "pure", "title": "Pure" }, { "filename": "purebasic", "title": "PureBasic", "alias": ["pbfasm"] }, { "filename": "purescript", "title": "PureScript", "alias": ["purs"] }, { "filename": "python", "title": "Python", "alias": ["py"] }, { "filename": "qsharp", "title": "Q#", "alias": ["qs"] }, { "filename": "q", "title": "Q (kdb+ database)" }, { "filename": "qml", "title": "QML" }, { "filename": "qore", "title": "Qore" }, { "filename": "r", "title": "R" }, { "filename": "racket", "title": "Racket", "alias": ["rkt"] }, { "filename": "cshtml", "title": "Razor C#", "alias": ["razor"] }, { "filename": "jsx", "title": "React JSX" }, { "filename": "tsx", "title": "React TSX" }, { "filename": "reason", "title": "Reason" }, { "filename": "regex", "title": "Regex" }, { "filename": "rego", "title": "Rego" }, { "filename": "renpy", "title": "Ren'py", "alias": ["rpy"] }, { "filename": "rescript", "title": "ReScript", "alias": ["res"] }, { "filename": "rest", "title": "reST (reStructuredText)" }, { "filename": "rip", "title": "Rip" }, { "filename": "roboconf", "title": "Roboconf" }, { "filename": "robotframework", "title": "Robot Framework", "alias": ["robot"] }, { "filename": "ruby", "title": "Ruby", "alias": ["rb"] }, { "filename": "rust", "title": "Rust" }, { "filename": "sas", "title": "SAS" }, { "filename": "sass", "title": "Sass (Sass)" }, { "filename": "scss", "title": "Sass (Scss)" }, { "filename": "scala", "title": "Scala" }, { "filename": "scheme", "title": "Scheme" }, { "filename": "shell-session", "title": "Shell session", "alias": ["sh-session", "shellsession"] }, { "filename": "smali", "title": "Smali" }, { "filename": "smalltalk", "title": "Smalltalk" }, { "filename": "smarty", "title": "Smarty" }, { "filename": "sml", "title": "SML", "alias": ["smlnj"] }, { "filename": "solidity", "title": "Solidity (Ethereum)", "alias": ["sol"] }, { "filename": "solution-file", "title": "Solution file", "alias": ["sln"] }, { "filename": "soy", "title": "Soy (Closure Template)" }, { "filename": "sparql", "title": "SPARQL", "alias": ["rq"] }, { "filename": "splunk-spl", "title": "Splunk SPL" }, { "filename": "sqf", "title": "SQF: Status Quo Function (Arma 3)" }, { "filename": "sql", "title": "SQL" }, { "filename": "squirrel", "title": "Squirrel" }, { "filename": "stan", "title": "Stan" }, { "filename": "stata", "title": "Stata Ado" }, { "filename": "iecst", "title": "Structured Text (IEC 61131-3)" }, { "filename": "stylus", "title": "Stylus" }, { "filename": "supercollider", "title": "SuperCollider", "alias": ["sclang"] }, { "filename": "swift", "title": "Swift" }, { "filename": "systemd", "title": "Systemd configuration file" }, { "filename": "t4-templating", "title": "T4 templating" }, { "filename": "t4-cs", "title": "T4 Text Templates (C#)", "alias": ["t4"] }, { "filename": "t4-vb", "title": "T4 Text Templates (VB)" }, { "filename": "tap", "title": "TAP" }, { "filename": "tcl", "title": "Tcl" }, { "filename": "tt2", "title": "Template Toolkit 2" }, { "filename": "textile", "title": "Textile" }, { "filename": "toml", "title": "TOML" }, { "filename": "tremor", "title": "Tremor", "alias": ["trickle", "troy"] }, { "filename": "turtle", "title": "Turtle", "alias": ["trig"] }, { "filename": "twig", "title": "Twig" }, { "filename": "typescript", "title": "TypeScript", "alias": ["ts"] }, { "filename": "typoscript", "title": "TypoScript", "alias": ["tsconfig"] }, { "filename": "unrealscript", "title": "UnrealScript", "alias": ["uscript", "uc"] }, { "filename": "uorazor", "title": "UO Razor Script" }, { "filename": "uri", "title": "URI", "alias": ["url"] }, { "filename": "v", "title": "V" }, { "filename": "vala", "title": "Vala" }, { "filename": "vbnet", "title": "VB.Net" }, { "filename": "velocity", "title": "Velocity" }, { "filename": "verilog", "title": "Verilog" }, { "filename": "vhdl", "title": "VHDL" }, { "filename": "vim", "title": "vim" }, { "filename": "visual-basic", "title": "Visual Basic", "alias": ["vb", "vba"] }, { "filename": "warpscript", "title": "WarpScript" }, { "filename": "wasm", "title": "WebAssembly" }, { "filename": "web-idl", "title": "Web IDL", "alias": ["webidl"] }, { "filename": "wgsl", "title": "WGSL" }, { "filename": "wiki", "title": "Wiki markup" }, { "filename": "wolfram", "title": "Wolfram language", "alias": ["mathematica", "nb", "wl"] }, { "filename": "wren", "title": "Wren" }, { "filename": "xeora", "title": "Xeora", "alias": ["xeoracube"] }, { "filename": "xml-doc", "title": "XML doc (.net)" }, { "filename": "xojo", "title": "Xojo (REALbasic)" }, { "filename": "xquery", "title": "XQuery" }, { "filename": "yaml", "title": "YAML", "alias": ["yml"] }, { "filename": "yang", "title": "YANG" }, { "filename": "zig", "title": "Zig" }]
diff --git a/packages/editor/dist/es/extensions/codeblock/loader.d.ts b/packages/editor/dist/es/extensions/codeblock/loader.d.ts
deleted file mode 100644
index 5162f1715..000000000
--- a/packages/editor/dist/es/extensions/codeblock/loader.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export declare function isLanguageLoaded(name: string): boolean;
-export declare function loadLanguage(shortName: string): Promise<import("refractor/lib/core").Syntax | undefined>;
diff --git a/packages/editor/dist/es/extensions/codeblock/loader.js b/packages/editor/dist/es/extensions/codeblock/loader.js
deleted file mode 100644
index 97ed418cf..000000000
--- a/packages/editor/dist/es/extensions/codeblock/loader.js
+++ /dev/null
@@ -1,45 +0,0 @@
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-const loadedLanguages = {};
-export function isLanguageLoaded(name) {
- return !!loadedLanguages[name];
-}
-export function loadLanguage(shortName) {
- return __awaiter(this, void 0, void 0, function* () {
- if (loadedLanguages[shortName])
- return loadedLanguages[shortName];
- const url = `https://esm.sh/[email protected]/lang/${shortName}.js?bundle=true`;
- const result = yield loadScript(shortName, url);
- loadedLanguages[shortName] = result;
- return result;
- });
-}
-function loadScript(id, url) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- const callbackName = `on${id}Loaded`;
- const script = document.createElement("script");
- script.type = "module";
- script.innerHTML = `
- import LanguageDefinition from "${url}";
- if (window["${callbackName}"]) {
- window["${callbackName}"](LanguageDefinition)
- }
-`;
- window[callbackName] = (lang) => {
- script.remove();
- window[callbackName] = null;
- resolve(lang);
- };
- // Append to the `head` element
- document.head.appendChild(script);
- });
- });
-}
diff --git a/packages/editor/dist/es/extensions/codemark/codemark.d.ts b/packages/editor/dist/es/extensions/codemark/codemark.d.ts
deleted file mode 100644
index 003c47b2f..000000000
--- a/packages/editor/dist/es/extensions/codemark/codemark.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { Extension } from "@tiptap/core";
-export declare const Codemark: Extension<any, any>;
diff --git a/packages/editor/dist/es/extensions/codemark/codemark.js b/packages/editor/dist/es/extensions/codemark/codemark.js
deleted file mode 100644
index ac55412f3..000000000
--- a/packages/editor/dist/es/extensions/codemark/codemark.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Extension } from "@tiptap/core";
-import codemark from "prosemirror-codemark";
-export const Codemark = Extension.create({
- name: "codemarkPlugin",
- addProseMirrorPlugins() {
- return codemark({ markType: this.editor.schema.marks.code });
- },
-});
diff --git a/packages/editor/dist/es/extensions/codemark/index.d.ts b/packages/editor/dist/es/extensions/codemark/index.d.ts
deleted file mode 100644
index 8c4911b98..000000000
--- a/packages/editor/dist/es/extensions/codemark/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./code-mark";
-export { Codemark as default } from "./code-mark";
diff --git a/packages/editor/dist/es/extensions/codemark/index.js b/packages/editor/dist/es/extensions/codemark/index.js
deleted file mode 100644
index 8c4911b98..000000000
--- a/packages/editor/dist/es/extensions/codemark/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./code-mark";
-export { Codemark as default } from "./code-mark";
diff --git a/packages/editor/dist/es/extensions/dropcursor/dropcursor.d.ts b/packages/editor/dist/es/extensions/dropcursor/dropcursor.d.ts
deleted file mode 100644
index 5901f57f7..000000000
--- a/packages/editor/dist/es/extensions/dropcursor/dropcursor.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Extension } from "@tiptap/core";
-export interface DropcursorOptions {
- color?: string | null;
- width?: number | null;
- class?: string | null;
-}
-export declare const Dropcursor: Extension<DropcursorOptions, any>;
diff --git a/packages/editor/dist/es/extensions/dropcursor/dropcursor.js b/packages/editor/dist/es/extensions/dropcursor/dropcursor.js
deleted file mode 100644
index d97683bc4..000000000
--- a/packages/editor/dist/es/extensions/dropcursor/dropcursor.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Extension } from "@tiptap/core";
-import { dropCursor } from "./drop-cursor.pm";
-export const Dropcursor = Extension.create({
- name: "dropCursor",
- addOptions() {
- return {
- color: "currentColor",
- width: 1,
- class: null,
- };
- },
- addProseMirrorPlugins() {
- return [dropCursor(this.options)];
- },
-});
diff --git a/packages/editor/dist/es/extensions/dropcursor/dropcursor.pm.d.ts b/packages/editor/dist/es/extensions/dropcursor/dropcursor.pm.d.ts
deleted file mode 100644
index 169767489..000000000
--- a/packages/editor/dist/es/extensions/dropcursor/dropcursor.pm.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Plugin } from "prosemirror-state";
-import { DropcursorOptions } from "./drop-cursor";
-export declare function dropCursor(options?: DropcursorOptions): Plugin<any>;
diff --git a/packages/editor/dist/es/extensions/dropcursor/dropcursor.pm.js b/packages/editor/dist/es/extensions/dropcursor/dropcursor.pm.js
deleted file mode 100644
index af6a5ac17..000000000
--- a/packages/editor/dist/es/extensions/dropcursor/dropcursor.pm.js
+++ /dev/null
@@ -1,169 +0,0 @@
-import { Plugin } from "prosemirror-state";
-import { dropPoint } from "prosemirror-transform";
-// :: (options: ?Object) → Plugin
-// Create a plugin that, when added to a ProseMirror instance,
-// causes a decoration to show up at the drop position when something
-// is dragged over the editor.
-//
-// Nodes may add a `disableDropCursor` property to their spec to
-// control the showing of a drop cursor inside them. This may be a
-// boolean or a function, which will be called with a view and a
-// position, and should return a boolean.
-//
-// options::- These options are supported:
-//
-// color:: ?string
-// The color of the cursor. Defaults to `black`.
-//
-// width:: ?number
-// The precise width of the cursor in pixels. Defaults to 1.
-//
-// class:: ?string
-// A CSS class name to add to the cursor element.
-export function dropCursor(options = {}) {
- return new Plugin({
- view(editorView) {
- return new DropCursorView(editorView, options);
- },
- });
-}
-class DropCursorView {
- constructor(editorView, options) {
- this.editorView = editorView;
- this.width = options.width || 1;
- this.color = options.color || "black";
- this.class = options.class || "";
- this.cursorPos = null;
- this.element = null;
- this.timeout = null;
- this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((name) => {
- let handler = (e) => this[name](e);
- editorView.dom.addEventListener(name, handler);
- return { name, handler };
- });
- }
- destroy() {
- this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
- }
- update(editorView, prevState) {
- if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
- if (this.cursorPos > editorView.state.doc.content.size)
- this.setCursor(null);
- else
- this.updateOverlay();
- }
- }
- setCursor(pos) {
- if (pos == this.cursorPos)
- return;
- this.cursorPos = pos;
- if (pos == null && this.element && this.element.parentNode) {
- this.element.parentNode.removeChild(this.element);
- this.element = null;
- }
- else {
- this.updateOverlay();
- }
- }
- updateOverlay() {
- if (!this.cursorPos)
- return;
- let $pos = this.editorView.state.doc.resolve(this.cursorPos), rect;
- if (!$pos.parent.inlineContent) {
- let before = $pos.nodeBefore, after = $pos.nodeAfter;
- if (before || after) {
- const node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
- if (!node)
- return;
- let nodeRect = node.getBoundingClientRect();
- let top = before ? nodeRect.bottom : nodeRect.top;
- if (before && after) {
- const cursor = this.editorView.nodeDOM(this.cursorPos);
- if (!cursor)
- return;
- top = (top + cursor.getBoundingClientRect().top) / 2;
- }
- rect = {
- left: nodeRect.left,
- right: nodeRect.right,
- top: top - this.width / 2,
- bottom: top + this.width / 2,
- };
- }
- }
- if (!rect) {
- let coords = this.editorView.coordsAtPos(this.cursorPos);
- rect = {
- left: coords.left - this.width / 2,
- right: coords.left + this.width / 2,
- top: coords.top,
- bottom: coords.bottom,
- };
- }
- let parent = this.editorView.dom.offsetParent;
- if (!this.element && parent) {
- this.element = parent.appendChild(document.createElement("div"));
- if (this.class)
- this.element.className = this.class;
- this.element.style.cssText =
- "position: absolute; z-index: 50; pointer-events: none; background-color: " +
- this.color;
- }
- let parentLeft, parentTop;
- if (!parent ||
- (parent == document.body && getComputedStyle(parent).position == "static")) {
- parentLeft = -pageXOffset;
- parentTop = -pageYOffset;
- }
- else {
- let rect = parent.getBoundingClientRect();
- parentLeft = rect.left - parent.scrollLeft;
- parentTop = rect.top - parent.scrollTop;
- }
- if (!this.element)
- return;
- this.element.style.left = rect.left - parentLeft + "px";
- this.element.style.top = rect.top - parentTop + "px";
- this.element.style.width = rect.right - rect.left + "px";
- this.element.style.height = rect.bottom - rect.top + "px";
- }
- scheduleRemoval(timeout) {
- clearTimeout(this.timeout || undefined);
- this.timeout = (setTimeout(() => this.setCursor(null), timeout));
- }
- dragover(event) {
- if (!this.editorView.editable)
- return;
- let pos = this.editorView.posAtCoords({
- left: event.clientX,
- top: event.clientY,
- });
- let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
- let disableDropCursor = node && node.type.spec.disableDropCursor;
- let disabled = typeof disableDropCursor == "function"
- ? disableDropCursor(this.editorView, pos)
- : disableDropCursor;
- if (pos && !disabled) {
- let target = pos.pos;
- if (this.editorView.dragging && this.editorView.dragging.slice) {
- const point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
- if (!point)
- return this.setCursor(null);
- target = point;
- }
- this.setCursor(target);
- this.scheduleRemoval(5000);
- }
- }
- dragend() {
- this.scheduleRemoval(20);
- }
- drop() {
- this.scheduleRemoval(20);
- }
- dragleave(event) {
- if (event.target == this.editorView.dom ||
- !this.editorView.dom.contains(event.relatedTarget))
- this.setCursor(null);
- }
-}
diff --git a/packages/editor/dist/es/extensions/dropcursor/index.d.ts b/packages/editor/dist/es/extensions/dropcursor/index.d.ts
deleted file mode 100644
index 8b3d7693d..000000000
--- a/packages/editor/dist/es/extensions/dropcursor/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Dropcursor } from "./drop-cursor";
-export * from "./drop-cursor";
-export default Dropcursor;
diff --git a/packages/editor/dist/es/extensions/dropcursor/index.js b/packages/editor/dist/es/extensions/dropcursor/index.js
deleted file mode 100644
index 8b3d7693d..000000000
--- a/packages/editor/dist/es/extensions/dropcursor/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Dropcursor } from "./drop-cursor";
-export * from "./drop-cursor";
-export default Dropcursor;
diff --git a/packages/editor/dist/es/extensions/embed/component.d.ts b/packages/editor/dist/es/extensions/embed/component.d.ts
deleted file mode 100644
index 65b1ee648..000000000
--- a/packages/editor/dist/es/extensions/embed/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { EmbedAlignmentOptions, EmbedAttributes } from "./embed";
-import { SelectionBasedReactNodeViewProps } from "../react";
-export declare function EmbedComponent(props: SelectionBasedReactNodeViewProps<EmbedAttributes & EmbedAlignmentOptions>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/embed/component.js b/packages/editor/dist/es/extensions/embed/component.js
deleted file mode 100644
index 4e2bf0b5f..000000000
--- a/packages/editor/dist/es/extensions/embed/component.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { Box, Flex } from "rebass";
-import { useRef, useState } from "react";
-import { DesktopOnly } from "../../components/responsive";
-import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
-import { Icon, Icons } from "../../toolbar";
-import { Resizer } from "../../components/resizer";
-export function EmbedComponent(props) {
- const { editor, updateAttributes, selected, node } = props;
- const [isLoading, setIsLoading] = useState(true);
- const embedRef = useRef();
- const { src, width, height, align } = node.attrs;
- return (_jsx(_Fragment, { children: _jsx(Box, Object.assign({ sx: {
- display: "flex",
- justifyContent: align === "center" ? "center" : align === "left" ? "start" : "end",
- position: "relative",
- } }, { children: _jsxs(Resizer, Object.assign({ editor: editor, selected: selected, width: width, height: height, onResize: (width, height) => {
- updateAttributes({
- width,
- height,
- }, { addToHistory: true, preventUpdate: false });
- } }, { children: [_jsxs(Flex, Object.assign({ width: "100%", sx: {
- position: "relative",
- justifyContent: "end",
- p: "small",
- bg: editor.isEditable ? "bgSecondary" : "transparent",
- borderTopLeftRadius: "default",
- borderTopRightRadius: "default",
- borderColor: selected ? "border" : "bgSecondary",
- cursor: "pointer",
- ":hover": {
- borderColor: "border",
- },
- } }, { children: [_jsx(Icon, { path: Icons.dragHandle, size: "big" }), _jsx(DesktopOnly, { children: selected && (_jsx(Flex, Object.assign({ sx: { position: "relative", justifyContent: "end" } }, { children: _jsx(Flex, Object.assign({ sx: {
- position: "absolute",
- top: -10,
- mb: 2,
- alignItems: "end",
- } }, { children: _jsx(ToolbarGroup, { editor: editor, tools: [
- "embedAlignLeft",
- "embedAlignCenter",
- "embedAlignRight",
- "embedProperties",
- ], sx: {
- boxShadow: "menu",
- borderRadius: "default",
- bg: "background",
- } }) })) }))) })] })), _jsx(Box, Object.assign({ as: "iframe", ref: embedRef, src: src, width: "100%", height: "100%", sx: {
- bg: "bgSecondary",
- border: selected
- ? "2px solid var(--primary)"
- : "2px solid transparent",
- borderRadius: "default",
- }, onLoad: () => setIsLoading(false) }, props)), isLoading && (_jsx(Flex, Object.assign({ sx: {
- position: "absolute",
- bottom: 0,
- width: "100%",
- height: "calc(100% - 20px)",
- alignItems: "center",
- justifyContent: "center",
- } }, { children: _jsx(Icon, { path: Icons.loading, rotate: true, size: 32, color: "disabled" }) })))] })) })) }));
-}
diff --git a/packages/editor/dist/es/extensions/embed/embed.d.ts b/packages/editor/dist/es/extensions/embed/embed.d.ts
deleted file mode 100644
index 969f00b5a..000000000
--- a/packages/editor/dist/es/extensions/embed/embed.d.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Node } from "@tiptap/core";
-export interface EmbedOptions {
- HTMLAttributes: Record<string, any>;
-}
-export declare type EmbedAttributes = Partial<EmbedSizeOptions> & {
- src: string;
-};
-export declare type EmbedAlignmentOptions = {
- align?: "center" | "left" | "right";
-};
-export declare type Embed = Required<EmbedAttributes> & EmbedAlignmentOptions;
-export declare type EmbedSizeOptions = {
- width: number;
- height: number;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- embed: {
- /**
- * Add an embed
- */
- insertEmbed: (options: EmbedAttributes) => ReturnType;
- setEmbedAlignment: (options: EmbedAlignmentOptions) => ReturnType;
- setEmbedSize: (options: EmbedSizeOptions) => ReturnType;
- setEmbedSource: (src: string) => ReturnType;
- };
- }
-}
-export declare const EmbedNode: Node<EmbedOptions, any>;
diff --git a/packages/editor/dist/es/extensions/embed/embed.js b/packages/editor/dist/es/extensions/embed/embed.js
deleted file mode 100644
index 934daaa04..000000000
--- a/packages/editor/dist/es/extensions/embed/embed.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Node, mergeAttributes } from "@tiptap/core";
-import { createSelectionBasedNodeView, } from "../react";
-import { EmbedComponent } from "./component";
-export const EmbedNode = Node.create({
- name: "embed",
- content: "",
- marks: "",
- draggable: true,
- addOptions() {
- return {
- HTMLAttributes: {},
- };
- },
- group() {
- return "block";
- },
- addAttributes() {
- return {
- src: {
- default: null,
- },
- width: { default: null },
- height: { default: null },
- align: { default: "left" },
- };
- },
- parseHTML() {
- return [
- {
- tag: "iframe[src]",
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "iframe",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
- ];
- },
- addNodeView() {
- return createSelectionBasedNodeView(EmbedComponent);
- },
- addCommands() {
- return {
- insertEmbed: (options) => ({ commands }) => {
- return commands.insertContent({
- type: this.name,
- attrs: options,
- });
- },
- setEmbedAlignment: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- setEmbedSize: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- setEmbedSource: (src) => ({ commands }) => {
- return commands.updateAttributes(this.name, { src });
- },
- };
- },
-});
diff --git a/packages/editor/dist/es/extensions/embed/index.d.ts b/packages/editor/dist/es/extensions/embed/index.d.ts
deleted file mode 100644
index 12b3c5295..000000000
--- a/packages/editor/dist/es/extensions/embed/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./embed";
diff --git a/packages/editor/dist/es/extensions/embed/index.js b/packages/editor/dist/es/extensions/embed/index.js
deleted file mode 100644
index 12b3c5295..000000000
--- a/packages/editor/dist/es/extensions/embed/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./embed";
diff --git a/packages/editor/dist/es/extensions/fontsize/fontsize.d.ts b/packages/editor/dist/es/extensions/fontsize/fontsize.d.ts
deleted file mode 100644
index 5725a7a40..000000000
--- a/packages/editor/dist/es/extensions/fontsize/fontsize.d.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Extension } from "@tiptap/core";
-import "@tiptap/extension-text-style";
-declare type FontSizeOptions = {
- types: string[];
- defaultFontSize: number;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- fontSize: {
- /**
- * Set the font family
- */
- setFontSize: (fontSize: string) => ReturnType;
- /**
- * Unset the font family
- */
- unsetFontSize: () => ReturnType;
- };
- }
-}
-export declare const FontSize: Extension<FontSizeOptions, any>;
-export {};
diff --git a/packages/editor/dist/es/extensions/fontsize/fontsize.js b/packages/editor/dist/es/extensions/fontsize/fontsize.js
deleted file mode 100644
index 21d2c567c..000000000
--- a/packages/editor/dist/es/extensions/fontsize/fontsize.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import { Extension } from "@tiptap/core";
-import "@tiptap/extension-text-style";
-export const FontSize = Extension.create({
- name: "fontSize",
- defaultOptions: {
- types: ["textStyle"],
- defaultFontSize: 16,
- },
- addGlobalAttributes() {
- return [
- {
- types: this.options.types,
- attributes: {
- fontSize: {
- default: `${this.options.defaultFontSize}px`,
- parseHTML: (element) => element.style.fontSize,
- renderHTML: (attributes) => {
- if (!attributes.fontSize) {
- return {};
- }
- return {
- style: `font-size: ${attributes.fontSize}`,
- };
- },
- },
- },
- },
- ];
- },
- addCommands() {
- return {
- setFontSize: (fontSize) => ({ chain }) => {
- return chain().setMark("textStyle", { fontSize }).run();
- },
- unsetFontSize: () => ({ chain }) => {
- return chain()
- .setMark("textStyle", { fontSize: null })
- .removeEmptyTextStyle()
- .run();
- },
- };
- },
-});
diff --git a/packages/editor/dist/es/extensions/fontsize/index.d.ts b/packages/editor/dist/es/extensions/fontsize/index.d.ts
deleted file mode 100644
index 0424657fa..000000000
--- a/packages/editor/dist/es/extensions/fontsize/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { FontSize } from "./font-size";
-export * from "./font-size";
-export default FontSize;
diff --git a/packages/editor/dist/es/extensions/fontsize/index.js b/packages/editor/dist/es/extensions/fontsize/index.js
deleted file mode 100644
index 0424657fa..000000000
--- a/packages/editor/dist/es/extensions/fontsize/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { FontSize } from "./font-size";
-export * from "./font-size";
-export default FontSize;
diff --git a/packages/editor/dist/es/extensions/image/component.d.ts b/packages/editor/dist/es/extensions/image/component.d.ts
deleted file mode 100644
index 0ae7c84cd..000000000
--- a/packages/editor/dist/es/extensions/image/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ImageAlignmentOptions, ImageAttributes } from "./image";
-import { SelectionBasedReactNodeViewProps } from "../react";
-export declare function ImageComponent(props: SelectionBasedReactNodeViewProps<ImageAttributes & ImageAlignmentOptions>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/image/component.js b/packages/editor/dist/es/extensions/image/component.js
deleted file mode 100644
index 9afea299c..000000000
--- a/packages/editor/dist/es/extensions/image/component.js
+++ /dev/null
@@ -1,86 +0,0 @@
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { Box, Flex, Image } from "rebass";
-import { useEffect, useRef } from "react";
-import { DesktopOnly } from "../../components/responsive";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
-import { useIsMobile } from "../../toolbar/stores/toolbar-store";
-import { Resizer } from "../../components/resizer";
-export function ImageComponent(props) {
- const { editor, updateAttributes, node, selected } = props;
- const isMobile = useIsMobile();
- let { src, alt, title, width, height, align, float } = node.attrs;
- const imageRef = useRef();
- useEffect(() => {
- (() => __awaiter(this, void 0, void 0, function* () {
- if (!imageRef.current || !src)
- return;
- imageRef.current.src = yield dataUriToBlobURL(src);
- }))();
- }, [src, imageRef]);
- if (isMobile)
- float = false;
- return (_jsx(_Fragment, { children: _jsx(Box, Object.assign({ sx: {
- display: float ? "block" : "flex",
- justifyContent: float
- ? "stretch"
- : align === "center"
- ? "center"
- : align === "left"
- ? "start"
- : "end",
- ":hover .drag-handle, :active .drag-handle": {
- opacity: 1,
- },
- } }, { children: _jsxs(Resizer, Object.assign({ editor: editor, selected: selected, width: width, height: height, onResize: (width, height) => {
- updateAttributes({
- width,
- height,
- }, { addToHistory: true, preventUpdate: false });
- } }, { children: [_jsx(DesktopOnly, { children: selected && (_jsx(Flex, Object.assign({ sx: { position: "relative", justifyContent: "end" } }, { children: _jsx(Flex, Object.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",
- } }) })) }))) }), selected && (_jsx(Icon, { className: "drag-handle", "data-drag-handle": true, draggable: true, path: Icons.dragHandle, sx: {
- cursor: "grab",
- position: "absolute",
- top: 2,
- left: 2,
- zIndex: 999,
- } })), _jsx(Image, Object.assign({ "data-drag-image": true, ref: imageRef, alt: alt, src: "/placeholder.svg", title: title, width: "100%", height: "100%", sx: {
- bg: "bgSecondary",
- border: selected
- ? "2px solid var(--primary)"
- : "2px solid transparent",
- borderRadius: "default",
- } }, props))] })) })) }));
-}
-function dataUriToBlobURL(dataurl) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!dataurl.startsWith("data:image"))
- return dataurl;
- const response = yield fetch(dataurl);
- const blob = yield response.blob();
- return URL.createObjectURL(blob);
- });
-}
diff --git a/packages/editor/dist/es/extensions/image/image.d.ts b/packages/editor/dist/es/extensions/image/image.d.ts
deleted file mode 100644
index eb963ae33..000000000
--- a/packages/editor/dist/es/extensions/image/image.d.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Node } from "@tiptap/core";
-import { Attachment } from "../attachment";
-export interface ImageOptions {
- inline: boolean;
- allowBase64: boolean;
- HTMLAttributes: Record<string, any>;
-}
-export declare type ImageAttributes = Partial<ImageSizeOptions> & Partial<Attachment> & {
- src: string;
- alt?: string;
- title?: string;
-};
-export declare type ImageAlignmentOptions = {
- float?: boolean;
- align?: "center" | "left" | "right";
-};
-export declare type ImageSizeOptions = {
- width: number;
- height: number;
-};
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- image: {
- /**
- * Add an image
- */
- insertImage: (options: ImageAttributes) => ReturnType;
- updateImage: (options: ImageAttributes) => ReturnType;
- setImageAlignment: (options: ImageAlignmentOptions) => ReturnType;
- setImageSize: (options: ImageSizeOptions) => ReturnType;
- };
- }
-}
-export declare const inputRegex: RegExp;
-export declare const ImageNode: Node<ImageOptions, any>;
diff --git a/packages/editor/dist/es/extensions/image/image.js b/packages/editor/dist/es/extensions/image/image.js
deleted file mode 100644
index b2cd176d6..000000000
--- a/packages/editor/dist/es/extensions/image/image.js
+++ /dev/null
@@ -1,107 +0,0 @@
-import { Node, nodeInputRule, mergeAttributes, findChildren, } from "@tiptap/core";
-import { getDataAttribute } from "../attachment";
-import { createSelectionBasedNodeView, } from "../react";
-import { ImageComponent } from "./component";
-export const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
-export const ImageNode = Node.create({
- name: "image",
- addOptions() {
- return {
- inline: false,
- allowBase64: false,
- HTMLAttributes: {},
- };
- },
- inline() {
- return this.options.inline;
- },
- group() {
- return this.options.inline ? "inline" : "block";
- },
- draggable: true,
- addAttributes() {
- return {
- src: {
- default: null,
- },
- alt: {
- default: null,
- },
- title: {
- default: null,
- },
- width: { default: null },
- height: { default: null },
- // TODO: maybe these should be stored as styles?
- float: getDataAttribute("float", false),
- align: getDataAttribute("align", "left"),
- hash: getDataAttribute("hash"),
- filename: getDataAttribute("filename"),
- type: getDataAttribute("mime"),
- size: getDataAttribute("size"),
- };
- },
- parseHTML() {
- return [
- {
- tag: this.options.allowBase64 ? "img" : 'img:not([src^="data:"])',
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "img",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
- ];
- },
- addNodeView() {
- return createSelectionBasedNodeView(ImageComponent);
- },
- addCommands() {
- return {
- insertImage: (options) => ({ commands }) => {
- return commands.insertContent({
- type: this.name,
- attrs: options,
- });
- },
- setImageAlignment: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- setImageSize: (options) => ({ commands }) => {
- return commands.updateAttributes(this.name, Object.assign({}, options));
- },
- updateImage: (options) => ({ state, tr, dispatch }) => {
- const query = options.hash
- ? { key: "hash", value: options.hash }
- : options.src
- ? { key: "src", value: options.src }
- : null;
- if (!query)
- return false;
- const images = findChildren(state.doc, (node) => node.type.name === this.name &&
- node.attrs[query.key] === query.value);
- for (const image of images) {
- tr.setNodeMarkup(image.pos, image.node.type, Object.assign(Object.assign({}, image.node.attrs), options));
- }
- tr.setMeta("preventUpdate", true);
- tr.setMeta("addToHistory", false);
- if (dispatch)
- dispatch(tr);
- return true;
- },
- };
- },
- addInputRules() {
- return [
- nodeInputRule({
- find: inputRegex,
- type: this.type,
- getAttributes: (match) => {
- const [, , alt, src, title] = match;
- return { src, alt, title };
- },
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/es/extensions/image/index.d.ts b/packages/editor/dist/es/extensions/image/index.d.ts
deleted file mode 100644
index 0aa9b4bbd..000000000
--- a/packages/editor/dist/es/extensions/image/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./image";
diff --git a/packages/editor/dist/es/extensions/image/index.js b/packages/editor/dist/es/extensions/image/index.js
deleted file mode 100644
index 0aa9b4bbd..000000000
--- a/packages/editor/dist/es/extensions/image/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./image";
diff --git a/packages/editor/dist/es/extensions/keepinview/index.d.ts b/packages/editor/dist/es/extensions/keepinview/index.d.ts
deleted file mode 100644
index 7d6036306..000000000
--- a/packages/editor/dist/es/extensions/keepinview/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./keep-in-view";
diff --git a/packages/editor/dist/es/extensions/keepinview/index.js b/packages/editor/dist/es/extensions/keepinview/index.js
deleted file mode 100644
index 7d6036306..000000000
--- a/packages/editor/dist/es/extensions/keepinview/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./keep-in-view";
diff --git a/packages/editor/dist/es/extensions/keepinview/keepinview.d.ts b/packages/editor/dist/es/extensions/keepinview/keepinview.d.ts
deleted file mode 100644
index 708121164..000000000
--- a/packages/editor/dist/es/extensions/keepinview/keepinview.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Editor, Extension } from "@tiptap/core";
-export declare const KeepInView: Extension<any, any>;
-export declare function keepLastLineInView(editor: Editor): void;
diff --git a/packages/editor/dist/es/extensions/keepinview/keepinview.js b/packages/editor/dist/es/extensions/keepinview/keepinview.js
deleted file mode 100644
index 7b54a5694..000000000
--- a/packages/editor/dist/es/extensions/keepinview/keepinview.js
+++ /dev/null
@@ -1,63 +0,0 @@
-import { Extension, posToDOMRect } from "@tiptap/core";
-let onWindowResize = undefined;
-export const KeepInView = Extension.create({
- name: "keepinview",
- onCreate() {
- onWindowResize = () => {
- keepLastLineInView(this.editor);
- };
- window.addEventListener("resize", onWindowResize);
- },
- onDestroy() {
- if (!onWindowResize)
- return;
- window.removeEventListener("resize", onWindowResize);
- onWindowResize = undefined;
- },
- addKeyboardShortcuts() {
- return {
- Enter: ({ editor }) => {
- setTimeout(() => {
- keepLastLineInView(editor);
- });
- return false;
- },
- };
- },
-});
-export function keepLastLineInView(editor) {
- const THRESHOLD = 100;
- const node = editor.state.selection.$from;
- const { top } = posToDOMRect(editor.view, node.pos, node.pos + 1);
- const isBelowThreshold = window.innerHeight - top < THRESHOLD;
- if (isBelowThreshold) {
- let { node: domNode } = editor.view.domAtPos(node.pos);
- if (domNode.nodeType === Node.TEXT_NODE && domNode.parentNode)
- domNode = domNode.parentNode;
- if (domNode instanceof HTMLElement) {
- const container = findScrollContainer(domNode);
- if (container) {
- container.scrollBy({ top: THRESHOLD, behavior: "smooth" });
- }
- else
- domNode.scrollIntoView({ behavior: "smooth", block: "center" });
- }
- }
-}
-const findScrollContainer = (element) => {
- if (!element) {
- return undefined;
- }
- let parent = element.parentElement;
- while (parent) {
- const { overflow, overflowY } = parent.style;
- if (isOverlow(overflow) || isOverlow(overflowY)) {
- return parent;
- }
- parent = parent.parentElement;
- }
- return document.documentElement;
-};
-function isOverlow(str) {
- return str.split(" ").every((o) => o === "auto" || o === "scroll");
-}
diff --git a/packages/editor/dist/es/extensions/listitem/commands.d.ts b/packages/editor/dist/es/extensions/listitem/commands.d.ts
deleted file mode 100644
index 7ff452b25..000000000
--- a/packages/editor/dist/es/extensions/listitem/commands.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { NodeType } from "prosemirror-model";
-import { Editor } from "@tiptap/core";
-export declare function onBackspacePressed(editor: Editor, name: string, type: NodeType): boolean;
diff --git a/packages/editor/dist/es/extensions/listitem/commands.js b/packages/editor/dist/es/extensions/listitem/commands.js
deleted file mode 100644
index 1ec880433..000000000
--- a/packages/editor/dist/es/extensions/listitem/commands.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import { findParentNodeOfType, hasParentNodeOfType } from "prosemirror-utils";
-// WORKAROUND: if we're at the start of a list item, we need to either
-// backspace directly to an empty list item above, or outdent this node
-export function onBackspacePressed(editor, name, type) {
- const { selection } = editor.state;
- const { empty, $from } = selection;
- if (!empty ||
- !isInside(name, type, editor.state) ||
- $from.parentOffset !== 0 ||
- !isFirstChildOfParent(editor.state) ||
- !editor.can().liftListItem(type))
- return false;
- const isEmpty = isListItemEmpty(type, editor.state);
- if (isEmpty) {
- if (isFirstOfType(type, editor.state)) {
- const parentList = getListFromListItem(type, editor.state);
- if (!parentList)
- return false;
- return editor.commands.deleteNode(parentList.type);
- }
- return editor.commands.deleteNode(type);
- }
- else if (isFirstOfType(type, editor.state)) {
- return editor.commands.liftListItem(type);
- }
- else {
- // we have to run join backward twice because on the first join
- // the two list items are joined i.e., the editor just puts their
- // paragraphs next to each other. The next join merges the paragraphs
- // like it should be.
- return editor.chain().joinBackward().joinBackward().run();
- }
-}
-function isInside(name, type, state) {
- const { $from } = state.selection;
- let node = type || state.schema.nodes[name];
- const { paragraph } = state.schema.nodes;
- return (hasParentNodeOfType(node)(state.selection) &&
- $from.parent.type === paragraph);
-}
-function isFirstChildOfParent(state) {
- const { $from } = state.selection;
- return $from.depth > 1
- ? $from.parentOffset === 0 || $from.index($from.depth - 1) === 0
- : true;
-}
-const isFirstOfType = (type, state) => {
- const block = findParentNodeOfType(type)(state.selection);
- if (!block)
- return false;
- const { pos } = block;
- const resolved = state.doc.resolve(pos);
- console.log("isFirstOfType", resolved);
- return !resolved.nodeBefore;
-};
-const getListFromListItem = (type, state) => {
- var _a;
- const block = findParentNodeOfType(type)(state.selection);
- if (!block)
- return undefined;
- const { pos } = block;
- const resolved = state.doc.resolve(pos);
- if (!resolved.parent.type.spec.group ||
- ((_a = resolved.parent.type.spec.group) === null || _a === void 0 ? void 0 : _a.indexOf("list")) <= -1)
- return undefined;
- return resolved.parent;
-};
-function isListItemEmpty(type, state) {
- const block = findParentNodeOfType(type)(state.selection);
- if (!block)
- return false;
- const { node } = block;
- return !node.textContent.length;
-}
diff --git a/packages/editor/dist/es/extensions/listitem/index.d.ts b/packages/editor/dist/es/extensions/listitem/index.d.ts
deleted file mode 100644
index 24950c4f2..000000000
--- a/packages/editor/dist/es/extensions/listitem/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./list-item";
diff --git a/packages/editor/dist/es/extensions/listitem/index.js b/packages/editor/dist/es/extensions/listitem/index.js
deleted file mode 100644
index 24950c4f2..000000000
--- a/packages/editor/dist/es/extensions/listitem/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./list-item";
diff --git a/packages/editor/dist/es/extensions/listitem/listitem.d.ts b/packages/editor/dist/es/extensions/listitem/listitem.d.ts
deleted file mode 100644
index 8160a725a..000000000
--- a/packages/editor/dist/es/extensions/listitem/listitem.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const ListItem: import("@tiptap/core").Node<import("@tiptap/extension-list-item").ListItemOptions, any>;
diff --git a/packages/editor/dist/es/extensions/listitem/listitem.js b/packages/editor/dist/es/extensions/listitem/listitem.js
deleted file mode 100644
index 1522092eb..000000000
--- a/packages/editor/dist/es/extensions/listitem/listitem.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { ListItem as TiptapListItem } from "@tiptap/extension-list-item";
-import { onBackspacePressed } from "./commands";
-export const ListItem = TiptapListItem.extend({
- addKeyboardShortcuts() {
- var _a;
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { Backspace: ({ editor }) => onBackspacePressed(editor, this.name, this.type) });
- },
-});
diff --git a/packages/editor/dist/es/extensions/math/index.d.ts b/packages/editor/dist/es/extensions/math/index.d.ts
deleted file mode 100644
index 1331fdb01..000000000
--- a/packages/editor/dist/es/extensions/math/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { MathInline } from "./math-inline";
-export { MathBlock } from "./math-block";
diff --git a/packages/editor/dist/es/extensions/math/index.js b/packages/editor/dist/es/extensions/math/index.js
deleted file mode 100644
index 1331fdb01..000000000
--- a/packages/editor/dist/es/extensions/math/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export { MathInline } from "./math-inline";
-export { MathBlock } from "./math-block";
diff --git a/packages/editor/dist/es/extensions/math/mathblock.d.ts b/packages/editor/dist/es/extensions/math/mathblock.d.ts
deleted file mode 100644
index 5c266e9e8..000000000
--- a/packages/editor/dist/es/extensions/math/mathblock.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Node } from "@tiptap/core";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- mathBlock: {
- insertMathBlock: () => ReturnType;
- };
- }
-}
-export declare const MathBlock: Node<any, any>;
diff --git a/packages/editor/dist/es/extensions/math/mathblock.js b/packages/editor/dist/es/extensions/math/mathblock.js
deleted file mode 100644
index a041c7b47..000000000
--- a/packages/editor/dist/es/extensions/math/mathblock.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Node, mergeAttributes } from "@tiptap/core";
-import { inputRules } from "prosemirror-inputrules";
-import { insertMathNode, makeBlockMathInputRule, REGEX_BLOCK_MATH_DOLLARS, } from "./plugin";
-export const MathBlock = Node.create({
- name: "mathBlock",
- group: "block math",
- content: "text*",
- atom: true,
- code: true,
- parseHTML() {
- return [
- {
- tag: `div[class*='math-block']`, // important!
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "div",
- mergeAttributes({ class: "math-block math-node" }, HTMLAttributes),
- 0,
- ];
- },
- addCommands() {
- return {
- insertMathBlock: () => ({ state, dispatch, view }) => {
- return insertMathNode(this.type)(state, dispatch, view);
- },
- };
- },
- addProseMirrorPlugins() {
- const inputRulePlugin = inputRules({
- rules: [makeBlockMathInputRule(REGEX_BLOCK_MATH_DOLLARS, this.type)],
- });
- return [inputRulePlugin];
- },
-});
diff --git a/packages/editor/dist/es/extensions/math/mathinline.d.ts b/packages/editor/dist/es/extensions/math/mathinline.d.ts
deleted file mode 100644
index 56a7ec49f..000000000
--- a/packages/editor/dist/es/extensions/math/mathinline.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Node } from "@tiptap/core";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- mathInline: {
- insertMathInline: () => ReturnType;
- };
- }
-}
-export declare const MathInline: Node<any, any>;
diff --git a/packages/editor/dist/es/extensions/math/mathinline.js b/packages/editor/dist/es/extensions/math/mathinline.js
deleted file mode 100644
index e1e3a3181..000000000
--- a/packages/editor/dist/es/extensions/math/mathinline.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Node, mergeAttributes } from "@tiptap/core";
-import { inputRules } from "prosemirror-inputrules";
-import { makeInlineMathInputRule, REGEX_INLINE_MATH_DOLLARS, mathPlugin, } from "./plugin";
-export const MathInline = Node.create({
- name: "mathInline",
- group: "inline math",
- content: "text*",
- inline: true,
- atom: true,
- code: true,
- parseHTML() {
- return [
- {
- tag: "span[class*='math-inline']", // important!,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "span",
- mergeAttributes({ class: "math-inline math-node" }, HTMLAttributes),
- 0,
- ];
- },
- addCommands() {
- return {
- insertMathInline: () => ({ chain, tr }) => {
- const { $from } = tr.selection;
- return chain()
- .insertContent({ type: this.name, attrs: {} })
- .setNodeSelection($from.pos)
- .run();
- },
- };
- },
- addProseMirrorPlugins() {
- const inputRulePlugin = inputRules({
- rules: [makeInlineMathInputRule(REGEX_INLINE_MATH_DOLLARS, this.type)],
- });
- return [mathPlugin, inputRulePlugin];
- },
-});
diff --git a/packages/editor/dist/es/extensions/math/plugin/commands/collapsemathnode.d.ts b/packages/editor/dist/es/extensions/math/plugin/commands/collapsemathnode.d.ts
deleted file mode 100644
index a3210bd68..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/commands/collapsemathnode.d.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Command } from "prosemirror-state";
-import { EditorView } from "prosemirror-view";
-/**
- * A ProseMirror command for determining whether to exit a math block, based on
- * specific conditions. Normally called when the user has
- *
- * @param outerView The main ProseMirror EditorView containing this math node.
- * @param dir Used to indicate desired cursor position upon closing a math node.
- * When set to -1, cursor will be placed BEFORE the math node.
- * When set to +1, cursor will be placed AFTER the math node.
- * @param borderMode An exit condition based on cursor position and direction.
- * @param requireEmptySelection When TRUE, only exit the math node when the
- * (inner) selection is empty.
- * @returns A new ProseMirror command based on the input configuration.
- */
-export declare function collapseMathNode(outerView: EditorView, dir: 1 | -1, requireOnBorder: boolean, requireEmptySelection?: boolean): Command;
diff --git a/packages/editor/dist/es/extensions/math/plugin/commands/collapsemathnode.js b/packages/editor/dist/es/extensions/math/plugin/commands/collapsemathnode.js
deleted file mode 100644
index f9a6a9104..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/commands/collapsemathnode.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import { TextSelection } from "prosemirror-state";
-/**
- * A ProseMirror command for determining whether to exit a math block, based on
- * specific conditions. Normally called when the user has
- *
- * @param outerView The main ProseMirror EditorView containing this math node.
- * @param dir Used to indicate desired cursor position upon closing a math node.
- * When set to -1, cursor will be placed BEFORE the math node.
- * When set to +1, cursor will be placed AFTER the math node.
- * @param borderMode An exit condition based on cursor position and direction.
- * @param requireEmptySelection When TRUE, only exit the math node when the
- * (inner) selection is empty.
- * @returns A new ProseMirror command based on the input configuration.
- */
-export function collapseMathNode(outerView, dir, requireOnBorder, requireEmptySelection = true) {
- // create a new ProseMirror command based on the input conditions
- return (innerState, dispatch) => {
- // get selection info
- let outerState = outerView.state;
- let { to: outerTo, from: outerFrom } = outerState.selection;
- let { to: innerTo, from: innerFrom } = innerState.selection;
- // only exit math node when selection is empty
- if (requireEmptySelection && innerTo !== innerFrom) {
- return false;
- }
- let currentPos = dir > 0 ? innerTo : innerFrom;
- // when requireOnBorder is TRUE, collapse only when cursor
- // is about to leave the bounds of the math node
- if (requireOnBorder) {
- // (subtract two from nodeSize to account for start and end tokens)
- let nodeSize = innerState.doc.nodeSize - 2;
- // early return if exit conditions not met
- if (dir > 0 && currentPos < nodeSize) {
- return false;
- }
- if (dir < 0 && currentPos > 0) {
- return false;
- }
- }
- // all exit conditions met, so close the math node by moving the cursor outside
- if (dispatch) {
- // set outer selection to be outside of the nodeview
- let targetPos = dir > 0 ? outerTo : outerFrom;
- outerView.dispatch(outerState.tr.setSelection(TextSelection.create(outerState.doc, targetPos)));
- // must return focus to the outer view, otherwise no cursor will appear
- outerView.focus();
- }
- return true;
- };
-}
diff --git a/packages/editor/dist/es/extensions/math/plugin/commands/insertmathnode.d.ts b/packages/editor/dist/es/extensions/math/plugin/commands/insertmathnode.d.ts
deleted file mode 100644
index 4d8ba65ba..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/commands/insertmathnode.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Command } from "prosemirror-state";
-import { NodeType } from "prosemirror-model";
-/**
- * Returns a new command that can be used to inserts a new math node at the
- * user's current document position, provided that the document schema actually
- * allows a math node to be placed there.
- *
- * @param mathNodeType An instance for either your math_inline or math_display
- * NodeType. Must belong to the same schema that your EditorState uses!
- * @param initialText (optional) The initial source content for the math editor.
- */
-export declare function insertMathNode(mathNodeType: NodeType, initialText?: string): Command;
diff --git a/packages/editor/dist/es/extensions/math/plugin/commands/insertmathnode.js b/packages/editor/dist/es/extensions/math/plugin/commands/insertmathnode.js
deleted file mode 100644
index 215ccdb1d..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/commands/insertmathnode.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import { NodeSelection, TextSelection, } from "prosemirror-state";
-////////////////////////////////////////////////////////////////////////////////
-/**
- * Returns a new command that can be used to inserts a new math node at the
- * user's current document position, provided that the document schema actually
- * allows a math node to be placed there.
- *
- * @param mathNodeType An instance for either your math_inline or math_display
- * NodeType. Must belong to the same schema that your EditorState uses!
- * @param initialText (optional) The initial source content for the math editor.
- */
-export function insertMathNode(mathNodeType, initialText = "") {
- return function (state, dispatch) {
- let { $from, empty } = state.selection, index = $from.index();
- if (!empty && !$from.parent.canReplaceWith(index, index, mathNodeType)) {
- return false;
- }
- if (dispatch) {
- let mathNode = mathNodeType.create({}, initialText ? state.schema.text(initialText) : null);
- let tr = state.tr.replaceSelectionWith(mathNode);
- if (empty) {
- tr = tr.setSelection(TextSelection.create(tr.doc, $from.pos + 1));
- }
- else {
- tr = tr.setSelection(NodeSelection.create(tr.doc, $from.pos));
- }
- dispatch(tr);
- }
- return true;
- };
-}
diff --git a/packages/editor/dist/es/extensions/math/plugin/commands/move-cursor-cmd.d.ts b/packages/editor/dist/es/extensions/math/plugin/commands/move-cursor-cmd.d.ts
deleted file mode 100644
index d1361e53e..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/commands/move-cursor-cmd.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Command } from "prosemirror-state";
-/**
- * Some browsers (cough firefox cough) don't properly handle cursor movement on
- * the edges of a NodeView, so we need to make the desired behavior explicit.
- *
- * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1252108
- */
-export declare function nudgeCursorCmd(dir: -1 | 0 | 1): Command;
-export declare const nudgeCursorForwardCmd: Command;
-export declare const nudgeCursorBackCmd: Command;
diff --git a/packages/editor/dist/es/extensions/math/plugin/commands/move-cursor-cmd.js b/packages/editor/dist/es/extensions/math/plugin/commands/move-cursor-cmd.js
deleted file mode 100644
index 057856064..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/commands/move-cursor-cmd.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { TextSelection } from "prosemirror-state";
-////////////////////////////////////////////////////////////////////////////////
-/**
- * Some browsers (cough firefox cough) don't properly handle cursor movement on
- * the edges of a NodeView, so we need to make the desired behavior explicit.
- *
- * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1252108
- */
-export function nudgeCursorCmd(dir) {
- return (innerState, dispatch) => {
- let { to, from } = innerState.selection;
- // compute target position
- let emptySelection = to === from;
- let currentPos = dir < 0 ? from : to;
- let increment = emptySelection ? dir : 0;
- let nodeSize = innerState.doc.nodeSize;
- let targetPos = Math.max(0, Math.min(nodeSize, currentPos + increment));
- if (dispatch) {
- dispatch(innerState.tr.setSelection(TextSelection.create(innerState.doc, targetPos)));
- }
- return true;
- };
-}
-export const nudgeCursorForwardCmd = nudgeCursorCmd(+1);
-export const nudgeCursorBackCmd = nudgeCursorCmd(-1);
diff --git a/packages/editor/dist/es/extensions/math/plugin/index.d.ts b/packages/editor/dist/es/extensions/math/plugin/index.d.ts
deleted file mode 100644
index 13e02011b..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/index.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export { MathView, type ICursorPosObserver } from "./math-node-view";
-export { mathPlugin, createMathView, type IMathPluginState, } from "./math-plugin";
-export { mathSchemaSpec, createMathSchema } from "./math-schema";
-export { mathBackspaceCmd } from "./plugins/math-backspace";
-export { makeBlockMathInputRule, makeInlineMathInputRule, REGEX_BLOCK_MATH_DOLLARS, REGEX_INLINE_MATH_DOLLARS, REGEX_INLINE_MATH_DOLLARS_ESCAPED, } from "./plugins/math-input-rules";
-export { mathSelectPlugin } from "./plugins/math-select";
-export { insertMathNode } from "./commands/insert-math-node";
-export { mathSerializer } from "./utils/text-serializer";
-export * from "./utils/types";
diff --git a/packages/editor/dist/es/extensions/math/plugin/index.js b/packages/editor/dist/es/extensions/math/plugin/index.js
deleted file mode 100644
index bb3ad0ec5..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-// core functionality
-export { MathView } from "./math-node-view";
-export { mathPlugin, createMathView, } from "./math-plugin";
-export { mathSchemaSpec, createMathSchema } from "./math-schema";
-// recommended plugins
-export { mathBackspaceCmd } from "./plugins/math-backspace";
-export { makeBlockMathInputRule, makeInlineMathInputRule, REGEX_BLOCK_MATH_DOLLARS, REGEX_INLINE_MATH_DOLLARS, REGEX_INLINE_MATH_DOLLARS_ESCAPED, } from "./plugins/math-input-rules";
-// optional / experimental plugins
-export { mathSelectPlugin } from "./plugins/math-select";
-// commands
-export { insertMathNode } from "./commands/insert-math-node";
-// utilities
-export { mathSerializer } from "./utils/text-serializer";
-export * from "./utils/types";
diff --git a/packages/editor/dist/es/extensions/math/plugin/math-nodeview.d.ts b/packages/editor/dist/es/extensions/math/plugin/math-nodeview.d.ts
deleted file mode 100644
index 9d1e9ae52..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/math-nodeview.d.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Node as ProseNode } from "prosemirror-model";
-import { EditorState, Transaction, PluginKey } from "prosemirror-state";
-import { NodeView, EditorView, Decoration, DecorationSource } from "prosemirror-view";
-import { IMathPluginState } from "./math-plugin";
-import { MathRenderFn } from "./renderers/types";
-export interface ICursorPosObserver {
- /** indicates on which side cursor should appear when this node is selected */
- cursorSide: "start" | "end";
- /** */
- updateCursorPos(state: EditorState): void;
-}
-interface IMathViewOptions {
- /** Dom element name to use for this NodeView */
- tagName?: string;
- /** Used to render the Tex input */
- renderer: MathRenderFn;
- /** Should be true if node is inline */
- className?: string;
-}
-export declare class MathView implements NodeView, ICursorPosObserver {
- private _node;
- private _outerView;
- private _getPos;
- dom: HTMLElement;
- private _mathRenderElt;
- private _mathSrcElt;
- private _innerView;
- cursorSide: "start" | "end";
- private _tagName;
- private _isEditing;
- private _mathPluginKey;
- private options;
- /**
- * @param onDestroy Callback for when this NodeView is destroyed.
- * This NodeView should unregister itself from the list of ICursorPosObservers.
- *
- * Math Views support the following options:
- * @option displayMode If TRUE, will render math in display mode, otherwise in inline mode.
- * @option tagName HTML tag name to use for this NodeView. If none is provided,
- * will use the node name with underscores converted to hyphens.
- */
- constructor(node: ProseNode, view: EditorView, getPos: () => number, options: IMathViewOptions, mathPluginKey: PluginKey<IMathPluginState>, onDestroy?: () => void);
- destroy(): void;
- /**
- * Ensure focus on the inner editor whenever this node has focus.
- * This helps to prevent accidental deletions of math blocks.
- */
- ensureFocus(): void;
- update(node: ProseNode, _decorations: readonly Decoration[], _innerDecorations: DecorationSource): boolean;
- updateCursorPos(state: EditorState): void;
- selectNode(): void;
- deselectNode(): void;
- stopEvent(event: Event): boolean;
- ignoreMutation(): boolean;
- renderMath(): void;
- dispatchInner(tr: Transaction): void;
- openEditor(): void;
- /**
- * Called when the inner ProseMirror editor should close.
- *
- * @param render Optionally update the rendered math after closing. (which
- * is generally what we want to do, since the user is done editing!)
- */
- closeEditor(render?: boolean): void;
-}
-export {};
diff --git a/packages/editor/dist/es/extensions/math/plugin/math-nodeview.js b/packages/editor/dist/es/extensions/math/plugin/math-nodeview.js
deleted file mode 100644
index a07bc52f2..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/math-nodeview.js
+++ /dev/null
@@ -1,280 +0,0 @@
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-import { EditorState, TextSelection, } from "prosemirror-state";
-import { EditorView, } from "prosemirror-view";
-import { StepMap } from "prosemirror-transform";
-import { keymap } from "prosemirror-keymap";
-import { newlineInCode, chainCommands, deleteSelection, } from "prosemirror-commands";
-import { collapseMathNode } from "./commands/collapse-math-node";
-export class MathView {
- // == Lifecycle ===================================== //
- /**
- * @param onDestroy Callback for when this NodeView is destroyed.
- * This NodeView should unregister itself from the list of ICursorPosObservers.
- *
- * Math Views support the following options:
- * @option displayMode If TRUE, will render math in display mode, otherwise in inline mode.
- * @option tagName HTML tag name to use for this NodeView. If none is provided,
- * will use the node name with underscores converted to hyphens.
- */
- constructor(node, view, getPos, options, mathPluginKey, onDestroy) {
- // store arguments
- this.options = options;
- this._node = node;
- this._outerView = view;
- this._getPos = getPos;
- this._mathPluginKey = mathPluginKey;
- // editing state
- this.cursorSide = "start";
- this._isEditing = false;
- // options
- this._tagName = options.tagName || this._node.type.name.replace("_", "-");
- // create dom representation of nodeview
- this.dom = document.createElement(this._tagName);
- if (options.className)
- this.dom.classList.add(options.className);
- this.dom.classList.add("math-node");
- this._mathRenderElt = document.createElement("span");
- this._mathRenderElt.textContent = "";
- this._mathRenderElt.classList.add("math-render");
- this.dom.appendChild(this._mathRenderElt);
- this._mathSrcElt = document.createElement("span");
- this._mathSrcElt.classList.add("math-src");
- this.dom.appendChild(this._mathSrcElt);
- // ensure
- this.dom.addEventListener("click", () => this.ensureFocus());
- // render initial content
- this.renderMath();
- }
- destroy() {
- // close the inner editor without rendering
- this.closeEditor(false);
- // clean up dom elements
- if (this._mathRenderElt) {
- this._mathRenderElt.remove();
- delete this._mathRenderElt;
- }
- if (this._mathSrcElt) {
- this._mathSrcElt.remove();
- delete this._mathSrcElt;
- }
- this.dom.remove();
- }
- /**
- * Ensure focus on the inner editor whenever this node has focus.
- * This helps to prevent accidental deletions of math blocks.
- */
- ensureFocus() {
- if (this._innerView && this._outerView.hasFocus()) {
- this._innerView.focus();
- }
- }
- // == Updates ======================================= //
- update(node, _decorations, _innerDecorations) {
- if (!node.sameMarkup(this._node))
- return false;
- this._node = node;
- if (this._innerView) {
- let state = this._innerView.state;
- let start = node.content.findDiffStart(state.doc.content);
- if (start != null) {
- let diff = node.content.findDiffEnd(state.doc.content);
- if (diff) {
- let { a: endA, b: endB } = diff;
- let overlap = start - Math.min(endA, endB);
- if (overlap > 0) {
- endA += overlap;
- endB += overlap;
- }
- this._innerView.dispatch(state.tr
- .replace(start, endB, node.slice(start, endA))
- .setMeta("fromOutside", true));
- }
- }
- }
- if (!this._isEditing) {
- this.renderMath();
- }
- return true;
- }
- updateCursorPos(state) {
- const pos = this._getPos();
- const size = this._node.nodeSize;
- const inPmSelection = state.selection.from < pos + size && pos < state.selection.to;
- if (!inPmSelection) {
- this.cursorSide = pos < state.selection.from ? "end" : "start";
- }
- }
- // == Events ===================================== //
- selectNode() {
- if (!this._outerView.editable) {
- return;
- }
- this.dom.classList.add("ProseMirror-selectednode");
- if (!this._isEditing) {
- this.openEditor();
- }
- }
- deselectNode() {
- this.dom.classList.remove("ProseMirror-selectednode");
- if (this._isEditing) {
- this.closeEditor();
- }
- }
- stopEvent(event) {
- return (this._innerView !== undefined &&
- event.target !== undefined &&
- this._innerView.dom.contains(event.target));
- }
- ignoreMutation() {
- return true;
- }
- // == Rendering ===================================== //
- renderMath() {
- if (!this._mathRenderElt) {
- return;
- }
- // get tex string to render
- let content = this._node.content.content;
- let texString = "";
- if (content.length > 0 && content[0].textContent !== null) {
- texString = content[0].textContent.trim();
- }
- // empty math?
- if (texString.length < 1) {
- this.dom.classList.add("empty-math");
- // clear rendered math, since this node is in an invalid state
- while (this._mathRenderElt.firstChild) {
- this._mathRenderElt.firstChild.remove();
- }
- // do not render empty math
- return;
- }
- else {
- this.dom.classList.remove("empty-math");
- }
- // render katex, but fail gracefully
- try {
- this.options.renderer(texString, this._mathRenderElt);
- this._mathRenderElt.classList.remove("parse-error");
- this.dom.setAttribute("title", "");
- }
- catch (err) {
- if (err instanceof Error) {
- console.error(err);
- this._mathRenderElt.classList.add("parse-error");
- this.dom.setAttribute("title", err.toString());
- }
- }
- }
- // == Inner Editor ================================== //
- dispatchInner(tr) {
- if (!this._innerView) {
- return;
- }
- let { state, transactions } = this._innerView.state.applyTransaction(tr);
- this._innerView.updateState(state);
- if (!tr.getMeta("fromOutside")) {
- let outerTr = this._outerView.state.tr, offsetMap = StepMap.offset(this._getPos() + 1);
- for (let i = 0; i < transactions.length; i++) {
- let steps = transactions[i].steps;
- for (let j = 0; j < steps.length; j++) {
- let mapped = steps[j].map(offsetMap);
- if (!mapped) {
- throw Error("step discarded!");
- }
- outerTr.step(mapped);
- }
- }
- if (outerTr.docChanged)
- this._outerView.dispatch(outerTr);
- }
- }
- openEditor() {
- var _a;
- if (this._innerView) {
- throw Error("inner view should not exist!");
- }
- if (!this._mathSrcElt)
- throw new Error("_mathSrcElt does not exist!");
- // create a nested ProseMirror view
- this._innerView = new EditorView(this._mathSrcElt, {
- state: EditorState.create({
- doc: this._node,
- plugins: [
- keymap({
- Tab: (state, dispatch) => {
- if (dispatch) {
- dispatch(state.tr.insertText("\t"));
- }
- return true;
- },
- Backspace: chainCommands(deleteSelection, (state, dispatch, tr_inner) => {
- // default backspace behavior for non-empty selections
- if (!state.selection.empty) {
- return false;
- }
- // default backspace behavior when math node is non-empty
- if (this._node.textContent.length > 0) {
- return false;
- }
- // otherwise, we want to delete the empty math node and focus the outer view
- this._outerView.dispatch(this._outerView.state.tr.insertText(""));
- this._outerView.focus();
- return true;
- }),
- // "Ctrl-Backspace": (state, dispatch, tr_inner) => {
- // // delete math node and focus the outer view
- // this._outerView.dispatch(this._outerView.state.tr.insertText(""));
- // this._outerView.focus();
- // return true;
- // },
- Enter: chainCommands(newlineInCode, collapseMathNode(this._outerView, +1, false)),
- "Ctrl-Enter": collapseMathNode(this._outerView, +1, false),
- ArrowLeft: collapseMathNode(this._outerView, -1, true),
- ArrowRight: collapseMathNode(this._outerView, +1, true),
- ArrowUp: collapseMathNode(this._outerView, -1, true),
- ArrowDown: collapseMathNode(this._outerView, +1, true),
- }),
- ],
- }),
- dispatchTransaction: this.dispatchInner.bind(this),
- });
- // focus element
- let innerState = this._innerView.state;
- this._innerView.focus();
- // request outer cursor position before math node was selected
- let maybePos = (_a = this._mathPluginKey.getState(this._outerView.state)) === null || _a === void 0 ? void 0 : _a.prevCursorPos;
- if (maybePos === null || maybePos === undefined) {
- console.error("[prosemirror-math] Error: Unable to fetch math plugin state from key.");
- }
- let prevCursorPos = maybePos !== null && maybePos !== void 0 ? maybePos : 0;
- // compute position that cursor should appear within the expanded math node
- let innerPos = prevCursorPos <= this._getPos() ? 0 : this._node.nodeSize - 2;
- setTimeout(() => {
- if (!this._innerView)
- return;
- this._innerView.focus();
- this._innerView.dispatch(innerState.tr.setSelection(TextSelection.create(innerState.doc, innerPos)));
- });
- this._isEditing = true;
- }
- /**
- * Called when the inner ProseMirror editor should close.
- *
- * @param render Optionally update the rendered math after closing. (which
- * is generally what we want to do, since the user is done editing!)
- */
- closeEditor(render = true) {
- if (this._innerView) {
- this._innerView.destroy();
- this._innerView = undefined;
- }
- if (render) {
- this.renderMath();
- }
- this._isEditing = false;
- }
-}
diff --git a/packages/editor/dist/es/extensions/math/plugin/math-plugin.d.ts b/packages/editor/dist/es/extensions/math/plugin/math-plugin.d.ts
deleted file mode 100644
index b7bd86a3f..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/math-plugin.d.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Node as ProseNode } from "prosemirror-model";
-import { Plugin as ProsePlugin } from "prosemirror-state";
-import { MathView } from "./math-node-view";
-import { EditorView } from "prosemirror-view";
-export interface IMathPluginState {
- macros: {
- [cmd: string]: string;
- };
- /** A list of currently active `NodeView`s, in insertion order. */
- activeNodeViews: MathView[];
- /**
- * Used to determine whether to place the cursor in the front- or back-most
- * position when expanding a math node, without overriding the default arrow
- * key behavior.
- */
- prevCursorPos: number;
-}
-/**
- * Returns a function suitable for passing as a field in `EditorProps.nodeViews`.
- * @param inline TRUE for block math, FALSE for inline math.
- * @see https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
- */
-export declare function createMathView(inline: boolean): (node: ProseNode, view: EditorView, getPos: boolean | (() => number)) => MathView;
-export declare const mathPlugin: ProsePlugin<IMathPluginState>;
diff --git a/packages/editor/dist/es/extensions/math/plugin/math-plugin.js b/packages/editor/dist/es/extensions/math/plugin/math-plugin.js
deleted file mode 100644
index 76c19e5be..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/math-plugin.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-import { Plugin as ProsePlugin, PluginKey, } from "prosemirror-state";
-import { MathView } from "./math-node-view";
-import { KatexRenderer } from "./renderers/katex";
-// uniquely identifies the prosemirror-math plugin
-const MATH_PLUGIN_KEY = new PluginKey("prosemirror-math");
-/**
- * Returns a function suitable for passing as a field in `EditorProps.nodeViews`.
- * @param inline TRUE for block math, FALSE for inline math.
- * @see https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
- */
-export function createMathView(inline) {
- return (node, view, getPos) => {
- /** @todo is this necessary?
- * Docs says that for any function proprs, the current plugin instance
- * will be bound to `this`. However, the typings don't reflect this.
- */
- let pluginState = MATH_PLUGIN_KEY.getState(view.state);
- if (!pluginState) {
- throw new Error("no math plugin!");
- }
- let nodeViews = pluginState.activeNodeViews;
- // set up NodeView
- let nodeView = new MathView(node, view, getPos, {
- className: inline ? "math-inline" : "math-block",
- renderer: inline ? KatexRenderer.inline : KatexRenderer.block,
- tagName: inline ? "span" : "div",
- }, MATH_PLUGIN_KEY, () => {
- nodeViews.splice(nodeViews.indexOf(nodeView));
- });
- nodeViews.push(nodeView);
- return nodeView;
- };
-}
-let mathPluginSpec = {
- key: MATH_PLUGIN_KEY,
- state: {
- init(config, instance) {
- return {
- macros: {},
- activeNodeViews: [],
- prevCursorPos: 0,
- };
- },
- apply(tr, value, oldState, newState) {
- // produce updated state field for this plugin
- const newPos = newState.selection.from;
- const oldPos = oldState.selection.from;
- return {
- // these values are left unchanged
- activeNodeViews: value.activeNodeViews,
- macros: value.macros,
- // update with the second-most recent cursor pos
- prevCursorPos: oldPos !== newPos ? oldPos : value.prevCursorPos,
- };
- },
- /** @todo (8/21/20) implement serialization for math plugin */
- // toJSON(value) { },
- // fromJSON(config, value, state){ return {}; }
- },
- props: {
- nodeViews: {
- mathInline: createMathView(true),
- mathBlock: createMathView(false),
- },
- },
-};
-export const mathPlugin = new ProsePlugin(mathPluginSpec);
diff --git a/packages/editor/dist/es/extensions/math/plugin/math-schema.d.ts b/packages/editor/dist/es/extensions/math/plugin/math-schema.d.ts
deleted file mode 100644
index 1bf09c98a..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/math-schema.d.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { MarkSpec, NodeSpec, Schema, SchemaSpec } from "prosemirror-model";
-import { SchemaSpecMarkT, SchemaSpecNodeT } from "./utils/types";
-/**
- * Borrowed from ProseMirror typings, modified to exclude OrderedMaps in spec,
- * in order to help with the schema-building functions below.
- *
- * NOTE: TypeScript's typings for the spread operator { ...a, ...b } are only
- * an approximation to the true type, and have difficulty with optional fields.
- * So, unlike the SchemaSpec type, the `marks` field is NOT optional here.
- *
- * function example<T extends string>(x: { [name in T]: string; } | null) {
- * const s = { ...x }; // inferred to have type `{}`.
- * }
- *
- * @see https://github.com/microsoft/TypeScript/issues/10727
- */
-interface SchemaSpecJson<N extends string = any, M extends string = any> extends SchemaSpec<N, M> {
- nodes: {
- [name in N]: NodeSpec;
- };
- marks: {
- [name in M]: MarkSpec;
- };
- topNode?: string;
-}
-declare type MathSpecNodeT = SchemaSpecNodeT<typeof mathSchemaSpec>;
-declare type MathSpecMarkT = SchemaSpecMarkT<typeof mathSchemaSpec>;
-export declare const mathSchemaSpec: SchemaSpecJson<"paragraph" | "text" | "doc" | "math_inline" | "math_display", "math_select">;
-/**
- * Use the prosemirror-math default SchemaSpec to create a new Schema.
- */
-export declare function createMathSchema(): Schema<"paragraph" | "text" | "doc" | "math_inline" | "math_display", "math_select">;
-/**
- * Create a new SchemaSpec by adding math nodes to an existing spec.
-
- * @deprecated This function is included for demonstration/testing only. For the
- * time being, I highly recommend adding the math nodes manually to your own
- * ProseMirror spec to avoid unexpected interactions between the math nodes
- * and your own spec. Use the example spec for reference.
- *
- * @param baseSpec The SchemaSpec to extend. Must specify a `marks` field, and
- * must be a raw object (not an OrderedMap).
- */
-export declare function extendMathSchemaSpec<N extends string, M extends string>(baseSpec: SchemaSpecJson<N, M>): SchemaSpecJson<N | MathSpecNodeT, M | MathSpecMarkT>;
-export {};
diff --git a/packages/editor/dist/es/extensions/math/plugin/math-schema.js b/packages/editor/dist/es/extensions/math/plugin/math-schema.js
deleted file mode 100644
index b844a7eec..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/math-schema.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-// prosemirror imports
-import { Schema, } from "prosemirror-model";
-import { defaultBlockMathParseRules, defaultInlineMathParseRules, } from "./plugins/math-paste-rules";
-////////////////////////////////////////////////////////////
-// force typescript to infer generic type arguments for SchemaSpec
-function createSchemaSpec(spec) {
- return spec;
-}
-// bare minimum ProseMirror schema for working with math nodes
-export const mathSchemaSpec = createSchemaSpec({
- nodes: {
- // :: NodeSpec top-level document node
- doc: {
- content: "block+",
- },
- paragraph: {
- content: "inline*",
- group: "block",
- parseDOM: [{ tag: "p" }],
- toDOM() {
- return ["p", 0];
- },
- },
- math_inline: {
- group: "inline math",
- content: "text*",
- inline: true,
- atom: true,
- toDOM: () => ["math-inline", { class: "math-node" }, 0],
- parseDOM: [{ tag: "math-inline" }, ...defaultInlineMathParseRules],
- },
- math_display: {
- group: "block math",
- content: "text*",
- atom: true,
- code: true,
- toDOM: () => ["math-display", { class: "math-node" }, 0],
- parseDOM: [{ tag: "math-display" }, ...defaultBlockMathParseRules],
- },
- text: {
- group: "inline",
- },
- },
- marks: {
- math_select: {
- toDOM() {
- return ["math-select", 0];
- },
- parseDOM: [{ tag: "math-select" }],
- },
- },
-});
-/**
- * Use the prosemirror-math default SchemaSpec to create a new Schema.
- */
-export function createMathSchema() {
- return new Schema(mathSchemaSpec);
-}
-/**
- * Create a new SchemaSpec by adding math nodes to an existing spec.
-
- * @deprecated This function is included for demonstration/testing only. For the
- * time being, I highly recommend adding the math nodes manually to your own
- * ProseMirror spec to avoid unexpected interactions between the math nodes
- * and your own spec. Use the example spec for reference.
- *
- * @param baseSpec The SchemaSpec to extend. Must specify a `marks` field, and
- * must be a raw object (not an OrderedMap).
- */
-export function extendMathSchemaSpec(baseSpec) {
- let nodes = Object.assign(Object.assign({}, baseSpec.nodes), mathSchemaSpec.nodes);
- let marks = Object.assign(Object.assign({}, baseSpec.marks), mathSchemaSpec.marks);
- return { nodes, marks, topNode: baseSpec.topNode };
-}
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-backspace.d.ts b/packages/editor/dist/es/extensions/math/plugin/plugins/math-backspace.d.ts
deleted file mode 100644
index 634f31931..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-backspace.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { Command as ProseCommand } from "prosemirror-state";
-export declare const mathBackspaceCmd: ProseCommand;
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-backspace.js b/packages/editor/dist/es/extensions/math/plugin/plugins/math-backspace.js
deleted file mode 100644
index 7fe2ab4a8..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-backspace.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { NodeSelection } from "prosemirror-state";
-export const mathBackspaceCmd = (state, dispatch) => {
- // check node before
- let { $from } = state.selection;
- let nodeBefore = $from.nodeBefore;
- if (!nodeBefore) {
- return false;
- }
- if (nodeBefore.type.name == "math_inline") {
- // select math node
- let index = $from.index($from.depth);
- let $beforePos = state.doc.resolve($from.posAtIndex(index - 1));
- if (dispatch) {
- dispatch(state.tr.setSelection(new NodeSelection($beforePos)));
- }
- return true;
- }
- else if (nodeBefore.type.name == "math_block") {
- /** @todo (8/1/20) implement backspace for math blocks
- * check how code blocks behave when pressing backspace
- */
- return false;
- }
- return false;
-};
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-inputrules.d.ts b/packages/editor/dist/es/extensions/math/plugin/plugins/math-inputrules.d.ts
deleted file mode 100644
index 92f1be7e5..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-inputrules.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { InputRule } from "prosemirror-inputrules";
-import { NodeType } from "prosemirror-model";
-export declare const REGEX_INLINE_MATH_DOLLARS: RegExp;
-export declare const REGEX_INLINE_MATH_DOLLARS_ESCAPED: RegExp;
-export declare const REGEX_BLOCK_MATH_DOLLARS: RegExp;
-export declare function makeInlineMathInputRule(pattern: RegExp, nodeType: NodeType, getAttrs?: (match: string[]) => any): InputRule;
-export declare function makeBlockMathInputRule(pattern: RegExp, nodeType: NodeType, getAttrs?: (match: string[]) => any): InputRule;
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-inputrules.js b/packages/editor/dist/es/extensions/math/plugin/plugins/math-inputrules.js
deleted file mode 100644
index b0811ef69..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-inputrules.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-import { InputRule } from "prosemirror-inputrules";
-import { NodeSelection } from "prosemirror-state";
-////////////////////////////////////////////////////////////
-// ---- Inline Input Rules ------------------------------ //
-// simple input rule for inline math
-export const REGEX_INLINE_MATH_DOLLARS = /\$\$(.+)\$\$/; //new RegExp("\$(.+)\$", "i");
-// negative lookbehind regex notation allows for escaped \$ delimiters
-// (requires browser supporting ECMA2018 standard -- currently only Chrome / FF)
-// (see https://javascript.info/regexp-lookahead-lookbehind)
-export const REGEX_INLINE_MATH_DOLLARS_ESCAPED = (() => {
- // attempt to create regex with negative lookbehind
- try {
- return new RegExp("(?<!\\\\)\\$(.+)(?<!\\\\)\\$");
- }
- catch (e) {
- return REGEX_INLINE_MATH_DOLLARS;
- }
-})();
-// ---- Block Input Rules ------------------------------- //
-// simple inputrule for block math
-export const REGEX_BLOCK_MATH_DOLLARS = /\$\$\$\s+$/; //new RegExp("\$\$\s+$", "i");
-////////////////////////////////////////////////////////////
-export function makeInlineMathInputRule(pattern, nodeType, getAttrs) {
- return new InputRule(pattern, (state, match, start, end) => {
- let $start = state.doc.resolve(start);
- let index = $start.index();
- let $end = state.doc.resolve(end);
- // get attrs
- let attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
- // check if replacement valid
- if (!$start.parent.canReplaceWith(index, $end.index(), nodeType)) {
- return null;
- }
- // perform replacement
- return state.tr.replaceRangeWith(start, end, nodeType.create(attrs, nodeType.schema.text(match[1])));
- });
-}
-export function makeBlockMathInputRule(pattern, nodeType, getAttrs) {
- return new InputRule(pattern, (state, match, start, end) => {
- let $start = state.doc.resolve(start);
- let attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
- if (!$start
- .node(-1)
- .canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType))
- return null;
- let tr = state.tr
- .delete(start, end)
- .setBlockType(start, start, nodeType, attrs);
- return tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map($start.pos - 1)));
- });
-}
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-paste-rules.d.ts b/packages/editor/dist/es/extensions/math/plugin/plugins/math-paste-rules.d.ts
deleted file mode 100644
index f6fb45c04..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-paste-rules.d.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Note that for some of the `ParseRule`s defined below,
- * we define a `getAttrs` function, which, other than
- * defining node attributes, can be used to describe complex
- * match conditions for a rule.
-
- * Returning `false` from `ParseRule.getAttrs` prevents the
- * rule from matching, while returning `null` indicates that
- * the default set of note attributes should be used.
- */
-import { ParseRule } from "prosemirror-model";
-/**
- * Wikipedia formats block math inside a <dl>...</dl> element, as below.
- *
- * - Evidently no CSS class is used to distinguish inline vs block math
- * - Sometimes the `\displaystyle` TeX command is present even in inline math
- *
- * ```html
- * <dl><dd><span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span></dd></dl>
- * ```
- */
-export declare const wikipediaBlockMathParseRule: ParseRule;
-/**
- * Parse rule for inline math content on Wikipedia of the following form:
- *
- * ```html
- * <span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span>
- * ```
- */
-export declare const wikipediaInlineMathParseRule: ParseRule;
-export declare const defaultInlineMathParseRules: ParseRule[];
-export declare const defaultBlockMathParseRules: ParseRule[];
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-paste-rules.js b/packages/editor/dist/es/extensions/math/plugin/plugins/math-paste-rules.js
deleted file mode 100644
index 007203e1f..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-paste-rules.js
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * Note that for some of the `ParseRule`s defined below,
- * we define a `getAttrs` function, which, other than
- * defining node attributes, can be used to describe complex
- * match conditions for a rule.
-
- * Returning `false` from `ParseRule.getAttrs` prevents the
- * rule from matching, while returning `null` indicates that
- * the default set of note attributes should be used.
- */
-import { Fragment, } from "prosemirror-model";
-////////////////////////////////////////////////////////////
-function getFirstMatch(root, rules) {
- for (let rule of rules) {
- let match = rule(root);
- if (match !== false) {
- return match;
- }
- }
- return false;
-}
-function makeTextFragment(text, schema) {
- return Fragment.from(schema.text(text));
-}
-////////////////////////////////////////////////////////////
-// -- Wikipedia ----------------------------------------- //
-/**
- * Look for a child node that matches the following template:
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- */
-function texFromMediaWikiFallbackImage(root) {
- var _a;
- let match = root.querySelector("img.mwe-math-fallback-image-inline[alt]");
- return (_a = match === null || match === void 0 ? void 0 : match.getAttribute("alt")) !== null && _a !== void 0 ? _a : false;
-}
-/**
- * Look for a child node that matches the following template:
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- */
-function texFromMathML_01(root) {
- var _a;
- let match = root.querySelector("math[alttext]");
- return (_a = match === null || match === void 0 ? void 0 : match.getAttribute("alttext")) !== null && _a !== void 0 ? _a : false;
-}
-/**
- * Look for a child node that matches the following template:
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- */
-function texFromMathML_02(root) {
- var _a;
- let match = root.querySelector("math annotation[encoding='application/x-tex'");
- return (_a = match === null || match === void 0 ? void 0 : match.textContent) !== null && _a !== void 0 ? _a : false;
-}
-/**
- * Look for a child node that matches the following template:
- * <script type="math/tex"></script>
- */
-function texFromScriptTag(root) {
- var _a;
- let match = root.querySelector("script[type*='math/tex']");
- return (_a = match === null || match === void 0 ? void 0 : match.textContent) !== null && _a !== void 0 ? _a : false;
-}
-function matchWikipedia(root) {
- let match = getFirstMatch(root, [
- texFromMediaWikiFallbackImage,
- texFromMathML_01,
- texFromMathML_02,
- ]);
- // TODO: if no tex string was found, but we have MathML, try to parse it
- return match;
-}
-/**
- * Wikipedia formats block math inside a <dl>...</dl> element, as below.
- *
- * - Evidently no CSS class is used to distinguish inline vs block math
- * - Sometimes the `\displaystyle` TeX command is present even in inline math
- *
- * ```html
- * <dl><dd><span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span></dd></dl>
- * ```
- */
-export const wikipediaBlockMathParseRule = {
- tag: "dl",
- getAttrs(p) {
- let dl = p;
- // <dl> must contain exactly one child
- if (dl.childElementCount !== 1) {
- return false;
- }
- let dd = dl.firstChild;
- if (dd.tagName !== "DD") {
- return false;
- }
- // <dd> must contain exactly one child
- if (dd.childElementCount !== 1) {
- return false;
- }
- let mweElt = dd.firstChild;
- if (!mweElt.classList.contains("mwe-math-element")) {
- return false;
- }
- // success! proceed to `getContent` for further processing
- return null;
- },
- getContent(p, schema) {
- // search the matched element for a TeX string
- let match = matchWikipedia(p);
- // return a fragment representing the math node's children
- let texString = match || "\\text{\\color{red}(paste error)}";
- return makeTextFragment(texString, schema);
- },
-};
-/**
- * Parse rule for inline math content on Wikipedia of the following form:
- *
- * ```html
- * <span class="mwe-math-element">
- * <span class="mwe-math-mathml-inline mwe-math-mathml-ally" style="...">
- * <math xmlns="http://www.w3.org/1998/Math/MathML" alttext="...">
- * <semantics>
- * <mrow class="MJX-TeXAtom-ORD">...</mrow>
- * <annotation encoding="application/x-tex">...</annotation>
- * </semantics>
- * </math>
- * <img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/..."
- * class="mwe-math-fallback-image-inline"
- * alt="..." />
- * </span>
- * </span>
- * ```
- */
-export const wikipediaInlineMathParseRule = {
- tag: "span",
- getAttrs(p) {
- let span = p;
- if (!span.classList.contains("mwe-math-element")) {
- return false;
- }
- // success! proceed to `getContent` for further processing
- return null;
- },
- getContent(p, schema) {
- // search the matched element for a TeX string
- let match = matchWikipedia(p);
- // return a fragment representing the math node's children
- let texString = match || "\\text{\\color{red}(paste error)}";
- return makeTextFragment(texString, schema);
- },
-};
-// -- MathJax ------------------------------------------- //
-////////////////////////////////////////////////////////////
-export const defaultInlineMathParseRules = [
- wikipediaInlineMathParseRule,
-];
-export const defaultBlockMathParseRules = [
- wikipediaBlockMathParseRule,
-];
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-select.d.ts b/packages/editor/dist/es/extensions/math/plugin/plugins/math-select.d.ts
deleted file mode 100644
index fa6e7915e..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-select.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Plugin as ProsePlugin } from "prosemirror-state";
-/**
- * Due to the internals of KaTeX, by default, selecting rendered
- * math will put a box around each individual character of a
- * math expression. This plugin attempts to make math selections
- * slightly prettier by instead setting a background color on the node.
- *
- * (remember to use the included math.css!)
- *
- * @todo (6/13/20) math selection rectangles are not quite even with text
- */
-export declare const mathSelectPlugin: ProsePlugin;
diff --git a/packages/editor/dist/es/extensions/math/plugin/plugins/math-select.js b/packages/editor/dist/es/extensions/math/plugin/plugins/math-select.js
deleted file mode 100644
index dedb5f71d..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/plugins/math-select.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/*---------------------------------------------------------
- * Author: Benjamin R. Bray
- * License: MIT (see LICENSE in project root for details)
- *--------------------------------------------------------*/
-// prosemirror imports
-import { Plugin as ProsePlugin, } from "prosemirror-state";
-import { DecorationSet, Decoration } from "prosemirror-view";
-////////////////////////////////////////////////////////////
-/**
- * Uses the selection to determine which math_select decorations
- * should be applied to the given document.
- * @param arg Should be either a Transaction or an EditorState,
- * although any object with `selection` and `doc` will work.
- */
-const checkSelection = (arg) => {
- let { from, to } = arg.selection;
- let content = arg.selection.content().content;
- let result = [];
- content.descendants((node, pos, parent) => {
- if (node.type.name == "text") {
- return false;
- }
- if (node.type.name.startsWith("math_")) {
- result.push({
- start: Math.max(from + pos - 1, 0),
- end: from + pos + node.nodeSize - 1,
- });
- return false;
- }
- return true;
- });
- return DecorationSet.create(arg.doc, result.map(({ start, end }) => Decoration.node(start, end, { class: "math-select" })));
-};
-/**
- * Due to the internals of KaTeX, by default, selecting rendered
- * math will put a box around each individual character of a
- * math expression. This plugin attempts to make math selections
- * slightly prettier by instead setting a background color on the node.
- *
- * (remember to use the included math.css!)
- *
- * @todo (6/13/20) math selection rectangles are not quite even with text
- */
-export const mathSelectPlugin = new ProsePlugin({
- state: {
- init(config, partialState) {
- return checkSelection(partialState);
- },
- apply(tr, value, oldState, newState) {
- if (!tr.selection || !tr.selectionSet) {
- return oldState;
- }
- let sel = checkSelection(tr);
- return sel;
- },
- },
- props: {
- decorations: (state) => {
- return mathSelectPlugin.getState(state);
- },
- },
-});
diff --git a/packages/editor/dist/es/extensions/math/plugin/renderers/katex.d.ts b/packages/editor/dist/es/extensions/math/plugin/renderers/katex.d.ts
deleted file mode 100644
index 0b716cff8..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/renderers/katex.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { MathRenderer } from "./types";
-export declare const KatexRenderer: MathRenderer;
diff --git a/packages/editor/dist/es/extensions/math/plugin/renderers/katex.js b/packages/editor/dist/es/extensions/math/plugin/renderers/katex.js
deleted file mode 100644
index 50f945424..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/renderers/katex.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-function loadKatex() {
- return __awaiter(this, void 0, void 0, function* () {
- // @ts-ignore
- const { default: katex } = yield import("katex");
- // Chemistry formulas support
- // @ts-ignore
- yield import("katex/contrib/mhchem/mhchem");
- return katex;
- });
-}
-export const KatexRenderer = {
- inline: (text, element) => {
- loadKatex().then((katex) => {
- katex.render(text, element, {
- displayMode: false,
- globalGroup: true,
- throwOnError: false,
- });
- });
- },
- block: (text, element) => {
- loadKatex().then((katex) => {
- katex.render(text, element, {
- displayMode: true,
- globalGroup: true,
- throwOnError: false,
- });
- });
- },
-};
diff --git a/packages/editor/dist/es/extensions/math/plugin/renderers/types.d.ts b/packages/editor/dist/es/extensions/math/plugin/renderers/types.d.ts
deleted file mode 100644
index 437b6338b..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/renderers/types.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export declare type MathRenderFn = (text: string, element: HTMLElement) => void;
-export declare type MathRenderer = {
- inline: MathRenderFn;
- block: MathRenderFn;
-};
diff --git a/packages/editor/dist/es/extensions/math/plugin/renderers/types.js b/packages/editor/dist/es/extensions/math/plugin/renderers/types.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/renderers/types.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/editor/dist/es/extensions/math/plugin/utils/text-serializer.d.ts b/packages/editor/dist/es/extensions/math/plugin/utils/text-serializer.d.ts
deleted file mode 100644
index 4e03d2a81..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/utils/text-serializer.d.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Node as ProseNode, Mark, Slice, NodeType, MarkType, Fragment } from "prosemirror-model";
-declare type TypedNode<T extends string> = ProseNode & {
- type: NodeType & {
- name: T;
- };
-};
-declare type TypedMark<T extends string> = Mark & {
- type: MarkType & {
- name: T;
- };
-};
-declare type NodeSerializer<T extends string> = (node: TypedNode<T>) => string;
-declare type MarkSerializer<T extends string> = (mark: TypedMark<T>) => string;
-declare class ProseMirrorTextSerializer {
- nodes: {
- [name: string]: NodeSerializer<string> | undefined;
- };
- marks: {
- [name: string]: MarkSerializer<string> | undefined;
- };
- constructor(fns: {
- nodes?: {
- [name: string]: NodeSerializer<string> | undefined;
- };
- marks?: {
- [name: string]: MarkSerializer<string> | undefined;
- };
- }, base?: ProseMirrorTextSerializer);
- serializeFragment(fragment: Fragment): string;
- serializeSlice(slice: Slice): string;
- serializeNode(node: ProseNode): string | null;
-}
-export declare const mathSerializer: ProseMirrorTextSerializer;
-export {};
diff --git a/packages/editor/dist/es/extensions/math/plugin/utils/text-serializer.js b/packages/editor/dist/es/extensions/math/plugin/utils/text-serializer.js
deleted file mode 100644
index 50cd63595..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/utils/text-serializer.js
+++ /dev/null
@@ -1,58 +0,0 @@
-class ProseMirrorTextSerializer {
- constructor(fns, base) {
- // use base serializer as a fallback
- this.nodes = Object.assign(Object.assign({}, base === null || base === void 0 ? void 0 : base.nodes), fns.nodes);
- this.marks = Object.assign(Object.assign({}, base === null || base === void 0 ? void 0 : base.marks), fns.marks);
- }
- serializeFragment(fragment) {
- // adapted from the undocumented `Fragment.textBetween` function
- // https://github.com/ProseMirror/prosemirror-model/blob/eef20c8c6dbf841b1d70859df5d59c21b5108a4f/src/fragment.js#L46
- let blockSeparator = "\n\n";
- let leafText = undefined;
- let text = "";
- let separated = true;
- let from = 0;
- let to = fragment.size;
- fragment.nodesBetween(from, to, (node, pos) => {
- var _a;
- // check if one of our custom serializers handles this node
- let serialized = this.serializeNode(node);
- if (serialized !== null) {
- text += serialized;
- return false;
- }
- if (node.isText) {
- text += ((_a = node.text) === null || _a === void 0 ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos)) || "";
- separated = !blockSeparator;
- }
- else if (node.isLeaf && leafText) {
- text += leafText;
- separated = !blockSeparator;
- }
- else if (!separated && node.isBlock) {
- text += blockSeparator;
- separated = true;
- }
- }, 0);
- return text;
- }
- serializeSlice(slice) {
- return this.serializeFragment(slice.content);
- }
- serializeNode(node) {
- // check if one of our custom serializers handles this node
- let nodeSerializer = this.nodes[node.type.name];
- if (nodeSerializer !== undefined) {
- return nodeSerializer(node);
- }
- else {
- return null;
- }
- }
-}
-export const mathSerializer = new ProseMirrorTextSerializer({
- nodes: {
- math_inline: (node) => `$${node.textContent}$`,
- math_display: (node) => `\n\n$$\n${node.textContent}\n$$`,
- },
-});
diff --git a/packages/editor/dist/es/extensions/math/plugin/utils/types.d.ts b/packages/editor/dist/es/extensions/math/plugin/utils/types.d.ts
deleted file mode 100644
index 6792b9f33..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/utils/types.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { Schema, SchemaSpec } from "prosemirror-model";
-export declare type SchemaSpecNodeT<Spec> = Spec extends SchemaSpec<infer N, infer _> ? N : never;
-export declare type SchemaSpecMarkT<Spec> = Spec extends SchemaSpec<infer _, infer M> ? M : never;
-export declare type SchemaNodeT<S> = S extends Schema<infer N, infer _> ? N : never;
-export declare type SchemaMarkT<S> = S extends Schema<infer _, infer M> ? M : never;
diff --git a/packages/editor/dist/es/extensions/math/plugin/utils/types.js b/packages/editor/dist/es/extensions/math/plugin/utils/types.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/packages/editor/dist/es/extensions/math/plugin/utils/types.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/editor/dist/es/extensions/orderedlist/index.d.ts b/packages/editor/dist/es/extensions/orderedlist/index.d.ts
deleted file mode 100644
index e5d88c387..000000000
--- a/packages/editor/dist/es/extensions/orderedlist/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { OrderedList } from "./ordered-list";
-export * from "./ordered-list";
-export default OrderedList;
diff --git a/packages/editor/dist/es/extensions/orderedlist/index.js b/packages/editor/dist/es/extensions/orderedlist/index.js
deleted file mode 100644
index e5d88c387..000000000
--- a/packages/editor/dist/es/extensions/orderedlist/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { OrderedList } from "./ordered-list";
-export * from "./ordered-list";
-export default OrderedList;
diff --git a/packages/editor/dist/es/extensions/orderedlist/orderedlist.d.ts b/packages/editor/dist/es/extensions/orderedlist/orderedlist.d.ts
deleted file mode 100644
index 16afc3a43..000000000
--- a/packages/editor/dist/es/extensions/orderedlist/orderedlist.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const OrderedList: import("@tiptap/core").Node<import("@tiptap/extension-ordered-list").OrderedListOptions, any>;
diff --git a/packages/editor/dist/es/extensions/orderedlist/orderedlist.js b/packages/editor/dist/es/extensions/orderedlist/orderedlist.js
deleted file mode 100644
index fd2d9fc0a..000000000
--- a/packages/editor/dist/es/extensions/orderedlist/orderedlist.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import TiptapOrderedList from "@tiptap/extension-ordered-list";
-export const OrderedList = TiptapOrderedList.extend({
- addAttributes() {
- return {
- listType: {
- default: null,
- parseHTML: (element) => element.style.listStyleType,
- renderHTML: (attributes) => {
- if (!attributes.listType) {
- return {};
- }
- return {
- style: `list-style-type: ${attributes.listType}`,
- };
- },
- },
- };
- },
-});
diff --git a/packages/editor/dist/es/extensions/outlinelist/component.d.ts b/packages/editor/dist/es/extensions/outlinelist/component.d.ts
deleted file mode 100644
index 2e64b6e02..000000000
--- a/packages/editor/dist/es/extensions/outlinelist/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-import { OutlineListAttributes } from "./outline-list";
-export declare function OutlineListComponent(props: ReactNodeViewProps<OutlineListAttributes>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/outlinelist/component.js b/packages/editor/dist/es/extensions/outlinelist/component.js
deleted file mode 100644
index 07a9da082..000000000
--- a/packages/editor/dist/es/extensions/outlinelist/component.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
-import { Text } from "rebass";
-import { useMemo } from "react";
-import { OutlineListItem } from "../outline-list-item";
-export function OutlineListComponent(props) {
- const { editor, getPos, node, updateAttributes, forwardRef } = props;
- const { collapsed } = node.attrs;
- const isNested = useMemo(() => {
- var _a;
- const pos = editor.state.doc.resolve(getPos());
- return ((_a = pos.parent) === null || _a === void 0 ? void 0 : _a.type.name) === OutlineListItem.name;
- }, []);
- return (_jsx(_Fragment, { children: _jsx(Text, { className: "outline-list", as: "div", ref: forwardRef, sx: {
- ul: {
- display: collapsed ? "none" : "block",
- paddingInlineStart: 0,
- paddingLeft: 0,
- marginBlockStart: isNested ? 5 : 0,
- marginBlockEnd: 0
- },
- li: {
- listStyleType: "none"
- }
- } }) }));
-}
diff --git a/packages/editor/dist/es/extensions/outlinelist/index.d.ts b/packages/editor/dist/es/extensions/outlinelist/index.d.ts
deleted file mode 100644
index 5aec1c8aa..000000000
--- a/packages/editor/dist/es/extensions/outlinelist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./outline-list";
diff --git a/packages/editor/dist/es/extensions/outlinelist/index.js b/packages/editor/dist/es/extensions/outlinelist/index.js
deleted file mode 100644
index 5aec1c8aa..000000000
--- a/packages/editor/dist/es/extensions/outlinelist/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./outline-list";
diff --git a/packages/editor/dist/es/extensions/outlinelist/outlinelist.d.ts b/packages/editor/dist/es/extensions/outlinelist/outlinelist.d.ts
deleted file mode 100644
index 5c1a1f21f..000000000
--- a/packages/editor/dist/es/extensions/outlinelist/outlinelist.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Node } from "@tiptap/core";
-export declare type OutlineListAttributes = {
- collapsed: boolean;
-};
-export interface OutlineListOptions {
- HTMLAttributes: Record<string, any>;
-}
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- outlineList: {
- /**
- * Toggle a bullet list
- */
- toggleOutlineList: () => ReturnType;
- };
- }
-}
-export declare const inputRegex: RegExp;
-export declare const OutlineList: Node<OutlineListOptions, any>;
diff --git a/packages/editor/dist/es/extensions/outlinelist/outlinelist.js b/packages/editor/dist/es/extensions/outlinelist/outlinelist.js
deleted file mode 100644
index 90c113c63..000000000
--- a/packages/editor/dist/es/extensions/outlinelist/outlinelist.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import { Node, mergeAttributes, wrappingInputRule } from "@tiptap/core";
-import { createNodeView } from "../react";
-import { OutlineListComponent } from "./component";
-export const inputRegex = /^\s*(-o)\s$/;
-const outlineListItemName = `outlineListItem`;
-export const OutlineList = Node.create({
- name: "outlineList",
- addOptions() {
- return {
- HTMLAttributes: {},
- };
- },
- addAttributes() {
- return {
- collapsed: {
- default: false,
- keepOnSplit: false,
- parseHTML: (element) => element.dataset.collapsed === "true",
- renderHTML: (attributes) => ({
- "data-collapsed": attributes.collapsed === true,
- }),
- },
- };
- },
- group: "block list",
- content: `${outlineListItemName}+`,
- parseHTML() {
- return [
- {
- tag: `ul[data-type="${this.name}"]`,
- priority: 52,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "ul",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- "data-type": this.name,
- }),
- 0,
- ];
- },
- addCommands() {
- return {
- toggleOutlineList: () => ({ commands }) => {
- return commands.toggleList(this.name, outlineListItemName);
- },
- };
- },
- addKeyboardShortcuts() {
- return {
- "Mod-Shift-O": () => this.editor.commands.toggleOutlineList(),
- };
- },
- addInputRules() {
- return [
- wrappingInputRule({
- find: inputRegex,
- type: this.type,
- }),
- ];
- },
- addNodeView() {
- return createNodeView(OutlineListComponent, {
- contentDOMFactory: () => {
- const content = document.createElement("ul");
- content.classList.add(`${this.name.toLowerCase()}-content-wrapper`);
- content.style.whiteSpace = "inherit";
- return { dom: content };
- },
- });
- },
-});
diff --git a/packages/editor/dist/es/extensions/outlinelistitem/component.d.ts b/packages/editor/dist/es/extensions/outlinelistitem/component.d.ts
deleted file mode 100644
index 26d37f4a2..000000000
--- a/packages/editor/dist/es/extensions/outlinelistitem/component.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-export declare function OutlineListItemComponent(props: ReactNodeViewProps): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/outlinelistitem/component.js b/packages/editor/dist/es/extensions/outlinelistitem/component.js
deleted file mode 100644
index f9405065c..000000000
--- a/packages/editor/dist/es/extensions/outlinelistitem/component.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Box, Flex, Text } from "rebass";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { findChildren } from "@tiptap/core";
-import { OutlineList } from "../outline-list/outline-list";
-import { useIsMobile } from "../../toolbar/stores/toolbar-store";
-export function OutlineListItemComponent(props) {
- var _a, _b;
- const { editor, updateAttributes, node, getPos, forwardRef } = props;
- const isMobile = useIsMobile();
- const isNested = ((_a = node.lastChild) === null || _a === void 0 ? void 0 : _a.type.name) === OutlineList.name;
- const isCollapsed = isNested && ((_b = node.lastChild) === null || _b === void 0 ? void 0 : _b.attrs.collapsed);
- const onClick = () => {
- const [subList] = findChildren(node, (node) => node.type.name === OutlineList.name);
- if (!subList)
- return;
- const { pos } = subList;
- editor.commands.toggleOutlineCollapse(pos + getPos() + 1, !isCollapsed);
- };
- return (_jsxs(Flex, { children: [_jsxs(Flex, Object.assign({ className: "outline", sx: {
- flexDirection: "column",
- alignItems: "center",
- mt: isMobile ? "0px" : "3px"
- } }, { children: [isNested ? (_jsx(Icon, { path: isCollapsed ? Icons.chevronRight : Icons.chevronDown, title: isCollapsed
- ? "Click to uncollapse list"
- : "Click to collapse list", sx: {
- cursor: "pointer",
- transition: `all .2s ease-in-out`,
- ":hover": {
- transform: ["unset", "scale(1.3)"]
- },
- ":active": {
- transform: ["scale(1.3)", "unset"]
- },
- ".icon:hover path": {
- fill: "var(--checked) !important"
- }
- }, size: isMobile ? 24 : 18, onMouseDown: (e) => e.preventDefault(), onTouchEnd: (e) => {
- e.preventDefault();
- onClick();
- }, onClick: onClick })) : (_jsx(Icon, { path: Icons.circle, size: isMobile ? 24 : 18, sx: { transform: "scale(0.4)" } })), isNested && !isCollapsed && (_jsx(Box, { sx: {
- flex: 1,
- width: 1,
- mt: 2,
- backgroundColor: "border",
- borderRadius: 50,
- flexShrink: 0,
- cursor: "pointer",
- transition: `all .2s ease-in-out`,
- ":hover": {
- backgroundColor: "fontTertiary",
- width: 4
- }
- }, contentEditable: false }))] })), _jsx(Text, { ref: forwardRef, sx: {
- pl: 1,
- listStyleType: "none",
- flex: 1
- } })] }));
-}
diff --git a/packages/editor/dist/es/extensions/outlinelistitem/index.d.ts b/packages/editor/dist/es/extensions/outlinelistitem/index.d.ts
deleted file mode 100644
index 1b1e56bc7..000000000
--- a/packages/editor/dist/es/extensions/outlinelistitem/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./outline-list-item";
diff --git a/packages/editor/dist/es/extensions/outlinelistitem/index.js b/packages/editor/dist/es/extensions/outlinelistitem/index.js
deleted file mode 100644
index 1b1e56bc7..000000000
--- a/packages/editor/dist/es/extensions/outlinelistitem/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./outline-list-item";
diff --git a/packages/editor/dist/es/extensions/outlinelistitem/outlinelistitem.d.ts b/packages/editor/dist/es/extensions/outlinelistitem/outlinelistitem.d.ts
deleted file mode 100644
index d9742f1d1..000000000
--- a/packages/editor/dist/es/extensions/outlinelistitem/outlinelistitem.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Node } from "@tiptap/core";
-export interface ListItemOptions {
- HTMLAttributes: Record<string, any>;
-}
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- outlineListItem: {
- toggleOutlineCollapse: (subListPos: number, state: boolean) => ReturnType;
- };
- }
-}
-export declare const OutlineListItem: Node<ListItemOptions, any>;
diff --git a/packages/editor/dist/es/extensions/outlinelistitem/outlinelistitem.js b/packages/editor/dist/es/extensions/outlinelistitem/outlinelistitem.js
deleted file mode 100644
index 876a52bf4..000000000
--- a/packages/editor/dist/es/extensions/outlinelistitem/outlinelistitem.js
+++ /dev/null
@@ -1,99 +0,0 @@
-import { Node, mergeAttributes, findChildren } from "@tiptap/core";
-import { findParentNodeOfTypeClosestToPos } from "prosemirror-utils";
-import { onBackspacePressed } from "../list-item/commands";
-import { OutlineList } from "../outline-list/outline-list";
-import { createNodeView } from "../react";
-import { OutlineListItemComponent } from "./component";
-export const OutlineListItem = Node.create({
- name: "outlineListItem",
- addOptions() {
- return {
- HTMLAttributes: {},
- };
- },
- content: "heading* paragraph block*",
- defining: true,
- parseHTML() {
- return [
- {
- tag: `li[data-type="${this.name}"]`,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "li",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- "data-type": this.name,
- }),
- 0,
- ];
- },
- addKeyboardShortcuts() {
- return {
- "Mod-Space": ({ editor }) => {
- const subList = findSublist(editor, this.type);
- if (!subList)
- return false;
- const { isCollapsed, subListPos } = subList;
- return this.editor.commands.toggleOutlineCollapse(subListPos, !isCollapsed);
- },
- Enter: ({ editor }) => {
- // const subList = findSublist(editor, this.type);
- // if (!subList) return this.editor.commands.splitListItem(this.name);
- // const { isCollapsed, subListPos } = subList;
- // if (isCollapsed) {
- // return this.editor.commands.toggleOutlineCollapse(subListPos, false);
- // }
- return this.editor.commands.splitListItem(this.name);
- },
- Tab: () => this.editor.commands.sinkListItem(this.name),
- "Shift-Tab": () => this.editor.commands.liftListItem(this.name),
- Backspace: ({ editor }) => onBackspacePressed(editor, this.name, this.type),
- };
- },
- addCommands() {
- return {
- toggleOutlineCollapse: (pos, state) => ({ tr }) => {
- tr.setNodeMarkup(pos, undefined, {
- collapsed: state,
- });
- return true;
- },
- };
- },
- addNodeView() {
- return createNodeView(OutlineListItemComponent, {
- contentDOMFactory: true,
- wrapperFactory: () => document.createElement("li"),
- });
- },
-});
-function findSublist(editor, type) {
- var _a, _b;
- const { selection } = editor.state;
- const { $from } = selection;
- const listItem = findParentNodeOfTypeClosestToPos($from, type);
- if (!listItem)
- return false;
- const [subList] = findChildren(listItem.node, (node) => node.type.name === OutlineList.name);
- if (!subList)
- return false;
- const isNested = ((_a = subList === null || subList === void 0 ? void 0 : subList.node) === null || _a === void 0 ? void 0 : _a.type.name) === OutlineList.name;
- const isCollapsed = (_b = subList === null || subList === void 0 ? void 0 : subList.node) === null || _b === void 0 ? void 0 : _b.attrs.collapsed;
- const subListPos = listItem.pos + subList.pos + 1;
- return { isCollapsed, isNested, subListPos };
- // return (
- // this.editor
- // .chain()
- // .command(({ tr }) => {
- // tr.setNodeMarkup(listItem.pos + subList.pos + 1, undefined, {
- // collapsed: !isCollapsed,
- // });
- // return true;
- // })
- // //.setTextSelection(listItem.pos + subList.pos + 1)
- // //.splitListItem(this.name)
- // .run()
- // );
-}
diff --git a/packages/editor/dist/es/extensions/react/eventdispatcher.d.ts b/packages/editor/dist/es/extensions/react/eventdispatcher.d.ts
deleted file mode 100644
index f9fba57a4..000000000
--- a/packages/editor/dist/es/extensions/react/eventdispatcher.d.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { PluginKey } from "prosemirror-state";
-export interface Listeners {
- [name: string]: Set<Listener>;
-}
-export declare type Listener<T = any> = (data: T) => void;
-export declare type Dispatch<T = any> = (eventName: PluginKey | string, data: T) => void;
-export declare class EventDispatcher<T = any> {
- private listeners;
- on(event: string, cb: Listener<T>): void;
- off(event: string, cb: Listener<T>): void;
- emit(event: string, data: T): void;
- destroy(): void;
-}
-/**
- * Creates a dispatch function that can be called inside ProseMirror Plugin
- * to notify listeners about that plugin's state change.
- */
-export declare function createDispatch<T>(eventDispatcher: EventDispatcher<T>): Dispatch<T>;
diff --git a/packages/editor/dist/es/extensions/react/eventdispatcher.js b/packages/editor/dist/es/extensions/react/eventdispatcher.js
deleted file mode 100644
index 96ce55866..000000000
--- a/packages/editor/dist/es/extensions/react/eventdispatcher.js
+++ /dev/null
@@ -1,43 +0,0 @@
-export class EventDispatcher {
- constructor() {
- this.listeners = {};
- }
- on(event, cb) {
- if (!this.listeners[event]) {
- this.listeners[event] = new Set();
- }
- this.listeners[event].add(cb);
- }
- off(event, cb) {
- if (!this.listeners[event]) {
- return;
- }
- if (this.listeners[event].has(cb)) {
- this.listeners[event].delete(cb);
- }
- }
- emit(event, data) {
- if (!this.listeners[event]) {
- return;
- }
- this.listeners[event].forEach((cb) => cb(data));
- }
- destroy() {
- this.listeners = {};
- }
-}
-/**
- * Creates a dispatch function that can be called inside ProseMirror Plugin
- * to notify listeners about that plugin's state change.
- */
-export function createDispatch(eventDispatcher) {
- return (eventName, data) => {
- if (!eventName) {
- throw new Error("event name is required!");
- }
- const event = typeof eventName === "string"
- ? eventName
- : eventName.key;
- eventDispatcher.emit(event, data);
- };
-}
diff --git a/packages/editor/dist/es/extensions/react/index.d.ts b/packages/editor/dist/es/extensions/react/index.d.ts
deleted file mode 100644
index db315768f..000000000
--- a/packages/editor/dist/es/extensions/react/index.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from "./react-node-view";
-export * from "./types";
-export * from "./react-portal-provider";
-export * from "./selection-based-react-node-view";
-export * from "./plugin";
-export * from "./event-dispatcher";
diff --git a/packages/editor/dist/es/extensions/react/index.js b/packages/editor/dist/es/extensions/react/index.js
deleted file mode 100644
index db315768f..000000000
--- a/packages/editor/dist/es/extensions/react/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from "./react-node-view";
-export * from "./types";
-export * from "./react-portal-provider";
-export * from "./selection-based-react-node-view";
-export * from "./plugin";
-export * from "./event-dispatcher";
diff --git a/packages/editor/dist/es/extensions/react/plugin.d.ts b/packages/editor/dist/es/extensions/react/plugin.d.ts
deleted file mode 100644
index 032e5008b..000000000
--- a/packages/editor/dist/es/extensions/react/plugin.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Plugin, PluginKey } from "prosemirror-state";
-import { Extension } from "@tiptap/core";
-export declare type StateChangeHandler = (fromPos: number, toPos: number) => any;
-export declare class ReactNodeViewState {
- private changeHandlers;
- constructor();
- subscribe(cb: StateChangeHandler): void;
- unsubscribe(cb: StateChangeHandler): void;
- notifyNewSelection(fromPos: number, toPos: number): void;
-}
-export declare const stateKey: PluginKey<any>;
-export declare const NodeViewSelectionNotifierPlugin: Plugin<ReactNodeViewState>;
-export declare const NodeViewSelectionNotifier: Extension<any, any>;
diff --git a/packages/editor/dist/es/extensions/react/plugin.js b/packages/editor/dist/es/extensions/react/plugin.js
deleted file mode 100644
index 15fc68405..000000000
--- a/packages/editor/dist/es/extensions/react/plugin.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Plugin, PluginKey } from "prosemirror-state";
-import { Extension } from "@tiptap/core";
-export class ReactNodeViewState {
- constructor() {
- this.changeHandlers = [];
- this.changeHandlers = [];
- }
- subscribe(cb) {
- this.changeHandlers.push(cb);
- }
- unsubscribe(cb) {
- this.changeHandlers = this.changeHandlers.filter((ch) => ch !== cb);
- }
- notifyNewSelection(fromPos, toPos) {
- this.changeHandlers.forEach((cb) => cb(fromPos, toPos));
- }
-}
-export const stateKey = new PluginKey("reactNodeView");
-export const NodeViewSelectionNotifierPlugin = new Plugin({
- state: {
- init() {
- return new ReactNodeViewState();
- },
- apply(_tr, pluginState) {
- return pluginState;
- },
- },
- key: stateKey,
- view: (view) => {
- const pluginState = stateKey.getState(view.state);
- return {
- update: (view) => {
- const { from, to } = view.state.selection;
- pluginState.notifyNewSelection(from, to);
- },
- };
- },
-});
-export const NodeViewSelectionNotifier = Extension.create({
- name: "node-view-selection-notifier",
- addProseMirrorPlugins() {
- return [NodeViewSelectionNotifierPlugin];
- },
-});
diff --git a/packages/editor/dist/es/extensions/react/reactnodeview.d.ts b/packages/editor/dist/es/extensions/react/reactnodeview.d.ts
deleted file mode 100644
index 0fc1c6e89..000000000
--- a/packages/editor/dist/es/extensions/react/reactnodeview.d.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from "react";
-import { NodeView, Decoration, DecorationSource } from "prosemirror-view";
-import { Node as PMNode } from "prosemirror-model";
-import { PortalProviderAPI } from "./react-portal-provider";
-import { ReactNodeViewProps, ReactNodeViewOptions, GetPosNode, ForwardRef, ContentDOM } from "./types";
-import { NodeViewRendererProps } from "@tiptap/core";
-import { Editor } from "../../types";
-export declare class ReactNodeView<P extends ReactNodeViewProps> implements NodeView {
- protected readonly editor: Editor;
- protected readonly getPos: GetPosNode;
- protected readonly options: ReactNodeViewOptions<P>;
- private domRef;
- private contentDOMWrapper?;
- contentDOM: HTMLElement | undefined;
- node: PMNode;
- isDragging: boolean;
- portalProviderAPI: PortalProviderAPI;
- constructor(node: PMNode, editor: Editor, getPos: GetPosNode, options: ReactNodeViewOptions<P>);
- /**
- * This method exists to move initialization logic out of the constructor,
- * so object can be initialized properly before calling render first time.
- *
- * Example:
- * Instance properties get added to an object only after super call in
- * constructor, which leads to some methods being undefined during the
- * first render.
- */
- init(): this;
- private renderReactComponent;
- createDomRef(): HTMLElement;
- getContentDOM(): ContentDOM;
- handleRef: (node: HTMLElement | null) => void;
- private _handleRef;
- render(props?: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
- updateAttributes(attributes: any, pos: number, addToHistory?: boolean, preventUpdate?: boolean): void;
- update(node: PMNode, _decorations: readonly Decoration[], _innerDecorations: DecorationSource): boolean;
- onDragStart(event: DragEvent): void;
- stopEvent(event: Event): boolean;
- ignoreMutation(mutation: MutationRecord | {
- type: "selection";
- target: Element;
- }): boolean;
- viewShouldUpdate(nextNode: PMNode): boolean;
- /**
- * Copies the attributes from a ProseMirror Node to a DOM node.
- * @param node The Prosemirror Node from which to source the attributes
- */
- setDomAttrs(node: PMNode, element: HTMLElement): void;
- get dom(): HTMLElement;
- destroy(): void;
-}
-export declare function createNodeView<TProps extends ReactNodeViewProps>(component: React.ComponentType<TProps>, options?: Omit<ReactNodeViewOptions<TProps>, "component">): ({ node, getPos, editor }: NodeViewRendererProps) => ReactNodeView<TProps>;
diff --git a/packages/editor/dist/es/extensions/react/reactnodeview.js b/packages/editor/dist/es/extensions/react/reactnodeview.js
deleted file mode 100644
index c8e5f74e3..000000000
--- a/packages/editor/dist/es/extensions/react/reactnodeview.js
+++ /dev/null
@@ -1,330 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { NodeSelection } from "prosemirror-state";
-// @ts-ignore
-import { __serializeForClipboard } from "prosemirror-view";
-import { ThemeProvider } from "../../components/theme-provider";
-export class ReactNodeView {
- constructor(node, editor, getPos, options) {
- this.editor = editor;
- this.getPos = getPos;
- this.options = options;
- this.isDragging = false;
- this.handleRef = (node) => this._handleRef(node);
- this.portalProviderAPI = editor.storage
- .portalProviderAPI;
- this.node = node;
- }
- /**
- * This method exists to move initialization logic out of the constructor,
- * so object can be initialized properly before calling render first time.
- *
- * Example:
- * Instance properties get added to an object only after super call in
- * constructor, which leads to some methods being undefined during the
- * first render.
- */
- init() {
- this.domRef = this.createDomRef();
- this.domRef.ondragstart = (ev) => this.onDragStart(ev);
- // this.setDomAttrs(this.node, this.domRef);
- const { dom: contentDOMWrapper, contentDOM } = this.getContentDOM() || {
- dom: undefined,
- contentDOM: undefined,
- };
- if (this.domRef && contentDOMWrapper) {
- this.domRef.appendChild(contentDOMWrapper);
- this.contentDOM = contentDOM ? contentDOM : contentDOMWrapper;
- this.contentDOMWrapper = contentDOMWrapper || contentDOM;
- }
- // @see ED-3790
- // something gets messed up during mutation processing inside of a
- // nodeView if DOM structure has nested plain "div"s, it doesn't see the
- // difference between them and it kills the nodeView
- this.domRef.classList.add(`${this.node.type.name}-view-content-wrap`);
- this.renderReactComponent(() => this.render(this.options.props, this.handleRef));
- return this;
- }
- renderReactComponent(component) {
- if (!this.domRef || !component || !this.portalProviderAPI) {
- console.warn("Cannot render node view", this.editor.storage);
- return;
- }
- this.portalProviderAPI.render(component, this.domRef);
- }
- createDomRef() {
- if (this.options.wrapperFactory)
- return this.options.wrapperFactory();
- if (!this.node.isInline) {
- return document.createElement("div");
- }
- const htmlElement = document.createElement("span");
- return htmlElement;
- }
- getContentDOM() {
- var _a, _b;
- if (!this.options.contentDOMFactory)
- return;
- if (this.options.contentDOMFactory === true) {
- const content = document.createElement("div");
- content.classList.add(`${this.node.type.name.toLowerCase()}-content-wrapper`);
- content.style.whiteSpace = "inherit";
- // caret is not visible if content element width is 0px
- content.style.minWidth = `20px`;
- return { dom: content };
- }
- return (_b = (_a = this.options).contentDOMFactory) === null || _b === void 0 ? void 0 : _b.call(_a);
- }
- _handleRef(node) {
- const contentDOM = this.contentDOMWrapper || this.contentDOM;
- // move the contentDOM node inside the inner reference after rendering
- if (node && contentDOM && !node.contains(contentDOM)) {
- node.appendChild(contentDOM);
- }
- }
- render(props = {}, forwardRef) {
- if (!this.options.component)
- return null;
- return (_jsx(ThemeProvider, { children: _jsx(this.options.component, Object.assign({}, props, { editor: this.editor, getPos: this.getPos, node: this.node, forwardRef: forwardRef, updateAttributes: (attr, options) => this.updateAttributes(attr, this.getPos(), options === null || options === void 0 ? void 0 : options.addToHistory, options === null || options === void 0 ? void 0 : options.preventUpdate) })) }));
- }
- updateAttributes(attributes, pos, addToHistory = false, preventUpdate = false) {
- this.editor.commands.command(({ tr }) => {
- tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), attributes));
- tr.setMeta("addToHistory", addToHistory);
- tr.setMeta("preventUpdate", preventUpdate);
- return true;
- });
- }
- update(node, _decorations, _innerDecorations
- // _innerDecorations?: Array<Decoration>,
- // validUpdate: (currentNode: PMNode, newNode: PMNode) => boolean = () => true
- ) {
- // @see https://github.com/ProseMirror/prosemirror/issues/648
- const isValidUpdate = this.node.type === node.type; // && validUpdate(this.node, node);
- if (!isValidUpdate) {
- return false;
- }
- // if (this.domRef && !this.node.sameMarkup(node)) {
- // this.setDomAttrs(node, this.domRef);
- // }
- // View should not process a re-render if this is false.
- // We dont want to destroy the view, so we return true.
- if (!this.viewShouldUpdate(node)) {
- this.node = node;
- return true;
- }
- this.node = node;
- this.renderReactComponent(() => this.render(this.options.props, this.handleRef));
- return true;
- }
- onDragStart(event) {
- var _a, _b, _c, _d, _e, _f, _g;
- const { view } = this.editor;
- const target = event.target;
- // get the drag handle element
- // `closest` is not available for text nodes so we may have to use its parent
- const dragHandle = target.nodeType === 3
- ? (_a = target.parentElement) === null || _a === void 0 ? void 0 : _a.closest("[data-drag-handle]")
- : target.closest("[data-drag-handle]");
- if (!this.dom || ((_b = this.contentDOM) === null || _b === void 0 ? void 0 : _b.contains(target)) || !dragHandle) {
- return;
- }
- const dragImage = this.dom.querySelector("[data-drag-image]") || this.dom;
- let x = 0;
- let y = 0;
- // calculate offset for drag element if we use a different drag handle element
- if (dragImage !== dragHandle) {
- const domBox = dragImage.getBoundingClientRect();
- const handleBox = dragHandle.getBoundingClientRect();
- // In React, we have to go through nativeEvent to reach offsetX/offsetY.
- const offsetX = (_c = event.offsetX) !== null && _c !== void 0 ? _c : (_d = event.nativeEvent) === null || _d === void 0 ? void 0 : _d.offsetX;
- const offsetY = (_e = event.offsetY) !== null && _e !== void 0 ? _e : (_f = event.nativeEvent) === null || _f === void 0 ? void 0 : _f.offsetY;
- x = handleBox.x - domBox.x + offsetX;
- y = handleBox.y - domBox.y + offsetY;
- }
- // we need to tell ProseMirror that we want to move the whole node
- // so we create a NodeSelection
- const selection = NodeSelection.create(view.state.doc, this.getPos());
- const transaction = view.state.tr.setSelection(selection);
- view.dispatch(transaction);
- (_g = event.dataTransfer) === null || _g === void 0 ? void 0 : _g.setDragImage(dragImage, x, y);
- forceHandleDrag(event, this.editor);
- }
- stopEvent(event) {
- var _a;
- if (!this.dom) {
- return false;
- }
- // if (typeof this.options.stopEvent === 'function') {
- // return this.options.stopEvent({ event })
- // }
- const target = event.target;
- const isInElement = this.dom.contains(target) && !((_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.contains(target));
- // any event from child nodes should be handled by ProseMirror
- if (!isInElement) {
- return false;
- }
- const isDropEvent = event.type === "drop";
- const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) ||
- target.isContentEditable;
- // any input event within node views should be ignored by ProseMirror
- if (isInput && !isDropEvent) {
- return true;
- }
- const { isEditable } = this.editor;
- const { isDragging } = this;
- const isDraggable = !!this.node.type.spec.draggable;
- const isSelectable = NodeSelection.isSelectable(this.node);
- const isCopyEvent = event.type === "copy";
- const isPasteEvent = event.type === "paste";
- const isCutEvent = event.type === "cut";
- const isClickEvent = event.type === "mousedown";
- const isDragEvent = event.type.startsWith("drag");
- // if (event instanceof DragEvent && event.dataTransfer) {
- // console.log(
- // `[${event.type}]:`,
- // this.editor.view.dragging,
- // event.dataTransfer.getData("Text"),
- // event.dataTransfer.getData("text/plain"),
- // event.dataTransfer.getData("text/html")
- // );
- // }
- // ProseMirror tries to drag selectable nodes
- // even if `draggable` is set to `false`
- // this fix prevents that
- if (!isDraggable && isSelectable && isDragEvent) {
- event.preventDefault();
- }
- if (isDraggable && isDragEvent && !isDragging) {
- event.preventDefault();
- return false;
- }
- // we have to store that dragging started
- if (isDraggable && isEditable && !isDragging && isClickEvent) {
- const dragHandle = target.closest("[data-drag-handle]");
- const isValidDragHandle = dragHandle &&
- (this.dom === dragHandle || this.dom.contains(dragHandle));
- if (isValidDragHandle) {
- this.isDragging = true;
- document.addEventListener("dragend", () => {
- this.isDragging = false;
- }, { once: true });
- document.addEventListener("mouseup", () => {
- this.isDragging = false;
- }, { once: true });
- }
- }
- // these events are handled by prosemirror
- if (isDragging ||
- isDropEvent ||
- isCopyEvent ||
- isPasteEvent ||
- isCutEvent ||
- (isClickEvent && isSelectable)) {
- return false;
- }
- return true;
- }
- ignoreMutation(mutation) {
- if (!this.dom || !this.contentDOM) {
- return true;
- }
- // TODO if (typeof this.options.ignoreMutation === 'function') {
- // return this.options.ignoreMutation({ mutation })
- // }
- // a leaf/atom node is like a black box for ProseMirror
- // and should be fully handled by the node view
- if (this.node.isLeaf || this.node.isAtom) {
- return true;
- }
- // ProseMirror should handle any selections
- if (mutation.type === "selection") {
- return false;
- }
- // try to prevent a bug on mobiles that will break node views on enter
- // this is because ProseMirror can’t preventDispatch on enter
- // this will lead to a re-render of the node view on enter
- // see: https://github.com/ueberdosis/tiptap/issues/1214
- if (this.dom.contains(mutation.target) &&
- mutation.type === "childList" &&
- this.editor.isFocused) {
- const changedNodes = [
- ...Array.from(mutation.addedNodes),
- ...Array.from(mutation.removedNodes),
- ];
- // we’ll check if every changed node is contentEditable
- // to make sure it’s probably mutated by ProseMirror
- if (changedNodes.every((node) => node.isContentEditable)) {
- return false;
- }
- }
- // we will allow mutation contentDOM with attributes
- // so we can for example adding classes within our node view
- if (this.contentDOM === mutation.target && mutation.type === "attributes") {
- return true;
- }
- // ProseMirror should handle any changes within contentDOM
- if (this.contentDOM.contains(mutation.target)) {
- return false;
- }
- return true;
- }
- viewShouldUpdate(nextNode) {
- if (this.options.shouldUpdate)
- return this.options.shouldUpdate(this.node, nextNode);
- return true;
- }
- /**
- * Copies the attributes from a ProseMirror Node to a DOM node.
- * @param node The Prosemirror Node from which to source the attributes
- */
- setDomAttrs(node, element) {
- Object.keys(node.attrs || {}).forEach((attr) => {
- element.setAttribute(attr, node.attrs[attr]);
- });
- }
- get dom() {
- return this.domRef;
- }
- destroy() {
- if (!this.domRef || !this.portalProviderAPI) {
- return;
- }
- this.portalProviderAPI.remove(this.domRef);
- // @ts-ignore NEW PM API
- this.domRef = undefined;
- this.contentDOM = undefined;
- }
-}
-export function createNodeView(component, options) {
- return ({ node, getPos, editor }) => {
- const _getPos = () => (typeof getPos === "boolean" ? -1 : getPos());
- return new ReactNodeView(node, editor, _getPos, Object.assign(Object.assign({}, options), { component })).init();
- };
-}
-// function isiOS(): boolean {
-// return (
-// [
-// "iPad Simulator",
-// "iPhone Simulator",
-// "iPod Simulator",
-// "iPad",
-// "iPhone",
-// "iPod",
-// ].includes(navigator.platform) ||
-// // iPad on iOS 13 detection
-// (navigator.userAgent.includes("Mac") && "ontouchend" in document)
-// );
-// }
-function forceHandleDrag(event, editor) {
- if (!event.dataTransfer)
- return;
- const { view } = editor;
- const slice = view.state.selection.content();
- const { dom, text } = __serializeForClipboard(view, slice);
- event.dataTransfer.clearData();
- event.dataTransfer.setData("Text", text);
- event.dataTransfer.setData("text/plain", text);
- event.dataTransfer.setData("text/html", dom.innerHTML);
- event.dataTransfer.effectAllowed = "copyMove";
- view.dragging = { slice, move: true };
-}
diff --git a/packages/editor/dist/es/extensions/react/reactportalprovider.d.ts b/packages/editor/dist/es/extensions/react/reactportalprovider.d.ts
deleted file mode 100644
index a6a95fd3e..000000000
--- a/packages/editor/dist/es/extensions/react/reactportalprovider.d.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import React, { PropsWithChildren } from "react";
-import { EventDispatcher } from "./event-dispatcher";
-export declare type BasePortalProviderProps = PropsWithChildren<{}>;
-export declare type Portals = Map<HTMLElement, React.ReactChild>;
-export declare type PortalRendererState = {
- portals: Portals;
-};
-declare type MountedPortal = {
- children: () => React.ReactChild | null;
-};
-export declare class PortalProviderAPI extends EventDispatcher {
- portals: Map<HTMLElement, MountedPortal>;
- context: any;
- constructor();
- setContext: (context: any) => void;
- render(children: () => React.ReactChild | JSX.Element | null, container: HTMLElement): void;
- forceUpdate(): void;
- remove(container: HTMLElement): void;
-}
-export declare function usePortalProvider(): PortalProviderAPI | undefined;
-export declare class PortalProvider extends React.Component<BasePortalProviderProps> {
- static displayName: string;
- portalProviderAPI: PortalProviderAPI;
- constructor(props: BasePortalProviderProps);
- render(): JSX.Element;
- componentDidUpdate(): void;
-}
-export declare class PortalRenderer extends React.Component<{
- portalProviderAPI: PortalProviderAPI;
-}, PortalRendererState> {
- constructor(props: {
- portalProviderAPI: PortalProviderAPI;
- });
- handleUpdate: (portals: Portals) => void;
- render(): JSX.Element;
-}
-export {};
diff --git a/packages/editor/dist/es/extensions/react/reactportalprovider.js b/packages/editor/dist/es/extensions/react/reactportalprovider.js
deleted file mode 100644
index 8bf1867bf..000000000
--- a/packages/editor/dist/es/extensions/react/reactportalprovider.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import React, { useContext } from "react";
-import { createPortal, unstable_renderSubtreeIntoContainer, unmountComponentAtNode, } from "react-dom";
-import { EventDispatcher } from "./event-dispatcher";
-export class PortalProviderAPI extends EventDispatcher {
- constructor() {
- super();
- this.portals = new Map();
- this.setContext = (context) => {
- this.context = context;
- };
- }
- render(children, container) {
- this.portals.set(container, {
- children,
- });
- let wrappedChildren = children();
- unstable_renderSubtreeIntoContainer(this.context, wrappedChildren, container);
- }
- // TODO: until https://product-fabric.atlassian.net/browse/ED-5013
- // we (unfortunately) need to re-render to pass down any updated context.
- // selectively do this for nodeviews that opt-in via `hasAnalyticsContext`
- forceUpdate() { }
- remove(container) {
- this.portals.delete(container);
- // There is a race condition that can happen caused by Prosemirror vs React,
- // where Prosemirror removes the container from the DOM before React gets
- // around to removing the child from the container
- // This will throw a NotFoundError: The node to be removed is not a child of this node
- // Both Prosemirror and React remove the elements asynchronously, and in edge
- // cases Prosemirror beats React
- try {
- unmountComponentAtNode(container);
- }
- catch (error) {
- // IGNORE console.error(error);
- }
- }
-}
-const PortalProviderContext = React.createContext(undefined);
-export function usePortalProvider() {
- return useContext(PortalProviderContext);
-}
-export class PortalProvider extends React.Component {
- constructor(props) {
- super(props);
- this.portalProviderAPI = new PortalProviderAPI();
- }
- render() {
- return (_jsxs(PortalProviderContext.Provider, Object.assign({ value: this.portalProviderAPI }, { children: [this.props.children, _jsx(PortalRenderer, { portalProviderAPI: this.portalProviderAPI })] })));
- }
- componentDidUpdate() {
- this.portalProviderAPI.forceUpdate();
- }
-}
-PortalProvider.displayName = "PortalProvider";
-export class PortalRenderer extends React.Component {
- constructor(props) {
- super(props);
- this.handleUpdate = (portals) => this.setState({ portals });
- props.portalProviderAPI.setContext(this);
- props.portalProviderAPI.on("update", this.handleUpdate);
- this.state = { portals: new Map() };
- }
- render() {
- const { portals } = this.state;
- return (_jsx(_Fragment, { children: Array.from(portals.entries()).map(([container, children]) => createPortal(children, container)) }));
- }
-}
diff --git a/packages/editor/dist/es/extensions/react/selectionbasedreactnodeview.d.ts b/packages/editor/dist/es/extensions/react/selectionbasedreactnodeview.d.ts
deleted file mode 100644
index fda86bb29..000000000
--- a/packages/editor/dist/es/extensions/react/selectionbasedreactnodeview.d.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import React from "react";
-import { Node as PMNode } from "prosemirror-model";
-import { ReactNodeViewOptions, GetPosNode, SelectionBasedReactNodeViewProps, ForwardRef } from "./types";
-import { ReactNodeView } from "./react-node-view";
-import { NodeViewRendererProps } from "@tiptap/core";
-import { Editor } from "../../types";
-/**
- * A ReactNodeView that handles React components sensitive
- * to selection changes.
- *
- * If the selection changes, it will attempt to re-render the
- * React component. Otherwise it does nothing.
- *
- * You can subclass `viewShouldUpdate` to include other
- * props that your component might want to consider before
- * entering the React lifecycle. These are usually props you
- * compare in `shouldComponentUpdate`.
- *
- * An example:
- *
- * ```
- * viewShouldUpdate(nextNode) {
- * if (nextNode.attrs !== this.node.attrs) {
- * return true;
- * }
- *
- * return super.viewShouldUpdate(nextNode);
- * }```
- */
-export declare class SelectionBasedNodeView<P extends SelectionBasedReactNodeViewProps> extends ReactNodeView<P> {
- private oldSelection;
- private selectionChangeState;
- pos: number;
- posEnd: number | undefined;
- constructor(node: PMNode, editor: Editor, getPos: GetPosNode, options: ReactNodeViewOptions<P>);
- render(props?: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
- /**
- * Update current node's start and end positions.
- *
- * Prefer `this.pos` rather than getPos(), because calling getPos is
- * expensive, unless you know you're definitely going to render.
- */
- private updatePos;
- private getPositionsWithDefault;
- isNodeInsideSelection: (from: number, to: number, pos?: number, posEnd?: number) => boolean;
- isSelectionInsideNode: (from: number, to: number, pos?: number, posEnd?: number) => boolean;
- private isSelectedNode;
- insideSelection: () => boolean;
- nodeInsideSelection: () => boolean;
- viewShouldUpdate(nextNode: PMNode): boolean;
- destroy(): void;
- private onSelectionChange;
-}
-export declare function createSelectionBasedNodeView<TProps extends SelectionBasedReactNodeViewProps>(component: React.ComponentType<TProps>, options?: Omit<ReactNodeViewOptions<TProps>, "component">): ({ node, getPos, editor }: NodeViewRendererProps) => SelectionBasedNodeView<TProps>;
diff --git a/packages/editor/dist/es/extensions/react/selectionbasedreactnodeview.js b/packages/editor/dist/es/extensions/react/selectionbasedreactnodeview.js
deleted file mode 100644
index b12aa43f9..000000000
--- a/packages/editor/dist/es/extensions/react/selectionbasedreactnodeview.js
+++ /dev/null
@@ -1,144 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { DecorationSet } from "prosemirror-view";
-import { NodeSelection } from "prosemirror-state";
-import { stateKey as SelectionChangePluginKey, } from "./plugin";
-import { ReactNodeView } from "./react-node-view";
-import { ThemeProvider } from "../../components/theme-provider";
-/**
- * A ReactNodeView that handles React components sensitive
- * to selection changes.
- *
- * If the selection changes, it will attempt to re-render the
- * React component. Otherwise it does nothing.
- *
- * You can subclass `viewShouldUpdate` to include other
- * props that your component might want to consider before
- * entering the React lifecycle. These are usually props you
- * compare in `shouldComponentUpdate`.
- *
- * An example:
- *
- * ```
- * viewShouldUpdate(nextNode) {
- * if (nextNode.attrs !== this.node.attrs) {
- * return true;
- * }
- *
- * return super.viewShouldUpdate(nextNode);
- * }```
- */
-export class SelectionBasedNodeView extends ReactNodeView {
- constructor(node, editor, getPos, options) {
- super(node, editor, getPos, options);
- this.pos = -1;
- this.isNodeInsideSelection = (from, to, pos, posEnd) => {
- ({ pos, posEnd } = this.getPositionsWithDefault(pos, posEnd));
- if (typeof pos !== "number" || typeof posEnd !== "number") {
- return false;
- }
- return from <= pos && to >= posEnd;
- };
- this.isSelectionInsideNode = (from, to, pos, posEnd) => {
- ({ pos, posEnd } = this.getPositionsWithDefault(pos, posEnd));
- if (typeof pos !== "number" || typeof posEnd !== "number") {
- return false;
- }
- return pos < from && to < posEnd;
- };
- this.isSelectedNode = (selection) => {
- if (selection instanceof NodeSelection) {
- const { selection: { from, to }, } = this.editor.view.state;
- return (selection.node === this.node ||
- // If nodes are not the same object, we check if they are referring to the same document node
- (this.pos === from &&
- this.posEnd === to &&
- selection.node.eq(this.node)));
- }
- return false;
- };
- this.insideSelection = () => {
- const { selection: { from, to }, } = this.editor.view.state;
- return (this.isSelectedNode(this.editor.view.state.selection) ||
- this.isSelectionInsideNode(from, to));
- };
- this.nodeInsideSelection = () => {
- const { selection } = this.editor.view.state;
- const { from, to } = selection;
- return (this.isSelectedNode(selection) || this.isNodeInsideSelection(from, to));
- };
- this.onSelectionChange = () => {
- this.update(this.node, [], DecorationSet.empty);
- };
- this.updatePos();
- this.oldSelection = editor.view.state.selection;
- this.selectionChangeState = SelectionChangePluginKey.getState(this.editor.view.state);
- this.selectionChangeState.subscribe(this.onSelectionChange);
- }
- render(props = {}, forwardRef) {
- if (!this.options.component)
- return null;
- const isSelected = this.editor.isEditable &&
- (this.insideSelection() || this.nodeInsideSelection());
- return (_jsx(ThemeProvider, { children: _jsx(this.options.component, Object.assign({}, props, { editor: this.editor, getPos: this.getPos, node: this.node, forwardRef: forwardRef, selected: isSelected, updateAttributes: (attr, options) => this.updateAttributes(attr, this.pos, options === null || options === void 0 ? void 0 : options.addToHistory, options === null || options === void 0 ? void 0 : options.preventUpdate) })) }));
- }
- /**
- * Update current node's start and end positions.
- *
- * Prefer `this.pos` rather than getPos(), because calling getPos is
- * expensive, unless you know you're definitely going to render.
- */
- updatePos() {
- if (typeof this.getPos === "boolean") {
- return;
- }
- this.pos = this.getPos();
- this.posEnd = this.pos + this.node.nodeSize;
- }
- getPositionsWithDefault(pos, posEnd) {
- return {
- pos: typeof pos !== "number" ? this.pos : pos,
- posEnd: typeof posEnd !== "number" ? this.posEnd : posEnd,
- };
- }
- viewShouldUpdate(nextNode) {
- if (super.viewShouldUpdate(nextNode))
- return true;
- const { state: { selection }, } = this.editor.view;
- // update selection
- const oldSelection = this.oldSelection;
- this.oldSelection = selection;
- // update cached positions
- const { pos: oldPos, posEnd: oldPosEnd } = this;
- this.updatePos();
- const { from, to } = selection;
- const { from: oldFrom, to: oldTo } = oldSelection;
- if (this.node.type.spec.selectable) {
- const newNodeSelection = selection instanceof NodeSelection && selection.from === this.pos;
- const oldNodeSelection = oldSelection instanceof NodeSelection && oldSelection.from === this.pos;
- if ((newNodeSelection && !oldNodeSelection) ||
- (oldNodeSelection && !newNodeSelection)) {
- return true;
- }
- }
- const movedInToSelection = this.isNodeInsideSelection(from, to) &&
- !this.isNodeInsideSelection(oldFrom, oldTo);
- const movedOutOfSelection = !this.isNodeInsideSelection(from, to) &&
- this.isNodeInsideSelection(oldFrom, oldTo);
- const moveOutFromOldSelection = this.isNodeInsideSelection(from, to, oldPos, oldPosEnd) &&
- !this.isNodeInsideSelection(from, to);
- if (movedInToSelection || movedOutOfSelection || moveOutFromOldSelection) {
- return true;
- }
- return false;
- }
- destroy() {
- this.selectionChangeState.unsubscribe(this.onSelectionChange);
- super.destroy();
- }
-}
-export function createSelectionBasedNodeView(component, options) {
- return ({ node, getPos, editor }) => {
- const _getPos = () => (typeof getPos === "boolean" ? -1 : getPos());
- return new SelectionBasedNodeView(node, editor, _getPos, Object.assign(Object.assign({}, options), { component })).init();
- };
-}
diff --git a/packages/editor/dist/es/extensions/react/types.d.ts b/packages/editor/dist/es/extensions/react/types.d.ts
deleted file mode 100644
index 516fcf4af..000000000
--- a/packages/editor/dist/es/extensions/react/types.d.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-import { Node as PMNode, Attrs } from "prosemirror-model";
-export interface ReactNodeProps {
- selected: boolean;
-}
-export declare type NodeWithAttrs<T> = PMNode & {
- attrs: T;
-};
-export declare type GetPos = GetPosNode | boolean;
-export declare type GetPosNode = () => number;
-export declare type ForwardRef = (node: HTMLElement | null) => void;
-export declare type ShouldUpdate = (prevNode: PMNode, nextNode: PMNode) => boolean;
-export declare type UpdateAttributes<T> = (attributes: Partial<T>, options?: {
- addToHistory?: boolean;
- preventUpdate?: boolean;
-}) => void;
-export declare type ContentDOM = {
- dom: HTMLElement;
- contentDOM?: HTMLElement | null | undefined;
-} | undefined;
-export declare type ReactNodeViewProps<TAttributes = Attrs> = {
- getPos: GetPosNode;
- node: NodeWithAttrs<TAttributes>;
- editor: Editor;
- updateAttributes: UpdateAttributes<TAttributes>;
- forwardRef?: ForwardRef;
-};
-export declare type SelectionBasedReactNodeViewProps<TAttributes = Attrs> = ReactNodeViewProps<TAttributes> & {
- selected: boolean;
-};
-export declare type ReactNodeViewOptions<P> = {
- props?: P;
- component?: React.ComponentType<P>;
- shouldUpdate?: ShouldUpdate;
- contentDOMFactory?: (() => ContentDOM) | boolean;
- wrapperFactory?: () => HTMLElement;
-};
diff --git a/packages/editor/dist/es/extensions/react/types.js b/packages/editor/dist/es/extensions/react/types.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/packages/editor/dist/es/extensions/react/types.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/editor/dist/es/extensions/searchreplace/index.d.ts b/packages/editor/dist/es/extensions/searchreplace/index.d.ts
deleted file mode 100644
index 8a016dad8..000000000
--- a/packages/editor/dist/es/extensions/searchreplace/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./search-replace";
diff --git a/packages/editor/dist/es/extensions/searchreplace/index.js b/packages/editor/dist/es/extensions/searchreplace/index.js
deleted file mode 100644
index 8a016dad8..000000000
--- a/packages/editor/dist/es/extensions/searchreplace/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./search-replace";
diff --git a/packages/editor/dist/es/extensions/searchreplace/searchreplace.d.ts b/packages/editor/dist/es/extensions/searchreplace/searchreplace.d.ts
deleted file mode 100644
index dc7b33bac..000000000
--- a/packages/editor/dist/es/extensions/searchreplace/searchreplace.d.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Extension } from "@tiptap/core";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- searchreplace: {
- startSearch: () => ReturnType;
- endSearch: () => ReturnType;
- search: (term: string, options?: SearchSettings) => ReturnType;
- moveToNextResult: () => ReturnType;
- moveToPreviousResult: () => ReturnType;
- replace: (term: string) => ReturnType;
- replaceAll: (term: string) => ReturnType;
- };
- }
-}
-interface Result {
- from: number;
- to: number;
-}
-interface SearchOptions {
- searchResultClass: string;
-}
-interface SearchSettings {
- matchCase: boolean;
- enableRegex: boolean;
- matchWholeWord: boolean;
-}
-export declare type SearchStorage = SearchSettings & {
- searchTerm: string;
- selectedIndex: number;
- isSearching: boolean;
- selectedText?: string;
- results?: Result[];
-};
-export declare const SearchReplace: Extension<SearchOptions, SearchStorage>;
-export {};
diff --git a/packages/editor/dist/es/extensions/searchreplace/searchreplace.js b/packages/editor/dist/es/extensions/searchreplace/searchreplace.js
deleted file mode 100644
index 8b22abd47..000000000
--- a/packages/editor/dist/es/extensions/searchreplace/searchreplace.js
+++ /dev/null
@@ -1,211 +0,0 @@
-import { Extension } from "@tiptap/core";
-import { Decoration, DecorationSet } from "prosemirror-view";
-import { Plugin, PluginKey, TextSelection, } from "prosemirror-state";
-const updateView = (state, dispatch) => dispatch(state.tr);
-const regex = (s, settings) => {
- const { enableRegex, matchCase, matchWholeWord } = settings;
- const boundary = matchWholeWord ? "\\b" : "";
- console.log(boundary);
- return RegExp(boundary +
- (enableRegex ? s : s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")) +
- boundary, matchCase ? "gu" : "gui");
-};
-function searchDocument(doc, searchResultClass, searchTerm) {
- if (!searchTerm)
- return { decorationSet: DecorationSet.empty, results: [] };
- const decorations = [];
- const results = [];
- let index = 0;
- let textNodesWithPosition = [];
- doc === null || doc === void 0 ? void 0 : doc.descendants((node, pos) => {
- if (node.isText) {
- if (textNodesWithPosition[index]) {
- textNodesWithPosition[index] = {
- text: textNodesWithPosition[index].text + node.text,
- pos: textNodesWithPosition[index].pos,
- };
- }
- else {
- textNodesWithPosition[index] = {
- text: node.text || "",
- pos,
- };
- }
- }
- else {
- index += 1;
- }
- });
- textNodesWithPosition = textNodesWithPosition.filter(Boolean);
- for (const { text, pos } of textNodesWithPosition) {
- const matches = text.matchAll(searchTerm);
- for (const m of matches) {
- if (m[0] === "")
- break;
- if (m.index !== undefined) {
- results.push({
- from: pos + m.index,
- to: pos + m.index + m[0].length,
- });
- }
- }
- }
- for (const { from, to } of results) {
- decorations.push(Decoration.inline(from, to, { class: searchResultClass }));
- }
- return {
- decorationSet: DecorationSet.create(doc, decorations),
- results,
- };
-}
-const replaceAll = (replaceTerm, results, tr) => {
- let offset = 0;
- if (!results.length)
- return;
- const map = tr.mapping;
- for (let i = 0; i < results.length; i += 1) {
- const { from, to } = results[i];
- tr.insertText(replaceTerm, from, to);
- if (i + 1 < results.length) {
- const { from, to } = results[i + 1];
- results[i + 1] = {
- from: map.map(from),
- to: map.map(to),
- };
- }
- }
- return tr;
-};
-export const SearchReplace = Extension.create({
- name: "searchreplace",
- addOptions() {
- return {
- searchResultClass: "search-result",
- };
- },
- addCommands() {
- return {
- startSearch: () => ({ state }) => {
- this.storage.isSearching = true;
- if (!state.selection.empty) {
- this.storage.selectedText = state.doc.textBetween(state.selection.$from.pos, state.selection.$to.pos);
- }
- return true;
- },
- endSearch: () => ({ state, dispatch }) => {
- this.storage.isSearching = false;
- this.storage.searchTerm = "";
- updateView(state, dispatch);
- return true;
- },
- search: (term, options) => ({ state, dispatch }) => {
- this.storage.searchTerm = term;
- this.storage.enableRegex = (options === null || options === void 0 ? void 0 : options.enableRegex) || false;
- this.storage.matchCase = (options === null || options === void 0 ? void 0 : options.matchCase) || false;
- this.storage.matchWholeWord = (options === null || options === void 0 ? void 0 : options.matchWholeWord) || false;
- this.storage.results = [];
- updateView(state, dispatch);
- return true;
- },
- moveToNextResult: () => ({ chain }) => {
- const { selectedIndex, results } = this.storage;
- if (!results || results.length <= 0)
- return false;
- let nextIndex = selectedIndex + 1;
- if (isNaN(nextIndex) || nextIndex >= results.length)
- nextIndex = 0;
- const { from, to } = results[nextIndex];
- console.log("[moveToNextResult]", from, to);
- const result = chain()
- .focus(undefined, { scrollIntoView: true })
- .setTextSelection({ from, to })
- .run();
- if (result)
- this.storage.selectedIndex = nextIndex;
- return result;
- },
- moveToPreviousResult: () => ({ chain }) => {
- const { selectedIndex, results } = this.storage;
- if (!results || results.length <= 0)
- return false;
- let prevIndex = selectedIndex - 1;
- if (isNaN(prevIndex) || prevIndex < 0)
- prevIndex = results.length - 1;
- const { from, to } = results[prevIndex];
- const result = chain()
- .focus(undefined, { scrollIntoView: true })
- .setTextSelection({ from, to })
- .run();
- if (result)
- this.storage.selectedIndex = prevIndex;
- return result;
- },
- replace: (term) => ({ commands, tr, dispatch }) => {
- const { selectedIndex, results } = this.storage;
- if (!dispatch || !results || results.length <= 0)
- return false;
- const index = selectedIndex === undefined ? 0 : selectedIndex;
- const { from, to } = results[index];
- tr.insertText(term, from, to);
- if (index + 1 < results.length) {
- const { from, to } = results[index + 1];
- const nextResult = (results[index + 1] = {
- from: tr.mapping.map(from),
- to: tr.mapping.map(to),
- });
- commands.focus();
- tr.setSelection(new TextSelection(tr.doc.resolve(nextResult.from), tr.doc.resolve(nextResult.to)));
- }
- dispatch(tr);
- results.splice(index, 1);
- return true;
- },
- replaceAll: (term) => ({ state, tr, dispatch }) => {
- if (!dispatch)
- return false;
- const { results } = this.storage;
- if (!dispatch || !results || results.length <= 0)
- return false;
- dispatch(replaceAll(term, results, tr));
- return true;
- },
- };
- },
- addKeyboardShortcuts() {
- return {
- "Mod-f": ({ editor }) => editor.commands.startSearch(),
- Escape: ({ editor }) => editor.commands.endSearch(),
- };
- },
- addProseMirrorPlugins() {
- const key = new PluginKey("searchreplace");
- return [
- new Plugin({
- key,
- state: {
- init() {
- return DecorationSet.empty;
- },
- apply: ({ doc, docChanged, setSelection }) => {
- const { searchTerm, enableRegex, matchCase, matchWholeWord } = this.storage;
- const { searchResultClass } = this.options;
- if (docChanged || searchTerm) {
- const searchRegex = searchTerm
- ? regex(searchTerm, { enableRegex, matchCase, matchWholeWord })
- : undefined;
- const { decorationSet, results } = searchDocument(doc, searchResultClass, searchRegex);
- this.storage.results = results;
- return decorationSet;
- }
- return DecorationSet.empty;
- },
- },
- props: {
- decorations(state) {
- return key.getState(state);
- },
- },
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/es/extensions/selectionpersist/index.d.ts b/packages/editor/dist/es/extensions/selectionpersist/index.d.ts
deleted file mode 100644
index 1bb64b085..000000000
--- a/packages/editor/dist/es/extensions/selectionpersist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./selection-persist";
diff --git a/packages/editor/dist/es/extensions/selectionpersist/index.js b/packages/editor/dist/es/extensions/selectionpersist/index.js
deleted file mode 100644
index 1bb64b085..000000000
--- a/packages/editor/dist/es/extensions/selectionpersist/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./selection-persist";
diff --git a/packages/editor/dist/es/extensions/selectionpersist/selectionpersist.d.ts b/packages/editor/dist/es/extensions/selectionpersist/selectionpersist.d.ts
deleted file mode 100644
index daad8ea1b..000000000
--- a/packages/editor/dist/es/extensions/selectionpersist/selectionpersist.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { Extension } from "@tiptap/core";
-export declare const SelectionPersist: Extension<any, any>;
diff --git a/packages/editor/dist/es/extensions/selectionpersist/selectionpersist.js b/packages/editor/dist/es/extensions/selectionpersist/selectionpersist.js
deleted file mode 100644
index 0a1f600c6..000000000
--- a/packages/editor/dist/es/extensions/selectionpersist/selectionpersist.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Extension } from "@tiptap/core";
-import { Plugin, PluginKey } from "prosemirror-state";
-import { Decoration, DecorationSet } from "prosemirror-view";
-const key = new PluginKey("selection-persist-key");
-export const SelectionPersist = Extension.create({
- name: "selection-persist",
- addProseMirrorPlugins() {
- let isFocused = false;
- let isBlurred = false;
- return [
- new Plugin({
- key,
- props: {
- decorations(state) {
- return key.getState(state);
- },
- },
- state: {
- init() {
- return DecorationSet.empty;
- },
- apply(tr, value, oldState, newState) {
- // isBlurred should remain true until isFocused becomes true
- // isFocused should remain true until isBlurred becomes true
- const _isBlurred = !!tr.getMeta("blur");
- const _isFocused = !!tr.getMeta("focus");
- if (_isFocused) {
- isBlurred = false;
- isFocused = true;
- }
- if (_isBlurred) {
- isBlurred = true;
- isFocused = false;
- }
- const { from, to } = oldState.selection;
- if (isBlurred) {
- return DecorationSet.create(tr.doc, [
- Decoration.inline(from, to, {
- style: `background-color: var(--dimPrimary)`,
- }),
- ]);
- }
- else if (isFocused) {
- return DecorationSet.empty;
- }
- return DecorationSet.empty;
- },
- },
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/es/extensions/table/actions.d.ts b/packages/editor/dist/es/extensions/table/actions.d.ts
deleted file mode 100644
index c4a829775..000000000
--- a/packages/editor/dist/es/extensions/table/actions.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Editor } from "@tiptap/core";
-declare function moveColumnRight(editor: Editor): void;
-declare function moveColumnLeft(editor: Editor): void;
-declare function moveRowDown(editor: Editor): void;
-declare function moveRowUp(editor: Editor): void;
-export { moveColumnLeft, moveColumnRight, moveRowDown, moveRowUp };
diff --git a/packages/editor/dist/es/extensions/table/actions.js b/packages/editor/dist/es/extensions/table/actions.js
deleted file mode 100644
index 81ce084ac..000000000
--- a/packages/editor/dist/es/extensions/table/actions.js
+++ /dev/null
@@ -1,105 +0,0 @@
-import { selectedRect } from "@_ueberdosis/prosemirror-tables";
-function moveColumnRight(editor) {
- const { tr } = editor.state;
- const rect = selectedRect(editor.state);
- if (rect.right === rect.map.width)
- return;
- const transaction = moveColumn(tr, rect, rect.left, rect.left + 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-function moveColumnLeft(editor) {
- const { tr } = editor.state;
- const rect = selectedRect(editor.state);
- if (rect.left === 0)
- return;
- const transaction = moveColumn(tr, rect, rect.left, rect.left - 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-function moveRowDown(editor) {
- const { tr } = editor.state;
- const rect = selectedRect(editor.state);
- if (rect.top + 1 === rect.map.height)
- return;
- const transaction = moveRow(tr, rect, rect.top, rect.top + 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-function moveRowUp(editor) {
- const { tr } = editor.state;
- const rect = selectedRect(editor.state);
- if (rect.top === 0)
- return;
- const transaction = moveRow(tr, rect, rect.top, rect.top - 1);
- if (!transaction)
- return;
- editor.view.dispatch(transaction);
-}
-function moveColumn(tr, rect, from, to) {
- let fromCells = getColumnCells(rect, from);
- let toCells = getColumnCells(rect, to);
- return moveCells(tr, rect, fromCells, toCells);
-}
-function getColumnCells({ map, table }, col) {
- let cells = [];
- for (let row = 0; row < map.height;) {
- let index = row * map.width + col;
- if (index >= map.map.length)
- break;
- let pos = map.map[index];
- let cell = table.nodeAt(pos);
- if (!cell)
- continue;
- cells.push({ cell, pos });
- row += cell.attrs.rowspan;
- }
- return cells;
-}
-function moveRow(tr, rect, from, to) {
- let fromCells = getRowCells(rect, from);
- let toCells = getRowCells(rect, to);
- return moveCells(tr, rect, fromCells, toCells);
-}
-function getRowCells({ map, table }, row) {
- let cells = [];
- for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
- if (index >= map.map.length)
- break;
- let pos = map.map[index];
- let cell = table.nodeAt(pos);
- if (!cell)
- continue;
- cells.push({ cell, pos });
- col += cell.attrs.colspan - 1;
- }
- return cells;
-}
-function moveCells(tr, rect, fromCells, toCells) {
- if (fromCells.length !== toCells.length)
- return;
- let mapStart = tr.mapping.maps.length;
- for (let i = 0; i < toCells.length; ++i) {
- const fromCell = fromCells[i];
- const toCell = toCells[i];
- let fromStart = tr.mapping
- .slice(mapStart)
- .map(rect.tableStart + fromCell.pos);
- let fromEnd = fromStart + fromCell.cell.nodeSize;
- const fromSlice = tr.doc.slice(fromStart, fromEnd);
- const toStart = tr.mapping
- .slice(mapStart)
- .map(rect.tableStart + toCell.pos);
- const toEnd = toStart + toCell.cell.nodeSize;
- const toSlice = tr.doc.slice(toStart, toEnd);
- tr.replace(toStart, toEnd, fromSlice);
- fromStart = tr.mapping.slice(mapStart).map(rect.tableStart + fromCell.pos);
- fromEnd = fromStart + fromCell.cell.nodeSize;
- tr.replace(fromStart, fromEnd, toSlice);
- }
- return tr;
-}
-export { moveColumnLeft, moveColumnRight, moveRowDown, moveRowUp };
diff --git a/packages/editor/dist/es/extensions/table/component.d.ts b/packages/editor/dist/es/extensions/table/component.d.ts
deleted file mode 100644
index 529809d1d..000000000
--- a/packages/editor/dist/es/extensions/table/component.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/// <reference types="react" />
-import { SelectionBasedReactNodeViewProps } from "../react";
-import { Editor } from "../../types";
-import { NodeView } from "prosemirror-view";
-export declare function TableComponent(props: SelectionBasedReactNodeViewProps): JSX.Element;
-export declare function TableNodeView(editor: Editor): NodeView;
diff --git a/packages/editor/dist/es/extensions/table/component.js b/packages/editor/dist/es/extensions/table/component.js
deleted file mode 100644
index 9fcb280b7..000000000
--- a/packages/editor/dist/es/extensions/table/component.js
+++ /dev/null
@@ -1,121 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { Flex } from "rebass";
-import { SelectionBasedNodeView, } from "../react";
-import { useEffect, useRef } from "react";
-import { updateColumnsOnResize } from "@_ueberdosis/prosemirror-tables";
-import { InsertColumnRight, InsertRowBelow, RowProperties, TableProperties, } from "../../toolbar/tools/table";
-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) {
- const { editor, node, forwardRef } = props;
- const colgroupRef = useRef(null);
- const tableRef = useRef();
- const selected = editor.isActive("table");
- useEffect(() => {
- if (!colgroupRef.current || !tableRef.current)
- return;
- updateColumnsOnResize(node, colgroupRef.current, tableRef.current, 50);
- }, [node]);
- 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", Object.assign({ className: "tableWrapper" }, { children: _jsx("table", Object.assign({ ref: (ref) => {
- forwardRef === null || forwardRef === void 0 ? void 0 : forwardRef(ref);
- tableRef.current = ref || undefined;
- } }, { children: _jsx("colgroup", { ref: colgroupRef }) })) }))] }));
-}
-export function TableNodeView(editor) {
- class TableNode extends SelectionBasedNodeView {
- constructor(node, cellMinWidth) {
- super(node, editor, () => 0, // todo
- {
- component: TableComponent,
- shouldUpdate: (prev, next) => {
- return prev.type === next.type;
- },
- contentDOMFactory: () => {
- const dom = document.createElement("tbody");
- return { dom };
- },
- wrapperFactory: () => {
- const dom = document.createElement("div");
- dom.style.position = "relative";
- return dom;
- },
- });
- super.init();
- }
- }
- return TableNode;
-}
-function TableRowToolbar(props) {
- const { editor } = props;
- const rowToolsRef = useRef(null);
- useEffect(() => {
- if (!rowToolsRef.current) {
- return;
- }
- const currentRow = findSelectedDOMNode(editor, ["tableRow"]);
- if (!currentRow)
- return;
- const pos = getPosition(rowToolsRef.current, {
- location: "left",
- target: currentRow,
- align: "start",
- xOffset: -5,
- yOffset: -3,
- });
- rowToolsRef.current.style.top = `${pos.top}px`;
- rowToolsRef.current.style.left = `${pos.left}px`;
- }, [editor.state.selection, rowToolsRef.current]);
- return (_jsxs(Flex, Object.assign({ ref: rowToolsRef, sx: {
- zIndex: 999,
- top: 0,
- left: 0,
- position: "absolute",
- bg: "background",
- flexWrap: "nowrap",
- borderRadius: "default",
- opacity: 0.3,
- ":hover": {
- opacity: 1,
- },
- } }, { children: [_jsx(RowProperties, Object.assign({}, getToolDefinition("rowProperties"), { icon: "more", variant: "small", editor: editor })), _jsx(InsertRowBelow, Object.assign({}, getToolDefinition("insertRowBelow"), { editor: editor, variant: "small" }))] })));
-}
-function TableColumnToolbar(props) {
- const { editor, table } = props;
- const columnToolsRef = useRef(null);
- useEffect(() => {
- if (!columnToolsRef.current || !table) {
- return;
- }
- const currentCell = findSelectedDOMNode(editor, [
- "tableCell",
- "tableHeader",
- ]);
- if (!currentCell)
- return;
- // tableRef.current
- const pos = getPosition(columnToolsRef.current, {
- location: "top",
- align: "center",
- target: currentCell,
- yAnchor: table,
- yOffset: 2,
- });
- columnToolsRef.current.style.left = `${pos.left}px`;
- columnToolsRef.current.style.top = `${pos.top}px`;
- }, [editor.state.selection, columnToolsRef.current, table]);
- return (_jsxs(Flex, Object.assign({ ref: columnToolsRef, sx: {
- zIndex: 999,
- top: 0,
- left: 0,
- position: "absolute",
- bg: "background",
- flexWrap: "nowrap",
- borderRadius: "default",
- opacity: 0.3,
- ":hover": {
- opacity: 1,
- },
- } }, { children: [_jsx(TableProperties, { editor: editor, title: "tableProperties", icon: "more", variant: "small" }), _jsx(InsertColumnRight, Object.assign({}, getToolDefinition("insertColumnRight"), { editor: editor, variant: "small", icon: "plus" }))] })));
-}
diff --git a/packages/editor/dist/es/extensions/table/index.d.ts b/packages/editor/dist/es/extensions/table/index.d.ts
deleted file mode 100644
index 0e948df9e..000000000
--- a/packages/editor/dist/es/extensions/table/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./table";
diff --git a/packages/editor/dist/es/extensions/table/index.js b/packages/editor/dist/es/extensions/table/index.js
deleted file mode 100644
index 0e948df9e..000000000
--- a/packages/editor/dist/es/extensions/table/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./table";
diff --git a/packages/editor/dist/es/extensions/table/table.d.ts b/packages/editor/dist/es/extensions/table/table.d.ts
deleted file mode 100644
index e5a29b0de..000000000
--- a/packages/editor/dist/es/extensions/table/table.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { TableOptions } from "@tiptap/extension-table";
-export declare const Table: import("@tiptap/core").Node<TableOptions, any>;
diff --git a/packages/editor/dist/es/extensions/table/table.js b/packages/editor/dist/es/extensions/table/table.js
deleted file mode 100644
index 7bcd80f95..000000000
--- a/packages/editor/dist/es/extensions/table/table.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { Table as TiptapTable } from "@tiptap/extension-table";
-import { columnResizing, tableEditing } from "@_ueberdosis/prosemirror-tables";
-import { TableNodeView } from "./component";
-export const Table = TiptapTable.extend({
- addProseMirrorPlugins() {
- const isResizable = this.options.resizable && this.editor.isEditable;
- return [
- ...(isResizable
- ? [
- columnResizing({
- handleWidth: this.options.handleWidth,
- cellMinWidth: this.options.cellMinWidth,
- View: TableNodeView(this.editor),
- // TODO: PR for @types/prosemirror-tables
- // @ts-ignore (incorrect type)
- lastColumnResizable: this.options.lastColumnResizable,
- }),
- ]
- : []),
- tableEditing({
- allowTableNodeSelection: this.options.allowTableNodeSelection,
- }),
- ];
- },
-});
diff --git a/packages/editor/dist/es/extensions/tablecell/index.d.ts b/packages/editor/dist/es/extensions/tablecell/index.d.ts
deleted file mode 100644
index a85cac945..000000000
--- a/packages/editor/dist/es/extensions/tablecell/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { TableCell } from "./table-cell";
-export * from "./table-cell";
-export default TableCell;
diff --git a/packages/editor/dist/es/extensions/tablecell/index.js b/packages/editor/dist/es/extensions/tablecell/index.js
deleted file mode 100644
index a85cac945..000000000
--- a/packages/editor/dist/es/extensions/tablecell/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { TableCell } from "./table-cell";
-export * from "./table-cell";
-export default TableCell;
diff --git a/packages/editor/dist/es/extensions/tablecell/tablecell.d.ts b/packages/editor/dist/es/extensions/tablecell/tablecell.d.ts
deleted file mode 100644
index 16c4d1e28..000000000
--- a/packages/editor/dist/es/extensions/tablecell/tablecell.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare const TableCell: import("@tiptap/core").Node<import("@tiptap/extension-table-cell").TableCellOptions, any>;
diff --git a/packages/editor/dist/es/extensions/tablecell/tablecell.js b/packages/editor/dist/es/extensions/tablecell/tablecell.js
deleted file mode 100644
index 57012eb42..000000000
--- a/packages/editor/dist/es/extensions/tablecell/tablecell.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import TiptapTableCell from "@tiptap/extension-table-cell";
-export const TableCell = TiptapTableCell.extend({
- addAttributes() {
- var _a;
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { backgroundColor: addStyleAttribute("backgroundColor", "background-color"), color: addStyleAttribute("color", "color"), borderWidth: addStyleAttribute("borderWidth", "border-width", "px"), borderStyle: addStyleAttribute("borderStyle", "border-style"), borderColor: addStyleAttribute("borderColor", "border-color") });
- },
-});
-function addStyleAttribute(name, cssName, unit) {
- return {
- default: null,
- parseHTML: (element) => {
- var _a;
- return unit
- ? (_a = element.style[name]) === null || _a === void 0 ? void 0 : _a.toString().replace(unit, "")
- : element.style[name];
- },
- renderHTML: (attributes) => {
- if (!attributes[name]) {
- return {};
- }
- return {
- style: `${cssName}: ${attributes[name]}${unit || ""}`,
- };
- },
- };
-}
diff --git a/packages/editor/dist/es/extensions/taskitem/component.d.ts b/packages/editor/dist/es/extensions/taskitem/component.d.ts
deleted file mode 100644
index b01ab35de..000000000
--- a/packages/editor/dist/es/extensions/taskitem/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-import { TaskItemAttributes } from "./task-item";
-export declare function TaskItemComponent(props: ReactNodeViewProps<TaskItemAttributes>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/taskitem/component.js b/packages/editor/dist/es/extensions/taskitem/component.js
deleted file mode 100644
index 08604687e..000000000
--- a/packages/editor/dist/es/extensions/taskitem/component.js
+++ /dev/null
@@ -1,94 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { Flex, Text } from "rebass";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { findChildren, } from "@tiptap/core";
-import { useCallback } from "react";
-import { TaskItemNode } from "./task-item";
-import { useIsMobile } from "../../toolbar/stores/toolbar-store";
-export function TaskItemComponent(props) {
- const { editor, updateAttributes, node, getPos, forwardRef } = props;
- const { checked } = props.node.attrs;
- const isMobile = useIsMobile();
- const toggle = useCallback(() => {
- var _a;
- if (!editor.isEditable)
- return false;
- updateAttributes({ checked: !checked });
- const pos = getPos();
- const node = (_a = editor.current) === null || _a === void 0 ? void 0 : _a.state.doc.nodeAt(pos);
- if (!node)
- return false;
- editor.commands.command(({ tr }) => {
- toggleChildren(node, tr, !checked, pos);
- return true;
- });
- return true;
- }, [editor, getPos, checked]);
- return (_jsx(_Fragment, { children: _jsxs(Flex, Object.assign({ "data-drag-image": true, sx: {
- bg: "background",
- borderRadius: "default",
- ":hover > .dragHandle": {
- opacity: editor.isEditable ? 1 : 0,
- },
- } }, { children: [_jsx(Icon, { className: "dragHandle", draggable: "true", "data-drag-handle": true, path: Icons.dragHandle, sx: {
- opacity: [1, 1, 0],
- alignSelf: "start",
- mr: 2,
- bg: "transparent",
- cursor: "grab",
- ".icon:hover path": {
- fill: "var(--checked) !important",
- },
- }, size: isMobile ? 24 : 20 }), _jsx(Icon, { path: checked ? Icons.check : "", stroke: "1px", sx: {
- border: "2px solid",
- borderColor: checked ? "checked" : "icon",
- borderRadius: "default",
- alignSelf: "start",
- mr: 2,
- p: "1px",
- cursor: editor.isEditable ? "pointer" : "unset",
- ":hover": {
- borderColor: "checked",
- },
- ":hover .icon path": {
- fill: "var(--checked) !important",
- },
- }, onMouseDown: (e) => {
- e.preventDefault();
- toggle();
- }, onTouchEnd: (e) => {
- e.preventDefault();
- toggle();
- }, color: checked ? "checked" : "icon", size: isMobile ? 16 : 14 }), _jsx(Text, { as: "div", ref: forwardRef, sx: {
- "> .taskitem-content-wrapper > p": {
- textDecorationLine: checked ? "line-through" : "none",
- opacity: checked ? 0.8 : 1,
- },
- flex: 1,
- } })] })) }));
-}
-function toggleChildren(node, tr, toggleState, parentPos) {
- const children = findChildren(node, (node) => node.type.name === TaskItemNode.name);
- for (const { pos } of children) {
- // need to add 1 to get inside the node
- const actualPos = pos + parentPos + 1;
- tr.setNodeMarkup(actualPos, undefined, {
- checked: toggleState,
- });
- }
- return tr;
-}
-function getChildren(node, parentPos) {
- const children = [];
- node.forEach((node, offset) => {
- children.push({ node, pos: parentPos + offset + 1 });
- });
- return children;
-}
-function areAllChecked(node) {
- const children = findChildren(node, (node) => node.type.name === TaskItemNode.name);
- if (children.length <= 0)
- return undefined;
- return children.every((node) => node.node.attrs.checked);
-}
diff --git a/packages/editor/dist/es/extensions/taskitem/index.d.ts b/packages/editor/dist/es/extensions/taskitem/index.d.ts
deleted file mode 100644
index 3518ff3b2..000000000
--- a/packages/editor/dist/es/extensions/taskitem/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./task-item";
diff --git a/packages/editor/dist/es/extensions/taskitem/index.js b/packages/editor/dist/es/extensions/taskitem/index.js
deleted file mode 100644
index 3518ff3b2..000000000
--- a/packages/editor/dist/es/extensions/taskitem/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./task-item";
diff --git a/packages/editor/dist/es/extensions/taskitem/taskitem.d.ts b/packages/editor/dist/es/extensions/taskitem/taskitem.d.ts
deleted file mode 100644
index 32494f7fa..000000000
--- a/packages/editor/dist/es/extensions/taskitem/taskitem.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export declare type TaskItemAttributes = {
- checked: boolean;
-};
-export declare const TaskItemNode: import("@tiptap/core").Node<import("@tiptap/extension-task-item").TaskItemOptions, any>;
diff --git a/packages/editor/dist/es/extensions/taskitem/taskitem.js b/packages/editor/dist/es/extensions/taskitem/taskitem.js
deleted file mode 100644
index 6f3ae64e0..000000000
--- a/packages/editor/dist/es/extensions/taskitem/taskitem.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import { mergeAttributes } from "@tiptap/core";
-import { onBackspacePressed } from "../list-item/commands";
-import { TaskItem } from "@tiptap/extension-task-item";
-import { TaskItemComponent } from "./component";
-import { createNodeView } from "../react";
-export const TaskItemNode = TaskItem.extend({
- draggable: true,
- addAttributes() {
- return {
- checked: {
- default: false,
- keepOnSplit: false,
- parseHTML: (element) => element.classList.contains("checked"),
- renderHTML: (attributes) => ({
- class: attributes.checked ? "checked" : "",
- }),
- },
- };
- },
- renderHTML({ node, HTMLAttributes }) {
- return [
- "li",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- class: "checklist--item",
- }),
- 0,
- ];
- },
- parseHTML() {
- return [
- {
- tag: `li`,
- getAttrs: (node) => {
- var _a;
- if (node instanceof Node && node instanceof HTMLElement) {
- return node.classList.contains("checklist--item") ||
- ((_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains("checklist"))
- ? null
- : false;
- }
- return false;
- },
- priority: 51,
- },
- ];
- },
- addKeyboardShortcuts() {
- var _a;
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { Backspace: ({ editor }) => onBackspacePressed(editor, this.name, this.type) });
- },
- addNodeView() {
- return createNodeView(TaskItemComponent, {
- contentDOMFactory: true,
- wrapperFactory: () => document.createElement("li"),
- shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
- return (prev.checked !== next.checked || prev.collapsed !== next.collapsed);
- },
- });
- },
-});
diff --git a/packages/editor/dist/es/extensions/tasklist/component.d.ts b/packages/editor/dist/es/extensions/tasklist/component.d.ts
deleted file mode 100644
index 5cc94955c..000000000
--- a/packages/editor/dist/es/extensions/tasklist/component.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ReactNodeViewProps } from "../react";
-import { TaskListAttributes } from "./task-list";
-export declare function TaskListComponent(props: ReactNodeViewProps<TaskListAttributes>): JSX.Element;
diff --git a/packages/editor/dist/es/extensions/tasklist/component.js b/packages/editor/dist/es/extensions/tasklist/component.js
deleted file mode 100644
index adb888387..000000000
--- a/packages/editor/dist/es/extensions/tasklist/component.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
-import { Box, Flex, Text } from "rebass";
-import { findChildren, getNodeType, } from "@tiptap/core";
-import { Icon } from "../../toolbar/components/icon";
-import { Icons } from "../../toolbar/icons";
-import { useCallback, useEffect, useMemo, useState } from "react";
-import { Input } from "@rebass/forms";
-import { TaskItemNode } from "../task-item";
-import { findParentNodeOfTypeClosestToPos } from "prosemirror-utils";
-import { useIsMobile } from "../../toolbar/stores/toolbar-store";
-export function TaskListComponent(props) {
- const isMobile = useIsMobile();
- const { editor, getPos, node, updateAttributes, forwardRef } = props;
- const taskItemType = getNodeType(TaskItemNode.name, editor.schema);
- const { title, collapsed } = node.attrs;
- const [stats, setStats] = useState({ checked: 0, total: 0, percentage: 0 });
- const getParent = useCallback(() => {
- const pos = editor.state.doc.resolve(getPos());
- return findParentNodeOfTypeClosestToPos(pos, taskItemType);
- }, []);
- const isNested = useMemo(() => {
- return !!getParent();
- }, [getParent]);
- useEffect(() => {
- const parent = getParent();
- if (!parent)
- return;
- const { node, pos } = parent;
- const allChecked = areAllChecked(node, pos, editor.state.doc);
- // no need to create a transaction if the check state is
- // not changed.
- if (node.attrs.checked === allChecked)
- return;
- // check parent item if all child items are checked.
- editor.commands.command(({ tr }) => {
- tr.setNodeMarkup(pos, undefined, { checked: allChecked });
- return true;
- });
- }, [node, node.childCount]);
- useEffect(() => {
- const children = findChildren(node, (node) => node.type.name === TaskItemNode.name);
- const checked = children.filter((node) => node.node.attrs.checked).length;
- const total = children.length;
- const percentage = Math.round((checked / total) * 100);
- setStats({ checked, total, percentage });
- }, [isNested, node]);
- return (_jsxs(_Fragment, { children: [_jsx(Flex, Object.assign({ sx: {
- flexDirection: "column",
- ":hover > div > .toggleSublist": { opacity: 1 },
- } }, { children: isNested ? (_jsxs(Flex, Object.assign({ sx: {
- position: "absolute",
- top: 0,
- right: 0,
- }, contentEditable: false }, { children: [collapsed && (_jsxs(Text, Object.assign({ variant: "body", sx: { color: "fontTertiary", mr: 35 } }, { children: [stats.checked, "/", stats.total] }))), _jsx(Icon, { className: "toggleSublist", path: collapsed ? Icons.chevronDown : Icons.chevronUp, sx: {
- opacity: isMobile || collapsed ? 1 : 0,
- position: "absolute",
- right: 0,
- alignSelf: "start",
- mr: 2,
- cursor: "pointer",
- ".icon:hover path": {
- fill: "var(--checked) !important",
- },
- }, size: isMobile ? 24 : 20, onClick: () => {
- updateAttributes({ collapsed: !collapsed }, { addToHistory: false, preventUpdate: true });
- } })] }))) : (_jsxs(Flex, Object.assign({ sx: {
- position: "relative",
- bg: "bgSecondary",
- py: 1,
- borderRadius: "default",
- mb: 2,
- alignItems: "center",
- justifyContent: "end",
- overflow: "hidden",
- }, contentEditable: false }, { children: [_jsx(Box, { sx: {
- height: "100%",
- width: `${stats.percentage}%`,
- position: "absolute",
- bg: "border",
- zIndex: 0,
- left: 0,
- transition: "width 250ms ease-out",
- } }), _jsx(Input, { readOnly: !editor.isEditable, value: title || "", variant: "clean", sx: { p: 0, px: 2, zIndex: 1, color: "fontTertiary" }, placeholder: "Untitled", onChange: (e) => {
- updateAttributes({ title: e.target.value }, { addToHistory: true, preventUpdate: false });
- } }), _jsxs(Flex, Object.assign({ sx: { flexShrink: 0, pr: 2 } }, { children: [_jsx(Icon, { path: Icons.checkbox, size: 15, color: "fontTertiary" }), _jsxs(Text, Object.assign({ variant: "body", sx: { ml: 1, color: "fontTertiary" } }, { children: [stats.checked, "/", stats.total] }))] }))] }))) })), _jsx(Text, { as: "div", ref: forwardRef, sx: {
- ul: {
- display: collapsed ? "none" : "block",
- paddingInlineStart: 0,
- marginBlockStart: isNested ? 10 : 0,
- marginBlockEnd: 0,
- marginLeft: isNested ? -35 : 0,
- },
- li: {
- listStyleType: "none",
- position: "relative",
- marginBottom: [2, "7px"],
- },
- } })] }));
-}
-function areAllChecked(node, pos, doc) {
- const children = findChildren(node, (node) => node.type.name === TaskItemNode.name);
- for (const child of children) {
- const childPos = pos + child.pos + 1;
- const node = doc.nodeAt(childPos);
- if (!(node === null || node === void 0 ? void 0 : node.attrs.checked))
- return false;
- }
- return true;
-}
diff --git a/packages/editor/dist/es/extensions/tasklist/index.d.ts b/packages/editor/dist/es/extensions/tasklist/index.d.ts
deleted file mode 100644
index 291e035cb..000000000
--- a/packages/editor/dist/es/extensions/tasklist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./task-list";
diff --git a/packages/editor/dist/es/extensions/tasklist/index.js b/packages/editor/dist/es/extensions/tasklist/index.js
deleted file mode 100644
index 291e035cb..000000000
--- a/packages/editor/dist/es/extensions/tasklist/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./task-list";
diff --git a/packages/editor/dist/es/extensions/tasklist/tasklist.d.ts b/packages/editor/dist/es/extensions/tasklist/tasklist.d.ts
deleted file mode 100644
index 46bdb2668..000000000
--- a/packages/editor/dist/es/extensions/tasklist/tasklist.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export declare type TaskListAttributes = {
- title: string;
- collapsed: boolean;
-};
-export declare const TaskListNode: import("@tiptap/core").Node<import("@tiptap/extension-task-list").TaskListOptions, any>;
diff --git a/packages/editor/dist/es/extensions/tasklist/tasklist.js b/packages/editor/dist/es/extensions/tasklist/tasklist.js
deleted file mode 100644
index 0e6d2512b..000000000
--- a/packages/editor/dist/es/extensions/tasklist/tasklist.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import { mergeAttributes } from "@tiptap/core";
-import { TaskList } from "@tiptap/extension-task-list";
-import { createNodeView } from "../react";
-import { TaskListComponent } from "./component";
-export const TaskListNode = TaskList.extend({
- addAttributes() {
- return {
- collapsed: {
- default: false,
- keepOnSplit: false,
- parseHTML: (element) => element.dataset.collapsed === "true",
- renderHTML: (attributes) => ({
- "data-collapsed": attributes.collapsed === true,
- }),
- },
- title: {
- default: null,
- keepOnSplit: false,
- parseHTML: (element) => element.dataset.title,
- renderHTML: (attributes) => {
- if (!attributes.title || attributes.nested) {
- return {};
- }
- return {
- "data-title": attributes.title,
- };
- },
- },
- };
- },
- parseHTML() {
- return [
- {
- tag: `ul`,
- getAttrs: (node) => {
- if (node instanceof Node && node instanceof HTMLElement) {
- return node.classList.contains("checklist") && null;
- }
- return false;
- },
- priority: 51,
- },
- ];
- },
- renderHTML({ HTMLAttributes }) {
- return [
- "ul",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- class: "checklist",
- }),
- 0,
- ];
- },
- addCommands() {
- return {
- toggleTaskList: () => ({ editor, commands, state, tr }) => {
- const { $from, $to } = state.selection;
- commands.toggleList(this.name, this.options.itemTypeName);
- const position = {
- from: tr.mapping.map($from.pos),
- to: tr.mapping.map($to.pos),
- };
- // There is a minor bug in Prosemirror or Tiptap where creating
- // nested node view causes the editor selection to act weird.
- // The solution is to manually force the editor back to the correct
- // position.
- // NOTE: We have to wrap this in setTimeout & use the editor
- // directly or else it won't run.
- setTimeout(() => editor.commands.setTextSelection(position), 0);
- return true;
- },
- };
- },
- addNodeView() {
- return createNodeView(TaskListComponent, {
- contentDOMFactory: () => {
- const content = document.createElement("ul");
- content.classList.add(`${this.name.toLowerCase()}-content-wrapper`);
- content.style.whiteSpace = "inherit";
- return { dom: content };
- },
- });
- },
-});
diff --git a/packages/editor/dist/es/extensions/textdirection/index.d.ts b/packages/editor/dist/es/extensions/textdirection/index.d.ts
deleted file mode 100644
index ea2fee63c..000000000
--- a/packages/editor/dist/es/extensions/textdirection/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { TextDirection } from "./text-direction";
-export * from "./text-direction";
-export default TextDirection;
diff --git a/packages/editor/dist/es/extensions/textdirection/index.js b/packages/editor/dist/es/extensions/textdirection/index.js
deleted file mode 100644
index ea2fee63c..000000000
--- a/packages/editor/dist/es/extensions/textdirection/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { TextDirection } from "./text-direction";
-export * from "./text-direction";
-export default TextDirection;
diff --git a/packages/editor/dist/es/extensions/textdirection/textdirection.d.ts b/packages/editor/dist/es/extensions/textdirection/textdirection.d.ts
deleted file mode 100644
index a29fdf91d..000000000
--- a/packages/editor/dist/es/extensions/textdirection/textdirection.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Extension } from "@tiptap/core";
-import "@tiptap/extension-text-style";
-declare type TextDirectionOptions = {
- types: string[];
- defaultDirection: TextDirections;
-};
-declare type TextDirections = "ltr" | "rtl";
-declare module "@tiptap/core" {
- interface Commands<ReturnType> {
- textDirection: {
- /**
- * Set the font family
- */
- setTextDirection: (direction: TextDirections) => ReturnType;
- };
- }
-}
-export declare const TextDirection: Extension<TextDirectionOptions, any>;
-export {};
diff --git a/packages/editor/dist/es/extensions/textdirection/textdirection.js b/packages/editor/dist/es/extensions/textdirection/textdirection.js
deleted file mode 100644
index 01e32da55..000000000
--- a/packages/editor/dist/es/extensions/textdirection/textdirection.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Extension } from "@tiptap/core";
-import "@tiptap/extension-text-style";
-export const TextDirection = Extension.create({
- name: "textDirection",
- defaultOptions: {
- types: ["paragraph", "heading"],
- defaultDirection: "ltr",
- },
- addGlobalAttributes() {
- return [
- {
- types: this.options.types,
- attributes: {
- textDirection: {
- default: this.options.defaultDirection,
- parseHTML: (element) => element.dir,
- renderHTML: (attributes) => {
- if (!attributes.textDirection) {
- return {};
- }
- return {
- dir: attributes.textDirection,
- };
- },
- },
- },
- },
- ];
- },
- addCommands() {
- return {
- setTextDirection: (direction) => ({ commands }) => {
- return this.options.types.every((type) => commands.updateAttributes(type, { textDirection: direction }));
- },
- };
- },
-});
diff --git a/packages/editor/dist/es/hooks/useEditor.d.ts b/packages/editor/dist/es/hooks/useEditor.d.ts
deleted file mode 100644
index 5b12357f0..000000000
--- a/packages/editor/dist/es/hooks/useEditor.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { EditorOptions } from "@tiptap/core";
-import { DependencyList } from "react";
-import { Editor } from "../types";
-export declare const useEditor: (options?: Partial<EditorOptions>, deps?: DependencyList) => Editor | null;
diff --git a/packages/editor/dist/es/hooks/useEditor.js b/packages/editor/dist/es/hooks/useEditor.js
deleted file mode 100644
index 41917f4ce..000000000
--- a/packages/editor/dist/es/hooks/useEditor.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useEffect, useRef, useState } from "react";
-import { Editor } from "../types";
-function useForceUpdate() {
- const [, setValue] = useState(0);
- return () => setValue((value) => value + 1);
-}
-export const useEditor = (options = {}, deps = []) => {
- const [editor, setEditor] = useState(null);
- const forceUpdate = useForceUpdate();
- const editorRef = useRef(editor);
- useEffect(() => {
- let isMounted = true;
- const instance = new Editor(options);
- setEditor(instance);
- instance.on("transaction", () => {
- requestAnimationFrame(() => {
- requestAnimationFrame(() => {
- if (isMounted) {
- forceUpdate();
- }
- });
- });
- });
- return () => {
- instance.destroy();
- isMounted = false;
- };
- }, deps);
- useEffect(() => {
- editorRef.current = editor;
- if (!editor)
- return;
- if (!editor.current) {
- Object.defineProperty(editor, "current", {
- get: () => editorRef.current,
- });
- }
- // if (!editor.executor) {
- // Object.defineProperty(editor, "executor", {
- // get: () => (id?: string) => {
- // console.log(id);
- // return editorRef.current;
- // },
- // });
- // }
- }, [editor]);
- useEffect(() => {
- // this is required for the drag/drop to work properly
- // in the editor.
- function onDragEnter(event) {
- if (!!(editor === null || editor === void 0 ? void 0 : editor.view.dragging)) {
- event.preventDefault();
- return true;
- }
- }
- editor === null || editor === void 0 ? void 0 : editor.view.dom.addEventListener("dragenter", onDragEnter);
- return () => {
- editor === null || editor === void 0 ? void 0 : editor.view.dom.removeEventListener("dragenter", onDragEnter);
- };
- }, [editor === null || editor === void 0 ? void 0 : editor.view.dom]);
- return editor;
-};
diff --git a/packages/editor/dist/es/hooks/usePermissionHandler.d.ts b/packages/editor/dist/es/hooks/usePermissionHandler.d.ts
deleted file mode 100644
index 7aa8fe0d6..000000000
--- a/packages/editor/dist/es/hooks/usePermissionHandler.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { UnionCommands } from "@tiptap/core";
-export declare type Claims = "premium";
-export declare type PermissionHandlerOptions = {
- claims: Record<Claims, boolean>;
- onPermissionDenied: (claim: Claims, id: keyof UnionCommands) => void;
-};
-export declare function usePermissionHandler(options: PermissionHandlerOptions): void;
diff --git a/packages/editor/dist/es/hooks/usePermissionHandler.js b/packages/editor/dist/es/hooks/usePermissionHandler.js
deleted file mode 100644
index adf9fcd6b..000000000
--- a/packages/editor/dist/es/hooks/usePermissionHandler.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useEffect } from "react";
-const ClaimsMap = {
- premium: ["insertImage"],
-};
-export function usePermissionHandler(options) {
- const { claims, onPermissionDenied } = options;
- useEffect(() => {
- function onPermissionRequested(ev) {
- const { detail: { id }, } = ev;
- for (const key in ClaimsMap) {
- const claim = key;
- const commands = ClaimsMap[claim];
- if (commands.indexOf(id) <= -1)
- continue;
- if (claims[claim])
- continue;
- onPermissionDenied(claim, id);
- ev.preventDefault();
- break;
- }
- ev.preventDefault();
- }
- window.addEventListener("permissionrequest", onPermissionRequested);
- return () => {
- window.removeEventListener("permissionrequest", onPermissionRequested);
- };
- }, [claims, onPermissionDenied]);
-}
diff --git a/packages/editor/dist/es/hooks/useRefValue.d.ts b/packages/editor/dist/es/hooks/useRefValue.d.ts
deleted file mode 100644
index de0bdea82..000000000
--- a/packages/editor/dist/es/hooks/useRefValue.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-/// <reference types="react" />
-export declare function useRefValue<T>(value: T): import("react").MutableRefObject<T>;
diff --git a/packages/editor/dist/es/hooks/useRefValue.js b/packages/editor/dist/es/hooks/useRefValue.js
deleted file mode 100644
index d86f8befb..000000000
--- a/packages/editor/dist/es/hooks/useRefValue.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { useEffect, useRef } from "react";
-export function useRefValue(value) {
- const refValue = useRef(value);
- useEffect(() => {
- refValue.current = value;
- }, [value]);
- return refValue;
-}
diff --git a/packages/editor/dist/es/index.d.ts b/packages/editor/dist/es/index.d.ts
deleted file mode 100644
index 3c141a049..000000000
--- a/packages/editor/dist/es/index.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/// <reference types="react" />
-import "./extensions";
-import Toolbar from "./toolbar";
-import { Theme } from "@streetwriters/theme";
-import { AttachmentOptions } from "./extensions/attachment";
-import { EditorOptions } from "@tiptap/core";
-import { usePermissionHandler } from "./hooks/use-permission-handler";
-declare type TiptapOptions = EditorOptions & AttachmentOptions & {
- theme: Theme;
- isMobile?: boolean;
-};
-declare const useTiptap: (options?: Partial<TiptapOptions>, deps?: import("react").DependencyList) => import("./types").Editor | null;
-export { useTiptap, Toolbar, usePermissionHandler };
-export * from "./types";
-export * from "./extensions/react";
-export * from "./toolbar";
-export { type AttachmentType, type Attachment } from "./extensions/attachment";
diff --git a/packages/editor/dist/es/index.js b/packages/editor/dist/es/index.js
deleted file mode 100644
index 080143835..000000000
--- a/packages/editor/dist/es/index.js
+++ /dev/null
@@ -1,154 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import "./extensions";
-import CharacterCount from "@tiptap/extension-character-count";
-import Placeholder from "@tiptap/extension-placeholder";
-import Underline from "@tiptap/extension-underline";
-import StarterKit from "@tiptap/starter-kit";
-import { useEffect, useMemo } from "react";
-import { EditorView } from "prosemirror-view";
-import Toolbar from "./toolbar";
-import TextAlign from "@tiptap/extension-text-align";
-import Subscript from "@tiptap/extension-subscript";
-import Superscript from "@tiptap/extension-superscript";
-import FontSize from "./extensions/font-size";
-import TextDirection from "./extensions/text-direction";
-import TextStyle from "@tiptap/extension-text-style";
-import FontFamily from "@tiptap/extension-font-family";
-import BulletList from "./extensions/bullet-list";
-import OrderedList from "./extensions/ordered-list";
-import Highlight from "@tiptap/extension-highlight";
-import Color from "@tiptap/extension-color";
-import TableRow from "@tiptap/extension-table-row";
-import TableCell from "./extensions/table-cell";
-import TableHeader from "@tiptap/extension-table-header";
-import { ImageNode } from "./extensions/image";
-import { AttachmentNode } from "./extensions/attachment";
-import { TaskListNode } from "./extensions/task-list";
-import { TaskItemNode } from "./extensions/task-item";
-import { Dropcursor } from "./extensions/drop-cursor";
-import { SearchReplace } from "./extensions/search-replace";
-import { EmbedNode } from "./extensions/embed";
-import { CodeBlock } from "./extensions/code-block";
-import { ListItem } from "./extensions/list-item";
-import { Link } from "@tiptap/extension-link";
-import { Codemark } from "./extensions/code-mark";
-import { MathInline, MathBlock } from "./extensions/math";
-import { NodeViewSelectionNotifier, usePortalProvider, } from "./extensions/react";
-import { OutlineList } from "./extensions/outline-list";
-import { OutlineListItem } from "./extensions/outline-list-item";
-import { KeepInView } from "./extensions/keep-in-view";
-import { SelectionPersist } from "./extensions/selection-persist";
-import { Table } from "./extensions/table";
-import { useToolbarStore } from "./toolbar/stores/toolbar-store";
-import { useEditor } from "./hooks/use-editor";
-import { usePermissionHandler } from "./hooks/use-permission-handler";
-EditorView.prototype.updateState = function updateState(state) {
- if (!this.docView)
- return; // This prevents the matchesNode error on hot reloads
- this.updateStateInner(state, this.state.plugins != state.plugins);
-};
-const useTiptap = (options = {}, deps = []) => {
- const { theme, isMobile, onDownloadAttachment, onOpenAttachmentPicker, onBeforeCreate } = options, restOptions = __rest(options, ["theme", "isMobile", "onDownloadAttachment", "onOpenAttachmentPicker", "onBeforeCreate"]);
- const PortalProviderAPI = usePortalProvider();
- const setIsMobile = useToolbarStore((store) => store.setIsMobile);
- const setTheme = useToolbarStore((store) => store.setTheme);
- useEffect(() => {
- setIsMobile(isMobile || false);
- setTheme(theme);
- }, [isMobile, theme]);
- const defaultOptions = useMemo(() => ({
- extensions: [
- NodeViewSelectionNotifier,
- SearchReplace,
- TextStyle,
- StarterKit.configure({
- dropcursor: false,
- codeBlock: false,
- listItem: false,
- orderedList: false,
- bulletList: false,
- history: {
- depth: 200,
- newGroupDelay: 1000,
- },
- }),
- Dropcursor.configure({
- class: "drop-cursor",
- }),
- CharacterCount,
- Underline,
- Subscript,
- Superscript,
- FontSize,
- TextDirection,
- FontFamily,
- BulletList,
- OrderedList,
- TaskItemNode.configure({ nested: true }),
- TaskListNode,
- Link.configure({ openOnClick: !isMobile }),
- Table.configure({
- resizable: true,
- allowTableNodeSelection: true,
- cellMinWidth: 50,
- }),
- TableRow,
- TableCell,
- TableHeader,
- Highlight.configure({
- multicolor: true,
- }),
- CodeBlock,
- Color,
- TextAlign.configure({
- types: ["heading", "paragraph"],
- alignments: ["left", "right", "center", "justify"],
- defaultAlignment: "left",
- }),
- Placeholder.configure({
- placeholder: "Start writing your note...",
- }),
- ImageNode,
- EmbedNode,
- AttachmentNode.configure({
- onDownloadAttachment,
- onOpenAttachmentPicker,
- }),
- OutlineListItem,
- OutlineList,
- ListItem,
- Codemark,
- MathInline,
- MathBlock,
- KeepInView,
- SelectionPersist,
- ],
- onBeforeCreate: ({ editor }) => {
- editor.storage.portalProviderAPI = PortalProviderAPI;
- if (onBeforeCreate)
- onBeforeCreate({ editor });
- },
- injectCSS: false,
- }), [
- onDownloadAttachment,
- onOpenAttachmentPicker,
- PortalProviderAPI,
- onBeforeCreate,
- ]);
- const editor = useEditor(Object.assign(Object.assign({}, defaultOptions), restOptions), deps);
- return editor;
-};
-export { useTiptap, Toolbar, usePermissionHandler };
-export * from "./types";
-export * from "./extensions/react";
-export * from "./toolbar";
diff --git a/packages/editor/dist/es/package.json b/packages/editor/dist/es/package.json
deleted file mode 100644
index 472002573..000000000
--- a/packages/editor/dist/es/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "type": "module"
-}
diff --git a/packages/editor/dist/es/toolbar/components/counter.d.ts b/packages/editor/dist/es/toolbar/components/counter.d.ts
deleted file mode 100644
index bfbe39347..000000000
--- a/packages/editor/dist/es/toolbar/components/counter.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import React from "react";
-export declare type CounterProps = {
- title: string;
- onIncrease: () => void;
- onDecrease: () => void;
- onReset: () => void;
- value: string;
-};
-declare function _Counter(props: CounterProps): JSX.Element;
-export declare const Counter: React.MemoExoticComponent<typeof _Counter>;
-export {};
diff --git a/packages/editor/dist/es/toolbar/components/counter.js b/packages/editor/dist/es/toolbar/components/counter.js
deleted file mode 100644
index 32046dab1..000000000
--- a/packages/editor/dist/es/toolbar/components/counter.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import React from "react";
-import { Flex } from "rebass";
-import { Button } from "../../components/button";
-import { ToolButton } from "./tool-button";
-function _Counter(props) {
- const { title, onDecrease, onIncrease, onReset, value } = props;
- return (_jsxs(Flex, Object.assign({ sx: {
- alignItems: "center",
- mr: 1,
- ":last-of-type": {
- mr: 0,
- },
- } }, { children: [_jsx(ToolButton, { toggled: false, title: `Decrease ${title}`, icon: "minus", variant: "small", onClick: onDecrease }), _jsx(Button, Object.assign({ sx: {
- color: "text",
- bg: "transparent",
- px: 0,
- fontSize: "subBody",
- mx: 1,
- textAlign: "center",
- ":hover": { bg: "transparent" },
- }, onClick: onReset, title: `Reset ${title}` }, { children: value })), _jsx(ToolButton, { toggled: false, title: `Increase ${title}`, icon: "plus", variant: "small", onClick: onIncrease })] })));
-}
-export const Counter = React.memo(_Counter, (prev, next) => {
- return prev.value === next.value;
-});
diff --git a/packages/editor/dist/es/toolbar/components/dropdown.d.ts b/packages/editor/dist/es/toolbar/components/dropdown.d.ts
deleted file mode 100644
index d383ea4a0..000000000
--- a/packages/editor/dist/es/toolbar/components/dropdown.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-import { MenuItem } from "../../components/menu/types";
-declare type DropdownProps = {
- id: string;
- group: string;
- selectedItem: string | JSX.Element;
- items: MenuItem[];
- buttonRef?: React.MutableRefObject<HTMLButtonElement | undefined>;
- menuWidth?: number;
-};
-export declare function Dropdown(props: DropdownProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/components/dropdown.js b/packages/editor/dist/es/toolbar/components/dropdown.js
deleted file mode 100644
index 443b25343..000000000
--- a/packages/editor/dist/es/toolbar/components/dropdown.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { useRef, useState } from "react";
-import { Text } from "rebass";
-import { Icon } from "./icon";
-import { Icons } from "../icons";
-import { useIsMobile, useToolbarLocation, } from "../stores/toolbar-store";
-import { MenuPresenter } from "../../components/menu";
-import { getToolbarElement } from "../utils/dom";
-import { Button } from "../../components/button";
-import { usePopupHandler } from "../../components/popup-presenter";
-export function Dropdown(props) {
- let { id, group, items, selectedItem, buttonRef, menuWidth } = props;
- const internalRef = useRef();
- const [isOpen, setIsOpen] = useState(false);
- const toolbarLocation = useToolbarLocation();
- const isMobile = useIsMobile();
- const isBottom = toolbarLocation === "bottom";
- const { closePopup, isPopupOpen } = usePopupHandler({
- group,
- id,
- isOpen,
- onClosed: () => setIsOpen(false),
- });
- return (_jsxs(_Fragment, { children: [_jsxs(Button, Object.assign({ ref: (ref) => {
- internalRef.current = ref;
- if (buttonRef)
- buttonRef.current = ref || undefined;
- }, sx: {
- p: 1,
- m: 0,
- bg: isPopupOpen ? "hover" : "transparent",
- mr: 1,
- display: "flex",
- alignItems: "center",
- ":hover": { bg: "hover" },
- ":last-of-type": {
- mr: 0,
- },
- }, onClick: () => setIsOpen((s) => !s), onMouseDown: (e) => e.preventDefault() }, { children: [typeof selectedItem === "string" ? (_jsx(Text, Object.assign({ sx: { fontSize: "subBody", mr: 1, color: "text" } }, { children: selectedItem }))) : (selectedItem), _jsx(Icon, { path: isBottom ? Icons.chevronUp : Icons.chevronDown, size: "small", color: "text" })] })), _jsx(MenuPresenter, { isOpen: isPopupOpen, items: items, onClose: () => closePopup(id), position: {
- target: isBottom
- ? getToolbarElement()
- : internalRef.current || "mouse",
- isTargetAbsolute: true,
- location: isBottom ? "top" : "below",
- align: "center",
- yOffset: 5,
- }, blocking: !isMobile, focusOnRender: !isMobile, sx: {
- minWidth: menuWidth,
- maxWidth: isBottom ? "95vw" : "auto",
- flexDirection: isBottom ? "row" : "column",
- overflowX: isBottom ? "auto" : "hidden",
- marginRight: isBottom ? "10px" : 0,
- display: "flex",
- alignItems: isBottom ? "center" : "unset",
- mr: isBottom ? 0 : 2,
- } })] }));
-}
diff --git a/packages/editor/dist/es/toolbar/components/icon.d.ts b/packages/editor/dist/es/toolbar/components/icon.d.ts
deleted file mode 100644
index b7b4d5cb3..000000000
--- a/packages/editor/dist/es/toolbar/components/icon.d.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/// <reference types="react" />
-import { Theme } from "@streetwriters/theme";
-import { SchemeColors } from "@streetwriters/theme/dist/theme/colorscheme";
-import { FlexProps } from "rebass";
-declare type IconProps = {
- title?: string;
- path: string;
- size?: keyof Theme["iconSizes"] | number;
- color?: keyof SchemeColors;
- stroke?: string;
- rotate?: boolean;
-};
-export declare type NNIconProps = FlexProps & IconProps;
-export declare function Icon(props: NNIconProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/components/icon.js b/packages/editor/dist/es/toolbar/components/icon.js
deleted file mode 100644
index 50190b301..000000000
--- a/packages/editor/dist/es/toolbar/components/icon.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import MDIIcon from "@mdi/react";
-import { Flex } from "rebass";
-import { useTheme } from "emotion-theming";
-function MDIIconWrapper({ title, path, size = 24, color = "icon", stroke, rotate, }) {
- const theme = useTheme();
- const themedColor = (theme === null || theme === void 0 ? void 0 : theme.colors)
- ? theme.colors[color]
- : color;
- return (_jsx(MDIIcon, { className: "icon", title: title, path: path, size: typeof size === "string"
- ? `${(theme === null || theme === void 0 ? void 0 : theme.iconSizes[size]) || 24}px`
- : `${size}px`, style: {
- strokeWidth: stroke || "0px",
- stroke: themedColor,
- }, color: themedColor, spin: rotate }));
-}
-export function Icon(props) {
- const { sx, title, color, size, stroke, rotate, path } = props, restProps = __rest(props, ["sx", "title", "color", "size", "stroke", "rotate", "path"]);
- return (_jsx(Flex, Object.assign({ sx: Object.assign({ flexShrink: 0, justifyContent: "center", alignItems: "center" }, sx) }, restProps, { children: _jsx(MDIIconWrapper, { title: title, path: path, rotate: rotate, color: color, stroke: stroke, size: size }) })));
-}
diff --git a/packages/editor/dist/es/toolbar/components/moretools.d.ts b/packages/editor/dist/es/toolbar/components/moretools.d.ts
deleted file mode 100644
index f630e403e..000000000
--- a/packages/editor/dist/es/toolbar/components/moretools.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-import { ToolId } from "../tools";
-declare type MoreToolsProps = ToolProps & {
- popupId: string;
- tools: ToolId[];
- autoCloseOnUnmount?: boolean;
-};
-export declare function MoreTools(props: MoreToolsProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/components/moretools.js b/packages/editor/dist/es/toolbar/components/moretools.js
deleted file mode 100644
index 9e9bfb587..000000000
--- a/packages/editor/dist/es/toolbar/components/moretools.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { useRef, useState } from "react";
-import { PopupWrapper } from "../../components/popup-presenter";
-import { ToolButton } from "../components/tool-button";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { getToolbarElement } from "../utils/dom";
-import { ToolbarGroup } from "./toolbar-group";
-export function MoreTools(props) {
- const { popupId, editor, tools, autoCloseOnUnmount } = props;
- const toolbarLocation = useToolbarLocation();
- const isBottom = toolbarLocation === "bottom";
- const buttonRef = useRef();
- const [isOpen, setIsOpen] = useState(false);
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({}, props, { toggled: isOpen, buttonRef: buttonRef, onClick: () => setIsOpen((s) => !s) })), _jsx(PopupWrapper, { isOpen: isOpen, group: "toolbarGroup", id: popupId, onClosed: () => setIsOpen(false), position: {
- isTargetAbsolute: true,
- target: isBottom ? getToolbarElement() : buttonRef.current || "mouse",
- align: "center",
- location: isBottom ? "top" : "below",
- yOffset: 10,
- }, autoCloseOnUnmount: autoCloseOnUnmount, focusOnRender: false, blocking: false, renderPopup: () => (_jsx(ToolbarGroup, { tools: tools, editor: editor, sx: {
- flex: 1,
- // this is intentionally set to a fixed value
- // because we want the same padding on mobile
- // and web.
- p: "5px",
- boxShadow: "menu",
- bg: "background",
- borderRadius: "default",
- overflowX: "auto",
- maxWidth: "95vw",
- } })) })] }));
-}
diff --git a/packages/editor/dist/es/toolbar/components/popup.d.ts b/packages/editor/dist/es/toolbar/components/popup.d.ts
deleted file mode 100644
index fb521b343..000000000
--- a/packages/editor/dist/es/toolbar/components/popup.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { PropsWithChildren } from "react";
-declare type Action = {
- title: string;
- onClick: () => void;
- loading?: boolean;
- disabled?: boolean;
-};
-export declare type PopupProps = {
- title?: string;
- onClose?: () => void;
- action?: Action;
-};
-export declare function Popup(props: PropsWithChildren<PopupProps>): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/components/popup.js b/packages/editor/dist/es/toolbar/components/popup.js
deleted file mode 100644
index 567163ec6..000000000
--- a/packages/editor/dist/es/toolbar/components/popup.js
+++ /dev/null
@@ -1,27 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { Button, Flex, Text } from "rebass";
-import { Icon } from "./icon";
-import { Icons } from "../icons";
-import { DesktopOnly, MobileOnly } from "../../components/responsive";
-export function Popup(props) {
- const { title, onClose, action, children } = props;
- return (_jsxs(_Fragment, { children: [_jsx(DesktopOnly, { children: _jsxs(Flex, Object.assign({ sx: {
- overflow: "hidden",
- bg: "background",
- flexDirection: "column",
- borderRadius: "default",
- // border: "1px solid var(--border)",
- boxShadow: "menu",
- minWidth: 200,
- } }, { children: [title && (_jsxs(Flex, Object.assign({ className: "movable", sx: {
- justifyContent: "space-between",
- alignItems: "center",
- p: 2,
- } }, { children: [_jsx(Text, Object.assign({ variant: "title" }, { children: title })), _jsx(Button, Object.assign({ variant: "tool", sx: { p: 0, bg: "transparent" }, onClick: onClose }, { children: _jsx(Icon, { path: Icons.close, size: "big" }) }))] }))), children, title && action && (_jsx(Flex, Object.assign({ sx: { justifyContent: "end" }, bg: "bgSecondary", p: 1, px: 2, mt: 2 }, { children: _jsx(Button, Object.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, Object.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/es/toolbar/components/splitbutton.d.ts b/packages/editor/dist/es/toolbar/components/splitbutton.d.ts
deleted file mode 100644
index 0db2f1020..000000000
--- a/packages/editor/dist/es/toolbar/components/splitbutton.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { PropsWithChildren } from "react";
-import { ToolButtonProps } from "./tool-button";
-import React from "react";
-export declare type SplitButtonProps = ToolButtonProps & {
- onOpen: () => void;
-};
-declare function _SplitButton(props: PropsWithChildren<SplitButtonProps>): JSX.Element;
-export declare const SplitButton: React.MemoExoticComponent<typeof _SplitButton>;
-export {};
diff --git a/packages/editor/dist/es/toolbar/components/splitbutton.js b/packages/editor/dist/es/toolbar/components/splitbutton.js
deleted file mode 100644
index 733bee369..000000000
--- a/packages/editor/dist/es/toolbar/components/splitbutton.js
+++ /dev/null
@@ -1,42 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { useRef } from "react";
-import { Flex } from "rebass";
-import { Icons } from "../icons";
-import { Icon } from "./icon";
-import { ToolButton } from "./tool-button";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { Button } from "../../components/button";
-import React from "react";
-function _SplitButton(props) {
- const { children, toggled, onOpen } = props, toolButtonProps = __rest(props, ["children", "toggled", "onOpen"]);
- const ref = useRef(null);
- const toolbarLocation = useToolbarLocation();
- return (_jsxs(_Fragment, { children: [_jsxs(Flex, Object.assign({ ref: ref, sx: {
- borderRadius: "default",
- } }, { children: [_jsx(ToolButton, Object.assign({}, toolButtonProps, { sx: { mr: 0, ":hover": { bg: "hover" } }, toggled: false })), _jsx(Button, Object.assign({ sx: {
- flexShrink: 0,
- p: 0,
- m: 0,
- px: "3px",
- bg: "bgSecondary",
- ":hover": { bg: "hover" },
- ":last-of-type": {
- mr: 0,
- },
- }, onClick: onOpen }, { children: _jsx(Icon, { path: toolbarLocation === "bottom" ? Icons.chevronUp : Icons.chevronDown, color: "text", size: "small", sx: { flexShrink: 0 } }) }))] })), children] }));
-}
-export const SplitButton = React.memo(_SplitButton, (prev, next) => {
- return (prev.toggled === next.toggled &&
- JSON.stringify(prev.sx) === JSON.stringify(next.sx));
-});
diff --git a/packages/editor/dist/es/toolbar/components/toolbargroup.d.ts b/packages/editor/dist/es/toolbar/components/toolbargroup.d.ts
deleted file mode 100644
index 94c8be6dd..000000000
--- a/packages/editor/dist/es/toolbar/components/toolbargroup.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/// <reference types="react" />
-import { ToolbarGroupDefinition, ToolButtonVariant } from "../types";
-import { FlexProps } from "rebass";
-import { Editor } from "../../types";
-import { NodeWithOffset } from "../utils/prosemirror";
-export declare type ToolbarGroupProps = FlexProps & {
- tools: ToolbarGroupDefinition;
- editor: Editor;
- variant?: ToolButtonVariant;
- force?: boolean;
- selectedNode?: NodeWithOffset;
-};
-export declare function ToolbarGroup(props: ToolbarGroupProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/components/toolbargroup.js b/packages/editor/dist/es/toolbar/components/toolbargroup.js
deleted file mode 100644
index 14ab942d9..000000000
--- a/packages/editor/dist/es/toolbar/components/toolbargroup.js
+++ /dev/null
@@ -1,29 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { findTool } from "../tools";
-import { Flex } from "rebass";
-import { MoreTools } from "./more-tools";
-import { getToolDefinition } from "../tool-definitions";
-export function ToolbarGroup(props) {
- const { tools, editor, force, selectedNode } = props, flexProps = __rest(props, ["tools", "editor", "force", "selectedNode"]);
- return (_jsx(Flex, Object.assign({ className: "toolbar-group" }, flexProps, { children: tools.map((toolId) => {
- if (Array.isArray(toolId)) {
- return (_jsx(MoreTools, { title: "More", icon: "more", popupId: toolId.join(""), tools: toolId, editor: editor }, "more-tools"));
- }
- else {
- const Component = findTool(toolId);
- const toolDefinition = getToolDefinition(toolId);
- return (_jsx(Component, Object.assign({ editor: editor, force: force, selectedNode: selectedNode }, toolDefinition), toolDefinition.title));
- }
- }) })));
-}
diff --git a/packages/editor/dist/es/toolbar/components/toolbutton.d.ts b/packages/editor/dist/es/toolbar/components/toolbutton.d.ts
deleted file mode 100644
index 58c40f4ee..000000000
--- a/packages/editor/dist/es/toolbar/components/toolbutton.d.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Theme } from "@streetwriters/theme";
-import { SchemeColors } from "@streetwriters/theme/dist/theme/colorscheme";
-import React from "react";
-import { ButtonProps } from "rebass";
-import { IconNames } from "../icons";
-import { ToolButtonVariant } from "../types";
-export declare type ToolButtonProps = ButtonProps & {
- icon: IconNames;
- iconColor?: keyof SchemeColors;
- iconSize?: keyof Theme["iconSizes"] | number;
- toggled: boolean;
- buttonRef?: React.MutableRefObject<HTMLButtonElement | null | undefined>;
- variant?: ToolButtonVariant;
-};
-export declare const ToolButton: React.NamedExoticComponent<ButtonProps & {
- icon: IconNames;
- iconColor?: "background" | "border" | "text" | "blue" | "gray" | "green" | "orange" | "purple" | "red" | "yellow" | "checked" | "disabled" | "placeholder" | "icon" | keyof import("@streetwriters/theme/dist/theme/colorscheme/static").StaticColors | "primary" | "bgTransparent" | "accent" | "bgSecondary" | "bgSecondaryText" | "bgSecondaryHover" | "hover" | "fontSecondary" | "fontTertiary" | "overlay" | "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/es/toolbar/components/toolbutton.js b/packages/editor/dist/es/toolbar/components/toolbutton.js
deleted file mode 100644
index 99b7dcb0c..000000000
--- a/packages/editor/dist/es/toolbar/components/toolbutton.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import React from "react";
-import { Icons } from "../icons";
-import { Button } from "../../components/button";
-import { Icon } from "./icon";
-export const ToolButton = React.memo(function ToolButton(props) {
- const { id, icon, iconSize, iconColor, toggled, sx, buttonRef, variant = "normal" } = props, buttonProps = __rest(props, ["id", "icon", "iconSize", "iconColor", "toggled", "sx", "buttonRef", "variant"]);
- return (_jsx(Button, Object.assign({ ref: buttonRef, tabIndex: -1, id: `tool-${id || icon}`, sx: Object.assign({ flexShrink: 0, p: variant === "small" ? "small" : 1, borderRadius: variant === "small" ? "small" : "default", m: 0, bg: toggled ? "hover" : "transparent", mr: variant === "small" ? 0 : 1, ":hover": { bg: "hover" }, ":last-of-type": {
- mr: 0,
- } }, sx), onMouseDown: (e) => e.preventDefault() }, buttonProps, { children: _jsx(Icon, { path: Icons[icon], color: iconColor || "icon", size: iconSize || (variant === "small" ? "medium" : "big") }) })));
-}, (prev, next) => {
- return (prev.toggled === next.toggled &&
- prev.icon === next.icon &&
- JSON.stringify(prev.sx) === JSON.stringify(next.sx));
-});
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/index.d.ts b/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/index.d.ts
deleted file mode 100644
index e23f86eea..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/index.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Editor } from "../../../types";
-import { NodeWithOffset } from "../../utils/prosemirror";
-import { FloatingMenuProps } from "../types";
-export declare type HoverPopupProps = {
- editor: Editor;
- selectedNode: NodeWithOffset;
-};
-export declare function HoverPopupHandler(props: FloatingMenuProps): null;
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/index.js b/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/index.js
deleted file mode 100644
index 2504e89ff..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/index.js
+++ /dev/null
@@ -1,65 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { useEffect, useRef } from "react";
-import { showPopup } from "../../../components/popup-presenter";
-import { LinkHoverPopupHandler } from "./link";
-const handlers = Object.assign({}, LinkHoverPopupHandler);
-const HOVER_TIMEOUT = 500;
-export function HoverPopupHandler(props) {
- const { editor } = props;
- const hoverTimeoutId = useRef();
- const activePopup = useRef();
- useEffect(() => {
- function onMouseOver(e) {
- if (!e.target ||
- !(e.target instanceof HTMLElement) ||
- e.target.classList.contains("ProseMirror"))
- return;
- const element = e.target;
- if (activePopup.current) {
- const isOutsideEditor = !element.closest(".ProseMirror");
- const isInsidePopup = element.closest(".popup-presenter-portal");
- const isActiveElement = activePopup.current.element === element;
- if (isInsidePopup)
- return;
- if (isOutsideEditor || !isActiveElement) {
- console.log("HIDING", isOutsideEditor, isActiveElement, element);
- activePopup.current.hide();
- activePopup.current = undefined;
- return;
- }
- }
- clearTimeout(hoverTimeoutId.current);
- hoverTimeoutId.current = setTimeout(() => {
- const nodeName = element.nodeName.toLowerCase();
- const PopupHandler = handlers[nodeName];
- if (!PopupHandler || !editor.current)
- return;
- const pos = editor.current.view.posAtDOM(element, 0);
- const node = editor.current.view.state.doc.nodeAt(pos);
- if (!node)
- return;
- const hidePopup = showPopup({
- popup: () => (_jsx(PopupHandler, { editor: editor, selectedNode: {
- node,
- from: pos,
- to: pos + node.nodeSize,
- } })),
- blocking: false,
- focusOnRender: false,
- position: {
- target: element,
- align: "center",
- location: "top",
- isTargetAbsolute: true,
- },
- });
- activePopup.current = { element, hide: hidePopup };
- }, HOVER_TIMEOUT, {});
- }
- window.addEventListener("mouseover", onMouseOver);
- return () => {
- window.removeEventListener("mouseover", onMouseOver);
- };
- }, []);
- return null;
-}
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.d.ts b/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.d.ts
deleted file mode 100644
index 6463e2600..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { HoverPopupProps } from ".";
-declare function LinkHoverPopup(props: HoverPopupProps): JSX.Element | null;
-export declare const LinkHoverPopupHandler: {
- a: typeof LinkHoverPopup;
-};
-export {};
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.js b/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.js
deleted file mode 100644
index 4e63e0eaf..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/hoverpopup/link.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { ToolbarGroup } from "../../components/toolbar-group";
-function LinkHoverPopup(props) {
- const { editor, selectedNode } = props;
- const { node } = selectedNode;
- if (!(node === null || node === void 0 ? void 0 : node.isText) ||
- node.marks.length <= 0 ||
- !node.marks.some((mark) => mark.type.name === "link"))
- return null;
- return (_jsx(ToolbarGroup, { force: true, tools: ["openLink", "editLink", "removeLink"], editor: editor, selectedNode: selectedNode, sx: {
- bg: "background",
- boxShadow: "menu",
- borderRadius: "default",
- p: 1,
- } }));
-}
-export const LinkHoverPopupHandler = { a: LinkHoverPopup };
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/index.d.ts b/packages/editor/dist/es/toolbar/floatingmenus/index.d.ts
deleted file mode 100644
index b02c024c2..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { FloatingMenuProps } from "./types";
-export declare function EditorFloatingMenus(props: FloatingMenuProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/index.js b/packages/editor/dist/es/toolbar/floatingmenus/index.js
deleted file mode 100644
index dabfded55..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { DesktopOnly } from "../../components/responsive";
-import { HoverPopupHandler } from "./hover-popup";
-import { SearchReplaceFloatingMenu } from "./search-replace";
-export function EditorFloatingMenus(props) {
- return (_jsxs(_Fragment, { children: [_jsx(SearchReplaceFloatingMenu, Object.assign({}, props)), _jsx(DesktopOnly, { children: _jsx(HoverPopupHandler, Object.assign({}, props)) })] }));
-}
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/searchreplace.d.ts b/packages/editor/dist/es/toolbar/floatingmenus/searchreplace.d.ts
deleted file mode 100644
index 66a0fa228..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/searchreplace.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { FloatingMenuProps } from "./types";
-export declare function SearchReplaceFloatingMenu(props: FloatingMenuProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/searchreplace.js b/packages/editor/dist/es/toolbar/floatingmenus/searchreplace.js
deleted file mode 100644
index 443b9382d..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/searchreplace.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { SearchReplacePopup } from "../popups/search-replace";
-import { ResponsivePresenter, } from "../../components/responsive";
-import { getToolbarElement } from "../utils/dom";
-export function SearchReplaceFloatingMenu(props) {
- const { editor } = props;
- const { isSearching } = editor.storage.searchreplace;
- return (_jsx(ResponsivePresenter, Object.assign({ mobile: "sheet", desktop: "menu", isOpen: isSearching, onClose: () => editor.commands.endSearch(), position: {
- target: getToolbarElement(),
- isTargetAbsolute: true,
- location: "below",
- align: "end",
- yOffset: 5,
- }, blocking: false, focusOnRender: false, draggable: false }, { children: _jsx(SearchReplacePopup, { editor: editor }) })));
-}
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/types.d.ts b/packages/editor/dist/es/toolbar/floatingmenus/types.d.ts
deleted file mode 100644
index f3ea5ebf6..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/types.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { Editor } from "../../types";
-export declare type FloatingMenuProps = {
- editor: Editor;
-};
diff --git a/packages/editor/dist/es/toolbar/floatingmenus/types.js b/packages/editor/dist/es/toolbar/floatingmenus/types.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/packages/editor/dist/es/toolbar/floatingmenus/types.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/editor/dist/es/toolbar/icons.d.ts b/packages/editor/dist/es/toolbar/icons.d.ts
deleted file mode 100644
index 9a38e6591..000000000
--- a/packages/editor/dist/es/toolbar/icons.d.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-export declare const Icons: {
- bold: string;
- italic: string;
- underline: string;
- strikethrough: string;
- code: string;
- codeRemove: string;
- alignCenter: string;
- alignLeft: string;
- alignRight: string;
- alignJustify: string;
- subscript: string;
- superscript: string;
- horizontalRule: string;
- codeblock: string;
- blockquote: string;
- formatClear: string;
- ltr: string;
- rtl: string;
- numberedList: string;
- bulletList: string;
- highlight: string;
- textColor: string;
- link: string;
- linkRemove: string;
- openLink: string;
- linkEdit: string;
- linkSettings: string;
- url: string;
- image: string;
- imageSettings: string;
- colorClear: string;
- check: string;
- checkbox: string;
- loading: string;
- more: string;
- upload: string;
- camera: string;
- attachment: string;
- table: string;
- rowProperties: string;
- insertRowBelow: string;
- insertRowAbove: string;
- moveRowDown: string;
- moveRowUp: string;
- deleteRow: string;
- toggleHeaderRow: string;
- columnProperties: string;
- insertColumnRight: string;
- insertColumnLeft: string;
- moveColumnRight: string;
- moveColumnLeft: string;
- deleteColumn: string;
- cellProperties: string;
- cellBorderColor: string;
- backgroundColor: string;
- borderColor: string;
- sortDesc: string;
- deleteTable: string;
- mergeCells: string;
- splitCells: string;
- checklist: string;
- dragHandle: string;
- previousMatch: string;
- nextMatch: string;
- replaceOne: string;
- replaceAll: string;
- replace: string;
- attachmentSettings: string;
- caseSensitive: string;
- wholeWord: string;
- regex: string;
- embed: string;
- embedSettings: string;
- palette: string;
- tableSettings: string;
- math: string;
- mathBlock: string;
- outlineList: string;
- fontFamily: string;
- fontSize: string;
- heading: string;
- indent: string;
- outdent: string;
- plus: string;
- minus: string;
- close: string;
- delete: string;
- download: string;
- chevronDown: string;
- chevronUp: string;
- chevronRight: string;
- chevronLeft: string;
- circle: string;
- arrowLeft: string;
- resize: string;
- none: string;
-};
-export declare type IconNames = keyof typeof Icons;
diff --git a/packages/editor/dist/es/toolbar/icons.js b/packages/editor/dist/es/toolbar/icons.js
deleted file mode 100644
index 0c47cc30b..000000000
--- a/packages/editor/dist/es/toolbar/icons.js
+++ /dev/null
@@ -1,99 +0,0 @@
-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, mdiLinkOff, mdiOpenInNew, mdiCameraOutline, mdiMathIntegral, mdiFunctionVariant, mdiFileTreeOutline, mdiFormatFont, mdiFormatFontSizeIncrease, mdiFormatHeaderPound, mdiFormatIndentIncrease, mdiFormatIndentDecrease, mdiResizeBottomRight } from "@mdi/js";
-export const Icons = {
- bold: mdiFormatBold,
- italic: mdiFormatItalic,
- underline: mdiFormatUnderline,
- strikethrough: mdiFormatStrikethrough,
- code: mdiCodeTags,
- codeRemove: `M3.62109375 1.83837892 2.26318358 3.13037107 6.46289063 7.536621 1.9995117 12l6.0000003 6 1.40039025-1.400391L4.80029295 12l3.0292968-3.0292965 7.0283205 7.371093-.2578125.2578125L16.000488 18l.224121-.224121 4.3125 4.52490225 1.35791025-1.29492225-4.34326125-4.55712825L22.000488 12l-6-6-1.40039025 1.40039063L19.19970675 12l-3.016113 3.016113L9.156738 7.6435545l.24316425-.24316387L7.999512 6l-.2109375.2109375Z`,
- alignCenter: mdiFormatAlignCenter,
- alignLeft: mdiFormatAlignLeft,
- alignRight: mdiFormatAlignRight,
- alignJustify: mdiFormatAlignJustify,
- subscript: mdiFormatSubscript,
- superscript: mdiFormatSuperscript,
- horizontalRule: mdiBorderHorizontal,
- codeblock: mdiCodeBraces,
- blockquote: mdiFormatQuoteClose,
- formatClear: mdiFormatClear,
- ltr: mdiFormatTextdirectionLToR,
- rtl: mdiFormatTextdirectionRToL,
- numberedList: mdiFormatListNumbered,
- bulletList: mdiFormatListBulleted,
- highlight: mdiFormatColorHighlight,
- textColor: mdiFormatColorText,
- link: mdiLinkPlus,
- linkRemove: mdiLinkOff,
- openLink: mdiOpenInNew,
- linkEdit: "m19 14 1.28 1.28c.22.21.22.56 0 .77l-1 1L17.23 15l1-1c.11-.11.25-.17.39-.17s.27.06.38.17m-.3 3.63-6.06 6.07h-2.06v-2.06l6.07-6.06zM7 7h4v2H7c-1.6568542 0-3 1.343146-3 3s1.3431458 3 3 3h4v2H7c-2.7614237 0-5-2.238576-5-5 0-2.7614237 2.2385763-5 5-5m10 0c2.761424 0 5 2.2385763 5 5h-2c0-1.656854-1.343146-3-3-3h-4V7h4m-9 4h8v2H8v-2",
- linkSettings: "M7 7h4v2H7c-1.6568542 0-3 1.343146-3 3s1.3431458 3 3 3h4v2H7c-2.7614237 0-5-2.238576-5-5 0-2.7614237 2.2385763-5 5-5m10 0c2.761424 0 5 2.2385763 5 5h-2c0-1.656854-1.343146-3-3-3h-4V7h4m-9 4h8v2H8v-2m15.119777 8.323608-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.212462-.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-.107538.03258-.240607-.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.5z",
- url: mdiLink,
- image: mdiImage,
- imageSettings: mdiImageEditOutline,
- colorClear: mdiInvertColorsOff,
- check: mdiCheck,
- checkbox: mdiCheckboxMarkedOutline,
- loading: mdiLoading,
- more: mdiDotsVertical,
- upload: mdiUploadOutline,
- camera: mdiCameraOutline,
- attachment: mdiAttachment,
- table: mdiTable,
- rowProperties: mdiTableRowHeight,
- insertRowBelow: mdiTableRowPlusAfter,
- insertRowAbove: mdiTableRowPlusBefore,
- moveRowDown: mdiArrowExpandDown,
- moveRowUp: mdiArrowExpandUp,
- deleteRow: mdiTableRowRemove,
- toggleHeaderRow: mdiTableBorder,
- columnProperties: mdiTableColumnWidth,
- insertColumnRight: mdiTableColumnPlusAfter,
- insertColumnLeft: mdiTableColumnPlusBefore,
- moveColumnRight: mdiArrowExpandRight,
- moveColumnLeft: mdiArrowExpandLeft,
- deleteColumn: mdiTableColumnRemove,
- cellProperties: mdiRectangle,
- cellBorderColor: "M4 24q-.825 0-1.412-.587Q2 22.825 2 22q0-.825.588-1.413Q3.175 20 4 20h16q.825 0 1.413.587Q22 21.175 22 22q0 .825-.587 1.413Q20.825 24 20 24Zm1-6q-.425 0-.713-.288Q4 17.425 4 17v-2.325q0-.2.075-.388q.075-.187.225-.337l8.75-8.75l3.75 3.75l-8.75 8.75q-.15.15-.337.225q-.188.075-.388.075Zm1-2h.9L14 8.95L13.05 8L6 15.1Zm11.925-8.15l-3.75-3.75l1.8-1.8q.275-.3.7-.288q.425.013.7.288l2.35 2.35q.275.275.275.688q0 .412-.275.712ZM6 16Z",
- backgroundColor: mdiFormatColorFill,
- borderColor: "M4 24q-.825 0-1.412-.587Q2 22.825 2 22q0-.825.588-1.413Q3.175 20 4 20h16q.825 0 1.413.587Q22 21.175 22 22q0 .825-.587 1.413Q20.825 24 20 24Zm1-6q-.425 0-.713-.288Q4 17.425 4 17v-2.325q0-.2.075-.388q.075-.187.225-.337l8.75-8.75l3.75 3.75l-8.75 8.75q-.15.15-.337.225q-.188.075-.388.075Zm1-2h.9L14 8.95L13.05 8L6 15.1Zm11.925-8.15l-3.75-3.75l1.8-1.8q.275-.3.7-.288q.425.013.7.288l2.35 2.35q.275.275.275.688q0 .412-.275.712ZM6 16Z",
- sortDesc: mdiSortDescending,
- deleteTable: mdiTableOff,
- mergeCells: mdiTableMergeCells,
- splitCells: mdiTableSplitCell,
- checklist: mdiFormatListCheckbox,
- dragHandle: mdiDrag,
- previousMatch: mdiArrowUp,
- nextMatch: mdiArrowDown,
- 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,
- math: mdiFunctionVariant,
- mathBlock: mdiMathIntegral,
- outlineList: mdiFileTreeOutline,
- fontFamily: mdiFormatFont,
- fontSize: mdiFormatFontSizeIncrease,
- heading: mdiFormatHeaderPound,
- indent: mdiFormatIndentIncrease,
- outdent: mdiFormatIndentDecrease,
- plus: mdiPlus,
- minus: mdiMinus,
- close: mdiClose,
- delete: mdiDeleteOutline,
- download: mdiDownloadOutline,
- chevronDown: mdiChevronDown,
- chevronUp: mdiChevronUp,
- chevronRight: mdiChevronRight,
- chevronLeft: mdiChevronLeft,
- circle: mdiCircle,
- arrowLeft: mdiArrowLeft,
- resize: mdiResizeBottomRight,
- none: ""
-};
diff --git a/packages/editor/dist/es/toolbar/index.d.ts b/packages/editor/dist/es/toolbar/index.d.ts
deleted file mode 100644
index 37d1c1dbe..000000000
--- a/packages/editor/dist/es/toolbar/index.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Toolbar } from "./toolbar";
-export default Toolbar;
-export * from "./types";
-export * from "./icons";
-export * from "./components/icon";
-export * from "./tools";
-export * from "./tool-definitions";
diff --git a/packages/editor/dist/es/toolbar/index.js b/packages/editor/dist/es/toolbar/index.js
deleted file mode 100644
index 37d1c1dbe..000000000
--- a/packages/editor/dist/es/toolbar/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Toolbar } from "./toolbar";
-export default Toolbar;
-export * from "./types";
-export * from "./icons";
-export * from "./components/icon";
-export * from "./tools";
-export * from "./tool-definitions";
diff --git a/packages/editor/dist/es/toolbar/popups/cellproperties.d.ts b/packages/editor/dist/es/toolbar/popups/cellproperties.d.ts
deleted file mode 100644
index 7c0de5a61..000000000
--- a/packages/editor/dist/es/toolbar/popups/cellproperties.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-declare type CellPropertiesProps = {
- editor: Editor;
- onClose: () => void;
-};
-export declare function CellProperties(props: CellPropertiesProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/popups/cellproperties.js b/packages/editor/dist/es/toolbar/popups/cellproperties.js
deleted file mode 100644
index baabde8ac..000000000
--- a/packages/editor/dist/es/toolbar/popups/cellproperties.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Box } from "rebass";
-import { Tab, Tabs } from "../../components/tabs";
-import { Icon } from "../components/icon";
-// import { MenuPresenter } from "../../components/menu/menu";
-import { Popup } from "../components/popup";
-import { Icons } from "../icons";
-import { ColorPicker } from "./color-picker";
-export function CellProperties(props) {
- const { editor, onClose } = props;
- const attributes = editor.getAttributes("tableCell");
- return (_jsx(Popup, Object.assign({ title: "Cell properties", onClose: onClose }, { children: _jsxs(Tabs, Object.assign({ activeIndex: 0 }, { children: [_jsxs(Tab, Object.assign({ title: _jsx(Icon, { title: "Cell background color", path: Icons.backgroundColor, size: 16 }) }, { children: [_jsx(Box, { mt: 2 }), _jsx(ColorPicker, { expanded: true, color: attributes.backgroundColor, onChange: (color) => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("backgroundColor", color);
- }, onClear: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("backgroundColor", undefined);
- } })] })), _jsxs(Tab, Object.assign({ title: _jsx(Icon, { title: "Cell text color", path: Icons.textColor, size: 16 }) }, { children: [_jsx(Box, { mt: 2 }), _jsx(ColorPicker, { expanded: true, color: attributes.color, onChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("color", color); }, onClear: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("color", undefined); } })] })), _jsxs(Tab, Object.assign({ title: _jsx(Icon, { title: "Cell border color", path: Icons.cellBorderColor, size: 16 }) }, { children: [_jsx(Box, { mt: 2 }), _jsx(ColorPicker, { expanded: true, color: attributes.borderColor, onChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderColor", color); }, onClear: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderColor", undefined);
- } })] }))] })) })));
-}
diff --git a/packages/editor/dist/es/toolbar/popups/colorpicker.d.ts b/packages/editor/dist/es/toolbar/popups/colorpicker.d.ts
deleted file mode 100644
index e9870067d..000000000
--- a/packages/editor/dist/es/toolbar/popups/colorpicker.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/// <reference types="react" />
-export declare const DEFAULT_COLORS: string[];
-declare type ColorPickerProps = {
- colors?: string[];
- color?: string;
- onClear: () => void;
- expanded?: boolean;
- onChange: (color: string) => void;
- onClose?: () => void;
- title?: string;
-};
-export declare function ColorPicker(props: ColorPickerProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/popups/colorpicker.js b/packages/editor/dist/es/toolbar/popups/colorpicker.js
deleted file mode 100644
index 76fa7b201..000000000
--- a/packages/editor/dist/es/toolbar/popups/colorpicker.js
+++ /dev/null
@@ -1,121 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { Box, Flex, Text } from "rebass";
-import { Input } from "@rebass/forms";
-import { Icon } from "../components/icon";
-import { Icons } from "../icons";
-import { useCallback, useEffect, useRef, useState } from "react";
-import tinycolor from "tinycolor2";
-import { HexColorPicker } from "react-colorful";
-import { Button } from "../../components/button";
-import { debounce } from "../../utils/debounce";
-export const DEFAULT_COLORS = [
- "#e91e63",
- "#9c27b0",
- "#673ab7",
- "#3f51b5",
- "#2196f3",
- "#03a9f4",
- "#00bcd4",
- "#009688",
- "#4caf50",
- "#8bc34a",
- "#cddc39",
- "#ffeb3b",
- "#ffc107",
- "#f44336",
-];
-const PALETTE_SIZE = [35, 35, 25];
-export function ColorPicker(props) {
- const { colors = DEFAULT_COLORS, color, onClear, onChange, title, onClose, expanded, } = props;
- const ref = useRef();
- const [isPickerOpen, setIsPickerOpen] = useState(expanded || false);
- const [currentColor, setCurrentColor] = useState(tinycolor(color || colors[0]).toHexString());
- const tColor = tinycolor(currentColor);
- useEffect(() => {
- if (!ref.current)
- return;
- if (isPickerOpen)
- ref.current.focus({ preventScroll: true });
- }, [isPickerOpen]);
- const onColorChange = useCallback(debounce((color) => {
- onChange(color);
- }, 500), [onChange]);
- return (_jsxs(Flex, Object.assign({ ref: ref, tabIndex: -1, sx: {
- bg: "background",
- flexDirection: "column",
- ".react-colorful": {
- width: "auto",
- height: 150,
- },
- ".react-colorful__saturation": {
- borderRadius: ["default", 0],
- },
- width: ["calc(100vw - 20px)", 250],
- // width: ["auto", 250],
- } }, { children: [onClose && (_jsxs(Box, Object.assign({ sx: {
- display: ["none", "flex"],
- justifyContent: "space-between",
- p: 2,
- pb: isPickerOpen ? 2 : 0,
- //pb: 0,
- alignItems: "center",
- }, onClick: onClose }, { children: [_jsx(Text, Object.assign({ variant: "title" }, { children: title })), _jsx(Button, Object.assign({ variant: "icon", sx: { p: 0 } }, { children: _jsx(Icon, { path: Icons.close, size: "big" }) }))] }))), isPickerOpen ? (_jsxs(_Fragment, { children: [_jsx(HexColorPicker, { onChange: (color) => {
- setCurrentColor(color);
- onColorChange(color);
- }, onTouchEnd: () => onChange(currentColor), onMouseUp: () => onChange(currentColor) }), _jsx(Input, { variant: "clean", placeholder: "#000000", spellCheck: false, sx: {
- my: 2,
- p: 0,
- borderRadius: 0,
- fontSize: ["title", "title", "body"],
- color: "fontTertiary",
- textAlign: "center",
- letterSpacing: 1.5,
- }, value: currentColor.toUpperCase(), maxLength: 7, onChange: (e) => {
- const { value } = e.target;
- if (!value)
- return;
- if (tinycolor(value, { format: "hex" }).isValid()) {
- setCurrentColor(value);
- onChange(value);
- }
- } })] })) : null, _jsxs(Flex, { children: [_jsxs(Flex, Object.assign({ className: "hide-scrollbar", sx: {
- flex: 1,
- p: 1,
- overflowX: ["auto", "hidden"],
- flexWrap: ["nowrap", "wrap"],
- } }, { children: [_jsx(Button, Object.assign({ variant: "icon", sx: {
- flexShrink: 0,
- width: PALETTE_SIZE,
- height: PALETTE_SIZE,
- borderRadius: 50,
- boxShadow: "menu",
- p: 0,
- ml: [2, 2, 1],
- }, onClick: onClear }, { children: _jsx(Icon, { path: Icons.colorClear, color: "text", size: 15 }) })), _jsx(Button, Object.assign({ variant: "secondary", sx: {
- flexShrink: 0,
- bg: currentColor,
- width: PALETTE_SIZE,
- height: PALETTE_SIZE,
- borderRadius: 50,
- // boxShadow: "menu",
- p: 0,
- ml: [2, 2, 1],
- ":hover": {
- bg: currentColor,
- },
- }, onClick: () => setIsPickerOpen((s) => !s) }, { children: _jsx(Icon, { path: Icons.palette, color: tColor.isDark() ? "static" : "icon", size: 18 }) })), colors.map((color) => (_jsx(Button, { sx: {
- flex: "0 0 auto",
- bg: color,
- width: PALETTE_SIZE,
- height: PALETTE_SIZE,
- ml: [2, 1, 1],
- mb: [0, 1, 1],
- borderRadius: 50,
- ":hover": {
- bg: color,
- },
- }, onClick: () => {
- setCurrentColor(color);
- onChange(color);
- } }, color)))] })), onClose && (_jsx(Button, Object.assign({ variant: "icon", sx: { display: ["block", "none"], px: 2 }, onClick: onClose }, { children: _jsx(Icon, { path: Icons.close, size: "big" }) })))] })] })));
-}
diff --git a/packages/editor/dist/es/toolbar/popups/embedpopup.d.ts b/packages/editor/dist/es/toolbar/popups/embedpopup.d.ts
deleted file mode 100644
index 2b87a72e6..000000000
--- a/packages/editor/dist/es/toolbar/popups/embedpopup.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/// <reference types="react" />
-import { Embed, EmbedSizeOptions } from "../../extensions/embed";
-export declare type EmbedPopupProps = {
- onClose: (embed?: Embed) => void;
- title: string;
- embed?: Embed;
- onSizeChanged?: (size: EmbedSizeOptions) => void;
-};
-export declare function EmbedPopup(props: EmbedPopupProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/popups/embedpopup.js b/packages/editor/dist/es/toolbar/popups/embedpopup.js
deleted file mode 100644
index 719309839..000000000
--- a/packages/editor/dist/es/toolbar/popups/embedpopup.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
-import { Flex, Text } from "rebass";
-import { useCallback, useState } from "react";
-import { Popup } from "../components/popup";
-import { Input, Textarea } from "@rebass/forms";
-import { convertUrlToEmbedUrl } from "@social-embed/lib";
-import { InlineInput } from "../../components/inline-input";
-import { Tabs, Tab } from "../../components/tabs";
-export function EmbedPopup(props) {
- const { onClose, onSizeChanged, title, embed } = props;
- const [width, setWidth] = useState((embed === null || embed === void 0 ? void 0 : embed.width) || 300);
- const [height, setHeight] = useState((embed === null || embed === void 0 ? void 0 : embed.height) || 150);
- const [src, setSrc] = useState((embed === null || embed === void 0 ? void 0 : embed.src) || "");
- const [embedSource, setEmbedSource] = useState("url");
- const [error, setError] = useState(null);
- const onSizeChange = useCallback((newWidth, newHeight) => {
- const size = newWidth
- ? {
- width: newWidth,
- height: newWidth * (height / width),
- }
- : newHeight
- ? {
- width: newHeight * (width / height),
- height: newHeight,
- }
- : {
- width: 0,
- height: 0,
- };
- setWidth(size.width);
- setHeight(size.height);
- if (onSizeChanged)
- onSizeChanged(size);
- }, [width, height]);
- return (_jsx(Popup, Object.assign({ title: title, onClose: () => onClose(), action: {
- title: "Save",
- onClick: () => {
- setError(null);
- let _src = src;
- let _width = width;
- let _height = height;
- if (embedSource === "code") {
- const document = new DOMParser().parseFromString(src, "text/html");
- if (document.getElementsByTagName("iframe").length <= 0)
- return setError("Embed code must include an iframe.");
- const srcValue = getAttribute(document, "src");
- if (!srcValue)
- return setError("Embed code must include an iframe with an src attribute.");
- _src = srcValue;
- const widthValue = getAttribute(document, "width");
- if (widthValue && !isNaN(parseInt(widthValue)))
- _width = parseInt(widthValue);
- const heightValue = getAttribute(document, "height");
- if (heightValue && !isNaN(parseInt(heightValue)))
- _height = parseInt(heightValue);
- }
- const convertedUrl = convertUrlToEmbedUrl(_src);
- if (!!convertedUrl)
- _src = convertedUrl;
- onClose({
- height: _height,
- width: _width,
- src: _src,
- });
- },
- } }, { children: _jsxs(Flex, Object.assign({ sx: { flexDirection: "column", width: ["auto", 300] } }, { children: [error && (_jsxs(Text, Object.assign({ variant: "error", sx: {
- bg: "errorBg",
- color: "error",
- p: 1,
- borderRadius: "default",
- } }, { children: ["Error: ", error] }))), _jsxs(Tabs, Object.assign({ activeIndex: 0, containerProps: { sx: { mx: 1, flexDirection: "column" } }, onTabChanged: (index) => setEmbedSource(index === 0 ? "url" : "code") }, { children: [_jsxs(Tab, Object.assign({ title: "From URL" }, { children: [_jsx(Input, { placeholder: "Enter embed source URL", value: src, autoFocus: true, onChange: (e) => setSrc(e.target.value), autoCapitalize: "none", sx: { fontSize: "body" } }), _jsxs(Flex, Object.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: (e) => onSizeChange(e.target.valueAsNumber) }), _jsx(InlineInput, { label: "height", type: "number", placeholder: "Height", value: height, sx: { fontSize: "body" }, onChange: (e) => onSizeChange(undefined, e.target.valueAsNumber) })] }))] })), _jsx(Tab, Object.assign({ title: "From code" }, { children: _jsx(Textarea, { autoFocus: true, variant: "forms.input", sx: { fontSize: "subBody", fontFamily: "monospace" }, minHeight: [200, 100], onChange: (e) => setSrc(e.target.value), placeholder: "Paste embed code here. Only iframes are supported." }) }))] }))] })) })));
-}
-function getAttribute(document, id) {
- const element = document.querySelector(`[${id}]`);
- if (!element)
- return null;
- const attribute = element.getAttribute(id);
- return attribute;
-}
diff --git a/packages/editor/dist/es/toolbar/popups/imageproperties.d.ts b/packages/editor/dist/es/toolbar/popups/imageproperties.d.ts
deleted file mode 100644
index 19bf028a6..000000000
--- a/packages/editor/dist/es/toolbar/popups/imageproperties.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/// <reference types="react" />
-import { ImageAlignmentOptions, ImageSizeOptions } from "../../extensions/image";
-import { Editor } from "../../types";
-export declare type ImagePropertiesProps = ImageSizeOptions & ImageAlignmentOptions & {
- editor: Editor;
- onClose: () => void;
-};
-export declare function ImageProperties(props: ImagePropertiesProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/popups/imageproperties.js b/packages/editor/dist/es/toolbar/popups/imageproperties.js
deleted file mode 100644
index e72876ef2..000000000
--- a/packages/editor/dist/es/toolbar/popups/imageproperties.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Flex } from "rebass";
-import { useCallback } from "react";
-import { Popup } from "../components/popup";
-import { Checkbox, Label } from "@rebass/forms";
-import { InlineInput } from "../../components/inline-input";
-import { DesktopOnly } from "../../components/responsive";
-export function ImageProperties(props) {
- const { height, width, float, editor, onClose } = props;
- const onSizeChange = useCallback((newWidth, newHeight) => {
- const size = newWidth
- ? {
- width: newWidth,
- height: newWidth * (height / width),
- }
- : newHeight
- ? {
- width: newHeight * (width / height),
- height: newHeight,
- }
- : {
- width: 0,
- height: 0,
- };
- editor.chain().setImageSize(size).run();
- }, [width, height]);
- return (_jsx(Popup, Object.assign({ title: "Image properties", onClose: onClose }, { children: _jsxs(Flex, Object.assign({ sx: { width: ["auto", 300], flexDirection: "column", p: 1 } }, { children: [_jsx(DesktopOnly, { children: _jsxs(Label, Object.assign({ variant: "text.body", sx: { justifyContent: "space-between", alignItems: "center" } }, { children: ["Float image", _jsx(Checkbox, { checked: float, onClick: () => editor
- .chain()
- .setImageAlignment({ float: !float, align: "left" })
- .run() })] })) }), _jsxs(Flex, Object.assign({ sx: { alignItems: "center", mt: 2 } }, { children: [_jsx(InlineInput, { label: "width", type: "number", value: width, containerProps: {
- sx: { mr: 1 },
- }, onChange: (e) => onSizeChange(e.target.valueAsNumber) }), _jsx(InlineInput, { label: "height", type: "number", value: height, onChange: (e) => onSizeChange(undefined, e.target.valueAsNumber) })] }))] })) })));
-}
diff --git a/packages/editor/dist/es/toolbar/popups/imageupload.d.ts b/packages/editor/dist/es/toolbar/popups/imageupload.d.ts
deleted file mode 100644
index 306f74f64..000000000
--- a/packages/editor/dist/es/toolbar/popups/imageupload.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { ImageAttributes } from "../../extensions/image";
-export declare type ImageUploadPopupProps = {
- onInsert: (image: ImageAttributes) => void;
- onClose: () => void;
-};
-export declare function ImageUploadPopup(props: ImageUploadPopupProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/popups/imageupload.js b/packages/editor/dist/es/toolbar/popups/imageupload.js
deleted file mode 100644
index a4526f146..000000000
--- a/packages/editor/dist/es/toolbar/popups/imageupload.js
+++ /dev/null
@@ -1,74 +0,0 @@
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Input } from "@rebass/forms";
-import { useState } from "react";
-import { Flex, Text } from "rebass";
-import { Popup } from "../components/popup";
-export function ImageUploadPopup(props) {
- const { onInsert, onClose } = props;
- const [isDownloading, setIsDownloading] = useState(false);
- const [error, setError] = useState();
- const [url, setUrl] = useState("");
- return (_jsx(Popup, Object.assign({ title: "Insert image from URL", onClose: onClose, action: {
- loading: isDownloading,
- title: "Insert image",
- disabled: !url,
- onClick: () => __awaiter(this, void 0, void 0, function* () {
- setIsDownloading(true);
- setError(undefined);
- try {
- const response = yield fetch(url);
- if (!response.ok)
- return setError(`invalid status code ${response.status}`);
- const contentType = response.headers.get("Content-Type");
- const contentLength = response.headers.get("Content-Length");
- if (!contentType ||
- !contentLength ||
- contentLength === "0" ||
- !contentType.startsWith("image/"))
- return setError("not an image");
- const size = parseInt(contentLength);
- const dataurl = yield toDataURL(yield response.blob());
- onInsert({ src: dataurl, type: contentType, size });
- }
- catch (e) {
- if (e instanceof Error)
- setError(e.message);
- }
- finally {
- setIsDownloading(false);
- }
- }),
- } }, { children: _jsxs(Flex, Object.assign({ sx: { px: 1, flexDirection: "column", width: ["auto", 350] } }, { children: [_jsx(Input, { type: "url", autoFocus: true, placeholder: "Paste Image URL here", value: url, onChange: (e) => {
- setUrl(e.target.value);
- setError(undefined);
- } }), error ? (_jsxs(Text, Object.assign({ variant: "error", sx: {
- bg: "errorBg",
- mt: 1,
- p: 1,
- borderRadius: "default",
- } }, { children: ["Failed to download image: ", error.toLowerCase(), "."] }))) : (_jsx(Text, Object.assign({ variant: "subBody", sx: {
- bg: "shade",
- color: "primary",
- mt: 1,
- p: 1,
- borderRadius: "default",
- } }, { children: "To protect your privacy, we will download the image & add it to your attachments." })))] })) })));
-}
-function toDataURL(blob) {
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.onload = (_e) => resolve(reader.result);
- reader.onerror = (_e) => reject(reader.error);
- reader.onabort = (_e) => reject(new Error("Read aborted"));
- reader.readAsDataURL(blob);
- });
-}
diff --git a/packages/editor/dist/es/toolbar/popups/linkpopup.d.ts b/packages/editor/dist/es/toolbar/popups/linkpopup.d.ts
deleted file mode 100644
index 1d6894848..000000000
--- a/packages/editor/dist/es/toolbar/popups/linkpopup.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-export declare type LinkPopupProps = {
- text?: string;
- href?: string;
- isEditing?: boolean;
- onDone: (link: {
- text: string;
- href: string;
- }) => void;
- onClose: () => void;
-};
-export declare function LinkPopup(props: LinkPopupProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/popups/linkpopup.js b/packages/editor/dist/es/toolbar/popups/linkpopup.js
deleted file mode 100644
index 90add5bce..000000000
--- a/packages/editor/dist/es/toolbar/popups/linkpopup.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Input } from "@rebass/forms";
-import { useState } from "react";
-import { Flex } from "rebass";
-import { Popup } from "../components/popup";
-export function LinkPopup(props) {
- const { text: _text, href: _href, isEditing = false, onDone, onClose, } = props;
- const [href, setHref] = useState(_href || "");
- const [text, setText] = useState(_text || "");
- return (_jsx(Popup, Object.assign({ title: isEditing ? "Edit link" : "Insert link", onClose: onClose, action: {
- title: isEditing ? "Save edits" : "Insert link",
- onClick: () => onDone({ text, href }),
- } }, { children: _jsxs(Flex, Object.assign({ sx: { p: 1, flexDirection: "column", width: ["auto", 250] } }, { children: [_jsx(Input, { type: "text", placeholder: "Link text", value: text, onChange: (e) => setText(e.target.value) }), _jsx(Input, { type: "url", sx: { mt: 1 }, autoFocus: true, placeholder: "https://example.com/", value: href, onChange: (e) => setHref(e.target.value) })] })) })));
-}
diff --git a/packages/editor/dist/es/toolbar/popups/searchreplace.d.ts b/packages/editor/dist/es/toolbar/popups/searchreplace.d.ts
deleted file mode 100644
index 3fa70fe5f..000000000
--- a/packages/editor/dist/es/toolbar/popups/searchreplace.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-export declare type SearchReplacePopupProps = {
- editor: Editor;
-};
-export declare function SearchReplacePopup(props: SearchReplacePopupProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/popups/searchreplace.js b/packages/editor/dist/es/toolbar/popups/searchreplace.js
deleted file mode 100644
index 1a7cd422f..000000000
--- a/packages/editor/dist/es/toolbar/popups/searchreplace.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { Input } from "@rebass/forms";
-import { useCallback, useEffect, useRef, useState } from "react";
-import { Flex, Text } from "rebass";
-import { ToolButton } from "../components/tool-button";
-export function SearchReplacePopup(props) {
- const { editor } = props;
- const { selectedText, results } = editor.storage
- .searchreplace;
- const [isReplacing, setIsReplacing] = useState(false);
- const [isExpanded, setIsExpanded] = useState(false);
- const [matchCase, setMatchCase] = useState(false);
- const [matchWholeWord, setMatchWholeWord] = useState(false);
- const [enableRegex, setEnableRegex] = useState(false);
- const replaceText = useRef("");
- const searchInputRef = useRef();
- const search = useCallback((term) => {
- editor.commands.search(term, {
- matchCase,
- enableRegex,
- matchWholeWord,
- });
- }, [matchCase, enableRegex, matchWholeWord]);
- useEffect(() => {
- if (!searchInputRef.current)
- return;
- search(searchInputRef.current.value);
- }, [search, matchCase, matchWholeWord, enableRegex]);
- useEffect(() => {
- if (selectedText) {
- if (searchInputRef.current) {
- const input = searchInputRef.current;
- setTimeout(() => {
- input.value = selectedText;
- input.focus();
- }, 0);
- }
- search(selectedText);
- }
- }, [selectedText, search]);
- return (_jsx(Flex, Object.assign({ sx: {
- p: 1,
- bg: "background",
- flexDirection: "column",
- boxShadow: ["none", "menu"],
- borderRadius: [0, "default"],
- } }, { children: _jsxs(Flex, { children: [_jsxs(Flex, Object.assign({ sx: { flexDirection: "column", flex: 1, width: ["auto", 300], mr: 1 } }, { children: [_jsxs(Flex, Object.assign({ sx: {
- flex: 1,
- position: "relative",
- alignItems: "center",
- outline: "1px solid var(--border)",
- borderRadius: "default",
- p: 1,
- py: 0,
- ":focus-within": {
- outlineColor: "primary",
- outlineWidth: "1.8px",
- },
- ":hover": {
- outlineColor: "primary",
- },
- } }, { children: [_jsx(Input, { variant: "clean", defaultValue: selectedText, ref: searchInputRef, autoFocus: true, placeholder: "Find", sx: { p: 0 }, onChange: (e) => {
- search(e.target.value);
- } }), _jsxs(Flex, Object.assign({ sx: {
- flexShrink: 0,
- mr: 0,
- alignItems: "center",
- } }, { children: [_jsx(ToolButton, { sx: {
- mr: 0,
- }, toggled: isExpanded, title: "Expand", id: "expand", icon: isExpanded ? "chevronRight" : "chevronLeft", onClick: () => setIsExpanded((s) => !s), iconSize: "medium" }), isExpanded && (_jsxs(_Fragment, { children: [_jsx(ToolButton, { sx: {
- mr: 0,
- }, toggled: matchCase, title: "Match case", id: "matchCase", icon: "caseSensitive", onClick: () => setMatchCase((s) => !s), iconSize: "medium" }), _jsx(ToolButton, { sx: {
- mr: 0,
- }, toggled: matchWholeWord, title: "Match whole word", id: "matchWholeWord", icon: "wholeWord", onClick: () => setMatchWholeWord((s) => !s), iconSize: "medium" }), _jsx(ToolButton, { sx: {
- mr: 0,
- }, toggled: enableRegex, title: "Enable regex", id: "enableRegex", icon: "regex", onClick: () => setEnableRegex((s) => !s), iconSize: "medium" })] })), _jsxs(Text, Object.assign({ variant: "subBody", sx: {
- flexShrink: 0,
- borderLeft: "1px solid var(--border)",
- color: "fontTertiary",
- px: 1,
- } }, { children: [results ? `${results.length}` : "0", isExpanded ? "" : " results"] }))] }))] })), isReplacing && (_jsx(Input, { sx: { mt: 1, p: "7px" }, placeholder: "Replace", onChange: (e) => (replaceText.current = e.target.value) }))] })), _jsxs(Flex, Object.assign({ sx: { flexDirection: "column" } }, { children: [_jsxs(Flex, Object.assign({ sx: { alignItems: "center", height: "33.2px" } }, { children: [_jsx(ToolButton, { toggled: isReplacing, title: "Toggle replace", id: "toggleReplace", icon: "replace", onClick: () => setIsReplacing((s) => !s), sx: { mr: 0 }, iconSize: "big" }), _jsx(ToolButton, { toggled: false, title: "Previous match", id: "previousMatch", icon: "previousMatch", onClick: () => editor.commands.moveToPreviousResult(), sx: { mr: 0 }, iconSize: "big" }), _jsx(ToolButton, { toggled: false, title: "Next match", id: "nextMatch", icon: "nextMatch", onClick: () => editor.commands.moveToNextResult(), sx: { mr: 0 }, iconSize: "big" }), _jsx(ToolButton, { toggled: false, title: "Close", id: "close", icon: "close", onClick: () => editor.chain().focus().endSearch().run(), sx: { mr: 0 }, iconSize: "big" })] })), isReplacing && (_jsxs(Flex, Object.assign({ sx: { alignItems: "center", height: "33.2px", mt: 1 } }, { children: [_jsx(ToolButton, { toggled: false, title: "Replace", id: "replace", icon: "replaceOne", onClick: () => editor.commands.replace(replaceText.current), sx: { mr: 0 }, iconSize: 18 }), _jsx(ToolButton, { toggled: false, title: "Replace all", id: "replaceAll", icon: "replaceAll", onClick: () => editor.commands.replaceAll(replaceText.current), sx: { mr: 0 }, iconSize: 18 })] })))] }))] }) })));
-}
diff --git a/packages/editor/dist/es/toolbar/popups/tablepopup.d.ts b/packages/editor/dist/es/toolbar/popups/tablepopup.d.ts
deleted file mode 100644
index 0e35ac702..000000000
--- a/packages/editor/dist/es/toolbar/popups/tablepopup.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/// <reference types="react" />
-declare type TableSize = {
- columns: number;
- rows: number;
-};
-export declare type TablePopupProps = {
- onInsertTable: (size: TableSize) => void;
-};
-export declare function TablePopup(props: TablePopupProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/popups/tablepopup.js b/packages/editor/dist/es/toolbar/popups/tablepopup.js
deleted file mode 100644
index 85169f143..000000000
--- a/packages/editor/dist/es/toolbar/popups/tablepopup.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-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";
-const MAX_COLUMNS = 20;
-const MAX_ROWS = 20;
-const MIN_COLUMNS = 10;
-const MIN_ROWS = 6;
-export function TablePopup(props) {
- const isMobile = useIsMobile();
- const autoExpand = !isMobile;
- const cellSize = isMobile ? 30 : 15;
- const { onInsertTable } = props;
- const [cellLocation, setCellLocation] = useState({
- column: 0,
- row: 0
- });
- const [tableSize, setTableSize] = useState({
- columns: MIN_COLUMNS,
- rows: MIN_ROWS
- });
- useEffect(() => {
- if (!autoExpand)
- return;
- setTableSize((old) => {
- const { columns, rows } = old;
- const { column, row } = cellLocation;
- let isDecrease = row === rows - 2 || column === columns - 2;
- let rowFactor = Number(row === rows || row === rows - 2);
- let columnFactor = Number(column === columns || column === columns - 2);
- return {
- columns: isDecrease
- ? Math.max(column + columnFactor, MIN_COLUMNS)
- : Math.min(old.columns + columnFactor, MAX_COLUMNS),
- rows: isDecrease
- ? Math.max(row + rowFactor, MIN_ROWS)
- : Math.min(old.rows + rowFactor, MAX_ROWS)
- };
- });
- }, [cellLocation, autoExpand]);
- return (_jsx(Popup, Object.assign({ 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
- })
- } }, { children: _jsxs(Flex, Object.assign({ sx: { px: 1, pt: 1, flexDirection: "column", alignItems: "center" } }, { children: [_jsx(Box, Object.assign({ sx: {
- display: "grid",
- gridTemplateColumns: `repeat(${tableSize.columns}, minmax(${cellSize}px, 1fr))`,
- gap: "small",
- bg: "background",
- width: "100%"
- }, onTouchMove: (e) => {
- const touch = e.touches.item(0);
- const element = document.elementFromPoint(touch.pageX, touch.pageY);
- if (!element)
- return;
- const index = element.dataset.index;
- if (!index)
- return;
- setCellLocation(getCellLocation(parseInt(index), tableSize));
- } }, { children: Array(tableSize.columns * tableSize.rows)
- .fill(0)
- .map((_, index) => (_jsx(Box, { "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));
- }, onTouchEnd: (e) => {
- e.preventDefault();
- }, onClick: () => {
- onInsertTable({
- columns: cellLocation.column,
- rows: cellLocation.row
- });
- } }, index))) })), _jsxs(Flex, Object.assign({ sx: {
- display: ["flex", "none", "none"],
- mt: 1,
- alignItems: "center",
- justifyContent: "center"
- } }, { children: [_jsx(InlineInput, { containerProps: { sx: { mr: 1 } }, label: "columns", placeholder: `${cellLocation.column} columns`, type: "number", value: cellLocation.column, onChange: (e) => {
- setCellLocation((l) => (Object.assign(Object.assign({}, l), { column: e.target.valueAsNumber || 0 })));
- } }), _jsx(InlineInput, { label: "rows", placeholder: `${cellLocation.row} rows`, type: "number", value: cellLocation.row, onChange: (e) => {
- setCellLocation((l) => (Object.assign(Object.assign({}, l), { row: e.target.valueAsNumber || 0 })));
- } })] })), _jsxs(Text, Object.assign({ variant: "body", sx: { mt: 1, display: ["none", "block", "block"] } }, { children: [cellLocation.column, " x ", cellLocation.row] }))] })) })));
-}
-function getCellLocation(index, tableSize) {
- const cellIndex = index + 1;
- const column = cellIndex % tableSize.columns;
- let row = cellIndex / tableSize.columns;
- const flooredRow = Math.floor(row);
- row = row === flooredRow ? row : flooredRow + 1;
- return { column: column ? column : tableSize.columns, row };
-}
-function isCellHighlighted(index, currentCellLocation, tableSize) {
- const cellLocation = getCellLocation(index, tableSize);
- return (cellLocation.row <= currentCellLocation.row &&
- cellLocation.column <= currentCellLocation.column);
-}
diff --git a/packages/editor/dist/es/toolbar/stores/toolbarstore.d.ts b/packages/editor/dist/es/toolbar/stores/toolbarstore.d.ts
deleted file mode 100644
index 4b0f4bcc1..000000000
--- a/packages/editor/dist/es/toolbar/stores/toolbarstore.d.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Theme } from "@streetwriters/theme";
-export declare type ToolbarLocation = "top" | "bottom";
-export declare type PopupRef = {
- id: string;
- group: string;
-};
-interface ToolbarState {
- theme?: Theme;
- setTheme: (theme?: Theme) => void;
- isMobile: boolean;
- openedPopups: Record<string, PopupRef | false>;
- setIsMobile: (isMobile: boolean) => void;
- toolbarLocation: ToolbarLocation;
- setToolbarLocation: (location: ToolbarLocation) => void;
- isPopupOpen: (popupId: string) => boolean;
- openPopup: (ref: PopupRef) => void;
- closePopup: (popupId: string) => void;
- closePopupGroup: (groupId: string, excluded: string[]) => void;
-}
-export declare const useToolbarStore: import("zustand").UseBoundStore<ToolbarState, import("zustand").StoreApi<ToolbarState>>;
-export declare function useToolbarLocation(): ToolbarLocation;
-export declare function useIsMobile(): boolean;
-export declare const useTheme: (() => Theme | undefined) & {
- theme: Theme | undefined;
-};
-export {};
diff --git a/packages/editor/dist/es/toolbar/stores/toolbarstore.js b/packages/editor/dist/es/toolbar/stores/toolbarstore.js
deleted file mode 100644
index 254ad1eff..000000000
--- a/packages/editor/dist/es/toolbar/stores/toolbarstore.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import create from "zustand";
-export const useToolbarStore = create((set, get) => ({
- theme: undefined,
- isMobile: false,
- openedPopups: {},
- setIsMobile: (isMobile) => set((state) => {
- state.isMobile = isMobile;
- }),
- setTheme: (theme) => set((state) => {
- state.theme = theme;
- }),
- toolbarLocation: "top",
- setToolbarLocation: (location) => set((state) => {
- state.toolbarLocation = location;
- }),
- closePopup: (id) => set((state) => {
- state.openedPopups = Object.assign(Object.assign({}, state.openedPopups), { [id]: false });
- }),
- isPopupOpen: (id) => !!get().openedPopups[id],
- openPopup: (ref) => set((state) => {
- state.openedPopups = Object.assign(Object.assign({}, state.openedPopups), { [ref.id]: ref });
- }),
- closePopupGroup: (group, excluded) => set((state) => {
- for (const key in state.openedPopups) {
- const ref = state.openedPopups[key];
- if (ref && ref.group === group && !excluded.includes(ref.id)) {
- state.openedPopups[key] = false;
- }
- }
- }),
-}));
-export function useToolbarLocation() {
- return useToolbarStore((store) => store.toolbarLocation);
-}
-export function useIsMobile() {
- return useToolbarStore((store) => store.isMobile);
-}
-export const useTheme = Object.defineProperty(() => {
- return useToolbarStore((store) => store.theme);
-}, "theme", {
- get: () => useToolbarStore.getState().theme,
-});
diff --git a/packages/editor/dist/es/toolbar/toolbar.d.ts b/packages/editor/dist/es/toolbar/toolbar.d.ts
deleted file mode 100644
index e7fd5f446..000000000
--- a/packages/editor/dist/es/toolbar/toolbar.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/// <reference types="react" />
-import { Theme } from "@streetwriters/theme";
-import { Editor } from "../types";
-import { FlexProps } from "rebass";
-import { ToolbarLocation } from "./stores/toolbar-store";
-import { ToolbarDefinition } from "./types";
-declare type ToolbarProps = FlexProps & {
- theme: Theme;
- editor: Editor | null;
- location: ToolbarLocation;
- tools?: ToolbarDefinition;
-};
-export declare function Toolbar(props: ToolbarProps): JSX.Element | null;
-export {};
diff --git a/packages/editor/dist/es/toolbar/toolbar.js b/packages/editor/dist/es/toolbar/toolbar.js
deleted file mode 100644
index 3227c3449..000000000
--- a/packages/editor/dist/es/toolbar/toolbar.js
+++ /dev/null
@@ -1,40 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
-import { Flex } from "rebass";
-import { ThemeProvider } from "emotion-theming";
-import { EditorFloatingMenus } from "./floating-menus";
-import { getDefaultPresets, STATIC_TOOLBAR_GROUPS } from "./tool-definitions";
-import { useEffect, useMemo } from "react";
-import { useIsMobile, useToolbarStore, } from "./stores/toolbar-store";
-import { ToolbarGroup } from "./components/toolbar-group";
-import { EditorContext, PopupRenderer, } from "../components/popup-presenter/popuprenderer";
-export function Toolbar(props) {
- const { editor, theme, location, tools = getDefaultPresets().default, sx } = props, flexProps = __rest(props, ["editor", "theme", "location", "tools", "sx"]);
- const toolbarTools = useMemo(() => [...STATIC_TOOLBAR_GROUPS, ...tools], [tools]);
- const isMobile = useIsMobile();
- const setToolbarLocation = useToolbarStore((store) => store.setToolbarLocation);
- useEffect(() => {
- setToolbarLocation(location);
- }, [location]);
- if (!editor)
- return null;
- return (_jsx(ThemeProvider, Object.assign({ theme: theme }, { children: _jsx(EditorContext.Provider, Object.assign({ value: editor }, { children: _jsxs(PopupRenderer, Object.assign({ editor: editor }, { children: [_jsx(Flex, Object.assign({ className: "editor-toolbar", sx: Object.assign(Object.assign({}, sx), { flexWrap: isMobile ? "nowrap" : "wrap", overflowX: isMobile ? "auto" : "hidden" }) }, flexProps, { children: toolbarTools.map((tools) => {
- return (_jsx(ToolbarGroup, { tools: tools, editor: editor, sx: {
- flexShrink: 0,
- pr: 2,
- mr: 2,
- borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
- } }, tools.join("")));
- }) })), _jsx(EditorFloatingMenus, { editor: editor })] })) })) })));
-}
diff --git a/packages/editor/dist/es/toolbar/tooldefinitions.d.ts b/packages/editor/dist/es/toolbar/tooldefinitions.d.ts
deleted file mode 100644
index aa2eba3f0..000000000
--- a/packages/editor/dist/es/toolbar/tooldefinitions.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { ToolbarDefinition, ToolDefinition } from "./types";
-import { ToolId } from "./tools";
-export declare function getToolDefinition(id: ToolId): ToolDefinition;
-export declare function getAllTools(): Record<"fontSize" | "underline" | "bold" | "bulletList" | "code" | "italic" | "subscript" | "superscript" | "textDirection" | "fontFamily" | "highlight" | "removeAttachment" | "downloadAttachment" | "deleteColumn" | "deleteRow" | "deleteTable" | "mergeCells" | "strikethrough" | "codeRemove" | "numberedList" | "textColor" | "openLink" | "linkSettings" | "imageSettings" | "rowProperties" | "insertRowBelow" | "insertRowAbove" | "moveRowDown" | "moveRowUp" | "columnProperties" | "insertColumnRight" | "insertColumnLeft" | "moveColumnRight" | "moveColumnLeft" | "cellProperties" | "cellBorderColor" | "splitCells" | "attachmentSettings" | "embedSettings" | "tableSettings" | "math" | "indent" | "outdent" | "clearformatting" | "addLink" | "editLink" | "removeLink" | "insertBlock" | "headings" | "alignment" | "imageAlignCenter" | "imageAlignLeft" | "imageAlignRight" | "imageProperties" | "embedAlignCenter" | "embedAlignLeft" | "embedAlignRight" | "embedProperties" | "cellBackgroundColor" | "cellTextColor" | "cellBorderWidth", ToolDefinition>;
-export declare function getDefaultPresets(): Record<"default" | "minimal", ToolbarDefinition>;
-export declare const STATIC_TOOLBAR_GROUPS: ToolbarDefinition;
diff --git a/packages/editor/dist/es/toolbar/tooldefinitions.js b/packages/editor/dist/es/toolbar/tooldefinitions.js
deleted file mode 100644
index c9db643a4..000000000
--- a/packages/editor/dist/es/toolbar/tooldefinitions.js
+++ /dev/null
@@ -1,337 +0,0 @@
-const tools = {
- bold: {
- icon: "bold",
- title: "Bold",
- },
- italic: {
- icon: "italic",
- title: "Italic",
- },
- underline: {
- icon: "underline",
- title: "Underline",
- },
- strikethrough: {
- icon: "strikethrough",
- title: "Strikethrough",
- },
- addLink: {
- icon: "link",
- title: "Link",
- },
- editLink: {
- icon: "linkEdit",
- title: "Edit link",
- conditional: true,
- },
- removeLink: {
- icon: "linkRemove",
- title: "Remove link",
- conditional: true,
- },
- openLink: {
- icon: "openLink",
- title: "Open link",
- conditional: true,
- },
- linkSettings: {
- icon: "linkSettings",
- title: "Link settings",
- conditional: true,
- },
- code: {
- icon: "code",
- title: "Code",
- },
- codeRemove: {
- icon: "codeRemove",
- title: "Code",
- conditional: true,
- },
- clearformatting: {
- icon: "formatClear",
- title: "Clear all formatting",
- },
- subscript: {
- icon: "subscript",
- title: "Subscript",
- },
- superscript: {
- icon: "superscript",
- title: "Superscript",
- },
- insertBlock: {
- icon: "plus",
- title: "Insert",
- conditional: true,
- },
- bulletList: {
- icon: "bulletList",
- title: "Bullet list",
- },
- numberedList: {
- icon: "numberedList",
- title: "Numbered list",
- },
- fontFamily: {
- icon: "fontFamily",
- title: "Font family",
- },
- fontSize: {
- icon: "fontSize",
- title: "Font size",
- },
- headings: {
- icon: "heading",
- title: "Headings",
- },
- alignment: {
- icon: "alignCenter",
- title: "Alignment",
- },
- textDirection: {
- icon: "ltr",
- title: "Text direction",
- },
- highlight: {
- icon: "highlight",
- title: "Highlight",
- },
- textColor: {
- icon: "textColor",
- title: "Text color",
- },
- math: {
- icon: "math",
- title: "Math (inline)",
- },
- tableSettings: {
- icon: "tableSettings",
- title: "Table settings",
- conditional: true,
- },
- columnProperties: {
- icon: "columnProperties",
- title: "Column properties",
- conditional: true,
- },
- rowProperties: {
- icon: "rowProperties",
- title: "Row properties",
- conditional: true,
- },
- cellProperties: {
- icon: "cellProperties",
- title: "Cell properties",
- conditional: true,
- },
- insertColumnLeft: {
- icon: "insertColumnLeft",
- title: "Insert column left",
- conditional: true,
- },
- insertColumnRight: {
- icon: "insertColumnRight",
- title: "Insert column right",
- conditional: true,
- },
- moveColumnLeft: {
- icon: "moveColumnLeft",
- title: "Move column left",
- conditional: true,
- },
- moveColumnRight: {
- icon: "moveColumnRight",
- title: "Move column right",
- conditional: true,
- },
- deleteColumn: {
- icon: "deleteColumn",
- title: "Delete column",
- conditional: true,
- },
- splitCells: {
- icon: "splitCells",
- title: "Split cells",
- conditional: true,
- },
- mergeCells: {
- icon: "mergeCells",
- title: "Merge cells",
- conditional: true,
- },
- insertRowAbove: {
- icon: "insertRowAbove",
- title: "Insert row above",
- conditional: true,
- },
- insertRowBelow: {
- icon: "insertRowBelow",
- title: "Insert row below",
- conditional: true,
- },
- moveRowUp: {
- icon: "moveRowUp",
- title: "Move row up",
- conditional: true,
- },
- moveRowDown: {
- icon: "moveRowDown",
- title: "Move row down",
- conditional: true,
- },
- deleteRow: {
- icon: "deleteRow",
- title: "Delete row",
- conditional: true,
- },
- deleteTable: {
- icon: "deleteTable",
- title: "Delete table",
- conditional: true,
- },
- cellBackgroundColor: {
- icon: "backgroundColor",
- title: "Cell background color",
- conditional: true,
- },
- cellBorderColor: {
- icon: "cellBorderColor",
- title: "Cell border color",
- conditional: true,
- },
- cellTextColor: {
- icon: "textColor",
- title: "Cell text color",
- conditional: true,
- },
- cellBorderWidth: {
- icon: "none",
- title: "Cell border width",
- conditional: true,
- },
- imageSettings: {
- icon: "imageSettings",
- title: "Image settings",
- conditional: true,
- },
- imageAlignCenter: {
- icon: "alignCenter",
- title: "Align center",
- conditional: true,
- },
- imageAlignLeft: {
- icon: "alignLeft",
- title: "Align left",
- conditional: true,
- },
- imageAlignRight: {
- icon: "alignRight",
- title: "Align right",
- conditional: true,
- },
- imageProperties: {
- icon: "more",
- 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,
- },
- outdent: {
- icon: "outdent",
- title: "Lift list item",
- },
- indent: {
- icon: "indent",
- title: "Sink list item",
- },
-};
-export function getToolDefinition(id) {
- return tools[id];
-}
-export function getAllTools() {
- return tools;
-}
-export function getDefaultPresets() {
- return defaultPresets;
-}
-export const STATIC_TOOLBAR_GROUPS = [
- [
- "insertBlock",
- "tableSettings",
- "imageSettings",
- "embedSettings",
- "attachmentSettings",
- "linkSettings",
- "codeRemove",
- "outdent",
- "indent",
- ],
-];
-const defaultPresets = {
- default: [
- [
- "bold",
- "italic",
- "underline",
- [
- "strikethrough",
- "code",
- "subscript",
- "superscript",
- "highlight",
- "textColor",
- "math",
- ],
- ],
- ["fontSize"],
- ["headings", "fontFamily"],
- ["numberedList", "bulletList"],
- ["addLink"],
- ["alignment", "textDirection"],
- ["clearformatting"],
- ],
- minimal: [
- ["bold", "italic", "underline", "strikethrough", "code"],
- ["headings", "addLink"],
- ["clearformatting"],
- ],
-};
diff --git a/packages/editor/dist/es/toolbar/tools/alignment.d.ts b/packages/editor/dist/es/toolbar/tools/alignment.d.ts
deleted file mode 100644
index 198c68a56..000000000
--- a/packages/editor/dist/es/toolbar/tools/alignment.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function Alignment(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/alignment.js b/packages/editor/dist/es/toolbar/tools/alignment.js
deleted file mode 100644
index fe15a0bf2..000000000
--- a/packages/editor/dist/es/toolbar/tools/alignment.js
+++ /dev/null
@@ -1,43 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-import { useRefValue } from "../../hooks/use-ref-value";
-function AlignmentTool(props) {
- const { editor, alignment } = props, toolProps = __rest(props, ["editor", "alignment"]);
- const alignmentRef = useRefValue(alignment);
- return (_jsx(ToolButton, Object.assign({}, toolProps, { onClick: () => {
- var _a;
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setTextAlign(alignmentRef.current).run();
- }, toggled: false })));
-}
-export function Alignment(props) {
- const { editor } = props;
- const { textAlign } = Object.assign(Object.assign({}, editor.getAttributes("paragraph")), editor.getAttributes("heading"));
- const newAlignment = textAlign === "left"
- ? "center"
- : textAlign === "center"
- ? "right"
- : textAlign === "right"
- ? "justify"
- : textAlign === "justify"
- ? "left"
- : "left";
- const icon = textAlign === "center"
- ? "alignCenter"
- : textAlign === "justify"
- ? "alignJustify"
- : textAlign === "right"
- ? "alignRight"
- : "alignLeft";
- return _jsx(AlignmentTool, Object.assign({ alignment: newAlignment }, props, { icon: icon }));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/attachment.d.ts b/packages/editor/dist/es/toolbar/tools/attachment.d.ts
deleted file mode 100644
index 6fb9c8012..000000000
--- a/packages/editor/dist/es/toolbar/tools/attachment.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/// <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/es/toolbar/tools/attachment.js b/packages/editor/dist/es/toolbar/tools/attachment.js
deleted file mode 100644
index 55ffc07d1..000000000
--- a/packages/editor/dist/es/toolbar/tools/attachment.js
+++ /dev/null
@@ -1,25 +0,0 @@
-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) {
- const { editor } = props;
- const isBottom = useToolbarLocation() === "bottom";
- if (!editor.isActive("attachment") || !isBottom)
- return null;
- return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "attachmentSettings", tools: ["downloadAttachment", "removeAttachment"] })));
-}
-export function DownloadAttachment(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- const attachmentNode = findSelectedNode(editor, "attachment");
- const attachment = ((attachmentNode === null || attachmentNode === void 0 ? void 0 : attachmentNode.attrs) || {});
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().downloadAttachment(attachment).run();
- } })));
-}
-export function RemoveAttachment(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().removeAttachment().run(); } })));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/block.d.ts b/packages/editor/dist/es/toolbar/tools/block.d.ts
deleted file mode 100644
index 9ab2e4d50..000000000
--- a/packages/editor/dist/es/toolbar/tools/block.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function InsertBlock(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/block.js b/packages/editor/dist/es/toolbar/tools/block.js
deleted file mode 100644
index 65fa48cd3..000000000
--- a/packages/editor/dist/es/toolbar/tools/block.js
+++ /dev/null
@@ -1,237 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { Icons } from "../icons";
-import { useMemo, useRef, useState } from "react";
-import { Icon } from "../components/icon";
-import { EmbedPopup } from "../popups/embed-popup";
-import { TablePopup } from "../popups/table-popup";
-import { useIsMobile, useToolbarLocation } from "../stores/toolbar-store";
-import { ResponsivePresenter } from "../../components/responsive";
-import { showPopup } from "../../components/popup-presenter";
-import { ImageUploadPopup } from "../popups/image-upload";
-import { Button } from "../../components/button";
-export function InsertBlock(props) {
- const { editor } = props;
- const buttonRef = useRef(null);
- const [isOpen, setIsOpen] = useState(false);
- const toolbarLocation = useToolbarLocation();
- const isMobile = useIsMobile();
- const menuItems = useMemo(() => {
- return [
- tasklist(editor),
- outlinelist(editor),
- horizontalRule(editor),
- codeblock(editor),
- mathblock(editor),
- blockquote(editor),
- image(editor, isMobile),
- attachment(editor),
- isMobile ? embedMobile(editor) : embedDesktop(editor),
- table(editor),
- ];
- }, [isMobile]);
- return (_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ ref: buttonRef, sx: {
- p: 1,
- m: 0,
- bg: isOpen ? "hover" : "transparent",
- mr: 1,
- display: "flex",
- alignItems: "center",
- ":hover": { bg: "hover" },
- ":last-of-type": {
- mr: 0,
- },
- }, onMouseDown: (e) => e.preventDefault(), onClick: () => setIsOpen((s) => !s) }, { children: _jsx(Icon, { path: Icons.plus, size: 18, color: "primary" }) })), _jsx(ResponsivePresenter, { desktop: "menu", mobile: "sheet", title: "Choose a block to insert", isOpen: isOpen, items: menuItems, onClose: () => setIsOpen(false), position: {
- target: buttonRef.current || undefined,
- isTargetAbsolute: true,
- location: toolbarLocation === "bottom" ? "top" : "below",
- yOffset: 5,
- } })] }));
-}
-const horizontalRule = (editor) => ({
- key: "hr",
- type: "button",
- title: "Horizontal rule",
- icon: "horizontalRule",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("horizontalRule"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setHorizontalRule().run(); },
-});
-const codeblock = (editor) => ({
- key: "codeblock",
- type: "button",
- title: "Code block",
- icon: "codeblock",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleCodeBlock().run(); },
-});
-const blockquote = (editor) => ({
- key: "blockquote",
- type: "button",
- title: "Quote",
- icon: "blockquote",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("blockQuote"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleBlockquote().run(); },
-});
-const mathblock = (editor) => ({
- key: "math",
- type: "button",
- title: "Math & formulas",
- icon: "mathBlock",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("mathBlock"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().insertMathBlock().run(); },
-});
-const image = (editor, isMobile) => ({
- key: "image",
- type: "button",
- title: "Image",
- icon: "image",
- menu: {
- title: "Insert an image",
- items: [
- {
- key: "upload-from-disk",
- type: "button",
- title: "Upload from disk",
- icon: "upload",
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().openAttachmentPicker("image").run(); },
- },
- {
- key: "camera",
- type: "button",
- title: "Take a photo using camera",
- icon: "camera",
- isHidden: !isMobile,
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().openAttachmentPicker("camera").run(); },
- },
- isMobile ? uploadImageFromURLMobile(editor) : uploadImageFromURL(editor),
- ],
- },
-});
-const table = (editor) => ({
- key: "table",
- type: "button",
- title: "Table",
- icon: "table",
- menu: {
- title: "Insert a table",
- items: [
- {
- key: "table-size-selector",
- type: "popup",
- component: (props) => (_jsx(TablePopup, { onInsertTable: (size) => {
- var _a, _b;
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().insertTable({
- rows: size.rows,
- cols: size.columns,
- }).run();
- (_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props);
- } })),
- },
- ],
- },
-});
-const embedMobile = (editor) => ({
- key: "embed",
- type: "button",
- title: "Embed",
- icon: "embed",
- menu: {
- title: "Insert an embed",
- items: [
- {
- key: "embed-popup",
- type: "popup",
- component: function ({ onClick }) {
- return (_jsx(EmbedPopup, { title: "Insert embed", onClose: (embed) => {
- var _a;
- if (!embed)
- return onClick === null || onClick === void 0 ? void 0 : onClick();
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().insertEmbed(embed).run();
- onClick === null || onClick === void 0 ? void 0 : onClick();
- } }));
- },
- },
- ],
- },
-});
-const embedDesktop = (editor) => ({
- key: "embed",
- type: "button",
- title: "Embed",
- icon: "embed",
- onClick: () => {
- if (!editor)
- return;
- showPopup({
- popup: (hide) => (_jsx(EmbedPopup, { title: "Insert embed", onClose: (embed) => {
- var _a;
- if (!embed)
- return hide();
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().insertEmbed(embed).run();
- hide();
- } })),
- });
- },
-});
-const attachment = (editor) => ({
- key: "attachment",
- type: "button",
- title: "Attachment",
- icon: "attachment",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("attachment"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().openAttachmentPicker("file").run(); },
-});
-const tasklist = (editor) => ({
- key: "tasklist",
- type: "button",
- title: "Task list",
- icon: "checkbox",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("taskList"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleTaskList().run(); },
-});
-const outlinelist = (editor) => ({
- key: "outlinelist",
- type: "button",
- title: "Outline list",
- icon: "outlineList",
- isChecked: editor === null || editor === void 0 ? void 0 : editor.isActive("outlineList"),
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleOutlineList().run(); },
-});
-const uploadImageFromURLMobile = (editor) => ({
- key: "upload-from-url",
- type: "button",
- title: "Attach from URL",
- icon: "link",
- menu: {
- title: "Attach image from URL",
- items: [
- {
- key: "attach-image",
- type: "popup",
- component: ({ onClick }) => (_jsx(ImageUploadPopup, { onInsert: (image) => {
- var _a;
- (_a = editor
- .requestPermission("insertImage")) === null || _a === void 0 ? void 0 : _a.chain().focus().insertImage(image).run();
- onClick === null || onClick === void 0 ? void 0 : onClick();
- }, onClose: () => {
- onClick === null || onClick === void 0 ? void 0 : onClick();
- } })),
- },
- ],
- },
-});
-const uploadImageFromURL = (editor) => ({
- key: "upload-from-url",
- type: "button",
- title: "Attach from URL",
- icon: "link",
- onClick: () => {
- showPopup({
- popup: (hide) => (_jsx(ImageUploadPopup, { onInsert: (image) => {
- var _a;
- (_a = editor
- .requestPermission("insertImage")) === null || _a === void 0 ? void 0 : _a.chain().focus().insertImage(image).run();
- hide();
- }, onClose: hide })),
- });
- },
-});
diff --git a/packages/editor/dist/es/toolbar/tools/colors.d.ts b/packages/editor/dist/es/toolbar/tools/colors.d.ts
deleted file mode 100644
index 68c8fa59f..000000000
--- a/packages/editor/dist/es/toolbar/tools/colors.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-declare type ColorToolProps = ToolProps & {
- onColorChange: (color?: string) => void;
- getActiveColor: () => string;
- title: string;
- cacheKey: string;
-};
-export declare function ColorTool(props: ColorToolProps): JSX.Element;
-export declare function Highlight(props: ToolProps): JSX.Element;
-export declare function TextColor(props: ToolProps): JSX.Element;
-export {};
diff --git a/packages/editor/dist/es/toolbar/tools/colors.js b/packages/editor/dist/es/toolbar/tools/colors.js
deleted file mode 100644
index b07ab8074..000000000
--- a/packages/editor/dist/es/toolbar/tools/colors.js
+++ /dev/null
@@ -1,64 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { useState } from "react";
-import tinycolor from "tinycolor2";
-import { PopupWrapper } from "../../components/popup-presenter";
-import { config } from "../../utils/config";
-import { SplitButton } from "../components/split-button";
-import { ColorPicker } from "../popups/color-picker";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { getToolbarElement } from "../utils/dom";
-export function ColorTool(props) {
- const { editor, onColorChange, getActiveColor, title, cacheKey } = props, toolProps = __rest(props, ["editor", "onColorChange", "getActiveColor", "title", "cacheKey"]);
- const activeColor = getActiveColor() || config.get(cacheKey);
- const tColor = tinycolor(activeColor);
- const isBottom = useToolbarLocation() === "bottom";
- const [isOpen, setIsOpen] = useState(false);
- return (_jsx(SplitButton, Object.assign({}, toolProps, { iconColor: activeColor && tColor.isDark() ? "static" : "icon", sx: {
- mr: 0,
- bg: activeColor || "transparent",
- ":hover": {
- bg: activeColor ? tColor.darken(5).toRgbString() : "transparent",
- },
- }, onOpen: () => setIsOpen((s) => !s), toggled: isOpen, onClick: () => onColorChange(activeColor) }, { children: _jsx(PopupWrapper, { isOpen: isOpen, id: props.icon, group: "color", position: {
- isTargetAbsolute: true,
- target: getToolbarElement(),
- align: isBottom ? "center" : "end",
- location: isBottom ? "top" : "below",
- yOffset: 10,
- }, focusOnRender: false, blocking: false, renderPopup: (close) => (_jsx(ColorPicker, { color: activeColor, onClear: () => {
- onColorChange();
- config.set(cacheKey, null);
- }, onChange: (color) => {
- onColorChange(color);
- config.set(cacheKey, color);
- }, onClose: close, title: title })) }) })));
-}
-export function Highlight(props) {
- const { editor } = props;
- return (_jsx(ColorTool, Object.assign({}, props, { cacheKey: "highlight", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("highlight").color; }, title: "Background color", onColorChange: (color) => {
- var _a, _b;
- return color
- ? (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleHighlight({ color }).run()
- : (_b = editor.current) === null || _b === void 0 ? void 0 : _b.chain().focus().unsetHighlight().run();
- } })));
-}
-export function TextColor(props) {
- const { editor } = props;
- return (_jsx(ColorTool, Object.assign({}, props, { cacheKey: "textColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("textStyle").color; }, title: "Text color", onColorChange: (color) => {
- var _a, _b;
- return color
- ? (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setColor(color).run()
- : (_b = editor.current) === null || _b === void 0 ? void 0 : _b.chain().focus().unsetColor().run();
- } })));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/embed.d.ts b/packages/editor/dist/es/toolbar/tools/embed.d.ts
deleted file mode 100644
index 3c143f3c1..000000000
--- a/packages/editor/dist/es/toolbar/tools/embed.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <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/es/toolbar/tools/embed.js b/packages/editor/dist/es/toolbar/tools/embed.js
deleted file mode 100644
index d6c238955..000000000
--- a/packages/editor/dist/es/toolbar/tools/embed.js
+++ /dev/null
@@ -1,60 +0,0 @@
-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 { 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) {
- const { editor } = props;
- const isBottom = useToolbarLocation() === "bottom";
- if (!editor.isActive("embed") || !isBottom)
- return null;
- return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "embedSettings", tools: [] })));
-}
-export function EmbedAlignLeft(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setEmbedAlignment({ align: "left" }).run();
- } })));
-}
-export function EmbedAlignRight(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setEmbedAlignment({ align: "right" }).run();
- } })));
-}
-export function EmbedAlignCenter(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setEmbedAlignment({ align: "center" }).run();
- } })));
-}
-// TODO: stop re-rendering
-export function EmbedProperties(props) {
- const { editor } = props;
- const [isOpen, setIsOpen] = useState(false);
- const buttonRef = useRef();
- // TODO: improve perf by deferring this until user opens the popup
- const embedNode = useMemo(() => findSelectedNode(editor, "embed"), []);
- const embed = ((embedNode === null || embedNode === void 0 ? void 0 : embedNode.attrs) || {});
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: () => setIsOpen((s) => !s) })), _jsx(ResponsivePresenter, Object.assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: () => setIsOpen(false), blocking: true, focusOnRender: false, position: {
- target: buttonRef.current || "mouse",
- align: "start",
- location: "below",
- yOffset: 10,
- isTargetAbsolute: true,
- } }, { children: _jsx(EmbedPopup, { title: "Embed properties", onClose: (newEmbed) => {
- var _a, _b;
- if (!newEmbed) {
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSize(embed);
- }
- else if (newEmbed.src !== embed.src)
- (_b = editor.current) === null || _b === void 0 ? void 0 : _b.commands.setEmbedSource(newEmbed.src);
- setIsOpen(false);
- }, embed: embed, onSizeChanged: (size) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSize(size); } }) }))] }));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/font.d.ts b/packages/editor/dist/es/toolbar/tools/font.d.ts
deleted file mode 100644
index e7818addd..000000000
--- a/packages/editor/dist/es/toolbar/tools/font.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function FontSize(props: ToolProps): JSX.Element;
-export declare function FontFamily(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/font.js b/packages/editor/dist/es/toolbar/tools/font.js
deleted file mode 100644
index 3ba3fa872..000000000
--- a/packages/editor/dist/es/toolbar/tools/font.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { Dropdown } from "../components/dropdown";
-import { useCallback, useMemo } from "react";
-import { Counter } from "../components/counter";
-import { useRefValue } from "../../hooks/use-ref-value";
-export function FontSize(props) {
- const { editor } = props;
- const { fontSize: _fontSize } = editor.getAttributes("textStyle");
- const fontSize = _fontSize || "16px";
- const fontSizeAsNumber = useRefValue(parseInt(fontSize.replace("px", "")));
- const decreaseFontSize = useCallback(() => {
- return Math.max(8, fontSizeAsNumber.current - 1);
- }, []);
- const increaseFontSize = useCallback(() => {
- return Math.min(120, fontSizeAsNumber.current + 1);
- }, []);
- return (_jsx(Counter, { title: "font size", onDecrease: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontSize(`${decreaseFontSize()}px`).run();
- }, onIncrease: () => {
- var _a;
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontSize(`${increaseFontSize()}px`).run();
- }, onReset: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontSize(`16px`).run(); }, value: fontSize }));
-}
-const fontFamilies = {
- "Sans-serif": "Open Sans",
- Serif: "serif",
- Monospace: "monospace",
-};
-export function FontFamily(props) {
- var _a, _b;
- const { editor } = props;
- const currentFontFamily = ((_b = (_a = Object.entries(fontFamilies)
- .find(([key, value]) => editor.isActive("textStyle", { fontFamily: value }))) === null || _a === void 0 ? void 0 : _a.map((a) => a)) === null || _b === void 0 ? void 0 : _b.at(0)) || "Sans-serif";
- const items = useMemo(() => toMenuItems(editor, currentFontFamily), [currentFontFamily]);
- return (_jsx(Dropdown, { id: "fontFamily", group: "font", selectedItem: currentFontFamily, items: items, menuWidth: 130 }));
-}
-function toMenuItems(editor, currentFontFamily) {
- const menuItems = [];
- for (const key in fontFamilies) {
- const value = fontFamilies[key];
- menuItems.push({
- key,
- type: "button",
- title: key,
- isChecked: key === currentFontFamily,
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setFontFamily(value).run(); },
- styles: {
- fontFamily: value,
- },
- });
- }
- return menuItems;
-}
diff --git a/packages/editor/dist/es/toolbar/tools/headings.d.ts b/packages/editor/dist/es/toolbar/tools/headings.d.ts
deleted file mode 100644
index e237b7e5f..000000000
--- a/packages/editor/dist/es/toolbar/tools/headings.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function Headings(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/headings.js b/packages/editor/dist/es/toolbar/tools/headings.js
deleted file mode 100644
index 24048a264..000000000
--- a/packages/editor/dist/es/toolbar/tools/headings.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { Dropdown } from "../components/dropdown";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { useMemo } from "react";
-const defaultLevels = [1, 2, 3, 4, 5, 6];
-export function Headings(props) {
- const { editor } = props;
- const toolbarLocation = useToolbarLocation();
- const currentHeadingLevel = defaultLevels.find((level) => editor.isActive("heading", { level }));
- const items = useMemo(() => toMenuItems(editor, toolbarLocation, currentHeadingLevel), [currentHeadingLevel]);
- return (_jsx(Dropdown, { id: "headings", group: "headings", selectedItem: currentHeadingLevel ? `Heading ${currentHeadingLevel}` : "Paragraph", items: items, menuWidth: 130 }));
-}
-function toMenuItems(editor, toolbarLocation, currentHeadingLevel) {
- const menuItems = defaultLevels.map((level) => ({
- type: "button",
- key: `heading-${level}`,
- title: toolbarLocation === "bottom" ? `H${level}` : `Heading ${level}`,
- isChecked: level === currentHeadingLevel,
- onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().updateAttributes("textStyle", { fontSize: null, fontStyle: null }).setHeading({ level: level }).run();
- },
- }));
- const paragraph = {
- key: "paragraph",
- type: "button",
- title: "Paragraph",
- isChecked: !currentHeadingLevel,
- onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setParagraph().run(); },
- };
- return [paragraph, ...menuItems];
-}
diff --git a/packages/editor/dist/es/toolbar/tools/image.d.ts b/packages/editor/dist/es/toolbar/tools/image.d.ts
deleted file mode 100644
index d192850d6..000000000
--- a/packages/editor/dist/es/toolbar/tools/image.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function ImageSettings(props: ToolProps): JSX.Element | null;
-export declare function ImageAlignLeft(props: ToolProps): JSX.Element;
-export declare function ImageAlignRight(props: ToolProps): JSX.Element;
-export declare function ImageAlignCenter(props: ToolProps): JSX.Element;
-export declare function ImageProperties(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/image.js b/packages/editor/dist/es/toolbar/tools/image.js
deleted file mode 100644
index 3a46f836b..000000000
--- a/packages/editor/dist/es/toolbar/tools/image.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-import { useRef, useState } from "react";
-import { ResponsivePresenter } from "../../components/responsive";
-import { MoreTools } from "../components/more-tools";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { ImageProperties as ImagePropertiesPopup } from "../popups/image-properties";
-import { findSelectedNode } from "../utils/prosemirror";
-export function ImageSettings(props) {
- var _a, _b;
- const { editor } = props;
- const isBottom = useToolbarLocation() === "bottom";
- if (!editor.isActive("image") || !isBottom)
- return null;
- return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "imageSettings", tools: ((_b = (_a = findSelectedNode(editor, "image")) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.float)
- ? ["imageAlignLeft", "imageAlignRight", "imageProperties"]
- : [
- "imageAlignLeft",
- "imageAlignCenter",
- "imageAlignRight",
- "imageProperties",
- ] })));
-}
-export function ImageAlignLeft(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setImageAlignment({ align: "left" }).run();
- } })));
-}
-export function ImageAlignRight(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setImageAlignment({ align: "right" }).run();
- } })));
-}
-export function ImageAlignCenter(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setImageAlignment({ align: "center" }).run();
- } })));
-}
-export function ImageProperties(props) {
- const { editor } = props;
- const [isOpen, setIsOpen] = useState(false);
- const buttonRef = useRef();
- // TODO: defer until user opens the popup
- const image = findSelectedNode(editor, "image");
- const { float, align, width, height } = ((image === null || image === void 0 ? void 0 : image.attrs) ||
- {});
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({ buttonRef: buttonRef, toggled: isOpen }, props, { onClick: () => setIsOpen((s) => !s) })), _jsx(ResponsivePresenter, Object.assign({ isOpen: isOpen, desktop: "menu", mobile: "sheet", onClose: () => setIsOpen(false), blocking: true, focusOnRender: false, position: {
- target: buttonRef.current || "mouse",
- align: "start",
- location: "below",
- yOffset: 10,
- isTargetAbsolute: true,
- } }, { children: _jsx(ImagePropertiesPopup, { editor: editor, height: height, width: width, align: align, float: float, onClose: () => setIsOpen(false) }) }))] }));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/index.d.ts b/packages/editor/dist/es/toolbar/tools/index.d.ts
deleted file mode 100644
index 959c01b7c..000000000
--- a/packages/editor/dist/es/toolbar/tools/index.d.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import React from "react";
-import { ToolProps } from "../types";
-import { Bold, Italic, Underline, Strikethrough, Code, Subscript, Superscript, ClearFormatting, CodeRemove, Math } from "./inline";
-import { InsertBlock } from "./block";
-import { FontSize, FontFamily } from "./font";
-import { Alignment } from "./alignment";
-import { Headings } from "./headings";
-import { NumberedList, BulletList, Outdent, Indent } from "./lists";
-import { TextDirection } 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";
-import { AddLink, EditLink, RemoveLink, LinkSettings, OpenLink } from "./link";
-export declare type ToolId = keyof typeof tools;
-declare const tools: {
- bold: typeof Bold;
- italic: typeof Italic;
- underline: typeof Underline;
- strikethrough: typeof Strikethrough;
- code: typeof Code;
- codeRemove: typeof CodeRemove;
- subscript: typeof Subscript;
- superscript: typeof Superscript;
- clearformatting: typeof ClearFormatting;
- addLink: typeof AddLink;
- editLink: typeof EditLink;
- removeLink: typeof RemoveLink;
- linkSettings: typeof LinkSettings;
- openLink: typeof OpenLink;
- insertBlock: typeof InsertBlock;
- numberedList: typeof NumberedList;
- bulletList: typeof BulletList;
- fontSize: typeof FontSize;
- fontFamily: typeof FontFamily;
- headings: typeof Headings;
- alignment: typeof Alignment;
- textDirection: typeof TextDirection;
- textColor: typeof TextColor;
- highlight: typeof Highlight;
- math: typeof Math;
- imageSettings: typeof ImageSettings;
- imageAlignCenter: typeof ImageAlignCenter;
- 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;
- cellProperties: typeof CellProperties;
- insertColumnLeft: (props: ToolProps) => JSX.Element;
- insertColumnRight: (props: ToolProps) => JSX.Element;
- moveColumnLeft: (props: ToolProps) => JSX.Element;
- moveColumnRight: (props: ToolProps) => JSX.Element;
- deleteColumn: (props: ToolProps) => JSX.Element;
- splitCells: (props: ToolProps) => JSX.Element;
- mergeCells: (props: ToolProps) => JSX.Element;
- cellBackgroundColor: typeof CellBackgroundColor;
- cellBorderColor: typeof CellBorderColor;
- cellTextColor: typeof CellTextColor;
- cellBorderWidth: typeof CellBorderWidth;
- insertRowAbove: (props: ToolProps) => JSX.Element;
- insertRowBelow: (props: ToolProps) => JSX.Element;
- moveRowUp: (props: ToolProps) => JSX.Element;
- moveRowDown: (props: ToolProps) => JSX.Element;
- deleteRow: (props: ToolProps) => JSX.Element;
- deleteTable: (props: ToolProps) => JSX.Element;
- outdent: typeof Outdent;
- indent: typeof Indent;
-};
-export declare function findTool(id: ToolId): React.FunctionComponent<ToolProps>;
-export {};
diff --git a/packages/editor/dist/es/toolbar/tools/index.js b/packages/editor/dist/es/toolbar/tools/index.js
deleted file mode 100644
index ecfa21689..000000000
--- a/packages/editor/dist/es/toolbar/tools/index.js
+++ /dev/null
@@ -1,79 +0,0 @@
-import { Bold, Italic, Underline, Strikethrough, Code, Subscript, Superscript, ClearFormatting, CodeRemove, Math, } from "./inline";
-import { InsertBlock } from "./block";
-import { FontSize, FontFamily } from "./font";
-import { Alignment } from "./alignment";
-import { Headings } from "./headings";
-import { NumberedList, BulletList, Outdent, Indent } from "./lists";
-import { TextDirection } 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";
-import { AddLink, EditLink, RemoveLink, LinkSettings, OpenLink } from "./link";
-const tools = {
- bold: Bold,
- italic: Italic,
- underline: Underline,
- strikethrough: Strikethrough,
- code: Code,
- codeRemove: CodeRemove,
- subscript: Subscript,
- superscript: Superscript,
- clearformatting: ClearFormatting,
- addLink: AddLink,
- editLink: EditLink,
- removeLink: RemoveLink,
- linkSettings: LinkSettings,
- openLink: OpenLink,
- insertBlock: InsertBlock,
- numberedList: NumberedList,
- bulletList: BulletList,
- fontSize: FontSize,
- fontFamily: FontFamily,
- headings: Headings,
- alignment: Alignment,
- textDirection: TextDirection,
- textColor: TextColor,
- highlight: Highlight,
- math: Math,
- imageSettings: ImageSettings,
- imageAlignCenter: ImageAlignCenter,
- 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,
- cellProperties: CellProperties,
- insertColumnLeft: InsertColumnLeft,
- insertColumnRight: InsertColumnRight,
- moveColumnLeft: MoveColumnLeft,
- moveColumnRight: MoveColumnRight,
- deleteColumn: DeleteColumn,
- splitCells: SplitCells,
- mergeCells: MergeCells,
- cellBackgroundColor: CellBackgroundColor,
- cellBorderColor: CellBorderColor,
- cellTextColor: CellTextColor,
- cellBorderWidth: CellBorderWidth,
- insertRowAbove: InsertRowAbove,
- insertRowBelow: InsertRowBelow,
- moveRowUp: MoveRowUp,
- moveRowDown: MoveRowDown,
- deleteRow: DeleteRow,
- deleteTable: DeleteTable,
- outdent: Outdent,
- indent: Indent,
-};
-export function findTool(id) {
- return tools[id];
-}
diff --git a/packages/editor/dist/es/toolbar/tools/inline.d.ts b/packages/editor/dist/es/toolbar/tools/inline.d.ts
deleted file mode 100644
index f8a5deb2c..000000000
--- a/packages/editor/dist/es/toolbar/tools/inline.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function Italic(props: ToolProps): JSX.Element;
-export declare function Strikethrough(props: ToolProps): JSX.Element;
-export declare function Underline(props: ToolProps): JSX.Element;
-export declare function Code(props: ToolProps): JSX.Element;
-export declare function Bold(props: ToolProps): JSX.Element;
-export declare function Subscript(props: ToolProps): JSX.Element;
-export declare function Superscript(props: ToolProps): JSX.Element;
-export declare function ClearFormatting(props: ToolProps): JSX.Element;
-export declare function CodeRemove(props: ToolProps): JSX.Element | null;
-export declare function Math(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/inline.js b/packages/editor/dist/es/toolbar/tools/inline.js
deleted file mode 100644
index e0c8958f5..000000000
--- a/packages/editor/dist/es/toolbar/tools/inline.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-import { useToolbarLocation } from "../stores/toolbar-store";
-export function Italic(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("italic"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleItalic().run(); } })));
-}
-export function Strikethrough(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("strike"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleStrike().run(); } })));
-}
-export function Underline(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("underline"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleUnderline().run(); } })));
-}
-export function Code(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("code"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleCode().run(); } })));
-}
-export function Bold(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("bold"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleBold().run(); } })));
-}
-export function Subscript(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("subscript"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleSubscript().run(); } })));
-}
-export function Superscript(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: editor.isActive("superscript"), onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleSuperscript().run(); } })));
-}
-export function ClearFormatting(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().clearNodes().unsetAllMarks().unsetMark("link").run();
- } })));
-}
-export function CodeRemove(props) {
- const { editor } = props;
- const isBottom = useToolbarLocation() === "bottom";
- if (!editor.isActive("code") || !isBottom)
- return null;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().unsetMark("code").run(); } })));
-}
-export function Math(props) {
- const { editor } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().insertMathInline().run(); } })));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/link.d.ts b/packages/editor/dist/es/toolbar/tools/link.d.ts
deleted file mode 100644
index 58223feb4..000000000
--- a/packages/editor/dist/es/toolbar/tools/link.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function LinkSettings(props: ToolProps): JSX.Element | null;
-export declare function AddLink(props: ToolProps): JSX.Element;
-export declare function EditLink(props: ToolProps): JSX.Element;
-export declare function RemoveLink(props: ToolProps): JSX.Element;
-export declare function OpenLink(props: ToolProps): JSX.Element | null;
diff --git a/packages/editor/dist/es/toolbar/tools/link.js b/packages/editor/dist/es/toolbar/tools/link.js
deleted file mode 100644
index 5d0594700..000000000
--- a/packages/editor/dist/es/toolbar/tools/link.js
+++ /dev/null
@@ -1,141 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-import { useCallback, useRef, useState } from "react";
-import { ResponsivePresenter } from "../../components/responsive";
-import { LinkPopup } from "../popups/link-popup";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { MoreTools } from "../components/more-tools";
-import { useRefValue } from "../../hooks/use-ref-value";
-import { findMark, selectionToOffset } from "../utils/prosemirror";
-import { setTextSelection } from "prosemirror-utils";
-import { Flex, Text } from "rebass";
-export function LinkSettings(props) {
- const { editor } = props;
- const isBottom = useToolbarLocation() === "bottom";
- if (!editor.isActive("link") || !isBottom)
- return null;
- return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "linkSettings", tools: ["openLink", "editLink", "removeLink"] })));
-}
-export function AddLink(props) {
- const { editor } = props;
- const isActive = props.editor.isActive("link");
- const onDone = useCallback((href, text) => {
- var _a, _b;
- if (!href)
- return;
- let commandChain = (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus();
- if (!commandChain)
- return;
- const isSelection = !((_b = editor.current) === null || _b === void 0 ? void 0 : _b.state.selection.empty);
- commandChain
- .extendMarkRange("link")
- .toggleLink({ href, target: "_blank" })
- .insertContent(text || href)
- .focus();
- if (!isSelection)
- commandChain = commandChain.unsetMark("link").insertContent(" ");
- commandChain.run();
- }, []);
- if (isActive)
- return _jsx(EditLink, Object.assign({}, props));
- return (_jsx(LinkTool, Object.assign({}, props, { onDone: onDone, onClick: () => {
- if (!editor.current)
- return;
- const { state } = editor.current;
- let { from, to } = state.selection;
- const selectedText = state.doc.textBetween(from, to);
- return { text: selectedText };
- } })));
-}
-export function EditLink(props) {
- const { editor, selectedNode: _selectedNode } = props;
- const selectedNode = useRefValue(_selectedNode || selectionToOffset(editor.state));
- const onDone = useCallback((href, text) => {
- const { from, node, to } = selectedNode.current;
- if (!href || !editor.current || !node)
- return;
- const mark = findMark(node, "link");
- if (!mark)
- return;
- editor.current
- .chain()
- .command(({ tr }) => {
- tr.removeMark(from, to, mark.type);
- tr.addMark(from, to, mark.type.create({ href }));
- tr.insertText(text || node.textContent, from, to);
- setTextSelection(tr.mapping.map(from))(tr);
- return true;
- })
- .focus(undefined, { scrollIntoView: true })
- .run();
- }, []);
- return (_jsx(LinkTool, Object.assign({}, props, { isEditing: true, onDone: onDone, onClick: () => {
- const { node } = selectedNode.current;
- if (!node)
- return;
- const selectedText = node.textContent;
- const mark = findMark(node, "link");
- if (!mark)
- return;
- return { text: selectedText, href: mark.attrs.href };
- } })));
-}
-export function RemoveLink(props) {
- const { editor, selectedNode } = props;
- return (_jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => {
- var _a, _b;
- if (selectedNode)
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setTextSelection(selectedNode.from);
- (_b = editor.current) === null || _b === void 0 ? void 0 : _b.chain().focus().unsetLink().run();
- } })));
-}
-export function OpenLink(props) {
- const { editor, selectedNode: _selectedNode } = props;
- const selectedNode = useRefValue(_selectedNode || selectionToOffset(editor.state));
- const { node } = selectedNode.current;
- const link = node ? findMark(node, "link") : null;
- if (!link)
- return null;
- const href = link === null || link === void 0 ? void 0 : link.attrs.href;
- return (_jsxs(Flex, Object.assign({ sx: { alignItems: "center" } }, { children: [_jsx(Text, Object.assign({ as: "a", href: href, target: "_blank", variant: "body", sx: { mr: 1 } }, { children: href })), _jsx(ToolButton, Object.assign({}, props, { toggled: false, onClick: () => window.open(href, "_blank") }))] })));
-}
-function LinkTool(props) {
- const { isEditing, onClick, onDone, editor } = props, toolProps = __rest(props, ["isEditing", "onClick", "onDone", "editor"]);
- const buttonRef = useRef(null);
- const [isOpen, setIsOpen] = useState(false);
- const [href, setHref] = useState();
- const [text, setText] = useState();
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({}, toolProps, { buttonRef: buttonRef, onClick: () => {
- const result = onClick();
- if (!result)
- return;
- const { text, href } = result;
- setHref(href);
- setText(text);
- setIsOpen(true);
- }, toggled: isOpen })), _jsx(ResponsivePresenter, Object.assign({ mobile: "sheet", desktop: "menu", position: {
- target: buttonRef.current || undefined,
- isTargetAbsolute: true,
- location: "below",
- align: "center",
- yOffset: 5,
- }, title: isEditing ? "Edit link" : "Insert link", isOpen: isOpen, items: [], onClose: () => {
- var _a;
- setIsOpen(false);
- (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.focus();
- }, focusOnRender: false }, { children: _jsx(LinkPopup, { href: href, text: text, isEditing: isEditing, onClose: () => setIsOpen(false), onDone: ({ href, text }) => {
- onDone(href, text);
- setIsOpen(false);
- } }) }))] }));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/lists.d.ts b/packages/editor/dist/es/toolbar/tools/lists.d.ts
deleted file mode 100644
index 551f6e925..000000000
--- a/packages/editor/dist/es/toolbar/tools/lists.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function NumberedList(props: ToolProps): JSX.Element;
-export declare function BulletList(props: ToolProps): JSX.Element;
-export declare function Indent(props: ToolProps): JSX.Element | null;
-export declare function Outdent(props: ToolProps): JSX.Element | null;
diff --git a/packages/editor/dist/es/toolbar/tools/lists.js b/packages/editor/dist/es/toolbar/tools/lists.js
deleted file mode 100644
index 85f0bd7ae..000000000
--- a/packages/editor/dist/es/toolbar/tools/lists.js
+++ /dev/null
@@ -1,124 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { Box, Button, Flex } from "rebass";
-import { useCallback, useRef, useState } from "react";
-import { SplitButton } from "../components/split-button";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { getToolbarElement } from "../utils/dom";
-import { PopupWrapper } from "../../components/popup-presenter";
-import React from "react";
-import { ToolButton } from "../components/tool-button";
-import { findListItemType, isListActive } from "../utils/prosemirror";
-function _ListTool(props) {
- const { editor, onClick, isActive, subTypes, type } = props, toolProps = __rest(props, ["editor", "onClick", "isActive", "subTypes", "type"]);
- const toolbarLocation = useToolbarLocation();
- const isBottom = toolbarLocation === "bottom";
- const [isOpen, setIsOpen] = useState(false);
- const buttonRef = useRef();
- return (_jsx(SplitButton, Object.assign({}, toolProps, { buttonRef: buttonRef, onClick: onClick, toggled: isOpen, sx: { mr: 0 }, onOpen: () => setIsOpen((s) => !s) }, { children: _jsx(PopupWrapper, { isOpen: isOpen, group: "lists", id: toolProps.title, blocking: false, focusOnRender: false, position: {
- isTargetAbsolute: true,
- target: isBottom ? getToolbarElement() : buttonRef.current || "mouse",
- align: "center",
- location: isBottom ? "top" : "below",
- yOffset: 10,
- }, onClosed: () => setIsOpen(false), renderPopup: () => (_jsx(Box, Object.assign({ sx: {
- bg: "background",
- display: "grid",
- gridTemplateColumns: "1fr 1fr 1fr",
- p: 1,
- } }, { children: subTypes.map((item) => (_jsx(Button, Object.assign({ variant: "menuitem", sx: { width: 80 }, onClick: () => {
- var _a;
- let chain = (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus();
- if (!chain || !editor.current)
- return;
- if (!isListActive(editor.current)) {
- if (type === "bulletList")
- chain = chain.toggleBulletList();
- else
- chain = chain.toggleOrderedList();
- }
- return chain
- .updateAttributes(type, { listType: item.type })
- .run();
- } }, { children: _jsx(ListThumbnail, { listStyleType: item.type }) }), item.title))) }))) }) })));
-}
-const ListTool = React.memo(_ListTool, (prev, next) => {
- return prev.isActive === next.isActive;
-});
-export function NumberedList(props) {
- const { editor } = props;
- const onClick = useCallback(() => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleOrderedList().run(); }, []);
- return (_jsx(ListTool, Object.assign({}, props, { type: "orderedList", isActive: editor.isActive("orderedList"), onClick: onClick, subTypes: [
- { type: "decimal", title: "Decimal", items: ["1", "2", "3"] },
- { type: "upper-alpha", title: "Upper alpha", items: ["A", "B", "C"] },
- { type: "lower-alpha", title: "Lower alpha", items: ["a", "b", "c"] },
- {
- type: "upper-roman",
- title: "Upper Roman",
- items: ["I", "II", "III"],
- },
- {
- type: "lower-roman",
- title: "Lower Roman",
- items: ["i", "ii", "iii"],
- },
- { type: "lower-greek", title: "Lower Greek", items: ["α", "β", "γ"] },
- ] })));
-}
-export function BulletList(props) {
- const { editor } = props;
- const onClick = useCallback(() => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().toggleBulletList().run(); }, []);
- return (_jsx(ListTool, Object.assign({}, props, { type: "bulletList", onClick: onClick, isActive: editor.isActive("bulletList"), subTypes: [
- { type: "disc", title: "Decimal", items: ["1", "2", "3"] },
- { type: "circle", title: "Upper alpha", items: ["A", "B", "C"] },
- { type: "square", title: "Lower alpha", items: ["a", "b", "c"] },
- ] })));
-}
-export function Indent(props) {
- const { editor } = props, toolProps = __rest(props, ["editor"]);
- const isBottom = useToolbarLocation() === "bottom";
- const listItemType = findListItemType(editor);
- if (!listItemType || !isBottom)
- return null;
- return (_jsx(ToolButton, Object.assign({}, toolProps, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().sinkListItem(listItemType).run(); } })));
-}
-export function Outdent(props) {
- const { editor } = props, toolProps = __rest(props, ["editor"]);
- const isBottom = useToolbarLocation() === "bottom";
- const listItemType = findListItemType(editor);
- if (!listItemType || !isBottom)
- return null;
- return (_jsx(ToolButton, Object.assign({}, toolProps, { toggled: false, onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().liftListItem(listItemType).run(); } })));
-}
-function ListThumbnail(props) {
- const { listStyleType } = props;
- return (_jsx(Flex, Object.assign({ as: "ul", sx: {
- flexDirection: "column",
- flex: 1,
- p: 0,
- listStyleType,
- }, onMouseDown: (e) => e.preventDefault() }, { children: [0, 1, 2].map((i) => (_jsx(Box, Object.assign({ as: "li", sx: {
- display: "list-item",
- color: "text",
- fontSize: 8,
- mb: "1px",
- } }, { children: _jsx(Flex, Object.assign({ sx: {
- alignItems: "center",
- } }, { children: _jsx(Box, { sx: {
- width: "100%",
- flexShrink: 0,
- height: 4,
- bg: "#cbcbcb",
- borderRadius: "small",
- } }) })) }), i.toString()))) })));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/table.d.ts b/packages/editor/dist/es/toolbar/tools/table.d.ts
deleted file mode 100644
index 8a7280fd5..000000000
--- a/packages/editor/dist/es/toolbar/tools/table.d.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function TableSettings(props: ToolProps): JSX.Element | null;
-export declare function RowProperties(props: ToolProps): JSX.Element;
-export declare function ColumnProperties(props: ToolProps): JSX.Element;
-export declare function TableProperties(props: ToolProps): JSX.Element;
-export declare function CellProperties(props: ToolProps): JSX.Element;
-export declare function CellBackgroundColor(props: ToolProps): JSX.Element;
-export declare function CellTextColor(props: ToolProps): JSX.Element;
-export declare function CellBorderColor(props: ToolProps): JSX.Element;
-export declare function CellBorderWidth(props: ToolProps): JSX.Element;
-export declare const InsertColumnLeft: (props: ToolProps) => JSX.Element;
-export declare const InsertColumnRight: (props: ToolProps) => JSX.Element;
-export declare const MoveColumnLeft: (props: ToolProps) => JSX.Element;
-export declare const MoveColumnRight: (props: ToolProps) => JSX.Element;
-export declare const DeleteColumn: (props: ToolProps) => JSX.Element;
-export declare const SplitCells: (props: ToolProps) => JSX.Element;
-export declare const MergeCells: (props: ToolProps) => JSX.Element;
-export declare const InsertRowAbove: (props: ToolProps) => JSX.Element;
-export declare const InsertRowBelow: (props: ToolProps) => JSX.Element;
-export declare const MoveRowUp: (props: ToolProps) => JSX.Element;
-export declare const MoveRowDown: (props: ToolProps) => JSX.Element;
-export declare const DeleteRow: (props: ToolProps) => JSX.Element;
-export declare const DeleteTable: (props: ToolProps) => JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/table.js b/packages/editor/dist/es/toolbar/tools/table.js
deleted file mode 100644
index 177d6bc8f..000000000
--- a/packages/editor/dist/es/toolbar/tools/table.js
+++ /dev/null
@@ -1,166 +0,0 @@
-import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-import { useCallback, useMemo, useRef, useState } from "react";
-import { Flex, Text } from "rebass";
-import { ResponsivePresenter } from "../../components/responsive";
-import { moveColumnLeft as moveColumnLeftAction, moveColumnRight as moveColumnRightAction, moveRowDown as moveRowDownAction, moveRowUp as moveRowUpAction, } from "../../extensions/table/actions";
-import { MoreTools } from "../components/more-tools";
-import { menuButtonToTool } from "./utils";
-import { getToolDefinition } from "../tool-definitions";
-import { CellProperties as CellPropertiesPopup } from "../popups/cell-properties";
-import { ColorTool } from "./colors";
-import { Counter } from "../components/counter";
-import { useToolbarLocation } from "../stores/toolbar-store";
-import { showPopup } from "../../components/popup-presenter";
-export function TableSettings(props) {
- const { editor } = props;
- const isBottom = useToolbarLocation() === "bottom";
- if (!editor.isActive("table") || !isBottom)
- return null;
- return (_jsx(MoreTools, Object.assign({}, props, { autoCloseOnUnmount: true, popupId: "tableSettings", tools: [
- "insertColumnLeft",
- "insertColumnRight",
- "insertRowAbove",
- "insertRowBelow",
- "cellProperties",
- "columnProperties",
- "rowProperties",
- "deleteRow",
- "deleteColumn",
- "deleteTable",
- ] })));
-}
-export function RowProperties(props) {
- const { editor } = props;
- const buttonRef = useRef();
- const [isMenuOpen, setIsMenuOpen] = useState(false);
- const items = useMemo(() => [
- insertRowAbove(editor),
- insertRowBelow(editor),
- moveRowUp(editor),
- moveRowDown(editor),
- deleteRow(editor),
- ], []);
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({}, props, { buttonRef: buttonRef, toggled: isMenuOpen, onClick: () => setIsMenuOpen(true) })), _jsx(ResponsivePresenter, { title: "Row properties", mobile: "sheet", desktop: "menu", isOpen: isMenuOpen, onClose: () => setIsMenuOpen(false), position: {
- target: buttonRef.current,
- isTargetAbsolute: true,
- location: "below",
- yOffset: 5,
- }, items: items })] }));
-}
-export function ColumnProperties(props) {
- const { editor } = props;
- const buttonRef = useRef();
- const [isMenuOpen, setIsMenuOpen] = useState(false);
- const items = useMemo(() => [
- insertColumnLeft(editor),
- insertColumnRight(editor),
- moveColumnLeft(editor),
- moveColumnRight(editor),
- deleteColumn(editor),
- ], []);
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({}, props, { buttonRef: buttonRef, toggled: isMenuOpen, onClick: () => setIsMenuOpen(true) })), _jsx(ResponsivePresenter, { title: "Column properties", mobile: "sheet", desktop: "menu", isOpen: isMenuOpen, onClose: () => setIsMenuOpen(false), position: {
- target: buttonRef.current,
- isTargetAbsolute: true,
- location: "below",
- yOffset: 5,
- }, items: items })] }));
-}
-export function TableProperties(props) {
- const { editor } = props;
- const buttonRef = useRef();
- const [isMenuOpen, setIsMenuOpen] = useState(false);
- const items = useMemo(() => [
- insertColumnLeft(editor),
- insertColumnRight(editor),
- moveColumnLeft(editor),
- moveColumnRight(editor),
- deleteColumn(editor),
- { type: "separator", key: "cellSeperator" },
- mergeCells(editor),
- splitCells(editor),
- cellProperties(editor),
- { type: "separator", key: "tableSeperator" },
- deleteTable(editor),
- ], []);
- return (_jsxs(_Fragment, { children: [_jsx(ToolButton, Object.assign({}, props, { buttonRef: buttonRef, toggled: isMenuOpen, onClick: () => setIsMenuOpen(true) })), _jsx(ResponsivePresenter, { title: "Table properties", mobile: "sheet", desktop: "menu", isOpen: isMenuOpen, onClose: () => setIsMenuOpen(false), position: {
- target: buttonRef.current,
- isTargetAbsolute: true,
- location: "below",
- yOffset: 5,
- }, items: items })] }));
-}
-export function CellProperties(props) {
- return (_jsx(_Fragment, { children: _jsx(MoreTools, Object.assign({}, props, { popupId: "cellProperties", tools: [
- "mergeCells",
- "splitCells",
- "cellBackgroundColor",
- "cellTextColor",
- "cellBorderColor",
- "cellBorderWidth",
- ] })) }));
-}
-export function CellBackgroundColor(props) {
- const { editor } = props;
- return (_jsx(ColorTool, Object.assign({}, props, { cacheKey: "cellBackgroundColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("tableCell").backgroundColor; }, title: "Cell background color", onColorChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().setCellAttribute("backgroundColor", color).run(); } })));
-}
-export function CellTextColor(props) {
- const { editor } = props;
- return (_jsx(ColorTool, Object.assign({}, props, { cacheKey: "cellTextColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("tableCell").color; }, title: "Cell text color", onColorChange: (color) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setCellAttribute("color", color).run(); } })));
-}
-export function CellBorderColor(props) {
- const { editor } = props;
- return (_jsx(ColorTool, Object.assign({}, props, { cacheKey: "cellBorderColor", getActiveColor: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.getAttributes("tableCell").borderColor; }, title: "Cell border color", onColorChange: (color) => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setCellAttribute("borderColor", color).run();
- } })));
-}
-export function CellBorderWidth(props) {
- const { editor } = props;
- const { borderWidth: _borderWidth } = editor.getAttributes("tableCell");
- const borderWidth = _borderWidth ? _borderWidth : 1;
- const decreaseBorderWidth = useCallback(() => {
- return Math.max(1, borderWidth - 1);
- }, [borderWidth]);
- const increaseBorderWidth = useCallback(() => {
- return Math.min(10, borderWidth + 1);
- }, [borderWidth]);
- return (_jsxs(Flex, Object.assign({ sx: { justifyContent: "center", alignItems: "center" } }, { children: [_jsx(Text, Object.assign({ variant: "subBody", sx: { mx: 1 } }, { children: "Border width:" })), _jsx(Counter, { title: "cell border width", onDecrease: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderWidth", decreaseBorderWidth());
- }, onIncrease: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderWidth", increaseBorderWidth());
- }, onReset: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setCellAttribute("borderWidth", 1); }, value: borderWidth + "px" })] })));
-}
-const insertColumnLeft = (editor) => (Object.assign(Object.assign({}, getToolDefinition("insertColumnLeft")), { key: "addColumnLeft", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addColumnBefore().run(); } }));
-const insertColumnRight = (editor) => (Object.assign(Object.assign({}, getToolDefinition("insertColumnRight")), { key: "addColumnRight", type: "button", title: "Add column right", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addColumnAfter().run(); }, icon: "insertColumnRight" }));
-const moveColumnLeft = (editor) => (Object.assign(Object.assign({}, getToolDefinition("moveColumnLeft")), { key: "moveColumnLeft", type: "button", onClick: () => moveColumnLeftAction(editor) }));
-const moveColumnRight = (editor) => (Object.assign(Object.assign({}, getToolDefinition("moveColumnRight")), { key: "moveColumnRight", type: "button", onClick: () => moveColumnRightAction(editor) }));
-const deleteColumn = (editor) => (Object.assign(Object.assign({}, getToolDefinition("deleteColumn")), { key: "deleteColumn", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().deleteColumn().run(); } }));
-const splitCells = (editor) => (Object.assign(Object.assign({}, getToolDefinition("splitCells")), { key: "splitCells", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().splitCell().run(); } }));
-const mergeCells = (editor) => (Object.assign(Object.assign({}, getToolDefinition("mergeCells")), { key: "mergeCells", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().mergeCells().run(); } }));
-const insertRowAbove = (editor) => (Object.assign(Object.assign({}, getToolDefinition("insertRowAbove")), { key: "insertRowAbove", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addRowBefore().run(); } }));
-const insertRowBelow = (editor) => (Object.assign(Object.assign({}, getToolDefinition("insertRowBelow")), { key: "insertRowBelow", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().addRowAfter().run(); } }));
-const moveRowUp = (editor) => (Object.assign(Object.assign({}, getToolDefinition("moveRowUp")), { key: "moveRowUp", type: "button", onClick: () => moveRowUpAction(editor) }));
-const moveRowDown = (editor) => (Object.assign(Object.assign({}, getToolDefinition("moveRowDown")), { key: "moveRowDown", type: "button", onClick: () => moveRowDownAction(editor) }));
-const deleteRow = (editor) => (Object.assign(Object.assign({}, getToolDefinition("deleteRow")), { key: "deleteRow", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().deleteRow().run(); } }));
-const deleteTable = (editor) => (Object.assign(Object.assign({}, getToolDefinition("deleteTable")), { key: "deleteTable", type: "button", onClick: () => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().deleteTable().run(); } }));
-const cellProperties = (editor) => (Object.assign(Object.assign({}, getToolDefinition("cellProperties")), { key: "cellProperties", type: "button", onClick: () => {
- showPopup({
- popup: (hide) => _jsx(CellPropertiesPopup, { onClose: hide, editor: editor }),
- });
- } }));
-export const InsertColumnLeft = menuButtonToTool(insertColumnLeft);
-export const InsertColumnRight = menuButtonToTool(insertColumnRight);
-export const MoveColumnLeft = menuButtonToTool(moveColumnLeft);
-export const MoveColumnRight = menuButtonToTool(moveColumnRight);
-export const DeleteColumn = menuButtonToTool(deleteColumn);
-export const SplitCells = menuButtonToTool(splitCells);
-export const MergeCells = menuButtonToTool(mergeCells);
-export const InsertRowAbove = menuButtonToTool(insertRowAbove);
-export const InsertRowBelow = menuButtonToTool(insertRowBelow);
-export const MoveRowUp = menuButtonToTool(moveRowUp);
-export const MoveRowDown = menuButtonToTool(moveRowDown);
-export const DeleteRow = menuButtonToTool(deleteRow);
-export const DeleteTable = menuButtonToTool(deleteTable);
diff --git a/packages/editor/dist/es/toolbar/tools/textdirection.d.ts b/packages/editor/dist/es/toolbar/tools/textdirection.d.ts
deleted file mode 100644
index 1acbfbb23..000000000
--- a/packages/editor/dist/es/toolbar/tools/textdirection.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-/// <reference types="react" />
-import { ToolProps } from "../types";
-export declare function TextDirection(props: ToolProps): JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/textdirection.js b/packages/editor/dist/es/toolbar/tools/textdirection.js
deleted file mode 100644
index 6943bcf27..000000000
--- a/packages/editor/dist/es/toolbar/tools/textdirection.js
+++ /dev/null
@@ -1,29 +0,0 @@
-var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
-};
-import { jsx as _jsx } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-import { useRefValue } from "../../hooks/use-ref-value";
-function TextDirectionTool(props) {
- const { editor, direction } = props, toolProps = __rest(props, ["editor", "direction"]);
- const directionRef = useRefValue(direction);
- return (_jsx(ToolButton, Object.assign({}, toolProps, { onClick: () => {
- var _a;
- return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.chain().focus().setTextDirection(directionRef.current).run();
- }, toggled: false })));
-}
-export function TextDirection(props) {
- const { editor } = props;
- const { textDirection } = Object.assign(Object.assign({}, editor.getAttributes("paragraph")), editor.getAttributes("heading"));
- const newTextDirection = textDirection === "ltr" ? "rtl" : "ltr";
- const icon = textDirection === "ltr" ? "ltr" : "rtl";
- return (_jsx(TextDirectionTool, Object.assign({ direction: newTextDirection }, props, { icon: icon })));
-}
diff --git a/packages/editor/dist/es/toolbar/tools/utils.d.ts b/packages/editor/dist/es/toolbar/tools/utils.d.ts
deleted file mode 100644
index 6faea73ef..000000000
--- a/packages/editor/dist/es/toolbar/tools/utils.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/// <reference types="react" />
-import { Editor } from "../../types";
-import { MenuButton } from "../../components/menu/types";
-import { ToolProps } from "../types";
-export declare function menuButtonToTool(constructItem: (editor: Editor) => MenuButton): (props: ToolProps) => JSX.Element;
diff --git a/packages/editor/dist/es/toolbar/tools/utils.js b/packages/editor/dist/es/toolbar/tools/utils.js
deleted file mode 100644
index 494464fee..000000000
--- a/packages/editor/dist/es/toolbar/tools/utils.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { jsx as _jsx } from "react/jsx-runtime";
-import { ToolButton } from "../components/tool-button";
-export function menuButtonToTool(constructItem) {
- return function (props) {
- const item = constructItem(props.editor);
- return (_jsx(ToolButton, Object.assign({}, props, { icon: item.icon || props.icon, toggled: item.isChecked || false, title: item.title, onClick: item.onClick })));
- };
-}
diff --git a/packages/editor/dist/es/toolbar/types.d.ts b/packages/editor/dist/es/toolbar/types.d.ts
deleted file mode 100644
index 08982355e..000000000
--- a/packages/editor/dist/es/toolbar/types.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Editor } from "../types";
-import { IconNames } from "./icons";
-import { ToolId } from "./tools";
-import { NodeWithOffset } from "./utils/prosemirror";
-export declare type ToolButtonVariant = "small" | "normal";
-export declare type ToolProps = ToolDefinition & {
- editor: Editor;
- variant?: ToolButtonVariant;
- force?: boolean;
- selectedNode?: NodeWithOffset;
-};
-export declare type ToolDefinition = {
- icon: IconNames;
- title: string;
- conditional?: boolean;
- description?: string;
-};
-export declare type ToolbarGroupDefinition = (ToolId | ToolId[])[];
-export declare type ToolbarDefinition = ToolbarGroupDefinition[];
diff --git a/packages/editor/dist/es/toolbar/types.js b/packages/editor/dist/es/toolbar/types.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/packages/editor/dist/es/toolbar/types.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/editor/dist/es/toolbar/utils/dom.d.ts b/packages/editor/dist/es/toolbar/utils/dom.d.ts
deleted file mode 100644
index e3fdd7ffb..000000000
--- a/packages/editor/dist/es/toolbar/utils/dom.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export declare function getToolbarElement(): HTMLElement;
-export declare function getPopupContainer(): HTMLElement;
-export declare function getEditorContainer(): HTMLElement;
-export declare function getEditorDOM(): HTMLElement;
diff --git a/packages/editor/dist/es/toolbar/utils/dom.js b/packages/editor/dist/es/toolbar/utils/dom.js
deleted file mode 100644
index 729a9f754..000000000
--- a/packages/editor/dist/es/toolbar/utils/dom.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export function getToolbarElement() {
- return (document.querySelector(".editor-toolbar") || undefined);
-}
-export function getPopupContainer() {
- return (document.getElementById("popup-container") || undefined);
-}
-export function getEditorContainer() {
- return (document.querySelector(".editor") ||
- getPopupContainer());
-}
-export function getEditorDOM() {
- return (document.querySelector(".ProseMirror") ||
- getEditorContainer()); // ProseMirror
-}
diff --git a/packages/editor/dist/es/toolbar/utils/prosemirror.d.ts b/packages/editor/dist/es/toolbar/utils/prosemirror.d.ts
deleted file mode 100644
index f965c8484..000000000
--- a/packages/editor/dist/es/toolbar/utils/prosemirror.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Editor } from "@tiptap/core";
-import { Node as ProsemirrorNode, Mark } from "prosemirror-model";
-import { EditorState } from "prosemirror-state";
-export declare type NodeWithOffset = {
- node?: ProsemirrorNode;
- from: number;
- to: number;
-};
-export declare function findSelectedDOMNode(editor: Editor, types: string[]): HTMLElement | null;
-export declare function findSelectedNode(editor: Editor, type: string): ProsemirrorNode | null;
-export declare function findMark(node: ProsemirrorNode, type: string): Mark | undefined;
-export declare function selectionToOffset(state: EditorState): NodeWithOffset;
-export declare function findListItemType(editor: Editor): string | null;
-export declare function isListActive(editor: Editor): boolean;
diff --git a/packages/editor/dist/es/toolbar/utils/prosemirror.js b/packages/editor/dist/es/toolbar/utils/prosemirror.js
deleted file mode 100644
index e786008f2..000000000
--- a/packages/editor/dist/es/toolbar/utils/prosemirror.js
+++ /dev/null
@@ -1,53 +0,0 @@
-import { findParentNode } from "@tiptap/core";
-export function findSelectedDOMNode(editor, types) {
- var _a;
- const { $anchor } = editor.state.selection;
- const selectedNode = editor.state.doc.nodeAt($anchor.pos);
- const pos = types.includes((selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.type.name) || "")
- ? $anchor.pos
- : (_a = findParentNode((node) => types.includes(node.type.name))(editor.state.selection)) === null || _a === void 0 ? void 0 : _a.pos;
- if (!pos)
- return null;
- return editor.view.nodeDOM(pos) || null;
-}
-export function findSelectedNode(editor, type) {
- var _a;
- const { $anchor } = editor.state.selection;
- const selectedNode = editor.state.doc.nodeAt($anchor.pos);
- const pos = (selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.type.name) === type
- ? $anchor.pos
- : (_a = findParentNode((node) => node.type.name === type)(editor.state.selection)) === null || _a === void 0 ? void 0 : _a.pos;
- if (!pos)
- return null;
- return editor.state.doc.nodeAt(pos);
-}
-export function findMark(node, type) {
- const mark = node.marks.find((m) => m.type.name === type);
- return mark;
-}
-export function selectionToOffset(state) {
- const { $from, from } = state.selection;
- return {
- node: state.doc.nodeAt(from) || undefined,
- from,
- to: from + $from.node().nodeSize,
- };
-}
-export function findListItemType(editor) {
- const isTaskList = editor.isActive("taskList");
- const isOutlineList = editor.isActive("outlineList");
- const isList = editor.isActive("bulletList") || editor.isActive("orderedList");
- return isList
- ? "listItem"
- : isOutlineList
- ? "outlineListItem"
- : isTaskList
- ? "taskItem"
- : null;
-}
-export function isListActive(editor) {
- const isTaskList = editor.isActive("taskList");
- const isOutlineList = editor.isActive("outlineList");
- const isList = editor.isActive("bulletList") || editor.isActive("orderedList");
- return isTaskList || isOutlineList || isList;
-}
diff --git a/packages/editor/dist/es/types.d.ts b/packages/editor/dist/es/types.d.ts
deleted file mode 100644
index ec55db8df..000000000
--- a/packages/editor/dist/es/types.d.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { UnionCommands, Editor as TiptapEditor } from "@tiptap/core";
-export interface PermissionRequestEvent extends CustomEvent<{
- id: keyof UnionCommands;
-}> {
-}
-export declare class Editor extends TiptapEditor {
- /**
- * Use this to get the latest instance of the editor.
- * This is required to reduce unnecessary rerenders of
- * toolbar elements.
- */
- current?: TiptapEditor;
- /**
- * Request permission before executing a command to make sure user
- * is allowed to perform the action.
- * @param id the command id to get permission for
- * @returns latest editor instance
- */
- requestPermission(id: keyof UnionCommands): TiptapEditor | undefined;
-}
diff --git a/packages/editor/dist/es/types.js b/packages/editor/dist/es/types.js
deleted file mode 100644
index 9a8782dba..000000000
--- a/packages/editor/dist/es/types.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Editor as TiptapEditor } from "@tiptap/core";
-export class Editor extends TiptapEditor {
- /**
- * Request permission before executing a command to make sure user
- * is allowed to perform the action.
- * @param id the command id to get permission for
- * @returns latest editor instance
- */
- requestPermission(id) {
- const event = new CustomEvent("permissionrequest", {
- detail: { id },
- cancelable: true,
- });
- if (!window.dispatchEvent(event))
- return undefined;
- return this.current;
- }
-}
diff --git a/packages/editor/dist/es/utils/config.d.ts b/packages/editor/dist/es/utils/config.d.ts
deleted file mode 100644
index 737bfd7e4..000000000
--- a/packages/editor/dist/es/utils/config.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-declare function set<T>(key: string, value: T | null): void;
-declare function get<T>(key: string, def?: T): T | undefined;
-export declare const config: {
- set: typeof set;
- get: typeof get;
-};
-export {};
diff --git a/packages/editor/dist/es/utils/config.js b/packages/editor/dist/es/utils/config.js
deleted file mode 100644
index 4e07c19fa..000000000
--- a/packages/editor/dist/es/utils/config.js
+++ /dev/null
@@ -1,22 +0,0 @@
-function set(key, value) {
- if (!value)
- return window.localStorage.removeItem(key);
- window.localStorage.setItem(key, JSON.stringify(value));
-}
-function get(key, def) {
- const value = window.localStorage.getItem(key);
- if (!value)
- return def;
- return tryParse(value);
-}
-export const config = { set, get };
-function tryParse(val) {
- if (val === "undefined" || val === "null")
- return;
- try {
- return JSON.parse(val);
- }
- catch (e) {
- return val;
- }
-}
diff --git a/packages/editor/dist/es/utils/debounce.d.ts b/packages/editor/dist/es/utils/debounce.d.ts
deleted file mode 100644
index aa5951c17..000000000
--- a/packages/editor/dist/es/utils/debounce.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare function debounce<F extends (...args: any) => any>(func: F, waitFor: number): (...args: Parameters<F>) => ReturnType<F>;
diff --git a/packages/editor/dist/es/utils/debounce.js b/packages/editor/dist/es/utils/debounce.js
deleted file mode 100644
index bc2f92584..000000000
--- a/packages/editor/dist/es/utils/debounce.js
+++ /dev/null
@@ -1,9 +0,0 @@
-export function debounce(func, waitFor) {
- let timeout;
- const debounced = (...args) => {
- if (timeout)
- clearTimeout(timeout);
- timeout = setTimeout(() => func(...args), waitFor);
- };
- return debounced;
-}
diff --git a/packages/editor/dist/es/utils/position.d.ts b/packages/editor/dist/es/utils/position.d.ts
deleted file mode 100644
index 85bee69bf..000000000
--- a/packages/editor/dist/es/utils/position.d.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-declare type PositionData = {
- x: number;
- y: number;
- actualX: number;
- actualY: number;
- width?: number;
- height?: number;
-};
-export declare type PositionOptions = {
- target?: HTMLElement | "mouse";
- isTargetAbsolute?: boolean;
- location?: "right" | "left" | "below" | "top";
- align?: "center" | "start" | "end";
- yOffset?: number;
- xOffset?: number;
- yAnchor?: HTMLElement;
- parent?: HTMLElement | Element;
-};
-export declare function getPosition(element: HTMLElement, options: PositionOptions): {
- top: number;
- left: number;
-};
-export declare function getElementPosition(element: HTMLElement, absolute: boolean): PositionData;
-export {};
diff --git a/packages/editor/dist/es/utils/position.js b/packages/editor/dist/es/utils/position.js
deleted file mode 100644
index bd6843f12..000000000
--- a/packages/editor/dist/es/utils/position.js
+++ /dev/null
@@ -1,106 +0,0 @@
-const mousePosition = { x: 0, y: 0, actualX: 0, actualY: 0 };
-window.addEventListener("mousemove", (e) => {
- const { x, y, actualX, actualY } = getMousePosition(e);
- mousePosition.x = x;
- mousePosition.y = y;
- mousePosition.actualX = actualX;
- mousePosition.actualY = actualY;
-});
-export function getPosition(element, options) {
- const { target = "mouse", isTargetAbsolute = false, location = undefined, yOffset = 0, xOffset = 0, align = "start", parent = document.body, yAnchor, } = options || {};
- const { x, y, width, height, actualX, actualY } = target === "mouse"
- ? mousePosition
- : getElementPosition(target, isTargetAbsolute);
- const elementWidth = element.offsetWidth;
- const elementHeight = element.offsetHeight;
- const windowWidth = parent.clientWidth;
- const windowHeight = parent.clientHeight;
- let position = { top: 0, left: 0 };
- if (windowWidth - actualX < elementWidth) {
- const xDiff = actualX - x;
- position.left = windowWidth - elementWidth;
- position.left -= xDiff;
- }
- else {
- position.left = x;
- }
- if (width && location === "right") {
- position.left += width;
- }
- else if (location === "left")
- position.left -= elementWidth;
- if (actualY + elementHeight > windowHeight) {
- position.top = windowHeight - elementHeight;
- }
- else {
- position.top = y;
- }
- if (height) {
- if (location === "below")
- position.top += height;
- else if (location === "top")
- position.top = y - elementHeight;
- }
- if (width && target !== "mouse" && align === "center" && elementWidth > 0) {
- position.left -= (elementWidth - width) / 2;
- }
- else if (width &&
- target !== "mouse" &&
- align === "end" &&
- elementWidth > 0) {
- position.left -= elementWidth - width;
- }
- // Adjust menu height
- if (elementHeight > windowHeight - position.top) {
- element.style.maxHeight = `${windowHeight - 20}px`;
- }
- if (yAnchor) {
- const anchorY = getElementPosition(yAnchor, isTargetAbsolute);
- position.top = anchorY.y - elementHeight;
- }
- position.top = isTargetAbsolute && position.top < 0 ? 0 : position.top;
- position.left = isTargetAbsolute && position.left < 0 ? 0 : position.left;
- position.top += location === "below" ? yOffset : -yOffset;
- position.left += xOffset;
- return position;
-}
-function getMousePosition(e) {
- var posx = 0;
- var posy = 0;
- if (!e && window.event)
- e = window.event;
- if (e.pageX || e.pageY) {
- posx = e.pageX;
- posy = e.pageY;
- }
- else if (e.clientX || e.clientY) {
- posx =
- e.clientX +
- document.body.scrollLeft +
- document.documentElement.scrollLeft;
- posy =
- e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
- }
- return {
- x: posx,
- y: posy,
- actualY: posy,
- actualX: posx,
- };
-}
-export function getElementPosition(element, absolute) {
- const rect = element.getBoundingClientRect();
- const position = {
- x: element.offsetLeft,
- y: element.offsetTop,
- width: rect.width,
- height: rect.height,
- actualY: rect.y,
- actualX: rect.x,
- };
- if (absolute) {
- position.x = position.actualX;
- position.y = position.actualY;
- }
- return position;
-}