@blocknote/core 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +2043 -1918
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +20 -20
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +5 -4
- package/src/BlockNoteExtensions.ts +11 -11
- package/src/api/Editor.ts +90 -6
- package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +616 -0
- package/src/api/blockManipulation/blockManipulation.test.ts +172 -0
- package/src/api/blockManipulation/blockManipulation.ts +25 -14
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +346 -0
- package/src/api/formatConversions/formatConversions.test.ts +766 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +268 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +244 -0
- package/src/api/nodeConversions/nodeConversions.ts +167 -58
- package/src/api/nodeConversions/testUtil.ts +61 -0
- package/src/api/util/nodeUtil.ts +38 -0
- package/src/editor.module.css +1 -0
- package/src/extensions/Blocks/api/blockTypes.ts +14 -9
- package/src/extensions/Blocks/api/inlineContentTypes.ts +27 -36
- package/src/extensions/Blocks/nodes/Block.module.css +39 -36
- package/src/extensions/Blocks/nodes/BlockContainer.ts +15 -14
- package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +149 -87
- package/src/shared/utils.ts +6 -0
- package/types/src/BlockNoteEditor.d.ts +2 -2
- package/types/src/api/Editor.d.ts +26 -6
- package/types/src/api/blockManipulation/blockManipulation.d.ts +5 -5
- package/types/src/api/blockManipulation/blockManipulation.test.d.ts +1 -0
- package/types/src/api/formatConversions/formatConversions.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeConversions.d.ts +11 -4
- package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
- package/types/src/api/nodeConversions/testUtil.d.ts +2 -0
- package/types/src/api/util/nodeUtil.d.ts +8 -0
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +10 -9
- package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +25 -19
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +15 -0
- package/types/src/shared/utils.d.ts +3 -0
- package/types/src/EditorElement.d.ts +0 -7
- package/types/src/api/Document.d.ts +0 -5
- package/types/src/api/removeUnderlinesRehypePlugin.d.ts +0 -6
- package/types/src/api/simplifyBlocksRehypePlugin.d.ts +0 -16
- package/types/src/extensions/Blocks/BlockAttributes.d.ts +0 -2
- package/types/src/extensions/Blocks/MultipleNodeSelection.d.ts +0 -24
- package/types/src/extensions/Blocks/api/apiTypes.d.ts +0 -18
- package/types/src/extensions/Blocks/api/styleTypes.d.ts +0 -22
- package/types/src/extensions/Blocks/apiTypes.d.ts +0 -16
- package/types/src/extensions/Blocks/nodes/Block.d.ts +0 -24
- package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +0 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +0 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +0 -8
- package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +0 -8
- package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +0 -6
- package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +0 -8
- package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +0 -27
- package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +0 -44
- package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +0 -12
- package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +0 -18
- package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +0 -8
- package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +0 -11
- package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +0 -11
- package/types/src/extensions/Paragraph/FixedParagraph.d.ts +0 -1
- package/types/src/extensions/SlashMenu/defaultCommands.d.ts +0 -8
- package/types/src/utils.d.ts +0 -2
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Selection } from "prosemirror-state";
|
|
2
|
-
import { Node, ResolvedPos, Slice } from "prosemirror-model";
|
|
3
|
-
import { Mappable } from "prosemirror-transform";
|
|
4
|
-
/**
|
|
5
|
-
* This class represents an editor selection which spans multiple nodes/blocks. It's currently only used to allow users
|
|
6
|
-
* to drag multiple blocks at the same time. Expects the selection anchor and head to be between nodes, i.e. just before
|
|
7
|
-
* the first target node and just after the last, and that anchor and head are at the same nesting level.
|
|
8
|
-
*
|
|
9
|
-
* Partially based on ProseMirror's NodeSelection implementation:
|
|
10
|
-
* (https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.ts)
|
|
11
|
-
* MultipleNodeSelection differs from NodeSelection in the following ways:
|
|
12
|
-
* 1. Stores which nodes are included in the selection instead of just a single node.
|
|
13
|
-
* 2. Already expects the selection to start just before the first target node and ends just after the last, while a
|
|
14
|
-
* NodeSelection automatically sets both anchor and head to just before the single target node.
|
|
15
|
-
*/
|
|
16
|
-
export declare class MultipleNodeSelection extends Selection {
|
|
17
|
-
nodes: Array<Node>;
|
|
18
|
-
constructor($anchor: ResolvedPos, $head: ResolvedPos);
|
|
19
|
-
static create(doc: Node, from: number, to?: number): MultipleNodeSelection;
|
|
20
|
-
content(): Slice;
|
|
21
|
-
eq(selection: Selection): boolean;
|
|
22
|
-
map(doc: Node, mapping: Mappable): Selection;
|
|
23
|
-
toJSON(): any;
|
|
24
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type BlockSpec<Type extends string, Props extends Record<string, string>> = {
|
|
2
|
-
id: string;
|
|
3
|
-
children: Block[];
|
|
4
|
-
type: Type;
|
|
5
|
-
props: Props;
|
|
6
|
-
};
|
|
7
|
-
export type BlockSpecUpdate<Spec> = Spec extends BlockSpec<infer Type, infer Props> ? {
|
|
8
|
-
type: Type;
|
|
9
|
-
props?: Partial<Props>;
|
|
10
|
-
} : never;
|
|
11
|
-
export type NumberedListItemBlock = BlockSpec<"numberedListItem", {}>;
|
|
12
|
-
export type BulletListItemBlock = BlockSpec<"bulletListItem", {}>;
|
|
13
|
-
export type HeadingBlock = BlockSpec<"heading", {
|
|
14
|
-
level: "1" | "2" | "3";
|
|
15
|
-
}>;
|
|
16
|
-
export type ParagraphBlock = BlockSpec<"paragraph", {}>;
|
|
17
|
-
export type Block = ParagraphBlock | HeadingBlock | BulletListItemBlock | NumberedListItemBlock;
|
|
18
|
-
export type BlockUpdate = BlockSpecUpdate<Block>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type StyleTemplate<Type extends string, Props extends Record<string, string>> = {
|
|
2
|
-
type: Type;
|
|
3
|
-
props: Props;
|
|
4
|
-
};
|
|
5
|
-
export type Bold = StyleTemplate<"bold", {}>;
|
|
6
|
-
export type Italic = StyleTemplate<"italic", {}>;
|
|
7
|
-
export type Underline = StyleTemplate<"underline", {}>;
|
|
8
|
-
export type Strikethrough = StyleTemplate<"strike", {}>;
|
|
9
|
-
export type TextColor = StyleTemplate<"textColor", {
|
|
10
|
-
color: string;
|
|
11
|
-
}>;
|
|
12
|
-
export type BackgroundColor = StyleTemplate<"backgroundColor", {
|
|
13
|
-
color: string;
|
|
14
|
-
}>;
|
|
15
|
-
export type Link = StyleTemplate<"link", {
|
|
16
|
-
href: string;
|
|
17
|
-
}>;
|
|
18
|
-
export type Style = Bold | Italic | Underline | Strikethrough | TextColor | BackgroundColor | Link;
|
|
19
|
-
export type StyledText = {
|
|
20
|
-
text: string;
|
|
21
|
-
styles: Style[];
|
|
22
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type BlockSpec<Type extends string, Props extends Record<string, string>> = {
|
|
2
|
-
type: Type;
|
|
3
|
-
props: Props;
|
|
4
|
-
};
|
|
5
|
-
export type BlockSpecUpdate<Spec> = Spec extends BlockSpec<infer Type, infer Props> ? {
|
|
6
|
-
type: Type;
|
|
7
|
-
props?: Partial<Props>;
|
|
8
|
-
} : never;
|
|
9
|
-
export type NumberedListItemBlock = BlockSpec<"numberedListItem", {}>;
|
|
10
|
-
export type BulletListItemBlock = BlockSpec<"bulletListItem", {}>;
|
|
11
|
-
export type HeadingBlock = BlockSpec<"heading", {
|
|
12
|
-
level: "1" | "2" | "3";
|
|
13
|
-
}>;
|
|
14
|
-
export type ParagraphBlock = BlockSpec<"paragraph", {}>;
|
|
15
|
-
export type Block = ParagraphBlock | HeadingBlock | BulletListItemBlock | NumberedListItemBlock;
|
|
16
|
-
export type BlockUpdate = BlockSpecUpdate<Block>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Node } from "@tiptap/core";
|
|
2
|
-
import { TextContentType } from "./BlockTypes/TextBlock/TextContent";
|
|
3
|
-
import { HeadingContentType } from "./BlockTypes/HeadingBlock/HeadingContent";
|
|
4
|
-
import { ListItemContentType } from "./BlockTypes/ListItemBlock/ListItemContent";
|
|
5
|
-
export interface IBlock {
|
|
6
|
-
HTMLAttributes: Record<string, any>;
|
|
7
|
-
}
|
|
8
|
-
export declare type BlockContentType = TextContentType | HeadingContentType | ListItemContentType;
|
|
9
|
-
declare module "@tiptap/core" {
|
|
10
|
-
interface Commands<ReturnType> {
|
|
11
|
-
block: {
|
|
12
|
-
BNCreateBlock: (pos: number) => ReturnType;
|
|
13
|
-
BNDeleteBlock: (posInBlock: number) => ReturnType;
|
|
14
|
-
BNMergeBlocks: (posBetweenBlocks: number) => ReturnType;
|
|
15
|
-
BNSplitBlock: (posInBlock: number, keepType: boolean) => ReturnType;
|
|
16
|
-
BNSetContentType: (posInBlock: number, type: BlockContentType) => ReturnType;
|
|
17
|
-
BNCreateBlockOrSetContentType: (posInBlock: number, type: BlockContentType) => ReturnType;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The main "Block node" documents consist of
|
|
23
|
-
*/
|
|
24
|
-
export declare const Block: Node<IBlock, any>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { BubbleMenuFactory } from "./BubbleMenuFactoryTypes";
|
|
3
|
-
/**
|
|
4
|
-
* The menu that is displayed when selecting a piece of text.
|
|
5
|
-
*/
|
|
6
|
-
export declare const BubbleMenuExtension: Extension<{
|
|
7
|
-
bubbleMenuFactory: BubbleMenuFactory;
|
|
8
|
-
}, any>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EditorElement, ElementFactory } from "../../shared/EditorElement";
|
|
2
|
-
export declare type BubbleMenuParams = {
|
|
3
|
-
boldIsActive: boolean;
|
|
4
|
-
toggleBold: () => void;
|
|
5
|
-
italicIsActive: boolean;
|
|
6
|
-
toggleItalic: () => void;
|
|
7
|
-
underlineIsActive: boolean;
|
|
8
|
-
toggleUnderline: () => void;
|
|
9
|
-
strikeIsActive: boolean;
|
|
10
|
-
toggleStrike: () => void;
|
|
11
|
-
hyperlinkIsActive: boolean;
|
|
12
|
-
activeHyperlinkUrl: string;
|
|
13
|
-
activeHyperlinkText: string;
|
|
14
|
-
setHyperlink: (url: string, text?: string) => void;
|
|
15
|
-
paragraphIsActive: boolean;
|
|
16
|
-
setParagraph: () => void;
|
|
17
|
-
headingIsActive: boolean;
|
|
18
|
-
activeHeadingLevel: string;
|
|
19
|
-
setHeading: (level: string) => void;
|
|
20
|
-
setListItem: (type: string) => void;
|
|
21
|
-
listItemIsActive: boolean;
|
|
22
|
-
activeListItemType: string;
|
|
23
|
-
selectionBoundingBox: DOMRect;
|
|
24
|
-
editorElement: Element;
|
|
25
|
-
};
|
|
26
|
-
export declare type BubbleMenu = EditorElement<BubbleMenuParams>;
|
|
27
|
-
export declare type BubbleMenuFactory = ElementFactory<BubbleMenuParams>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
3
|
-
import { EditorView } from "prosemirror-view";
|
|
4
|
-
import { BubbleMenu, BubbleMenuFactory, BubbleMenuParams } from "./BubbleMenuFactoryTypes";
|
|
5
|
-
export interface BubbleMenuPluginProps {
|
|
6
|
-
pluginKey: PluginKey;
|
|
7
|
-
editor: Editor;
|
|
8
|
-
bubbleMenuFactory: BubbleMenuFactory;
|
|
9
|
-
shouldShow?: ((props: {
|
|
10
|
-
editor: Editor;
|
|
11
|
-
view: EditorView;
|
|
12
|
-
state: EditorState;
|
|
13
|
-
oldState?: EditorState;
|
|
14
|
-
from: number;
|
|
15
|
-
to: number;
|
|
16
|
-
}) => boolean) | null;
|
|
17
|
-
}
|
|
18
|
-
export declare type BubbleMenuViewProps = BubbleMenuPluginProps & {
|
|
19
|
-
view: EditorView;
|
|
20
|
-
};
|
|
21
|
-
export declare class BubbleMenuView {
|
|
22
|
-
editor: Editor;
|
|
23
|
-
view: EditorView;
|
|
24
|
-
bubbleMenuParams: BubbleMenuParams;
|
|
25
|
-
bubbleMenu: BubbleMenu;
|
|
26
|
-
preventHide: boolean;
|
|
27
|
-
preventShow: boolean;
|
|
28
|
-
menuIsOpen: boolean;
|
|
29
|
-
shouldShow: Exclude<BubbleMenuPluginProps["shouldShow"], null>;
|
|
30
|
-
constructor({ editor, bubbleMenuFactory, view, shouldShow, }: BubbleMenuViewProps);
|
|
31
|
-
viewMousedownHandler: () => void;
|
|
32
|
-
viewMouseupHandler: () => void;
|
|
33
|
-
dragstartHandler: () => void;
|
|
34
|
-
focusHandler: () => void;
|
|
35
|
-
blurHandler: ({ event }: {
|
|
36
|
-
event: FocusEvent;
|
|
37
|
-
}) => void;
|
|
38
|
-
update(view: EditorView, oldState?: EditorState): void;
|
|
39
|
-
destroy(): void;
|
|
40
|
-
getSelectionBoundingBox(): DOMRect;
|
|
41
|
-
initBubbleMenuParams(): BubbleMenuParams;
|
|
42
|
-
updateBubbleMenuParams(): void;
|
|
43
|
-
}
|
|
44
|
-
export declare const createBubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EditorElement, ElementFactory } from "../../shared/EditorElement";
|
|
2
|
-
export declare type BlockMenuParams = {
|
|
3
|
-
addBlock: () => void;
|
|
4
|
-
deleteBlock: () => void;
|
|
5
|
-
blockDragStart: (event: DragEvent) => void;
|
|
6
|
-
blockDragEnd: () => void;
|
|
7
|
-
freezeMenu: () => void;
|
|
8
|
-
unfreezeMenu: () => void;
|
|
9
|
-
blockBoundingBox: DOMRect;
|
|
10
|
-
};
|
|
11
|
-
export declare type BlockMenu = EditorElement<BlockMenuParams>;
|
|
12
|
-
export declare type BlockMenuFactory = ElementFactory<BlockMenuParams>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EditorElement, ElementFactory } from "../../shared/EditorElement";
|
|
2
|
-
export declare type AddBlockButtonParams = {
|
|
3
|
-
addBlock: () => void;
|
|
4
|
-
blockBoundingBox: DOMRect;
|
|
5
|
-
};
|
|
6
|
-
export declare type AddBlockButton = EditorElement<AddBlockButtonParams>;
|
|
7
|
-
export declare type AddBlockButtonFactory = ElementFactory<AddBlockButtonParams>;
|
|
8
|
-
export declare type DragHandleParams = {
|
|
9
|
-
blockBoundingBox: DOMRect;
|
|
10
|
-
};
|
|
11
|
-
export declare type DragHandle = EditorElement<DragHandleParams>;
|
|
12
|
-
export declare type DragHandleFactory = ElementFactory<DragHandleParams>;
|
|
13
|
-
export declare type DragHandleMenuParams = {
|
|
14
|
-
deleteBlock: () => void;
|
|
15
|
-
dragHandleBoundingBox: DOMRect;
|
|
16
|
-
};
|
|
17
|
-
export declare type DragHandleMenu = EditorElement<DragHandleMenuParams>;
|
|
18
|
-
export declare type DragHandleMenuFactory = ElementFactory<DragHandleMenuParams>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HyperlinkMenuPluginProps } from "./HyperlinkMenuPlugin";
|
|
2
|
-
/**
|
|
3
|
-
* This custom link includes a special menu for editing/deleting/opening the link.
|
|
4
|
-
* The menu will be triggered by hovering over the link with the mouse,
|
|
5
|
-
* or by moving the cursor inside the link text
|
|
6
|
-
*/
|
|
7
|
-
declare const Hyperlink: import("@tiptap/core").Mark<HyperlinkMenuPluginProps, any>;
|
|
8
|
-
export default Hyperlink;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EditorElement, ElementFactory } from "../../shared/EditorElement";
|
|
2
|
-
export declare type HyperlinkMenuParams = {
|
|
3
|
-
url: string;
|
|
4
|
-
text: string;
|
|
5
|
-
editHyperlink: (url: string, text: string) => void;
|
|
6
|
-
deleteHyperlink: () => void;
|
|
7
|
-
boundingBox: DOMRect;
|
|
8
|
-
editorElement: Element;
|
|
9
|
-
};
|
|
10
|
-
export declare type HyperlinkMenu = EditorElement<HyperlinkMenuParams>;
|
|
11
|
-
export declare type HyperlinkMenuFactory = ElementFactory<HyperlinkMenuParams>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
import { Plugin } from "prosemirror-state";
|
|
3
|
-
import { HyperlinkMenuFactory } from "./HyperlinkMenuFactoryTypes";
|
|
4
|
-
export declare type HyperlinkMenuPluginProps = {
|
|
5
|
-
hyperlinkMenuFactory: HyperlinkMenuFactory;
|
|
6
|
-
};
|
|
7
|
-
export declare type HyperlinkMenuViewProps = {
|
|
8
|
-
editor: Editor;
|
|
9
|
-
hyperlinkMenuFactory: HyperlinkMenuFactory;
|
|
10
|
-
};
|
|
11
|
-
export declare const createHyperlinkMenuPlugin: (editor: Editor, options: HyperlinkMenuPluginProps) => Plugin<any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const FixedParagraph: import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any>;
|
package/types/src/utils.d.ts
DELETED