Merge branch 'main' of github.com:ueberdosis/tiptap-next into main
This commit is contained in:
@@ -16,7 +16,7 @@ export default Node.create({
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ['node-view', mergeAttributes(HTMLAttributes)]
|
||||
return ['node-view', mergeAttributes(HTMLAttributes), 0]
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
|
||||
@@ -18,7 +18,7 @@ export default Node.create({
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ['react-component', mergeAttributes(HTMLAttributes)]
|
||||
return ['react-component', mergeAttributes(HTMLAttributes), 0]
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
|
||||
@@ -18,7 +18,7 @@ export default Node.create({
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ['vue-component', mergeAttributes(HTMLAttributes)]
|
||||
return ['vue-component', mergeAttributes(HTMLAttributes), 0]
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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.
|
||||
},
|
||||
|
||||
@@ -51,6 +51,7 @@ const editor = new Editor({
|
||||
Text,
|
||||
// …
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
Learn [more about custom extensions in our guide](/guide/extend-extensions).
|
||||
|
||||
@@ -49,6 +49,7 @@ const editor = new Editor({
|
||||
Text,
|
||||
// …
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
Learn [more about custom extensions in our guide](/guide/custom-extensions).
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
61
packages/core/src/commands/resetAttributes.ts
Normal file
61
packages/core/src/commands/resetAttributes.ts
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
66
packages/core/src/commands/updateAttributes.ts
Normal file
66
packages/core/src/commands/updateAttributes.ts
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -56,10 +56,10 @@ export const TextAlign = Extension.create<TextAlignOptions>({
|
||||
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'))
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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<NodeViewContentProps> = props => {
|
||||
const { isEditable } = useReactNodeView()
|
||||
const Tag = props.as || 'div'
|
||||
|
||||
return (
|
||||
<Tag
|
||||
className={props.className}
|
||||
data-node-view-content=""
|
||||
contentEditable={isEditable}
|
||||
style={{ whiteSpace: 'pre-wrap' }}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -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<React.FunctionComponent, Editor> {
|
||||
}
|
||||
|
||||
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 (
|
||||
<ReactNodeViewContext.Provider value={{ onDragStart, isEditable }}>
|
||||
<ReactNodeViewContext.Provider value={{ onDragStart }}>
|
||||
<Component {...componentProps} />
|
||||
</ReactNodeViewContext.Provider>
|
||||
)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { createContext, useContext } from 'react'
|
||||
|
||||
export interface ReactNodeViewContextProps {
|
||||
isEditable: boolean,
|
||||
onDragStart: (event: DragEvent) => void,
|
||||
}
|
||||
|
||||
export const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({
|
||||
isEditable: undefined,
|
||||
onDragStart: undefined,
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
)
|
||||
},
|
||||
|
||||
@@ -71,11 +71,6 @@ class VueNodeView extends NodeView<Component, Editor> {
|
||||
}
|
||||
|
||||
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<Component, Editor> {
|
||||
props: Object.keys(props),
|
||||
setup: () => {
|
||||
provide('onDragStart', onDragStart)
|
||||
provide('isEditable', isEditable)
|
||||
provide('decorationClasses', this.decorationClasses)
|
||||
|
||||
return (this.component as any).setup?.(props)
|
||||
|
||||
Reference in New Issue
Block a user