File
Blob: src/shared/editor/schema/index.ts
| 1 | import type { AnyExtension } from "@tiptap/core"; |
| 2 | import CharacterCount from "@tiptap/extension-character-count"; |
| 3 | import { TaskItem } from "@tiptap/extension-task-item"; |
| 4 | import { TaskList } from "@tiptap/extension-task-list"; |
| 5 | import { TextAlign } from "@tiptap/extension-text-align"; |
| 6 | import { BackgroundColor, Color, TextStyle } from "@tiptap/extension-text-style"; |
| 7 | import Typography from "@tiptap/extension-typography"; |
| 8 | import { StarterKit } from "@tiptap/starter-kit"; |
| 9 | import { SharedCalloutExtension } from "./callout"; |
| 10 | import { SharedCodeBlock } from "./code-block"; |
| 11 | import { SharedDetailsBlockExtensions } from "./details"; |
| 12 | import { SharedEmoji } from "./emoji"; |
| 13 | import { SharedImage } from "./image"; |
| 14 | import { countCharacters, countWords } from "./metrics"; |
| 15 | import { SharedPageMentionNode } from "./page-mention"; |
| 16 | import { createSharedTableExtensions } from "./table"; |
| 17 | import { SharedTopLevelBlockAttributes } from "./top-level-blocks"; |
| 18 | |
| 19 | export function createHeadlessEditorExtensions(): AnyExtension[] { |
| 20 | return [ |
| 21 | StarterKit.configure({ |
| 22 | undoRedo: false, |
| 23 | dropcursor: false, |
| 24 | link: { openOnClick: false, autolink: true }, |
| 25 | codeBlock: false, |
| 26 | }), |
| 27 | // Keep quote and ellipsis fixes for prose, but avoid operator-style |
| 28 | // rewrites that are risky in technical and code-adjacent writing. |
| 29 | Typography.configure({ |
| 30 | emDash: false, |
| 31 | openDoubleQuote: false, |
| 32 | closeDoubleQuote: false, |
| 33 | openSingleQuote: false, |
| 34 | closeSingleQuote: false, |
| 35 | leftArrow: false, |
| 36 | rightArrow: false, |
| 37 | copyright: false, |
| 38 | trademark: false, |
| 39 | servicemark: false, |
| 40 | registeredTrademark: false, |
| 41 | oneHalf: false, |
| 42 | plusMinus: false, |
| 43 | notEqual: false, |
| 44 | laquo: false, |
| 45 | raquo: false, |
| 46 | multiplication: false, |
| 47 | superscriptTwo: false, |
| 48 | superscriptThree: false, |
| 49 | oneQuarter: false, |
| 50 | threeQuarters: false, |
| 51 | }), |
| 52 | SharedEmoji, |
| 53 | CharacterCount.configure({ |
| 54 | textCounter: countCharacters, |
| 55 | wordCounter: countWords, |
| 56 | }), |
| 57 | TextStyle, |
| 58 | Color, |
| 59 | BackgroundColor, |
| 60 | TextAlign.configure({ types: ["heading", "paragraph"] }), |
| 61 | ...SharedDetailsBlockExtensions, |
| 62 | SharedCalloutExtension, |
| 63 | SharedCodeBlock.configure({ |
| 64 | defaultLanguage: "text", |
| 65 | enableTabIndentation: true, |
| 66 | }), |
| 67 | SharedTopLevelBlockAttributes, |
| 68 | SharedImage.configure({ inline: false, allowBase64: false }), |
| 69 | TaskList, |
| 70 | TaskItem.configure({ nested: true }), |
| 71 | SharedPageMentionNode, |
| 72 | ...createSharedTableExtensions(), |
| 73 | ] as AnyExtension[]; |
| 74 | } |
| 75 | |
| 76 | export * from "./callout"; |
| 77 | export * from "./code-block"; |
| 78 | export * from "./details"; |
| 79 | export * from "./emoji"; |
| 80 | export * from "./image"; |
| 81 | export * from "./metrics"; |
| 82 | export * from "./page-mention"; |
| 83 | export * from "./table"; |
| 84 | export * from "./top-level-blocks"; |