editor: make imports esm compatible

This commit is contained in:
Abdullah Atta
2024-09-23 15:12:44 +05:00
parent 22559cdf42
commit f060c65bd5
151 changed files with 764 additions and 718 deletions

View File

@@ -26,7 +26,7 @@ import React, {
} from "react";
import { MenuItem, Icon, MenuButton, MenuSeparator } from "@notesnook/ui";
import { Box, Button, Flex, Text } from "@theme-ui/components";
import { Icons } from "../../toolbar/icons";
import { Icons } from "../../toolbar/icons.js";
import Modal from "react-modal";
import {
motion,

View File

@@ -28,13 +28,13 @@ import {
getPopupRoot,
getToolbarElement,
unmountPopupRoot
} from "../../toolbar/utils/dom";
} from "../../toolbar/utils/dom.js";
import {
useIsMobile,
useToolbarStore
} from "../../toolbar/stores/toolbar-store";
} from "../../toolbar/stores/toolbar-store.js";
import React from "react";
import { ResponsivePresenter, ResponsivePresenterProps } from "../responsive";
import { ResponsivePresenter, ResponsivePresenterProps } from "../responsive/index.js";
export type PopupWrapperProps = UsePopupHandlerOptions & {
autoCloseOnUnmount?: boolean;

View File

@@ -20,10 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { SchemeColors } from "@notesnook/theme";
import { Resizable } from "re-resizable";
import { PropsWithChildren } from "react";
import { Icons } from "../../toolbar";
import { Icons } from "../../toolbar/index.js";
import { Icon } from "@notesnook/ui";
import { Flex } from "@theme-ui/components";
import { getEditorDOM } from "../../toolbar/utils/dom";
import { getEditorDOM } from "../../toolbar/utils/dom.js";
type ResizerProps = {
enabled: boolean;

View File

@@ -18,17 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { PropsWithChildren } from "react";
import { useIsMobile } from "../../toolbar/stores/toolbar-store";
import { useIsMobile } from "../../toolbar/stores/toolbar-store.js";
import {
ActionSheetPresenter,
ActionSheetPresenterProps
} from "../action-sheet";
} from "../action-sheet/index.js";
import {
MenuPresenter,
MenuPresenterProps,
PopupPresenter
} from "@notesnook/ui";
import { getPopupContainer } from "../../toolbar/utils/dom";
import { getPopupContainer } from "../../toolbar/utils/dom.js";
type ResponsiveContainerProps = {
mobile?: JSX.Element;

View File

@@ -0,0 +1,50 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export type * from "@tiptap/extension-history";
export type * from "@tiptap/extension-character-count";
export type * from "@tiptap/extension-placeholder";
export type * from "@tiptap/extension-underline";
export type * from "@tiptap/starter-kit";
export type * from "@tiptap/extension-text-align";
export type * from "@tiptap/extension-subscript";
export type * from "@tiptap/extension-superscript";
export type * from "./extensions/font-size/index.js";
export type * from "./extensions/text-direction/index.js";
export type * from "@tiptap/extension-text-style";
export type * from "@tiptap/extension-font-family";
export type * from "./extensions/bullet-list/index.js";
export type * from "./extensions/ordered-list/index.js";
export type * from "@tiptap/extension-color";
export type * from "@tiptap/extension-table-row";
export type * from "./extensions/table-cell/index.js";
export type * from "./extensions/table-header/index.js";
export type * from "./extensions/image/index.js";
export type * from "./extensions/attachment/index.js";
export type * from "./extensions/task-list/index.js";
export type * from "./extensions/task-item/index.js";
export type * from "./extensions/search-replace/index.js";
export type * from "./extensions/embed/index.js";
export type * from "./extensions/code-block/index.js";
export type * from "./extensions/list-item/index.js";
export type * from "./extensions/outline-list/index.js";
export type * from "./extensions/outline-list-item/index.js";
export type * from "./extensions/table/index.js";
export type * from "./extensions/check-list/index.js";
export type * from "./extensions/check-list-item/index.js";

View File

@@ -1,49 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import "@tiptap/extension-character-count";
import "@tiptap/extension-placeholder";
import "@tiptap/extension-underline";
import "@tiptap/starter-kit";
import "@tiptap/extension-text-align";
import "@tiptap/extension-subscript";
import "@tiptap/extension-superscript";
import "./extensions/font-size";
import "./extensions/text-direction";
import "@tiptap/extension-text-style";
import "@tiptap/extension-font-family";
import "./extensions/bullet-list";
import "./extensions/ordered-list";
import "@tiptap/extension-color";
import "@tiptap/extension-table-row";
import "./extensions/table-cell";
import "./extensions/table-header";
import "./extensions/image";
import "./extensions/attachment";
import "./extensions/task-list";
import "./extensions/task-item";
import "./extensions/search-replace";
import "./extensions/embed";
import "./extensions/code-block";
import "./extensions/list-item";
import "./extensions/outline-list";
import "./extensions/outline-list-item";
import "./extensions/table";
import "./extensions/check-list";
import "./extensions/check-list-item";

View File

@@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Node, mergeAttributes, findChildren } from "@tiptap/core";
import { Attribute } from "@tiptap/core";
import { createNodeView } from "../react";
import { AttachmentComponent } from "./component";
import { Attachment } from "./types";
import { createNodeView } from "../react/index.js";
import { AttachmentComponent } from "./component.js";
import { Attachment } from "./types.js";
export type AttachmentType = "image" | "file" | "camera";
export interface AttachmentOptions {

View File

@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Box, Text } from "@theme-ui/components";
import { FileAttachment } from "./types";
import { FileAttachment } from "./types.js";
import { useRef, useState } from "react";
import { Icon } from "@notesnook/ui";
import { Icons } from "../../toolbar/icons";
import { ReactNodeViewProps } from "../react";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
import { DesktopOnly } from "../../components/responsive";
import { Icons } from "../../toolbar/icons.js";
import { ReactNodeViewProps } from "../react/index.js";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group.js";
import { DesktopOnly } from "../../components/responsive/index.js";
export function AttachmentComponent(props: ReactNodeViewProps<FileAttachment>) {
const { editor, node, selected } = props;

View File

@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./attachment";
export * from "./types";
export * from "./attachment.js";
export * from "./types.js";

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { BlockId } from "./block-id";
import { BlockId } from "./block-id.js";
export * from "./block-id";
export * from "./block-id.js";
export default BlockId;

View File

@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { getParentAttributes } from "../../utils/prosemirror";
import { getParentAttributes } from "../../utils/prosemirror.js";
import { wrappingInputRule } from "@tiptap/core";
import TiptapBlockquote, { inputRegex } from "@tiptap/extension-blockquote";

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Blockquote } from "./blockquote";
import { Blockquote } from "./blockquote.js";
export * from "./blockquote";
export * from "./blockquote.js";
export default Blockquote;

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import TiptapBulletList from "@tiptap/extension-bullet-list";
import { wrappingInputRule } from "@tiptap/core";
import { getParentAttributes } from "../../utils/prosemirror";
import { getParentAttributes } from "../../utils/prosemirror.js";
export const inputRegex = /^\s*([-+*])\s$/;
export const BulletList = TiptapBulletList.extend({

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { BulletList } from "./bullet-list";
import { BulletList } from "./bullet-list.js";
export * from "./bullet-list";
export * from "./bullet-list.js";
export default BulletList;

View File

@@ -16,15 +16,15 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { getParentAttributes } from "../../utils/prosemirror";
import { getParentAttributes } from "../../utils/prosemirror.js";
import {
InputRule,
Node,
findParentNodeClosestToPos,
mergeAttributes
} from "@tiptap/core";
import { Paragraph } from "../paragraph";
import { Heading } from "../heading";
import { Paragraph } from "../paragraph/index.js";
import { Heading } from "../heading/index.js";
import { TextSelection } from "@tiptap/pm/state";
import { Fragment } from "@tiptap/pm/model";

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./callout";
export * from "./callout.js";

View File

@@ -16,8 +16,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { CheckListItem } from "./check-list-item";
import { CheckListItem } from "./check-list-item.js";
export * from "./check-list-item";
export * from "./check-list-item.js";
export default CheckListItem;

View File

@@ -16,8 +16,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { CheckList } from "./check-list";
import { CheckList } from "./check-list.js";
export * from "./check-list";
export * from "./check-list.js";
export default CheckList;

View File

@@ -23,8 +23,8 @@ import {
} from "@tiptap/pm/model";
import { encodeNonAsciiHTML } from "entities";
import { Schema, Slice } from "prosemirror-model";
import { inferLanguage } from "../code-block";
import { hasPermission } from "../../types";
import { inferLanguage } from "../code-block/index.js";
import { hasPermission } from "../../types.js";
export class ClipboardDOMParser extends ProsemirrorDOMParser {
static fromSchema(schema: Schema): ClipboardDOMParser {

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { ResolvedPos, Slice } from "@tiptap/pm/model";
import { encodeNonAsciiHTML } from "entities";
import { ClipboardDOMParser } from "./clipboard-dom-parser";
import { ClipboardDOMParser } from "./clipboard-dom-parser.js";
import { EditorView } from "@tiptap/pm/view";
export function clipboardTextParser(

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { TextSerializer } from "@tiptap/core";
import { Schema, Slice } from "prosemirror-model";
import { ListItem } from "../list-item";
import { ListItem } from "../list-item/index.js";
import { EditorView } from "@tiptap/pm/view";
export function clipboardTextSerializer(content: Slice, view: EditorView) {

View File

@@ -20,11 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Extension } from "@tiptap/core";
import { Plugin, PluginKey } from "prosemirror-state";
import { Slice } from "prosemirror-model";
import { LIST_NODE_TYPES } from "../../utils/node-types";
import { ClipboardDOMParser } from "./clipboard-dom-parser";
import { ClipboardDOMSerializer } from "./clipboard-dom-serializer";
import { clipboardTextParser } from "./clipboard-text-parser";
import { clipboardTextSerializer } from "./clipboard-text-serializer";
import { LIST_NODE_TYPES } from "../../utils/node-types.js";
import { ClipboardDOMParser } from "./clipboard-dom-parser.js";
import { ClipboardDOMSerializer } from "./clipboard-dom-serializer.js";
import { clipboardTextParser } from "./clipboard-text-parser.js";
import { clipboardTextSerializer } from "./clipboard-text-serializer.js";
import { EditorView } from "prosemirror-view";
export const Clipboard = Extension.create({

View File

@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./clipboard";
export { Clipboard as default } from "./clipboard";
export * from "./clipboard.js";
export { Clipboard as default } from "./clipboard.js";

View File

@@ -22,7 +22,7 @@ import {
formatCodeblocks,
convertBrToSingleSpacedParagraphs,
convertGoogleDocsChecklist
} from "../clipboard-dom-parser";
} from "../clipboard-dom-parser.js";
const cases = [
[`<p>line 1<br>line 2</p>`],

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { test } from "vitest";
import { convertTextToHTML } from "../clipboard-text-parser";
import { convertTextToHTML } from "../clipboard-text-parser.js";
const cases = [
`Hello\r\nworld`,

View File

@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { test } from "vitest";
import { createEditor, h } from "../../../../test-utils";
import OrderedList from "../../ordered-list";
import { ListItem } from "../../list-item";
import { transformCopied } from "../index";
import { Paragraph } from "../../paragraph";
import { ClipboardDOMSerializer } from "../clipboard-dom-serializer";
import { clipboardTextSerializer } from "../clipboard-text-serializer";
import Link from "../../link";
import { createEditor, h } from "../../../../test-utils/index.js";
import OrderedList from "../../ordered-list/index.js";
import { ListItem } from "../../list-item/index.js";
import { transformCopied } from "../index.js";
import { Paragraph } from "../../paragraph/index.js";
import { ClipboardDOMSerializer } from "../clipboard-dom-serializer.js";
import { clipboardTextSerializer } from "../clipboard-text-serializer.js";
import Link from "../../link/index.js";
test("copied list items shouldn't contain extra newlines", (t) => {
const { editor } = createEditor({

View File

@@ -27,14 +27,15 @@ import {
Selection
} from "prosemirror-state";
import { ResolvedPos, Node as ProsemirrorNode, Slice } from "prosemirror-model";
import { CodeblockComponent } from "./component";
import { HighlighterPlugin } from "./highlighter";
import { createNodeView } from "../react";
import { CodeblockComponent } from "./component.js";
import { HighlighterPlugin } from "./highlighter.js";
import { createNodeView } from "../react/index.js";
import detectIndent from "detect-indent";
import redent from "redent";
import stripIndent from "strip-indent";
import { nanoid } from "nanoid";
import Languages from "./languages.json";
import { CaretPosition, CodeLine } from "./utils.js";
interface Indent {
type: "tab" | "space";
@@ -558,41 +559,6 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
}
});
export type CaretPosition = {
column: number;
line: number;
selected?: number;
total: number;
from: number;
};
export function toCaretPosition(
selection: Selection,
lines?: CodeLine[]
): CaretPosition | undefined {
const { $from, $to, $head } = selection;
if ($from.parent.type.name !== CodeBlock.name) return;
lines = lines || getLines($from.parent);
for (const line of lines) {
if ($head.pos >= line.from && $head.pos <= line.to) {
const lineLength = line.length + 1;
return {
line: line.index + 1,
column: lineLength - (line.to - $head.pos),
selected: $to.pos - $from.pos,
total: lines.length,
from: line.from
};
}
}
return;
}
export function getLines(node: ProsemirrorNode) {
const { lines } = node.attrs as CodeBlockAttributes;
return lines || [];
}
function exitOnTripleEnter(editor: Editor, $from: ResolvedPos) {
const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
@@ -639,46 +605,6 @@ function getNewline($from: ResolvedPos, options: Indent) {
};
}
type CodeLine = {
index: number;
from: number;
to: number;
length: number;
text: (length?: number) => string;
};
export function toCodeLines(code: string, pos: number): CodeLine[] {
const positions: CodeLine[] = [];
let start = 0;
let from = pos + 1;
let index = 0;
while (start <= code.length) {
let end = code.indexOf("\n", start);
if (end <= -1) end = code.length;
const lineLength = end - start;
const to = from + lineLength;
const lineStart = start;
positions.push({
index,
length: lineLength,
from,
to,
text: (length) => {
return code.slice(
lineStart,
length ? lineStart + length : lineStart + lineLength
);
}
});
from = to + 1;
start = end + 1;
++index;
}
return positions;
}
function getSelectedLines(lines: CodeLine[], selection: Selection) {
const { $from, $to } = selection;
return lines.filter(

View File

@@ -19,14 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Flex, Input, Text } from "@theme-ui/components";
import { useRef, useState } from "react";
import { Button } from "../../components/button";
import { ResponsivePresenter } from "../../components/responsive";
import { useTimer } from "../../hooks/use-timer";
import { Button } from "../../components/button.js";
import { ResponsivePresenter } from "../../components/responsive/index.js";
import { useTimer } from "../../hooks/use-timer.js";
import { Icon } from "@notesnook/ui";
import { Popup } from "../../toolbar/components/popup";
import { Icons } from "../../toolbar/icons";
import { ReactNodeViewProps } from "../react/types";
import { CodeBlockAttributes } from "./code-block";
import { Popup } from "../../toolbar/components/popup.js";
import { Icons } from "../../toolbar/icons.js";
import { ReactNodeViewProps } from "../react/types.js";
import { CodeBlockAttributes } from "./code-block.js";
import Languages from "./languages.json";
import { useThemeEngineStore } from "@notesnook/theme";

View File

@@ -24,13 +24,13 @@ import {
findParentNodeClosestToPos,
NodeWithPos
} from "@tiptap/core";
import { Root, refractor } from "refractor/lib/core";
import { Root, refractor } from "refractor/lib/core.js";
import { RootContent } from "hast";
import { ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
import { toCaretPosition, toCodeLines } from "./code-block";
import { toCaretPosition, toCodeLines } from "./utils.js";
import Languages from "./languages.json";
import { isLanguageLoaded, loadLanguage } from "./loader";
import { getChangedNodes } from "../../utils/prosemirror";
import { isLanguageLoaded, loadLanguage } from "./loader.js";
import { getChangedNodes } from "../../utils/prosemirror.js";
export type ReplaceMergedStep = ReplaceAroundStep | ReplaceStep;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./code-block";
export * from "./code-block.js";

View File

@@ -17,16 +17,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { loadLanguage as _loadLanguage } from "./languages/index.js";
const loadedLanguages: Record<string, boolean> = {};
export function isLanguageLoaded(name: string) {
return !!loadedLanguages[name];
}
export async function loadLanguage(shortName: string) {
const { default: language } = await import(
/* webpackChunkName: 'code-lang-[request]' */
`../../../languages/${shortName}.js`
);
const { default: language } = (await _loadLanguage(shortName)) || {};
loadedLanguages[shortName] = true;
return language;
}

View File

@@ -17,11 +17,11 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { createEditor, h } from "../../../../test-utils";
import { createEditor, h } from "../../../../test-utils/index.js";
import { expect, test, vi } from "vitest";
import { CodeBlock, inferLanguage } from "../code-block";
import { HighlighterPlugin } from "../highlighter";
import { getChangedNodes } from "../../../utils/prosemirror";
import { CodeBlock, inferLanguage } from "../code-block.js";
import { HighlighterPlugin } from "../highlighter.js";
import { getChangedNodes } from "../../../utils/prosemirror.js";
import { refractor } from "refractor/lib/core";
const CODEBLOCKS_HTML = h("div", [

View File

@@ -0,0 +1,99 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Node } from "@tiptap/pm/model";
import { Selection } from "@tiptap/pm/state";
import type { CodeBlockAttributes } from "./code-block.js";
export type CodeLine = {
index: number;
from: number;
to: number;
length: number;
text: (length?: number) => string;
};
export type CaretPosition = {
column: number;
line: number;
selected?: number;
total: number;
from: number;
};
export function toCodeLines(code: string, pos: number): CodeLine[] {
const positions: CodeLine[] = [];
let start = 0;
let from = pos + 1;
let index = 0;
while (start <= code.length) {
let end = code.indexOf("\n", start);
if (end <= -1) end = code.length;
const lineLength = end - start;
const to = from + lineLength;
const lineStart = start;
positions.push({
index,
length: lineLength,
from,
to,
text: (length) => {
return code.slice(
lineStart,
length ? lineStart + length : lineStart + lineLength
);
}
});
from = to + 1;
start = end + 1;
++index;
}
return positions;
}
export function toCaretPosition(
selection: Selection,
lines?: CodeLine[]
): CaretPosition | undefined {
const { $from, $to, $head } = selection;
if ($from.parent.type.name !== "codeblock") return;
lines = lines || getLines($from.parent);
for (const line of lines) {
if ($head.pos >= line.from && $head.pos <= line.to) {
const lineLength = line.length + 1;
return {
line: line.index + 1,
column: lineLength - (line.to - $head.pos),
selected: $to.pos - $from.pos,
total: lines.length,
from: line.from
};
}
}
return;
}
export function getLines(node: Node) {
const { lines } = node.attrs as CodeBlockAttributes;
return lines || [];
}

View File

@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./code-mark";
export { Codemark as default } from "./code-mark";
export * from "./code-mark.js";
export { Codemark as default } from "./code-mark.js";

View File

@@ -23,9 +23,7 @@ import {
InputRuleFinder,
ExtendedRegExpMatchArray
} from "@tiptap/core";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { formatDate } from "@notesnook/core/dist/utils/date";
import { formatDate } from "@notesnook/common";
declare module "@tiptap/core" {
interface Commands<ReturnType> {

View File

@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./date-time";
export { DateTime as default } from "./date-time";
export * from "./date-time.js";
export { DateTime as default } from "./date-time.js";

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./diff-highlighter";
export * from "./diff-highlighter.js";

View File

@@ -19,13 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Box, Flex, Embed } from "@theme-ui/components";
import { useRef, useState } from "react";
import { EmbedAlignmentOptions, EmbedAttributes } from "./embed";
import { ReactNodeViewProps } from "../react";
import { DesktopOnly } from "../../components/responsive";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
import { Icons } from "../../toolbar";
import { EmbedAlignmentOptions, EmbedAttributes } from "./embed.js";
import { ReactNodeViewProps } from "../react/index.js";
import { DesktopOnly } from "../../components/responsive/index.js";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group.js";
import { Icons } from "../../toolbar/index.js";
import { Icon } from "@notesnook/ui";
import { Resizer } from "../../components/resizer";
import { Resizer } from "../../components/resizer/index.js";
export function EmbedComponent(
props: ReactNodeViewProps<EmbedAttributes & EmbedAlignmentOptions>

View File

@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Node, mergeAttributes } from "@tiptap/core";
import { hasSameAttributes } from "../../utils/prosemirror";
import { createNodeView } from "../react";
import { TextDirections } from "../text-direction";
import { EmbedComponent } from "./component";
import { hasSameAttributes } from "../../utils/prosemirror.js";
import { createNodeView } from "../react/index.js";
import { TextDirections } from "../text-direction/index.js";
import { EmbedComponent } from "./component.js";
export interface EmbedOptions {
HTMLAttributes: Record<string, unknown>;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./embed";
export * from "./embed.js";

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import "@tiptap/extension-text-style";
import { Extension } from "@tiptap/core";
import { getFontById } from "../../utils/font";
import { getFontById } from "../../utils/font.js";
export type FontFamilyOptions = {
types: string[];

View File

@@ -16,8 +16,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { FontFamily } from "./font-family";
import { FontFamily } from "./font-family.js";
export * from "./font-family";
export * from "./font-family.js";
export default FontFamily;

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useToolbarStore } from "../../toolbar/stores/toolbar-store";
import { useToolbarStore } from "../../toolbar/stores/toolbar-store.js";
import { Editor, Extension } from "@tiptap/core";
type FontSizeOptions = {

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { FontSize } from "./font-size";
import { FontSize } from "./font-size.js";
export * from "./font-size";
export * from "./font-size.js";
export default FontSize;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./heading";
export * from "./heading.js";

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./highlight";
export * from "./highlight.js";

View File

@@ -19,29 +19,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { ThemeUIStyleObject } from "@theme-ui/core";
import { Box, Flex, Image, Text } from "@theme-ui/components";
import { ImageAttributes } from "./image";
import { ImageAttributes } from "./image.js";
import { useEffect, useRef, useState } from "react";
import { ReactNodeViewProps } from "../react";
import { DesktopOnly } from "../../components/responsive";
import { ReactNodeViewProps } from "../react/index.js";
import { DesktopOnly } from "../../components/responsive/index.js";
import { Icon } from "@notesnook/ui";
import { Icons } from "../../toolbar/icons";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
import { Icons } from "../../toolbar/icons.js";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group.js";
import {
useIsMobile,
useToolbarStore
} from "../../toolbar/stores/toolbar-store";
import { Resizer } from "../../components/resizer";
} from "../../toolbar/stores/toolbar-store.js";
import { Resizer } from "../../components/resizer/index.js";
import {
corsify,
downloadImage,
revokeBloburl,
toBlobURL,
toDataURL
} from "../../utils/downloader";
} from "../../utils/downloader.js";
import { motion } from "framer-motion";
import { useObserver } from "../../hooks/use-observer";
import { Attachment, ImageAlignmentOptions } from "../attachment";
import DataURL from "@notesnook/core/dist/utils/dataurl";
import { useObserver } from "../../hooks/use-observer.js";
import { Attachment, ImageAlignmentOptions } from "../attachment/index.js";
import { DataURL } from "@notesnook/common";
export const AnimatedImage = motion(Image);

View File

@@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Node, nodeInputRule, mergeAttributes } from "@tiptap/core";
import { hasSameAttributes } from "../../utils/prosemirror";
import { hasSameAttributes } from "../../utils/prosemirror.js";
import {
ImageAlignmentOptions,
ImageAttachment,
getDataAttribute
} from "../attachment";
import { createNodeView } from "../react";
import { TextDirections } from "../text-direction";
import { ImageComponent } from "./component";
} from "../attachment/index.js";
import { createNodeView } from "../react/index.js";
import { TextDirections } from "../text-direction/index.js";
import { ImageComponent } from "./component.js";
export interface ImageOptions {
inline: boolean;
@@ -56,7 +56,7 @@ declare module "@tiptap/core" {
}
}
export const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
export const ImageNode = Node.create<ImageOptions>({
name: "image",

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./image";
export * from "./image.js";

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./keep-in-view";
export * from "./keep-in-view.js";

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Editor, Extension, posToDOMRect } from "@tiptap/core";
import { inlineDebounce } from "../../utils/debounce";
import { inlineDebounce } from "../../utils/debounce.js";
type KeepInViewOptions = {
scrollIntoViewOnWindowResize: boolean;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./key-map";
export * from "./key-map.js";

View File

@@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Extension } from "@tiptap/core";
import { isInTable } from "@tiptap/pm/tables";
import { isListActive } from "../../utils/prosemirror";
import { CodeBlock } from "../code-block";
import { showLinkPopup } from "../../toolbar/popups/link-popup";
import { CodeBlock } from "../code-block/index.js";
import { showLinkPopup } from "../../toolbar/popups/link-popup.js";
import { isListActive } from "../../utils/list.js";
export const KeyMap = Extension.create({
name: "key-map",

View File

@@ -16,8 +16,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Link } from "./link";
import { Link } from "./link.js";
export * from "./link";
export * from "./link.js";
export default Link;

View File

@@ -29,11 +29,11 @@ import {
} from "@tiptap/core";
import { Plugin, TextSelection } from "@tiptap/pm/state";
import { find, registerCustomProtocol, reset } from "linkifyjs";
import { autolink } from "./helpers/autolink";
import { clickHandler } from "./helpers/clickHandler";
import { pasteHandler } from "./helpers/pasteHandler";
import { ImageNode } from "../image";
import { selectionToOffset } from "../../utils/prosemirror";
import { autolink } from "./helpers/autolink.js";
import { clickHandler } from "./helpers/clickHandler.js";
import { pasteHandler } from "./helpers/pasteHandler.js";
import { ImageNode } from "../image/index.js";
import { selectionToOffset } from "../../utils/prosemirror.js";
export interface LinkProtocolOptions {
scheme: string;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./list-item";
export * from "./list-item.js";

View File

@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export { MathInline } from "./math-inline";
export { MathBlock } from "./math-block";
export { MathInline } from "./math-inline.js";
export { MathBlock } from "./math-block.js";

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Node, mergeAttributes } from "@tiptap/core";
import { insertMathNode } from "./plugin";
import { insertMathNode } from "./plugin/index.js";
import { NodeSelection } from "prosemirror-state";
declare module "@tiptap/core" {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Node, mergeAttributes } from "@tiptap/core";
import { mathPlugin } from "./plugin";
import { mathPlugin } from "./plugin/index.js";
declare module "@tiptap/core" {
interface Commands<ReturnType> {

View File

@@ -23,22 +23,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*--------------------------------------------------------*/
// core functionality
export { MathView, type ICursorPosObserver } from "./math-node-view";
export { MathView, type ICursorPosObserver } from "./math-node-view.js";
export {
mathPlugin,
createMathView,
type IMathPluginState
} from "./math-plugin";
} from "./math-plugin.js";
// recommended plugins
export { mathBackspaceCmd } from "./plugins/math-backspace";
export { mathBackspaceCmd } from "./plugins/math-backspace.js";
// optional / experimental plugins
export { mathSelectPlugin } from "./plugins/math-select";
export { mathSelectPlugin } from "./plugins/math-select.js";
// commands
export { insertMathNode } from "./commands/insert-math-node";
export { insertMathNode } from "./commands/insert-math-node.js";
// utilities
export { mathSerializer } from "./utils/text-serializer";
export * from "./utils/types";
export { mathSerializer } from "./utils/text-serializer.js";
export * from "./utils/types.js";

View File

@@ -44,9 +44,9 @@ import {
deleteSelection
} from "prosemirror-commands";
import { collapseMathNode } from "./commands/collapse-math-node";
import { IMathPluginState } from "./math-plugin";
import { MathRenderFn } from "./renderers/types";
import { collapseMathNode } from "./commands/collapse-math-node.js";
import { IMathPluginState } from "./math-plugin.js";
import { MathRenderFn } from "./renderers/types.js";
type FragmentWithContent = Fragment & { content: ProseNode[] };

View File

@@ -29,9 +29,9 @@ import {
PluginKey,
PluginSpec
} from "prosemirror-state";
import { MathView } from "./math-node-view";
import { MathView } from "./math-node-view.js";
import { EditorView } from "prosemirror-view";
import { KatexRenderer } from "./renderers/katex";
import { KatexRenderer } from "./renderers/katex.js";
////////////////////////////////////////////////////////////

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { MathRenderer } from "./types";
import { MathRenderer } from "./types.js";
async function loadKatex() {
const { default: katex } = await import("katex");
@@ -25,7 +25,7 @@ async function loadKatex() {
// Chemistry formulas support
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore TODO: maybe rewrite this in typescript?
await import("katex/contrib/mhchem/mhchem");
await import("katex/contrib/mhchem/mhchem.js");
return katex;
}

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { OrderedList } from "./ordered-list";
import { OrderedList } from "./ordered-list.js";
export * from "./ordered-list";
export * from "./ordered-list.js";
export default OrderedList;

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { wrappingInputRule } from "@tiptap/core";
import TiptapOrderedList, { inputRegex } from "@tiptap/extension-ordered-list";
import { getParentAttributes } from "../../utils/prosemirror";
import { getParentAttributes } from "../../utils/prosemirror.js";
export const OrderedList = TiptapOrderedList.extend({
addAttributes() {

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./outline-list-item";
export * from "./outline-list-item.js";

View File

@@ -22,8 +22,8 @@ import {
mergeAttributes,
findParentNodeClosestToPos
} from "@tiptap/core";
import { findParentNodeOfTypeClosestToPos } from "../../utils/prosemirror";
import { OutlineList } from "../outline-list/outline-list";
import { findParentNodeOfTypeClosestToPos } from "../../utils/prosemirror.js";
import { OutlineList } from "../outline-list/outline-list.js";
export interface ListItemOptions {
HTMLAttributes: Record<string, unknown>;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./outline-list";
export * from "./outline-list.js";

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { getParentAttributes } from "../../utils/prosemirror";
import { getParentAttributes } from "../../utils/prosemirror.js";
import { Node, mergeAttributes, wrappingInputRule } from "@tiptap/core";
export type OutlineListAttributes = {
@@ -41,7 +41,7 @@ declare module "@tiptap/core" {
}
}
export const inputRegex = /^\s*(-o)\s$/;
const inputRegex = /^\s*(-o)\s$/;
const outlineListItemName = "outlineListItem";
export const OutlineList = Node.create<OutlineListOptions>({
name: "outlineList",

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./paragraph";
export * from "./paragraph.js";

View File

@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./quirks";
export { Quirks as default } from "./quirks";
export * from "./quirks.js";
export { Quirks as default } from "./quirks.js";

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Editor, Extension, findParentNode } from "@tiptap/core";
import { EditorState, Selection } from "@tiptap/pm/state";
import { isAndroid } from "../../utils/platform";
import { isAndroid } from "../../utils/platform.js";
export type QuirksOptions = {
/**

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./react-node-view";
export * from "./types";
export * from "./react-portal-provider";
export * from "./event-dispatcher";
export * from "./react-node-view.js";
export * from "./types.js";
export * from "./react-portal-provider.js";
export * from "./event-dispatcher.js";

View File

@@ -21,18 +21,18 @@ import React, { FunctionComponent, SyntheticEvent } from "react";
import { NodeView, Decoration, DecorationSource } from "prosemirror-view";
import { Node as PMNode, Slice } from "prosemirror-model";
import { NodeSelection } from "prosemirror-state";
import { PortalProviderAPI } from "./react-portal-provider";
import { PortalProviderAPI } from "./react-portal-provider.js";
import {
ReactNodeViewProps,
ReactNodeViewOptions,
GetPosNode,
ContentDOM
} from "./types";
} from "./types.js";
import { Editor, NodeViewRendererProps } from "@tiptap/core";
import { __serializeForClipboard, EditorView } from "prosemirror-view";
import { EmotionThemeProvider } from "@notesnook/theme";
import { isAndroid, isiOS } from "../../utils/platform";
import { useToolbarStore } from "../../toolbar/stores/toolbar-store";
import { isAndroid, isiOS } from "../../utils/platform.js";
import { useToolbarStore } from "../../toolbar/stores/toolbar-store.js";
// This is hacky workaround to manually handle serialization when
// drag/dropping on mobile devices.

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { FunctionComponent, PropsWithChildren } from "react";
import { flushSync } from "react-dom";
import { EventDispatcher } from "./event-dispatcher";
import { EventDispatcher } from "./event-dispatcher.js";
import { Root, createRoot } from "react-dom/client";
export type BasePortalProviderProps = PropsWithChildren<unknown>;

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Editor } from "../../types";
import { Editor } from "../../types.js";
import { Node as PMNode, Attrs } from "prosemirror-model";
export interface ReactNodeProps {

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./search-replace";
export * from "./search-replace.js";

View File

@@ -26,7 +26,7 @@ import {
Transaction,
TextSelection
} from "prosemirror-state";
import { SearchSettings } from "../../toolbar/stores/search-store";
import { SearchSettings } from "../../toolbar/stores/search-store.js";
type DispatchFn = (tr: Transaction) => void;
declare module "@tiptap/core" {

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { TableCell } from "./table-cell";
import { TableCell } from "./table-cell.js";
export * from "./table-cell";
export * from "./table-cell.js";
export default TableCell;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import TiptapTableCell from "@tiptap/extension-table-cell";
import { addStyleAttribute } from "./utils";
import { addStyleAttribute } from "./utils.js";
export const TableCell = TiptapTableCell.extend({
addAttributes() {

View File

@@ -16,8 +16,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { TableHeader } from "./table-header";
import { TableHeader } from "./table-header.js";
export * from "./table-header";
export * from "./table-header.js";
export default TableHeader;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import TipTapTableHeader from "@tiptap/extension-table-header";
import { addStyleAttribute } from "../table-cell/utils";
import { addStyleAttribute } from "../table-cell/utils.js";
export const TableHeader = TipTapTableHeader.extend({
addAttributes() {

View File

@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Flex } from "@theme-ui/components";
import { ReactNodeView, ReactNodeViewProps } from "../react";
import { ReactNodeView, ReactNodeViewProps } from "../react/index.js";
import { Node as ProsemirrorNode } from "prosemirror-model";
import { Editor } from "../../types";
import { Editor } from "../../types.js";
import { Editor as TiptapEditor } from "@tiptap/core";
import { useEffect, useRef } from "react";
import { updateColumnsOnResize } from "@tiptap/pm/tables";
@@ -30,15 +30,15 @@ import {
InsertRowBelow,
RowProperties,
TableProperties
} from "../../toolbar/tools/table";
import { getToolDefinition } from "../../toolbar/tool-definitions";
} from "../../toolbar/tools/table.js";
import { getToolDefinition } from "../../toolbar/tool-definitions.js";
import { getPosition } from "@notesnook/ui";
import {
findSelectedDOMNode,
hasSameAttributes
} from "../../utils/prosemirror";
import { DesktopOnly } from "../../components/responsive";
import { TextDirections } from "../text-direction";
} from "../../utils/prosemirror.js";
import { DesktopOnly } from "../../components/responsive/index.js";
import { TextDirections } from "../text-direction/index.js";
export function TableComponent(props: ReactNodeViewProps) {
const { editor, node, forwardRef } = props;

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./table";
export * from "./table.js";

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Table as TiptapTable, TableOptions } from "@tiptap/extension-table";
import { tableEditing, columnResizing, TableView } from "@tiptap/pm/tables";
import { TableNodeView } from "./component";
import { TableNodeView } from "./component.js";
import { Plugin, PluginKey } from "prosemirror-state";
export const Table = TiptapTable.extend<TableOptions>({

View File

@@ -18,15 +18,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Box, Flex } from "@theme-ui/components";
import { ReactNodeViewProps } from "../react";
import { ReactNodeViewProps } from "../react/index.js";
import { Icon } from "@notesnook/ui";
import { Icons } from "../../toolbar/icons";
import { Icons } from "../../toolbar/icons.js";
import { findChildrenInRange } from "@tiptap/core";
import { useCallback } from "react";
import { TaskItemNode, TaskItemAttributes } from "./task-item";
import { useIsMobile } from "../../toolbar/stores/toolbar-store";
import { isiOS } from "../../utils/platform";
import { DesktopOnly } from "../../components/responsive";
import type { TaskItemAttributes } from "./task-item.js";
import { useIsMobile } from "../../toolbar/stores/toolbar-store.js";
import { isiOS } from "../../utils/platform.js";
import { DesktopOnly } from "../../components/responsive/index.js";
import TaskItem from "@tiptap/extension-task-item";
export function TaskItemComponent(
props: ReactNodeViewProps<TaskItemAttributes>
@@ -42,7 +43,7 @@ export function TaskItemComponent(
const selectedTaskItems = findChildrenInRange(
editor.state.doc,
{ from, to },
(node) => node.type.name === TaskItemNode.name
(node) => node.type.name === TaskItem.name
);
if (!empty && selectedTaskItems.findIndex((a) => a.node === node) > -1) {
editor.commands.command(({ tr }) => {

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./task-item";
export * from "./task-item.js";

View File

@@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { mergeAttributes } from "@tiptap/core";
import { TaskItem } from "@tiptap/extension-task-item";
import { TaskItemComponent } from "./component";
import { createNodeView } from "../react";
import { TaskItemComponent } from "./component.js";
import { createNodeView } from "../react/index.js";
export type TaskItemAttributes = {
checked: boolean;

View File

@@ -19,15 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Box, Flex, Input, Text } from "@theme-ui/components";
import { useMemo } from "react";
import { ToolButton } from "../../toolbar/components/tool-button";
import { ReactNodeViewProps } from "../react";
import { toggleChildren, type TaskListAttributes } from "./task-list";
import { replaceDateTime } from "../date-time";
import { deleteCheckedItems, sortList } from "./utils";
import { ToolButton } from "../../toolbar/components/tool-button.js";
import { ReactNodeViewProps } from "../react/index.js";
import { type TaskListAttributes } from "./task-list.js";
import { replaceDateTime } from "../date-time/index.js";
import { deleteCheckedItems, sortList, toggleChildren } from "./utils.js";
import TaskList from "@tiptap/extension-task-list";
import TaskItem from "@tiptap/extension-task-item";
import { useIsMobile } from "../../toolbar/stores/toolbar-store";
import { Icons } from "../../toolbar/icons";
import { useIsMobile } from "../../toolbar/stores/toolbar-store.js";
import { Icons } from "../../toolbar/icons.js";
import { Icon } from "@notesnook/ui";
export function TaskListComponent(

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./task-list";
export * from "./task-list.js";

View File

@@ -19,14 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { mergeAttributes, wrappingInputRule } from "@tiptap/core";
import { TaskList } from "@tiptap/extension-task-list";
import { createNodeView } from "../react";
import { TaskListComponent } from "./component";
import {
Plugin,
PluginKey,
NodeSelection,
Transaction
} from "prosemirror-state";
import { createNodeView } from "../react/index.js";
import { TaskListComponent } from "./component.js";
import { Plugin, PluginKey, NodeSelection } from "prosemirror-state";
import { inputRegex } from "@tiptap/extension-task-item";
import { dropPoint } from "prosemirror-transform";
import {
@@ -36,10 +31,10 @@ import {
hasSameAttributes,
findParentNodeClosestToPos,
getExactChangedNodes
} from "../../utils/prosemirror";
import { countCheckedItems, findRootTaskList } from "./utils";
} from "../../utils/prosemirror.js";
import { countCheckedItems, findRootTaskList, toggleChildren } from "./utils.js";
import { Node as ProsemirrorNode } from "@tiptap/pm/model";
import { TaskItemNode } from "../task-item";
import { TaskItemNode } from "../task-item/index.js";
type TaskListStats = { checked: number; total: number };
export type TaskListAttributes = {
@@ -396,26 +391,3 @@ function areAllChecked(node: ProsemirrorNode) {
}
return allChecked;
}
export function toggleChildren(
tr: Transaction,
node: ProsemirrorNode,
toggleState: boolean,
parentPos: number
) {
let changes = 0;
node.descendants((node, pos) => {
if (
node.type.name === TaskItemNode.name &&
toggleState !== node.attrs.checked
) {
const actualPos = pos + parentPos + 1;
tr.setNodeMarkup(tr.mapping.map(actualPos), undefined, {
...node.attrs,
checked: toggleState
});
changes++;
}
});
return changes;
}

View File

@@ -17,12 +17,12 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { createEditor, h, ul, li } from "../../../../test-utils";
import { createEditor, h, ul, li } from "../../../../test-utils/index.js";
import { test, expect } from "vitest";
import { TaskListNode } from "../index";
import { TaskItemNode } from "../../task-item";
import { TaskListNode } from "../index.js";
import { TaskItemNode } from "../../task-item/index.js";
import { p, eq } from "prosemirror-test-builder";
import { countCheckedItems, deleteCheckedItems, sortList } from "../utils";
import { countCheckedItems, deleteCheckedItems, sortList } from "../utils.js";
function taskList(...children: HTMLLIElement[]) {
return ul(children, { class: "checklist" });

View File

@@ -21,8 +21,9 @@ import TaskList from "@tiptap/extension-task-list";
import { Transaction } from "@tiptap/pm/state";
import { Fragment, Node as ProsemirrorNode } from "prosemirror-model";
import { NodeWithPos } from "@tiptap/core";
import { findParentNodeClosestToPos } from "../../utils/prosemirror";
import { findParentNodeClosestToPos } from "../../utils/prosemirror.js";
import TaskItem from "@tiptap/extension-task-item";
import { TaskItemNode } from "../task-item/index.js";
export function countCheckedItems(node: ProsemirrorNode) {
let checked = 0;
@@ -133,3 +134,26 @@ export function findRootTaskList(doc: ProsemirrorNode, pos?: number) {
(!parent || !invalidTaskListParents.includes(parent.type.name))
);
}
export function toggleChildren(
tr: Transaction,
node: ProsemirrorNode,
toggleState: boolean,
parentPos: number
) {
let changes = 0;
node.descendants((node, pos) => {
if (
node.type.name === TaskItemNode.name &&
toggleState !== node.attrs.checked
) {
const actualPos = pos + parentPos + 1;
tr.setNodeMarkup(tr.mapping.map(actualPos), undefined, {
...node.attrs,
checked: toggleState
});
changes++;
}
});
return changes;
}

View File

@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { TextDirection } from "./text-direction";
import { TextDirection } from "./text-direction.js";
export * from "./text-direction";
export * from "./text-direction.js";
export default TextDirection;

View File

@@ -17,11 +17,11 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { isListActive } from "../../utils/prosemirror";
import { Extension, Editor, findParentNode } from "@tiptap/core";
import "@tiptap/extension-text-style";
import { Paragraph } from "../paragraph";
import { Paragraph } from "../paragraph/index.js";
import { Node as ProsemirrorNode } from "@tiptap/pm/model";
import { isListActive } from "../../utils/list.js";
export type TextDirections = undefined | "rtl";
const TEXT_DIRECTION_TYPES = [

View File

@@ -19,12 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Box, Flex, Text } from "@theme-ui/components";
import { useEffect, useRef, useState } from "react";
import { ReactNodeViewProps } from "../react";
import { Icons } from "../../toolbar";
import { ReactNodeViewProps } from "../react/index.js";
import { Icons } from "../../toolbar/index.js";
import { Icon } from "@notesnook/ui";
import { WebClipAttributes } from "./web-clip";
import { DesktopOnly } from "../../components/responsive";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group";
import { WebClipAttributes } from "./web-clip.js";
import { DesktopOnly } from "../../components/responsive/index.js";
import { ToolbarGroup } from "../../toolbar/components/toolbar-group.js";
const FAILED_CONTENT = `<html><head>
<title>Failed to load web clip</title>

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./web-clip";
export * from "./web-clip.js";

View File

@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Node, mergeAttributes } from "@tiptap/core";
import { hasSameAttributes } from "../../utils/prosemirror";
import { WebClipAttachment, getDataAttribute } from "../attachment";
import { createNodeView } from "../react";
import { WebClipComponent } from "./component";
import { hasSameAttributes } from "../../utils/prosemirror.js";
import { WebClipAttachment, getDataAttribute } from "../attachment/index.js";
import { createNodeView } from "../react/index.js";
import { WebClipComponent } from "./component.js";
export interface WebClipOptions {
HTMLAttributes: Record<string, unknown>;

View File

@@ -24,9 +24,9 @@ import {
resolveFocusPosition
} from "@tiptap/core";
import { DependencyList, useEffect, useMemo, useRef, useState } from "react";
import { Editor } from "../types";
import { Editor } from "../types.js";
import { EditorState } from "@tiptap/pm/state";
import { useToolbarStore } from "../toolbar/stores/toolbar-store";
import { useToolbarStore } from "../toolbar/stores/toolbar-store.js";
function useForceUpdate() {
const [, setValue] = useState(0);

View File

@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useState, useRef, useEffect, useCallback } from "react";
import { debounce } from "../utils/debounce";
type ObserverType = {
threshold: number;

Some files were not shown because too many files have changed in this diff Show More