refactor: Use named exports instead of default exports (#2238)

* use named exports instead of default exports

* fix tests

Co-authored-by: Philipp Kühn <philippkuehn@MacBook-Pro-von-Philipp.local>
This commit is contained in:
Philipp Kühn 2021-12-06 12:00:09 +01:00 committed by GitHub
parent fa8318c38f
commit e07a5b625d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
123 changed files with 279 additions and 283 deletions

View File

@ -1,6 +1,6 @@
import { EditorState, Transaction } from 'prosemirror-state' import { EditorState, Transaction } from 'prosemirror-state'
import { Editor } from './Editor' import { Editor } from './Editor'
import createChainableState from './helpers/createChainableState' import { createChainableState } from './helpers/createChainableState'
import { import {
SingleCommands, SingleCommands,
ChainedCommands, ChainedCommands,
@ -9,7 +9,7 @@ import {
CommandProps, CommandProps,
} from './types' } from './types'
export default class CommandManager { export class CommandManager {
editor: Editor editor: Editor

View File

@ -6,19 +6,19 @@ import {
} from 'prosemirror-state' } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view' import { EditorView } from 'prosemirror-view'
import { Schema, MarkType, NodeType } from 'prosemirror-model' import { Schema, MarkType, NodeType } from 'prosemirror-model'
import getAttributes from './helpers/getAttributes' import { getAttributes } from './helpers/getAttributes'
import isActive from './helpers/isActive' import { isActive } from './helpers/isActive'
import createDocument from './helpers/createDocument' import { createDocument } from './helpers/createDocument'
import getHTMLFromFragment from './helpers/getHTMLFromFragment' import { getHTMLFromFragment } from './helpers/getHTMLFromFragment'
import getText from './helpers/getText' import { getText } from './helpers/getText'
import isNodeEmpty from './helpers/isNodeEmpty' import { isNodeEmpty } from './helpers/isNodeEmpty'
import resolveFocusPosition from './helpers/resolveFocusPosition' import { resolveFocusPosition } from './helpers/resolveFocusPosition'
import getTextSeralizersFromSchema from './helpers/getTextSeralizersFromSchema' import { getTextSeralizersFromSchema } from './helpers/getTextSeralizersFromSchema'
import createStyleTag from './utilities/createStyleTag' import { createStyleTag } from './utilities/createStyleTag'
import isFunction from './utilities/isFunction' import { isFunction } from './utilities/isFunction'
import CommandManager from './CommandManager' import { CommandManager } from './CommandManager'
import ExtensionManager from './ExtensionManager' import { ExtensionManager } from './ExtensionManager'
import EventEmitter from './EventEmitter' import { EventEmitter } from './EventEmitter'
import { import {
EditorOptions, EditorOptions,
CanCommands, CanCommands,
@ -29,7 +29,7 @@ import {
EditorEvents, EditorEvents,
} from './types' } from './types'
import * as extensions from './extensions' import * as extensions from './extensions'
import style from './style' import { style } from './style'
export { extensions } export { extensions }

View File

@ -8,7 +8,7 @@ type CallbackFunction<
EventName extends StringKeyOf<T>, EventName extends StringKeyOf<T>,
> = (...props: CallbackType<T, EventName>) => any > = (...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[] } = {} private callbacks: { [key: string]: Function[] } = {}

View File

@ -4,9 +4,9 @@ import { PasteRule } from './PasteRule'
import { Editor } from './Editor' import { Editor } from './Editor'
import { Node } from './Node' import { Node } from './Node'
import { Mark } from './Mark' import { Mark } from './Mark'
import mergeDeep from './utilities/mergeDeep' import { mergeDeep } from './utilities/mergeDeep'
import callOrReturn from './utilities/callOrReturn' import { callOrReturn } from './utilities/callOrReturn'
import getExtensionField from './helpers/getExtensionField' import { getExtensionField } from './helpers/getExtensionField'
import { import {
AnyConfig, AnyConfig,
Extensions, Extensions,

View File

@ -6,19 +6,19 @@ import { EditorView, Decoration } from 'prosemirror-view'
import { Plugin } from 'prosemirror-state' import { Plugin } from 'prosemirror-state'
import { Editor } from './Editor' import { Editor } from './Editor'
import { Extensions, RawCommands, AnyConfig } from './types' import { Extensions, RawCommands, AnyConfig } from './types'
import getExtensionField from './helpers/getExtensionField' import { getExtensionField } from './helpers/getExtensionField'
import getSchemaByResolvedExtensions from './helpers/getSchemaByResolvedExtensions' import { getSchemaByResolvedExtensions } from './helpers/getSchemaByResolvedExtensions'
import getSchemaTypeByName from './helpers/getSchemaTypeByName' import { getSchemaTypeByName } from './helpers/getSchemaTypeByName'
import getNodeType from './helpers/getNodeType' import { getNodeType } from './helpers/getNodeType'
import splitExtensions from './helpers/splitExtensions' import { splitExtensions } from './helpers/splitExtensions'
import getAttributesFromExtensions from './helpers/getAttributesFromExtensions' import { getAttributesFromExtensions } from './helpers/getAttributesFromExtensions'
import getRenderedAttributes from './helpers/getRenderedAttributes' import { getRenderedAttributes } from './helpers/getRenderedAttributes'
import isExtensionRulesEnabled from './helpers/isExtensionRulesEnabled' import { isExtensionRulesEnabled } from './helpers/isExtensionRulesEnabled'
import callOrReturn from './utilities/callOrReturn' import { callOrReturn } from './utilities/callOrReturn'
import findDuplicates from './utilities/findDuplicates' import { findDuplicates } from './utilities/findDuplicates'
import { NodeConfig } from '.' import { NodeConfig } from '.'
export default class ExtensionManager { export class ExtensionManager {
editor: Editor editor: Editor

View File

@ -1,8 +1,8 @@
import { EditorState, Plugin, TextSelection } from 'prosemirror-state' import { EditorState, Plugin, TextSelection } from 'prosemirror-state'
import { Editor } from './Editor' import { Editor } from './Editor'
import CommandManager from './CommandManager' import { CommandManager } from './CommandManager'
import createChainableState from './helpers/createChainableState' import { createChainableState } from './helpers/createChainableState'
import isRegExp from './utilities/isRegExp' import { isRegExp } from './utilities/isRegExp'
import { import {
Range, Range,
ExtendedRegExpMatchArray, ExtendedRegExpMatchArray,

View File

@ -7,9 +7,9 @@ import {
import { Plugin, Transaction } from 'prosemirror-state' import { Plugin, Transaction } from 'prosemirror-state'
import { InputRule } from './InputRule' import { InputRule } from './InputRule'
import { PasteRule } from './PasteRule' import { PasteRule } from './PasteRule'
import mergeDeep from './utilities/mergeDeep' import { mergeDeep } from './utilities/mergeDeep'
import callOrReturn from './utilities/callOrReturn' import { callOrReturn } from './utilities/callOrReturn'
import getExtensionField from './helpers/getExtensionField' import { getExtensionField } from './helpers/getExtensionField'
import { import {
AnyConfig, AnyConfig,
Extensions, Extensions,

View File

@ -7,9 +7,9 @@ import {
import { Plugin, Transaction } from 'prosemirror-state' import { Plugin, Transaction } from 'prosemirror-state'
import { InputRule } from './InputRule' import { InputRule } from './InputRule'
import { PasteRule } from './PasteRule' import { PasteRule } from './PasteRule'
import mergeDeep from './utilities/mergeDeep' import { mergeDeep } from './utilities/mergeDeep'
import callOrReturn from './utilities/callOrReturn' import { callOrReturn } from './utilities/callOrReturn'
import getExtensionField from './helpers/getExtensionField' import { getExtensionField } from './helpers/getExtensionField'
import { import {
AnyConfig, AnyConfig,
Extensions, Extensions,

View File

@ -3,7 +3,7 @@ import { NodeSelection } from 'prosemirror-state'
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Editor as CoreEditor } from './Editor' import { Editor as CoreEditor } from './Editor'
import { Node } from './Node' import { Node } from './Node'
import isiOS from './utilities/isiOS' import { isiOS } from './utilities/isiOS'
import { NodeViewRendererProps, NodeViewRendererOptions } from './types' import { NodeViewRendererProps, NodeViewRendererOptions } from './types'
export class NodeView< export class NodeView<

View File

@ -1,9 +1,9 @@
import { EditorState, Plugin } from 'prosemirror-state' import { EditorState, Plugin } from 'prosemirror-state'
import { Editor } from './Editor' import { Editor } from './Editor'
import CommandManager from './CommandManager' import { CommandManager } from './CommandManager'
import createChainableState from './helpers/createChainableState' import { createChainableState } from './helpers/createChainableState'
import isRegExp from './utilities/isRegExp' import { isRegExp } from './utilities/isRegExp'
import isNumber from './utilities/isNumber' import { isNumber } from './utilities/isNumber'
import { import {
Range, Range,
ExtendedRegExpMatchArray, ExtendedRegExpMatchArray,

View File

@ -1,5 +1,5 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
import { RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {

View File

@ -1,8 +1,8 @@
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import { getMarkType } from '../helpers/getMarkType'
import getMarkRange from '../helpers/getMarkRange' import { getMarkRange } from '../helpers/getMarkRange'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { RawCommands, FocusPosition } from '../types' import { RawCommands, FocusPosition } from '../types'
import isTextSelection from '../helpers/isTextSelection' import { isTextSelection } from '../helpers/isTextSelection'
import isiOS from '../utilities/isiOS' import { isiOS } from '../utilities/isiOS'
import resolveFocusPosition from '../helpers/resolveFocusPosition' import { resolveFocusPosition } from '../helpers/resolveFocusPosition'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,6 +1,6 @@
import { Fragment, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model' import { Fragment, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model'
import createNodeFromContent from '../helpers/createNodeFromContent' import { createNodeFromContent } from '../helpers/createNodeFromContent'
import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd' import { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd'
import { import {
RawCommands, RawCommands,
Content, Content,

View File

@ -1,8 +1,8 @@
import { lift as originalLift } from 'prosemirror-commands' import { lift as originalLift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import { isNodeActive } from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list' import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,8 +1,8 @@
import { NodeType, MarkType } from 'prosemirror-model' import { NodeType, MarkType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
import getMarkType from '../helpers/getMarkType' import { getMarkType } from '../helpers/getMarkType'
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName' import { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName'
import deleteProps from '../utilities/deleteProps' import { deleteProps } from '../utilities/deleteProps'
import { RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {

View File

@ -1,6 +1,6 @@
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import { ParseOptions } from 'prosemirror-model' import { ParseOptions } from 'prosemirror-model'
import createDocument from '../helpers/createDocument' import { createDocument } from '../helpers/createDocument'
import { RawCommands, Content } from '../types' import { RawCommands, Content } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {

View File

@ -1,7 +1,7 @@
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import { getMarkType } from '../helpers/getMarkType'
import getMarkAttributes from '../helpers/getMarkAttributes' import { getMarkAttributes } from '../helpers/getMarkAttributes'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { setBlockType } from 'prosemirror-commands' import { setBlockType } from 'prosemirror-commands'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,5 +1,5 @@
import { Selection, NodeSelection } from 'prosemirror-state' import { Selection, NodeSelection } from 'prosemirror-state'
import minMax from '../utilities/minMax' import { minMax } from '../utilities/minMax'
import { RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {

View File

@ -1,5 +1,5 @@
import { Selection, TextSelection } from 'prosemirror-state' import { Selection, TextSelection } from 'prosemirror-state'
import minMax from '../utilities/minMax' import { minMax } from '../utilities/minMax'
import { RawCommands, Range } from '../types' import { RawCommands, Range } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {

View File

@ -1,7 +1,7 @@
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list' import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -2,7 +2,7 @@ import { canSplit } from 'prosemirror-transform'
import { ContentMatch } from 'prosemirror-model' import { ContentMatch } from 'prosemirror-model'
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state' import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getSplittedAttributes from '../helpers/getSplittedAttributes' import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
function defaultBlockAt(match: ContentMatch) { function defaultBlockAt(match: ContentMatch) {
for (let i = 0; i < match.edgeCount; i += 1) { for (let i = 0; i < match.edgeCount; i += 1) {

View File

@ -7,8 +7,8 @@ import {
import { canSplit } from 'prosemirror-transform' import { canSplit } from 'prosemirror-transform'
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
import getSplittedAttributes from '../helpers/getSplittedAttributes' import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,8 +1,8 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
import findParentNode from '../helpers/findParentNode' import { findParentNode } from '../helpers/findParentNode'
import isList from '../helpers/isList' import { isList } from '../helpers/isList'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import { getMarkType } from '../helpers/getMarkType'
import isMarkActive from '../helpers/isMarkActive' import { isMarkActive } from '../helpers/isMarkActive'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import { isNodeActive } from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,8 +1,8 @@
import { wrapIn, lift } from 'prosemirror-commands' import { wrapIn, lift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import { isNodeActive } from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import { getMarkType } from '../helpers/getMarkType'
import getMarkRange from '../helpers/getMarkRange' import { getMarkRange } from '../helpers/getMarkRange'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { NodeType, MarkType } from 'prosemirror-model' import { NodeType, MarkType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
import getMarkType from '../helpers/getMarkType' import { getMarkType } from '../helpers/getMarkType'
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName' import { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName'
import { RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {

View File

@ -1,8 +1,8 @@
import { wrapIn as originalWrapIn } from 'prosemirror-commands' import { wrapIn as originalWrapIn } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import { isNodeActive } from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list' import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import { getNodeType } from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands<ReturnType> { interface Commands<ReturnType> {

View File

@ -1,7 +1,7 @@
import { Plugin, PluginKey } from 'prosemirror-state' import { Plugin, PluginKey } from 'prosemirror-state'
import { Extension } from '../Extension' import { Extension } from '../Extension'
import getTextBetween from '../helpers/getTextBetween' import { getTextBetween } from '../helpers/getTextBetween'
import getTextSeralizersFromSchema from '../helpers/getTextSeralizersFromSchema' import { getTextSeralizersFromSchema } from '../helpers/getTextSeralizersFromSchema'
export const ClipboardTextSerializer = Extension.create({ export const ClipboardTextSerializer = Extension.create({
name: 'clipboardTextSerializer', name: 'clipboardTextSerializer',

View File

@ -5,7 +5,7 @@ import { Transform } from 'prosemirror-transform'
/** /**
* Returns a new `Transform` based on all steps of the passed transactions. * Returns a new `Transform` based on all steps of the passed transactions.
*/ */
export default function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform { export function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform {
const transform = new Transform(oldDoc) const transform = new Transform(oldDoc)
transactions.forEach(transaction => { transactions.forEach(transaction => {

View File

@ -1,6 +1,6 @@
import { EditorState, Transaction } from 'prosemirror-state' import { EditorState, Transaction } from 'prosemirror-state'
export default function createChainableState(config: { export function createChainableState(config: {
transaction: Transaction, transaction: Transaction,
state: EditorState, state: EditorState,
}): EditorState { }): EditorState {

View File

@ -1,8 +1,8 @@
import { Schema, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model' import { Schema, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model'
import { Content } from '../types' import { Content } from '../types'
import createNodeFromContent from './createNodeFromContent' import { createNodeFromContent } from './createNodeFromContent'
export default function createDocument( export function createDocument(
content: Content, content: Content,
schema: Schema, schema: Schema,
parseOptions: ParseOptions = {}, parseOptions: ParseOptions = {},

View File

@ -5,7 +5,7 @@ import {
Fragment, Fragment,
ParseOptions, ParseOptions,
} from 'prosemirror-model' } from 'prosemirror-model'
import elementFromString from '../utilities/elementFromString' import { elementFromString } from '../utilities/elementFromString'
import { Content } from '../types' import { Content } from '../types'
export type CreateNodeFromContentOptions = { export type CreateNodeFromContentOptions = {
@ -13,7 +13,7 @@ export type CreateNodeFromContentOptions = {
parseOptions?: ParseOptions, parseOptions?: ParseOptions,
} }
export default function createNodeFromContent( export function createNodeFromContent(
content: Content, content: Content,
schema: Schema, schema: Schema,
options?: CreateNodeFromContentOptions, options?: CreateNodeFromContentOptions,

View File

@ -1,6 +1,6 @@
import { ContentMatch, NodeType } from 'prosemirror-model' import { ContentMatch, NodeType } from 'prosemirror-model'
export default function defaultBlockAt(match: ContentMatch): NodeType | null { export function defaultBlockAt(match: ContentMatch): NodeType | null {
for (let i = 0; i < match.edgeCount; i += 1) { for (let i = 0; i < match.edgeCount; i += 1) {
const { type } = match.edge(i) const { type } = match.edge(i)

View File

@ -1,7 +1,7 @@
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Predicate, NodeWithPos } from '../types' import { Predicate, NodeWithPos } from '../types'
export default function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[] { export function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[] {
const nodesWithPos: NodeWithPos[] = [] const nodesWithPos: NodeWithPos[] = []
node.descendants((child, pos) => { node.descendants((child, pos) => {

View File

@ -4,7 +4,7 @@ import { Predicate, Range, NodeWithPos } from '../types'
/** /**
* Same as `findChildren` but searches only within a `range`. * Same as `findChildren` but searches only within a `range`.
*/ */
export default function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] { export function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] {
const nodesWithPos: NodeWithPos[] = [] const nodesWithPos: NodeWithPos[] = []
// if (range.from === range.to) { // if (range.from === range.to) {

View File

@ -1,7 +1,7 @@
import { Selection } from 'prosemirror-state' import { Selection } from 'prosemirror-state'
import findParentNodeClosestToPos from './findParentNodeClosestToPos' import { findParentNodeClosestToPos } from './findParentNodeClosestToPos'
import { Predicate } from '../types' import { Predicate } from '../types'
export default function findParentNode(predicate: Predicate) { export function findParentNode(predicate: Predicate) {
return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate) return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)
} }

View File

@ -1,7 +1,7 @@
import { ResolvedPos, Node as ProseMirrorNode } from 'prosemirror-model' import { ResolvedPos, Node as ProseMirrorNode } from 'prosemirror-model'
import { Predicate } from '../types' import { Predicate } from '../types'
export default function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ({ export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ({
pos: number, pos: number,
start: number, start: number,
depth: number, depth: number,

View File

@ -1,9 +1,9 @@
import { Node } from 'prosemirror-model' import { Node } from 'prosemirror-model'
import getSchema from './getSchema' import { getSchema } from './getSchema'
import getHTMLFromFragment from './getHTMLFromFragment' import { getHTMLFromFragment } from './getHTMLFromFragment'
import { Extensions, JSONContent } from '../types' import { Extensions, JSONContent } from '../types'
export default function generateHTML(doc: JSONContent, extensions: Extensions): string { export function generateHTML(doc: JSONContent, extensions: Extensions): string {
const schema = getSchema(extensions) const schema = getSchema(extensions)
const contentNode = Node.fromJSON(schema, doc) const contentNode = Node.fromJSON(schema, doc)

View File

@ -1,9 +1,9 @@
import { DOMParser } from 'prosemirror-model' import { DOMParser } from 'prosemirror-model'
import getSchema from './getSchema' import { getSchema } from './getSchema'
import elementFromString from '../utilities/elementFromString' import { elementFromString } from '../utilities/elementFromString'
import { Extensions } from '../types' import { Extensions } from '../types'
export default function generateJSON(html: string, extensions: Extensions): Record<string, any> { export function generateJSON(html: string, extensions: Extensions): Record<string, any> {
const schema = getSchema(extensions) const schema = getSchema(extensions)
const dom = elementFromString(html) const dom = elementFromString(html)

View File

@ -1,10 +1,10 @@
import { Node } from 'prosemirror-model' import { Node } from 'prosemirror-model'
import getSchema from './getSchema' import { getSchema } from './getSchema'
import { Extensions, JSONContent, TextSerializer } from '../types' import { Extensions, JSONContent, TextSerializer } from '../types'
import getTextSeralizersFromSchema from './getTextSeralizersFromSchema' import { getTextSeralizersFromSchema } from './getTextSeralizersFromSchema'
import getText from './getText' import { getText } from './getText'
export default function generateText( export function generateText(
doc: JSONContent, doc: JSONContent,
extensions: Extensions, extensions: Extensions,
options?: { options?: {

View File

@ -1,10 +1,10 @@
import { MarkType, NodeType } from 'prosemirror-model' import { MarkType, NodeType } from 'prosemirror-model'
import { EditorState } from 'prosemirror-state' import { EditorState } from 'prosemirror-state'
import getSchemaTypeNameByName from './getSchemaTypeNameByName' import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
import getNodeAttributes from './getNodeAttributes' import { getNodeAttributes } from './getNodeAttributes'
import getMarkAttributes from './getMarkAttributes' import { getMarkAttributes } from './getMarkAttributes'
export default function getAttributes( export function getAttributes(
state: EditorState, state: EditorState,
typeOrName: string | NodeType | MarkType, typeOrName: string | NodeType | MarkType,
): Record<string, any> { ): Record<string, any> {

View File

@ -1,5 +1,5 @@
import splitExtensions from './splitExtensions' import { splitExtensions } from './splitExtensions'
import getExtensionField from './getExtensionField' import { getExtensionField } from './getExtensionField'
import { import {
Extensions, Extensions,
GlobalAttributes, GlobalAttributes,
@ -14,7 +14,7 @@ import { NodeConfig, MarkConfig } from '..'
* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`. * Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
* @param extensions List of extensions * @param extensions List of extensions
*/ */
export default function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[] { export function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[] {
const extensionAttributes: ExtensionAttribute[] = [] const extensionAttributes: ExtensionAttribute[] = []
const { nodeExtensions, markExtensions } = splitExtensions(extensions) const { nodeExtensions, markExtensions } = splitExtensions(extensions)
const nodeAndMarkExtensions = [...nodeExtensions, ...markExtensions] const nodeAndMarkExtensions = [...nodeExtensions, ...markExtensions]

View File

@ -1,6 +1,6 @@
import { Transform, Step } from 'prosemirror-transform' import { Transform, Step } from 'prosemirror-transform'
import { Range } from '../types' import { Range } from '../types'
import removeDuplicates from '../utilities/removeDuplicates' import { removeDuplicates } from '../utilities/removeDuplicates'
export type ChangedRange = { export type ChangedRange = {
oldRange: Range, oldRange: Range,
@ -32,7 +32,7 @@ function simplifyChangedRanges(changes: ChangedRange[]): ChangedRange[] {
* Returns a list of changed ranges * Returns a list of changed ranges
* based on the first and last state of all steps. * based on the first and last state of all steps.
*/ */
export default function getChangedRanges(transform: Transform): ChangedRange[] { export function getChangedRanges(transform: Transform): ChangedRange[] {
const { mapping, steps } = transform const { mapping, steps } = transform
const changes: ChangedRange[] = [] const changes: ChangedRange[] = []

View File

@ -6,7 +6,7 @@ interface DebugJSONContent extends JSONContent {
to: number, to: number,
} }
export default function getDebugJSON(node: ProseMirrorNode, startOffset = 0): DebugJSONContent { export function getDebugJSON(node: ProseMirrorNode, startOffset = 0): DebugJSONContent {
const isTopNode = node.type === node.type.schema.topNodeType const isTopNode = node.type === node.type.schema.topNodeType
const increment = isTopNode ? 0 : 1 const increment = isTopNode ? 0 : 1
const from = startOffset // + offset const from = startOffset // + offset

View File

@ -1,6 +1,6 @@
import { AnyExtension, RemoveThis, MaybeThisParameterType } from '../types' import { AnyExtension, RemoveThis, MaybeThisParameterType } from '../types'
export default function getExtensionField<T = any>( export function getExtensionField<T = any>(
extension: AnyExtension, extension: AnyExtension,
field: string, field: string,
context?: Omit<MaybeThisParameterType<T>, 'parent'>, context?: Omit<MaybeThisParameterType<T>, 'parent'>,

View File

@ -1,6 +1,6 @@
import { DOMSerializer, Schema, Fragment } from 'prosemirror-model' import { DOMSerializer, Schema, Fragment } from 'prosemirror-model'
export default function getHTMLFromFragment(fragment: Fragment, schema: Schema): string { export function getHTMLFromFragment(fragment: Fragment, schema: Schema): string {
const documentFragment = DOMSerializer const documentFragment = DOMSerializer
.fromSchema(schema) .fromSchema(schema)
.serializeFragment(fragment) .serializeFragment(fragment)

View File

@ -1,8 +1,8 @@
import { EditorState } from 'prosemirror-state' import { EditorState } from 'prosemirror-state'
import { Mark, MarkType } from 'prosemirror-model' import { Mark, MarkType } from 'prosemirror-model'
import getMarkType from './getMarkType' import { getMarkType } from './getMarkType'
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> { export function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> {
const type = getMarkType(typeOrName, state.schema) const type = getMarkType(typeOrName, state.schema)
const { from, to, empty } = state.selection const { from, to, empty } = state.selection
const marks: Mark[] = [] const marks: Mark[] = []

View File

@ -1,5 +1,5 @@
import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from 'prosemirror-model' import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from 'prosemirror-model'
import objectIncludes from '../utilities/objectIncludes' import { objectIncludes } from '../utilities/objectIncludes'
import { Range } from '../types' import { Range } from '../types'
function findMarkInSet( function findMarkInSet(
@ -20,7 +20,7 @@ function isMarkInSet(
return !!findMarkInSet(marks, type, attributes) return !!findMarkInSet(marks, type, attributes)
} }
export default function getMarkRange( export function getMarkRange(
$pos: ResolvedPos, $pos: ResolvedPos,
type: MarkType, type: MarkType,
attributes: Record<string, any> = {}, attributes: Record<string, any> = {},

View File

@ -1,6 +1,6 @@
import { MarkType, Schema } from 'prosemirror-model' import { MarkType, Schema } from 'prosemirror-model'
export default function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType { export function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType {
if (typeof nameOrType === 'string') { if (typeof nameOrType === 'string') {
if (!schema.marks[nameOrType]) { if (!schema.marks[nameOrType]) {
throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`) throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`)

View File

@ -1,8 +1,8 @@
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
import { MarkRange } from '../types' import { MarkRange } from '../types'
import getMarkRange from './getMarkRange' import { getMarkRange } from './getMarkRange'
export default function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): MarkRange[] { export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): MarkRange[] {
const marks: MarkRange[] = [] const marks: MarkRange[] = []
// get all inclusive marks on empty selection // get all inclusive marks on empty selection

View File

@ -1,8 +1,8 @@
import { EditorState } from 'prosemirror-state' import { EditorState } from 'prosemirror-state'
import { Node, NodeType } from 'prosemirror-model' import { Node, NodeType } from 'prosemirror-model'
import getNodeType from './getNodeType' import { getNodeType } from './getNodeType'
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> { export function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> {
const type = getNodeType(typeOrName, state.schema) const type = getNodeType(typeOrName, state.schema)
const { from, to } = state.selection const { from, to } = state.selection
const nodes: Node[] = [] const nodes: Node[] = []

View File

@ -1,6 +1,6 @@
import { NodeType, Schema } from 'prosemirror-model' import { NodeType, Schema } from 'prosemirror-model'
export default function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType { export function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType {
if (typeof nameOrType === 'string') { if (typeof nameOrType === 'string') {
if (!schema.nodes[nameOrType]) { if (!schema.nodes[nameOrType]) {
throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`) throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`)

View File

@ -1,8 +1,8 @@
import { Node, Mark } from 'prosemirror-model' import { Node, Mark } from 'prosemirror-model'
import { ExtensionAttribute } from '../types' import { ExtensionAttribute } from '../types'
import mergeAttributes from '../utilities/mergeAttributes' import { mergeAttributes } from '../utilities/mergeAttributes'
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): Record<string, any> { export function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): Record<string, any> {
return extensionAttributes return extensionAttributes
.filter(item => item.attribute.rendered) .filter(item => item.attribute.rendered)
.map(item => { .map(item => {

View File

@ -1,9 +1,9 @@
import { Schema } from 'prosemirror-model' import { Schema } from 'prosemirror-model'
import getSchemaByResolvedExtensions from './getSchemaByResolvedExtensions' import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
import ExtensionManager from '../ExtensionManager' import { ExtensionManager } from '../ExtensionManager'
import { Extensions } from '../types' import { Extensions } from '../types'
export default function getSchema(extensions: Extensions): Schema { export function getSchema(extensions: Extensions): Schema {
const resolvedExtensions = ExtensionManager.resolve(extensions) const resolvedExtensions = ExtensionManager.resolve(extensions)
return getSchemaByResolvedExtensions(resolvedExtensions) return getSchemaByResolvedExtensions(resolvedExtensions)

View File

@ -1,13 +1,13 @@
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model' import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model'
import { AnyConfig, Extensions } from '../types' import { AnyConfig, Extensions } from '../types'
import { NodeConfig, MarkConfig } from '..' import { NodeConfig, MarkConfig } from '..'
import splitExtensions from './splitExtensions' import { splitExtensions } from './splitExtensions'
import getAttributesFromExtensions from './getAttributesFromExtensions' import { getAttributesFromExtensions } from './getAttributesFromExtensions'
import getRenderedAttributes from './getRenderedAttributes' import { getRenderedAttributes } from './getRenderedAttributes'
import isEmptyObject from '../utilities/isEmptyObject' import { isEmptyObject } from '../utilities/isEmptyObject'
import injectExtensionAttributesToParseRule from './injectExtensionAttributesToParseRule' import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
import getExtensionField from './getExtensionField' import { getExtensionField } from './getExtensionField'
function cleanUpSchemaItem<T>(data: T) { function cleanUpSchemaItem<T>(data: T) {
return Object.fromEntries(Object.entries(data).filter(([key, value]) => { return Object.fromEntries(Object.entries(data).filter(([key, value]) => {
@ -19,7 +19,7 @@ function cleanUpSchemaItem<T>(data: T) {
})) as T })) as T
} }
export default function getSchemaByResolvedExtensions(extensions: Extensions): Schema { export function getSchemaByResolvedExtensions(extensions: Extensions): Schema {
const allAttributes = getAttributesFromExtensions(extensions) const allAttributes = getAttributesFromExtensions(extensions)
const { nodeExtensions, markExtensions } = splitExtensions(extensions) const { nodeExtensions, markExtensions } = splitExtensions(extensions)
const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name

View File

@ -1,5 +1,5 @@
import { MarkType, NodeType, Schema } from 'prosemirror-model' import { MarkType, NodeType, Schema } from 'prosemirror-model'
export default function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null { export function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null {
return schema.nodes[name] || schema.marks[name] || null return schema.nodes[name] || schema.marks[name] || null
} }

View File

@ -1,6 +1,6 @@
import { Schema } from 'prosemirror-model' import { Schema } from 'prosemirror-model'
export default function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null { export function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null {
if (schema.nodes[name]) { if (schema.nodes[name]) {
return 'node' return 'node'
} }

View File

@ -1,6 +1,6 @@
import { ExtensionAttribute } from '../types' import { ExtensionAttribute } from '../types'
export default function getSplittedAttributes( export function getSplittedAttributes(
extensionAttributes: ExtensionAttribute[], extensionAttributes: ExtensionAttribute[],
typeName: string, typeName: string,
attributes: Record<string, any>, attributes: Record<string, any>,

View File

@ -1,8 +1,8 @@
import { TextSerializer } from '../types' import { TextSerializer } from '../types'
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
import getTextBetween from './getTextBetween' import { getTextBetween } from './getTextBetween'
export default function getText( export function getText(
node: ProseMirrorNode, node: ProseMirrorNode,
options?: { options?: {
blockSeparator?: string, blockSeparator?: string,

View File

@ -1,7 +1,7 @@
import { Range, TextSerializer } from '../types' import { Range, TextSerializer } from '../types'
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
export default function getTextBetween( export function getTextBetween(
startNode: ProseMirrorNode, startNode: ProseMirrorNode,
range: Range, range: Range,
options?: { options?: {

View File

@ -1,7 +1,7 @@
import { Schema } from 'prosemirror-model' import { Schema } from 'prosemirror-model'
import { TextSerializer } from '../types' import { TextSerializer } from '../types'
export default function getTextSeralizersFromSchema(schema: Schema): Record<string, TextSerializer> { export function getTextSeralizersFromSchema(schema: Schema): Record<string, TextSerializer> {
return Object.fromEntries(Object return Object.fromEntries(Object
.entries(schema.nodes) .entries(schema.nodes)
.filter(([, node]) => node.spec.toText) .filter(([, node]) => node.spec.toText)

View File

@ -1,7 +1,7 @@
import { ParseRule } from 'prosemirror-model' import { ParseRule } from 'prosemirror-model'
import { ExtensionAttribute } from '../types' import { ExtensionAttribute } from '../types'
import fromString from '../utilities/fromString' import { fromString } from '../utilities/fromString'
import isObject from '../utilities/isObject' import { isObject } from '../utilities/isObject'
/** /**
* This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`). * This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
@ -9,7 +9,7 @@ import isObject from '../utilities/isObject'
* @param parseRule ProseMirror ParseRule * @param parseRule ProseMirror ParseRule
* @param extensionAttributes List of attributes to inject * @param extensionAttributes List of attributes to inject
*/ */
export default function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule { export function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule {
if (parseRule.style) { if (parseRule.style) {
return parseRule return parseRule
} }

View File

@ -1,9 +1,9 @@
import { EditorState } from 'prosemirror-state' import { EditorState } from 'prosemirror-state'
import isNodeActive from './isNodeActive' import { isNodeActive } from './isNodeActive'
import isMarkActive from './isMarkActive' import { isMarkActive } from './isMarkActive'
import getSchemaTypeNameByName from './getSchemaTypeNameByName' import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
export default function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean { export function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean {
if (!name) { if (!name) {
return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes) return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes)
} }

View File

@ -1,6 +1,6 @@
import { AnyExtension, EnableRules } from '../types' import { AnyExtension, EnableRules } from '../types'
export default function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean { export function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
if (Array.isArray(enabled)) { if (Array.isArray(enabled)) {
return enabled.some(enabledExtension => { return enabled.some(enabledExtension => {
const name = typeof enabledExtension === 'string' const name = typeof enabledExtension === 'string'

View File

@ -1,10 +1,10 @@
import { Extensions } from '../types' import { Extensions } from '../types'
import { NodeConfig } from '..' import { NodeConfig } from '..'
import splitExtensions from './splitExtensions' import { splitExtensions } from './splitExtensions'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
import getExtensionField from '../helpers/getExtensionField' import { getExtensionField } from '../helpers/getExtensionField'
export default function isList(name: string, extensions: Extensions): boolean { export function isList(name: string, extensions: Extensions): boolean {
const { nodeExtensions } = splitExtensions(extensions) const { nodeExtensions } = splitExtensions(extensions)
const extension = nodeExtensions.find(item => item.name === name) const extension = nodeExtensions.find(item => item.name === name)

View File

@ -1,10 +1,10 @@
import { EditorState } from 'prosemirror-state' import { EditorState } from 'prosemirror-state'
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import objectIncludes from '../utilities/objectIncludes' import { objectIncludes } from '../utilities/objectIncludes'
import getMarkType from './getMarkType' import { getMarkType } from './getMarkType'
import { MarkRange } from '../types' import { MarkRange } from '../types'
export default function isMarkActive( export function isMarkActive(
state: EditorState, state: EditorState,
typeOrName: MarkType | string | null, typeOrName: MarkType | string | null,
attributes: Record<string, any> = {}, attributes: Record<string, any> = {},

View File

@ -1,10 +1,10 @@
import { EditorState } from 'prosemirror-state' import { EditorState } from 'prosemirror-state'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import objectIncludes from '../utilities/objectIncludes' import { objectIncludes } from '../utilities/objectIncludes'
import getNodeType from './getNodeType' import { getNodeType } from './getNodeType'
import { NodeRange } from '../types' import { NodeRange } from '../types'
export default function isNodeActive( export function isNodeActive(
state: EditorState, state: EditorState,
typeOrName: NodeType | string | null, typeOrName: NodeType | string | null,
attributes: Record<string, any> = {}, attributes: Record<string, any> = {},

View File

@ -1,6 +1,6 @@
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
export default function isNodeEmpty(node: ProseMirrorNode): boolean { export function isNodeEmpty(node: ProseMirrorNode): boolean {
const defaultContent = node.type.createAndFill()?.toJSON() const defaultContent = node.type.createAndFill()?.toJSON()
const content = node.toJSON() const content = node.toJSON()

View File

@ -1,6 +1,6 @@
import { NodeSelection } from 'prosemirror-state' import { NodeSelection } from 'prosemirror-state'
import isObject from '../utilities/isObject' import { isObject } from '../utilities/isObject'
export default function isNodeSelection(value: unknown): value is NodeSelection { export function isNodeSelection(value: unknown): value is NodeSelection {
return isObject(value) && value instanceof NodeSelection return isObject(value) && value instanceof NodeSelection
} }

View File

@ -1,6 +1,6 @@
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import isObject from '../utilities/isObject' import { isObject } from '../utilities/isObject'
export default function isTextSelection(value: unknown): value is TextSelection { export function isTextSelection(value: unknown): value is TextSelection {
return isObject(value) && value instanceof TextSelection return isObject(value) && value instanceof TextSelection
} }

View File

@ -1,7 +1,7 @@
import { EditorView } from 'prosemirror-view' import { EditorView } from 'prosemirror-view'
import minMax from '../utilities/minMax' import { minMax } from '../utilities/minMax'
export default function posToDOMRect(view: EditorView, from: number, to: number): DOMRect { export function posToDOMRect(view: EditorView, from: number, to: number): DOMRect {
const minPos = 0 const minPos = 0
const maxPos = view.state.doc.content.size const maxPos = view.state.doc.content.size
const resolvedFrom = minMax(from, minPos, maxPos) const resolvedFrom = minMax(from, minPos, maxPos)

View File

@ -1,9 +1,9 @@
import { Node as ProseMirrorNode } from 'prosemirror-model' import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Selection, TextSelection } from 'prosemirror-state' import { Selection, TextSelection } from 'prosemirror-state'
import { FocusPosition } from '../types' import { FocusPosition } from '../types'
import minMax from '../utilities/minMax' import { minMax } from '../utilities/minMax'
export default function resolveFocusPosition( export function resolveFocusPosition(
doc: ProseMirrorNode, doc: ProseMirrorNode,
position: FocusPosition = null, position: FocusPosition = null,
): Selection | null { ): Selection | null {

View File

@ -2,7 +2,7 @@ import { Selection, Transaction } from 'prosemirror-state'
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform' import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform'
// source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466 // source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466
export default function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number) { export function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number) {
const last = tr.steps.length - 1 const last = tr.steps.length - 1
if (last < startLen) { if (last < startLen) {

View File

@ -3,7 +3,7 @@ import { Extension } from '../Extension'
import { Node } from '../Node' import { Node } from '../Node'
import { Mark } from '../Mark' import { Mark } from '../Mark'
export default function splitExtensions(extensions: Extensions) { export function splitExtensions(extensions: Extensions) {
const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[] const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]
const nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[] const nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[]
const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[] const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[]

View File

@ -12,48 +12,48 @@ export * from './PasteRule'
export * from './CommandManager' export * from './CommandManager'
export * from './types' export * from './types'
export { default as nodeInputRule } from './inputRules/nodeInputRule' export * from './inputRules/nodeInputRule'
export { default as markInputRule } from './inputRules/markInputRule' export * from './inputRules/markInputRule'
export { default as textblockTypeInputRule } from './inputRules/textblockTypeInputRule' export * from './inputRules/textblockTypeInputRule'
export { default as textInputRule } from './inputRules/textInputRule' export * from './inputRules/textInputRule'
export { default as wrappingInputRule } from './inputRules/wrappingInputRule' export * from './inputRules/wrappingInputRule'
export { default as markPasteRule } from './pasteRules/markPasteRule' export * from './pasteRules/markPasteRule'
export { default as textPasteRule } from './pasteRules/textPasteRule' export * from './pasteRules/textPasteRule'
export { default as callOrReturn } from './utilities/callOrReturn' export * from './utilities/callOrReturn'
export { default as mergeAttributes } from './utilities/mergeAttributes' export * from './utilities/mergeAttributes'
export { default as combineTransactionSteps } from './helpers/combineTransactionSteps' export * from './helpers/combineTransactionSteps'
export { default as defaultBlockAt } from './helpers/defaultBlockAt' export * from './helpers/defaultBlockAt'
export { default as getExtensionField } from './helpers/getExtensionField' export * from './helpers/getExtensionField'
export { default as findChildren } from './helpers/findChildren' export * from './helpers/findChildren'
export { default as findChildrenInRange } from './helpers/findChildrenInRange' export * from './helpers/findChildrenInRange'
export { default as findParentNode } from './helpers/findParentNode' export * from './helpers/findParentNode'
export { default as findParentNodeClosestToPos } from './helpers/findParentNodeClosestToPos' export * from './helpers/findParentNodeClosestToPos'
export { default as generateHTML } from './helpers/generateHTML' export * from './helpers/generateHTML'
export { default as generateJSON } from './helpers/generateJSON' export * from './helpers/generateJSON'
export { default as generateText } from './helpers/generateText' export * from './helpers/generateText'
export { default as getChangedRanges } from './helpers/getChangedRanges' export * from './helpers/getChangedRanges'
export { default as getSchema } from './helpers/getSchema' export * from './helpers/getSchema'
export { default as getHTMLFromFragment } from './helpers/getHTMLFromFragment' export * from './helpers/getHTMLFromFragment'
export { default as getDebugJSON } from './helpers/getDebugJSON' export * from './helpers/getDebugJSON'
export { default as getAttributes } from './helpers/getAttributes' export * from './helpers/getAttributes'
export { default as getMarkAttributes } from './helpers/getMarkAttributes' export * from './helpers/getMarkAttributes'
export { default as getMarkRange } from './helpers/getMarkRange' export * from './helpers/getMarkRange'
export { default as getMarkType } from './helpers/getMarkType' export * from './helpers/getMarkType'
export { default as getMarksBetween } from './helpers/getMarksBetween' export * from './helpers/getMarksBetween'
export { default as getNodeAttributes } from './helpers/getNodeAttributes' export * from './helpers/getNodeAttributes'
export { default as getNodeType } from './helpers/getNodeType' export * from './helpers/getNodeType'
export { default as getText } from './helpers/getText' export * from './helpers/getText'
export { default as getTextBetween } from './helpers/getTextBetween' export * from './helpers/getTextBetween'
export { default as isActive } from './helpers/isActive' export * from './helpers/isActive'
export { default as isList } from './helpers/isList' export * from './helpers/isList'
export { default as isMarkActive } from './helpers/isMarkActive' export * from './helpers/isMarkActive'
export { default as isNodeActive } from './helpers/isNodeActive' export * from './helpers/isNodeActive'
export { default as isNodeEmpty } from './helpers/isNodeEmpty' export * from './helpers/isNodeEmpty'
export { default as isNodeSelection } from './helpers/isNodeSelection' export * from './helpers/isNodeSelection'
export { default as isTextSelection } from './helpers/isTextSelection' export * from './helpers/isTextSelection'
export { default as posToDOMRect } from './helpers/posToDOMRect' export * from './helpers/posToDOMRect'
// eslint-disable-next-line // eslint-disable-next-line
export interface Commands<ReturnType = any> {} export interface Commands<ReturnType = any> {}

View File

@ -1,14 +1,14 @@
import { InputRule, InputRuleFinder } from '../InputRule' import { InputRule, InputRuleFinder } from '../InputRule'
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import getMarksBetween from '../helpers/getMarksBetween' import { getMarksBetween } from '../helpers/getMarksBetween'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
import { ExtendedRegExpMatchArray } from '../types' import { ExtendedRegExpMatchArray } from '../types'
/** /**
* Build an input rule that adds a mark when the * Build an input rule that adds a mark when the
* matched text is typed into it. * matched text is typed into it.
*/ */
export default function markInputRule(config: { export function markInputRule(config: {
find: InputRuleFinder, find: InputRuleFinder,
type: MarkType, type: MarkType,
getAttributes?: getAttributes?:

View File

@ -1,13 +1,13 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { InputRule, InputRuleFinder } from '../InputRule' import { InputRule, InputRuleFinder } from '../InputRule'
import { ExtendedRegExpMatchArray } from '../types' import { ExtendedRegExpMatchArray } from '../types'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
/** /**
* Build an input rule that adds a node when the * Build an input rule that adds a node when the
* matched text is typed into it. * matched text is typed into it.
*/ */
export default function nodeInputRule(config: { export function nodeInputRule(config: {
find: InputRuleFinder, find: InputRuleFinder,
type: NodeType, type: NodeType,
getAttributes?: getAttributes?:

View File

@ -4,7 +4,7 @@ import { InputRule, InputRuleFinder } from '../InputRule'
* Build an input rule that replaces text when the * Build an input rule that replaces text when the
* matched text is typed into it. * matched text is typed into it.
*/ */
export default function textInputRule(config: { export function textInputRule(config: {
find: InputRuleFinder, find: InputRuleFinder,
replace: string, replace: string,
}) { }) {

View File

@ -1,7 +1,7 @@
import { InputRule, InputRuleFinder } from '../InputRule' import { InputRule, InputRuleFinder } from '../InputRule'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { ExtendedRegExpMatchArray } from '../types' import { ExtendedRegExpMatchArray } from '../types'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
/** /**
* Build an input rule that changes the type of a textblock when the * Build an input rule that changes the type of a textblock when the
@ -9,7 +9,7 @@ import callOrReturn from '../utilities/callOrReturn'
* probably want the regexp to start with `^`, so that the pattern can * probably want the regexp to start with `^`, so that the pattern can
* only occur at the start of a textblock. * only occur at the start of a textblock.
*/ */
export default function textblockTypeInputRule(config: { export function textblockTypeInputRule(config: {
find: InputRuleFinder, find: InputRuleFinder,
type: NodeType, type: NodeType,
getAttributes?: getAttributes?:

View File

@ -2,7 +2,7 @@ import { InputRule, InputRuleFinder } from '../InputRule'
import { NodeType, Node as ProseMirrorNode } from 'prosemirror-model' import { NodeType, Node as ProseMirrorNode } from 'prosemirror-model'
import { findWrapping, canJoin } from 'prosemirror-transform' import { findWrapping, canJoin } from 'prosemirror-transform'
import { ExtendedRegExpMatchArray } from '../types' import { ExtendedRegExpMatchArray } from '../types'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
/** /**
* Build an input rule for automatically wrapping a textblock when a * Build an input rule for automatically wrapping a textblock when a
@ -18,7 +18,7 @@ import callOrReturn from '../utilities/callOrReturn'
* expression match and the node before the wrapped node, and can * expression match and the node before the wrapped node, and can
* return a boolean to indicate whether a join should happen. * return a boolean to indicate whether a join should happen.
*/ */
export default function wrappingInputRule(config: { export function wrappingInputRule(config: {
find: InputRuleFinder, find: InputRuleFinder,
type: NodeType, type: NodeType,
getAttributes?: getAttributes?:

View File

@ -1,14 +1,14 @@
import { PasteRule, PasteRuleFinder } from '../PasteRule' import { PasteRule, PasteRuleFinder } from '../PasteRule'
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import getMarksBetween from '../helpers/getMarksBetween' import { getMarksBetween } from '../helpers/getMarksBetween'
import callOrReturn from '../utilities/callOrReturn' import { callOrReturn } from '../utilities/callOrReturn'
import { ExtendedRegExpMatchArray } from '../types' import { ExtendedRegExpMatchArray } from '../types'
/** /**
* Build an paste rule that adds a mark when the * Build an paste rule that adds a mark when the
* matched text is pasted into it. * matched text is pasted into it.
*/ */
export default function markPasteRule(config: { export function markPasteRule(config: {
find: PasteRuleFinder, find: PasteRuleFinder,
type: MarkType, type: MarkType,
getAttributes?: getAttributes?:

View File

@ -4,7 +4,7 @@ import { PasteRule, PasteRuleFinder } from '../PasteRule'
* Build an paste rule that replaces text when the * Build an paste rule that replaces text when the
* matched text is pasted into it. * matched text is pasted into it.
*/ */
export default function textPasteRule(config: { export function textPasteRule(config: {
find: PasteRuleFinder, find: PasteRuleFinder,
replace: string, replace: string,
}) { }) {

View File

@ -1,4 +1,4 @@
const style = `.ProseMirror { export const style = `.ProseMirror {
position: relative; position: relative;
} }
@ -73,5 +73,3 @@ img.ProseMirror-separator {
.tippy-box[data-animation=fade][data-state=hidden] { .tippy-box[data-animation=fade][data-state=hidden] {
opacity: 0 opacity: 0
}` }`
export default style

View File

@ -1,5 +1,5 @@
import { MaybeReturnType } from '../types' import { MaybeReturnType } from '../types'
import isFunction from './isFunction' import { isFunction } from './isFunction'
/** /**
* Optionally calls `value` as a function. * Optionally calls `value` as a function.
@ -8,7 +8,7 @@ import isFunction from './isFunction'
* @param context Optional context to bind to function. * @param context Optional context to bind to function.
* @param props Optional props to pass to function. * @param props Optional props to pass to function.
*/ */
export default function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> { export function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> {
if (isFunction(value)) { if (isFunction(value)) {
if (context) { if (context) {
return value.bind(context)(...props) return value.bind(context)(...props)

View File

@ -1,4 +1,4 @@
export default function createStyleTag(style: string): HTMLStyleElement { export function createStyleTag(style: string): HTMLStyleElement {
const tipTapStyleTag = (<HTMLStyleElement>document.querySelector('style[data-tiptap-style]')) const tipTapStyleTag = (<HTMLStyleElement>document.querySelector('style[data-tiptap-style]'))
if (tipTapStyleTag !== null) { if (tipTapStyleTag !== null) {

View File

@ -3,7 +3,7 @@
* @param obj Object * @param obj Object
* @param key Key to remove * @param key Key to remove
*/ */
export default function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> { export function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> {
const props = typeof propOrProps === 'string' const props = typeof propOrProps === 'string'
? [propOrProps] ? [propOrProps]
: propOrProps : propOrProps

View File

@ -1,4 +1,4 @@
export default function elementFromString(value: string): HTMLElement { export function elementFromString(value: string): HTMLElement {
// add a wrapper to preserve leading and trailing whitespace // add a wrapper to preserve leading and trailing whitespace
const wrappedValue = `<body>${value}</body>` const wrappedValue = `<body>${value}</body>`

View File

@ -1,4 +1,4 @@
export default function findDuplicates(items: any[]): any[] { export function findDuplicates(items: any[]): any[] {
const filtered = items.filter((el, index) => items.indexOf(el) !== index) const filtered = items.filter((el, index) => items.indexOf(el) !== index)
return [...new Set(filtered)] return [...new Set(filtered)]

View File

@ -1,4 +1,4 @@
export default function fromString(value: any): any { export function fromString(value: any): any {
if (typeof value !== 'string') { if (typeof value !== 'string') {
return value return value
} }

View File

@ -1,4 +1,4 @@
export default function isClass(value: any): boolean { export function isClass(value: any): boolean {
if (value.constructor?.toString().substring(0, 5) !== 'class') { if (value.constructor?.toString().substring(0, 5) !== 'class') {
return false return false
} }

View File

@ -1,3 +1,3 @@
export default function isEmptyObject(value = {}): boolean { export function isEmptyObject(value = {}): boolean {
return Object.keys(value).length === 0 && value.constructor === Object return Object.keys(value).length === 0 && value.constructor === Object
} }

View File

@ -1,3 +1,3 @@
export default function isObject(value: any): value is Function { export function isFunction(value: any): value is Function {
return typeof value === 'function' return typeof value === 'function'
} }

View File

@ -1,3 +1,3 @@
export default function isNumber(value: any): value is number { export function isNumber(value: any): value is number {
return typeof value === 'number' return typeof value === 'number'
} }

View File

@ -1,6 +1,6 @@
import isClass from './isClass' import { isClass } from './isClass'
export default function isObject(value: any): boolean { export function isObject(value: any): boolean {
return ( return (
value value
&& typeof value === 'object' && typeof value === 'object'

Some files were not shown because too many files have changed in this diff Show More