diff --git a/.eslintrc.js b/.eslintrc.js index 007700b6dd7..44e8122ad3b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -70,8 +70,6 @@ module.exports = { '@typescript-eslint/ban-types': 'off', '@typescript-eslint/comma-dangle': ['error', 'always-multiline'], '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-namespace': 'off', - 'no-undef': 'off', }, }, ], diff --git a/packages/core/src/CommandManager.ts b/packages/core/src/CommandManager.ts index ceeecfc4f3f..b9fef148c03 100644 --- a/packages/core/src/CommandManager.ts +++ b/packages/core/src/CommandManager.ts @@ -1,9 +1,9 @@ import { EditorState, Transaction } from 'prosemirror-state' import { - Editor, - CommandSpec, SingleCommands, ChainedCommands, + Editor, + CommandSpec, } from './Editor' import getAllMethodNames from './utils/getAllMethodNames' diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index e6dfcf4b53e..5791204a3ae 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -21,6 +21,8 @@ import { Extensions, UnionToIntersection } from './types' import * as extensions from './extensions' import style from './style' +export { extensions } + export type Command = (props: { editor: Editor, tr: Transaction, @@ -38,25 +40,21 @@ export interface CommandsSpec { [key: string]: CommandSpec } -declare global { - namespace Tiptap { - export interface AllExtensions {} - } -} +export interface AllExtensions {} -type UnfilteredCommands = { - [Item in keyof Tiptap.AllExtensions]: Tiptap.AllExtensions[Item] extends Extension +export type UnfilteredCommands = { + [Item in keyof AllExtensions]: AllExtensions[Item] extends Extension ? ExtensionCommands - : Tiptap.AllExtensions[Item] extends Node + : AllExtensions[Item] extends Node ? NodeCommands - : Tiptap.AllExtensions[Item] extends Mark + : AllExtensions[Item] extends Mark ? MarkCommands : never } -type ValuesOf = T[keyof T]; -type KeysWithTypeOf = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T] -type AllCommands = UnionToIntersection>>> +export type ValuesOf = T[keyof T]; +export type KeysWithTypeOf = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T] +export type AllCommands = UnionToIntersection>>> export type SingleCommands = { [Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any diff --git a/packages/core/src/extensions/commands.ts b/packages/core/src/extensions/commands.ts index 63d3715bae7..3b82b620a9c 100644 --- a/packages/core/src/extensions/commands.ts +++ b/packages/core/src/extensions/commands.ts @@ -147,10 +147,8 @@ export const Commands = Extension.create({ }, }) -declare global { - namespace Tiptap { - interface AllExtensions { - Commands: typeof Commands, - } +declare module '@tiptap/core' { + interface AllExtensions { + Commands: typeof Commands, } } diff --git a/packages/core/src/extensions/editable.ts b/packages/core/src/extensions/editable.ts index dc609ff983c..4dc9f2d0813 100644 --- a/packages/core/src/extensions/editable.ts +++ b/packages/core/src/extensions/editable.ts @@ -14,10 +14,8 @@ export const Editable = Extension.create({ }, }) -declare global { - namespace Tiptap { - interface AllExtensions { - Editable: typeof Editable, - } +declare module '@tiptap/core' { + interface AllExtensions { + Editable: typeof Editable, } } diff --git a/packages/core/src/extensions/focusEvents.ts b/packages/core/src/extensions/focusEvents.ts index f5be8311d5d..468d105fa39 100644 --- a/packages/core/src/extensions/focusEvents.ts +++ b/packages/core/src/extensions/focusEvents.ts @@ -36,10 +36,8 @@ export const FocusEvents = Extension.create({ }, }) -declare global { - namespace Tiptap { - interface AllExtensions { - FocusEvents: typeof FocusEvents, - } +declare module '@tiptap/core' { + interface AllExtensions { + FocusEvents: typeof FocusEvents, } } diff --git a/packages/core/src/extensions/keymap.ts b/packages/core/src/extensions/keymap.ts index 99c87781b1f..99486512e25 100644 --- a/packages/core/src/extensions/keymap.ts +++ b/packages/core/src/extensions/keymap.ts @@ -45,10 +45,8 @@ export const Keymap = Extension.create({ }, }) -declare global { - namespace Tiptap { - interface AllExtensions { - Keymap: typeof Keymap, - } +declare module '@tiptap/core' { + interface AllExtensions { + Keymap: typeof Keymap, } } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 97316c91406..a1aa1c8575c 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,9 +1,4 @@ -export { - Editor, - Command, - CommandsSpec, -} from './Editor' - +export * from './Editor' export * from './Extension' export * from './Node' export * from './Mark' diff --git a/packages/extension-blockquote/src/index.ts b/packages/extension-blockquote/src/index.ts index d29a4c935b7..d0d3f318abf 100644 --- a/packages/extension-blockquote/src/index.ts +++ b/packages/extension-blockquote/src/index.ts @@ -58,10 +58,8 @@ const Blockquote = Node.create({ export default Blockquote -declare global { - namespace Tiptap { - interface AllExtensions { - Blockquote: typeof Blockquote, - } +declare module '@tiptap/core' { + interface AllExtensions { + Blockquote: typeof Blockquote, } } diff --git a/packages/extension-bold/src/index.ts b/packages/extension-bold/src/index.ts index 59fe2c7fd42..64ff675e70a 100644 --- a/packages/extension-bold/src/index.ts +++ b/packages/extension-bold/src/index.ts @@ -74,10 +74,8 @@ const Bold = Mark.create({ export default Bold -declare global { - namespace Tiptap { - interface AllExtensions { - Bold: typeof Bold, - } +declare module '@tiptap/core' { + interface AllExtensions { + Bold: typeof Bold, } } diff --git a/packages/extension-bullet-list/src/index.ts b/packages/extension-bullet-list/src/index.ts index fbb6d9ae3ea..3fa2338b611 100644 --- a/packages/extension-bullet-list/src/index.ts +++ b/packages/extension-bullet-list/src/index.ts @@ -56,10 +56,8 @@ const BulletList = Node.create({ export default BulletList -declare global { - namespace Tiptap { - interface AllExtensions { - BulletList: typeof BulletList, - } +declare module '@tiptap/core' { + interface AllExtensions { + BulletList: typeof BulletList, } } diff --git a/packages/extension-code-block/src/index.ts b/packages/extension-code-block/src/index.ts index 1c6e870ca85..2d697e9d0df 100644 --- a/packages/extension-code-block/src/index.ts +++ b/packages/extension-code-block/src/index.ts @@ -99,10 +99,8 @@ const CodeBlock = Node.create({ export default CodeBlock -declare global { - namespace Tiptap { - interface AllExtensions { - CodeBlock: typeof CodeBlock, - } +declare module '@tiptap/core' { + interface AllExtensions { + CodeBlock: typeof CodeBlock, } } diff --git a/packages/extension-code/src/index.ts b/packages/extension-code/src/index.ts index 6445ec5f2d6..5eb5909ecfb 100644 --- a/packages/extension-code/src/index.ts +++ b/packages/extension-code/src/index.ts @@ -65,10 +65,8 @@ const Code = Mark.create({ export default Code -declare global { - namespace Tiptap { - interface AllExtensions { - Code: typeof Code, - } +declare module '@tiptap/core' { + interface AllExtensions { + Code: typeof Code, } } diff --git a/packages/extension-collaboration-cursor/src/index.ts b/packages/extension-collaboration-cursor/src/index.ts index a4fb97e3680..ae88704cb89 100644 --- a/packages/extension-collaboration-cursor/src/index.ts +++ b/packages/extension-collaboration-cursor/src/index.ts @@ -64,10 +64,8 @@ const CollaborationCursor = Extension.create({ export default CollaborationCursor -declare global { - namespace Tiptap { - interface AllExtensions { - CollaborationCursor: typeof CollaborationCursor, - } +declare module '@tiptap/core' { + interface AllExtensions { + CollaborationCursor: typeof CollaborationCursor, } } diff --git a/packages/extension-collaboration/src/index.ts b/packages/extension-collaboration/src/index.ts index 3ed695ee90c..729ef245bab 100644 --- a/packages/extension-collaboration/src/index.ts +++ b/packages/extension-collaboration/src/index.ts @@ -32,10 +32,8 @@ const Collaboration = Extension.create({ export default Collaboration -declare global { - namespace Tiptap { - interface AllExtensions { - Collaboration: typeof Collaboration, - } +declare module '@tiptap/core' { + interface AllExtensions { + Collaboration: typeof Collaboration, } } diff --git a/packages/extension-document/src/index.ts b/packages/extension-document/src/index.ts index efec4dd5f5b..5c9b4796164 100644 --- a/packages/extension-document/src/index.ts +++ b/packages/extension-document/src/index.ts @@ -8,10 +8,8 @@ const Document = Node.create({ export default Document -declare global { - namespace Tiptap { - interface AllExtensions { - Document: typeof Document, - } +declare module '@tiptap/core' { + interface AllExtensions { + Document: typeof Document, } } diff --git a/packages/extension-dropcursor/src/index.ts b/packages/extension-dropcursor/src/index.ts index acbf2866aca..fd951be21a3 100644 --- a/packages/extension-dropcursor/src/index.ts +++ b/packages/extension-dropcursor/src/index.ts @@ -11,10 +11,8 @@ const Dropcursor = Extension.create({ export default Dropcursor -declare global { - namespace Tiptap { - interface AllExtensions { - Dropcursor: typeof Dropcursor, - } +declare module '@tiptap/core' { + interface AllExtensions { + Dropcursor: typeof Dropcursor, } } diff --git a/packages/extension-focus/src/index.ts b/packages/extension-focus/src/index.ts index 10c517e7eb9..62c7844c36b 100644 --- a/packages/extension-focus/src/index.ts +++ b/packages/extension-focus/src/index.ts @@ -50,10 +50,8 @@ const FocusClasses = Extension.create({ export default FocusClasses -declare global { - namespace Tiptap { - interface AllExtensions { - FocusClasses: typeof FocusClasses, - } +declare module '@tiptap/core' { + interface AllExtensions { + FocusClasses: typeof FocusClasses, } } diff --git a/packages/extension-font-family/src/index.ts b/packages/extension-font-family/src/index.ts index 4dbf17076e3..e83846dcf84 100644 --- a/packages/extension-font-family/src/index.ts +++ b/packages/extension-font-family/src/index.ts @@ -52,10 +52,8 @@ const FontFamily = Extension.create({ export default FontFamily -declare global { - namespace Tiptap { - interface AllExtensions { - FontFamily: typeof FontFamily, - } +declare module '@tiptap/core' { + interface AllExtensions { + FontFamily: typeof FontFamily, } } diff --git a/packages/extension-gapcursor/src/index.ts b/packages/extension-gapcursor/src/index.ts index f295bef70c9..09ee3846059 100644 --- a/packages/extension-gapcursor/src/index.ts +++ b/packages/extension-gapcursor/src/index.ts @@ -11,10 +11,8 @@ const Gapcursor = Extension.create({ export default Gapcursor -declare global { - namespace Tiptap { - interface AllExtensions { - Gapcursor: typeof Gapcursor, - } +declare module '@tiptap/core' { + interface AllExtensions { + Gapcursor: typeof Gapcursor, } } diff --git a/packages/extension-hard-break/src/index.ts b/packages/extension-hard-break/src/index.ts index dcaa9c4092f..677b094160a 100644 --- a/packages/extension-hard-break/src/index.ts +++ b/packages/extension-hard-break/src/index.ts @@ -50,10 +50,8 @@ const HardBreak = Node.create({ export default HardBreak -declare global { - namespace Tiptap { - interface AllExtensions { - HardBreak: typeof HardBreak, - } +declare module '@tiptap/core' { + interface AllExtensions { + HardBreak: typeof HardBreak, } } diff --git a/packages/extension-heading/src/index.ts b/packages/extension-heading/src/index.ts index e94202639ee..c02b8a811ad 100644 --- a/packages/extension-heading/src/index.ts +++ b/packages/extension-heading/src/index.ts @@ -83,10 +83,8 @@ const Heading = Node.create({ export default Heading -declare global { - namespace Tiptap { - interface AllExtensions { - Heading: typeof Heading, - } +declare module '@tiptap/core' { + interface AllExtensions { + Heading: typeof Heading, } } diff --git a/packages/extension-highlight/src/index.ts b/packages/extension-highlight/src/index.ts index c57adfe5a56..c3298aa6c38 100644 --- a/packages/extension-highlight/src/index.ts +++ b/packages/extension-highlight/src/index.ts @@ -88,10 +88,8 @@ const Highlight = Mark.create({ export default Highlight -declare global { - namespace Tiptap { - interface AllExtensions { - Highlight: typeof Highlight, - } +declare module '@tiptap/core' { + interface AllExtensions { + Highlight: typeof Highlight, } } diff --git a/packages/extension-history/src/index.ts b/packages/extension-history/src/index.ts index 12e6ed7af7b..6f389f2ea45 100644 --- a/packages/extension-history/src/index.ts +++ b/packages/extension-history/src/index.ts @@ -46,10 +46,8 @@ const History = Extension.create({ export default History -declare global { - namespace Tiptap { - interface AllExtensions { - History: typeof History, - } +declare module '@tiptap/core' { + interface AllExtensions { + History: typeof History, } } diff --git a/packages/extension-horizontal-rule/src/index.ts b/packages/extension-horizontal-rule/src/index.ts index d8f0e04d4f7..ebab3e3bd3c 100644 --- a/packages/extension-horizontal-rule/src/index.ts +++ b/packages/extension-horizontal-rule/src/index.ts @@ -47,10 +47,8 @@ const HorizontalRule = Node.create({ export default HorizontalRule -declare global { - namespace Tiptap { - interface AllExtensions { - HorizontalRule: typeof HorizontalRule, - } +declare module '@tiptap/core' { + interface AllExtensions { + HorizontalRule: typeof HorizontalRule, } } diff --git a/packages/extension-image/src/index.ts b/packages/extension-image/src/index.ts index 9a8bfd938a7..7eeb831ba1d 100644 --- a/packages/extension-image/src/index.ts +++ b/packages/extension-image/src/index.ts @@ -82,10 +82,8 @@ const Image = Node.create({ export default Image -declare global { - namespace Tiptap { - interface AllExtensions { - Image: typeof Image, - } +declare module '@tiptap/core' { + interface AllExtensions { + Image: typeof Image, } } diff --git a/packages/extension-italic/src/index.ts b/packages/extension-italic/src/index.ts index 4b2261867ab..9843f65ec52 100644 --- a/packages/extension-italic/src/index.ts +++ b/packages/extension-italic/src/index.ts @@ -76,10 +76,8 @@ const Italic = Mark.create({ export default Italic -declare global { - namespace Tiptap { - interface AllExtensions { - Italic: typeof Italic, - } +declare module '@tiptap/core' { + interface AllExtensions { + Italic: typeof Italic, } } diff --git a/packages/extension-link/src/index.ts b/packages/extension-link/src/index.ts index 9aaf2f16adb..3570b998011 100644 --- a/packages/extension-link/src/index.ts +++ b/packages/extension-link/src/index.ts @@ -93,10 +93,8 @@ const Link = Mark.create({ export default Link -declare global { - namespace Tiptap { - interface AllExtensions { - Link: typeof Link, - } +declare module '@tiptap/core' { + interface AllExtensions { + Link: typeof Link, } } diff --git a/packages/extension-list-item/src/index.ts b/packages/extension-list-item/src/index.ts index bf587470f9b..b0d88118cff 100644 --- a/packages/extension-list-item/src/index.ts +++ b/packages/extension-list-item/src/index.ts @@ -40,10 +40,8 @@ const ListItem = Node.create({ export default ListItem -declare global { - namespace Tiptap { - interface AllExtensions { - ListItem: typeof ListItem, - } +declare module '@tiptap/core' { + interface AllExtensions { + ListItem: typeof ListItem, } } diff --git a/packages/extension-ordered-list/src/index.ts b/packages/extension-ordered-list/src/index.ts index da0b4afa897..d20b361a84c 100644 --- a/packages/extension-ordered-list/src/index.ts +++ b/packages/extension-ordered-list/src/index.ts @@ -80,10 +80,8 @@ const OrderedList = Node.create({ export default OrderedList -declare global { - namespace Tiptap { - interface AllExtensions { - OrderedList: typeof OrderedList, - } +declare module '@tiptap/core' { + interface AllExtensions { + OrderedList: typeof OrderedList, } } diff --git a/packages/extension-paragraph/src/index.ts b/packages/extension-paragraph/src/index.ts index d9712f1bd66..961d08eb5d9 100644 --- a/packages/extension-paragraph/src/index.ts +++ b/packages/extension-paragraph/src/index.ts @@ -47,10 +47,8 @@ const Paragraph = Node.create({ export default Paragraph -declare global { - namespace Tiptap { - interface AllExtensions { - Paragraph: typeof Paragraph, - } +declare module '@tiptap/core' { + interface AllExtensions { + Paragraph: typeof Paragraph, } } diff --git a/packages/extension-strike/src/index.ts b/packages/extension-strike/src/index.ts index b74df416851..197e949eca0 100644 --- a/packages/extension-strike/src/index.ts +++ b/packages/extension-strike/src/index.ts @@ -74,10 +74,8 @@ const Strike = Mark.create({ export default Strike -declare global { - namespace Tiptap { - interface AllExtensions { - Strike: typeof Strike, - } +declare module '@tiptap/core' { + interface AllExtensions { + Strike: typeof Strike, } } diff --git a/packages/extension-task-item/src/index.ts b/packages/extension-task-item/src/index.ts index 18202b4a015..ce7c0ab3ca1 100644 --- a/packages/extension-task-item/src/index.ts +++ b/packages/extension-task-item/src/index.ts @@ -125,10 +125,8 @@ const TaskItem = Node.create({ export default TaskItem -declare global { - namespace Tiptap { - interface AllExtensions { - TaskItem: typeof TaskItem, - } +declare module '@tiptap/core' { + interface AllExtensions { + TaskItem: typeof TaskItem, } } diff --git a/packages/extension-task-list/src/index.ts b/packages/extension-task-list/src/index.ts index c5c1d17117b..554cf283714 100644 --- a/packages/extension-task-list/src/index.ts +++ b/packages/extension-task-list/src/index.ts @@ -44,10 +44,8 @@ const TaskList = Node.create({ export default TaskList -declare global { - namespace Tiptap { - interface AllExtensions { - TaskList: typeof TaskList, - } +declare module '@tiptap/core' { + interface AllExtensions { + TaskList: typeof TaskList, } } diff --git a/packages/extension-text-align/src/index.ts b/packages/extension-text-align/src/index.ts index 46847db1b6e..63fb2279d0c 100644 --- a/packages/extension-text-align/src/index.ts +++ b/packages/extension-text-align/src/index.ts @@ -65,10 +65,8 @@ const TextAlign = Extension.create({ export default TextAlign -declare global { - namespace Tiptap { - interface AllExtensions { - TextAlign: typeof TextAlign, - } +declare module '@tiptap/core' { + interface AllExtensions { + TextAlign: typeof TextAlign, } } diff --git a/packages/extension-text-style/src/index.ts b/packages/extension-text-style/src/index.ts index aaea4511c18..bed66e3246a 100644 --- a/packages/extension-text-style/src/index.ts +++ b/packages/extension-text-style/src/index.ts @@ -46,10 +46,8 @@ const TextStyle = Mark.create({ export default TextStyle -declare global { - namespace Tiptap { - interface AllExtensions { - TextStyle: typeof TextStyle, - } +declare module '@tiptap/core' { + interface AllExtensions { + TextStyle: typeof TextStyle, } } diff --git a/packages/extension-text/src/index.ts b/packages/extension-text/src/index.ts index 2180e1c25e0..b6bea78dec2 100644 --- a/packages/extension-text/src/index.ts +++ b/packages/extension-text/src/index.ts @@ -7,10 +7,8 @@ const Text = Node.create({ export default Text -declare global { - namespace Tiptap { - interface AllExtensions { - Text: typeof Text, - } +declare module '@tiptap/core' { + interface AllExtensions { + Text: typeof Text, } } diff --git a/packages/extension-typography/src/index.ts b/packages/extension-typography/src/index.ts index 3b35dc939ac..34e696c4623 100644 --- a/packages/extension-typography/src/index.ts +++ b/packages/extension-typography/src/index.ts @@ -45,10 +45,8 @@ const Typography = Extension.create({ export default Typography -declare global { - namespace Tiptap { - interface AllExtensions { - Typography: typeof Typography, - } +declare module '@tiptap/core' { + interface AllExtensions { + Typography: typeof Typography, } } diff --git a/packages/extension-underline/src/index.ts b/packages/extension-underline/src/index.ts index 4bfe1ee509e..0f9cb39c1ce 100644 --- a/packages/extension-underline/src/index.ts +++ b/packages/extension-underline/src/index.ts @@ -45,10 +45,8 @@ const Underline = Mark.create({ export default Underline -declare global { - namespace Tiptap { - interface AllExtensions { - Underline: typeof Underline, - } +declare module '@tiptap/core' { + interface AllExtensions { + Underline: typeof Underline, } }