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

This commit is contained in:
Hans Pagel
2021-09-28 20:24:57 +02:00
32 changed files with 330 additions and 39 deletions

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div id="app"></div>
<script type="module">
import setup from '../../../../setup/react.ts'
import source from '@source'
setup('Examples/CustomDocument', source)
</script>
</body>
</html>

View File

@@ -0,0 +1,42 @@
import React from 'react'
import { useEditor, EditorContent } from '@tiptap/react'
import Document from '@tiptap/extension-document'
import Placeholder from '@tiptap/extension-placeholder'
import StarterKit from '@tiptap/starter-kit'
import './styles.scss'
const CustomDocument = Document.extend({
content: 'heading block*',
})
export default () => {
const editor = useEditor({
extensions: [
CustomDocument,
StarterKit.configure({
document: false,
}),
Placeholder.configure({
placeholder: ({ node }) => {
if (node.type.name === 'heading') {
return 'Whats the title?'
}
return 'Can you add some further context?'
},
}),
],
content: `
<h1>
Itll always have a heading …
</h1>
<p>
… if you pass a custom document. Thats the beauty of having full control over the schema.
</p>
`,
})
return (
<EditorContent editor={editor} />
)
}

View File

@@ -0,0 +1,24 @@
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
/* Placeholder (at the top) */
/*.ProseMirror p.is-editor-empty:first-child::before {
content: attr(data-placeholder);
float: left;
color: #ced4da;
pointer-events: none;
height: 0;
}*/
/* Placeholder (on every new line) */
.ProseMirror .is-empty::before {
content: attr(data-placeholder);
float: left;
color: #ced4da;
pointer-events: none;
height: 0;
}

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div id="app"></div>
<script type="module">
import setup from '../../../../setup/vue.ts'
import source from '@source'
setup('Examples/CustomDocument', source)
</script>
</body>
</html>

View File

@@ -0,0 +1,7 @@
context('/src/Examples/CustomDocument/Vue/', () => {
before(() => {
cy.visit('/src/Examples/CustomDocument/Vue/')
})
// TODO: Write tests
})

View File

@@ -0,0 +1,85 @@
<template>
<editor-content :editor="editor" />
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-3'
import Document from '@tiptap/extension-document'
import Placeholder from '@tiptap/extension-placeholder'
import StarterKit from '@tiptap/starter-kit'
const CustomDocument = Document.extend({
content: 'heading block*',
})
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
CustomDocument,
StarterKit.configure({
document: false,
}),
Placeholder.configure({
placeholder: ({ node }) => {
if (node.type.name === 'heading') {
return 'Whats the title?'
}
return 'Can you add some further context?'
},
}),
],
content: `
<h1>
Itll always have a heading …
</h1>
<p>
… if you pass a custom document. Thats the beauty of having full control over the schema.
</p>
`,
})
},
beforeUnmount() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
/* Placeholder (at the top) */
/*.ProseMirror p.is-editor-empty:first-child::before {
content: attr(data-placeholder);
float: left;
color: #ced4da;
pointer-events: none;
height: 0;
}*/
/* Placeholder (on every new line) */
.ProseMirror .is-empty::before {
content: attr(data-placeholder);
float: left;
color: #ced4da;
pointer-events: none;
height: 0;
}
</style>

View File

@@ -0,0 +1,3 @@
# Custom Document
<tiptap-demo name="Examples/CustomDocument"></tiptap-demo>

View File

@@ -84,6 +84,8 @@
link: /examples/suggestions
- title: Minimal setup
link: /examples/minimal
- title: Force a title
link: /examples/custom-document
- title: A clever editor
link: /examples/savvy
- title: Interactivity

View File

@@ -3,6 +3,18 @@
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.113](https://github.com/ueberdosis/tiptap/compare/@tiptap/core@2.0.0-beta.112...@tiptap/core@2.0.0-beta.113) (2021-09-27)
### Bug Fixes
* add support for CellSelection in isActive helper, fix [#1947](https://github.com/ueberdosis/tiptap/issues/1947) ([b42e442](https://github.com/ueberdosis/tiptap/commit/b42e442a5af167f78edb5252dd8dbdcb8e0a96ed))
* handle backspace also on shift ([32ae386](https://github.com/ueberdosis/tiptap/commit/32ae3868eaf42bb3f5d016038b57337ff64c21b4))
# [2.0.0-beta.112](https://github.com/ueberdosis/tiptap/compare/@tiptap/core@2.0.0-beta.111...@tiptap/core@2.0.0-beta.112) (2021-09-23)
**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.112",
"version": "2.0.0-beta.113",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@@ -25,10 +25,11 @@ export const Keymap = Extension.create({
() => commands.splitBlock(),
]),
'Mod-Enter': () => this.editor.commands.exitCode(),
Backspace: () => handleBackspace(),
'Mod-Backspace': () => handleBackspace(),
Delete: () => handleDelete(),
'Mod-Delete': () => handleDelete(),
Backspace: handleBackspace,
'Mod-Backspace': handleBackspace,
'Shift-Backspace': handleBackspace,
Delete: handleDelete,
'Mod-Delete': handleDelete,
'Mod-a': () => this.editor.commands.selectAll(),
}
},

View File

@@ -9,7 +9,7 @@ export default function isMarkActive(
typeOrName: MarkType | string | null,
attributes: Record<string, any> = {},
): boolean {
const { from, to, empty } = state.selection
const { empty, ranges } = state.selection
const type = typeOrName
? getMarkType(typeOrName, state.schema)
: null
@@ -29,22 +29,27 @@ export default function isMarkActive(
let selectionRange = 0
const markRanges: MarkRange[] = []
state.doc.nodesBetween(from, to, (node, pos) => {
if (!node.marks.length) {
return
}
ranges.forEach(({ $from, $to }) => {
const from = $from.pos
const to = $to.pos
const relativeFrom = Math.max(from, pos)
const relativeTo = Math.min(to, pos + node.nodeSize)
const range = relativeTo - relativeFrom
state.doc.nodesBetween(from, to, (node, pos) => {
if (!node.isText && !node.marks.length) {
return
}
selectionRange += range
const relativeFrom = Math.max(from, pos)
const relativeTo = Math.min(to, pos + node.nodeSize)
const range = relativeTo - relativeFrom
markRanges.push(...node.marks.map(mark => ({
mark,
from: relativeFrom,
to: relativeTo,
})))
selectionRange += range
markRanges.push(...node.marks.map(mark => ({
mark,
from: relativeFrom,
to: relativeTo,
})))
})
})
if (selectionRange === 0) {

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.36](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bubble-menu@2.0.0-beta.35...@tiptap/extension-bubble-menu@2.0.0-beta.36) (2021-09-27)
**Note:** Version bump only for package @tiptap/extension-bubble-menu
# [2.0.0-beta.35](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-bubble-menu@2.0.0-beta.34...@tiptap/extension-bubble-menu@2.0.0-beta.35) (2021-09-22)

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-bubble-menu",
"description": "bubble-menu extension for tiptap",
"version": "2.0.0-beta.35",
"version": "2.0.0-beta.36",
"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.30](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-floating-menu@2.0.0-beta.29...@tiptap/extension-floating-menu@2.0.0-beta.30) (2021-09-27)
**Note:** Version bump only for package @tiptap/extension-floating-menu
# [2.0.0-beta.29](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-floating-menu@2.0.0-beta.28...@tiptap/extension-floating-menu@2.0.0-beta.29) (2021-09-22)

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-floating-menu",
"description": "floating-menu extension for tiptap",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.30",
"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.21](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-gapcursor@2.0.0-beta.20...@tiptap/extension-gapcursor@2.0.0-beta.21) (2021-09-27)
**Note:** Version bump only for package @tiptap/extension-gapcursor
# [2.0.0-beta.20](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-gapcursor@2.0.0-beta.19...@tiptap/extension-gapcursor@2.0.0-beta.20) (2021-09-21)
**Note:** Version bump only for package @tiptap/extension-gapcursor

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-gapcursor",
"description": "gapcursor extension for tiptap",
"version": "2.0.0-beta.20",
"version": "2.0.0-beta.21",
"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.18](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-hard-break@2.0.0-beta.17...@tiptap/extension-hard-break@2.0.0-beta.18) (2021-09-27)
**Note:** Version bump only for package @tiptap/extension-hard-break
# [2.0.0-beta.17](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-hard-break@2.0.0-beta.16...@tiptap/extension-hard-break@2.0.0-beta.17) (2021-09-23)

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-hard-break",
"description": "hard break extension for tiptap",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.18",
"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.18](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-highlight@2.0.0-beta.17...@tiptap/extension-highlight@2.0.0-beta.18) (2021-09-27)
**Note:** Version bump only for package @tiptap/extension-highlight
# [2.0.0-beta.17](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-highlight@2.0.0-beta.16...@tiptap/extension-highlight@2.0.0-beta.17) (2021-09-21)

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-highlight",
"description": "highlight extension for tiptap",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.18",
"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.112](https://github.com/ueberdosis/tiptap/compare/@tiptap/html@2.0.0-beta.111...@tiptap/html@2.0.0-beta.112) (2021-09-27)
**Note:** Version bump only for package @tiptap/html
# [2.0.0-beta.111](https://github.com/ueberdosis/tiptap/compare/@tiptap/html@2.0.0-beta.110...@tiptap/html@2.0.0-beta.111) (2021-09-23)
**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.111",
"version": "2.0.0-beta.112",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -21,7 +21,7 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.112",
"@tiptap/core": "^2.0.0-beta.113",
"hostic-dom": "^0.8.7",
"prosemirror-model": "^1.14.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.73](https://github.com/ueberdosis/tiptap/compare/@tiptap/react@2.0.0-beta.72...@tiptap/react@2.0.0-beta.73) (2021-09-27)
**Note:** Version bump only for package @tiptap/react
# [2.0.0-beta.72](https://github.com/ueberdosis/tiptap/compare/@tiptap/react@2.0.0-beta.71...@tiptap/react@2.0.0-beta.72) (2021-09-23)
**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.72",
"version": "2.0.0-beta.73",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -32,8 +32,8 @@
"react-dom": "^17.0.0"
},
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.0.0-beta.35",
"@tiptap/extension-floating-menu": "^2.0.0-beta.29",
"@tiptap/extension-bubble-menu": "^2.0.0-beta.36",
"@tiptap/extension-floating-menu": "^2.0.0-beta.30",
"prosemirror-view": "^1.20.1"
},
"repository": {

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.112](https://github.com/ueberdosis/tiptap/compare/@tiptap/starter-kit@2.0.0-beta.111...@tiptap/starter-kit@2.0.0-beta.112) (2021-09-27)
**Note:** Version bump only for package @tiptap/starter-kit
# [2.0.0-beta.111](https://github.com/ueberdosis/tiptap/compare/@tiptap/starter-kit@2.0.0-beta.110...@tiptap/starter-kit@2.0.0-beta.111) (2021-09-23)
**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.111",
"version": "2.0.0-beta.112",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -21,7 +21,7 @@
"dist"
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.112",
"@tiptap/core": "^2.0.0-beta.113",
"@tiptap/extension-blockquote": "^2.0.0-beta.15",
"@tiptap/extension-bold": "^2.0.0-beta.15",
"@tiptap/extension-bullet-list": "^2.0.0-beta.15",
@@ -29,8 +29,8 @@
"@tiptap/extension-code-block": "^2.0.0-beta.18",
"@tiptap/extension-document": "^2.0.0-beta.13",
"@tiptap/extension-dropcursor": "^2.0.0-beta.19",
"@tiptap/extension-gapcursor": "^2.0.0-beta.20",
"@tiptap/extension-hard-break": "^2.0.0-beta.17",
"@tiptap/extension-gapcursor": "^2.0.0-beta.21",
"@tiptap/extension-hard-break": "^2.0.0-beta.18",
"@tiptap/extension-heading": "^2.0.0-beta.15",
"@tiptap/extension-history": "^2.0.0-beta.16",
"@tiptap/extension-horizontal-rule": "^2.0.0-beta.19",

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.54](https://github.com/ueberdosis/tiptap/compare/@tiptap/vue-2@2.0.0-beta.53...@tiptap/vue-2@2.0.0-beta.54) (2021-09-27)
**Note:** Version bump only for package @tiptap/vue-2
# [2.0.0-beta.53](https://github.com/ueberdosis/tiptap/compare/@tiptap/vue-2@2.0.0-beta.52...@tiptap/vue-2@2.0.0-beta.53) (2021-09-22)
**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.53",
"version": "2.0.0-beta.54",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -28,8 +28,8 @@
"vue": "^2.6.0"
},
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.0.0-beta.35",
"@tiptap/extension-floating-menu": "^2.0.0-beta.29",
"@tiptap/extension-bubble-menu": "^2.0.0-beta.36",
"@tiptap/extension-floating-menu": "^2.0.0-beta.30",
"prosemirror-view": "^1.20.1"
},
"repository": {

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.64](https://github.com/ueberdosis/tiptap/compare/@tiptap/vue-3@2.0.0-beta.63...@tiptap/vue-3@2.0.0-beta.64) (2021-09-27)
**Note:** Version bump only for package @tiptap/vue-3
# [2.0.0-beta.63](https://github.com/ueberdosis/tiptap/compare/@tiptap/vue-3@2.0.0-beta.62...@tiptap/vue-3@2.0.0-beta.63) (2021-09-23)

View File

@@ -1,7 +1,7 @@
{
"name": "@tiptap/vue-3",
"description": "Vue components for tiptap",
"version": "2.0.0-beta.63",
"version": "2.0.0-beta.64",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@@ -28,8 +28,8 @@
"vue": "^3.0.0"
},
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.0.0-beta.35",
"@tiptap/extension-floating-menu": "^2.0.0-beta.29",
"@tiptap/extension-bubble-menu": "^2.0.0-beta.36",
"@tiptap/extension-floating-menu": "^2.0.0-beta.30",
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.20.1"
},