diff --git a/docs/src/demos/Guide/NodeViews/JavaScriptContent/Extension.js b/docs/src/demos/Guide/NodeViews/JavaScriptContent/Extension.js index d4faebe1..0fc4e469 100644 --- a/docs/src/demos/Guide/NodeViews/JavaScriptContent/Extension.js +++ b/docs/src/demos/Guide/NodeViews/JavaScriptContent/Extension.js @@ -16,7 +16,7 @@ export default Node.create({ }, renderHTML({ HTMLAttributes }) { - return ['node-view', mergeAttributes(HTMLAttributes)] + return ['node-view', mergeAttributes(HTMLAttributes), 0] }, addNodeView() { diff --git a/docs/src/demos/Guide/NodeViews/ReactComponentContent/Extension.js b/docs/src/demos/Guide/NodeViews/ReactComponentContent/Extension.js index b02d4d64..90a92887 100644 --- a/docs/src/demos/Guide/NodeViews/ReactComponentContent/Extension.js +++ b/docs/src/demos/Guide/NodeViews/ReactComponentContent/Extension.js @@ -18,7 +18,7 @@ export default Node.create({ }, renderHTML({ HTMLAttributes }) { - return ['react-component', mergeAttributes(HTMLAttributes)] + return ['react-component', mergeAttributes(HTMLAttributes), 0] }, addNodeView() { diff --git a/docs/src/demos/Guide/NodeViews/VueComponentContent/Extension.js b/docs/src/demos/Guide/NodeViews/VueComponentContent/Extension.js index 6cd5ed7c..8fbfbdb6 100644 --- a/docs/src/demos/Guide/NodeViews/VueComponentContent/Extension.js +++ b/docs/src/demos/Guide/NodeViews/VueComponentContent/Extension.js @@ -18,7 +18,7 @@ export default Node.create({ }, renderHTML({ HTMLAttributes }) { - return ['vue-component', mergeAttributes(HTMLAttributes)] + return ['vue-component', mergeAttributes(HTMLAttributes), 0] }, addNodeView() { diff --git a/docs/src/docPages/api/commands.md b/docs/src/docPages/api/commands.md index c218b8a2..c6ed1a46 100644 --- a/docs/src/docPages/api/commands.md +++ b/docs/src/docPages/api/commands.md @@ -168,7 +168,7 @@ Have a look at all of the core commands listed below. They should give you a goo | .newlineInCode() | Add a newline character in code. | | .replace() | Replaces text with a node. | | .replaceRange() | Replaces text with a node within a range. | -| .resetNodeAttributes() | Resets all node attributes to the default value. | +| .resetAttributes() | Resets some node or mark attributes to the default value. | | .selectParentNode() | Select the parent node. | | .setMark() | Add a mark with new attributes. | | .setNode() | Replace a given range with a node. | @@ -179,7 +179,7 @@ Have a look at all of the core commands listed below. They should give you a goo | .undoInputRule() | Undo an input rule. | | .unsetAllMarks() | Remove all marks in the current selection. | | .unsetMark() | Remove a mark in the current selection. | -| .updateNodeAttributes() | Update attributes of a node. | +| .updateAttributes() | Update attributes of a node or mark. | ### Lists | Command | Description | diff --git a/docs/src/docPages/api/events.md b/docs/src/docPages/api/events.md index 4771620e..e6f1f637 100644 --- a/docs/src/docPages/api/events.md +++ b/docs/src/docPages/api/events.md @@ -19,9 +19,6 @@ const editor = new Editor({ onSelectionUpdate({ editor }) { // The selection has changed. }, - onViewUpdate({ editor }) { - // The view has changed. - }, onTransaction({ editor, transaction }) { // The editor state has changed. }, @@ -57,10 +54,6 @@ editor.on('selectionUpdate', ({ editor }) => { // The selection has changed. } -editor.on('viewUpdate', ({ editor }) => { - // The view has changed. -} - editor.on('transaction', ({ editor, transaction }) => { // The editor state has changed. } @@ -113,9 +106,6 @@ const CustomExtension = Extension.create({ onSelectionUpdate({ editor }) { // The selection has changed. }, - onViewUpdate({ editor }) { - // The view has changed. - }, onTransaction({ editor, transaction }) { // The editor state has changed. }, diff --git a/docs/src/docPages/api/extensions.md b/docs/src/docPages/api/extensions.md index f55b8f9b..41f129fe 100644 --- a/docs/src/docPages/api/extensions.md +++ b/docs/src/docPages/api/extensions.md @@ -51,6 +51,7 @@ const editor = new Editor({ Text, // … ], +}) ``` Learn [more about custom extensions in our guide](/guide/extend-extensions). diff --git a/docs/src/docPages/api/nodes.md b/docs/src/docPages/api/nodes.md index ae84898b..f2b69335 100644 --- a/docs/src/docPages/api/nodes.md +++ b/docs/src/docPages/api/nodes.md @@ -49,6 +49,7 @@ const editor = new Editor({ Text, // … ], +}) ``` Learn [more about custom extensions in our guide](/guide/custom-extensions). diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index de67ae6e..5fcbe90f 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-beta.20](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.19...@tiptap/core@2.0.0-beta.20) (2021-04-07) + + +### Features + +* add resetAttributes() command, deprecate resetNodeAttributes() ([3334d93](https://github.com/ueberdosis/tiptap-next/commit/3334d930f30bd4acb5c314b4ec1934b6a1e0b712)) + + + + + +# [2.0.0-beta.19](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.18...@tiptap/core@2.0.0-beta.19) (2021-04-07) + + +### Features + +* add updateAttributes() command, deprecate updateNodeAttributes(), fix [#254](https://github.com/ueberdosis/tiptap-next/issues/254) ([aac32b4](https://github.com/ueberdosis/tiptap-next/commit/aac32b4df6a1dfd93500e09d3433fcd8acad5fbe)) + + + + + # [2.0.0-beta.18](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.17...@tiptap/core@2.0.0-beta.18) (2021-04-07) diff --git a/packages/core/package.json b/packages/core/package.json index 4b83677e..4e474908 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@tiptap/core", "description": "headless rich text editor", - "version": "2.0.0-beta.18", + "version": "2.0.0-beta.20", "homepage": "https://tiptap.dev", "keywords": [ "tiptap", diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index f045d3fb..f5ff9f38 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -60,7 +60,6 @@ export class Editor extends EventEmitter { onCreate: () => null, onUpdate: () => null, onSelectionUpdate: () => null, - onViewUpdate: () => null, onTransaction: () => null, onFocus: () => null, onBlur: () => null, @@ -79,7 +78,6 @@ export class Editor extends EventEmitter { this.on('create', this.options.onCreate) this.on('update', this.options.onUpdate) this.on('selectionUpdate', this.options.onSelectionUpdate) - this.on('viewUpdate', this.options.onViewUpdate) this.on('transaction', this.options.onTransaction) this.on('focus', this.options.onFocus) this.on('blur', this.options.onBlur) @@ -243,16 +241,7 @@ export class Editor extends EventEmitter { // `editor.view` is not yet available at this time. // Therefore we will add all plugins and node views directly afterwards. const newState = this.state.reconfigure({ - plugins: [ - new Plugin({ - view: () => ({ - update: () => this.emit('viewUpdate', { - editor: this, - }), - }), - }), - ...this.extensionManager.plugins, - ], + plugins: this.extensionManager.plugins, }) this.view.updateState(newState) diff --git a/packages/core/src/Extension.ts b/packages/core/src/Extension.ts index 6308c765..059b770c 100644 --- a/packages/core/src/Extension.ts +++ b/packages/core/src/Extension.ts @@ -123,14 +123,6 @@ declare module '@tiptap/core' { editor: Editor, }) => void) | null, - /** - * The view has changed. - */ - onViewUpdate?: ((this: { - options: Options, - editor: Editor, - }) => void) | null, - /** * The editor state has changed. */ diff --git a/packages/core/src/ExtensionManager.ts b/packages/core/src/ExtensionManager.ts index 6927d484..364623a5 100644 --- a/packages/core/src/ExtensionManager.ts +++ b/packages/core/src/ExtensionManager.ts @@ -55,10 +55,6 @@ export default class ExtensionManager { this.editor.on('selectionUpdate', extension.config.onSelectionUpdate.bind(context)) } - if (typeof extension.config.onViewUpdate === 'function') { - this.editor.on('viewUpdate', extension.config.onViewUpdate.bind(context)) - } - if (typeof extension.config.onTransaction === 'function') { this.editor.on('transaction', extension.config.onTransaction.bind(context)) } diff --git a/packages/core/src/Mark.ts b/packages/core/src/Mark.ts index ee3e0ceb..d2b2dbc9 100644 --- a/packages/core/src/Mark.ts +++ b/packages/core/src/Mark.ts @@ -136,15 +136,6 @@ declare module '@tiptap/core' { type: MarkType, }) => void) | null, - /** - * The view has changed. - */ - onViewUpdate?: ((this: { - options: Options, - editor: Editor, - type: MarkType, - }) => void) | null, - /** * The editor state has changed. */ diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index e4b208a4..b0facfb8 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -135,16 +135,7 @@ declare module '@tiptap/core' { /** * The selection has changed. */ - onSelectionUpdate?: ((this: { - options: Options, - editor: Editor, - type: NodeType, - }) => void) | null, - - /** - * The view has changed. - */ - onViewUpdate?: ((this: { + onSelectionUpdate?: ((this: { options: Options, editor: Editor, type: NodeType, diff --git a/packages/core/src/commands/resetAttributes.ts b/packages/core/src/commands/resetAttributes.ts new file mode 100644 index 00000000..e9c6bf6c --- /dev/null +++ b/packages/core/src/commands/resetAttributes.ts @@ -0,0 +1,61 @@ +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 { Command, RawCommands } from '../types' + +declare module '@tiptap/core' { + interface Commands { + resetAttributes: { + /** + * Resets some node attributes to the default value. + */ + resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => Command, + } + } +} + +export const resetAttributes: RawCommands['resetAttributes'] = (typeOrName, attributes) => ({ tr, state, dispatch }) => { + let nodeType: NodeType | null = null + let markType: MarkType | null = null + + const schemaType = getSchemaTypeNameByName( + typeof typeOrName === 'string' + ? typeOrName + : typeOrName.name, + state.schema, + ) + + if (!schemaType) { + return false + } + + if (schemaType === 'node') { + nodeType = getNodeType(typeOrName as NodeType, state.schema) + } + + if (schemaType === 'mark') { + markType = getMarkType(typeOrName as MarkType, state.schema) + } + + if (dispatch) { + tr.selection.ranges.forEach(range => { + state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => { + if (nodeType && nodeType === node.type) { + tr.setNodeMarkup(pos, undefined, deleteProps(node.attrs, attributes)) + } + + if (markType && node.marks.length) { + node.marks.forEach(mark => { + if (markType === mark.type) { + tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes))) + } + }) + } + }) + }) + } + + return true +} diff --git a/packages/core/src/commands/resetNodeAttributes.ts b/packages/core/src/commands/resetNodeAttributes.ts index 6a51546e..d8bb68f3 100644 --- a/packages/core/src/commands/resetNodeAttributes.ts +++ b/packages/core/src/commands/resetNodeAttributes.ts @@ -15,6 +15,8 @@ declare module '@tiptap/core' { } export const resetNodeAttributes: RawCommands['resetNodeAttributes'] = (typeOrName, attributes) => ({ tr, state, dispatch }) => { + console.warn('[tiptap warn]: resetNodeAttributes() is deprecated. please use resetAttributes() instead.') + const type = getNodeType(typeOrName, state.schema) const { selection } = tr const { ranges } = selection diff --git a/packages/core/src/commands/updateAttributes.ts b/packages/core/src/commands/updateAttributes.ts new file mode 100644 index 00000000..931f7bb5 --- /dev/null +++ b/packages/core/src/commands/updateAttributes.ts @@ -0,0 +1,66 @@ +import { NodeType, MarkType } from 'prosemirror-model' +import getNodeType from '../helpers/getNodeType' +import getMarkType from '../helpers/getMarkType' +import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName' +import { AnyObject, Command, RawCommands } from '../types' + +declare module '@tiptap/core' { + interface Commands { + updateAttributes: { + /** + * Update attributes of a node or mark. + */ + updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: AnyObject) => Command, + } + } +} + +export const updateAttributes: RawCommands['updateAttributes'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => { + let nodeType: NodeType | null = null + let markType: MarkType | null = null + + const schemaType = getSchemaTypeNameByName( + typeof typeOrName === 'string' + ? typeOrName + : typeOrName.name, + state.schema, + ) + + if (!schemaType) { + return false + } + + if (schemaType === 'node') { + nodeType = getNodeType(typeOrName as NodeType, state.schema) + } + + if (schemaType === 'mark') { + markType = getMarkType(typeOrName as MarkType, state.schema) + } + + if (dispatch) { + tr.selection.ranges.forEach(range => { + state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => { + if (nodeType && nodeType === node.type) { + tr.setNodeMarkup(pos, undefined, { + ...node.attrs, + ...attributes, + }) + } + + if (markType && node.marks.length) { + node.marks.forEach(mark => { + if (markType === mark.type) { + tr.addMark(pos, pos + node.nodeSize, markType.create({ + ...mark.attrs, + ...attributes, + })) + } + }) + } + }) + }) + } + + return true +} diff --git a/packages/core/src/commands/updateNodeAttributes.ts b/packages/core/src/commands/updateNodeAttributes.ts index fd16f1e5..29ede6f4 100644 --- a/packages/core/src/commands/updateNodeAttributes.ts +++ b/packages/core/src/commands/updateNodeAttributes.ts @@ -14,6 +14,8 @@ declare module '@tiptap/core' { } export const updateNodeAttributes: RawCommands['updateNodeAttributes'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => { + console.warn('[tiptap warn]: updateNodeAttributes() is deprecated. please use updateAttributes() instead.') + const type = getNodeType(typeOrName, state.schema) const { selection } = tr const { ranges } = selection diff --git a/packages/core/src/extensions/commands.ts b/packages/core/src/extensions/commands.ts index ca992cea..a028b51b 100644 --- a/packages/core/src/extensions/commands.ts +++ b/packages/core/src/extensions/commands.ts @@ -24,6 +24,7 @@ import * as liftListItem from '../commands/liftListItem' import * as newlineInCode from '../commands/newlineInCode' import * as replace from '../commands/replace' import * as replaceRange from '../commands/replaceRange' +import * as resetAttributes from '../commands/resetAttributes' import * as resetNodeAttributes from '../commands/resetNodeAttributes' import * as scrollIntoView from '../commands/scrollIntoView' import * as selectAll from '../commands/selectAll' @@ -43,6 +44,7 @@ import * as toggleWrap from '../commands/toggleWrap' import * as undoInputRule from '../commands/undoInputRule' import * as unsetAllMarks from '../commands/unsetAllMarks' import * as unsetMark from '../commands/unsetMark' +import * as updateAttributes from '../commands/updateAttributes' import * as updateNodeAttributes from '../commands/updateNodeAttributes' import * as wrapIn from '../commands/wrapIn' import * as wrapInList from '../commands/wrapInList' @@ -72,6 +74,7 @@ export { liftListItem } export { newlineInCode } export { replace } export { replaceRange } +export { resetAttributes } export { resetNodeAttributes } export { scrollIntoView } export { selectAll } @@ -91,6 +94,7 @@ export { toggleWrap } export { undoInputRule } export { unsetAllMarks } export { unsetMark } +export { updateAttributes } export { updateNodeAttributes } export { wrapIn } export { wrapInList } @@ -125,6 +129,7 @@ export const Commands = Extension.create({ ...newlineInCode, ...replace, ...replaceRange, + ...resetAttributes, ...resetNodeAttributes, ...scrollIntoView, ...selectAll, @@ -144,6 +149,7 @@ export const Commands = Extension.create({ ...undoInputRule, ...unsetAllMarks, ...unsetMark, + ...updateAttributes, ...updateNodeAttributes, ...wrapIn, ...wrapInList, diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 453d52c6..8a6e7aa7 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -31,7 +31,6 @@ export interface EditorOptions { enablePasteRules: boolean, onCreate: (props: { editor: Editor }) => void, onUpdate: (props: { editor: Editor }) => void, - onViewUpdate: (props: { editor: Editor }) => void, onSelectionUpdate: (props: { editor: Editor }) => void, onTransaction: (props: { editor: Editor, transaction: Transaction }) => void, onFocus: (props: { editor: Editor, event: FocusEvent }) => void, diff --git a/packages/extension-mention/CHANGELOG.md b/packages/extension-mention/CHANGELOG.md index 02ccba6b..dfd9eb86 100644 --- a/packages/extension-mention/CHANGELOG.md +++ b/packages/extension-mention/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-beta.20](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.19...@tiptap/extension-mention@2.0.0-beta.20) (2021-04-07) + +**Note:** Version bump only for package @tiptap/extension-mention + + + + + +# [2.0.0-beta.19](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.18...@tiptap/extension-mention@2.0.0-beta.19) (2021-04-07) + +**Note:** Version bump only for package @tiptap/extension-mention + + + + + # [2.0.0-beta.18](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.17...@tiptap/extension-mention@2.0.0-beta.18) (2021-04-07) **Note:** Version bump only for package @tiptap/extension-mention diff --git a/packages/extension-mention/package.json b/packages/extension-mention/package.json index bd00ad1e..defd5996 100644 --- a/packages/extension-mention/package.json +++ b/packages/extension-mention/package.json @@ -1,7 +1,7 @@ { "name": "@tiptap/extension-mention", "description": "mention extension for tiptap", - "version": "2.0.0-beta.18", + "version": "2.0.0-beta.20", "homepage": "https://tiptap.dev", "keywords": [ "tiptap", @@ -25,6 +25,6 @@ "@tiptap/core": "^2.0.0-beta.1" }, "dependencies": { - "@tiptap/suggestion": "^2.0.0-beta.18" + "@tiptap/suggestion": "^2.0.0-beta.20" } } diff --git a/packages/extension-text-align/CHANGELOG.md b/packages/extension-text-align/CHANGELOG.md index 22927500..42b72f59 100644 --- a/packages/extension-text-align/CHANGELOG.md +++ b/packages/extension-text-align/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-beta.2...@tiptap/extension-text-align@2.0.0-beta.3) (2021-04-07) + + +### Features + +* add resetAttributes() command, deprecate resetNodeAttributes() ([3334d93](https://github.com/ueberdosis/tiptap-next/commit/3334d930f30bd4acb5c314b4ec1934b6a1e0b712)) + + + + + +# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-beta.1...@tiptap/extension-text-align@2.0.0-beta.2) (2021-04-07) + + +### Features + +* add updateAttributes() command, deprecate updateNodeAttributes(), fix [#254](https://github.com/ueberdosis/tiptap-next/issues/254) ([aac32b4](https://github.com/ueberdosis/tiptap-next/commit/aac32b4df6a1dfd93500e09d3433fcd8acad5fbe)) + + + + + # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@2.0.0-alpha.12...@tiptap/extension-text-align@2.0.0-beta.1) (2021-03-05) **Note:** Version bump only for package @tiptap/extension-text-align diff --git a/packages/extension-text-align/package.json b/packages/extension-text-align/package.json index 119dff16..646695cd 100644 --- a/packages/extension-text-align/package.json +++ b/packages/extension-text-align/package.json @@ -1,7 +1,7 @@ { "name": "@tiptap/extension-text-align", "description": "text align extension for tiptap", - "version": "2.0.0-beta.1", + "version": "2.0.0-beta.3", "homepage": "https://tiptap.dev", "keywords": [ "tiptap", diff --git a/packages/extension-text-align/src/text-align.ts b/packages/extension-text-align/src/text-align.ts index cef5ad27..bb41d312 100644 --- a/packages/extension-text-align/src/text-align.ts +++ b/packages/extension-text-align/src/text-align.ts @@ -56,10 +56,10 @@ export const TextAlign = Extension.create({ return false } - return this.options.types.every(type => commands.updateNodeAttributes(type, { textAlign: alignment })) + return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment })) }, unsetTextAlign: () => ({ commands }) => { - return this.options.types.every(type => commands.resetNodeAttributes(type, 'textAlign')) + return this.options.types.every(type => commands.resetAttributes(type, 'textAlign')) }, } }, diff --git a/packages/html/CHANGELOG.md b/packages/html/CHANGELOG.md index 969f11a8..ea9aaa74 100644 --- a/packages/html/CHANGELOG.md +++ b/packages/html/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-beta.20](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.19...@tiptap/html@2.0.0-beta.20) (2021-04-07) + +**Note:** Version bump only for package @tiptap/html + + + + + +# [2.0.0-beta.19](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.18...@tiptap/html@2.0.0-beta.19) (2021-04-07) + +**Note:** Version bump only for package @tiptap/html + + + + + # [2.0.0-beta.18](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.17...@tiptap/html@2.0.0-beta.18) (2021-04-07) **Note:** Version bump only for package @tiptap/html diff --git a/packages/html/package.json b/packages/html/package.json index 4934878d..b40e140b 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -1,7 +1,7 @@ { "name": "@tiptap/html", "description": "utility package to render tiptap JSON as HTML", - "version": "2.0.0-beta.18", + "version": "2.0.0-beta.20", "homepage": "https://tiptap.dev", "keywords": [ "tiptap", @@ -22,7 +22,7 @@ "dist" ], "dependencies": { - "@tiptap/core": "^2.0.0-beta.18", + "@tiptap/core": "^2.0.0-beta.20", "hostic-dom": "^0.8.6", "prosemirror-model": "^1.14.0" } diff --git a/packages/react/src/NodeViewContent.tsx b/packages/react/src/NodeViewContent.tsx index 6d2a429a..2587164c 100644 --- a/packages/react/src/NodeViewContent.tsx +++ b/packages/react/src/NodeViewContent.tsx @@ -1,5 +1,4 @@ import React from 'react' -import { useReactNodeView } from './useReactNodeView' export interface NodeViewContentProps { className?: string, @@ -7,14 +6,12 @@ export interface NodeViewContentProps { } export const NodeViewContent: React.FC = props => { - const { isEditable } = useReactNodeView() const Tag = props.as || 'div' return ( ) diff --git a/packages/react/src/ReactNodeViewRenderer.tsx b/packages/react/src/ReactNodeViewRenderer.tsx index 0ba36fef..8332a247 100644 --- a/packages/react/src/ReactNodeViewRenderer.tsx +++ b/packages/react/src/ReactNodeViewRenderer.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react' +import React from 'react' import { NodeView, NodeViewProps, @@ -40,21 +40,11 @@ class ReactNodeView extends NodeView { } const ReactNodeViewProvider: React.FunctionComponent = componentProps => { - const [isEditable, setIsEditable] = useState(this.editor.isEditable) const onDragStart = this.onDragStart.bind(this) - const onViewUpdate = () => setIsEditable(this.editor.isEditable) const Component = this.component - useEffect(() => { - this.editor.on('viewUpdate', onViewUpdate) - - return () => { - this.editor.off('viewUpdate', onViewUpdate) - } - }, []) - return ( - + ) diff --git a/packages/react/src/useReactNodeView.ts b/packages/react/src/useReactNodeView.ts index 142edbfa..a1353e53 100644 --- a/packages/react/src/useReactNodeView.ts +++ b/packages/react/src/useReactNodeView.ts @@ -1,12 +1,10 @@ import { createContext, useContext } from 'react' export interface ReactNodeViewContextProps { - isEditable: boolean, onDragStart: (event: DragEvent) => void, } export const ReactNodeViewContext = createContext>({ - isEditable: undefined, onDragStart: undefined, }) diff --git a/packages/starter-kit/CHANGELOG.md b/packages/starter-kit/CHANGELOG.md index 7b384bc4..3d68be38 100644 --- a/packages/starter-kit/CHANGELOG.md +++ b/packages/starter-kit/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.14...@tiptap/starter-kit@2.0.0-beta.15) (2021-04-07) + +**Note:** Version bump only for package @tiptap/starter-kit + + + + + +# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.13...@tiptap/starter-kit@2.0.0-beta.14) (2021-04-07) + +**Note:** Version bump only for package @tiptap/starter-kit + + + + + # [2.0.0-beta.13](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.12...@tiptap/starter-kit@2.0.0-beta.13) (2021-04-07) **Note:** Version bump only for package @tiptap/starter-kit diff --git a/packages/starter-kit/package.json b/packages/starter-kit/package.json index c93c9741..4765caf7 100644 --- a/packages/starter-kit/package.json +++ b/packages/starter-kit/package.json @@ -1,7 +1,7 @@ { "name": "@tiptap/starter-kit", "description": "starter kit for tiptap", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.15", "homepage": "https://tiptap.dev", "keywords": [ "tiptap", @@ -22,7 +22,7 @@ "dist" ], "dependencies": { - "@tiptap/core": "^2.0.0-beta.18", + "@tiptap/core": "^2.0.0-beta.20", "@tiptap/extension-blockquote": "^2.0.0-beta.1", "@tiptap/extension-bold": "^2.0.0-beta.1", "@tiptap/extension-bullet-list": "^2.0.0-beta.1", diff --git a/packages/suggestion/CHANGELOG.md b/packages/suggestion/CHANGELOG.md index bc006328..50950d1f 100644 --- a/packages/suggestion/CHANGELOG.md +++ b/packages/suggestion/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-beta.20](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.19...@tiptap/suggestion@2.0.0-beta.20) (2021-04-07) + +**Note:** Version bump only for package @tiptap/suggestion + + + + + +# [2.0.0-beta.19](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.18...@tiptap/suggestion@2.0.0-beta.19) (2021-04-07) + +**Note:** Version bump only for package @tiptap/suggestion + + + + + # [2.0.0-beta.18](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.17...@tiptap/suggestion@2.0.0-beta.18) (2021-04-07) **Note:** Version bump only for package @tiptap/suggestion diff --git a/packages/suggestion/package.json b/packages/suggestion/package.json index 06b3b7fb..c6ee656d 100644 --- a/packages/suggestion/package.json +++ b/packages/suggestion/package.json @@ -1,7 +1,7 @@ { "name": "@tiptap/suggestion", "description": "suggestion plugin for tiptap", - "version": "2.0.0-beta.18", + "version": "2.0.0-beta.20", "homepage": "https://tiptap.dev", "keywords": [ "tiptap", @@ -22,7 +22,7 @@ "dist" ], "dependencies": { - "@tiptap/core": "^2.0.0-beta.18", + "@tiptap/core": "^2.0.0-beta.20", "prosemirror-model": "^1.14.0", "prosemirror-state": "^1.3.4", "prosemirror-view": "^1.18.2" diff --git a/packages/vue-2/src/NodeViewContent.ts b/packages/vue-2/src/NodeViewContent.ts index 3405106f..b356ed1c 100644 --- a/packages/vue-2/src/NodeViewContent.ts +++ b/packages/vue-2/src/NodeViewContent.ts @@ -8,8 +8,6 @@ export const NodeViewContent = Vue.extend({ }, }, - inject: ['isEditable'], - render(createElement) { return createElement( this.as, { @@ -18,8 +16,6 @@ export const NodeViewContent = Vue.extend({ }, attrs: { 'data-node-view-content': '', - // @ts-ignore - contenteditable: this.isEditable.value, }, }, ) diff --git a/packages/vue-2/src/VueNodeViewRenderer.ts b/packages/vue-2/src/VueNodeViewRenderer.ts index 0772b99b..cd23b472 100644 --- a/packages/vue-2/src/VueNodeViewRenderer.ts +++ b/packages/vue-2/src/VueNodeViewRenderer.ts @@ -67,13 +67,6 @@ class VueNodeView extends NodeView<(Vue | VueConstructor), Editor> { } const onDragStart = this.onDragStart.bind(this) - const isEditable = Vue.observable({ - value: this.editor.isEditable, - }) - - this.editor.on('viewUpdate', () => { - isEditable.value = this.editor.isEditable - }) this.decorationClasses = Vue.observable({ value: this.getDecorationClasses(), @@ -86,7 +79,6 @@ class VueNodeView extends NodeView<(Vue | VueConstructor), Editor> { provide: () => { return { onDragStart, - isEditable, decorationClasses: this.decorationClasses, } }, diff --git a/packages/vue-3/src/NodeViewContent.ts b/packages/vue-3/src/NodeViewContent.ts index fe89f319..0daa14b8 100644 --- a/packages/vue-3/src/NodeViewContent.ts +++ b/packages/vue-3/src/NodeViewContent.ts @@ -8,8 +8,6 @@ export const NodeViewContent = defineComponent({ }, }, - inject: ['isEditable'], - render() { return h( this.as, { @@ -17,8 +15,6 @@ export const NodeViewContent = defineComponent({ whiteSpace: 'pre-wrap', }, 'data-node-view-content': '', - // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031) - contenteditable: this.isEditable.value, }, ) }, diff --git a/packages/vue-3/src/VueNodeViewRenderer.ts b/packages/vue-3/src/VueNodeViewRenderer.ts index cab63348..aa1ed6e3 100644 --- a/packages/vue-3/src/VueNodeViewRenderer.ts +++ b/packages/vue-3/src/VueNodeViewRenderer.ts @@ -71,11 +71,6 @@ class VueNodeView extends NodeView { } const onDragStart = this.onDragStart.bind(this) - const isEditable = ref(this.editor.isEditable) - - this.editor.on('viewUpdate', () => { - isEditable.value = this.editor.isEditable - }) this.decorationClasses = ref(this.getDecorationClasses()) @@ -84,7 +79,6 @@ class VueNodeView extends NodeView { props: Object.keys(props), setup: () => { provide('onDragStart', onDragStart) - provide('isEditable', isEditable) provide('decorationClasses', this.decorationClasses) return (this.component as any).setup?.(props)