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/comma-dangle': ['error', 'always-multiline'],
'@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 {
Editor,
CommandSpec,
SingleCommands,
ChainedCommands,
Editor,
CommandSpec,
} from './Editor'
import getAllMethodNames from './utils/getAllMethodNames'

View File

@ -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<any, infer ExtensionCommands>
export type UnfilteredCommands = {
[Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands>
? ExtensionCommands
: Tiptap.AllExtensions[Item] extends Node<any, infer NodeCommands>
: AllExtensions[Item] extends Node<any, infer NodeCommands>
? NodeCommands
: Tiptap.AllExtensions[Item] extends Mark<any, infer MarkCommands>
: AllExtensions[Item] extends Mark<any, infer MarkCommands>
? MarkCommands
: never
}
type ValuesOf<T> = T[keyof T];
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 ValuesOf<T> = T[keyof T];
export type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T]
export type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>>
export type SingleCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

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

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}