Skip to content

Commit

Permalink
refactor: Use named exports instead of default exports (#2238)
Browse files Browse the repository at this point in the history
* use named exports instead of default exports

* fix tests

Co-authored-by: Philipp Kühn <[email protected]>
  • Loading branch information
philippkuehn and Philipp Kühn authored Dec 6, 2021
1 parent fa8318c commit e07a5b6
Show file tree
Hide file tree
Showing 123 changed files with 279 additions and 283 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/CommandManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EditorState, Transaction } from 'prosemirror-state'
import { Editor } from './Editor'
import createChainableState from './helpers/createChainableState'
import { createChainableState } from './helpers/createChainableState'
import {
SingleCommands,
ChainedCommands,
Expand All @@ -9,7 +9,7 @@ import {
CommandProps,
} from './types'

export default class CommandManager {
export class CommandManager {

editor: Editor

Expand Down
28 changes: 14 additions & 14 deletions packages/core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import {
} from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { Schema, MarkType, NodeType } from 'prosemirror-model'
import getAttributes from './helpers/getAttributes'
import isActive from './helpers/isActive'
import createDocument from './helpers/createDocument'
import getHTMLFromFragment from './helpers/getHTMLFromFragment'
import getText from './helpers/getText'
import isNodeEmpty from './helpers/isNodeEmpty'
import resolveFocusPosition from './helpers/resolveFocusPosition'
import getTextSeralizersFromSchema from './helpers/getTextSeralizersFromSchema'
import createStyleTag from './utilities/createStyleTag'
import isFunction from './utilities/isFunction'
import CommandManager from './CommandManager'
import ExtensionManager from './ExtensionManager'
import EventEmitter from './EventEmitter'
import { getAttributes } from './helpers/getAttributes'
import { isActive } from './helpers/isActive'
import { createDocument } from './helpers/createDocument'
import { getHTMLFromFragment } from './helpers/getHTMLFromFragment'
import { getText } from './helpers/getText'
import { isNodeEmpty } from './helpers/isNodeEmpty'
import { resolveFocusPosition } from './helpers/resolveFocusPosition'
import { getTextSeralizersFromSchema } from './helpers/getTextSeralizersFromSchema'
import { createStyleTag } from './utilities/createStyleTag'
import { isFunction } from './utilities/isFunction'
import { CommandManager } from './CommandManager'
import { ExtensionManager } from './ExtensionManager'
import { EventEmitter } from './EventEmitter'
import {
EditorOptions,
CanCommands,
Expand All @@ -29,7 +29,7 @@ import {
EditorEvents,
} from './types'
import * as extensions from './extensions'
import style from './style'
import { style } from './style'

export { extensions }

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type CallbackFunction<
EventName extends StringKeyOf<T>,
> = (...props: CallbackType<T, EventName>) => any

export default class EventEmitter<T extends Record<string, any>> {
export class EventEmitter<T extends Record<string, any>> {

private callbacks: { [key: string]: Function[] } = {}

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { PasteRule } from './PasteRule'
import { Editor } from './Editor'
import { Node } from './Node'
import { Mark } from './Mark'
import mergeDeep from './utilities/mergeDeep'
import callOrReturn from './utilities/callOrReturn'
import getExtensionField from './helpers/getExtensionField'
import { mergeDeep } from './utilities/mergeDeep'
import { callOrReturn } from './utilities/callOrReturn'
import { getExtensionField } from './helpers/getExtensionField'
import {
AnyConfig,
Extensions,
Expand Down
22 changes: 11 additions & 11 deletions packages/core/src/ExtensionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { EditorView, Decoration } from 'prosemirror-view'
import { Plugin } from 'prosemirror-state'
import { Editor } from './Editor'
import { Extensions, RawCommands, AnyConfig } from './types'
import getExtensionField from './helpers/getExtensionField'
import getSchemaByResolvedExtensions from './helpers/getSchemaByResolvedExtensions'
import getSchemaTypeByName from './helpers/getSchemaTypeByName'
import getNodeType from './helpers/getNodeType'
import splitExtensions from './helpers/splitExtensions'
import getAttributesFromExtensions from './helpers/getAttributesFromExtensions'
import getRenderedAttributes from './helpers/getRenderedAttributes'
import isExtensionRulesEnabled from './helpers/isExtensionRulesEnabled'
import callOrReturn from './utilities/callOrReturn'
import findDuplicates from './utilities/findDuplicates'
import { getExtensionField } from './helpers/getExtensionField'
import { getSchemaByResolvedExtensions } from './helpers/getSchemaByResolvedExtensions'
import { getSchemaTypeByName } from './helpers/getSchemaTypeByName'
import { getNodeType } from './helpers/getNodeType'
import { splitExtensions } from './helpers/splitExtensions'
import { getAttributesFromExtensions } from './helpers/getAttributesFromExtensions'
import { getRenderedAttributes } from './helpers/getRenderedAttributes'
import { isExtensionRulesEnabled } from './helpers/isExtensionRulesEnabled'
import { callOrReturn } from './utilities/callOrReturn'
import { findDuplicates } from './utilities/findDuplicates'
import { NodeConfig } from '.'

export default class ExtensionManager {
export class ExtensionManager {

editor: Editor

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/InputRule.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EditorState, Plugin, TextSelection } from 'prosemirror-state'
import { Editor } from './Editor'
import CommandManager from './CommandManager'
import createChainableState from './helpers/createChainableState'
import isRegExp from './utilities/isRegExp'
import { CommandManager } from './CommandManager'
import { createChainableState } from './helpers/createChainableState'
import { isRegExp } from './utilities/isRegExp'
import {
Range,
ExtendedRegExpMatchArray,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
import { Plugin, Transaction } from 'prosemirror-state'
import { InputRule } from './InputRule'
import { PasteRule } from './PasteRule'
import mergeDeep from './utilities/mergeDeep'
import callOrReturn from './utilities/callOrReturn'
import getExtensionField from './helpers/getExtensionField'
import { mergeDeep } from './utilities/mergeDeep'
import { callOrReturn } from './utilities/callOrReturn'
import { getExtensionField } from './helpers/getExtensionField'
import {
AnyConfig,
Extensions,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
import { Plugin, Transaction } from 'prosemirror-state'
import { InputRule } from './InputRule'
import { PasteRule } from './PasteRule'
import mergeDeep from './utilities/mergeDeep'
import callOrReturn from './utilities/callOrReturn'
import getExtensionField from './helpers/getExtensionField'
import { mergeDeep } from './utilities/mergeDeep'
import { callOrReturn } from './utilities/callOrReturn'
import { getExtensionField } from './helpers/getExtensionField'
import {
AnyConfig,
Extensions,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/NodeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NodeSelection } from 'prosemirror-state'
import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Editor as CoreEditor } from './Editor'
import { Node } from './Node'
import isiOS from './utilities/isiOS'
import { isiOS } from './utilities/isiOS'
import { NodeViewRendererProps, NodeViewRendererOptions } from './types'

export class NodeView<
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/PasteRule.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EditorState, Plugin } from 'prosemirror-state'
import { Editor } from './Editor'
import CommandManager from './CommandManager'
import createChainableState from './helpers/createChainableState'
import isRegExp from './utilities/isRegExp'
import isNumber from './utilities/isNumber'
import { CommandManager } from './CommandManager'
import { createChainableState } from './helpers/createChainableState'
import { isRegExp } from './utilities/isRegExp'
import { isNumber } from './utilities/isNumber'
import {
Range,
ExtendedRegExpMatchArray,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/deleteNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import { getNodeType } from '../helpers/getNodeType'
import { RawCommands } from '../types'

declare module '@tiptap/core' {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/extendMarkRange.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TextSelection } from 'prosemirror-state'
import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType'
import getMarkRange from '../helpers/getMarkRange'
import { getMarkType } from '../helpers/getMarkType'
import { getMarkRange } from '../helpers/getMarkRange'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/commands/focus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RawCommands, FocusPosition } from '../types'
import isTextSelection from '../helpers/isTextSelection'
import isiOS from '../utilities/isiOS'
import resolveFocusPosition from '../helpers/resolveFocusPosition'
import { isTextSelection } from '../helpers/isTextSelection'
import { isiOS } from '../utilities/isiOS'
import { resolveFocusPosition } from '../helpers/resolveFocusPosition'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/insertContentAt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fragment, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model'
import createNodeFromContent from '../helpers/createNodeFromContent'
import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd'
import { createNodeFromContent } from '../helpers/createNodeFromContent'
import { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd'
import {
RawCommands,
Content,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/lift.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { lift as originalLift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType'
import { isNodeActive } from '../helpers/isNodeActive'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/liftListItem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/commands/resetAttributes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NodeType, MarkType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import getMarkType from '../helpers/getMarkType'
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
import deleteProps from '../utilities/deleteProps'
import { getNodeType } from '../helpers/getNodeType'
import { getMarkType } from '../helpers/getMarkType'
import { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName'
import { deleteProps } from '../utilities/deleteProps'
import { RawCommands } from '../types'

declare module '@tiptap/core' {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/setContent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TextSelection } from 'prosemirror-state'
import { ParseOptions } from 'prosemirror-model'
import createDocument from '../helpers/createDocument'
import { createDocument } from '../helpers/createDocument'
import { RawCommands, Content } from '../types'

declare module '@tiptap/core' {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/setMark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType'
import getMarkAttributes from '../helpers/getMarkAttributes'
import { getMarkType } from '../helpers/getMarkType'
import { getMarkAttributes } from '../helpers/getMarkAttributes'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/setNode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NodeType } from 'prosemirror-model'
import { setBlockType } from 'prosemirror-commands'
import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/setNodeSelection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Selection, NodeSelection } from 'prosemirror-state'
import minMax from '../utilities/minMax'
import { minMax } from '../utilities/minMax'
import { RawCommands } from '../types'

declare module '@tiptap/core' {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/setTextSelection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Selection, TextSelection } from 'prosemirror-state'
import minMax from '../utilities/minMax'
import { minMax } from '../utilities/minMax'
import { RawCommands, Range } from '../types'

declare module '@tiptap/core' {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/sinkListItem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/splitBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { canSplit } from 'prosemirror-transform'
import { ContentMatch } from 'prosemirror-model'
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
import { RawCommands } from '../types'
import getSplittedAttributes from '../helpers/getSplittedAttributes'
import { getSplittedAttributes } from '../helpers/getSplittedAttributes'

function defaultBlockAt(match: ContentMatch) {
for (let i = 0; i < match.edgeCount; i += 1) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/splitListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
import { canSplit } from 'prosemirror-transform'
import { TextSelection } from 'prosemirror-state'
import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType'
import getSplittedAttributes from '../helpers/getSplittedAttributes'
import { getNodeType } from '../helpers/getNodeType'
import { getSplittedAttributes } from '../helpers/getSplittedAttributes'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/commands/toggleList.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType'
import findParentNode from '../helpers/findParentNode'
import isList from '../helpers/isList'
import { getNodeType } from '../helpers/getNodeType'
import { findParentNode } from '../helpers/findParentNode'
import { isList } from '../helpers/isList'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/toggleMark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType'
import isMarkActive from '../helpers/isMarkActive'
import { getMarkType } from '../helpers/getMarkType'
import { isMarkActive } from '../helpers/isMarkActive'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/toggleNode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType'
import { isNodeActive } from '../helpers/isNodeActive'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/toggleWrap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { wrapIn, lift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType'
import { isNodeActive } from '../helpers/isNodeActive'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/unsetMark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType'
import getMarkRange from '../helpers/getMarkRange'
import { getMarkType } from '../helpers/getMarkType'
import { getMarkRange } from '../helpers/getMarkRange'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/commands/updateAttributes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NodeType, MarkType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType'
import getMarkType from '../helpers/getMarkType'
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
import { getNodeType } from '../helpers/getNodeType'
import { getMarkType } from '../helpers/getMarkType'
import { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName'
import { RawCommands } from '../types'

declare module '@tiptap/core' {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/commands/wrapIn.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { wrapIn as originalWrapIn } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType'
import { isNodeActive } from '../helpers/isNodeActive'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/wrapInList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType'
import { getNodeType } from '../helpers/getNodeType'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down
Loading

0 comments on commit e07a5b6

Please sign in to comment.