Merge branch 'main' into feature/extension-code-block-lowlight

This commit is contained in:
Philipp Kühn
2021-04-07 22:39:39 +02:00
125 changed files with 1230 additions and 1389 deletions

View File

@@ -3,6 +3,69 @@
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)
### Features
* add priority option to extensions ([bb1ae65](https://github.com/ueberdosis/tiptap-next/commit/bb1ae659a463e97a7ada15af711347b5c004897a))
# [2.0.0-beta.17](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.16...@tiptap/core@2.0.0-beta.17) (2021-04-07)
### Bug Fixes
* remove debug log ([beb96c5](https://github.com/ueberdosis/tiptap-next/commit/beb96c5cbfdb81869763e23f82f5ab270c30f0ea))
# [2.0.0-beta.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.15...@tiptap/core@2.0.0-beta.16) (2021-04-07)
### Features
* add insertContent() command, deprecate insertText(), insertHTML() and insertNode() ([b8d9b7d](https://github.com/ueberdosis/tiptap-next/commit/b8d9b7d4c70b38fb9eec3c079be8243d30166e5e))
# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.14...@tiptap/core@2.0.0-beta.15) (2021-04-06)
**Note:** Version bump only for package @tiptap/core
# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.13...@tiptap/core@2.0.0-beta.14) (2021-04-04)
**Note:** Version bump only for package @tiptap/core

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/core",
"description": "headless rich text editor",
"version": "2.0.0-beta.14",
"version": "2.0.0-beta.20",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -35,10 +35,10 @@
"prosemirror-commands": "^1.1.7",
"prosemirror-inputrules": "^1.1.3",
"prosemirror-keymap": "^1.1.3",
"prosemirror-model": "^1.13.3",
"prosemirror-model": "^1.14.0",
"prosemirror-schema-list": "^1.1.4",
"prosemirror-state": "^1.3.4",
"prosemirror-transform": "^1.2.12",
"prosemirror-transform": "^1.3.2",
"prosemirror-view": "^1.18.2"
}
}

View File

@@ -2,12 +2,12 @@ import {
EditorState, Plugin, PluginKey, Transaction,
} from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { Schema, DOMParser, Node } from 'prosemirror-model'
import elementFromString from './utilities/elementFromString'
import { Schema } from 'prosemirror-model'
import getNodeAttributes from './helpers/getNodeAttributes'
import getMarkAttributes from './helpers/getMarkAttributes'
import isActive from './helpers/isActive'
import removeElement from './utilities/removeElement'
import createDocument from './helpers/createDocument'
import getHTMLFromFragment from './helpers/getHTMLFromFragment'
import isNodeEmpty from './helpers/isNodeEmpty'
import createStyleTag from './utilities/createStyleTag'
@@ -16,7 +16,6 @@ import ExtensionManager from './ExtensionManager'
import EventEmitter from './EventEmitter'
import {
EditorOptions,
Content,
CanCommands,
ChainedCommands,
SingleCommands,
@@ -62,7 +61,6 @@ export class Editor extends EventEmitter {
onCreate: () => null,
onUpdate: () => null,
onSelectionUpdate: () => null,
onViewUpdate: () => null,
onTransaction: () => null,
onFocus: () => null,
onBlur: () => null,
@@ -83,7 +81,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)
@@ -240,23 +237,14 @@ export class Editor extends EventEmitter {
...this.options.editorProps,
dispatchTransaction: this.dispatchTransaction.bind(this),
state: EditorState.create({
doc: this.createDocument(this.options.content),
doc: createDocument(this.options.content, this.schema, this.options.parseOptions),
}),
})
// `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)
@@ -278,34 +266,6 @@ export class Editor extends EventEmitter {
})
}
/**
* Creates a ProseMirror document.
*/
public createDocument = (content: Content, parseOptions = this.options.parseOptions): Node => {
if (content && typeof content === 'object') {
try {
return this.schema.nodeFromJSON(content)
} catch (error) {
console.warn(
'[tiptap warn]: Invalid content.',
'Passed value:',
content,
'Error:',
error,
)
return this.createDocument('')
}
}
if (typeof content === 'string') {
return DOMParser
.fromSchema(this.schema)
.parse(elementFromString(content), parseOptions)
}
return this.createDocument('')
}
public isCapturingTransaction = false
private capturedTransaction: Transaction | null = null

View File

@@ -16,6 +16,11 @@ declare module '@tiptap/core' {
*/
name: string,
/**
* Priority
*/
priority?: number,
/**
* Default options
*/
@@ -126,14 +131,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.
*/
@@ -188,6 +185,7 @@ export class Extension<Options = any> {
config: ExtensionConfig = {
name: 'extension',
priority: 100,
defaultOptions: {},
}

View File

@@ -25,7 +25,7 @@ export default class ExtensionManager {
constructor(extensions: Extensions, editor: Editor) {
this.editor = editor
this.extensions = extensions
this.extensions = this.sort(extensions)
this.schema = getSchema(this.extensions)
this.extensions.forEach(extension => {
@@ -59,10 +59,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))
}
@@ -81,6 +77,22 @@ export default class ExtensionManager {
})
}
private sort(extensions: Extensions) {
const defaultPriority = 100
return extensions.sort((a, b) => {
if ((a.config.priority || defaultPriority) > (b.config.priority || defaultPriority)) {
return -1
}
if ((a.config.priority || defaultPriority) < (b.config.priority || defaultPriority)) {
return 1
}
return 0
})
}
get commands(): RawCommands {
return this.extensions.reduce((commands, extension) => {
const context = {

View File

@@ -21,6 +21,11 @@ declare module '@tiptap/core' {
*/
name: string,
/**
* Priority
*/
priority?: number,
/**
* Default options
*/
@@ -140,15 +145,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.
*/
@@ -263,6 +259,7 @@ export class Mark<Options = any> {
config: MarkConfig = {
name: 'mark',
priority: 100,
defaultOptions: {},
}

View File

@@ -26,6 +26,11 @@ declare module '@tiptap/core' {
*/
name: string,
/**
* Priority
*/
priority?: number,
/**
* Default options
*/
@@ -139,16 +144,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,
@@ -321,6 +317,7 @@ export class Node<Options = any> {
config: NodeConfig = {
name: 'node',
priority: 100,
defaultOptions: {},
}

View File

@@ -0,0 +1,35 @@
import createNodeFromContent from '../helpers/createNodeFromContent'
import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd'
import { Command, RawCommands, Content } from '../types'
declare module '@tiptap/core' {
interface Commands {
insertContent: {
/**
* Insert a node or string of HTML at the current position.
*/
insertContent: (value: Content) => Command,
}
}
}
export const insertContent: RawCommands['insertContent'] = value => ({ tr, dispatch, editor }) => {
if (dispatch) {
const content = createNodeFromContent(value, editor.schema)
if (typeof content === 'string') {
tr.insertText(content)
return true
}
if (!tr.selection.empty) {
tr.deleteSelection()
}
tr.insert(tr.selection.anchor, content)
selectionToInsertionEnd(tr, tr.steps.length - 1, -1)
}
return true
}

View File

@@ -15,6 +15,8 @@ declare module '@tiptap/core' {
}
export const insertHTML: RawCommands['insertHTML'] = value => ({ tr, state, dispatch }) => {
console.warn('[tiptap warn]: insertHTML() is deprecated. please use insertContent() instead.')
const { selection } = tr
const element = elementFromString(value)
const slice = DOMParser.fromSchema(state.schema).parseSlice(element)

View File

@@ -14,6 +14,8 @@ declare module '@tiptap/core' {
}
export const insertNode: RawCommands['insertNode'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
console.warn('[tiptap warn]: insertNode() is deprecated. please use insertContent() instead.')
const { selection } = tr
const type = getNodeType(typeOrName, state.schema)

View File

@@ -12,6 +12,8 @@ declare module '@tiptap/core' {
}
export const insertText: RawCommands['insertText'] = value => ({ tr, dispatch }) => {
console.warn('[tiptap warn]: insertText() is deprecated. please use insertContent() instead.')
if (dispatch) {
tr.insertText(value)
}

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

View File

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

View File

@@ -1,5 +1,11 @@
import { TextSelection } from 'prosemirror-state'
import { AnyObject, Command, RawCommands } from '../types'
import createDocument from '../helpers/createDocument'
import {
AnyObject,
Command,
RawCommands,
Content,
} from '../types'
declare module '@tiptap/core' {
interface Commands {
@@ -7,15 +13,18 @@ declare module '@tiptap/core' {
/**
* Replace the whole document with new content.
*/
setContent: (content: string, emitUpdate?: Boolean, parseOptions?: AnyObject) => Command,
setContent: (
content: Content,
emitUpdate?: Boolean,
parseOptions?: AnyObject,
) => Command,
}
}
}
export const setContent: RawCommands['setContent'] = (content, emitUpdate = false, parseOptions = {}) => ({ tr, editor, dispatch }) => {
const { createDocument } = editor
const { doc } = tr
const document = createDocument(content, parseOptions)
const document = createDocument(content, editor.schema, parseOptions)
const selection = TextSelection.create(doc, 0, doc.content.size)
if (dispatch) {

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

View File

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

View File

@@ -11,6 +11,7 @@ import * as exitCode from '../commands/exitCode'
import * as extendMarkRange from '../commands/extendMarkRange'
import * as first from '../commands/first'
import * as focus from '../commands/focus'
import * as insertContent from '../commands/insertContent'
import * as insertHTML from '../commands/insertHTML'
import * as insertNode from '../commands/insertNode'
import * as insertText from '../commands/insertText'
@@ -23,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'
@@ -42,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'
@@ -58,6 +61,7 @@ export { exitCode }
export { extendMarkRange }
export { first }
export { focus }
export { insertContent }
export { insertHTML }
export { insertNode }
export { insertText }
@@ -70,6 +74,7 @@ export { liftListItem }
export { newlineInCode }
export { replace }
export { replaceRange }
export { resetAttributes }
export { resetNodeAttributes }
export { scrollIntoView }
export { selectAll }
@@ -89,6 +94,7 @@ export { toggleWrap }
export { undoInputRule }
export { unsetAllMarks }
export { unsetMark }
export { updateAttributes }
export { updateNodeAttributes }
export { wrapIn }
export { wrapInList }
@@ -110,6 +116,7 @@ export const Commands = Extension.create({
...extendMarkRange,
...first,
...focus,
...insertContent,
...insertHTML,
...insertNode,
...insertText,
@@ -122,6 +129,7 @@ export const Commands = Extension.create({
...newlineInCode,
...replace,
...replaceRange,
...resetAttributes,
...resetNodeAttributes,
...scrollIntoView,
...selectAll,
@@ -141,6 +149,7 @@ export const Commands = Extension.create({
...undoInputRule,
...unsetAllMarks,
...unsetMark,
...updateAttributes,
...updateNodeAttributes,
...wrapIn,
...wrapInList,

View File

@@ -0,0 +1,13 @@
import { Schema, Node as ProseMirrorNode } from 'prosemirror-model'
import { AnyObject } from '../types'
import createNodeFromContent from './createNodeFromContent'
export type Content = string | JSON | null
export default function createDocument(
content: Content,
schema: Schema,
parseOptions: AnyObject = {},
): ProseMirrorNode {
return createNodeFromContent(content, schema, { slice: false, parseOptions }) as ProseMirrorNode
}

View File

@@ -0,0 +1,59 @@
import {
Schema,
DOMParser,
Node as ProseMirrorNode,
Fragment,
} from 'prosemirror-model'
import elementFromString from '../utilities/elementFromString'
import { AnyObject } from '../types'
export type Content = string | JSON | null
export type CreateNodeFromContentOptions = {
slice?: boolean,
parseOptions?: AnyObject,
}
export default function createNodeFromContent(
content: Content,
schema: Schema,
options?: CreateNodeFromContentOptions,
): string | ProseMirrorNode | Fragment {
options = {
slice: true,
parseOptions: {},
...options,
}
if (content && typeof content === 'object') {
try {
return schema.nodeFromJSON(content)
} catch (error) {
console.warn(
'[tiptap warn]: Invalid content.',
'Passed value:',
content,
'Error:',
error,
)
return createNodeFromContent('', schema, options)
}
}
if (typeof content === 'string') {
const isHTML = content.trim().startsWith('<') && content.trim().endsWith('>')
if (isHTML || !options.slice) {
const parser = DOMParser.fromSchema(schema)
return options.slice
? parser.parseSlice(elementFromString(content), options.parseOptions).content
: parser.parse(elementFromString(content), options.parseOptions)
}
return content
}
return createNodeFromContent('', schema, options)
}

View File

@@ -32,7 +32,6 @@ export interface EditorOptions {
onBeforeCreate: (props: { editor: Editor }) => void,
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,

View File

@@ -3,6 +3,17 @@
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.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-collaboration-cursor@2.0.0-beta.4...@tiptap/extension-collaboration-cursor@2.0.0-beta.5) (2021-04-07)
### Features
* add priority option to extensions ([bb1ae65](https://github.com/ueberdosis/tiptap-next/commit/bb1ae659a463e97a7ada15af711347b5c004897a))
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-collaboration-cursor@2.0.0-beta.3...@tiptap/extension-collaboration-cursor@2.0.0-beta.4) (2021-03-16)
**Note:** Version bump only for package @tiptap/extension-collaboration-cursor

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-collaboration-cursor",
"description": "collaboration cursor extension for tiptap",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@@ -31,6 +31,8 @@ const awarenessStatesToArray = (states: Map<number, { [key: string]: any }>) =>
export const CollaborationCursor = Extension.create<CollaborationCursorOptions>({
name: 'collaborationCursor',
priority: 1000,
defaultOptions: {
provider: null,
user: {

View File

@@ -3,6 +3,14 @@
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.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-dropcursor@2.0.0-beta.1...@tiptap/extension-dropcursor@2.0.0-beta.2) (2021-04-06)
**Note:** Version bump only for package @tiptap/extension-dropcursor
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-dropcursor@2.0.0-alpha.11...@tiptap/extension-dropcursor@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/extension-dropcursor

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-dropcursor",
"description": "dropcursor extension for tiptap",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -26,6 +26,6 @@
},
"dependencies": {
"@types/prosemirror-dropcursor": "^1.0.1",
"prosemirror-dropcursor": "^1.3.3"
"prosemirror-dropcursor": "^1.3.4"
}
}

View File

@@ -3,6 +3,17 @@
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.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-horizontal-rule@2.0.0-beta.1...@tiptap/extension-horizontal-rule@2.0.0-beta.2) (2021-04-07)
### Bug Fixes
* improve handling of horizontal rule at document end, fix [#248](https://github.com/ueberdosis/tiptap-next/issues/248) ([af17f2c](https://github.com/ueberdosis/tiptap-next/commit/af17f2c65794767e4b7ddfd1c1277a567acd898d))
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-horizontal-rule@2.0.0-alpha.11...@tiptap/extension-horizontal-rule@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/extension-horizontal-rule

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-horizontal-rule",
"description": "horizontal rule extension for tiptap",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -22,7 +22,9 @@
"dist"
],
"peerDependencies": {
"@tiptap/core": "^2.0.0-beta.1",
"prosemirror-commands": "^1.1.3"
"@tiptap/core": "^2.0.0-beta.1"
},
"dependencies": {
"prosemirror-state": "^1.3.4"
}
}

View File

@@ -4,6 +4,7 @@ import {
nodeInputRule,
mergeAttributes,
} from '@tiptap/core'
import { TextSelection } from 'prosemirror-state'
export interface HorizontalRuleOptions {
HTMLAttributes: {
@@ -46,6 +47,22 @@ export const HorizontalRule = Node.create<HorizontalRuleOptions>({
setHorizontalRule: () => ({ tr, dispatch }) => {
if (dispatch) {
tr.replaceSelectionWith(this.type.create())
const { parent, pos } = tr.selection.$from
const posAfter = pos + 1
const nodeAfter = tr.doc.nodeAt(posAfter)
// end of document
if (!nodeAfter) {
const node = parent.type.contentMatch.defaultType?.create()
if (node) {
tr.insert(posAfter, node)
tr.setSelection(TextSelection.create(tr.doc, posAfter))
}
}
tr.scrollIntoView()
}
return true

View File

@@ -3,6 +3,17 @@
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.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@2.0.0-beta.1...@tiptap/extension-link@2.0.0-beta.2) (2021-04-07)
### Features
* add priority option to extensions ([bb1ae65](https://github.com/ueberdosis/tiptap-next/commit/bb1ae659a463e97a7ada15af711347b5c004897a))
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@2.0.0-alpha.11...@tiptap/extension-link@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/extension-link

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-link",
"description": "link extension for tiptap",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@@ -38,6 +38,8 @@ export const pasteRegexWithBrackets = /(?:\()https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%
export const Link = Mark.create<LinkOptions>({
name: 'link',
priority: 1000,
inclusive: false,
defaultOptions: {

View File

@@ -3,6 +3,57 @@
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
# [2.0.0-beta.17](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.16...@tiptap/extension-mention@2.0.0-beta.17) (2021-04-07)
**Note:** Version bump only for package @tiptap/extension-mention
# [2.0.0-beta.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.15...@tiptap/extension-mention@2.0.0-beta.16) (2021-04-07)
### Features
* add insertContent() command, deprecate insertText(), insertHTML() and insertNode() ([b8d9b7d](https://github.com/ueberdosis/tiptap-next/commit/b8d9b7d4c70b38fb9eec3c079be8243d30166e5e))
# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.14...@tiptap/extension-mention@2.0.0-beta.15) (2021-04-06)
**Note:** Version bump only for package @tiptap/extension-mention
# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.13...@tiptap/extension-mention@2.0.0-beta.14) (2021-04-04)
**Note:** Version bump only for package @tiptap/extension-mention

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-mention",
"description": "mention extension for tiptap",
"version": "2.0.0-beta.14",
"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.14"
"@tiptap/suggestion": "^2.0.0-beta.20"
}
}

View File

@@ -20,7 +20,7 @@ export const Mention = Node.create<MentionOptions>({
.chain()
.focus()
.replaceRange(range, 'mention', props)
.insertText(' ')
.insertContent(' ')
.run()
},
allow: ({ editor, range }) => {

View File

@@ -3,6 +3,17 @@
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.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-paragraph@2.0.0-beta.1...@tiptap/extension-paragraph@2.0.0-beta.2) (2021-04-07)
### Features
* add priority option to extensions ([bb1ae65](https://github.com/ueberdosis/tiptap-next/commit/bb1ae659a463e97a7ada15af711347b5c004897a))
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-paragraph@2.0.0-alpha.11...@tiptap/extension-paragraph@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/extension-paragraph

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-paragraph",
"description": "paragraph extension for tiptap",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@@ -20,6 +20,8 @@ declare module '@tiptap/core' {
export const Paragraph = Node.create<ParagraphOptions>({
name: 'paragraph',
priority: 1000,
defaultOptions: {
HTMLAttributes: {},
},

View File

@@ -3,6 +3,14 @@
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.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-placeholder@2.0.0-beta.3...@tiptap/extension-placeholder@2.0.0-beta.4) (2021-04-06)
**Note:** Version bump only for package @tiptap/extension-placeholder
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-placeholder@2.0.0-beta.2...@tiptap/extension-placeholder@2.0.0-beta.3) (2021-03-31)
**Note:** Version bump only for package @tiptap/extension-placeholder

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-placeholder",
"description": "placeholder extension for tiptap",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -25,7 +25,7 @@
"@tiptap/core": "^2.0.0-beta.1"
},
"dependencies": {
"prosemirror-model": "^1.13.3",
"prosemirror-model": "^1.14.0",
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.2"
}

View File

@@ -3,6 +3,17 @@
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.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-task-item@2.0.0-beta.1...@tiptap/extension-task-item@2.0.0-beta.2) (2021-04-06)
### Bug Fixes
* fix checkbox in firefox, fix [#251](https://github.com/ueberdosis/tiptap-next/issues/251) ([5622dec](https://github.com/ueberdosis/tiptap-next/commit/5622deca30397170bae341a000b9fe4693280c9b))
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-task-item@2.0.0-alpha.12...@tiptap/extension-task-item@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/extension-task-item

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-task-item",
"description": "task item extension for tiptap",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@@ -81,11 +81,13 @@ export const TaskItem = Node.create<TaskItemOptions>({
}) => {
const { view } = editor
const listItem = document.createElement('li')
const checkboxWrapper = document.createElement('label')
const checkboxStyler = document.createElement('span')
const checkbox = document.createElement('input')
const content = document.createElement('div')
checkboxWrapper.contentEditable = 'false'
checkbox.type = 'checkbox'
checkbox.contentEditable = 'false'
checkbox.addEventListener('change', event => {
const { checked } = event.target as any
@@ -101,11 +103,14 @@ export const TaskItem = Node.create<TaskItemOptions>({
checkbox.setAttribute('checked', 'checked')
}
listItem.append(checkbox, content)
checkboxWrapper.append(checkbox, checkboxStyler)
listItem.append(checkboxWrapper, content)
Object.entries(HTMLAttributes).forEach(([key, value]) => {
listItem.setAttribute(key, value)
})
Object
.entries(HTMLAttributes)
.forEach(([key, value]) => {
listItem.setAttribute(key, value)
})
return {
dom: listItem,

View File

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

View File

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

View File

@@ -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'))
},
}
},

View File

@@ -3,6 +3,54 @@
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
# [2.0.0-beta.17](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.16...@tiptap/html@2.0.0-beta.17) (2021-04-07)
**Note:** Version bump only for package @tiptap/html
# [2.0.0-beta.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.15...@tiptap/html@2.0.0-beta.16) (2021-04-07)
**Note:** Version bump only for package @tiptap/html
# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.14...@tiptap/html@2.0.0-beta.15) (2021-04-06)
**Note:** Version bump only for package @tiptap/html
# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.13...@tiptap/html@2.0.0-beta.14) (2021-04-04)
**Note:** Version bump only for package @tiptap/html

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/html",
"description": "utility package to render tiptap JSON as HTML",
"version": "2.0.0-beta.14",
"version": "2.0.0-beta.20",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -22,8 +22,8 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.14",
"@tiptap/core": "^2.0.0-beta.20",
"hostic-dom": "^0.8.6",
"prosemirror-model": "^1.13.3"
"prosemirror-model": "^1.14.0"
}
}

View File

@@ -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.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.15...@tiptap/react@2.0.0-beta.16) (2021-04-07)
**Note:** Version bump only for package @tiptap/react
# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.14...@tiptap/react@2.0.0-beta.15) (2021-04-07)
**Note:** Version bump only for package @tiptap/react
# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.13...@tiptap/react@2.0.0-beta.14) (2021-04-04)

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/react",
"description": "React components for tiptap",
"version": "2.0.0-beta.14",
"version": "2.0.0-beta.16",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -32,6 +32,7 @@
"prosemirror-view": "^1.18.2"
},
"devDependencies": {
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3"
}
}

View File

@@ -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' }}
/>
)

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'
import React from 'react'
import {
NodeView,
NodeViewProps,
@@ -36,26 +36,15 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor> {
return string.charAt(0).toUpperCase() + string.substring(1)
}
// @ts-ignore
this.component.displayName = capitalizeFirstChar(this.extension.config.name)
}
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>
)

View File

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

View File

@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"jsx": "react",
},
"exclude": [
"**/node_modules",
"**/dist",
"../vue-3",
]
}

View File

@@ -3,6 +3,54 @@
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
# [2.0.0-beta.12](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.11...@tiptap/starter-kit@2.0.0-beta.12) (2021-04-07)
**Note:** Version bump only for package @tiptap/starter-kit
# [2.0.0-beta.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.10...@tiptap/starter-kit@2.0.0-beta.11) (2021-04-07)
**Note:** Version bump only for package @tiptap/starter-kit
# [2.0.0-beta.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.9...@tiptap/starter-kit@2.0.0-beta.10) (2021-04-06)
**Note:** Version bump only for package @tiptap/starter-kit
# [2.0.0-beta.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/starter-kit@2.0.0-beta.8...@tiptap/starter-kit@2.0.0-beta.9) (2021-04-04)
**Note:** Version bump only for package @tiptap/starter-kit

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/starter-kit",
"description": "starter kit for tiptap",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.15",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -22,23 +22,23 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.14",
"@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",
"@tiptap/extension-code": "^2.0.0-beta.1",
"@tiptap/extension-code-block": "^2.0.0-beta.2",
"@tiptap/extension-document": "^2.0.0-beta.1",
"@tiptap/extension-dropcursor": "^2.0.0-beta.1",
"@tiptap/extension-dropcursor": "^2.0.0-beta.2",
"@tiptap/extension-gapcursor": "^2.0.0-beta.4",
"@tiptap/extension-hard-break": "^2.0.0-beta.1",
"@tiptap/extension-heading": "^2.0.0-beta.1",
"@tiptap/extension-history": "^2.0.0-beta.1",
"@tiptap/extension-horizontal-rule": "^2.0.0-beta.1",
"@tiptap/extension-horizontal-rule": "^2.0.0-beta.2",
"@tiptap/extension-italic": "^2.0.0-beta.1",
"@tiptap/extension-list-item": "^2.0.0-beta.1",
"@tiptap/extension-ordered-list": "^2.0.0-beta.1",
"@tiptap/extension-paragraph": "^2.0.0-beta.1",
"@tiptap/extension-paragraph": "^2.0.0-beta.2",
"@tiptap/extension-strike": "^2.0.0-beta.1",
"@tiptap/extension-text": "^2.0.0-beta.1"
}

View File

@@ -3,6 +3,54 @@
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
# [2.0.0-beta.17](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.16...@tiptap/suggestion@2.0.0-beta.17) (2021-04-07)
**Note:** Version bump only for package @tiptap/suggestion
# [2.0.0-beta.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.15...@tiptap/suggestion@2.0.0-beta.16) (2021-04-07)
**Note:** Version bump only for package @tiptap/suggestion
# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.14...@tiptap/suggestion@2.0.0-beta.15) (2021-04-06)
**Note:** Version bump only for package @tiptap/suggestion
# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.13...@tiptap/suggestion@2.0.0-beta.14) (2021-04-04)
**Note:** Version bump only for package @tiptap/suggestion

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/suggestion",
"description": "suggestion plugin for tiptap",
"version": "2.0.0-beta.14",
"version": "2.0.0-beta.20",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -22,8 +22,8 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.14",
"prosemirror-model": "^1.13.3",
"@tiptap/core": "^2.0.0-beta.20",
"prosemirror-model": "^1.14.0",
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.2"
}

View File

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

View File

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

View File

@@ -3,6 +3,25 @@
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.17](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-3@2.0.0-beta.16...@tiptap/vue-3@2.0.0-beta.17) (2021-04-06)
### Bug Fixes
* fix vue dependency ([73650c1](https://github.com/ueberdosis/tiptap-next/commit/73650c12e0cc7be13705775a02c031e5e36ee4d1))
# [2.0.0-beta.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-3@2.0.0-beta.15...@tiptap/vue-3@2.0.0-beta.16) (2021-04-06)
**Note:** Version bump only for package @tiptap/vue-3
# [2.0.0-beta.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-3@2.0.0-beta.14...@tiptap/vue-3@2.0.0-beta.15) (2021-04-03)
**Note:** Version bump only for package @tiptap/vue-3

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/vue-3",
"description": "Vue components for tiptap",
"version": "2.0.0-beta.15",
"version": "2.0.0-beta.17",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

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

View File

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

View File

@@ -1,248 +0,0 @@
# Change Log
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.13](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.12...@tiptap/vue-starter-kit@2.0.0-beta.13) (2021-04-04)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.12](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.11...@tiptap/vue-starter-kit@2.0.0-beta.12) (2021-04-02)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.10...@tiptap/vue-starter-kit@2.0.0-beta.11) (2021-04-01)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.9...@tiptap/vue-starter-kit@2.0.0-beta.10) (2021-04-01)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.8...@tiptap/vue-starter-kit@2.0.0-beta.9) (2021-03-31)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.7...@tiptap/vue-starter-kit@2.0.0-beta.8) (2021-03-31)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.6...@tiptap/vue-starter-kit@2.0.0-beta.7) (2021-03-28)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.5...@tiptap/vue-starter-kit@2.0.0-beta.6) (2021-03-24)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.4...@tiptap/vue-starter-kit@2.0.0-beta.5) (2021-03-18)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.3...@tiptap/vue-starter-kit@2.0.0-beta.4) (2021-03-16)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.2...@tiptap/vue-starter-kit@2.0.0-beta.3) (2021-03-09)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-beta.1...@tiptap/vue-starter-kit@2.0.0-beta.2) (2021-03-08)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.16...@tiptap/vue-starter-kit@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.16](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.15...@tiptap/vue-starter-kit@2.0.0-alpha.16) (2021-02-26)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.15](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.14...@tiptap/vue-starter-kit@2.0.0-alpha.15) (2021-02-16)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.13...@tiptap/vue-starter-kit@2.0.0-alpha.14) (2021-02-07)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.13](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.12...@tiptap/vue-starter-kit@2.0.0-alpha.13) (2021-02-05)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.12](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.11...@tiptap/vue-starter-kit@2.0.0-alpha.12) (2021-01-29)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.10...@tiptap/vue-starter-kit@2.0.0-alpha.11) (2021-01-29)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.9...@tiptap/vue-starter-kit@2.0.0-alpha.10) (2021-01-28)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.8...@tiptap/vue-starter-kit@2.0.0-alpha.9) (2021-01-06)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.7...@tiptap/vue-starter-kit@2.0.0-alpha.8) (2020-12-18)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.6...@tiptap/vue-starter-kit@2.0.0-alpha.7) (2020-12-18)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.5...@tiptap/vue-starter-kit@2.0.0-alpha.6) (2020-12-02)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.4...@tiptap/vue-starter-kit@2.0.0-alpha.5) (2020-11-20)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.3...@tiptap/vue-starter-kit@2.0.0-alpha.4) (2020-11-19)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.2...@tiptap/vue-starter-kit@2.0.0-alpha.3) (2020-11-19)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@2.0.0-alpha.1...@tiptap/vue-starter-kit@2.0.0-alpha.2) (2020-11-19)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@1.0.0-alpha.2...@tiptap/vue-starter-kit@2.0.0-alpha.1) (2020-11-18)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-starter-kit@1.0.0-alpha.1...@tiptap/vue-starter-kit@1.0.0-alpha.2) (2020-11-16)
**Note:** Version bump only for package @tiptap/vue-starter-kit
# 1.0.0-alpha.1 (2020-11-16)
**Note:** Version bump only for package @tiptap/vue-starter-kit

View File

@@ -1,14 +0,0 @@
# @tiptap/vue-starter-kit
[![Version](https://img.shields.io/npm/v/@tiptap/vue-starter-kit.svg?label=version)](https://www.npmjs.com/package/@tiptap/vue-starter-kit)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/vue-starter-kit.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
[![License](https://img.shields.io/npm/l/@tiptap/vue-starter-kit.svg)](https://www.npmjs.com/package/@tiptap/vue-starter-kit)
[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
## Introduction
tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
## Offical Documentation
Documentation can be found on the [tiptap website](https://tiptap.dev).
## License
tiptap is open-sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap-next/blob/main/LICENSE.md).

View File

@@ -1,28 +0,0 @@
{
"name": "@tiptap/vue-starter-kit",
"description": "Vue starter kit for tiptap",
"version": "2.0.0-beta.13",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
"tiptap starter kit"
],
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"main": "dist/tiptap-vue-starter-kit.cjs.js",
"umd": "dist/tiptap-vue-starter-kit.umd.js",
"module": "dist/tiptap-vue-starter-kit.esm.js",
"unpkg": "dist/tiptap-vue-starter-kit.bundle.umd.min.js",
"types": "dist/packages/vue-starter-kit/src/index.d.ts",
"files": [
"src",
"dist"
],
"dependencies": {
"@tiptap/starter-kit": "^2.0.0-beta.9",
"@tiptap/vue": "^2.0.0-beta.5"
}
}

View File

@@ -1,2 +0,0 @@
export * from '@tiptap/starter-kit'
export * from '@tiptap/vue'

View File

@@ -1,160 +0,0 @@
# Change Log
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.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-beta.4...@tiptap/vue@2.0.0-beta.5) (2021-03-31)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-beta.3...@tiptap/vue@2.0.0-beta.4) (2021-03-28)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-beta.2...@tiptap/vue@2.0.0-beta.3) (2021-03-24)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-beta.1...@tiptap/vue@2.0.0-beta.2) (2021-03-18)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.13...@tiptap/vue@2.0.0-beta.1) (2021-03-05)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.13](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.12...@tiptap/vue@2.0.0-alpha.13) (2021-02-26)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.12](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.11...@tiptap/vue@2.0.0-alpha.12) (2021-02-16)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.10...@tiptap/vue@2.0.0-alpha.11) (2021-02-07)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.9...@tiptap/vue@2.0.0-alpha.10) (2021-02-05)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.8...@tiptap/vue@2.0.0-alpha.9) (2021-01-29)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.7...@tiptap/vue@2.0.0-alpha.8) (2021-01-29)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.6...@tiptap/vue@2.0.0-alpha.7) (2021-01-28)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.5...@tiptap/vue@2.0.0-alpha.6) (2021-01-06)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.4...@tiptap/vue@2.0.0-alpha.5) (2020-12-18)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.3...@tiptap/vue@2.0.0-alpha.4) (2020-12-02)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.2...@tiptap/vue@2.0.0-alpha.3) (2020-11-19)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@2.0.0-alpha.1...@tiptap/vue@2.0.0-alpha.2) (2020-11-19)
**Note:** Version bump only for package @tiptap/vue
# [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@1.0.0-alpha.2...@tiptap/vue@2.0.0-alpha.1) (2020-11-18)
**Note:** Version bump only for package @tiptap/vue
# [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue@1.0.0-alpha.1...@tiptap/vue@1.0.0-alpha.2) (2020-11-16)
**Note:** Version bump only for package @tiptap/vue
# 1.0.0-alpha.1 (2020-11-16)
**Note:** Version bump only for package @tiptap/vue

View File

@@ -1,14 +0,0 @@
# @tiptap/vue
[![Version](https://img.shields.io/npm/v/@tiptap/vue.svg?label=version)](https://www.npmjs.com/package/@tiptap/vue)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/vue.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
[![License](https://img.shields.io/npm/l/@tiptap/vue.svg)](https://www.npmjs.com/package/@tiptap/vue)
[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
## Introduction
tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
## Offical Documentation
Documentation can be found on the [tiptap website](https://tiptap.dev).
## License
tiptap is open-sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap-next/blob/main/LICENSE.md).

View File

@@ -1,31 +0,0 @@
{
"name": "@tiptap/vue",
"description": "Vue components for tiptap",
"version": "2.0.0-beta.5",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
"tiptap vue components"
],
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"main": "dist/tiptap-vue.cjs.js",
"umd": "dist/tiptap-vue.umd.js",
"module": "dist/tiptap-vue.esm.js",
"unpkg": "dist/tiptap-vue.bundle.umd.min.js",
"types": "dist/packages/vue/src/index.d.ts",
"files": [
"src",
"dist"
],
"peerDependencies": {
"@tiptap/core": "^2.0.0-beta.1",
"vue": "^2.6.12"
},
"dependencies": {
"prosemirror-view": "^1.18.2"
}
}

View File

@@ -1,331 +0,0 @@
import {
Editor,
Node,
NodeViewRenderer,
NodeViewRendererProps,
} from '@tiptap/core'
import { Decoration, NodeView } from 'prosemirror-view'
import { NodeSelection } from 'prosemirror-state'
import { Node as ProseMirrorNode } from 'prosemirror-model'
import Vue from 'vue'
import { VueConstructor } from 'vue/types/umd'
import VueRenderer from './VueRenderer'
function getComponentFromElement(element: HTMLElement): Vue {
// @ts-ignore
// eslint-disable-next-line
return element.__vue__
}
interface VueNodeViewRendererOptions {
stopEvent: ((event: Event) => boolean) | null,
update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null,
}
class VueNodeView implements NodeView {
renderer!: VueRenderer
editor: Editor
extension!: Node
node!: ProseMirrorNode
decorations!: Decoration[]
id!: string
getPos!: any
isDragging = false
options: VueNodeViewRendererOptions = {
stopEvent: null,
update: null,
}
constructor(component: Vue | VueConstructor, props: NodeViewRendererProps, options?: Partial<VueNodeViewRendererOptions>) {
this.options = { ...this.options, ...options }
this.editor = props.editor
this.extension = props.extension
this.node = props.node
this.getPos = props.getPos
this.createUniqueId()
this.mount(component)
}
createUniqueId() {
this.id = `id_${Math.floor(Math.random() * 0xFFFFFFFF)}`
}
createNodeViewWrapper() {
const { handleDragStart } = this
const dragstart = handleDragStart.bind(this)
return Vue.extend({
props: {
as: {
type: String,
default: 'div',
},
},
render(createElement) {
return createElement(
this.as, {
style: {
whiteSpace: 'normal',
},
on: {
dragstart,
},
},
this.$slots.default,
)
},
})
}
handleDragStart(event: DragEvent) {
const { view } = this.editor
const target = (event.target as HTMLElement)
if (this.contentDOM?.contains(target)) {
return
}
// sometimes `event.target` is not the `dom` element
event.dataTransfer?.setDragImage(this.dom, 0, 0)
const selection = NodeSelection.create(view.state.doc, this.getPos())
const transaction = view.state.tr.setSelection(selection)
view.dispatch(transaction)
}
createNodeViewContent() {
const { id } = this
const { isEditable } = this.editor
return Vue.extend({
inheritAttrs: false,
props: {
as: {
type: String,
default: 'div',
},
},
render(createElement) {
return createElement(
this.as, {
style: {
whiteSpace: 'pre-wrap',
},
domProps: {
id,
contenteditable: isEditable,
},
},
)
},
})
}
mount(component: Vue | VueConstructor) {
const NodeViewWrapper = this.createNodeViewWrapper()
const NodeViewContent = this.createNodeViewContent()
const Component = Vue
.extend(component)
.extend({
components: {
NodeViewWrapper,
NodeViewContent,
},
})
const propsData = {
NodeViewWrapper,
NodeViewContent,
editor: this.editor,
node: this.node,
decorations: this.decorations,
selected: false,
extension: this.extension,
getPos: () => this.getPos(),
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
}
const parent = this.editor.view.dom.parentElement
? getComponentFromElement(this.editor.view.dom.parentElement)
: undefined
this.renderer = new VueRenderer(Component, {
parent,
propsData,
})
}
get dom() {
return this.renderer.element
}
get contentDOM() {
if (this.dom.id === this.id) {
return this.dom
}
return this.dom.querySelector(`#${this.id}`)
}
stopEvent(event: Event) {
if (typeof this.options.stopEvent === 'function') {
return this.options.stopEvent(event)
}
const target = (event.target as HTMLElement)
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target)
// ignore all events from child nodes
if (!isInElement) {
return false
}
const { isEditable } = this.editor
const { isDragging } = this
const isDraggable = !!this.node.type.spec.draggable
const isSelectable = NodeSelection.isSelectable(this.node)
const isCopyEvent = event.type === 'copy'
const isPasteEvent = event.type === 'paste'
const isCutEvent = event.type === 'cut'
const isClickEvent = event.type === 'mousedown'
const isDragEvent = event.type.startsWith('drag') || event.type === 'drop'
// ProseMirror tries to drag selectable nodes
// even if `draggable` is set to `false`
// this fix prevents that
if (!isDraggable && isSelectable && isDragEvent) {
event.preventDefault()
}
if (isDraggable && isDragEvent && !isDragging) {
event.preventDefault()
return false
}
// we have to store that dragging started
if (isDraggable && isEditable && !isDragging && isClickEvent) {
const dragHandle = target.closest('[data-drag-handle]')
const isValidDragHandle = dragHandle
&& (this.dom === dragHandle || (this.dom.contains(dragHandle)))
if (isValidDragHandle) {
this.isDragging = true
document.addEventListener('dragend', () => {
this.isDragging = false
}, { once: true })
}
}
// these events are handled by prosemirror
if (
isDragging
|| isCopyEvent
|| isPasteEvent
|| isCutEvent
|| (isClickEvent && isSelectable)
) {
return false
}
return true
}
ignoreMutation(mutation: MutationRecord | { type: 'selection'; target: Element }) {
if (mutation.type === 'selection') {
if (this.node.isLeaf) {
return true
}
return false
}
if (!this.contentDOM) {
return true
}
const contentDOMHasChanged = !this.contentDOM.contains(mutation.target)
|| this.contentDOM === mutation.target
return contentDOMHasChanged
}
destroy() {
this.renderer.destroy()
}
update(node: ProseMirrorNode, decorations: Decoration[]) {
if (typeof this.options.update === 'function') {
return this.options.update(node, decorations)
}
if (node.type !== this.node.type) {
return false
}
if (node === this.node && this.decorations === decorations) {
return true
}
this.node = node
this.decorations = decorations
this.renderer.updateProps({ node, decorations })
return true
}
updateAttributes(attributes: {}) {
if (!this.editor.view.editable) {
return
}
const { state } = this.editor.view
const pos = this.getPos()
const transaction = state.tr.setNodeMarkup(pos, undefined, {
...this.node.attrs,
...attributes,
})
this.editor.view.dispatch(transaction)
}
selectNode() {
this.renderer.updateProps({
selected: true,
})
}
deselectNode() {
this.renderer.updateProps({
selected: false,
})
}
}
export default function VueNodeViewRenderer(component: Vue | VueConstructor, options?: Partial<VueNodeViewRendererOptions>): NodeViewRenderer {
return (props: NodeViewRendererProps) => {
// try to get the parent component
// this is important for vue devtools to show the component hierarchy correctly
// maybe its `undefined` because <editor-content> isnt rendered yet
const parent = props.editor.view.dom.parentElement
? getComponentFromElement(props.editor.view.dom.parentElement)
: undefined
if (!parent) {
return {}
}
return new VueNodeView(component, props, options) as NodeView
}
}

View File

@@ -1,38 +0,0 @@
import Vue from 'vue'
import { VueConstructor } from 'vue/types/umd'
export default class VueRenderer {
vm!: Vue
constructor(component: Vue | VueConstructor, props: any) {
const Component = Vue.extend(component)
this.vm = new Component(props).$mount()
}
get element() {
return this.vm.$el
}
updateProps(props: { [key: string]: any } = {}) {
if (!this.vm.$props) {
return
}
// prevents `Avoid mutating a prop directly` error message
const originalSilent = Vue.config.silent
Vue.config.silent = true
Object
.entries(props)
.forEach(([key, value]) => {
this.vm.$props[key] = value
})
Vue.config.silent = originalSilent
}
destroy() {
this.vm.$destroy()
}
}

View File

@@ -1,36 +0,0 @@
import Vue from 'vue'
export default Vue.extend({
name: 'EditorContent',
props: {
editor: {
default: null,
type: Object,
},
},
watch: {
editor: {
immediate: true,
handler(editor) {
if (editor && editor.options.element) {
this.$nextTick(() => {
this.$el.appendChild(editor.options.element.firstChild)
editor.createNodeViews()
})
}
},
},
},
render(createElement) {
return createElement('div')
},
beforeDestroy() {
this.editor.setOptions({
element: this.$el,
})
},
})

View File

@@ -1,4 +0,0 @@
export * from '@tiptap/core'
export { default as VueRenderer } from './VueRenderer'
export { default as VueNodeViewRenderer } from './VueNodeViewRenderer'
export { default as EditorContent } from './components/EditorContent'