diff --git a/docs/src/docPages/api/editor.md b/docs/src/docPages/api/editor.md index a300ee57..c3f18136 100644 --- a/docs/src/docPages/api/editor.md +++ b/docs/src/docPages/api/editor.md @@ -139,8 +139,8 @@ Don’t confuse methods with [commands](/api/commands), which are used to change | `destroy()` | – | Stops the editor instance and unbinds all events. | | `getHTML()` | – | Returns the current content as HTML. | | `getJSON()` | – | Returns the current content as JSON. | -| `getMarkAttrs()` | `state` State of the editor
`name` Name of the mark | Get attributes of the currently selected mark. | -| `getNodeAttrs()` | `state` State of the editor`name` Name of the node | Get attributes of the currently selected node. | +| `getMarkAttributes()` | `name` Name of the mark | Get attributes of the currently selected mark. | +| `getNodeAttributes()` | `name` Name of the node | Get attributes of the currently selected node. | | `isActive()` | `name` Name of the node or mark
`attrs` Attributes of the node or mark | Returns if the currently selected node or mark is active. | | `isEditable()` | - | Returns whether the editor is editable. | | `isEmpty()` | - | Check if there is no content. | diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 1bc8798d..30b5081d 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -10,8 +10,8 @@ import magicMethods from './utils/magicMethods' import elementFromString from './utils/elementFromString' import nodeIsActive from './utils/nodeIsActive' import markIsActive from './utils/markIsActive' -import getNodeAttrs from './utils/getNodeAttrs' -import getMarkAttrs from './utils/getMarkAttrs' +import getNodeAttributes from './utils/getNodeAttributes' +import getMarkAttributes from './utils/getMarkAttributes' import removeElement from './utils/removeElement' import getSchemaTypeNameByName from './utils/getSchemaTypeNameByName' import getHTMLFromFragment from './utils/getHTMLFromFragment' @@ -333,8 +333,8 @@ export class Editor extends EventEmitter { * * @param name Name of the node */ - public getNodeAttrs(name: string) { - return getNodeAttrs(this.state, this.schema.nodes[name]) + public getNodeAttributes(name: string) { + return getNodeAttributes(this.state, this.schema.nodes[name]) } /** @@ -342,8 +342,8 @@ export class Editor extends EventEmitter { * * @param name Name of the mark */ - public getMarkAttrs(name: string) { - return getMarkAttrs(this.state, this.schema.marks[name]) + public getMarkAttributes(name: string) { + return getMarkAttributes(this.state, this.schema.marks[name]) } /** diff --git a/packages/core/src/commands/updateMarkAttributes.ts b/packages/core/src/commands/updateMarkAttributes.ts index dbacefa2..76073d54 100644 --- a/packages/core/src/commands/updateMarkAttributes.ts +++ b/packages/core/src/commands/updateMarkAttributes.ts @@ -1,13 +1,13 @@ import { MarkType } from 'prosemirror-model' import { Command } from '../types' import getMarkType from '../utils/getMarkType' -import getMarkAttrs from '../utils/getMarkAttrs' +import getMarkAttributes from '../utils/getMarkAttributes' export default (typeOrName: string | MarkType, attributes: {}): Command => ({ tr, state, dispatch }) => { const { selection } = tr const { from, to, empty } = selection const type = getMarkType(typeOrName, state.schema) - const oldAttributes = getMarkAttrs(state, type) + const oldAttributes = getMarkAttributes(state, type) const newAttributes = { ...oldAttributes, ...attributes, diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index dfbc639e..644d58ce 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -11,7 +11,7 @@ export { default as markPasteRule } from './pasteRules/markPasteRule' export { default as getSchema } from './utils/getSchema' export { default as generateHTML } from './utils/generateHTML' export { default as getHTMLFromFragment } from './utils/getHTMLFromFragment' -export { default as getMarkAttrs } from './utils/getMarkAttrs' +export { default as getMarkAttributes } from './utils/getMarkAttributes' export { default as mergeAttributes } from './utils/mergeAttributes' export interface AllExtensions {} diff --git a/packages/core/src/utils/getMarkAttrs.ts b/packages/core/src/utils/getMarkAttributes.ts similarity index 85% rename from packages/core/src/utils/getMarkAttrs.ts rename to packages/core/src/utils/getMarkAttributes.ts index d8e60d8d..95e250e3 100644 --- a/packages/core/src/utils/getMarkAttrs.ts +++ b/packages/core/src/utils/getMarkAttributes.ts @@ -1,7 +1,7 @@ import { EditorState } from 'prosemirror-state' import { Mark, MarkType } from 'prosemirror-model' -export default function getMarkAttrs(state: EditorState, type: MarkType) { +export default function getMarkAttributes(state: EditorState, type: MarkType) { const { from, to, empty } = state.selection let marks: Mark[] = [] diff --git a/packages/core/src/utils/getNodeAttrs.ts b/packages/core/src/utils/getNodeAttributes.ts similarity index 83% rename from packages/core/src/utils/getNodeAttrs.ts rename to packages/core/src/utils/getNodeAttributes.ts index 77eaaea2..da861b51 100644 --- a/packages/core/src/utils/getNodeAttrs.ts +++ b/packages/core/src/utils/getNodeAttributes.ts @@ -1,7 +1,7 @@ import { EditorState } from 'prosemirror-state' import { Node, NodeType } from 'prosemirror-model' -export default function getNodeAttrs(state: EditorState, type: NodeType) { +export default function getNodeAttributes(state: EditorState, type: NodeType) { const { from, to } = state.selection let nodes: Node[] = [] diff --git a/packages/core/src/utils/markHasAttributes.ts b/packages/core/src/utils/markHasAttributes.ts index 23fbf37b..a76b1b53 100644 --- a/packages/core/src/utils/markHasAttributes.ts +++ b/packages/core/src/utils/markHasAttributes.ts @@ -1,6 +1,6 @@ import { EditorState } from 'prosemirror-state' import { MarkType } from 'prosemirror-model' -import getMarkAttrs from './getMarkAttrs' +import getMarkAttributes from './getMarkAttributes' import { AnyObject } from '../types' import isEmptyObject from './isEmptyObject' @@ -9,7 +9,7 @@ export default function markHasAttributes(state: EditorState, type: MarkType, at return true } - const originalAttrs = getMarkAttrs(state, type) + const originalAttrs = getMarkAttributes(state, type) return !!Object .keys(attributes) diff --git a/packages/extension-link/src/index.ts b/packages/extension-link/src/index.ts index 3570b998..f7607f1b 100644 --- a/packages/extension-link/src/index.ts +++ b/packages/extension-link/src/index.ts @@ -75,7 +75,7 @@ const Link = Mark.create({ key: new PluginKey('handleClick'), props: { handleClick: (view, pos, event) => { - const attrs = this.editor.getMarkAttrs('link') + const attrs = this.editor.getMarkAttributes('link') if (attrs.href && event.target instanceof HTMLAnchorElement) { window.open(attrs.href, attrs.target) diff --git a/packages/extension-text-style/src/index.ts b/packages/extension-text-style/src/index.ts index bed66e32..2055941b 100644 --- a/packages/extension-text-style/src/index.ts +++ b/packages/extension-text-style/src/index.ts @@ -1,4 +1,4 @@ -import { Command, Mark, getMarkAttrs } from '@tiptap/core' +import { Command, Mark, getMarkAttributes } from '@tiptap/core' const TextStyle = Mark.create({ name: 'textStyle', @@ -30,7 +30,7 @@ const TextStyle = Mark.create({ * Remove spans without inline style attributes. */ removeEmptyTextStyle: (): Command => ({ state, commands }) => { - const attributes = getMarkAttrs(state, this.type) + const attributes = getMarkAttributes(state, this.type) const hasStyles = Object.entries(attributes).every(([, value]) => !!value) if (hasStyles) {