Skip to content

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

chore: publish compiled files

thecodrrcd8149540647
diff --git a/packages/editor/dist/cjs/components/menu/menubutton.js b/packages/editor/dist/cjs/components/menu/menubutton.js
index ad6e9c678..7e1361688 100644
--- a/packages/editor/dist/cjs/components/menu/menubutton.js
+++ b/packages/editor/dist/cjs/components/menu/menubutton.js
@@ -10,19 +10,13 @@ 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 } = item;
+ 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: {
- bg: isFocused && !isBottom ? "hover" : "transparent",
- display: "flex",
- alignItems: "center",
- justifyContent: "space-between",
- ":hover": {
+ 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, { 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" } }, { 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: {
+ } }) }, { 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",
diff --git a/packages/editor/dist/cjs/components/menu/types.d.ts b/packages/editor/dist/cjs/components/menu/types.d.ts
index 82ecdffe2..c99c27c95 100644
--- a/packages/editor/dist/cjs/components/menu/types.d.ts
+++ b/packages/editor/dist/cjs/components/menu/types.d.ts
@@ -1,4 +1,5 @@
/// <reference types="react" />
+import { SxStyleProp } from "rebass";
import { IconNames } from "../../toolbar/icons";
declare type MenuItemComponentProps = {
onClick?: (e?: any) => void;
@@ -25,6 +26,7 @@ export declare type MenuButton = BaseMenuItem<"button"> & {
title: string;
items: MenuItem[];
};
+ styles?: SxStyleProp;
};
export declare type MenuItem = MenuButton | MenuSeperator | MenuPopup;
export {};
diff --git a/packages/editor/dist/cjs/extensions/codeblock/component.js b/packages/editor/dist/cjs/extensions/codeblock/component.js
index bf3fc12bb..4666012a2 100644
--- a/packages/editor/dist/cjs/extensions/codeblock/component.js
+++ b/packages/editor/dist/cjs/extensions/codeblock/component.js
@@ -41,9 +41,10 @@ function CodeblockComponent(props) {
if (!syntax)
return;
core_1.refractor.register(syntax);
+ const preventUpdate = language === languageDefinition.filename;
updateAttributes({
language: languageDefinition.filename,
- });
+ }, preventUpdate);
});
})();
}, [language]);
diff --git a/packages/editor/dist/cjs/extensions/image/image.js b/packages/editor/dist/cjs/extensions/image/image.js
index 8d9d464b8..5eed4a835 100644
--- a/packages/editor/dist/cjs/extensions/image/image.js
+++ b/packages/editor/dist/cjs/extensions/image/image.js
@@ -35,6 +35,7 @@ exports.ImageNode = core_1.Node.create({
},
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"),
diff --git a/packages/editor/dist/es/extensions/scroll/index.d.ts b/packages/editor/dist/cjs/extensions/keepinview/index.d.ts
similarity index 100%
rename from packages/editor/dist/es/extensions/scroll/index.d.ts
rename to packages/editor/dist/cjs/extensions/keepinview/index.d.ts
diff --git a/packages/editor/dist/cjs/extensions/keepinview/index.js b/packages/editor/dist/cjs/extensions/keepinview/index.js
new file mode 100644
index 000000000..6520f8b36
--- /dev/null
+++ b/packages/editor/dist/cjs/extensions/keepinview/index.js
@@ -0,0 +1,17 @@
+"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/es/extensions/scroll/keepinview.d.ts b/packages/editor/dist/cjs/extensions/keepinview/keepinview.d.ts
similarity index 100%
rename from packages/editor/dist/es/extensions/scroll/keepinview.d.ts
rename to packages/editor/dist/cjs/extensions/keepinview/keepinview.d.ts
diff --git a/packages/editor/dist/es/extensions/scroll/keepinview.js b/packages/editor/dist/cjs/extensions/keepinview/keepinview.js
similarity index 76%
rename from packages/editor/dist/es/extensions/scroll/keepinview.js
rename to packages/editor/dist/cjs/extensions/keepinview/keepinview.js
index 65bff8f9f..23884c6b6 100644
--- a/packages/editor/dist/es/extensions/scroll/keepinview.js
+++ b/packages/editor/dist/cjs/extensions/keepinview/keepinview.js
@@ -1,5 +1,9 @@
-import { Extension, posToDOMRect } from "@tiptap/core";
-export const KeepInView = Extension.create({
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.keepLastLineInView = exports.KeepInView = void 0;
+const core_1 = require("@tiptap/core");
+exports.KeepInView = core_1.Extension.create({
+ name: "keepinview",
addKeyboardShortcuts() {
return {
Enter: ({ editor }) => {
@@ -11,10 +15,10 @@ export const KeepInView = Extension.create({
};
},
});
-export function keepLastLineInView(editor) {
+function keepLastLineInView(editor) {
const THRESHOLD = 100;
const node = editor.state.selection.$from;
- const { top } = posToDOMRect(editor.view, node.pos, node.pos + 1);
+ 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);
@@ -30,6 +34,7 @@ export function keepLastLineInView(editor) {
}
}
}
+exports.keepLastLineInView = keepLastLineInView;
const findScrollContainer = (element) => {
if (!element) {
return undefined;
diff --git a/packages/editor/dist/cjs/extensions/math/mathinline.js b/packages/editor/dist/cjs/extensions/math/mathinline.js
index 87b5ebd5e..f7ef8eaed 100644
--- a/packages/editor/dist/cjs/extensions/math/mathinline.js
+++ b/packages/editor/dist/cjs/extensions/math/mathinline.js
@@ -27,8 +27,12 @@ exports.MathInline = core_1.Node.create({
},
addCommands() {
return {
- insertMathInline: () => ({ state, dispatch, view }) => {
- return (0, plugin_1.insertMathNode)(this.type)(state, dispatch, view);
+ insertMathInline: () => ({ chain, tr }) => {
+ const { $from } = tr.selection;
+ return chain()
+ .insertContent({ type: this.name, attrs: {} })
+ .setNodeSelection($from.pos)
+ .run();
},
};
},
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js b/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js
index a79632c05..2f5ebae6d 100644
--- a/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js
+++ b/packages/editor/dist/cjs/extensions/math/plugin/commands/insertmathnode.js
@@ -14,14 +14,19 @@ const prosemirror_state_1 = require("prosemirror-state");
*/
function insertMathNode(mathNodeType, initialText = "") {
return function (state, dispatch) {
- let { $from } = state.selection, index = $from.index();
- if (!$from.parent.canReplaceWith(index, index, mathNodeType)) {
+ 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);
- tr = tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, $from.pos));
+ 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;
diff --git a/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js b/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js
index d1852cf17..da571a1d2 100644
--- a/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js
+++ b/packages/editor/dist/cjs/extensions/math/plugin/math-nodeview.js
@@ -256,7 +256,12 @@ class MathView {
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;
- this._innerView.dispatch(innerState.tr.setSelection(prosemirror_state_1.TextSelection.create(innerState.doc, innerPos)));
+ 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;
}
/**
diff --git a/packages/editor/dist/cjs/extensions/outlinelist/component.js b/packages/editor/dist/cjs/extensions/outlinelist/component.js
index 2c26f7202..3739ccc53 100644
--- a/packages/editor/dist/cjs/extensions/outlinelist/component.js
+++ b/packages/editor/dist/cjs/extensions/outlinelist/component.js
@@ -21,6 +21,9 @@ function OutlineListComponent(props) {
marginBlockStart: isNested ? 5 : 0,
marginBlockEnd: 0,
},
+ li: {
+ listStyleType: "none",
+ },
} }) }));
}
exports.OutlineListComponent = OutlineListComponent;
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/component.js b/packages/editor/dist/cjs/extensions/outlinelistitem/component.js
index 62f767bad..6cb5088a6 100644
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/component.js
+++ b/packages/editor/dist/cjs/extensions/outlinelistitem/component.js
@@ -7,33 +7,38 @@ 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);
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: "3px",
+ 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: "scale(1.3)",
+ transform: ["unset", "scale(1.3)"],
+ },
+ ":active": {
+ transform: ["scale(1.3)", "unset"],
},
".icon:hover path": {
fill: "var(--checked) !important",
},
- }, size: 18, onMouseDown: (e) => e.preventDefault(), onClick: () => {
+ }, size: isMobile ? 24 : 18, onMouseDown: (e) => e.preventDefault(), 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);
- } })) : ((0, jsx_runtime_1.jsx)(icon_1.Icon, { path: icons_1.Icons.circle, size: 18, sx: { transform: "scale(0.4)" } })), isNested && !isCollapsed && ((0, jsx_runtime_1.jsx)(rebass_1.Box, { sx: {
+ } })) : ((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,
@@ -46,7 +51,7 @@ function OutlineListItemComponent(props) {
backgroundColor: "fontTertiary",
width: 4,
},
- }, contentEditable: false }))] })), (0, jsx_runtime_1.jsx)(rebass_1.Text, { as: "li", ref: forwardRef, sx: {
+ }, contentEditable: false }))] })), (0, jsx_runtime_1.jsx)(rebass_1.Text, { ref: forwardRef, sx: {
pl: 2,
listStyleType: "none",
flex: 1,
diff --git a/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js b/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js
index e14e62aba..fb754aac0 100644
--- a/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js
+++ b/packages/editor/dist/cjs/extensions/outlinelistitem/outlinelistitem.js
@@ -14,7 +14,7 @@ exports.OutlineListItem = core_1.Node.create({
HTMLAttributes: {},
};
},
- content: "heading* block*",
+ content: "heading* paragraph block*",
defining: true,
parseHTML() {
return [
@@ -42,13 +42,12 @@ exports.OutlineListItem = core_1.Node.create({
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);
- }
+ // 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),
@@ -69,7 +68,7 @@ exports.OutlineListItem = core_1.Node.create({
addNodeView() {
return (0, react_1.createNodeView)(component_1.OutlineListItemComponent, {
contentDOMFactory: true,
- // wrapperFactory: () => document.createElement("li"),
+ wrapperFactory: () => document.createElement("li"),
});
},
});
diff --git a/packages/editor/dist/cjs/extensions/react/plugin.js b/packages/editor/dist/cjs/extensions/react/plugin.js
index 33e068e6e..851e14f1d 100644
--- a/packages/editor/dist/cjs/extensions/react/plugin.js
+++ b/packages/editor/dist/cjs/extensions/react/plugin.js
@@ -41,6 +41,7 @@ exports.NodeViewSelectionNotifierPlugin = new prosemirror_state_1.Plugin({
},
});
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
index ce79ab32d..329805b57 100644
--- a/packages/editor/dist/cjs/extensions/react/reactnodeview.d.ts
+++ b/packages/editor/dist/cjs/extensions/react/reactnodeview.d.ts
@@ -32,7 +32,7 @@ export declare class ReactNodeView<P extends ReactNodeViewProps> implements Node
handleRef: (node: HTMLElement | null) => void;
private _handleRef;
render(props?: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
- updateAttributes(attributes: any, pos: number): void;
+ updateAttributes(attributes: any, pos: number, preventUpdate?: boolean): void;
update(node: PMNode, _decorations: readonly Decoration[], _innerDecorations: DecorationSource): boolean;
onDragStart(event: DragEvent): void;
stopEvent(event: Event): boolean;
diff --git a/packages/editor/dist/cjs/extensions/react/reactnodeview.js b/packages/editor/dist/cjs/extensions/react/reactnodeview.js
index f1747fd31..a8ebd00eb 100644
--- a/packages/editor/dist/cjs/extensions/react/reactnodeview.js
+++ b/packages/editor/dist/cjs/extensions/react/reactnodeview.js
@@ -89,11 +89,13 @@ class ReactNodeView {
return null;
const theme = this.editor.storage.theme;
const pos = this.getPos();
- return ((0, jsx_runtime_1.jsx)(emotion_theming_1.ThemeProvider, Object.assign({ theme: theme }, { 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) => this.updateAttributes(attr, pos) })) })));
+ return ((0, jsx_runtime_1.jsx)(emotion_theming_1.ThemeProvider, Object.assign({ theme: theme }, { 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, preventUpdate) => this.updateAttributes(attr, pos, preventUpdate) })) })));
}
- updateAttributes(attributes, pos) {
+ updateAttributes(attributes, pos, preventUpdate = false) {
this.editor.commands.command(({ tr }) => {
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), attributes));
+ tr.setMeta("addToHistory", false);
+ tr.setMeta("preventUpdate", preventUpdate);
return true;
});
}
diff --git a/packages/editor/dist/cjs/extensions/react/types.d.ts b/packages/editor/dist/cjs/extensions/react/types.d.ts
index c9f7d15c7..0cc116f4f 100644
--- a/packages/editor/dist/cjs/extensions/react/types.d.ts
+++ b/packages/editor/dist/cjs/extensions/react/types.d.ts
@@ -11,7 +11,7 @@ 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>) => void;
+export declare type UpdateAttributes<T> = (attributes: Partial<T>, preventUpdate?: boolean) => void;
export declare type ContentDOM = {
dom: HTMLElement;
contentDOM?: HTMLElement | null | undefined;
diff --git a/packages/editor/dist/cjs/extensions/tasklist/component.js b/packages/editor/dist/cjs/extensions/tasklist/component.js
index dd4999d2c..2c5b7ff3f 100644
--- a/packages/editor/dist/cjs/extensions/tasklist/component.js
+++ b/packages/editor/dist/cjs/extensions/tasklist/component.js
@@ -10,7 +10,9 @@ 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;
@@ -25,6 +27,10 @@ function TaskListComponent(props) {
return;
const { node, pos } = parentTaskItem;
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 });
@@ -46,7 +52,7 @@ function TaskListComponent(props) {
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: collapsed ? 1 : 0,
+ opacity: isMobile || collapsed ? 1 : 0,
position: "absolute",
right: 0,
alignSelf: "start",
@@ -55,7 +61,7 @@ function TaskListComponent(props) {
".icon:hover path": {
fill: "var(--checked) !important",
},
- }, size: 20, onClick: () => {
+ }, size: isMobile ? 24 : 20, onClick: () => {
updateAttributes({ collapsed: !collapsed });
} })] }))) : ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
position: "relative",
diff --git a/packages/editor/dist/cjs/index.js b/packages/editor/dist/cjs/index.js
index 41c3f0980..b8a352a1a 100644
--- a/packages/editor/dist/cjs/index.js
+++ b/packages/editor/dist/cjs/index.js
@@ -67,6 +67,7 @@ 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 table_1 = require("./extensions/table");
const toolbarstore_1 = require("./toolbar/stores/toolbarstore");
const useEditor_1 = require("./hooks/useEditor");
@@ -148,6 +149,7 @@ const useTiptap = (options = {}, deps = []) => {
codemark_1.Codemark,
math_1.MathInline,
math_1.MathBlock,
+ keepinview_1.KeepInView,
],
onBeforeCreate: ({ editor }) => {
if (theme) {
diff --git a/packages/editor/dist/cjs/toolbar/components/counter.js b/packages/editor/dist/cjs/toolbar/components/counter.js
index ea7b50427..6e7c793af 100644
--- a/packages/editor/dist/cjs/toolbar/components/counter.js
+++ b/packages/editor/dist/cjs/toolbar/components/counter.js
@@ -24,6 +24,7 @@ function _Counter(props) {
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) => {
diff --git a/packages/editor/dist/cjs/toolbar/components/dropdown.js b/packages/editor/dist/cjs/toolbar/components/dropdown.js
index 78b22268a..6e4c15cf9 100644
--- a/packages/editor/dist/cjs/toolbar/components/dropdown.js
+++ b/packages/editor/dist/cjs/toolbar/components/dropdown.js
@@ -9,6 +9,7 @@ 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");
function Dropdown(props) {
const { items, selectedItem, buttonRef, menuWidth } = props;
const internalRef = (0, react_1.useRef)();
@@ -16,10 +17,10 @@ function Dropdown(props) {
const toolbarLocation = (0, toolbarstore_1.useToolbarLocation)();
const isMobile = (0, toolbarstore_1.useIsMobile)();
const isBottom = toolbarLocation === "bottom";
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(rebass_1.Button, Object.assign({ ref: (ref) => {
+ 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;
+ buttonRef.current = ref || undefined;
}, sx: {
p: 1,
m: 0,
diff --git a/packages/editor/dist/cjs/toolbar/components/moretools.js b/packages/editor/dist/cjs/toolbar/components/moretools.js
index 935c90e2b..62b095be3 100644
--- a/packages/editor/dist/cjs/toolbar/components/moretools.js
+++ b/packages/editor/dist/cjs/toolbar/components/moretools.js
@@ -19,7 +19,7 @@ function MoreTools(props) {
target: isBottom ? (0, dom_1.getToolbarElement)() : buttonRef.current || "mouse",
align: "center",
location: isBottom ? "top" : "below",
- yOffset: isBottom ? 10 : 5,
+ 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
diff --git a/packages/editor/dist/cjs/toolbar/components/splitbutton.js b/packages/editor/dist/cjs/toolbar/components/splitbutton.js
index b7c8fe915..ff04d1eb7 100644
--- a/packages/editor/dist/cjs/toolbar/components/splitbutton.js
+++ b/packages/editor/dist/cjs/toolbar/components/splitbutton.js
@@ -44,5 +44,6 @@ function _SplitButton(props) {
}, 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" }) }))] })), children] }));
}
exports.SplitButton = react_2.default.memo(_SplitButton, (prev, next) => {
- return prev.toggled === next.toggled;
+ return (prev.toggled === next.toggled &&
+ JSON.stringify(prev.sx) === JSON.stringify(next.sx));
});
diff --git a/packages/editor/dist/cjs/toolbar/components/toolbutton.js b/packages/editor/dist/cjs/toolbar/components/toolbutton.js
index 8e461e038..59e33f114 100644
--- a/packages/editor/dist/cjs/toolbar/components/toolbutton.js
+++ b/packages/editor/dist/cjs/toolbar/components/toolbutton.js
@@ -26,5 +26,7 @@ exports.ToolButton = react_1.default.memo(function ToolButton(props) {
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;
+ 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/popups/colorpicker.js b/packages/editor/dist/cjs/toolbar/popups/colorpicker.js
index adab10663..f0d382f06 100644
--- a/packages/editor/dist/cjs/toolbar/popups/colorpicker.js
+++ b/packages/editor/dist/cjs/toolbar/popups/colorpicker.js
@@ -106,7 +106,10 @@ function ColorPicker(props) {
// boxShadow: "menu",
p: 0,
ml: [2, 2, 1],
- }, 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, { variant: "secondary", sx: {
+ ":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,
@@ -114,7 +117,9 @@ function ColorPicker(props) {
ml: [2, 1, 1],
mb: [0, 1, 1],
borderRadius: 50,
- // boxShadow: "menu",
+ ":hover": {
+ bg: color,
+ },
}, onClick: () => {
setCurrentColor(color);
onChange(color);
diff --git a/packages/editor/dist/cjs/toolbar/tools/colors.d.ts b/packages/editor/dist/cjs/toolbar/tools/colors.d.ts
index e29d3e326..68c8fa59f 100644
--- a/packages/editor/dist/cjs/toolbar/tools/colors.d.ts
+++ b/packages/editor/dist/cjs/toolbar/tools/colors.d.ts
@@ -1,4 +1,4 @@
-import React from "react";
+/// <reference types="react" />
import { ToolProps } from "../types";
declare type ColorToolProps = ToolProps & {
onColorChange: (color?: string) => void;
@@ -6,8 +6,7 @@ declare type ColorToolProps = ToolProps & {
title: string;
cacheKey: string;
};
-declare function _ColorTool(props: ColorToolProps): JSX.Element;
-export declare const ColorTool: React.MemoExoticComponent<typeof _ColorTool>;
+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
index 3e1f270f3..738087765 100644
--- a/packages/editor/dist/cjs/toolbar/tools/colors.js
+++ b/packages/editor/dist/cjs/toolbar/tools/colors.js
@@ -1,27 +1,4 @@
"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 __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)
@@ -39,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (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 = __importStar(require("react"));
+const react_1 = require("react");
const tinycolor2_1 = __importDefault(require("tinycolor2"));
const popuppresenter_1 = require("../../components/popuppresenter");
const config_1 = require("../../utils/config");
@@ -47,8 +24,7 @@ const splitbutton_1 = require("../components/splitbutton");
const colorpicker_1 = require("../popups/colorpicker");
const toolbarstore_1 = require("../stores/toolbarstore");
const dom_1 = require("../utils/dom");
-// TODO test rerendering
-function _ColorTool(props) {
+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);
@@ -74,10 +50,10 @@ function _ColorTool(props) {
config_1.config.set(cacheKey, color);
}, onClose: close, title: title })) }) })));
}
-exports.ColorTool = react_1.default.memo(_ColorTool, () => true);
+exports.ColorTool = ColorTool;
function Highlight(props) {
const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(exports.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) => {
+ 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()
@@ -87,7 +63,7 @@ function Highlight(props) {
exports.Highlight = Highlight;
function TextColor(props) {
const { editor } = props;
- return ((0, jsx_runtime_1.jsx)(exports.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) => {
+ 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()
diff --git a/packages/editor/dist/cjs/toolbar/tools/font.js b/packages/editor/dist/cjs/toolbar/tools/font.js
index 08bd77906..01e0fe9eb 100644
--- a/packages/editor/dist/cjs/toolbar/tools/font.js
+++ b/packages/editor/dist/cjs/toolbar/tools/font.js
@@ -27,7 +27,7 @@ function FontSize(props) {
}
exports.FontSize = FontSize;
const fontFamilies = {
- Default: "Open Sans",
+ "Sans-serif": "Open Sans",
Serif: "serif",
Monospace: "monospace",
};
@@ -35,7 +35,7 @@ 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)) || "Default";
+ .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, { selectedItem: currentFontFamily, items: items, menuWidth: 130 }));
}
@@ -50,6 +50,9 @@ function toMenuItems(editor, currentFontFamily) {
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/lists.js b/packages/editor/dist/cjs/toolbar/tools/lists.js
index 3d85d2c90..49299e16f 100644
--- a/packages/editor/dist/cjs/toolbar/tools/lists.js
+++ b/packages/editor/dist/cjs/toolbar/tools/lists.js
@@ -36,7 +36,7 @@ function _ListTool(props) {
target: isBottom ? (0, dom_1.getToolbarElement)() : buttonRef.current || "mouse",
align: "center",
location: isBottom ? "top" : "below",
- yOffset: isBottom ? 10 : 5,
+ yOffset: 10,
}, onClosed: () => setIsOpen(false), renderPopup: () => ((0, jsx_runtime_1.jsx)(rebass_1.Box, Object.assign({ sx: {
bg: "background",
display: "grid",
diff --git a/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts b/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts
index ef7a00a57..d072ce375 100644
--- a/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts
+++ b/packages/editor/dist/cjs/toolbar/utils/prosemirror.d.ts
@@ -1,14 +1,14 @@
import { Editor } from "@tiptap/core";
-import { Node, Mark } from "prosemirror-model";
+import { Node as ProsemirrorNode, Mark } from "prosemirror-model";
import { Selection } from "prosemirror-state";
export declare type NodeWithOffset = {
- node: Node;
+ node: ProsemirrorNode;
from: number;
to: number;
};
export declare function findSelectedDOMNode(editor: Editor, types: string[]): HTMLElement | null;
-export declare function findSelectedNode(editor: Editor, type: string): Node | null;
-export declare function findMark(node: Node, type: string): Mark | undefined;
+export declare function findSelectedNode(editor: Editor, type: string): ProsemirrorNode | null;
+export declare function findMark(node: ProsemirrorNode, type: string): Mark | undefined;
export declare function selectionToOffset(selection: Selection): NodeWithOffset;
export declare function findListItemType(editor: Editor): string | null;
export declare function isListActive(editor: Editor): boolean;
diff --git a/packages/editor/dist/cjs/utils/position.js b/packages/editor/dist/cjs/utils/position.js
index a0abe314c..16c0fb978 100644
--- a/packages/editor/dist/cjs/utils/position.js
+++ b/packages/editor/dist/cjs/utils/position.js
@@ -45,7 +45,7 @@ function getPosition(element, options) {
position.top = y - elementHeight;
}
if (width && target !== "mouse" && align === "center" && elementWidth > 0) {
- position.left = (width - elementWidth) / 2;
+ position.left -= (elementWidth - width) / 2;
}
else if (width &&
target !== "mouse" &&
diff --git a/packages/editor/dist/es/components/menu/menubutton.js b/packages/editor/dist/es/components/menu/menubutton.js
index d1095f3f6..7652d40fc 100644
--- a/packages/editor/dist/es/components/menu/menubutton.js
+++ b/packages/editor/dist/es/components/menu/menubutton.js
@@ -7,19 +7,13 @@ 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 } = item;
+ 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: {
- bg: isFocused && !isBottom ? "hover" : "transparent",
- display: "flex",
- alignItems: "center",
- justifyContent: "space-between",
- ":hover": {
+ 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, { 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" } }, { 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: {
+ } }) }, { 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",
diff --git a/packages/editor/dist/es/components/menu/types.d.ts b/packages/editor/dist/es/components/menu/types.d.ts
index 82ecdffe2..c99c27c95 100644
--- a/packages/editor/dist/es/components/menu/types.d.ts
+++ b/packages/editor/dist/es/components/menu/types.d.ts
@@ -1,4 +1,5 @@
/// <reference types="react" />
+import { SxStyleProp } from "rebass";
import { IconNames } from "../../toolbar/icons";
declare type MenuItemComponentProps = {
onClick?: (e?: any) => void;
@@ -25,6 +26,7 @@ export declare type MenuButton = BaseMenuItem<"button"> & {
title: string;
items: MenuItem[];
};
+ styles?: SxStyleProp;
};
export declare type MenuItem = MenuButton | MenuSeperator | MenuPopup;
export {};
diff --git a/packages/editor/dist/es/extensions/image/image.js b/packages/editor/dist/es/extensions/image/image.js
index bc7d34b1d..b2cd176d6 100644
--- a/packages/editor/dist/es/extensions/image/image.js
+++ b/packages/editor/dist/es/extensions/image/image.js
@@ -32,6 +32,7 @@ export const ImageNode = Node.create({
},
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"),
diff --git a/packages/editor/dist/es/extensions/scroll/index.js b/packages/editor/dist/es/extensions/scroll/index.js
deleted file mode 100644
index 7d6036306..000000000
--- a/packages/editor/dist/es/extensions/scroll/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./keep-in-view";
diff --git a/packages/editor/dist/es/extensions/scroll/scroll.d.ts b/packages/editor/dist/es/extensions/scroll/scroll.d.ts
deleted file mode 100644
index c0695030e..000000000
--- a/packages/editor/dist/es/extensions/scroll/scroll.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { Editor, Extension } from "@tiptap/core";
-export declare const Scroll: Extension<any, any>;
-export declare function keepLastLineInView(editor: Editor): void;
diff --git a/packages/editor/dist/es/extensions/scroll/scroll.js b/packages/editor/dist/es/extensions/scroll/scroll.js
deleted file mode 100644
index b5f96f60e..000000000
--- a/packages/editor/dist/es/extensions/scroll/scroll.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Extension, posToDOMRect } from "@tiptap/core";
-export const Scroll = Extension.create({
- 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 } = parent.style;
- if (overflow.split(" ").every((o) => o === "auto" || o === "scroll")) {
- return parent;
- }
- parent = parent.parentElement;
- }
- return document.documentElement;
-};
diff --git a/packages/editor/dist/es/toolbar/components/counter.js b/packages/editor/dist/es/toolbar/components/counter.js
index eae647190..32046dab1 100644
--- a/packages/editor/dist/es/toolbar/components/counter.js
+++ b/packages/editor/dist/es/toolbar/components/counter.js
@@ -18,6 +18,7 @@ function _Counter(props) {
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) => {
diff --git a/packages/editor/dist/es/toolbar/components/toolbutton.d.ts b/packages/editor/dist/es/toolbar/components/toolbutton.d.ts
index c0b3fc2f9..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?: "background" | "border" | "text" | "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/tools/font.js b/packages/editor/dist/es/toolbar/tools/font.js
index 951eaa8f6..08f0d5c74 100644
--- a/packages/editor/dist/es/toolbar/tools/font.js
+++ b/packages/editor/dist/es/toolbar/tools/font.js
@@ -45,6 +45,9 @@ function toMenuItems(editor, currentFontFamily) {
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;