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 { Editor } from './Editor'
import createChainableState from './helpers/createChainableState'
import { createChainableState } from './helpers/createChainableState'
import {
SingleCommands,
ChainedCommands,
@ -9,7 +9,7 @@ import {
CommandProps,
} from './types'
export default class CommandManager {
export class CommandManager {
editor: Editor

View File

@ -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,
@ -29,7 +29,7 @@ import {
EditorEvents,
} from './types'
import * as extensions from './extensions'
import style from './style'
import { style } from './style'
export { extensions }

View File

@ -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[] } = {}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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' {

View File

@ -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> {

View File

@ -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> {

View File

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

View File

@ -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> {

View File

@ -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> {

View File

@ -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' {

View File

@ -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' {

View File

@ -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> {

View File

@ -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> {

View File

@ -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' {

View File

@ -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' {

View File

@ -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> {

View File

@ -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) {

View File

@ -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> {

View File

@ -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> {

View File

@ -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> {

View File

@ -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> {

View File

@ -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> {

View File

@ -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> {

View File

@ -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' {

View File

@ -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> {

View File

@ -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> {

View File

@ -1,7 +1,7 @@
import { Plugin, PluginKey } from 'prosemirror-state'
import { Extension } from '../Extension'
import getTextBetween from '../helpers/getTextBetween'
import getTextSeralizersFromSchema from '../helpers/getTextSeralizersFromSchema'
import { getTextBetween } from '../helpers/getTextBetween'
import { getTextSeralizersFromSchema } from '../helpers/getTextSeralizersFromSchema'
export const ClipboardTextSerializer = Extension.create({
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.
*/
export default function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform {
export function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform {
const transform = new Transform(oldDoc)
transactions.forEach(transaction => {

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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) {
const { type } = match.edge(i)

View File

@ -1,7 +1,7 @@
import { Node as ProseMirrorNode } from 'prosemirror-model'
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[] = []
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`.
*/
export default function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] {
export function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] {
const nodesWithPos: NodeWithPos[] = []
// if (range.from === range.to) {

View File

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

View File

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

View File

@ -1,9 +1,9 @@
import { Node } from 'prosemirror-model'
import getSchema from './getSchema'
import getHTMLFromFragment from './getHTMLFromFragment'
import { getSchema } from './getSchema'
import { getHTMLFromFragment } from './getHTMLFromFragment'
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 contentNode = Node.fromJSON(schema, doc)

View File

@ -1,9 +1,9 @@
import { DOMParser } from 'prosemirror-model'
import getSchema from './getSchema'
import elementFromString from '../utilities/elementFromString'
import { getSchema } from './getSchema'
import { elementFromString } from '../utilities/elementFromString'
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 dom = elementFromString(html)

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import { Transform, Step } from 'prosemirror-transform'
import { Range } from '../types'
import removeDuplicates from '../utilities/removeDuplicates'
import { removeDuplicates } from '../utilities/removeDuplicates'
export type ChangedRange = {
oldRange: Range,
@ -32,7 +32,7 @@ function simplifyChangedRanges(changes: ChangedRange[]): ChangedRange[] {
* Returns a list of changed ranges
* 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 changes: ChangedRange[] = []

View File

@ -6,7 +6,7 @@ interface DebugJSONContent extends JSONContent {
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 increment = isTopNode ? 0 : 1
const from = startOffset // + offset

View File

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

View File

@ -1,6 +1,6 @@
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
.fromSchema(schema)
.serializeFragment(fragment)

View File

@ -1,8 +1,8 @@
import { EditorState } from 'prosemirror-state'
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 { from, to, empty } = state.selection
const marks: Mark[] = []

View File

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

View File

@ -1,6 +1,6 @@
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 (!schema.marks[nameOrType]) {
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 { 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[] = []
// get all inclusive marks on empty selection

View File

@ -1,8 +1,8 @@
import { EditorState } from 'prosemirror-state'
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 { from, to } = state.selection
const nodes: Node[] = []

View File

@ -1,6 +1,6 @@
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 (!schema.nodes[nameOrType]) {
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 { 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
.filter(item => item.attribute.rendered)
.map(item => {

View File

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

View File

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

View File

@ -1,5 +1,5 @@
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
}

View File

@ -1,6 +1,6 @@
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]) {
return 'node'
}

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import { Schema } from 'prosemirror-model'
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
.entries(schema.nodes)
.filter(([, node]) => node.spec.toText)

View File

@ -1,7 +1,7 @@
import { ParseRule } from 'prosemirror-model'
import { ExtensionAttribute } from '../types'
import fromString from '../utilities/fromString'
import isObject from '../utilities/isObject'
import { fromString } from '../utilities/fromString'
import { isObject } from '../utilities/isObject'
/**
* 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 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) {
return parseRule
}

View File

@ -1,9 +1,9 @@
import { EditorState } from 'prosemirror-state'
import isNodeActive from './isNodeActive'
import isMarkActive from './isMarkActive'
import getSchemaTypeNameByName from './getSchemaTypeNameByName'
import { isNodeActive } from './isNodeActive'
import { isMarkActive } from './isMarkActive'
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) {
return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes)
}

View File

@ -1,6 +1,6 @@
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)) {
return enabled.some(enabledExtension => {
const name = typeof enabledExtension === 'string'

View File

@ -1,10 +1,10 @@
import { Extensions } from '../types'
import { NodeConfig } from '..'
import splitExtensions from './splitExtensions'
import callOrReturn from '../utilities/callOrReturn'
import getExtensionField from '../helpers/getExtensionField'
import { splitExtensions } from './splitExtensions'
import { callOrReturn } from '../utilities/callOrReturn'
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 extension = nodeExtensions.find(item => item.name === name)

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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 content = node.toJSON()

View File

@ -1,6 +1,6 @@
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
}

View File

@ -1,6 +1,6 @@
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
}

View File

@ -1,7 +1,7 @@
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 maxPos = view.state.doc.content.size
const resolvedFrom = minMax(from, minPos, maxPos)

View File

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

View File

@ -2,7 +2,7 @@ import { Selection, Transaction } from 'prosemirror-state'
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform'
// 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
if (last < startLen) {

View File

@ -3,7 +3,7 @@ import { Extension } from '../Extension'
import { Node } from '../Node'
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 nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[]
const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[]

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import { InputRule, InputRuleFinder } from '../InputRule'
import { NodeType } from 'prosemirror-model'
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
@ -9,7 +9,7 @@ import callOrReturn from '../utilities/callOrReturn'
* probably want the regexp to start with `^`, so that the pattern can
* only occur at the start of a textblock.
*/
export default function textblockTypeInputRule(config: {
export function textblockTypeInputRule(config: {
find: InputRuleFinder,
type: NodeType,
getAttributes?:

View File

@ -2,7 +2,7 @@ import { InputRule, InputRuleFinder } from '../InputRule'
import { NodeType, Node as ProseMirrorNode } from 'prosemirror-model'
import { findWrapping, canJoin } from 'prosemirror-transform'
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
@ -18,7 +18,7 @@ import callOrReturn from '../utilities/callOrReturn'
* expression match and the node before the wrapped node, and can
* return a boolean to indicate whether a join should happen.
*/
export default function wrappingInputRule(config: {
export function wrappingInputRule(config: {
find: InputRuleFinder,
type: NodeType,
getAttributes?:

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import { MaybeReturnType } from '../types'
import isFunction from './isFunction'
import { isFunction } from './isFunction'
/**
* Optionally calls `value` as a function.
@ -8,7 +8,7 @@ import isFunction from './isFunction'
* @param context Optional context to bind 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 (context) {
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]'))
if (tipTapStyleTag !== null) {

View File

@ -3,7 +3,7 @@
* @param obj Object
* @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'
? [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
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)
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') {
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') {
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
}

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'
}

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'
}

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 (
value
&& typeof value === 'object'

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