@blocknote/core 0.26.0 → 0.27.0
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.cjs +11 -10
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +3685 -9960
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/en-B7ycW7c8.js +360 -0
- package/dist/en-B7ycW7c8.js.map +1 -0
- package/dist/en-D4taoCs4.cjs +2 -0
- package/dist/en-D4taoCs4.cjs.map +1 -0
- package/dist/locales.cjs +2 -0
- package/dist/locales.cjs.map +1 -0
- package/dist/locales.js +6129 -0
- package/dist/locales.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +36 -27
- package/src/api/clipboard/__snapshots__/internal/basicBlocks.html +1 -1
- package/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +1 -1
- package/src/api/clipboard/clipboardExternal.test.ts +1 -1
- package/src/api/clipboard/clipboardInternal.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -0
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +96 -42
- package/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/python/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html +1 -1
- package/src/api/exporters/html/htmlConversion.test.ts +2 -2
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +4 -4
- package/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/complex/misc/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/lists/basic/markdown.md +8 -6
- package/src/api/exporters/markdown/__snapshots__/lists/nested/markdown.md +6 -6
- package/src/api/exporters/markdown/markdownExporter.test.ts +2 -2
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +2 -2
- package/src/api/parsers/html/__snapshots__/parse-codeblocks.json +1 -1
- package/src/api/parsers/html/parseHTML.test.ts +1 -1
- package/src/api/parsers/markdown/__snapshots__/pasted/whitespace bold.json +42 -0
- package/src/api/parsers/markdown/__snapshots__/whitespace bold.json +19 -0
- package/src/api/parsers/markdown/detectMarkdown.ts +60 -0
- package/src/api/parsers/markdown/parseMarkdown.test.ts +7 -2
- package/src/api/parsers/markdown/parseMarkdown.ts +19 -18
- package/src/api/testUtil/cases/defaultSchema.ts +13 -0
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +100 -69
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +98 -0
- package/src/blocks/TableBlockContent/TableExtension.ts +1 -1
- package/src/blocks/defaultBlocks.ts +2 -2
- package/src/editor/Block.css +13 -0
- package/src/editor/BlockNoteEditor.ts +102 -10
- package/src/editor/BlockNoteExtensions.ts +18 -4
- package/src/extensions/Comments/CommentsPlugin.ts +1 -1
- package/src/extensions/HardBreak/HardBreak.ts +35 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +100 -3
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -1
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +6 -0
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +6 -0
- package/src/i18n/locales/fr.ts +6 -0
- package/src/i18n/locales/hr.ts +6 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/it.ts +6 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/no.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +6 -0
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/uk.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +2 -3
- package/src/locales.ts +1 -0
- package/src/schema/blocks/types.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +1 -1
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +34 -2
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/clipboard/fromClipboard/fileDropExtension.d.ts +2 -2
- package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +3 -3
- package/types/src/api/clipboard/testUtil.d.ts +66 -34
- package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +1 -1
- package/types/src/api/exporters/html/externalHTMLExporter.d.ts +2 -2
- package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +2 -2
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +1 -1
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +1 -1
- package/types/src/api/parsers/markdown/detectMarkdown.d.ts +6 -0
- package/types/src/api/parsers/markdown/parseMarkdown.d.ts +1 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +72 -40
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +34 -2
- package/types/src/api/testUtil/cases/customStyles.d.ts +34 -2
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +3 -3
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +46 -34
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +3 -3
- package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +1 -1
- package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +2 -2
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +2 -2
- package/types/src/blocks/PageBreakBlockContent/schema.d.ts +13 -13
- package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -2
- package/types/src/blocks/QuoteBlockContent/QuoteBlockContent.d.ts +52 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +2 -2
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -2
- package/types/src/blocks/defaultBlockHelpers.d.ts +2 -2
- package/types/src/blocks/defaultBlocks.d.ts +107 -44
- package/types/src/comments/threadstore/yjs/YjsThreadStore.d.ts +3 -3
- package/types/src/editor/BlockNoteEditor.d.ts +58 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +3 -2
- package/types/src/exporter/mapping.d.ts +2 -2
- package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +1 -1
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +1 -1
- package/types/src/extensions/HardBreak/HardBreak.d.ts +2 -0
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +4 -4
- package/types/src/extensions/TextColor/TextColorMark.d.ts +1 -1
- package/types/src/i18n/index.d.ts +2 -0
- package/types/src/i18n/locales/en.d.ts +7 -1
- package/types/src/index.d.ts +1 -2
- package/types/src/locales.d.ts +1 -0
- package/types/src/pm-nodes/BlockContainer.d.ts +2 -7
- package/types/src/pm-nodes/BlockGroup.d.ts +2 -7
- package/types/src/schema/blocks/types.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +1 -1
- package/README.md +0 -125
- package/src/blocks/CodeBlockContent/defaultSupportedLanguages.ts +0 -116
- package/types/src/extensions/Comments/threadstore/DefaultThreadStoreAuth.d.ts +0 -47
- package/types/src/extensions/Comments/threadstore/ThreadStore.d.ts +0 -121
- package/types/src/extensions/Comments/threadstore/ThreadStoreAuth.d.ts +0 -12
- package/types/src/extensions/Comments/threadstore/TipTapThreadStore.d.ts +0 -97
- package/types/src/extensions/Comments/threadstore/yjs/RESTYjsThreadStore.d.ts +0 -83
- package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStore.d.ts +0 -79
- package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStore.test.d.ts +0 -1
- package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStoreBase.d.ts +0 -15
- package/types/src/extensions/Comments/threadstore/yjs/yjsHelpers.d.ts +0 -13
- package/types/src/extensions/Comments/types.d.ts +0 -109
- package/types/src/models/User.d.ts +0 -5
package/types/src/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as locales from "./i18n/locales/index.js";
|
|
2
1
|
export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
2
|
export * from "./api/exporters/html/externalHTMLExporter.js";
|
|
4
3
|
export * from "./api/exporters/html/internalHTMLSerializer.js";
|
|
@@ -53,8 +52,8 @@ export * from "./util/esmDependencies.js";
|
|
|
53
52
|
export * from "./util/table.js";
|
|
54
53
|
export * from "./util/string.js";
|
|
55
54
|
export * from "./util/typescript.js";
|
|
55
|
+
export type { CodeBlockOptions } from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
56
56
|
export { UnreachableCaseError, assertEmpty } from "./util/typescript.js";
|
|
57
|
-
export { locales };
|
|
58
57
|
export * from "./api/nodeConversions/blockToNode.js";
|
|
59
58
|
export * from "./api/nodeConversions/nodeToBlock.js";
|
|
60
59
|
export * from "./api/testUtil/partialBlockTestUtil.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./i18n/index.js";
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
2
|
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
|
|
3
|
+
import { BlockNoteDOMAttributes } from "../schema/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* The main "Block node" documents consist of
|
|
5
6
|
*/
|
|
6
7
|
export declare const BlockContainer: Node<{
|
|
7
|
-
domAttributes?:
|
|
8
|
-
editor: Record<string, string>;
|
|
9
|
-
block: Record<string, string>;
|
|
10
|
-
blockGroup: Record<string, string>;
|
|
11
|
-
blockContent: Record<string, string>;
|
|
12
|
-
inlineContent: Record<string, string>;
|
|
13
|
-
}> | undefined;
|
|
8
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
14
9
|
editor: BlockNoteEditor<any, any, any>;
|
|
15
10
|
}, any>;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
|
+
import { BlockNoteDOMAttributes } from "../schema/index.js";
|
|
2
3
|
export declare const BlockGroup: Node<{
|
|
3
|
-
domAttributes?:
|
|
4
|
-
editor: Record<string, string>;
|
|
5
|
-
block: Record<string, string>;
|
|
6
|
-
blockGroup: Record<string, string>;
|
|
7
|
-
blockContent: Record<string, string>;
|
|
8
|
-
inlineContent: Record<string, string>;
|
|
9
|
-
}> | undefined;
|
|
4
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
10
5
|
}, any>;
|
|
@@ -38,6 +38,7 @@ export type BlockConfig = {
|
|
|
38
38
|
content: "inline" | "none" | "table";
|
|
39
39
|
isSelectable?: boolean;
|
|
40
40
|
isFileBlock?: false;
|
|
41
|
+
hardBreakShortcut?: "shift+enter" | "enter" | "none";
|
|
41
42
|
} | FileBlockConfig;
|
|
42
43
|
export type TiptapBlockImplementation<T extends BlockConfig, B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
43
44
|
requiredExtensions?: Array<Extension | Node>;
|
|
@@ -22,7 +22,7 @@ export declare function createInlineContentSpecFromTipTapNode<T extends Node, P
|
|
|
22
22
|
content: "styled" | "none";
|
|
23
23
|
};
|
|
24
24
|
implementation: {
|
|
25
|
-
node: Node
|
|
25
|
+
node: Node;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export declare function getInlineContentSchemaFromSpecs<T extends InlineContentSpecs>(specs: T): InlineContentSchemaFromSpecs<T>;
|
package/README.md
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://www.blocknotejs.org">
|
|
3
|
-
<img alt="TypeCell" src="https://github.com/TypeCellOS/BlockNote/raw/main/docs/public/img/logos/banner.svg?raw=true" width="300" />
|
|
4
|
-
</a>
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
Welcome to BlockNote! The open source Block-Based
|
|
9
|
-
React rich text editor. Easily add a modern text editing experience to your app.
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
<p align="center">
|
|
13
|
-
<a href="https://discord.gg/Qc2QTTH5dF"><img alt="Discord" src="https://img.shields.io/badge/Chat on discord%20-%237289DA.svg?&style=for-the-badge&logo=discord&logoColor=white"/></a>
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
<p align="center">
|
|
17
|
-
<a href="https://www.blocknotejs.org">
|
|
18
|
-
Homepage
|
|
19
|
-
</a> - <a href="https://www.blocknotejs.org/docs/introduction">
|
|
20
|
-
Documentation
|
|
21
|
-
</a> - <a href="https://www.blocknotejs.org/docs/quickstart">
|
|
22
|
-
Quickstart
|
|
23
|
-
</a>- <a href="https://www.blocknotejs.org/examples">
|
|
24
|
-
Examples
|
|
25
|
-
</a>
|
|
26
|
-
</p>
|
|
27
|
-
|
|
28
|
-
# Live demo
|
|
29
|
-
|
|
30
|
-
See our homepage @ [https://www.blocknotejs.org](https://www.blocknotejs.org/) or browse the [examples](https://www.blocknotejs.org/examples).
|
|
31
|
-
|
|
32
|
-
# Example code (React)
|
|
33
|
-
|
|
34
|
-
[](https://badge.fury.io/js/%40blocknote%2Freact)
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { useCreateBlockNote } from "@blocknote/react";
|
|
38
|
-
import { BlockNoteView } from "@blocknote/mantine";
|
|
39
|
-
import "@blocknote/core/fonts/inter.css";
|
|
40
|
-
import "@blocknote/mantine/style.css";
|
|
41
|
-
|
|
42
|
-
function App() {
|
|
43
|
-
const editor = useCreateBlockNote();
|
|
44
|
-
|
|
45
|
-
return <BlockNoteView editor={editor} />;
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
`@blocknote/react` comes with a fully styled UI that makes it an instant, polished editor ready to use in your app.
|
|
50
|
-
|
|
51
|
-
If you prefer to create your own UI components (menus), or don't want to use React, you can use `@blocknote/core` (_advanced_, [see docs](https://www.blocknotejs.org/docs/vanilla-js)).
|
|
52
|
-
|
|
53
|
-
# Features
|
|
54
|
-
|
|
55
|
-
BlockNote comes with a number of features and components to make it easy to embed a high-quality block-based editor in your app:
|
|
56
|
-
|
|
57
|
-
### Animations:
|
|
58
|
-
|
|
59
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/animations.gif?raw=true" width="400" />
|
|
60
|
-
|
|
61
|
-
### Helpful placeholders:
|
|
62
|
-
|
|
63
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/placeholders.gif?raw=true" width="400" />
|
|
64
|
-
|
|
65
|
-
### Drag and drop blocks:
|
|
66
|
-
|
|
67
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/dragdrop.gif?raw=true" width="400" />
|
|
68
|
-
|
|
69
|
-
### Nesting / indentation with tab and shift+tab:
|
|
70
|
-
|
|
71
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/nesting.gif?raw=true" width="400" />
|
|
72
|
-
|
|
73
|
-
### Slash (/) menu:
|
|
74
|
-
|
|
75
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/slashmenu.gif?raw=true" width="400" />
|
|
76
|
-
|
|
77
|
-
### Format menu:
|
|
78
|
-
|
|
79
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/selectmenu.gif?raw=true" width="400" />
|
|
80
|
-
|
|
81
|
-
### Real-time collaboration:
|
|
82
|
-
|
|
83
|
-
<img src="https://github.com/TypeCellOS/BlockNote/blob/readme/.resources/collaboration.gif?raw=true" width="400" />
|
|
84
|
-
|
|
85
|
-
# Feedback 🙋♂️🙋♀️
|
|
86
|
-
|
|
87
|
-
We'd love to hear your thoughts and see your experiments, so [come and say hi on Discord](https://discord.gg/Qc2QTTH5dF) or [Matrix](https://matrix.to/#/#typecell-space:matrix.org).
|
|
88
|
-
|
|
89
|
-
# Contributing 🙌
|
|
90
|
-
|
|
91
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for more info and guidance on how to run the project (TLDR: just use `npm start`).
|
|
92
|
-
|
|
93
|
-
Directory structure:
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
blocknote
|
|
97
|
-
├── packages/core - The core of the editor
|
|
98
|
-
├── packages/react - The main library for use in React apps
|
|
99
|
-
├── packages/mantine - Mantine (default) implementation of BlockNote UI
|
|
100
|
-
├── packages/ariakit - AriaKit implementation of BlockNote UI
|
|
101
|
-
├── packages/shadcn - ShadCN / Tailwind / Radix implementation of BlockNote UI
|
|
102
|
-
├── examples - Example apps
|
|
103
|
-
├── playground - App to browse the example apps (https://playground.blocknotejs.org)
|
|
104
|
-
└── tests - Playwright end to end tests
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
The codebase is automatically tested using Vitest and Playwright.
|
|
108
|
-
|
|
109
|
-
# License 📃
|
|
110
|
-
|
|
111
|
-
BlockNote is licensed under the [MPL 2.0 license](https://fossa.com/blog/open-source-software-licenses-101-mozilla-public-license-2-0/), which allows you to use BlockNote in commercial (and closed-source) applications. If you make changes to the BlockNote source files, you're expected to publish these changes so the wider community can benefit as well.
|
|
112
|
-
|
|
113
|
-
# Credits ❤️
|
|
114
|
-
|
|
115
|
-
BlockNote builds directly on two awesome projects; [Prosemirror](https://prosemirror.net/) by Marijn Haverbeke and [Tiptap](https://tiptap.dev/). Consider sponsoring those libraries when using BlockNote: [Prosemirror](https://marijnhaverbeke.nl/fund/), [Tiptap](https://github.com/sponsors/ueberdosis).
|
|
116
|
-
|
|
117
|
-
BlockNote is built as part of [TypeCell](https://www.typecell.org). TypeCell is proudly sponsored by the renowned [NLNet foundation](https://nlnet.nl/foundation/) who are on a mission to support an open internet, and protect the privacy and security of internet users. Check them out!
|
|
118
|
-
|
|
119
|
-
<a href="https://nlnet.nl"><img src="https://nlnet.nl/image/logos/NGIAssure_tag.svg" alt="NLNet" width="100"></a>
|
|
120
|
-
|
|
121
|
-
Hosting and deployments powered by Vercel:
|
|
122
|
-
|
|
123
|
-
<a href="https://vercel.com/?utm_source=TypeCell&utm_campaign=oss"><img src="https://images.ctfassets.net/e5382hct74si/78Olo8EZRdUlcDUFQvnzG7/fa4cdb6dc04c40fceac194134788a0e2/1618983297-powered-by-vercel.svg" alt="NLNet" width="150"></a>
|
|
124
|
-
|
|
125
|
-
This project is tested with BrowserStack
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { bundledLanguagesInfo } from "shiki";
|
|
2
|
-
|
|
3
|
-
export type SupportedLanguageConfig = {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
match: string[];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const defaultSupportedLanguages: SupportedLanguageConfig[] = [
|
|
10
|
-
{
|
|
11
|
-
id: "text",
|
|
12
|
-
name: "Plain Text",
|
|
13
|
-
match: ["text", "txt", "plain"],
|
|
14
|
-
},
|
|
15
|
-
...bundledLanguagesInfo
|
|
16
|
-
.filter((lang) => {
|
|
17
|
-
return [
|
|
18
|
-
"c",
|
|
19
|
-
"cpp",
|
|
20
|
-
"css",
|
|
21
|
-
"glsl",
|
|
22
|
-
"graphql",
|
|
23
|
-
"haml",
|
|
24
|
-
"html",
|
|
25
|
-
"java",
|
|
26
|
-
"javascript",
|
|
27
|
-
"json",
|
|
28
|
-
"jsonc",
|
|
29
|
-
"jsonl",
|
|
30
|
-
"jsx",
|
|
31
|
-
"julia",
|
|
32
|
-
"less",
|
|
33
|
-
"markdown",
|
|
34
|
-
"mdx",
|
|
35
|
-
"php",
|
|
36
|
-
"postcss",
|
|
37
|
-
"pug",
|
|
38
|
-
"python",
|
|
39
|
-
"r",
|
|
40
|
-
"regexp",
|
|
41
|
-
"sass",
|
|
42
|
-
"scss",
|
|
43
|
-
"shellscript",
|
|
44
|
-
"sql",
|
|
45
|
-
"svelte",
|
|
46
|
-
"typescript",
|
|
47
|
-
"vue",
|
|
48
|
-
"vue-html",
|
|
49
|
-
"wasm",
|
|
50
|
-
"wgsl",
|
|
51
|
-
"xml",
|
|
52
|
-
"yaml",
|
|
53
|
-
].includes(lang.id);
|
|
54
|
-
})
|
|
55
|
-
.map((lang) => ({
|
|
56
|
-
match: [lang.id, ...(lang.aliases || [])],
|
|
57
|
-
id: lang.id,
|
|
58
|
-
name: lang.name,
|
|
59
|
-
})),
|
|
60
|
-
{ id: "tsx", name: "TSX", match: ["tsx", "typescriptreact"] },
|
|
61
|
-
{
|
|
62
|
-
id: "haskell",
|
|
63
|
-
name: "Haskell",
|
|
64
|
-
match: ["haskell", "hs"],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: "csharp",
|
|
68
|
-
name: "C#",
|
|
69
|
-
match: ["c#", "csharp", "cs"],
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: "latex",
|
|
73
|
-
name: "LaTeX",
|
|
74
|
-
match: ["latex"],
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: "lua",
|
|
78
|
-
name: "Lua",
|
|
79
|
-
match: ["lua"],
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: "mermaid",
|
|
83
|
-
name: "Mermaid",
|
|
84
|
-
match: ["mermaid", "mmd"],
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
id: "ruby",
|
|
88
|
-
name: "Ruby",
|
|
89
|
-
match: ["ruby", "rb"],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: "rust",
|
|
93
|
-
name: "Rust",
|
|
94
|
-
match: ["rust", "rs"],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: "scala",
|
|
98
|
-
name: "Scala",
|
|
99
|
-
match: ["scala"],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: "swift",
|
|
103
|
-
name: "Swift",
|
|
104
|
-
match: ["swift"],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
id: "kotlin",
|
|
108
|
-
name: "Kotlin",
|
|
109
|
-
match: ["kotlin", "kt", "kts"],
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
id: "objective-c",
|
|
113
|
-
name: "Objective C",
|
|
114
|
-
match: ["objective-c", "objc"],
|
|
115
|
-
},
|
|
116
|
-
];
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { CommentData, ThreadData } from "../types.js";
|
|
2
|
-
import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
|
|
3
|
-
export declare class DefaultThreadStoreAuth extends ThreadStoreAuth {
|
|
4
|
-
private readonly userId;
|
|
5
|
-
private readonly role;
|
|
6
|
-
constructor(userId: string, role: "comment" | "editor");
|
|
7
|
-
/**
|
|
8
|
-
* Auth: should be possible by anyone with comment access
|
|
9
|
-
*/
|
|
10
|
-
canCreateThread(): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Auth: should be possible by anyone with comment access
|
|
13
|
-
*/
|
|
14
|
-
canAddComment(_thread: ThreadData): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Auth: should only be possible by the comment author
|
|
17
|
-
*/
|
|
18
|
-
canUpdateComment(comment: CommentData): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Auth: should be possible by the comment author OR an editor of the document
|
|
21
|
-
*/
|
|
22
|
-
canDeleteComment(comment: CommentData): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Auth: should only be possible by an editor of the document
|
|
25
|
-
*/
|
|
26
|
-
canDeleteThread(_thread: ThreadData): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Auth: should be possible by anyone with comment access
|
|
29
|
-
*/
|
|
30
|
-
canResolveThread(_thread: ThreadData): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Auth: should be possible by anyone with comment access
|
|
33
|
-
*/
|
|
34
|
-
canUnresolveThread(_thread: ThreadData): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Auth: should be possible by anyone with comment access
|
|
37
|
-
*
|
|
38
|
-
* Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?
|
|
39
|
-
*/
|
|
40
|
-
canAddReaction(comment: CommentData, emoji?: string): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Auth: should be possible by anyone with comment access
|
|
43
|
-
*
|
|
44
|
-
* Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?
|
|
45
|
-
*/
|
|
46
|
-
canDeleteReaction(comment: CommentData, emoji?: string): boolean;
|
|
47
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { CommentBody, CommentData, ThreadData } from "../types.js";
|
|
2
|
-
import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
|
|
3
|
-
/**
|
|
4
|
-
* ThreadStore is an abstract class that defines the interface
|
|
5
|
-
* to read / add / update / delete threads and comments.
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class ThreadStore {
|
|
8
|
-
readonly auth: ThreadStoreAuth;
|
|
9
|
-
constructor(auth: ThreadStoreAuth);
|
|
10
|
-
/**
|
|
11
|
-
* A "thread" in the ThreadStore only contains information about the content
|
|
12
|
-
* of the thread / comments. It does not contain information about the position.
|
|
13
|
-
*
|
|
14
|
-
* This function can be implemented to store the thread in the document (by creating a mark)
|
|
15
|
-
* If not implemented, default behavior will apply (creating the mark via TipTap)
|
|
16
|
-
* See CommentsPlugin.ts for more details.
|
|
17
|
-
*/
|
|
18
|
-
abstract addThreadToDocument?(options: {
|
|
19
|
-
threadId: string;
|
|
20
|
-
selection: {
|
|
21
|
-
prosemirror: {
|
|
22
|
-
head: number;
|
|
23
|
-
anchor: number;
|
|
24
|
-
};
|
|
25
|
-
yjs: {
|
|
26
|
-
head: any;
|
|
27
|
-
anchor: any;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new thread with an initial comment.
|
|
33
|
-
*/
|
|
34
|
-
abstract createThread(options: {
|
|
35
|
-
initialComment: {
|
|
36
|
-
body: CommentBody;
|
|
37
|
-
metadata?: any;
|
|
38
|
-
};
|
|
39
|
-
metadata?: any;
|
|
40
|
-
}): Promise<ThreadData>;
|
|
41
|
-
/**
|
|
42
|
-
* Adds a comment to a thread.
|
|
43
|
-
*/
|
|
44
|
-
abstract addComment(options: {
|
|
45
|
-
comment: {
|
|
46
|
-
body: CommentBody;
|
|
47
|
-
metadata?: any;
|
|
48
|
-
};
|
|
49
|
-
threadId: string;
|
|
50
|
-
}): Promise<CommentData>;
|
|
51
|
-
/**
|
|
52
|
-
* Updates a comment in a thread.
|
|
53
|
-
*/
|
|
54
|
-
abstract updateComment(options: {
|
|
55
|
-
comment: {
|
|
56
|
-
body: CommentBody;
|
|
57
|
-
metadata?: any;
|
|
58
|
-
};
|
|
59
|
-
threadId: string;
|
|
60
|
-
commentId: string;
|
|
61
|
-
}): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Deletes a comment from a thread.
|
|
64
|
-
*/
|
|
65
|
-
abstract deleteComment(options: {
|
|
66
|
-
threadId: string;
|
|
67
|
-
commentId: string;
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Deletes a thread.
|
|
71
|
-
*/
|
|
72
|
-
abstract deleteThread(options: {
|
|
73
|
-
threadId: string;
|
|
74
|
-
}): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Marks a thread as resolved.
|
|
77
|
-
*/
|
|
78
|
-
abstract resolveThread(options: {
|
|
79
|
-
threadId: string;
|
|
80
|
-
}): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Marks a thread as unresolved.
|
|
83
|
-
*/
|
|
84
|
-
abstract unresolveThread(options: {
|
|
85
|
-
threadId: string;
|
|
86
|
-
}): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Adds a reaction to a comment.
|
|
89
|
-
*
|
|
90
|
-
* Auth: should be possible by anyone with comment access
|
|
91
|
-
*/
|
|
92
|
-
abstract addReaction(options: {
|
|
93
|
-
threadId: string;
|
|
94
|
-
commentId: string;
|
|
95
|
-
emoji: string;
|
|
96
|
-
}): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Deletes a reaction from a comment.
|
|
99
|
-
*
|
|
100
|
-
* Auth: should be possible by the reaction author
|
|
101
|
-
*/
|
|
102
|
-
abstract deleteReaction(options: {
|
|
103
|
-
threadId: string;
|
|
104
|
-
commentId: string;
|
|
105
|
-
emoji: string;
|
|
106
|
-
}): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Retrieve data for a specific thread.
|
|
109
|
-
*/
|
|
110
|
-
abstract getThread(threadId: string): ThreadData;
|
|
111
|
-
/**
|
|
112
|
-
* Retrieve all threads.
|
|
113
|
-
*/
|
|
114
|
-
abstract getThreads(): Map<string, ThreadData>;
|
|
115
|
-
/**
|
|
116
|
-
* Subscribe to changes in the thread store.
|
|
117
|
-
*
|
|
118
|
-
* @returns a function to unsubscribe from the thread store
|
|
119
|
-
*/
|
|
120
|
-
abstract subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void;
|
|
121
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CommentData, ThreadData } from "../types.js";
|
|
2
|
-
export declare abstract class ThreadStoreAuth {
|
|
3
|
-
abstract canCreateThread(): boolean;
|
|
4
|
-
abstract canAddComment(thread: ThreadData): boolean;
|
|
5
|
-
abstract canUpdateComment(comment: CommentData): boolean;
|
|
6
|
-
abstract canDeleteComment(comment: CommentData): boolean;
|
|
7
|
-
abstract canDeleteThread(thread: ThreadData): boolean;
|
|
8
|
-
abstract canResolveThread(thread: ThreadData): boolean;
|
|
9
|
-
abstract canUnresolveThread(thread: ThreadData): boolean;
|
|
10
|
-
abstract canAddReaction(comment: CommentData, emoji?: string): boolean;
|
|
11
|
-
abstract canDeleteReaction(comment: CommentData, emoji?: string): boolean;
|
|
12
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import type { TiptapCollabProvider } from "@hocuspocus/provider";
|
|
2
|
-
import { CommentBody, ThreadData } from "../types.js";
|
|
3
|
-
import { ThreadStore } from "./ThreadStore.js";
|
|
4
|
-
import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
|
|
5
|
-
/**
|
|
6
|
-
* The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.
|
|
7
|
-
* You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.
|
|
8
|
-
*
|
|
9
|
-
* Under the hood, this actually works similarly to the `YjsThreadStore` implementation. (comments are stored in the Yjs document)
|
|
10
|
-
*/
|
|
11
|
-
export declare class TiptapThreadStore extends ThreadStore {
|
|
12
|
-
private readonly userId;
|
|
13
|
-
private readonly provider;
|
|
14
|
-
constructor(userId: string, provider: TiptapCollabProvider, auth: ThreadStoreAuth);
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new thread with an initial comment.
|
|
17
|
-
*/
|
|
18
|
-
createThread(options: {
|
|
19
|
-
initialComment: {
|
|
20
|
-
body: CommentBody;
|
|
21
|
-
metadata?: any;
|
|
22
|
-
};
|
|
23
|
-
metadata?: any;
|
|
24
|
-
}): Promise<ThreadData>;
|
|
25
|
-
addThreadToDocument: undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Adds a comment to a thread.
|
|
28
|
-
*/
|
|
29
|
-
addComment(options: {
|
|
30
|
-
comment: {
|
|
31
|
-
body: CommentBody;
|
|
32
|
-
metadata?: any;
|
|
33
|
-
};
|
|
34
|
-
threadId: string;
|
|
35
|
-
}): Promise<CommentBody>;
|
|
36
|
-
/**
|
|
37
|
-
* Updates a comment in a thread.
|
|
38
|
-
*/
|
|
39
|
-
updateComment(options: {
|
|
40
|
-
comment: {
|
|
41
|
-
body: CommentBody;
|
|
42
|
-
metadata?: any;
|
|
43
|
-
};
|
|
44
|
-
threadId: string;
|
|
45
|
-
commentId: string;
|
|
46
|
-
}): Promise<void>;
|
|
47
|
-
private tiptapCommentToCommentData;
|
|
48
|
-
private tiptapThreadToThreadData;
|
|
49
|
-
/**
|
|
50
|
-
* Deletes a comment from a thread.
|
|
51
|
-
*/
|
|
52
|
-
deleteComment(options: {
|
|
53
|
-
threadId: string;
|
|
54
|
-
commentId: string;
|
|
55
|
-
}): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Deletes a thread.
|
|
58
|
-
*/
|
|
59
|
-
deleteThread(options: {
|
|
60
|
-
threadId: string;
|
|
61
|
-
}): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Marks a thread as resolved.
|
|
64
|
-
*/
|
|
65
|
-
resolveThread(options: {
|
|
66
|
-
threadId: string;
|
|
67
|
-
}): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Marks a thread as unresolved.
|
|
70
|
-
*/
|
|
71
|
-
unresolveThread(options: {
|
|
72
|
-
threadId: string;
|
|
73
|
-
}): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Adds a reaction to a comment.
|
|
76
|
-
*
|
|
77
|
-
* Auth: should be possible by anyone with comment access
|
|
78
|
-
*/
|
|
79
|
-
addReaction(options: {
|
|
80
|
-
threadId: string;
|
|
81
|
-
commentId: string;
|
|
82
|
-
emoji: string;
|
|
83
|
-
}): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Deletes a reaction from a comment.
|
|
86
|
-
*
|
|
87
|
-
* Auth: should be possible by the reaction author
|
|
88
|
-
*/
|
|
89
|
-
deleteReaction(options: {
|
|
90
|
-
threadId: string;
|
|
91
|
-
commentId: string;
|
|
92
|
-
emoji: string;
|
|
93
|
-
}): Promise<void>;
|
|
94
|
-
getThread(threadId: string): ThreadData;
|
|
95
|
-
getThreads(): Map<string, ThreadData>;
|
|
96
|
-
subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void;
|
|
97
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { CommentBody } from "../../types.js";
|
|
3
|
-
import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
|
|
4
|
-
import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
|
|
5
|
-
/**
|
|
6
|
-
* This is a REST-based implementation of the YjsThreadStoreBase.
|
|
7
|
-
* It Reads data directly from the underlying document (same as YjsThreadStore),
|
|
8
|
-
* but for Writes, it sends data to a REST API that should:
|
|
9
|
-
* - check the user has the correct permissions to make the desired changes
|
|
10
|
-
* - apply the updates to the underlying Yjs document
|
|
11
|
-
*
|
|
12
|
-
* (see https://github.com/TypeCellOS/BlockNote-demo-nextjs-hocuspocus)
|
|
13
|
-
*
|
|
14
|
-
* The reason we still use the Yjs document as underlying storage is that it makes it easy to
|
|
15
|
-
* sync updates in real-time to other collaborators.
|
|
16
|
-
* (but technically, you could also implement a different storage altogether
|
|
17
|
-
* and not store the thread related data in the Yjs document)
|
|
18
|
-
*/
|
|
19
|
-
export declare class RESTYjsThreadStore extends YjsThreadStoreBase {
|
|
20
|
-
private readonly BASE_URL;
|
|
21
|
-
private readonly headers;
|
|
22
|
-
constructor(BASE_URL: string, headers: Record<string, string>, threadsYMap: Y.Map<any>, auth: ThreadStoreAuth);
|
|
23
|
-
private doRequest;
|
|
24
|
-
addThreadToDocument: (options: {
|
|
25
|
-
threadId: string;
|
|
26
|
-
selection: {
|
|
27
|
-
prosemirror: {
|
|
28
|
-
head: number;
|
|
29
|
-
anchor: number;
|
|
30
|
-
};
|
|
31
|
-
yjs: {
|
|
32
|
-
head: any;
|
|
33
|
-
anchor: any;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}) => Promise<any>;
|
|
37
|
-
createThread: (options: {
|
|
38
|
-
initialComment: {
|
|
39
|
-
body: CommentBody;
|
|
40
|
-
metadata?: any;
|
|
41
|
-
};
|
|
42
|
-
metadata?: any;
|
|
43
|
-
}) => Promise<any>;
|
|
44
|
-
addComment: (options: {
|
|
45
|
-
comment: {
|
|
46
|
-
body: CommentBody;
|
|
47
|
-
metadata?: any;
|
|
48
|
-
};
|
|
49
|
-
threadId: string;
|
|
50
|
-
}) => Promise<any>;
|
|
51
|
-
updateComment: (options: {
|
|
52
|
-
comment: {
|
|
53
|
-
body: CommentBody;
|
|
54
|
-
metadata?: any;
|
|
55
|
-
};
|
|
56
|
-
threadId: string;
|
|
57
|
-
commentId: string;
|
|
58
|
-
}) => Promise<any>;
|
|
59
|
-
deleteComment: (options: {
|
|
60
|
-
threadId: string;
|
|
61
|
-
commentId: string;
|
|
62
|
-
softDelete?: boolean;
|
|
63
|
-
}) => Promise<any>;
|
|
64
|
-
deleteThread: (options: {
|
|
65
|
-
threadId: string;
|
|
66
|
-
}) => Promise<any>;
|
|
67
|
-
resolveThread: (options: {
|
|
68
|
-
threadId: string;
|
|
69
|
-
}) => Promise<any>;
|
|
70
|
-
unresolveThread: (options: {
|
|
71
|
-
threadId: string;
|
|
72
|
-
}) => Promise<any>;
|
|
73
|
-
addReaction: (options: {
|
|
74
|
-
threadId: string;
|
|
75
|
-
commentId: string;
|
|
76
|
-
emoji: string;
|
|
77
|
-
}) => Promise<any>;
|
|
78
|
-
deleteReaction: (options: {
|
|
79
|
-
threadId: string;
|
|
80
|
-
commentId: string;
|
|
81
|
-
emoji: string;
|
|
82
|
-
}) => Promise<any>;
|
|
83
|
-
}
|