Revert "use global namespace"

This reverts commit 24c3a9abd3.

# Conflicts:
#	packages/core/src/Editor.ts
This commit is contained in:
Philipp Kühn
2020-11-16 16:58:30 +01:00
parent 0cee9fb3b7
commit 0c9ce26c02
39 changed files with 118 additions and 197 deletions

View File

@@ -70,8 +70,6 @@ module.exports = {
'@typescript-eslint/ban-types': 'off', '@typescript-eslint/ban-types': 'off',
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'], '@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
'@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-namespace': 'off',
'no-undef': 'off',
}, },
}, },
], ],

View File

@@ -1,9 +1,9 @@
import { EditorState, Transaction } from 'prosemirror-state' import { EditorState, Transaction } from 'prosemirror-state'
import { import {
Editor,
CommandSpec,
SingleCommands, SingleCommands,
ChainedCommands, ChainedCommands,
Editor,
CommandSpec,
} from './Editor' } from './Editor'
import getAllMethodNames from './utils/getAllMethodNames' import getAllMethodNames from './utils/getAllMethodNames'

View File

@@ -21,6 +21,8 @@ import { Extensions, UnionToIntersection } from './types'
import * as extensions from './extensions' import * as extensions from './extensions'
import style from './style' import style from './style'
export { extensions }
export type Command = (props: { export type Command = (props: {
editor: Editor, editor: Editor,
tr: Transaction, tr: Transaction,
@@ -38,25 +40,21 @@ export interface CommandsSpec {
[key: string]: CommandSpec [key: string]: CommandSpec
} }
declare global { export interface AllExtensions {}
namespace Tiptap {
export interface AllExtensions {}
}
}
type UnfilteredCommands = { export type UnfilteredCommands = {
[Item in keyof Tiptap.AllExtensions]: Tiptap.AllExtensions[Item] extends Extension<any, infer ExtensionCommands> [Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands>
? ExtensionCommands ? ExtensionCommands
: Tiptap.AllExtensions[Item] extends Node<any, infer NodeCommands> : AllExtensions[Item] extends Node<any, infer NodeCommands>
? NodeCommands ? NodeCommands
: Tiptap.AllExtensions[Item] extends Mark<any, infer MarkCommands> : AllExtensions[Item] extends Mark<any, infer MarkCommands>
? MarkCommands ? MarkCommands
: never : never
} }
type ValuesOf<T> = T[keyof T]; export type ValuesOf<T> = T[keyof T];
type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T] export type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T]
type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>> export type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>>
export type SingleCommands = { export type SingleCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any [Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any

View File

@@ -147,10 +147,8 @@ export const Commands = Extension.create({
}, },
}) })
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Commands: typeof Commands, Commands: typeof Commands,
} }
}
} }

View File

@@ -14,10 +14,8 @@ export const Editable = Extension.create({
}, },
}) })
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Editable: typeof Editable, Editable: typeof Editable,
} }
}
} }

View File

@@ -36,10 +36,8 @@ export const FocusEvents = Extension.create({
}, },
}) })
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
FocusEvents: typeof FocusEvents, FocusEvents: typeof FocusEvents,
} }
}
} }

View File

@@ -45,10 +45,8 @@ export const Keymap = Extension.create({
}, },
}) })
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Keymap: typeof Keymap, Keymap: typeof Keymap,
} }
}
} }

View File

@@ -1,9 +1,4 @@
export { export * from './Editor'
Editor,
Command,
CommandsSpec,
} from './Editor'
export * from './Extension' export * from './Extension'
export * from './Node' export * from './Node'
export * from './Mark' export * from './Mark'

View File

@@ -58,10 +58,8 @@ const Blockquote = Node.create({
export default Blockquote export default Blockquote
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Blockquote: typeof Blockquote, Blockquote: typeof Blockquote,
} }
}
} }

View File

@@ -74,10 +74,8 @@ const Bold = Mark.create({
export default Bold export default Bold
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Bold: typeof Bold, Bold: typeof Bold,
} }
}
} }

View File

@@ -56,10 +56,8 @@ const BulletList = Node.create({
export default BulletList export default BulletList
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
BulletList: typeof BulletList, BulletList: typeof BulletList,
} }
}
} }

View File

@@ -99,10 +99,8 @@ const CodeBlock = Node.create({
export default CodeBlock export default CodeBlock
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
CodeBlock: typeof CodeBlock, CodeBlock: typeof CodeBlock,
} }
}
} }

View File

@@ -65,10 +65,8 @@ const Code = Mark.create({
export default Code export default Code
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Code: typeof Code, Code: typeof Code,
} }
}
} }

View File

@@ -64,10 +64,8 @@ const CollaborationCursor = Extension.create({
export default CollaborationCursor export default CollaborationCursor
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
CollaborationCursor: typeof CollaborationCursor, CollaborationCursor: typeof CollaborationCursor,
} }
}
} }

View File

@@ -32,10 +32,8 @@ const Collaboration = Extension.create({
export default Collaboration export default Collaboration
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Collaboration: typeof Collaboration, Collaboration: typeof Collaboration,
} }
}
} }

View File

@@ -8,10 +8,8 @@ const Document = Node.create({
export default Document export default Document
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Document: typeof Document, Document: typeof Document,
} }
}
} }

View File

@@ -11,10 +11,8 @@ const Dropcursor = Extension.create({
export default Dropcursor export default Dropcursor
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Dropcursor: typeof Dropcursor, Dropcursor: typeof Dropcursor,
} }
}
} }

View File

@@ -50,10 +50,8 @@ const FocusClasses = Extension.create({
export default FocusClasses export default FocusClasses
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
FocusClasses: typeof FocusClasses, FocusClasses: typeof FocusClasses,
} }
}
} }

View File

@@ -52,10 +52,8 @@ const FontFamily = Extension.create({
export default FontFamily export default FontFamily
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
FontFamily: typeof FontFamily, FontFamily: typeof FontFamily,
} }
}
} }

View File

@@ -11,10 +11,8 @@ const Gapcursor = Extension.create({
export default Gapcursor export default Gapcursor
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Gapcursor: typeof Gapcursor, Gapcursor: typeof Gapcursor,
} }
}
} }

View File

@@ -50,10 +50,8 @@ const HardBreak = Node.create({
export default HardBreak export default HardBreak
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
HardBreak: typeof HardBreak, HardBreak: typeof HardBreak,
} }
}
} }

View File

@@ -83,10 +83,8 @@ const Heading = Node.create({
export default Heading export default Heading
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Heading: typeof Heading, Heading: typeof Heading,
} }
}
} }

View File

@@ -88,10 +88,8 @@ const Highlight = Mark.create({
export default Highlight export default Highlight
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Highlight: typeof Highlight, Highlight: typeof Highlight,
} }
}
} }

View File

@@ -46,10 +46,8 @@ const History = Extension.create({
export default History export default History
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
History: typeof History, History: typeof History,
} }
}
} }

View File

@@ -47,10 +47,8 @@ const HorizontalRule = Node.create({
export default HorizontalRule export default HorizontalRule
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
HorizontalRule: typeof HorizontalRule, HorizontalRule: typeof HorizontalRule,
} }
}
} }

View File

@@ -82,10 +82,8 @@ const Image = Node.create({
export default Image export default Image
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Image: typeof Image, Image: typeof Image,
} }
}
} }

View File

@@ -76,10 +76,8 @@ const Italic = Mark.create({
export default Italic export default Italic
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Italic: typeof Italic, Italic: typeof Italic,
} }
}
} }

View File

@@ -93,10 +93,8 @@ const Link = Mark.create({
export default Link export default Link
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Link: typeof Link, Link: typeof Link,
} }
}
} }

View File

@@ -40,10 +40,8 @@ const ListItem = Node.create({
export default ListItem export default ListItem
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
ListItem: typeof ListItem, ListItem: typeof ListItem,
} }
}
} }

View File

@@ -80,10 +80,8 @@ const OrderedList = Node.create({
export default OrderedList export default OrderedList
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
OrderedList: typeof OrderedList, OrderedList: typeof OrderedList,
} }
}
} }

View File

@@ -47,10 +47,8 @@ const Paragraph = Node.create({
export default Paragraph export default Paragraph
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Paragraph: typeof Paragraph, Paragraph: typeof Paragraph,
} }
}
} }

View File

@@ -74,10 +74,8 @@ const Strike = Mark.create({
export default Strike export default Strike
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Strike: typeof Strike, Strike: typeof Strike,
} }
}
} }

View File

@@ -125,10 +125,8 @@ const TaskItem = Node.create({
export default TaskItem export default TaskItem
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
TaskItem: typeof TaskItem, TaskItem: typeof TaskItem,
} }
}
} }

View File

@@ -44,10 +44,8 @@ const TaskList = Node.create({
export default TaskList export default TaskList
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
TaskList: typeof TaskList, TaskList: typeof TaskList,
} }
}
} }

View File

@@ -65,10 +65,8 @@ const TextAlign = Extension.create({
export default TextAlign export default TextAlign
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
TextAlign: typeof TextAlign, TextAlign: typeof TextAlign,
} }
}
} }

View File

@@ -46,10 +46,8 @@ const TextStyle = Mark.create({
export default TextStyle export default TextStyle
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
TextStyle: typeof TextStyle, TextStyle: typeof TextStyle,
} }
}
} }

View File

@@ -7,10 +7,8 @@ const Text = Node.create({
export default Text export default Text
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Text: typeof Text, Text: typeof Text,
} }
}
} }

View File

@@ -45,10 +45,8 @@ const Typography = Extension.create({
export default Typography export default Typography
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Typography: typeof Typography, Typography: typeof Typography,
} }
}
} }

View File

@@ -45,10 +45,8 @@ const Underline = Mark.create({
export default Underline export default Underline
declare global { declare module '@tiptap/core' {
namespace Tiptap {
interface AllExtensions { interface AllExtensions {
Underline: typeof Underline, Underline: typeof Underline,
} }
}
} }