Merge branch 'main' of github.com:ueberdosis/tiptap-next into main

This commit is contained in:
Hans Pagel
2021-03-25 09:48:56 +01:00
46 changed files with 455 additions and 525 deletions

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.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.5...@tiptap/core@2.0.0-beta.6) (2021-03-24)
**Note:** Version bump only for package @tiptap/core
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.4...@tiptap/core@2.0.0-beta.5) (2021-03-18)
**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.5",
"version": "2.0.0-beta.6",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@@ -7,6 +7,7 @@ import getMarkAttributes from './helpers/getMarkAttributes'
import isActive from './helpers/isActive'
import removeElement from './utilities/removeElement'
import getHTMLFromFragment from './helpers/getHTMLFromFragment'
import isNodeEmpty from './helpers/isNodeEmpty'
import createStyleTag from './utilities/createStyleTag'
import CommandManager from './CommandManager'
import ExtensionManager from './ExtensionManager'
@@ -415,11 +416,8 @@ export class Editor extends EventEmitter {
/**
* Check if there is no content.
*/
public isEmpty(): boolean {
const defaultContent = this.state.doc.type.createAndFill()?.toJSON()
const content = this.getJSON()
return JSON.stringify(defaultContent) === JSON.stringify(content)
public get isEmpty(): boolean {
return isNodeEmpty(this.state.doc)
}
/**

View File

@@ -0,0 +1,8 @@
import { Node as ProseMirrorNode } from 'prosemirror-model'
export default function isNodeEmpty(node: ProseMirrorNode): boolean {
const defaultContent = node.type.createAndFill()?.toJSON()
const content = node.toJSON()
return JSON.stringify(defaultContent) === JSON.stringify(content)
}

View File

@@ -18,6 +18,7 @@ export { default as getMarkAttributes } from './helpers/getMarkAttributes'
export { default as isActive } from './helpers/isActive'
export { default as isMarkActive } from './helpers/isMarkActive'
export { default as isNodeActive } from './helpers/isNodeActive'
export { default as isNodeEmpty } from './helpers/isNodeEmpty'
export { default as isNodeSelection } from './helpers/isNodeSelection'
export { default as isTextSelection } from './helpers/isTextSelection'
export { default as findParentNodeClosestToPos } from './helpers/findParentNodeClosestToPos'

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.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-focus@2.0.0-beta.3...@tiptap/extension-focus@2.0.0-beta.4) (2021-03-25)
**Note:** Version bump only for package @tiptap/extension-focus
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-focus@2.0.0-beta.2...@tiptap/extension-focus@2.0.0-beta.3) (2021-03-24)
**Note:** Version bump only for package @tiptap/extension-focus
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-focus@2.0.0-beta.1...@tiptap/extension-focus@2.0.0-beta.2) (2021-03-18)
**Note:** Version bump only for package @tiptap/extension-focus

View File

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

View File

@@ -31,13 +31,15 @@ export const FocusClasses = Extension.create<FocusOptions>({
// Maximum Levels
let maxLevels = 0
if (this.options.mode === 'deepest') {
doc.descendants((node, pos) => {
if (node.isText) {
return
}
const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize)
const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)
if (!isCurrent) {
return false
}
@@ -48,12 +50,14 @@ export const FocusClasses = Extension.create<FocusOptions>({
// Loop through current
let currentLevel = 0
doc.descendants((node, pos) => {
if (node.isText) {
return false
}
const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize)
const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)
if (!isCurrent) {
return false
}
@@ -61,7 +65,7 @@ export const FocusClasses = Extension.create<FocusOptions>({
currentLevel += 1
const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)
|| (this.options.mode === 'shallowest' && currentLevel > 1)
|| (this.options.mode === 'shallowest' && currentLevel > 1)
if (outOfScope) {
return this.options.mode === 'deepest'

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.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.5...@tiptap/extension-mention@2.0.0-beta.6) (2021-03-24)
**Note:** Version bump only for package @tiptap/extension-mention
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.4...@tiptap/extension-mention@2.0.0-beta.5) (2021-03-18)
**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.5",
"version": "2.0.0-beta.6",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -25,6 +25,6 @@
"@tiptap/core": "^2.0.0-beta.1"
},
"dependencies": {
"@tiptap/suggestion": "^2.0.0-beta.5"
"@tiptap/suggestion": "^2.0.0-beta.6"
}
}

View File

@@ -0,0 +1,8 @@
# 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.1 (2021-03-24)
**Note:** Version bump only for package @tiptap/extension-placeholder

View File

@@ -0,0 +1,14 @@
# @tiptap/extension-placeholder
[![Version](https://img.shields.io/npm/v/@tiptap/extension-placeholder.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-placeholder)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-placeholder.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
[![License](https://img.shields.io/npm/l/@tiptap/extension-placeholder.svg)](https://www.npmjs.com/package/@tiptap/extension-placeholder)
[![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

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

View File

@@ -0,0 +1,5 @@
import { Placeholder } from './placeholder'
export * from './placeholder'
export default Placeholder

View File

@@ -0,0 +1,67 @@
import { Extension, isNodeEmpty } from '@tiptap/core'
import { Decoration, DecorationSet } from 'prosemirror-view'
import { Plugin } from 'prosemirror-state'
export interface PlaceholderOptions {
emptyEditorClass: string,
emptyNodeClass: string,
placeholder: string | Function,
showOnlyWhenEditable: boolean,
showOnlyCurrent: boolean,
}
export const Placeholder = Extension.create<PlaceholderOptions>({
name: 'placeholder',
defaultOptions: {
emptyEditorClass: 'is-editor-empty',
emptyNodeClass: 'is-empty',
placeholder: 'Write something …',
showOnlyWhenEditable: true,
showOnlyCurrent: true,
},
addProseMirrorPlugins() {
return [
new Plugin({
props: {
decorations: ({ doc, selection }) => {
const active = this.editor.isEditable || !this.options.showOnlyWhenEditable
const { anchor } = selection
const decorations: Decoration[] = []
if (!active) {
return
}
doc.descendants((node, pos) => {
const hasAnchor = anchor >= pos && anchor <= (pos + node.nodeSize)
const isEmpty = !node.isLeaf && isNodeEmpty(node)
if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
const classes = [this.options.emptyNodeClass]
if (this.editor.isEmpty) {
classes.push(this.options.emptyEditorClass)
}
const decoration = Decoration.node(pos, pos + node.nodeSize, {
class: classes.join(' '),
'data-placeholder': typeof this.options.placeholder === 'function'
? this.options.placeholder(node)
: this.options.placeholder,
})
decorations.push(decoration)
}
return false
})
return DecorationSet.create(doc, decorations)
},
},
}),
]
},
})

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.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-table@2.0.0-beta.2...@tiptap/extension-table@2.0.0-beta.3) (2021-03-24)
**Note:** Version bump only for package @tiptap/extension-table
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-table@2.0.0-beta.1...@tiptap/extension-table@2.0.0-beta.2) (2021-03-18)
**Note:** Version bump only for package @tiptap/extension-table

View File

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

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.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.5...@tiptap/html@2.0.0-beta.6) (2021-03-24)
**Note:** Version bump only for package @tiptap/html
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/html@2.0.0-beta.4...@tiptap/html@2.0.0-beta.5) (2021-03-18)
**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.5",
"version": "2.0.0-beta.6",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -22,7 +22,7 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.5",
"@tiptap/core": "^2.0.0-beta.6",
"hostic-dom": "^0.8.6",
"prosemirror-model": "^1.13.3"
}

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.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.4...@tiptap/react@2.0.0-beta.5) (2021-03-24)
**Note:** Version bump only for package @tiptap/react
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.3...@tiptap/react@2.0.0-beta.4) (2021-03-18)
**Note:** Version bump only for package @tiptap/react

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/react",
"description": "React components for tiptap",
"version": "2.0.0-beta.4",
"version": "2.0.0-beta.5",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -30,6 +30,6 @@
"prosemirror-view": "^1.18.1"
},
"devDependencies": {
"@types/react-dom": "^17.0.1"
"@types/react-dom": "^17.0.3"
}
}

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.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.5...@tiptap/suggestion@2.0.0-beta.6) (2021-03-24)
**Note:** Version bump only for package @tiptap/suggestion
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/suggestion@2.0.0-beta.4...@tiptap/suggestion@2.0.0-beta.5) (2021-03-18)
**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.5",
"version": "2.0.0-beta.6",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -22,7 +22,7 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.5",
"@tiptap/core": "^2.0.0-beta.6",
"prosemirror-model": "^1.13.3",
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.1"

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.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-2@2.0.0-beta.4...@tiptap/vue-2@2.0.0-beta.5) (2021-03-24)
**Note:** Version bump only for package @tiptap/vue-2
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-2@2.0.0-beta.3...@tiptap/vue-2@2.0.0-beta.4) (2021-03-18)
**Note:** Version bump only for package @tiptap/vue-2

View File

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

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.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-3@2.0.0-beta.5...@tiptap/vue-3@2.0.0-beta.6) (2021-03-24)
**Note:** Version bump only for package @tiptap/vue-3
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/vue-3@2.0.0-beta.4...@tiptap/vue-3@2.0.0-beta.5) (2021-03-18)
**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.5",
"version": "2.0.0-beta.6",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

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

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/vue-starter-kit",
"description": "Vue starter kit for tiptap",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.6",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -23,6 +23,6 @@
],
"dependencies": {
"@tiptap/starter-kit": "^2.0.0-beta.4",
"@tiptap/vue": "^2.0.0-beta.2"
"@tiptap/vue": "^2.0.0-beta.3"
}
}

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

View File

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