Skip to content

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

chore: publish

thecodrr077505208e0c
diff --git a/packages/editor/dist/cjs/components/resizer/index.d.ts b/packages/editor/dist/cjs/components/resizer/index.d.ts
new file mode 100644
index 000000000..08792a319
--- /dev/null
+++ b/packages/editor/dist/cjs/components/resizer/index.d.ts
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 000000000..b9d41917f
--- /dev/null
+++ b/packages/editor/dist/cjs/components/resizer/index.js
@@ -0,0 +1,39 @@
+"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/extensions/codeblock/highlighter.d.ts b/packages/editor/dist/cjs/extensions/codeblock/highlighter.d.ts
index 8a9b4718e..e42464534 100644
--- a/packages/editor/dist/cjs/extensions/codeblock/highlighter.d.ts
+++ b/packages/editor/dist/cjs/extensions/codeblock/highlighter.d.ts
@@ -2,7 +2,7 @@ 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 }: {
+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
index 9743b2b0b..ead12449e 100644
--- a/packages/editor/dist/cjs/extensions/codeblock/highlighter.js
+++ b/packages/editor/dist/cjs/extensions/codeblock/highlighter.js
@@ -35,17 +35,16 @@ function getLineDecoration(from, line, total, isActive) {
const attributes = {
class: `line-number ${isActive ? "active" : ""}`,
"data-line": String(line).padEnd(maxLength, " "),
- autocapitalize: "none"
};
const spec = {
line: line,
active: isActive,
total,
- from
+ from,
};
return prosemirror_view_1.Decoration.inline(from, from + 1, attributes, spec);
}
-function getDecorations({ doc, name, defaultLanguage, caretPosition }) {
+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) => {
@@ -68,7 +67,7 @@ function getDecorations({ doc, name, defaultLanguage, caretPosition }) {
const to = from + node.text.length;
if (node.classes.length) {
const decoration = prosemirror_view_1.Decoration.inline(from, to, {
- class: node.classes.join(" ")
+ class: node.classes.join(" "),
});
decorations.push(decoration);
}
@@ -77,7 +76,7 @@ function getDecorations({ doc, name, defaultLanguage, caretPosition }) {
});
return prosemirror_view_1.DecorationSet.create(doc, decorations);
}
-function HighlighterPlugin({ name, defaultLanguage }) {
+function HighlighterPlugin({ name, defaultLanguage, }) {
const key = new prosemirror_state_1.PluginKey("highlighter");
return new prosemirror_state_1.Plugin({
key,
@@ -86,7 +85,7 @@ function HighlighterPlugin({ name, defaultLanguage }) {
return getDecorations({
doc: state.doc,
name,
- defaultLanguage
+ defaultLanguage,
});
},
apply: (transaction, decorationSet, oldState, newState) => {
@@ -121,17 +120,17 @@ function HighlighterPlugin({ name, defaultLanguage }) {
doc: transaction.doc,
name,
defaultLanguage,
- caretPosition: position
+ 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;
@@ -158,7 +157,7 @@ function HighlighterPlugin({ name, defaultLanguage }) {
}
});
return modified ? tr : null;
- }
+ },
});
}
exports.HighlighterPlugin = HighlighterPlugin;
@@ -183,7 +182,7 @@ function getActiveLineDecorations(doc, decorations, position) {
decorations = decorations.remove(lineDecorations);
const newDecorations = [];
for (const decoration of cloned) {
- const { from, spec: { line, total } } = decoration;
+ 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);
diff --git a/packages/editor/dist/cjs/extensions/embed/component.js b/packages/editor/dist/cjs/extensions/embed/component.js
index 793b0e58c..63920bdc2 100644
--- a/packages/editor/dist/cjs/extensions/embed/component.js
+++ b/packages/editor/dist/cjs/extensions/embed/component.js
@@ -3,76 +3,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbedComponent = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const rebass_1 = require("rebass");
-const re_resizable_1 = require("re-resizable");
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"
- } }, { children: (0, jsx_runtime_1.jsxs)(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%", 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) => {
+ 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: ref.clientWidth,
- height: ref.clientHeight
+ width,
+ height,
}, { addToHistory: true, preventUpdate: false });
- }, lockAspectRatio: true }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ width: "100%", sx: {
+ } }, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ width: "100%", sx: {
position: "relative",
justifyContent: "end",
- borderTop: editor.isEditable
- ? "20px solid var(--bgSecondary)"
- : "none",
+ 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)(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: [
- "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: {
+ 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"
- } }, props))] })) })) }));
+ 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/image/component.js b/packages/editor/dist/cjs/extensions/image/component.js
index f82b6fe66..12be6f6c9 100644
--- a/packages/editor/dist/cjs/extensions/image/component.js
+++ b/packages/editor/dist/cjs/extensions/image/component.js
@@ -12,13 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageComponent = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const rebass_1 = require("rebass");
-const re_resizable_1 = require("re-resizable");
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)();
@@ -43,63 +43,39 @@ function ImageComponent(props) {
? "start"
: "end",
":hover .drag-handle, :active .drag-handle": {
- opacity: 1
- }
- } }, { children: (0, jsx_runtime_1.jsxs)(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
- }, handleComponent: {
- bottomRight: ((0, jsx_runtime_1.jsx)(icon_1.Icon, { sx: {
- width: 25,
- height: 25,
- marginLeft: -17,
- marginTop: -17,
- borderTopLeftRadius: "default",
- borderBottomRightRadius: "default"
- }, path: icons_1.Icons.resize, size: 25, color: "primary" }))
- }, style: {
- position: "relative",
- float: float ? (align === "left" ? "left" : "right") : "none"
- }, size: {
- height: height || "auto",
- width: width || "auto"
- }, maxWidth: "100%", onResizeStop: (e, direction, ref, d) => {
+ 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: ref.clientWidth,
- height: ref.clientHeight
+ width,
+ height,
}, { addToHistory: true, preventUpdate: false });
- }, lockAspectRatio: true }, { 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: {
+ } }, { 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"
+ alignItems: "end",
} }, { children: (0, jsx_runtime_1.jsx)(toolbargroup_1.ToolbarGroup, { editor: editor, tools: [
"imageAlignLeft",
"imageAlignCenter",
"imageAlignRight",
- "imageProperties"
+ "imageProperties",
], sx: {
boxShadow: "menu",
borderRadius: "default",
- bg: "background"
+ 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
+ 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"
+ borderRadius: "default",
} }, props))] })) })) }));
}
exports.ImageComponent = ImageComponent;
diff --git a/packages/editor/dist/cjs/extensions/taskitem/component.js b/packages/editor/dist/cjs/extensions/taskitem/component.js
index b9a23c917..b663deb5a 100644
--- a/packages/editor/dist/cjs/extensions/taskitem/component.js
+++ b/packages/editor/dist/cjs/extensions/taskitem/component.js
@@ -14,22 +14,26 @@ function TaskItemComponent(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 }) => {
- const parentPos = getPos();
- toggleChildren(node, tr, !checked, parentPos);
+ toggleChildren(node, tr, !checked, pos);
return true;
});
return true;
- }, [editor, getPos, node, checked]);
+ }, [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
- }
+ 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",
@@ -37,8 +41,8 @@ function TaskItemComponent(props) {
bg: "transparent",
cursor: "grab",
".icon:hover path": {
- fill: "var(--checked) !important"
- }
+ 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",
@@ -48,11 +52,11 @@ function TaskItemComponent(props) {
p: "1px",
cursor: editor.isEditable ? "pointer" : "unset",
":hover": {
- borderColor: "checked"
+ borderColor: "checked",
},
":hover .icon path": {
- fill: "var(--checked) !important"
- }
+ fill: "var(--checked) !important",
+ },
}, onMouseDown: (e) => {
e.preventDefault();
toggle();
@@ -60,11 +64,11 @@ function TaskItemComponent(props) {
e.preventDefault();
toggle();
}, color: checked ? "checked" : "icon", size: isMobile ? 16 : 14 }), (0, jsx_runtime_1.jsx)(rebass_1.Text, { as: "div", ref: forwardRef, sx: {
- p: {
+ "> .taskitem-content-wrapper > p": {
textDecorationLine: checked ? "line-through" : "none",
- opacity: checked ? 0.8 : 1
+ opacity: checked ? 0.8 : 1,
},
- flex: 1
+ flex: 1,
} })] })) }));
}
exports.TaskItemComponent = TaskItemComponent;
@@ -74,7 +78,7 @@ function toggleChildren(node, tr, toggleState, parentPos) {
// need to add 1 to get inside the node
const actualPos = pos + parentPos + 1;
tr.setNodeMarkup(actualPos, undefined, {
- checked: toggleState
+ checked: toggleState,
});
}
return tr;
diff --git a/packages/editor/dist/cjs/extensions/tasklist/component.js b/packages/editor/dist/cjs/extensions/tasklist/component.js
index 6501e0191..56fc8dc42 100644
--- a/packages/editor/dist/cjs/extensions/tasklist/component.js
+++ b/packages/editor/dist/cjs/extensions/tasklist/component.js
@@ -17,15 +17,18 @@ function TaskListComponent(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 parentTaskItem = (0, react_1.useMemo)(() => {
+ const getParent = (0, react_1.useCallback)(() => {
const pos = editor.state.doc.resolve(getPos());
return (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(pos, taskItemType);
}, []);
- const nested = !!parentTaskItem;
+ const isNested = (0, react_1.useMemo)(() => {
+ return !!getParent();
+ }, [getParent]);
(0, react_1.useEffect)(() => {
- if (!parentTaskItem)
+ const parent = getParent();
+ if (!parent)
return;
- const { node, pos } = parentTaskItem;
+ 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.
@@ -36,21 +39,21 @@ function TaskListComponent(props) {
tr.setNodeMarkup(pos, undefined, { checked: allChecked });
return true;
});
- }, [node, parentTaskItem]);
+ }, [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 });
- }, [nested, node]);
+ }, [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: nested ? ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
+ ":hover > div > .toggleSublist": { opacity: 1 },
+ } }, { children: isNested ? ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
position: "absolute",
top: 0,
- right: 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",
@@ -59,8 +62,8 @@ function TaskListComponent(props) {
mr: 2,
cursor: "pointer",
".icon:hover path": {
- fill: "var(--checked) !important"
- }
+ 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: {
@@ -71,7 +74,7 @@ function TaskListComponent(props) {
mb: 2,
alignItems: "center",
justifyContent: "end",
- overflow: "hidden"
+ overflow: "hidden",
}, contentEditable: false }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Box, { sx: {
height: "100%",
width: `${stats.percentage}%`,
@@ -79,22 +82,22 @@ function TaskListComponent(props) {
bg: "border",
zIndex: 0,
left: 0,
- transition: "width 250ms ease-out"
+ 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: nested ? 10 : 0,
+ marginBlockStart: isNested ? 10 : 0,
marginBlockEnd: 0,
- marginLeft: nested ? -35 : 0
+ marginLeft: isNested ? -35 : 0,
},
li: {
listStyleType: "none",
position: "relative",
- marginBottom: [2, "7px"]
- }
+ marginBottom: [2, "7px"],
+ },
} })] }));
}
exports.TaskListComponent = TaskListComponent;
diff --git a/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts b/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts
index 04e4e1dd6..2b87a72e6 100644
--- a/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts
+++ b/packages/editor/dist/cjs/toolbar/popups/embedpopup.d.ts
@@ -5,6 +5,5 @@ export declare type EmbedPopupProps = {
title: string;
embed?: Embed;
onSizeChanged?: (size: EmbedSizeOptions) => void;
- onSourceChanged?: (src: string) => 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
index a913f63c8..db9298c23 100644
--- a/packages/editor/dist/cjs/toolbar/popups/embedpopup.js
+++ b/packages/editor/dist/cjs/toolbar/popups/embedpopup.js
@@ -10,7 +10,7 @@ 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, onSourceChanged, title, embed } = 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) || "");
@@ -36,11 +36,8 @@ function EmbedPopup(props) {
if (onSizeChanged)
onSizeChanged(size);
}, [width, height]);
- (0, react_1.useEffect)(() => {
- onSourceChanged && onSourceChanged(src);
- }, [onSourceChanged, src]);
return ((0, jsx_runtime_1.jsx)(popup_1.Popup, Object.assign({ title: title, onClose: () => onClose(), action: {
- title,
+ title: "Save",
onClick: () => {
setError(null);
let _src = src;
diff --git a/packages/editor/dist/cjs/toolbar/tools/embed.js b/packages/editor/dist/cjs/toolbar/tools/embed.js
index 6a7943637..085567ec5 100644
--- a/packages/editor/dist/cjs/toolbar/tools/embed.js
+++ b/packages/editor/dist/cjs/toolbar/tools/embed.js
@@ -55,6 +55,14 @@ function EmbedProperties(props) {
location: "below",
yOffset: 10,
isTargetAbsolute: true,
- } }, { children: (0, jsx_runtime_1.jsx)(embedpopup_1.EmbedPopup, { title: "Embed properties", onClose: () => setIsOpen(false), embed: embed, onSourceChanged: (src) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSource(src); }, onSizeChanged: (size) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSize(size); } }) }))] }));
+ } }, { 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/es/components/resizer/index.d.ts b/packages/editor/dist/es/components/resizer/index.d.ts
new file mode 100644
index 000000000..08792a319
--- /dev/null
+++ b/packages/editor/dist/es/components/resizer/index.d.ts
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 000000000..3de68f90b
--- /dev/null
+++ b/packages/editor/dist/es/components/resizer/index.js
@@ -0,0 +1,35 @@
+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/extensions/embed/component.js b/packages/editor/dist/es/extensions/embed/component.js
index 8e3045d60..4e2bf0b5f 100644
--- a/packages/editor/dist/es/extensions/embed/component.js
+++ b/packages/editor/dist/es/extensions/embed/component.js
@@ -1,74 +1,62 @@
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Box, Flex } from "rebass";
-import { Resizable } from "re-resizable";
-import { useRef } from "react";
+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"
- } }, { children: _jsxs(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%", 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) => {
+ 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: ref.clientWidth,
- height: ref.clientHeight
+ width,
+ height,
}, { addToHistory: true, preventUpdate: false });
- }, lockAspectRatio: true }, { children: [_jsx(Flex, Object.assign({ width: "100%", sx: {
+ } }, { children: [_jsxs(Flex, Object.assign({ width: "100%", sx: {
position: "relative",
justifyContent: "end",
- borderTop: editor.isEditable
- ? "20px solid var(--bgSecondary)"
- : "none",
+ p: "small",
+ bg: editor.isEditable ? "bgSecondary" : "transparent",
borderTopLeftRadius: "default",
borderTopRightRadius: "default",
borderColor: selected ? "border" : "bgSecondary",
cursor: "pointer",
":hover": {
- borderColor: "border"
- }
- } }, { 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: [
- "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: {
+ 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"
- } }, props))] })) })) }));
+ 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/image/component.js b/packages/editor/dist/es/extensions/image/component.js
index 4f4aa529f..9afea299c 100644
--- a/packages/editor/dist/es/extensions/image/component.js
+++ b/packages/editor/dist/es/extensions/image/component.js
@@ -9,13 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Box, Flex, Image } from "rebass";
-import { Resizable } from "re-resizable";
import { useEffect, useRef } from "react";
import { DesktopOnly } from "../../components/responsive";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
import { 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();
@@ -40,63 +40,39 @@ export function ImageComponent(props) {
? "start"
: "end",
":hover .drag-handle, :active .drag-handle": {
- opacity: 1
- }
- } }, { children: _jsxs(Resizable, Object.assign({ enable: {
- bottom: false,
- left: false,
- right: false,
- top: false,
- bottomLeft: false,
- bottomRight: editor.isEditable && selected,
- topLeft: false,
- topRight: false
- }, handleComponent: {
- bottomRight: (_jsx(Icon, { sx: {
- width: 25,
- height: 25,
- marginLeft: -17,
- marginTop: -17,
- borderTopLeftRadius: "default",
- borderBottomRightRadius: "default"
- }, path: Icons.resize, size: 25, color: "primary" }))
- }, style: {
- position: "relative",
- float: float ? (align === "left" ? "left" : "right") : "none"
- }, size: {
- height: height || "auto",
- width: width || "auto"
- }, maxWidth: "100%", onResizeStop: (e, direction, ref, d) => {
+ opacity: 1,
+ },
+ } }, { children: _jsxs(Resizer, Object.assign({ editor: editor, selected: selected, width: width, height: height, onResize: (width, height) => {
updateAttributes({
- width: ref.clientWidth,
- height: ref.clientHeight
+ width,
+ height,
}, { addToHistory: true, preventUpdate: false });
- }, lockAspectRatio: true }, { children: [_jsx(DesktopOnly, { children: selected && (_jsx(Flex, Object.assign({ sx: { position: "relative", justifyContent: "end" } }, { children: _jsx(Flex, Object.assign({ sx: {
+ } }, { 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"
+ alignItems: "end",
} }, { children: _jsx(ToolbarGroup, { editor: editor, tools: [
"imageAlignLeft",
"imageAlignCenter",
"imageAlignRight",
- "imageProperties"
+ "imageProperties",
], sx: {
boxShadow: "menu",
borderRadius: "default",
- bg: "background"
+ 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
+ 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"
+ borderRadius: "default",
} }, props))] })) })) }));
}
function dataUriToBlobURL(dataurl) {
diff --git a/packages/editor/dist/es/extensions/taskitem/component.js b/packages/editor/dist/es/extensions/taskitem/component.js
index a57b84f6b..08604687e 100644
--- a/packages/editor/dist/es/extensions/taskitem/component.js
+++ b/packages/editor/dist/es/extensions/taskitem/component.js
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
import { Flex, Text } from "rebass";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
-import { findChildren } from "@tiptap/core";
+import { findChildren, } from "@tiptap/core";
import { useCallback } from "react";
import { TaskItemNode } from "./task-item";
import { useIsMobile } from "../../toolbar/stores/toolbar-store";
@@ -11,22 +11,26 @@ export function TaskItemComponent(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 }) => {
- const parentPos = getPos();
- toggleChildren(node, tr, !checked, parentPos);
+ toggleChildren(node, tr, !checked, pos);
return true;
});
return true;
- }, [editor, getPos, node, checked]);
+ }, [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
- }
+ 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",
@@ -34,8 +38,8 @@ export function TaskItemComponent(props) {
bg: "transparent",
cursor: "grab",
".icon:hover path": {
- fill: "var(--checked) !important"
- }
+ fill: "var(--checked) !important",
+ },
}, size: isMobile ? 24 : 20 }), _jsx(Icon, { path: checked ? Icons.check : "", stroke: "1px", sx: {
border: "2px solid",
borderColor: checked ? "checked" : "icon",
@@ -45,11 +49,11 @@ export function TaskItemComponent(props) {
p: "1px",
cursor: editor.isEditable ? "pointer" : "unset",
":hover": {
- borderColor: "checked"
+ borderColor: "checked",
},
":hover .icon path": {
- fill: "var(--checked) !important"
- }
+ fill: "var(--checked) !important",
+ },
}, onMouseDown: (e) => {
e.preventDefault();
toggle();
@@ -57,11 +61,11 @@ export function TaskItemComponent(props) {
e.preventDefault();
toggle();
}, color: checked ? "checked" : "icon", size: isMobile ? 16 : 14 }), _jsx(Text, { as: "div", ref: forwardRef, sx: {
- p: {
+ "> .taskitem-content-wrapper > p": {
textDecorationLine: checked ? "line-through" : "none",
- opacity: checked ? 0.8 : 1
+ opacity: checked ? 0.8 : 1,
},
- flex: 1
+ flex: 1,
} })] })) }));
}
function toggleChildren(node, tr, toggleState, parentPos) {
@@ -70,7 +74,7 @@ function toggleChildren(node, tr, toggleState, parentPos) {
// need to add 1 to get inside the node
const actualPos = pos + parentPos + 1;
tr.setNodeMarkup(actualPos, undefined, {
- checked: toggleState
+ checked: toggleState,
});
}
return tr;
diff --git a/packages/editor/dist/es/extensions/tasklist/component.js b/packages/editor/dist/es/extensions/tasklist/component.js
index 00be96f1b..adb888387 100644
--- a/packages/editor/dist/es/extensions/tasklist/component.js
+++ b/packages/editor/dist/es/extensions/tasklist/component.js
@@ -1,9 +1,9 @@
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 { findChildren, getNodeType, } from "@tiptap/core";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
-import { useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import { Input } from "@rebass/forms";
import { TaskItemNode } from "../task-item";
import { findParentNodeOfTypeClosestToPos } from "prosemirror-utils";
@@ -14,15 +14,18 @@ export function TaskListComponent(props) {
const taskItemType = getNodeType(TaskItemNode.name, editor.schema);
const { title, collapsed } = node.attrs;
const [stats, setStats] = useState({ checked: 0, total: 0, percentage: 0 });
- const parentTaskItem = useMemo(() => {
+ const getParent = useCallback(() => {
const pos = editor.state.doc.resolve(getPos());
return findParentNodeOfTypeClosestToPos(pos, taskItemType);
}, []);
- const nested = !!parentTaskItem;
+ const isNested = useMemo(() => {
+ return !!getParent();
+ }, [getParent]);
useEffect(() => {
- if (!parentTaskItem)
+ const parent = getParent();
+ if (!parent)
return;
- const { node, pos } = parentTaskItem;
+ 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.
@@ -33,21 +36,21 @@ export function TaskListComponent(props) {
tr.setNodeMarkup(pos, undefined, { checked: allChecked });
return true;
});
- }, [node, parentTaskItem]);
+ }, [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 });
- }, [nested, node]);
+ }, [isNested, node]);
return (_jsxs(_Fragment, { children: [_jsx(Flex, Object.assign({ sx: {
flexDirection: "column",
- ":hover > div > .toggleSublist": { opacity: 1 }
- } }, { children: nested ? (_jsxs(Flex, Object.assign({ sx: {
+ ":hover > div > .toggleSublist": { opacity: 1 },
+ } }, { children: isNested ? (_jsxs(Flex, Object.assign({ sx: {
position: "absolute",
top: 0,
- right: 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",
@@ -56,8 +59,8 @@ export function TaskListComponent(props) {
mr: 2,
cursor: "pointer",
".icon:hover path": {
- fill: "var(--checked) !important"
- }
+ fill: "var(--checked) !important",
+ },
}, size: isMobile ? 24 : 20, onClick: () => {
updateAttributes({ collapsed: !collapsed }, { addToHistory: false, preventUpdate: true });
} })] }))) : (_jsxs(Flex, Object.assign({ sx: {
@@ -68,7 +71,7 @@ export function TaskListComponent(props) {
mb: 2,
alignItems: "center",
justifyContent: "end",
- overflow: "hidden"
+ overflow: "hidden",
}, contentEditable: false }, { children: [_jsx(Box, { sx: {
height: "100%",
width: `${stats.percentage}%`,
@@ -76,22 +79,22 @@ export function TaskListComponent(props) {
bg: "border",
zIndex: 0,
left: 0,
- transition: "width 250ms ease-out"
+ 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: nested ? 10 : 0,
+ marginBlockStart: isNested ? 10 : 0,
marginBlockEnd: 0,
- marginLeft: nested ? -35 : 0
+ marginLeft: isNested ? -35 : 0,
},
li: {
listStyleType: "none",
position: "relative",
- marginBottom: [2, "7px"]
- }
+ marginBottom: [2, "7px"],
+ },
} })] }));
}
function areAllChecked(node, pos, doc) {
diff --git a/packages/editor/dist/es/toolbar/components/toolbutton.d.ts b/packages/editor/dist/es/toolbar/components/toolbutton.d.ts
index a58039736..d7cb97dd4 100644
--- a/packages/editor/dist/es/toolbar/components/toolbutton.d.ts
+++ b/packages/editor/dist/es/toolbar/components/toolbutton.d.ts
@@ -14,8 +14,8 @@ export declare type ToolButtonProps = ButtonProps & {
};
export declare const ToolButton: React.NamedExoticComponent<ButtonProps & {
icon: IconNames;
- iconColor?: "text" | "background" | "border" | "blue" | "gray" | "green" | "orange" | "purple" | "red" | "yellow" | "checked" | "disabled" | "placeholder" | "icon" | "overlay" | "primary" | "bgSecondary" | keyof import("@notesnook/theme/dist/theme/colorscheme/static").StaticColors | "bgTransparent" | "accent" | "bgSecondaryText" | "bgSecondaryHover" | "hover" | "fontSecondary" | "fontTertiary" | "secondary" | undefined;
- iconSize?: number | "small" | "big" | "medium" | undefined;
+ iconColor?: "background" | "border" | "text" | "blue" | "gray" | "green" | "orange" | "purple" | "red" | "yellow" | "checked" | "disabled" | "placeholder" | "icon" | keyof import("@notesnook/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/popups/embedpopup.d.ts b/packages/editor/dist/es/toolbar/popups/embedpopup.d.ts
index 04e4e1dd6..2b87a72e6 100644
--- a/packages/editor/dist/es/toolbar/popups/embedpopup.d.ts
+++ b/packages/editor/dist/es/toolbar/popups/embedpopup.d.ts
@@ -5,6 +5,5 @@ export declare type EmbedPopupProps = {
title: string;
embed?: Embed;
onSizeChanged?: (size: EmbedSizeOptions) => void;
- onSourceChanged?: (src: string) => 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
index 256522b8c..719309839 100644
--- a/packages/editor/dist/es/toolbar/popups/embedpopup.js
+++ b/packages/editor/dist/es/toolbar/popups/embedpopup.js
@@ -1,13 +1,13 @@
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Flex, Text } from "rebass";
-import { useCallback, useEffect, useState } from "react";
+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, onSourceChanged, title, embed } = 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) || "");
@@ -33,11 +33,8 @@ export function EmbedPopup(props) {
if (onSizeChanged)
onSizeChanged(size);
}, [width, height]);
- useEffect(() => {
- onSourceChanged && onSourceChanged(src);
- }, [onSourceChanged, src]);
return (_jsx(Popup, Object.assign({ title: title, onClose: () => onClose(), action: {
- title,
+ title: "Save",
onClick: () => {
setError(null);
let _src = src;
diff --git a/packages/editor/dist/es/toolbar/tools/embed.js b/packages/editor/dist/es/toolbar/tools/embed.js
index e3683b822..d6c238955 100644
--- a/packages/editor/dist/es/toolbar/tools/embed.js
+++ b/packages/editor/dist/es/toolbar/tools/embed.js
@@ -48,5 +48,13 @@ export function EmbedProperties(props) {
location: "below",
yOffset: 10,
isTargetAbsolute: true,
- } }, { children: _jsx(EmbedPopup, { title: "Embed properties", onClose: () => setIsOpen(false), embed: embed, onSourceChanged: (src) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSource(src); }, onSizeChanged: (size) => { var _a; return (_a = editor.current) === null || _a === void 0 ? void 0 : _a.commands.setEmbedSize(size); } }) }))] }));
+ } }, { 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/package-lock.json b/packages/editor/package-lock.json
index 36a7c5a86..218256075 100644
--- a/packages/editor/package-lock.json
+++ b/packages/editor/package-lock.json
@@ -3214,7 +3214,7 @@
},
"node_modules/@notesnook/theme": {
"version": "0.0.1",
- "resolved": "git+ssh://[email protected]/streetwriters/themeprovider.git#5ca5874b139fa2087150ea497fa997832f6ddd70",
+ "resolved": "git+ssh://[email protected]/streetwriters/themeprovider.git#d3f017bfae57772e7da4cd3375c12d0ccceebc77",
"dependencies": {
"@rebass/forms": "^4.0.6",
"@types/rebass": "^4.0.10",
@@ -27660,7 +27660,7 @@
}
},
"@notesnook/theme": {
- "version": "git+ssh://[email protected]/streetwriters/themeprovider.git#5ca5874b139fa2087150ea497fa997832f6ddd70",
+ "version": "git+ssh://[email protected]/streetwriters/themeprovider.git#d3f017bfae57772e7da4cd3375c12d0ccceebc77",
"from": "@notesnook/theme@github:streetwriters/themeprovider",
"requires": {
"@rebass/forms": "^4.0.6",
diff --git a/packages/editor/styles/styles.css b/packages/editor/styles/styles.css
deleted file mode 120000
index f459c5c14..000000000
--- a/packages/editor/styles/styles.css
+++ /dev/null
@@ -1 +0,0 @@
-/home/thecodrr/Sources/Repos/notesnook-editor/src/styles.css
\ No newline at end of file
diff --git a/packages/editor/styles/styles.css b/packages/editor/styles/styles.css
new file mode 100644
index 000000000..f4d69ae58
--- /dev/null
+++ b/packages/editor/styles/styles.css
@@ -0,0 +1,398 @@
+.ProseMirror p.is-editor-empty:first-child::before {
+ color: var(--placeholder);
+ content: attr(data-placeholder);
+ float: left;
+ height: 0;
+ pointer-events: none;
+}
+
+.ProseMirror code:not(pre code) {
+ background-color: var(--bgSecondary);
+}
+
+.ProseMirror:first-child {
+ margin-top: 10px;
+}
+
+.ProseMirror hr {
+ background-color: var(--border);
+ border-width: 0;
+ height: 2px;
+}
+
+.ProseMirror code:not(pre code) {
+ background-color: var(--bgSecondary);
+ border: 1px solid var(--border);
+ border-radius: 5px;
+ padding: 3px 5px 0px 5px;
+ font-family: ui-monospace, SFMono-Regular, SF Mono, Consolas, Liberation Mono,
+ Menlo, monospace !important;
+ font-size: 10pt !important;
+}
+
+.ProseMirror li p {
+ margin: 0px;
+}
+
+.ProseMirror li {
+ margin-bottom: 5px;
+}
+
+.ProseMirror a {
+ color: var(--primary);
+ cursor: pointer;
+}
+
+.ProseMirror a:hover {
+ filter: brightness(70%);
+}
+
+.ProseMirror {
+ position: relative;
+}
+.ProseMirror {
+ word-wrap: break-word;
+ white-space: pre-wrap;
+ white-space: break-spaces;
+ -webkit-font-variant-ligatures: none;
+ font-variant-ligatures: none;
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
+}
+.ProseMirror [contenteditable="false"] {
+ white-space: normal;
+}
+.ProseMirror [contenteditable="false"] [contenteditable="true"] {
+ white-space: pre-wrap;
+}
+.ProseMirror pre {
+ white-space: pre-wrap;
+}
+img.ProseMirror-separator {
+ display: inline !important;
+ border: none !important;
+ margin: 0 !important;
+ width: 1px !important;
+ height: 1px !important;
+}
+.ProseMirror-gapcursor {
+ display: none;
+ pointer-events: none;
+ position: absolute;
+ margin: 0;
+}
+.ProseMirror-gapcursor:after {
+ content: "";
+ display: block;
+ position: absolute;
+ top: -2px;
+ width: 20px;
+ border-top: 1px solid var(--text);
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
+}
+@keyframes ProseMirror-cursor-blink {
+ to {
+ visibility: hidden;
+ }
+}
+.ProseMirror-hideselection *::selection {
+ background: transparent;
+ color: var(--text);
+}
+.ProseMirror-hideselection *::-moz-selection {
+ background: transparent;
+ color: var(--text);
+}
+.ProseMirror-hideselection * {
+ caret-color: transparent;
+}
+.ProseMirror-focused .ProseMirror-gapcursor {
+ display: block;
+}
+.tippy-box[data-animation="fade"][data-state="hidden"] {
+ opacity: 0;
+}
+
+.ProseMirror li.node-taskItem {
+ list-style-type: none;
+}
+
+.ProseMirror table {
+ border-collapse: collapse;
+ margin: 0;
+ overflow: hidden;
+ table-layout: fixed;
+}
+
+.ProseMirror table td,
+.ProseMirror table th {
+ border: 1px solid var(--border);
+ box-sizing: border-box;
+ min-width: 1em;
+ padding: 3px 5px;
+ position: relative;
+ vertical-align: top;
+}
+
+.ProseMirror table td > *,
+.ProseMirror table th > * {
+ margin-bottom: 0;
+}
+
+.ProseMirror table th {
+ background-color: var(--bgSecondary);
+ font-weight: bold;
+ text-align: left;
+}
+
+.ProseMirror table .selectedCell:after {
+ background: var(--primary);
+ content: "";
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ pointer-events: none;
+ position: absolute;
+ z-index: 2;
+ opacity: 0.2;
+}
+
+.ProseMirror table .column-resize-handle {
+ background-color: var(--primary);
+ bottom: -2px;
+ position: absolute;
+ right: -2px;
+ pointer-events: none;
+ top: 0;
+ width: 5px;
+}
+
+.ProseMirror table p {
+ margin: 0;
+}
+
+.tableWrapper {
+ /* padding: 1rem 0; */
+ overflow-x: auto;
+}
+
+.resize-cursor {
+ cursor: ew-resize;
+ cursor: col-resize;
+}
+
+.drop-cursor {
+ background-color: var(--text) !important;
+}
+
+.search-result {
+ background-color: var(--disabled);
+}
+
+.line-number-widget,
+.line-number::before {
+ color: var(--codeFg);
+ pointer-events: none;
+ border-right: 1px solid currentColor;
+ margin-right: 10px;
+ padding-right: 10px;
+}
+
+.line-number::before {
+ content: attr(data-line);
+}
+
+.line-number.active::before,
+.line-number-widget.active {
+ color: var(--codeHighlight);
+}
+
+.line-number.active:after,
+.line-number-widget.active:after {
+ content: " ";
+ width: 100%;
+ position: absolute;
+ left: 0;
+ pointer-events: none;
+ background-color: var(--overlay);
+}
+
+pre::selection,
+pre *::selection {
+ background-color: var(--codeSelection) !important;
+ color: currentColor;
+}
+
+.hide-scrollbar::-webkit-scrollbar {
+ display: none;
+}
+
+.ProseMirror blockquote {
+ border-left: 5px solid var(--border);
+ padding-left: 15px;
+}
+
+/****************************************************************/
+/* Styles taken from https://github.com/curvenote/prosemirror-codemark/blob/main/src/codemark.css */
+/****************************************************************/
+
+@keyframes blink {
+ 49% {
+ border-color: unset;
+ }
+ 50% {
+ border-color: #fff;
+ }
+ 99% {
+ border-color: #fff;
+ }
+}
+.no-cursor {
+ caret-color: transparent;
+}
+div:focus .fake-cursor,
+span:focus .fake-cursor {
+ margin-right: -1px;
+ border-left-width: 1px;
+ border-left-style: solid;
+ animation: blink 1s;
+ animation-iteration-count: infinite;
+ position: relative;
+ z-index: 1;
+}
+
+/*******************************************/
+/* MATH STYLES */
+/*******************************************/
+
+/*---------------------------------------------------------
+ * Author: Benjamin R. Bray
+ * License: MIT (see LICENSE in project root for details)
+ *--------------------------------------------------------*/
+
+/* == Math Nodes ======================================== */
+
+.math-node {
+ min-width: 1em;
+ min-height: 1em;
+ font-size: 0.95em;
+ font-family: "Consolas", "Ubuntu Mono", monospace;
+ cursor: auto;
+}
+
+.math-node.empty-math .math-render::before {
+ content: "(empty)";
+ color: red;
+}
+
+.math-node .math-render.parse-error::before {
+ content: "(math error)";
+ color: red;
+ cursor: help;
+}
+
+.math-node.ProseMirror-selectednode {
+ outline: none;
+}
+
+.math-node .math-src {
+ display: none;
+ color: var(--text);
+ tab-size: 4;
+}
+
+.math-node.ProseMirror-selectednode .math-src {
+ display: inline;
+}
+.math-node.ProseMirror-selectednode .math-render {
+ display: none;
+}
+
+/* -- Inline Math --------------------------------------- */
+
+.math-inline {
+ display: inline;
+ white-space: nowrap;
+}
+
+.math-inline .math-render {
+ display: inline-block;
+ /* font-size: 0.85em; */
+ cursor: pointer;
+}
+
+.math-inline .math-src .ProseMirror {
+ display: inline;
+ /* Necessary to fix FireFox bug with contenteditable, https://bugzilla.mozilla.org/show_bug.cgi?id=1252108 */
+ border-right: 1px solid transparent;
+ border-left: 1px solid transparent;
+ font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas,
+ Liberation Mono, monospace !important;
+}
+
+.math-inline.ProseMirror-selectednode {
+ background-color: var(--bgSecondary);
+ padding: 3px;
+ border-radius: 5px;
+ border: 1px solid var(--border);
+}
+
+.math-inline .math-src::after,
+.math-inline .math-src::before {
+ content: "$$";
+ color: var(--disabled);
+}
+
+/* -- Block Math ---------------------------------------- */
+
+.math-block {
+ display: block;
+}
+
+.math-block .math-render {
+ display: block;
+}
+
+.math-block.ProseMirror-selectednode {
+ background-color: var(--bgSecondary);
+ padding: 10px;
+ border-radius: 5px;
+ border: 1px solid var(--border);
+}
+
+.math-block .math-src .ProseMirror {
+ width: 100%;
+ display: block;
+ margin-top: 10px;
+ font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas,
+ Liberation Mono, monospace !important;
+}
+
+/* .math-block .math-src::after, */
+.math-block .math-src::before {
+ content: "Math";
+ text-align: left;
+ color: var(--disabled);
+ margin-bottom: 10px;
+}
+
+.math-block .katex-display {
+ margin: 0;
+}
+
+/* -- Selection Plugin ---------------------------------- */
+
+/* p::selection,
+p > *::selection {
+ background-color: #c0c0c0;
+}
+.katex-html *::selection {
+ background-color: none !important;
+}
+
+.math-node.math-select .math-render {
+ background-color: #c0c0c0ff;
+}
+.math-inline.math-select .math-render {
+ padding-top: 2px;
+} */