chore: publish

This commit is contained in:
thecodrr
2022-07-08 12:32:20 +05:00
parent 4ab94fcf69
commit cc1ca84cc4
10 changed files with 19 additions and 17 deletions

View File

@@ -44,7 +44,7 @@ function CodeblockComponent(props) {
const preventUpdate = language === languageDefinition.filename;
updateAttributes({
language: languageDefinition.filename,
}, preventUpdate);
}, { preventUpdate, addToHistory: false });
});
})();
}, [language]);
@@ -103,7 +103,7 @@ function CodeblockComponent(props) {
location: "top",
yOffset: 5,
}, title: "Change code block language" }, { children: (0, jsx_runtime_1.jsx)(LanguageSelector, { selectedLanguage: (languageDefinition === null || languageDefinition === void 0 ? void 0 : languageDefinition.filename) || "Plaintext", onLanguageSelected: (language) => {
updateAttributes({ language });
updateAttributes({ language }, { addToHistory: true, preventUpdate: false });
setIsOpen(false);
}, onClose: () => setIsOpen(false) }) }))] }));
}

View File

@@ -30,7 +30,7 @@ function EmbedComponent(props) {
updateAttributes({
width: ref.clientWidth,
height: ref.clientHeight,
});
}, { addToHistory: true, preventUpdate: false });
}, lockAspectRatio: true }, { children: [(0, jsx_runtime_1.jsx)(rebass_1.Flex, Object.assign({ width: "100%", sx: {
position: "relative",
justifyContent: "end",

View File

@@ -60,7 +60,7 @@ function ImageComponent(props) {
updateAttributes({
width: ref.clientWidth,
height: ref.clientHeight,
});
}, { 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: {
position: "absolute",
top: -40,

View File

@@ -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, preventUpdate?: boolean): void;
updateAttributes(attributes: any, pos: number, addToHistory?: boolean, preventUpdate?: boolean): void;
update(node: PMNode, _decorations: readonly Decoration[], _innerDecorations: DecorationSource): boolean;
onDragStart(event: DragEvent): void;
stopEvent(event: Event): boolean;

View File

@@ -88,13 +88,12 @@ class ReactNodeView {
if (!this.options.component)
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, preventUpdate) => this.updateAttributes(attr, pos, preventUpdate) })) })));
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, options) => this.updateAttributes(attr, this.getPos(), options === null || options === void 0 ? void 0 : options.addToHistory, options === null || options === void 0 ? void 0 : options.preventUpdate) })) })));
}
updateAttributes(attributes, pos, preventUpdate = false) {
updateAttributes(attributes, pos, addToHistory = false, preventUpdate = false) {
this.editor.commands.command(({ tr }) => {
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), attributes));
tr.setMeta("addToHistory", false);
tr.setMeta("addToHistory", addToHistory);
tr.setMeta("preventUpdate", preventUpdate);
return true;
});

View File

@@ -83,7 +83,7 @@ class SelectionBasedNodeView extends reactnodeview_1.ReactNodeView {
const theme = this.editor.storage.theme;
const isSelected = this.editor.isEditable &&
(this.insideSelection() || this.nodeInsideSelection());
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, selected: isSelected, updateAttributes: (attr) => this.updateAttributes(attr, this.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, selected: isSelected, updateAttributes: (attr, options) => this.updateAttributes(attr, this.pos, options === null || options === void 0 ? void 0 : options.addToHistory, options === null || options === void 0 ? void 0 : options.preventUpdate) })) })));
}
/**
* Update current node's start and end positions.

View File

@@ -11,7 +11,10 @@ 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>, preventUpdate?: boolean) => void;
export declare type UpdateAttributes<T> = (attributes: Partial<T>, options?: {
addToHistory?: boolean;
preventUpdate?: boolean;
}) => void;
export declare type ContentDOM = {
dom: HTMLElement;
contentDOM?: HTMLElement | null | undefined;

View File

@@ -39,7 +39,7 @@ function TaskItemComponent(props) {
".icon:hover path": {
fill: "var(--checked) !important",
},
}, size: isMobile ? 24 : 20, onMouseDown: (e) => e.preventDefault() }), (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: checked ? icons_1.Icons.check : "", stroke: "1px", sx: {
}, size: isMobile ? 24 : 20 }), (0, jsx_runtime_1.jsx)(icon_1.Icon, { path: checked ? icons_1.Icons.check : "", stroke: "1px", sx: {
border: "2px solid",
borderColor: checked ? "checked" : "icon",
borderRadius: "default",
@@ -58,7 +58,7 @@ function TaskItemComponent(props) {
toggle();
}, color: checked ? "checked" : "icon", size: isMobile ? 16 : 14 }), (0, jsx_runtime_1.jsx)(rebass_1.Text, { as: "div", ref: forwardRef, sx: {
textDecorationLine: checked ? "line-through" : "none",
color: checked ? "var(--checked)" : "var(--text)",
opacity: checked ? 0.8 : 1,
flex: 1,
} })] })) }));
}

View File

@@ -62,7 +62,7 @@ function TaskListComponent(props) {
fill: "var(--checked) !important",
},
}, size: isMobile ? 24 : 20, onClick: () => {
updateAttributes({ collapsed: !collapsed });
updateAttributes({ collapsed: !collapsed }, { addToHistory: false, preventUpdate: true });
} })] }))) : ((0, jsx_runtime_1.jsxs)(rebass_1.Flex, Object.assign({ sx: {
position: "relative",
bg: "bgSecondary",
@@ -81,7 +81,7 @@ function TaskListComponent(props) {
left: 0,
transition: "width 250ms ease-out",
} }), (0, jsx_runtime_1.jsx)(forms_1.Input, { readOnly: !editor.isEditable, value: title || "", variant: "clean", sx: { p: 0, px: 2, zIndex: 1, color: "fontTertiary" }, placeholder: "Untitled", onChange: (e) => {
updateAttributes({ title: e.target.value });
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",

View File

@@ -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;