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

This commit is contained in:
Hans Pagel 2021-04-16 19:15:59 +02:00
commit 13da47f31b
144 changed files with 1861 additions and 813 deletions

View File

@ -0,0 +1,43 @@
<template>
<g-link :class="`banner-message banner-message--${color}`" :to="to">
<slot />
</g-link>
</template>
<script>
export default {
props: {
to: {
type: String,
required: true,
},
color: {
type: String,
default: 'black',
},
},
}
</script>
<style lang="scss" scoped>
.banner-message {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
padding: 0.65rem 1rem;
font-size: 0.85rem;
font-weight: 500;
&--black {
background-color: $colorBlack;
color: $colorWhite;
}
&--yellow {
background-color: $colorYellow;
color: $colorBlack;
}
}
</style>

View File

@ -17,7 +17,6 @@
<script>
import { NodeViewWrapper, NodeViewContent, nodeViewProps } from '@tiptap/vue-2'
import lowlight from 'lowlight/lib/core'
export default {
components: {
@ -29,7 +28,7 @@ export default {
data() {
return {
languages: lowlight.listLanguages(),
languages: this.extension.options.lowlight.listLanguages(),
}
},

View File

@ -70,7 +70,7 @@ export default {
this.editor = new Editor({
extensions: [
...defaultExtensions().filter(extension => extension.config.name !== 'history'),
...defaultExtensions().filter(extension => extension.name !== 'history'),
Highlight,
TaskList,
TaskItem,

View File

@ -24,8 +24,8 @@ export default () => {
})
return (
<div style={{ position: 'relative' }}>
{editor && <BubbleMenu className="bubble-menu" editor={editor}>
<>
{editor && <BubbleMenu className="bubble-menu" tippyOptions={{ duration: 100 }} editor={editor}>
<button
onClick={() => editor.chain().focus().toggleBold().run()}
className={editor.isActive('bold') ? 'is-active' : ''}
@ -46,7 +46,7 @@ export default () => {
</button>
</BubbleMenu>}
{editor && <FloatingMenu className="floating-menu" editor={editor}>
{editor && <FloatingMenu className="floating-menu" tippyOptions={{ duration: 100 }} editor={editor}>
<button
onClick={() => editor.chain().focus().toggleHeading({ level: 1 }).run()}
className={editor.isActive('heading', { level: 1 }) ? 'is-active' : ''}
@ -68,6 +68,6 @@ export default () => {
</FloatingMenu>}
<EditorContent editor={editor} />
</div>
</>
)
}

View File

@ -14,7 +14,6 @@
background-color: #0D0D0D;
padding: 0.2rem;
border-radius: 0.5rem;
transition: visibility 0.1s ease, opacity 0.1s ease;
button {
border: none;
@ -37,9 +36,6 @@
background-color: #0D0D0D10;
padding: 0.2rem;
border-radius: 0.5rem;
margin-top: -0.25rem;
margin-left: 0.25rem;
transition: visibility 0.1s ease, opacity 0.1s ease;
button {
border: none;

View File

@ -1,6 +1,11 @@
<template>
<div style="position: relative">
<bubble-menu class="bubble-menu" :editor="editor" v-if="editor">
<div>
<bubble-menu
class="bubble-menu"
:tippy-options="{ duration: 100 }"
:editor="editor"
v-if="editor"
>
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
Bold
</button>
@ -12,7 +17,12 @@
</button>
</bubble-menu>
<floating-menu class="floating-menu" :editor="editor" v-if="editor">
<floating-menu
class="floating-menu"
:tippy-options="{ duration: 100 }"
:editor="editor"
v-if="editor"
>
<button @click="editor.chain().focus().toggleHeading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
H1
</button>
@ -95,7 +105,6 @@ export default {
background-color: #0D0D0D;
padding: 0.2rem;
border-radius: 0.5rem;
transition: visibility 0.1s ease, opacity 0.1s ease;
button {
border: none;
@ -118,9 +127,6 @@ export default {
background-color: #0D0D0D10;
padding: 0.2rem;
border-radius: 0.5rem;
margin-top: -0.25rem;
margin-left: 0.25rem;
transition: visibility 0.1s ease, opacity 0.1s ease;
button {
border: none;

View File

@ -16,7 +16,7 @@ export default () => {
})
return (
<div style={{ position: 'relative' }}>
<>
{editor && <BubbleMenu editor={editor}>
<button
onClick={() => editor.chain().focus().toggleBold().run()}
@ -38,6 +38,6 @@ export default () => {
</button>
</BubbleMenu>}
<EditorContent editor={editor} />
</div>
</>
)
}

View File

@ -1,5 +1,5 @@
<template>
<div style="position: relative">
<div>
<bubble-menu :editor="editor" v-if="editor">
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
bold

View File

@ -17,7 +17,7 @@ export default () => {
})
return (
<div style={{ position: 'relative' }}>
<>
{editor && <FloatingMenu editor={editor}>
<button
onClick={() => editor.chain().focus().toggleHeading({ level: 1 }).run()}
@ -39,6 +39,6 @@ export default () => {
</button>
</FloatingMenu>}
<EditorContent editor={editor} />
</div>
</>
)
}

View File

@ -1,5 +1,5 @@
<template>
<div style="position: relative">
<div>
<floating-menu :editor="editor" v-if="editor">
<button @click="editor.chain().focus().toggleHeading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
h1

View File

@ -28,9 +28,6 @@ const editor = new Editor({
onBlur({ editor, event }) {
// The editor isnt focused anymore.
},
onResize({ editor, event }) {
// The editor view has resized.
},
onDestroy() {
// The editor is being destroyed.
},
@ -66,10 +63,6 @@ editor.on('blur', ({ editor, event }) => {
// The editor isnt focused anymore.
}
editor.on('resize', ({ editor, event }) => {
// The editor view has resized.
}
editor.on('destroy', () => {
// The editor is being destroyed.
}
@ -115,9 +108,6 @@ const CustomExtension = Extension.create({
onBlur({ editor, event }) {
// The editor isnt focused anymore.
},
onResize({ editor, event }) {
// The editor view has resized.
},
onDestroy() {
// The editor is being destroyed.
},

View File

@ -15,10 +15,10 @@ yarn add @tiptap/extension-bubble-menu
```
## Settings
| Option | Type | Default | Description |
| ------------ | ------------- | ------- | -------------------------------------------------------------------- |
| element | `HTMLElement` | `null` | The DOM element that contains your menu. |
| keepInBounds | `Boolean` | `true` | When enabled, its rendered inside the bounding box of the document. |
| Option | Type | Default | Description |
| ------------ | ------------- | ------- | ----------------------------------------------------------------------- |
| element | `HTMLElement` | `null` | The DOM element that contains your menu. |
| tippyOptions | `Object` | `{}` | [Options for tippy.js](https://atomiks.github.io/tippyjs/v6/all-props/) |
## Source code
[packages/extension-bubble-menu/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-bubble-menu/)

View File

@ -13,9 +13,10 @@ yarn add @tiptap/extension-floating-menu
```
## Settings
| Option | Type | Default | Description |
| ------------ | ------------- | --------- | ----------------------------- |
| element | `HTMLElement` | `null` | The DOM element of your menu. |
| Option | Type | Default | Description |
| ------------ | ------------- | ------- | ----------------------------------------------------------------------- |
| element | `HTMLElement` | `null` | The DOM element of your menu. |
| tippyOptions | `Object` | `{}` | [Options for tippy.js](https://atomiks.github.io/tippyjs/v6/all-props/) |
## Source code
[packages/extension-floating-menu/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-floating-menu/)

View File

@ -127,7 +127,7 @@ import { Editor, defaultExtensions } from '@tiptap/starter-kit'
new Editor({
extensions: [
...defaultExtensions().filter(extension => extension.config.name !== 'history'),
...defaultExtensions().filter(extension => extension.name !== 'history'),
],
})
```

View File

@ -1,6 +1,14 @@
<template>
<div class="app">
<div class="app__navigation">
<banner-message
to="https://www.tiptap.dev/"
v-if="$route.name === 'home'"
color="black"
>
Youre browsing the documentation for v2.x. Click here for v1.x documentation
</banner-message>
<div class="app__top-bar">
<g-link class="app__logo" to="/">
<img src="~@/assets/images/logo.svg">
@ -54,7 +62,7 @@
</g-link>
</portal>
<portal :to="sidebarPortal" v-if="showSidebar">
<portal :to="sidebarPortal">
<nav class="app__sidebar-menu">
<div class="app__link-group" v-for="(linkGroup, i) in linkGroups" :key="i">
<template v-if="linkGroup.link && !linkGroup.items">
@ -124,6 +132,7 @@ query {
import linkGroups from '@/links.yaml'
import Icon from '@/components/Icon'
import PageFooter from '@/components/PageFooter'
import BannerMessage from '@/components/BannerMessage'
// import GithubButton from 'vue-github-button'
export default {
@ -137,6 +146,7 @@ export default {
components: {
Icon,
PageFooter,
BannerMessage,
// GithubButton,
},

View File

@ -26,10 +26,10 @@
},
"devDependencies": {
"@atomico/rollup-plugin-sizes": "^1.1.4",
"@babel/core": "^7.13.14",
"@babel/core": "^7.13.15",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.0",
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@babel/preset-env": "^7.13.12",
"@babel/preset-env": "^7.13.15",
"@babel/preset-react": "^7.13.13",
"@lerna/batch-packages": "^3.16.0",
"@lerna/filter-packages": "^3.18.0",
@ -54,7 +54,7 @@
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-vue": "5",
"typescript": "^4.2.2",
"typescript": "^4.2.4",
"vue": "^2.6.12"
}
}

View File

@ -3,6 +3,37 @@
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.32](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.31...@tiptap/core@2.0.0-beta.32) (2021-04-16)
### Features
* add coordsAtPos and posToClientRect helper methods ([8dab614](https://github.com/ueberdosis/tiptap-next/commit/8dab6144a661e4c90f33d9d2f300882009eadd46))
* remove resize event handler ([9f64015](https://github.com/ueberdosis/tiptap-next/commit/9f64015157a83032d0d80bc0353efb529b56a342))
# [2.0.0-beta.31](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.30...@tiptap/core@2.0.0-beta.31) (2021-04-15)
### Bug Fixes
* fix type for emitUpdate, fix [#276](https://github.com/ueberdosis/tiptap-next/issues/276) ([4137e00](https://github.com/ueberdosis/tiptap-next/commit/4137e00d987c152b883022525056df94ad033be7))
# [2.0.0-beta.30](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.29...@tiptap/core@2.0.0-beta.30) (2021-04-15)
**Note:** Version bump only for package @tiptap/core
# [2.0.0-beta.29](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.28...@tiptap/core@2.0.0-beta.29) (2021-04-12)

View File

@ -1,7 +1,7 @@
{
"name": "@tiptap/core",
"description": "headless rich text editor",
"version": "2.0.0-beta.29",
"version": "2.0.0-beta.32",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

View File

@ -44,8 +44,6 @@ export class Editor extends EventEmitter {
public isFocused = false
private resizeObserver!: ResizeObserver
public options: EditorOptions = {
element: document.createElement('div'),
content: '',
@ -64,7 +62,6 @@ export class Editor extends EventEmitter {
onTransaction: () => null,
onFocus: () => null,
onBlur: () => null,
onResize: () => null,
onDestroy: () => null,
}
@ -89,13 +86,6 @@ export class Editor extends EventEmitter {
window.setTimeout(() => {
this.commands.focus(this.options.autofocus)
this.emit('create', { editor: this })
if (window.ResizeObserver) {
this.resizeObserver = new ResizeObserver(() => {
this.emit('resize', { editor: this })
})
this.resizeObserver.observe(this.view.dom)
}
}, 0)
}
@ -416,8 +406,6 @@ export class Editor extends EventEmitter {
* Destroy the editor.
*/
public destroy(): void {
this.resizeObserver?.unobserve(this.view.dom)
this.emit('destroy')
if (this.view) {

View File

@ -3,6 +3,7 @@ import { Command as ProseMirrorCommand } from 'prosemirror-commands'
import { InputRule } from 'prosemirror-inputrules'
import { Editor } from './Editor'
import { Node } from './Node'
import { Mark } from './Mark'
import mergeDeep from './utilities/mergeDeep'
import { GlobalAttributes, RawCommands, ParentConfig } from './types'
import { ExtensionConfig } from '.'
@ -31,7 +32,7 @@ declare module '@tiptap/core' {
*/
addGlobalAttributes?: (this: {
options: Options,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['addGlobalAttributes'],
}) => GlobalAttributes | {},
/**
@ -40,7 +41,7 @@ declare module '@tiptap/core' {
addCommands?: (this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['addCommands'],
}) => Partial<RawCommands>,
/**
@ -49,7 +50,7 @@ declare module '@tiptap/core' {
addKeyboardShortcuts?: (this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['addKeyboardShortcuts'],
}) => {
[key: string]: ProseMirrorCommand,
},
@ -60,7 +61,7 @@ declare module '@tiptap/core' {
addInputRules?: (this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['addInputRules'],
}) => InputRule[],
/**
@ -69,7 +70,7 @@ declare module '@tiptap/core' {
addPasteRules?: (this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['addPasteRules'],
}) => Plugin[],
/**
@ -78,7 +79,7 @@ declare module '@tiptap/core' {
addProseMirrorPlugins?: (this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['addProseMirrorPlugins'],
}) => Plugin[],
/**
@ -87,7 +88,7 @@ declare module '@tiptap/core' {
extendNodeSchema?: ((
this: {
options: Options,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['extendNodeSchema'],
},
extension: Node,
) => {
@ -100,9 +101,9 @@ declare module '@tiptap/core' {
extendMarkSchema?: ((
this: {
options: Options,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['extendMarkSchema'],
},
extension: Node,
extension: Mark,
) => {
[key: string]: any,
}) | null,
@ -113,7 +114,7 @@ declare module '@tiptap/core' {
onBeforeCreate?: ((this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onBeforeCreate'],
}) => void) | null,
/**
@ -122,7 +123,7 @@ declare module '@tiptap/core' {
onCreate?: ((this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onCreate'],
}) => void) | null,
/**
@ -131,7 +132,7 @@ declare module '@tiptap/core' {
onUpdate?: ((this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onUpdate'],
}) => void) | null,
/**
@ -140,7 +141,7 @@ declare module '@tiptap/core' {
onSelectionUpdate?: ((this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onSelectionUpdate'],
}) => void) | null,
/**
@ -150,7 +151,7 @@ declare module '@tiptap/core' {
this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onTransaction'],
},
props: {
transaction: Transaction,
@ -164,7 +165,7 @@ declare module '@tiptap/core' {
this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onFocus'],
},
props: {
event: FocusEvent,
@ -178,7 +179,7 @@ declare module '@tiptap/core' {
this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onBlur'],
},
props: {
event: FocusEvent,
@ -191,7 +192,7 @@ declare module '@tiptap/core' {
onDestroy?: ((this: {
options: Options,
editor: Editor,
parentConfig: ParentConfig<ExtensionConfig<Options>>,
parent: ParentConfig<ExtensionConfig<Options>>['onDestroy'],
}) => void) | null,
}
}
@ -199,48 +200,55 @@ declare module '@tiptap/core' {
export class Extension<Options = any> {
type = 'extension'
name = 'extension'
parent: Extension | null = null
child: Extension | null = null
options: Options
config: ExtensionConfig = {
name: 'extension',
name: this.name,
priority: 100,
defaultOptions: {},
}
parentConfig: Partial<ExtensionConfig> = {}
options!: Options
constructor(config: ExtensionConfig<Options>) {
constructor(config: Partial<ExtensionConfig<Options>> = {}) {
this.config = {
...this.config,
...config,
}
this.name = this.config.name
this.options = this.config.defaultOptions
}
static create<O>(config: ExtensionConfig<O>) {
static create<O>(config: Partial<ExtensionConfig<O>> = {}) {
return new Extension<O>(config)
}
configure(options: Partial<Options> = {}) {
return Extension
.create<Options>(this.config as ExtensionConfig<Options>)
.#configure(options)
}
#configure = (options: Partial<Options>) => {
this.options = mergeDeep(this.config.defaultOptions, options) as Options
this.options = mergeDeep(this.options, options) as Options
return this
}
extend<ExtendedOptions = Options>(extendedConfig: Partial<ExtensionConfig<ExtendedOptions>>) {
const extension = new Extension<ExtendedOptions>({
...this.config,
...extendedConfig,
} as ExtensionConfig<ExtendedOptions>)
extend<ExtendedOptions = Options>(extendedConfig: Partial<ExtensionConfig<ExtendedOptions>> = {}) {
const extension = new Extension<ExtendedOptions>(extendedConfig)
extension.parentConfig = this.config
extension.parent = this
this.child = extension
extension.name = extendedConfig.name
? extendedConfig.name
: this.name
extension.options = {
...extension.parent.options,
...extension.options,
}
return extension
}

View File

@ -4,8 +4,8 @@ import { inputRules as inputRulesPlugin } from 'prosemirror-inputrules'
import { EditorView, Decoration } from 'prosemirror-view'
import { Plugin } from 'prosemirror-state'
import { Editor } from './Editor'
import { Extensions, NodeViewRenderer, RawCommands } from './types'
import createExtensionContext from './helpers/createExtensionContext'
import { Extensions, RawCommands, AnyConfig } from './types'
import getExtensionField from './helpers/getExtensionField'
import getSchema from './helpers/getSchema'
import getSchemaTypeByName from './helpers/getSchemaTypeByName'
import getNodeType from './helpers/getNodeType'
@ -13,6 +13,7 @@ import splitExtensions from './helpers/splitExtensions'
import getAttributesFromExtensions from './helpers/getAttributesFromExtensions'
import getRenderedAttributes from './helpers/getRenderedAttributes'
import callOrReturn from './utilities/callOrReturn'
import { NodeConfig } from '.'
export default class ExtensionManager {
@ -30,50 +31,98 @@ export default class ExtensionManager {
this.schema = getSchema(this.extensions)
this.extensions.forEach(extension => {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
})
type: getSchemaTypeByName(extension.name, this.schema),
}
if (extension.type === 'mark') {
const keepOnSplit = callOrReturn(extension.config.keepOnSplit, context) ?? true
const keepOnSplit = callOrReturn(getExtensionField(extension, 'keepOnSplit', context)) ?? true
if (keepOnSplit) {
this.splittableMarks.push(extension.config.name)
this.splittableMarks.push(extension.name)
}
}
if (typeof extension.config.onBeforeCreate === 'function') {
this.editor.on('beforeCreate', extension.config.onBeforeCreate.bind(context))
const onBeforeCreate = getExtensionField<AnyConfig['onBeforeCreate']>(
extension,
'onBeforeCreate',
context,
)
if (onBeforeCreate) {
this.editor.on('beforeCreate', onBeforeCreate)
}
if (typeof extension.config.onCreate === 'function') {
this.editor.on('create', extension.config.onCreate.bind(context))
const onCreate = getExtensionField<AnyConfig['onCreate']>(
extension,
'onCreate',
context,
)
if (onCreate) {
this.editor.on('create', onCreate)
}
if (typeof extension.config.onUpdate === 'function') {
this.editor.on('update', extension.config.onUpdate.bind(context))
const onUpdate = getExtensionField<AnyConfig['onUpdate']>(
extension,
'onUpdate',
context,
)
if (onUpdate) {
this.editor.on('update', onUpdate)
}
if (typeof extension.config.onSelectionUpdate === 'function') {
this.editor.on('selectionUpdate', extension.config.onSelectionUpdate.bind(context))
const onSelectionUpdate = getExtensionField<AnyConfig['onSelectionUpdate']>(
extension,
'onSelectionUpdate',
context,
)
if (onSelectionUpdate) {
this.editor.on('selectionUpdate', onSelectionUpdate)
}
if (typeof extension.config.onTransaction === 'function') {
this.editor.on('transaction', extension.config.onTransaction.bind(context))
const onTransaction = getExtensionField<AnyConfig['onTransaction']>(
extension,
'onTransaction',
context,
)
if (onTransaction) {
this.editor.on('transaction', onTransaction)
}
if (typeof extension.config.onFocus === 'function') {
this.editor.on('focus', extension.config.onFocus.bind(context))
const onFocus = getExtensionField<AnyConfig['onFocus']>(
extension,
'onFocus',
context,
)
if (onFocus) {
this.editor.on('focus', onFocus)
}
if (typeof extension.config.onBlur === 'function') {
this.editor.on('blur', extension.config.onBlur.bind(context))
const onBlur = getExtensionField<AnyConfig['onBlur']>(
extension,
'onBlur',
context,
)
if (onBlur) {
this.editor.on('blur', onBlur)
}
if (typeof extension.config.onDestroy === 'function') {
this.editor.on('destroy', extension.config.onDestroy.bind(context))
const onDestroy = getExtensionField<AnyConfig['onDestroy']>(
extension,
'onDestroy',
context,
)
if (onDestroy) {
this.editor.on('destroy', onDestroy)
}
})
}
@ -82,11 +131,14 @@ export default class ExtensionManager {
const defaultPriority = 100
return extensions.sort((a, b) => {
if ((a.config.priority || defaultPriority) > (b.config.priority || defaultPriority)) {
const priorityA = getExtensionField<AnyConfig['priority']>(a, 'priority') || defaultPriority
const priorityB = getExtensionField<AnyConfig['priority']>(b, 'priority') || defaultPriority
if (priorityA > priorityB) {
return -1
}
if ((a.config.priority || defaultPriority) < (b.config.priority || defaultPriority)) {
if (priorityA < priorityB) {
return 1
}
@ -96,19 +148,25 @@ export default class ExtensionManager {
get commands(): RawCommands {
return this.extensions.reduce((commands, extension) => {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
})
type: getSchemaTypeByName(extension.name, this.schema),
}
if (!extension.config.addCommands) {
const addCommands = getExtensionField<AnyConfig['addCommands']>(
extension,
'addCommands',
context,
)
if (!addCommands) {
return commands
}
return {
...commands,
...extension.config.addCommands.bind(context)(),
...addCommands(),
}
}, {} as RawCommands)
}
@ -117,22 +175,34 @@ export default class ExtensionManager {
return [...this.extensions]
.reverse()
.map(extension => {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
})
type: getSchemaTypeByName(extension.name, this.schema),
}
const plugins: Plugin[] = []
if (extension.config.addKeyboardShortcuts) {
const keyMapPlugin = keymap(extension.config.addKeyboardShortcuts.bind(context)())
const addKeyboardShortcuts = getExtensionField<AnyConfig['addKeyboardShortcuts']>(
extension,
'addKeyboardShortcuts',
context,
)
if (addKeyboardShortcuts) {
const keyMapPlugin = keymap(addKeyboardShortcuts())
plugins.push(keyMapPlugin)
}
if (this.editor.options.enableInputRules && extension.config.addInputRules) {
const inputRules = extension.config.addInputRules.bind(context)()
const addInputRules = getExtensionField<AnyConfig['addInputRules']>(
extension,
'addInputRules',
context,
)
if (this.editor.options.enableInputRules && addInputRules) {
const inputRules = addInputRules()
const inputRulePlugins = inputRules.length
? [inputRulesPlugin({ rules: inputRules })]
: []
@ -140,14 +210,26 @@ export default class ExtensionManager {
plugins.push(...inputRulePlugins)
}
if (this.editor.options.enablePasteRules && extension.config.addPasteRules) {
const pasteRulePlugins = extension.config.addPasteRules.bind(context)()
const addPasteRules = getExtensionField<AnyConfig['addPasteRules']>(
extension,
'addPasteRules',
context,
)
if (this.editor.options.enablePasteRules && addPasteRules) {
const pasteRulePlugins = addPasteRules()
plugins.push(...pasteRulePlugins)
}
if (extension.config.addProseMirrorPlugins) {
const proseMirrorPlugins = extension.config.addProseMirrorPlugins.bind(context)()
const addProseMirrorPlugins = getExtensionField<AnyConfig['addProseMirrorPlugins']>(
extension,
'addProseMirrorPlugins',
context,
)
if (addProseMirrorPlugins) {
const proseMirrorPlugins = addProseMirrorPlugins()
plugins.push(...proseMirrorPlugins)
}
@ -166,15 +248,23 @@ export default class ExtensionManager {
const { nodeExtensions } = splitExtensions(this.extensions)
return Object.fromEntries(nodeExtensions
.filter(extension => !!extension.config.addNodeView)
.filter(extension => !!getExtensionField(extension, 'addNodeView'))
.map(extension => {
const extensionAttributes = this.attributes.filter(attribute => attribute.type === extension.config.name)
const context = createExtensionContext(extension, {
const extensionAttributes = this.attributes.filter(attribute => attribute.type === extension.name)
const context = {
options: extension.options,
editor,
type: getNodeType(extension.config.name, this.schema),
})
const renderer = extension.config.addNodeView?.call(context) as NodeViewRenderer
type: getNodeType(extension.name, this.schema),
}
const addNodeView = getExtensionField<NodeConfig['addNodeView']>(
extension,
'addNodeView',
context,
)
if (!addNodeView) {
return []
}
const nodeview = (
node: ProsemirrorNode,
@ -184,7 +274,7 @@ export default class ExtensionManager {
) => {
const HTMLAttributes = getRenderedAttributes(node, extensionAttributes)
return renderer({
return addNodeView()({
editor,
node,
getPos,
@ -194,7 +284,7 @@ export default class ExtensionManager {
})
}
return [extension.config.name, nodeview]
return [extension.name, nodeview]
}))
}
@ -203,17 +293,23 @@ export default class ExtensionManager {
const { nodeExtensions } = splitExtensions(this.extensions)
return Object.fromEntries(nodeExtensions
.filter(extension => !!extension.config.renderText)
.filter(extension => !!getExtensionField(extension, 'renderText'))
.map(extension => {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
editor,
type: getNodeType(extension.config.name, this.schema),
})
type: getNodeType(extension.name, this.schema),
}
const textSerializer = (props: { node: ProsemirrorNode }) => extension.config.renderText?.call(context, props)
const renderText = getExtensionField<NodeConfig['renderText']>(extension, 'renderText', context)
return [extension.config.name, textSerializer]
if (!renderText) {
return []
}
const textSerializer = (props: { node: ProsemirrorNode }) => renderText(props)
return [extension.name, textSerializer]
}))
}

View File

@ -14,6 +14,7 @@ import {
GlobalAttributes,
ParentConfig,
} from './types'
import { Node } from './Node'
import { MarkConfig } from '.'
import { Editor } from './Editor'
@ -41,7 +42,7 @@ declare module '@tiptap/core' {
*/
addGlobalAttributes?: (this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addGlobalAttributes'],
}) => GlobalAttributes | {},
/**
@ -51,7 +52,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addCommands'],
}) => Partial<RawCommands>,
/**
@ -61,7 +62,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addKeyboardShortcuts'],
}) => {
[key: string]: ProseMirrorCommand,
},
@ -73,7 +74,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addInputRules'],
}) => InputRule[],
/**
@ -83,7 +84,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addPasteRules'],
}) => Plugin[],
/**
@ -93,7 +94,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addProseMirrorPlugins'],
}) => Plugin[],
/**
@ -102,7 +103,7 @@ declare module '@tiptap/core' {
extendNodeSchema?: ((
this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['extendNodeSchema'],
},
extension: Node,
) => {
@ -115,9 +116,9 @@ declare module '@tiptap/core' {
extendMarkSchema?: ((
this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['extendMarkSchema'],
},
extension: Node,
extension: Mark,
) => {
[key: string]: any,
}) | null,
@ -125,11 +126,11 @@ declare module '@tiptap/core' {
/**
* The editor is not ready yet.
*/
onBeforeCreate?: ((this: {
onBeforeCreate?: ((this: {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onBeforeCreate'],
}) => void) | null,
/**
@ -139,7 +140,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onCreate'],
}) => void) | null,
/**
@ -149,7 +150,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onUpdate'],
}) => void) | null,
/**
@ -159,7 +160,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onSelectionUpdate'],
}) => void) | null,
/**
@ -170,7 +171,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onTransaction'],
},
props: {
transaction: Transaction,
@ -185,7 +186,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onFocus'],
},
props: {
event: FocusEvent,
@ -200,7 +201,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onBlur'],
},
props: {
event: FocusEvent,
@ -214,7 +215,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: MarkType,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['onDestroy'],
}) => void) | null,
/**
@ -227,7 +228,7 @@ declare module '@tiptap/core' {
*/
inclusive?: MarkSpec['inclusive'] | ((this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['inclusive'],
}) => MarkSpec['inclusive']),
/**
@ -235,7 +236,7 @@ declare module '@tiptap/core' {
*/
excludes?: MarkSpec['excludes'] | ((this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['excludes'],
}) => MarkSpec['excludes']),
/**
@ -243,7 +244,7 @@ declare module '@tiptap/core' {
*/
group?: MarkSpec['group'] | ((this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['group'],
}) => MarkSpec['group']),
/**
@ -251,7 +252,7 @@ declare module '@tiptap/core' {
*/
spanning?: MarkSpec['spanning'] | ((this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['spanning'],
}) => MarkSpec['spanning']),
/**
@ -260,7 +261,7 @@ declare module '@tiptap/core' {
parseHTML?: (
this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['parseHTML'],
},
) => MarkSpec['parseDOM'],
@ -270,12 +271,12 @@ declare module '@tiptap/core' {
renderHTML?: ((
this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['renderHTML'],
},
props: {
mark: ProseMirrorMark,
HTMLAttributes: { [key: string]: any },
}
},
) => DOMOutputSpec) | null,
/**
@ -284,7 +285,7 @@ declare module '@tiptap/core' {
addAttributes?: (
this: {
options: Options,
parentConfig: ParentConfig<MarkConfig<Options>>,
parent: ParentConfig<MarkConfig<Options>>['addAttributes'],
},
) => Attributes | {},
}
@ -293,48 +294,55 @@ declare module '@tiptap/core' {
export class Mark<Options = any> {
type = 'mark'
name = 'mark'
parent: Mark | null = null
child: Mark | null = null
options: Options
config: MarkConfig = {
name: 'mark',
name: this.name,
priority: 100,
defaultOptions: {},
}
parentConfig: Partial<MarkConfig> = {}
options!: Options
constructor(config: MarkConfig<Options>) {
constructor(config: Partial<MarkConfig<Options>> = {}) {
this.config = {
...this.config,
...config,
}
this.name = this.config.name
this.options = this.config.defaultOptions
}
static create<O>(config: MarkConfig<O>) {
static create<O>(config: Partial<MarkConfig<O>> = {}) {
return new Mark<O>(config)
}
configure(options: Partial<Options> = {}) {
return Mark
.create<Options>(this.config as MarkConfig<Options>)
.#configure(options)
}
#configure = (options: Partial<Options>) => {
this.options = mergeDeep(this.config.defaultOptions, options) as Options
this.options = mergeDeep(this.options, options) as Options
return this
}
extend<ExtendedOptions = Options>(extendedConfig: Partial<MarkConfig<ExtendedOptions>>) {
const extension = new Mark<ExtendedOptions>({
...this.config,
...extendedConfig,
} as MarkConfig<ExtendedOptions>)
extend<ExtendedOptions = Options>(extendedConfig: Partial<MarkConfig<ExtendedOptions>> = {}) {
const extension = new Mark<ExtendedOptions>(extendedConfig)
extension.parentConfig = this.config
extension.parent = this
this.child = extension
extension.name = extendedConfig.name
? extendedConfig.name
: this.name
extension.options = {
...extension.parent.options,
...extension.options,
}
return extension
}

View File

@ -42,7 +42,7 @@ declare module '@tiptap/core' {
*/
addGlobalAttributes?: (this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addGlobalAttributes'],
}) => GlobalAttributes | {},
/**
@ -52,7 +52,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addCommands'],
}) => Partial<RawCommands>,
/**
@ -62,7 +62,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addKeyboardShortcuts'],
}) => {
[key: string]: ProseMirrorCommand,
},
@ -74,7 +74,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addInputRules'],
}) => InputRule[],
/**
@ -84,7 +84,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addPasteRules'],
}) => Plugin[],
/**
@ -94,7 +94,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addProseMirrorPlugins'],
}) => Plugin[],
/**
@ -103,7 +103,7 @@ declare module '@tiptap/core' {
extendNodeSchema?: ((
this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['extendNodeSchema'],
},
extension: Node,
) => {
@ -116,7 +116,7 @@ declare module '@tiptap/core' {
extendMarkSchema?: ((
this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['extendMarkSchema'],
},
extension: Node,
) => {
@ -130,7 +130,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onBeforeCreate'],
}) => void) | null,
/**
@ -140,7 +140,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onCreate'],
}) => void) | null,
/**
@ -150,7 +150,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onUpdate'],
}) => void) | null,
/**
@ -160,7 +160,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onSelectionUpdate'],
}) => void) | null,
/**
@ -171,7 +171,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onTransaction'],
},
props: {
transaction: Transaction,
@ -186,7 +186,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onFocus'],
},
props: {
event: FocusEvent,
@ -201,7 +201,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onBlur'],
},
props: {
event: FocusEvent,
@ -215,7 +215,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['onDestroy'],
}) => void) | null,
/**
@ -225,7 +225,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addNodeView'],
}) => NodeViewRenderer) | null,
/**
@ -238,7 +238,7 @@ declare module '@tiptap/core' {
*/
content?: NodeSpec['content'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['content'],
}) => NodeSpec['content']),
/**
@ -246,7 +246,7 @@ declare module '@tiptap/core' {
*/
marks?: NodeSpec['marks'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['marks'],
}) => NodeSpec['marks']),
/**
@ -254,7 +254,7 @@ declare module '@tiptap/core' {
*/
group?: NodeSpec['group'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['group'],
}) => NodeSpec['group']),
/**
@ -262,7 +262,7 @@ declare module '@tiptap/core' {
*/
inline?: NodeSpec['inline'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['inline'],
}) => NodeSpec['inline']),
/**
@ -270,7 +270,7 @@ declare module '@tiptap/core' {
*/
atom?: NodeSpec['atom'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['atom'],
}) => NodeSpec['atom']),
/**
@ -278,7 +278,7 @@ declare module '@tiptap/core' {
*/
selectable?: NodeSpec['selectable'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['selectable'],
}) => NodeSpec['selectable']),
/**
@ -286,7 +286,7 @@ declare module '@tiptap/core' {
*/
draggable?: NodeSpec['draggable'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['draggable'],
}) => NodeSpec['draggable']),
/**
@ -294,7 +294,7 @@ declare module '@tiptap/core' {
*/
code?: NodeSpec['code'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['code'],
}) => NodeSpec['code']),
/**
@ -302,7 +302,7 @@ declare module '@tiptap/core' {
*/
defining?: NodeSpec['defining'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['defining'],
}) => NodeSpec['defining']),
/**
@ -310,7 +310,7 @@ declare module '@tiptap/core' {
*/
isolating?: NodeSpec['isolating'] | ((this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['isolating'],
}) => NodeSpec['isolating']),
/**
@ -319,7 +319,7 @@ declare module '@tiptap/core' {
parseHTML?: (
this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['parseHTML'],
},
) => NodeSpec['parseDOM'],
@ -329,7 +329,7 @@ declare module '@tiptap/core' {
renderHTML?: ((
this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['renderHTML'],
},
props: {
node: ProseMirrorNode,
@ -345,7 +345,7 @@ declare module '@tiptap/core' {
options: Options,
editor: Editor,
type: NodeType,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['renderText'],
},
props: {
node: ProseMirrorNode,
@ -358,7 +358,7 @@ declare module '@tiptap/core' {
addAttributes?: (
this: {
options: Options,
parentConfig: ParentConfig<NodeConfig<Options>>,
parent: ParentConfig<NodeConfig<Options>>['addAttributes'],
},
) => Attributes | {},
}
@ -367,48 +367,55 @@ declare module '@tiptap/core' {
export class Node<Options = any> {
type = 'node'
name = 'node'
parent: Node | null = null
child: Node | null = null
options: Options
config: NodeConfig = {
name: 'node',
name: this.name,
priority: 100,
defaultOptions: {},
}
parentConfig: Partial<NodeConfig> = {}
options!: Options
constructor(config: NodeConfig<Options>) {
constructor(config: Partial<NodeConfig<Options>> = {}) {
this.config = {
...this.config,
...config,
}
this.name = this.config.name
this.options = this.config.defaultOptions
}
static create<O>(config: NodeConfig<O>) {
static create<O>(config: Partial<NodeConfig<O>> = {}) {
return new Node<O>(config)
}
configure(options: Partial<Options> = {}) {
return Node
.create<Options>(this.config as NodeConfig<Options>)
.#configure(options)
}
#configure = (options: Partial<Options>) => {
this.options = mergeDeep(this.config.defaultOptions, options) as Options
this.options = mergeDeep(this.options, options) as Options
return this
}
extend<ExtendedOptions = Options>(extendedConfig: Partial<NodeConfig<ExtendedOptions>>) {
const extension = new Node<ExtendedOptions>({
...this.config,
...extendedConfig,
} as NodeConfig<ExtendedOptions>)
extend<ExtendedOptions = Options>(extendedConfig: Partial<NodeConfig<ExtendedOptions>> = {}) {
const extension = new Node<ExtendedOptions>(extendedConfig)
extension.parentConfig = this.config
extension.parent = this
this.child = extension
extension.name = extendedConfig.name
? extendedConfig.name
: this.name
extension.options = {
...extension.parent.options,
...extension.options,
}
return extension
}

View File

@ -6,7 +6,7 @@ declare module '@tiptap/core' {
/**
* Clear the whole document.
*/
clearContent: (emitUpdate: Boolean) => Command,
clearContent: (emitUpdate?: Boolean) => Command,
}
}
}

View File

@ -17,7 +17,7 @@ function singleRect(object: Range | Element, bias: number) {
: rects[bias < 0 ? 0 : rects.length - 1]
}
export function coordsAtPos(view: EditorView, pos: number, end = false) {
export default function coordsAtPos(view: EditorView, pos: number, end = false) {
const { node, offset } = view.domAtPos(pos) // view.docView.domFromPos(pos);
let side: DOMRectSide | null = null
let rect: DOMRect | null = null

View File

@ -1,21 +0,0 @@
import { AnyExtension, AnyObject } from '../types'
export default function createExtensionContext<T>(
extension: AnyExtension,
data: T,
): T & { parentConfig: AnyObject } {
const context = {
...data,
get parentConfig() {
return Object.fromEntries(Object.entries(extension.parentConfig).map(([key, value]) => {
if (typeof value !== 'function') {
return [key, value]
}
return [key, value.bind(context)]
}))
},
}
return context
}

View File

@ -1,12 +1,14 @@
import createExtensionContext from './createExtensionContext'
import splitExtensions from './splitExtensions'
import getExtensionField from './getExtensionField'
import {
Extensions,
GlobalAttributes,
Attributes,
Attribute,
ExtensionAttribute,
AnyConfig,
} from '../types'
import { NodeConfig, MarkConfig } from '..'
/**
* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
@ -25,15 +27,22 @@ export default function getAttributesFromExtensions(extensions: Extensions): Ext
}
extensions.forEach(extension => {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
})
}
if (!extension.config.addGlobalAttributes) {
const addGlobalAttributes = getExtensionField<AnyConfig['addGlobalAttributes']>(
extension,
'addGlobalAttributes',
context,
)
if (!addGlobalAttributes) {
return
}
const globalAttributes = extension.config.addGlobalAttributes.bind(context)() as GlobalAttributes
// TODO: remove `as GlobalAttributes`
const globalAttributes = addGlobalAttributes() as GlobalAttributes
globalAttributes.forEach(globalAttribute => {
globalAttribute.types.forEach(type => {
@ -54,21 +63,28 @@ export default function getAttributesFromExtensions(extensions: Extensions): Ext
})
nodeAndMarkExtensions.forEach(extension => {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
})
}
if (!extension.config.addAttributes) {
const addAttributes = getExtensionField<NodeConfig['addAttributes'] | MarkConfig['addAttributes']>(
extension,
'addAttributes',
context,
)
if (!addAttributes) {
return
}
const attributes = extension.config.addAttributes.bind(context)() as Attributes
// TODO: remove `as Attributes`
const attributes = addAttributes() as Attributes
Object
.entries(attributes)
.forEach(([name, attribute]) => {
extensionAttributes.push({
type: extension.config.name,
type: extension.name,
name,
attribute: {
...defaultAttribute,

View File

@ -0,0 +1,25 @@
import { AnyExtension, AnyObject, RemoveThis } from '../types'
export default function getExtensionField<T = any>(
extension: AnyExtension,
field: string,
context: AnyObject = {},
): RemoveThis<T> {
if (extension.config[field] === undefined && extension.parent) {
return getExtensionField(extension.parent, field, context)
}
if (typeof extension.config[field] === 'function') {
const value = extension.config[field].bind({
...context,
parent: extension.parent
? getExtensionField(extension.parent, field, context)
: null,
})
return value
}
return extension.config[field]
}

View File

@ -1,13 +1,13 @@
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model'
import { Extensions } from '../types'
import { ExtensionConfig, NodeConfig, MarkConfig } from '..'
import createExtensionContext from './createExtensionContext'
import { AnyConfig, Extensions } from '../types'
import { NodeConfig, MarkConfig } from '..'
import splitExtensions from './splitExtensions'
import getAttributesFromExtensions from './getAttributesFromExtensions'
import getRenderedAttributes from './getRenderedAttributes'
import isEmptyObject from '../utilities/isEmptyObject'
import injectExtensionAttributesToParseRule from './injectExtensionAttributesToParseRule'
import callOrReturn from '../utilities/callOrReturn'
import getExtensionField from './getExtensionField'
function cleanUpSchemaItem<T>(data: T) {
return Object.fromEntries(Object.entries(data).filter(([key, value]) => {
@ -22,116 +22,110 @@ function cleanUpSchemaItem<T>(data: T) {
export default function getSchema(extensions: Extensions): Schema {
const allAttributes = getAttributesFromExtensions(extensions)
const { nodeExtensions, markExtensions } = splitExtensions(extensions)
const topNode = nodeExtensions.find(extension => extension.config.topNode)?.config.name
const nodeSchemaExtenders: (
| ExtensionConfig['extendNodeSchema']
| NodeConfig['extendNodeSchema']
| MarkConfig['extendNodeSchema']
)[] = []
const markSchemaExtenders: (
| ExtensionConfig['extendNodeSchema']
| NodeConfig['extendNodeSchema']
| MarkConfig['extendNodeSchema']
)[] = []
extensions.forEach(extension => {
if (typeof extension.config.extendNodeSchema === 'function') {
nodeSchemaExtenders.push(extension.config.extendNodeSchema)
}
if (typeof extension.config.extendMarkSchema === 'function') {
markSchemaExtenders.push(extension.config.extendMarkSchema)
}
})
const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name
const nodes = Object.fromEntries(nodeExtensions.map(extension => {
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.config.name)
const context = createExtensionContext(extension, {
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)
const context = {
options: extension.options,
})
}
const extraNodeFields = nodeSchemaExtenders.reduce((fields, nodeSchemaExtender) => {
const extraFields = callOrReturn(nodeSchemaExtender, context, extension)
const extraNodeFields = extensions.reduce((fields, e) => {
const extendNodeSchema = getExtensionField<AnyConfig['extendNodeSchema']>(
e,
'extendNodeSchema',
context,
)
return {
...fields,
...extraFields,
...(extendNodeSchema ? extendNodeSchema(extension) : {}),
}
}, {})
const schema: NodeSpec = cleanUpSchemaItem({
...extraNodeFields,
content: callOrReturn(extension.config.content, context),
marks: callOrReturn(extension.config.marks, context),
group: callOrReturn(extension.config.group, context),
inline: callOrReturn(extension.config.inline, context),
atom: callOrReturn(extension.config.atom, context),
selectable: callOrReturn(extension.config.selectable, context),
draggable: callOrReturn(extension.config.draggable, context),
code: callOrReturn(extension.config.code, context),
defining: callOrReturn(extension.config.defining, context),
isolating: callOrReturn(extension.config.isolating, context),
content: callOrReturn(getExtensionField<NodeConfig['content']>(extension, 'content', context)),
marks: callOrReturn(getExtensionField<NodeConfig['marks']>(extension, 'marks', context)),
group: callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context)),
inline: callOrReturn(getExtensionField<NodeConfig['inline']>(extension, 'inline', context)),
atom: callOrReturn(getExtensionField<NodeConfig['atom']>(extension, 'atom', context)),
selectable: callOrReturn(getExtensionField<NodeConfig['selectable']>(extension, 'selectable', context)),
draggable: callOrReturn(getExtensionField<NodeConfig['draggable']>(extension, 'draggable', context)),
code: callOrReturn(getExtensionField<NodeConfig['code']>(extension, 'code', context)),
defining: callOrReturn(getExtensionField<NodeConfig['defining']>(extension, 'defining', context)),
isolating: callOrReturn(getExtensionField<NodeConfig['isolating']>(extension, 'isolating', context)),
attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => {
return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]
})),
})
if (extension.config.parseHTML) {
schema.parseDOM = extension.config.parseHTML
.bind(context)()
?.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes))
const parseHTML = callOrReturn(getExtensionField<NodeConfig['parseHTML']>(extension, 'parseHTML', context))
if (parseHTML) {
schema.parseDOM = parseHTML
.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes))
}
if (extension.config.renderHTML) {
schema.toDOM = node => (extension.config.renderHTML as Function)?.bind(context)({
const renderHTML = getExtensionField<NodeConfig['renderHTML']>(extension, 'renderHTML', context)
if (renderHTML) {
schema.toDOM = node => renderHTML({
node,
HTMLAttributes: getRenderedAttributes(node, extensionAttributes),
})
}
return [extension.config.name, schema]
return [extension.name, schema]
}))
const marks = Object.fromEntries(markExtensions.map(extension => {
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.config.name)
const context = createExtensionContext(extension, {
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)
const context = {
options: extension.options,
})
}
const extraMarkFields = markSchemaExtenders.reduce((fields, markSchemaExtender) => {
const extraFields = callOrReturn(markSchemaExtender, context, extension)
const extraMarkFields = extensions.reduce((fields, e) => {
const extendMarkSchema = getExtensionField<AnyConfig['extendMarkSchema']>(
e,
'extendMarkSchema',
context,
)
return {
...fields,
...extraFields,
...(extendMarkSchema ? extendMarkSchema(extension) : {}),
}
}, {})
const schema: MarkSpec = cleanUpSchemaItem({
...extraMarkFields,
inclusive: callOrReturn(extension.config.inclusive, context),
excludes: callOrReturn(extension.config.excludes, context),
group: callOrReturn(extension.config.group, context),
spanning: callOrReturn(extension.config.spanning, context),
inclusive: callOrReturn(getExtensionField<NodeConfig['inclusive']>(extension, 'inclusive', context)),
excludes: callOrReturn(getExtensionField<NodeConfig['excludes']>(extension, 'excludes', context)),
group: callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context)),
spanning: callOrReturn(getExtensionField<NodeConfig['spanning']>(extension, 'spanning', context)),
attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => {
return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]
})),
})
if (extension.config.parseHTML) {
schema.parseDOM = extension.config.parseHTML
.bind(context)()
?.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes))
const parseHTML = callOrReturn(getExtensionField<MarkConfig['parseHTML']>(extension, 'parseHTML', context))
if (parseHTML) {
schema.parseDOM = parseHTML
.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes))
}
if (extension.config.renderHTML) {
schema.toDOM = mark => (extension.config.renderHTML as Function)?.bind(context)({
const renderHTML = getExtensionField<MarkConfig['renderHTML']>(extension, 'renderHTML', context)
if (renderHTML) {
schema.toDOM = mark => renderHTML({
mark,
HTMLAttributes: getRenderedAttributes(mark, extensionAttributes),
})
}
return [extension.config.name, schema]
return [extension.name, schema]
}))
return new Schema({

View File

@ -1,20 +1,23 @@
import { Extensions } from '../types'
import { NodeConfig } from '..'
import splitExtensions from './splitExtensions'
import callOrReturn from '../utilities/callOrReturn'
import getExtensionField from '../helpers/getExtensionField'
export default function isList(name: string, extensions: Extensions): boolean {
const { nodeExtensions } = splitExtensions(extensions)
const extension = nodeExtensions.find(item => item.config.name === name)
const extension = nodeExtensions.find(item => item.name === name)
if (!extension) {
return false
}
const groups = callOrReturn(extension.config.group, { options: extension.options })
const context = { options: extension.options }
const group = callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context))
if (typeof groups !== 'string') {
if (typeof group !== 'string') {
return false
}
return groups.split(' ').includes('list')
return group.split(' ').includes('list')
}

View File

@ -0,0 +1,30 @@
import { EditorView } from 'prosemirror-view'
import coordsAtPos from './coordsAtPos'
export default function posToDOMRect(view: EditorView, from: number, to: number): DOMRect {
const start = coordsAtPos(view, from)
const end = coordsAtPos(view, to, true)
const top = Math.min(start.top, end.top)
const bottom = Math.max(start.bottom, end.bottom)
const left = Math.min(start.left, end.left)
const right = Math.max(start.right, end.right)
const width = right - left
const height = bottom - top
const x = left
const y = top
const data = {
top,
bottom,
left,
right,
width,
height,
x,
y,
}
return {
...data,
toJSON: () => data,
}
}

View File

@ -12,7 +12,8 @@ export { default as markPasteRule } from './pasteRules/markPasteRule'
export { default as callOrReturn } from './utilities/callOrReturn'
export { default as mergeAttributes } from './utilities/mergeAttributes'
export { default as createExtensionContext } from './helpers/createExtensionContext'
export { default as coordsAtPos } from './helpers/coordsAtPos'
export { default as getExtensionField } from './helpers/getExtensionField'
export { default as findChildren } from './helpers/findChildren'
export { default as findParentNode } from './helpers/findParentNode'
export { default as findParentNodeClosestToPos } from './helpers/findParentNodeClosestToPos'
@ -26,6 +27,7 @@ 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 posToDOMRect } from './helpers/posToDOMRect'
export interface Commands {}

View File

@ -57,6 +57,10 @@ const style = `.ProseMirror {
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
.tippy-box[data-animation=fade][data-state=hidden] {
opacity: 0
}`
export default style

View File

@ -14,17 +14,31 @@ import { Extension } from './Extension'
import { Node } from './Node'
import { Mark } from './Mark'
import { Editor } from './Editor'
import { Commands } from '.'
import {
Commands,
ExtensionConfig,
NodeConfig,
MarkConfig,
} from '.'
export type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig
export type AnyExtension = Extension | Node | Mark
export type Extensions = AnyExtension[]
export type ParentConfig<T> = Partial<{
[P in keyof T]: Required<T>[P] extends () => any
[P in keyof T]: Required<T>[P] extends (...args: any) => any
? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]>
: T[P]
}>
export type RemoveThis<T> = T extends (...args: any) => any
? (...args: Parameters<T>) => ReturnType<T>
: T
export type MaybeReturnType<T> = T extends (...args: any) => any
? ReturnType<T>
: T
export interface EditorOptions {
element: Element,
content: Content,
@ -43,7 +57,6 @@ export interface EditorOptions {
onTransaction: (props: { editor: Editor, transaction: Transaction }) => void,
onFocus: (props: { editor: Editor, event: FocusEvent }) => void,
onBlur: (props: { editor: Editor, event: FocusEvent }) => void,
onResize: (props: { editor: Editor }) => void,
onDestroy: () => void,
}

View File

@ -1,3 +1,5 @@
import { MaybeReturnType } from '../types'
/**
* Optionally calls `value` as a function.
* Otherwise it is returned directly.
@ -5,7 +7,7 @@
* @param context Optional context to bind to function.
* @param props Optional props to pass to function.
*/
export default function callOrReturn(value: any, context: any = undefined, ...props: any[]): any {
export default function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> {
if (typeof value === 'function') {
if (context) {
return value.bind(context)(...props)
@ -14,5 +16,5 @@ export default function callOrReturn(value: any, context: any = undefined, ...pr
return value(...props)
}
return value
return value as MaybeReturnType<T>
}

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

View File

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

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

View File

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

View File

@ -3,6 +3,32 @@
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.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-bubble-menu@2.0.0-beta.6...@tiptap/extension-bubble-menu@2.0.0-beta.7) (2021-04-16)
### Bug Fixes
* fix tippy for react ([398fc7f](https://github.com/ueberdosis/tiptap-next/commit/398fc7f210b9d5449cbb00543ddf4af768552b9c))
### Features
* add coordsAtPos and posToClientRect helper methods ([8dab614](https://github.com/ueberdosis/tiptap-next/commit/8dab6144a661e4c90f33d9d2f300882009eadd46))
* add tippyOptions prop ([9a56f66](https://github.com/ueberdosis/tiptap-next/commit/9a56f666a118ca7c59a6f1f67f40e6490e20d3b8))
* remove keepInBounds ([d7282f1](https://github.com/ueberdosis/tiptap-next/commit/d7282f168bc6cfae4e1630d14bb8462bc135b254))
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-bubble-menu@2.0.0-beta.5...@tiptap/extension-bubble-menu@2.0.0-beta.6) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-bubble-menu
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-bubble-menu@2.0.0-beta.4...@tiptap/extension-bubble-menu@2.0.0-beta.5) (2021-04-01)
**Note:** Version bump only for package @tiptap/extension-bubble-menu

View File

@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-bubble-menu",
"description": "bubble-menu extension for tiptap",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.7",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@ -26,6 +26,7 @@
},
"dependencies": {
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.2"
"prosemirror-view": "^1.18.2",
"tippy.js": "^6.3.1"
}
}

View File

@ -1,12 +1,12 @@
import { Editor } from '@tiptap/core'
import { Editor, posToDOMRect } from '@tiptap/core'
import { EditorState, Plugin, PluginKey } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { coordsAtPos } from './helpers'
import tippy, { Instance, Props } from 'tippy.js'
export interface BubbleMenuPluginProps {
editor: Editor,
element: HTMLElement,
keepInBounds: boolean,
tippyOptions?: Partial<Props>,
}
export type BubbleMenuViewProps = BubbleMenuPluginProps & {
@ -18,35 +18,26 @@ export class BubbleMenuView {
public element: HTMLElement
public keepInBounds = true
public view: EditorView
public isActive = false
public top = 0
public bottom = 0
public left = 0
public preventHide = false
public tippy!: Instance
constructor({
editor,
element,
keepInBounds,
view,
tippyOptions,
}: BubbleMenuViewProps) {
this.editor = editor
this.element = element
this.keepInBounds = keepInBounds
this.view = view
this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })
this.editor.on('focus', this.focusHandler)
this.editor.on('blur', this.blurHandler)
this.editor.on('resize', this.resizeHandler)
this.render()
this.createTooltip(tippyOptions)
this.element.style.visibility = 'visible'
}
mousedownHandler = () => {
@ -58,12 +49,6 @@ export class BubbleMenuView {
setTimeout(() => this.update(this.editor.view))
}
resizeHandler = () => {
if (this.isActive) {
this.update(this.editor.view)
}
}
blurHandler = ({ event }: { event: FocusEvent }) => {
if (this.preventHide) {
this.preventHide = false
@ -81,6 +66,19 @@ export class BubbleMenuView {
this.hide()
}
createTooltip(options: Partial<Props> = {}) {
this.tippy = tippy(this.view.dom, {
duration: 0,
getReferenceClientRect: null,
content: this.element,
interactive: true,
trigger: 'manual',
placement: 'top',
hideOnClick: 'toggle',
...options,
})
}
update(view: EditorView, oldState?: EditorState) {
const { state, composing } = view
const { doc, selection } = state
@ -91,60 +89,33 @@ export class BubbleMenuView {
}
const { from, to, empty } = selection
const parent = this.element.offsetParent
if (empty || !parent) {
if (empty) {
this.hide()
return
}
const start = coordsAtPos(view, from)
const end = coordsAtPos(view, to, true)
const parentBox = parent.getBoundingClientRect()
const box = this.element.getBoundingClientRect()
const left = (start.left + end.left) / 2 - parentBox.left - box.width / 2
this.tippy.setProps({
getReferenceClientRect: () => posToDOMRect(view, from, to),
})
this.isActive = true
this.top = Math.round(end.bottom - parentBox.top)
this.bottom = Math.round(parentBox.bottom - start.top)
this.left = Math.round(
this.keepInBounds
? Math.min(
parentBox.width - box.width,
Math.max(
left,
0,
),
)
: left,
)
this.render()
this.show()
}
render() {
Object.assign(this.element.style, {
position: 'absolute',
zIndex: 1,
visibility: this.isActive ? 'visible' : 'hidden',
opacity: this.isActive ? 1 : 0,
left: `${this.left}px`,
// top: `${this.top}px`,
bottom: `${this.bottom}px`,
})
show() {
this.tippy.show()
}
hide() {
this.isActive = false
this.render()
this.tippy.hide()
}
destroy() {
this.tippy.destroy()
this.element.removeEventListener('mousedown', this.mousedownHandler)
this.editor.off('focus', this.focusHandler)
this.editor.off('blur', this.blurHandler)
this.editor.off('resize', this.resizeHandler)
}
}

View File

@ -10,7 +10,7 @@ export const BubbleMenu = Extension.create<BubbleMenuOptions>({
defaultOptions: {
element: null,
keepInBounds: true,
tippyOptions: {},
},
addProseMirrorPlugins() {
@ -22,7 +22,7 @@ export const BubbleMenu = Extension.create<BubbleMenuOptions>({
BubbleMenuPlugin({
editor: this.editor,
element: this.options.element,
keepInBounds: this.options.keepInBounds,
tippyOptions: this.options.tippyOptions,
}),
]
},

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

View File

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

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

View File

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

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.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block-lowlight@2.0.0-beta.7...@tiptap/extension-code-block-lowlight@2.0.0-beta.8) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-code-block-lowlight
# [2.0.0-beta.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block-lowlight@2.0.0-beta.6...@tiptap/extension-code-block-lowlight@2.0.0-beta.7) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-code-block-lowlight
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block-lowlight@2.0.0-beta.4...@tiptap/extension-code-block-lowlight@2.0.0-beta.6) (2021-04-14)
**Note:** Version bump only for package @tiptap/extension-code-block-lowlight

View File

@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-code-block-lowlight",
"description": "code block extension for tiptap",
"version": "2.0.0-beta.6",
"version": "2.0.0-beta.8",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@ -25,7 +25,7 @@
"@tiptap/core": "^2.0.0-beta.1"
},
"dependencies": {
"@tiptap/extension-code-block": "^2.0.0-beta.3",
"@tiptap/extension-code-block": "^2.0.0-beta.5",
"@types/lowlight": "^0.0.1",
"lowlight": "^1.20.0",
"prosemirror-model": "^1.14.0",

View File

@ -8,14 +8,13 @@ export interface CodeBlockLowlightOptions extends CodeBlockOptions {
export const CodeBlockLowlight = CodeBlock.extend<CodeBlockLowlightOptions>({
defaultOptions: {
...CodeBlock.config.defaultOptions,
...CodeBlock.options,
lowlight,
},
addProseMirrorPlugins() {
return [
// disable for now, see: https://github.com/ueberdosis/tiptap-next/issues/259#issuecomment-817954835
// ...this.parentConfig.addProseMirrorPlugins?.() || [],
...this.parent?.() || [],
LowlightPlugin({
name: 'codeBlock',
lowlight: this.options.lowlight,

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.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block@2.0.0-beta.4...@tiptap/extension-code-block@2.0.0-beta.5) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-code-block
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block@2.0.0-beta.3...@tiptap/extension-code-block@2.0.0-beta.4) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-code-block
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block@2.0.0-beta.2...@tiptap/extension-code-block@2.0.0-beta.3) (2021-04-11)

View File

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

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

View File

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

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

View File

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

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

View File

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

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

View File

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

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

View File

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

View File

@ -3,6 +3,31 @@
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-floating-menu@2.0.0-beta.3...@tiptap/extension-floating-menu@2.0.0-beta.4) (2021-04-16)
### Bug Fixes
* fix tippy for react ([398fc7f](https://github.com/ueberdosis/tiptap-next/commit/398fc7f210b9d5449cbb00543ddf4af768552b9c))
### Features
* add tippyOptions prop ([9a56f66](https://github.com/ueberdosis/tiptap-next/commit/9a56f666a118ca7c59a6f1f67f40e6490e20d3b8))
* use tippy for floating menu ([54df2ce](https://github.com/ueberdosis/tiptap-next/commit/54df2ce077a4bac09c3f1d1eab8c68a09d8f8fa9))
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-floating-menu@2.0.0-beta.2...@tiptap/extension-floating-menu@2.0.0-beta.3) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-floating-menu
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-floating-menu@2.0.0-beta.1...@tiptap/extension-floating-menu@2.0.0-beta.2) (2021-04-01)
**Note:** Version bump only for package @tiptap/extension-floating-menu

View File

@ -1,7 +1,7 @@
{
"name": "@tiptap/extension-floating-menu",
"description": "floating-menu extension for tiptap",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.4",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@ -26,6 +26,7 @@
},
"dependencies": {
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.2"
"prosemirror-view": "^1.18.2",
"tippy.js": "^6.3.1"
}
}

View File

@ -1,10 +1,12 @@
import { Editor, isNodeEmpty } from '@tiptap/core'
import { Editor, isNodeEmpty, posToDOMRect } from '@tiptap/core'
import { EditorState, Plugin, PluginKey } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import tippy, { Instance, Props } from 'tippy.js'
export interface FloatingMenuPluginProps {
editor: Editor,
element: HTMLElement,
tippyOptions?: Partial<Props>,
}
export type FloatingMenuViewProps = FloatingMenuPluginProps & {
@ -18,18 +20,15 @@ export class FloatingMenuView {
public view: EditorView
public isActive = false
public top = 0
public left = 0
public preventHide = false
public tippy!: Instance
constructor({
editor,
element,
view,
tippyOptions,
}: FloatingMenuViewProps) {
this.editor = editor
this.element = element
@ -37,8 +36,8 @@ export class FloatingMenuView {
this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })
this.editor.on('focus', this.focusHandler)
this.editor.on('blur', this.blurHandler)
this.editor.on('resize', this.resizeHandler)
this.render()
this.createTooltip(tippyOptions)
this.element.style.visibility = 'visible'
}
mousedownHandler = () => {
@ -50,12 +49,6 @@ export class FloatingMenuView {
setTimeout(() => this.update(this.editor.view))
}
resizeHandler = () => {
if (this.isActive) {
this.update(this.editor.view)
}
}
blurHandler = ({ event }: { event: FocusEvent }) => {
if (this.preventHide) {
this.preventHide = false
@ -73,6 +66,19 @@ export class FloatingMenuView {
this.hide()
}
createTooltip(options: Partial<Props> = {}) {
this.tippy = tippy(this.view.dom, {
duration: 0,
getReferenceClientRect: null,
content: this.element,
interactive: true,
trigger: 'manual',
placement: 'right',
hideOnClick: 'toggle',
...options,
})
}
update(view: EditorView, oldState?: EditorState) {
const { state, composing } = view
const { doc, selection } = state
@ -82,52 +88,43 @@ export class FloatingMenuView {
return
}
const { $anchor, anchor, empty } = selection
const parent = this.element.offsetParent
const {
$anchor,
empty,
from,
to,
} = selection
const isRootDepth = $anchor.depth === 1
const isDefaultNodeType = $anchor.parent.type === state.doc.type.contentMatch.defaultType
const isDefaultNodeEmpty = isNodeEmpty(selection.$anchor.parent)
const isActive = isRootDepth && isDefaultNodeType && isDefaultNodeEmpty
if (!empty || !parent || !isActive) {
if (!empty || !isActive) {
this.hide()
return
}
const parentBox = parent.getBoundingClientRect()
const cursorCoords = view.coordsAtPos(anchor)
const top = cursorCoords.top - parentBox.top
const left = cursorCoords.left - parentBox.left
this.tippy.setProps({
getReferenceClientRect: () => posToDOMRect(view, from, to),
})
this.isActive = true
this.top = top
this.left = left
this.render()
this.show()
}
render() {
Object.assign(this.element.style, {
position: 'absolute',
zIndex: 1,
visibility: this.isActive ? 'visible' : 'hidden',
opacity: this.isActive ? 1 : 0,
left: `${this.left}px`,
top: `${this.top}px`,
})
show() {
this.tippy.show()
}
hide() {
this.isActive = false
this.render()
this.tippy.hide()
}
destroy() {
this.tippy.destroy()
this.element.removeEventListener('mousedown', this.mousedownHandler)
this.editor.off('focus', this.focusHandler)
this.editor.off('blur', this.blurHandler)
this.editor.off('resize', this.resizeHandler)
}
}

View File

@ -10,6 +10,7 @@ export const FloatingMenu = Extension.create<FloatingMenuOptions>({
defaultOptions: {
element: null,
tippyOptions: {},
},
addProseMirrorPlugins() {
@ -21,6 +22,7 @@ export const FloatingMenu = Extension.create<FloatingMenuOptions>({
FloatingMenuPlugin({
editor: this.editor,
element: this.options.element,
tippyOptions: this.options.tippyOptions,
}),
]
},

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.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-focus@2.0.0-beta.7...@tiptap/extension-focus@2.0.0-beta.8) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-focus
# [2.0.0-beta.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-focus@2.0.0-beta.6...@tiptap/extension-focus@2.0.0-beta.7) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-focus
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-focus@2.0.0-beta.5...@tiptap/extension-focus@2.0.0-beta.6) (2021-03-31)
**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.6",
"version": "2.0.0-beta.8",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",

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

View File

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

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.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-gapcursor@2.0.0-beta.6...@tiptap/extension-gapcursor@2.0.0-beta.7) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-gapcursor
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-gapcursor@2.0.0-beta.5...@tiptap/extension-gapcursor@2.0.0-beta.6) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-gapcursor
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-gapcursor@2.0.0-beta.4...@tiptap/extension-gapcursor@2.0.0-beta.5) (2021-04-12)

View File

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

View File

@ -1,7 +1,7 @@
import {
Extension,
callOrReturn,
createExtensionContext,
getExtensionField,
ParentConfig,
} from '@tiptap/core'
import { gapCursor } from 'prosemirror-gapcursor'
@ -31,12 +31,12 @@ export const Gapcursor = Extension.create({
},
extendNodeSchema(extension) {
const context = createExtensionContext(extension, {
const context = {
options: extension.options,
})
}
return {
allowGapCursor: callOrReturn(extension.config.allowGapCursor, context) ?? null,
allowGapCursor: callOrReturn(getExtensionField(extension, 'allowGapCursor', context)) ?? null,
}
},
})

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

View File

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

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

View File

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

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

View File

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

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

View File

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

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-horizontal-rule@2.0.0-beta.3...@tiptap/extension-horizontal-rule@2.0.0-beta.4) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-horizontal-rule
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-horizontal-rule@2.0.0-beta.2...@tiptap/extension-horizontal-rule@2.0.0-beta.3) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-horizontal-rule
# [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)

View File

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

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

View File

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

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

View File

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

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.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@2.0.0-beta.4...@tiptap/extension-link@2.0.0-beta.5) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-link
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@2.0.0-beta.3...@tiptap/extension-link@2.0.0-beta.4) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-link
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-link@2.0.0-beta.2...@tiptap/extension-link@2.0.0-beta.3) (2021-04-11)

View File

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

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

View File

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

View File

@ -3,6 +3,30 @@
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.32](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.31...@tiptap/extension-mention@2.0.0-beta.32) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-mention
# [2.0.0-beta.31](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.30...@tiptap/extension-mention@2.0.0-beta.31) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-mention
# [2.0.0-beta.30](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.29...@tiptap/extension-mention@2.0.0-beta.30) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-mention
# [2.0.0-beta.29](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-mention@2.0.0-beta.28...@tiptap/extension-mention@2.0.0-beta.29) (2021-04-12)
**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.29",
"version": "2.0.0-beta.32",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
@ -25,6 +25,6 @@
"@tiptap/core": "^2.0.0-beta.1"
},
"dependencies": {
"@tiptap/suggestion": "^2.0.0-beta.29"
"@tiptap/suggestion": "^2.0.0-beta.32"
}
}

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

View File

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

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

View File

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

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

View File

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

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-strike@2.0.0-beta.3...@tiptap/extension-strike@2.0.0-beta.4) (2021-04-16)
**Note:** Version bump only for package @tiptap/extension-strike
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-strike@2.0.0-beta.2...@tiptap/extension-strike@2.0.0-beta.3) (2021-04-15)
**Note:** Version bump only for package @tiptap/extension-strike
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-strike@2.0.0-beta.1...@tiptap/extension-strike@2.0.0-beta.2) (2021-04-09)

Some files were not shown because too many files have changed in this diff Show More