Skip to content

Commit

Permalink
Revert "use global namespace"
Browse files Browse the repository at this point in the history
This reverts commit 24c3a9a.

# Conflicts:
#	packages/core/src/Editor.ts
  • Loading branch information
philippkuehn committed Nov 16, 2020
1 parent 0cee9fb commit 0c9ce26
Show file tree
Hide file tree
Showing 39 changed files with 118 additions and 197 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/CommandManager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EditorState, Transaction } from 'prosemirror-state'
import {
Editor,
CommandSpec,
SingleCommands,
ChainedCommands,
Editor,
CommandSpec,
} from './Editor'
import getAllMethodNames from './utils/getAllMethodNames'

Expand Down
22 changes: 10 additions & 12 deletions packages/core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/extensions/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/core/src/extensions/editable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/core/src/extensions/focusEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/core/src/extensions/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
7 changes: 1 addition & 6 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
export {
Editor,
Command,
CommandsSpec,
} from './Editor'

export * from './Editor'
export * from './Extension'
export * from './Node'
export * from './Mark'
Expand Down
8 changes: 3 additions & 5 deletions packages/extension-blockquote/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-bold/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-bullet-list/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-code-block/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-code/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-collaboration-cursor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-collaboration/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-dropcursor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-focus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-font-family/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-gapcursor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-hard-break/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-heading/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-highlight/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-history/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-horizontal-rule/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-image/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
8 changes: 3 additions & 5 deletions packages/extension-italic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Loading

0 comments on commit 0c9ce26

Please sign in to comment.