diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25c117799f..ed86bdac1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,50 +23,49 @@ jobs: node-version: [16] steps: - - - uses: actions/checkout@v3.0.2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.5.1 - with: - node-version: ${{ matrix.node-version }} - - - name: Load cached dependencies - uses: actions/cache@v3.0.11 - id: cache - with: - path: | - **/node_modules - /home/runner/.cache/Cypress - key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install dependencies - id: install-dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: npm install - -# - name: Fix code style linting errors -# id: lint-fix -# run: npm run lint:fix -# continue-on-error: true -# -# - name: Commit fixed linting errors -# id: commit -# uses: stefanzweifel/git-auto-commit-action@v4 -# with: -# commit_message: "ci: fix code style linting errors" - - - name: Lint code - id: lint - run: npm run lint - - - name: Send Slack notifications - uses: act10ns/slack@v1 - if: failure() - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#tiptap-notifications' + - uses: actions/checkout@v3.0.2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3.5.1 + with: + node-version: ${{ matrix.node-version }} + + - name: Load cached dependencies + uses: actions/cache@v3.0.11 + id: cache + with: + path: | + **/node_modules + /home/runner/.cache/Cypress + key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install dependencies + id: install-dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: npm install + + # - name: Fix code style linting errors + # id: lint-fix + # run: npm run lint:fix + # continue-on-error: true + # + # - name: Commit fixed linting errors + # id: commit + # uses: stefanzweifel/git-auto-commit-action@v4 + # with: + # commit_message: "ci: fix code style linting errors" + + - name: Lint code + id: lint + run: npm run lint + + - name: Send Slack notifications + uses: act10ns/slack@v1 + if: failure() + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#tiptap-notifications' test: runs-on: ubuntu-latest @@ -79,48 +78,55 @@ jobs: node-version: [16] steps: - - - uses: actions/checkout@v3.0.2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.5.1 - with: - node-version: ${{ matrix.node-version }} - - - name: Run tests with Cypress - id: cypress - uses: cypress-io/github-action@v4.2.0 - with: - cache-key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} - start: npm run start - wait-on: 'http://localhost:3000' - project: ./tests - browser: chrome - quiet: true - - - name: Export screenshots (on failure only) - uses: actions/upload-artifact@v3.1.0 - if: failure() - with: - name: cypress-screenshots - path: tests/cypress/screenshots - retention-days: 7 - - - name: Export screen recordings (on failure only) - uses: actions/upload-artifact@v3.1.0 - if: failure() - with: - name: cypress-videos - path: tests/cypress/videos - retention-days: 7 - - - name: Send Slack notifications - uses: act10ns/slack@v1 - if: failure() - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#tiptap-notifications' + - uses: actions/checkout@v3.0.2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3.5.1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + id: install-dependencies + run: npm install + + - name: Try to build the packages + id: build-packages + run: npm run build:pm + + - name: Run tests with Cypress + id: cypress + uses: cypress-io/github-action@v4.2.0 + with: + cache-key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + start: npm run start + wait-on: 'http://localhost:3000' + project: ./tests + browser: chrome + quiet: true + + - name: Export screenshots (on failure only) + uses: actions/upload-artifact@v3.1.0 + if: failure() + with: + name: cypress-screenshots + path: tests/cypress/screenshots + retention-days: 7 + + - name: Export screen recordings (on failure only) + uses: actions/upload-artifact@v3.1.0 + if: failure() + with: + name: cypress-videos + path: tests/cypress/videos + retention-days: 7 + + - name: Send Slack notifications + uses: act10ns/slack@v1 + if: failure() + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#tiptap-notifications' build: runs-on: ubuntu-latest @@ -135,36 +141,35 @@ jobs: node-version: [16] steps: - - - uses: actions/checkout@v3.0.2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.5.1 - with: - node-version: ${{ matrix.node-version }} - - - name: Load cached dependencies - uses: actions/cache@v3.0.11 - id: cache - with: - path: | - **/node_modules - /home/runner/.cache/Cypress - key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install dependencies - id: install-dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: npm install - - - name: Try to build the packages - id: build-packages - run: npm run build:ci - - - name: Send Slack notifications - uses: act10ns/slack@v1 - if: failure() - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#tiptap-notifications' + - uses: actions/checkout@v3.0.2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3.5.1 + with: + node-version: ${{ matrix.node-version }} + + - name: Load cached dependencies + uses: actions/cache@v3.0.11 + id: cache + with: + path: | + **/node_modules + /home/runner/.cache/Cypress + key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install dependencies + id: install-dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: npm install + + - name: Try to build the packages + id: build-packages + run: npm run build:ci + + - name: Send Slack notifications + uses: act10ns/slack@v1 + if: failure() + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#tiptap-notifications' diff --git a/demos/includeDependencies.txt b/demos/includeDependencies.txt index 117f4fc598..374fd4c826 100644 --- a/demos/includeDependencies.txt +++ b/demos/includeDependencies.txt @@ -10,7 +10,7 @@ prosemirror-keymap prosemirror-model prosemirror-schema-list prosemirror-state -@tiptap/prosemirror-tables +prosemirror-tables prosemirror-transform prosemirror-view react diff --git a/demos/package-lock.json b/demos/package-lock.json index daf0b603cb..a32f68c305 100644 --- a/demos/package-lock.json +++ b/demos/package-lock.json @@ -33,7 +33,7 @@ "sass": "^1.49.7", "svelte": "^3.49.0", "tailwindcss": "^2.2.19", - "typescript": "^4.5.5", + "typescript": "4.7.4", "uuid": "^8.3.2", "vite": "^2.9.13", "vite-plugin-checker": "^0.3.4", diff --git a/demos/package.json b/demos/package.json index 396c305997..7dac3383be 100644 --- a/demos/package.json +++ b/demos/package.json @@ -34,7 +34,7 @@ "sass": "^1.49.7", "svelte": "^3.49.0", "tailwindcss": "^2.2.19", - "typescript": "^4.5.5", + "typescript": "4.7.4", "uuid": "^8.3.2", "vite": "^2.9.13", "vite-plugin-checker": "^0.3.4", diff --git a/demos/src/Examples/Savvy/React/ColorHighlighter.ts b/demos/src/Examples/Savvy/React/ColorHighlighter.ts index 6edc5f025c..193af7f52c 100644 --- a/demos/src/Examples/Savvy/React/ColorHighlighter.ts +++ b/demos/src/Examples/Savvy/React/ColorHighlighter.ts @@ -1,5 +1,5 @@ import { Extension } from '@tiptap/core' -import { Plugin } from 'prosemirror-state' +import { Plugin } from '@tiptap/pm/state' import findColors from './findColors' diff --git a/demos/src/Examples/Savvy/React/findColors.ts b/demos/src/Examples/Savvy/React/findColors.ts index 7e49d9ab1e..66ae2846c0 100644 --- a/demos/src/Examples/Savvy/React/findColors.ts +++ b/demos/src/Examples/Savvy/React/findColors.ts @@ -1,5 +1,5 @@ -import { Node } from 'prosemirror-model' -import { Decoration, DecorationSet } from 'prosemirror-view' +import { Node } from '@tiptap/pm/model' +import { Decoration, DecorationSet } from '@tiptap/pm/view' export default function (doc: Node): DecorationSet { const hexColor = /(#[0-9a-f]{3,6})\b/gi diff --git a/demos/src/Examples/Savvy/Vue/ColorHighlighter.ts b/demos/src/Examples/Savvy/Vue/ColorHighlighter.ts index 9ce38cfe91..193af7f52c 100644 --- a/demos/src/Examples/Savvy/Vue/ColorHighlighter.ts +++ b/demos/src/Examples/Savvy/Vue/ColorHighlighter.ts @@ -1,5 +1,5 @@ import { Extension } from '@tiptap/core' -import { Plugin } from 'prosemirror-state' +import { Plugin } from '@tiptap/pm/state' import findColors from './findColors' @@ -14,9 +14,7 @@ export const ColorHighlighter = Extension.create({ return findColors(doc) }, apply(transaction, oldState) { - return transaction.docChanged - ? findColors(transaction.doc) - : oldState + return transaction.docChanged ? findColors(transaction.doc) : oldState }, }, props: { diff --git a/demos/src/Examples/Savvy/Vue/findColors.ts b/demos/src/Examples/Savvy/Vue/findColors.ts index 211fa587e4..66ae2846c0 100644 --- a/demos/src/Examples/Savvy/Vue/findColors.ts +++ b/demos/src/Examples/Savvy/Vue/findColors.ts @@ -1,8 +1,8 @@ -import { Node } from 'prosemirror-model' -import { Decoration, DecorationSet } from 'prosemirror-view' +import { Node } from '@tiptap/pm/model' +import { Decoration, DecorationSet } from '@tiptap/pm/view' export default function (doc: Node): DecorationSet { - const hexColor = /(#[0-9a-f]{3,6})\b/ig + const hexColor = /(#[0-9a-f]{3,6})\b/gi const decorations: Decoration[] = [] doc.descendants((node, position) => { @@ -10,20 +10,18 @@ export default function (doc: Node): DecorationSet { return } - Array - .from(node.text.matchAll(hexColor)) - .forEach(match => { - const color = match[0] - const index = match.index || 0 - const from = position + index - const to = from + color.length - const decoration = Decoration.inline(from, to, { - class: 'color', - style: `--color: ${color}`, - }) - - decorations.push(decoration) + Array.from(node.text.matchAll(hexColor)).forEach(match => { + const color = match[0] + const index = match.index || 0 + const from = position + index + const to = from + color.length + const decoration = Decoration.inline(from, to, { + class: 'color', + style: `--color: ${color}`, }) + + decorations.push(decoration) + }) }) return DecorationSet.create(doc, decorations) diff --git a/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationPlugin.ts b/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationPlugin.ts index 70efa5f55e..89f0849e33 100644 --- a/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationPlugin.ts +++ b/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationPlugin.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' import * as Y from 'yjs' import { AnnotationState } from './AnnotationState' @@ -8,10 +8,10 @@ export const AnnotationPluginKey = new PluginKey('annotation') export interface AnnotationPluginOptions { HTMLAttributes: { [key: string]: any - }, - onUpdate: (items: [any?]) => {}, - map: Y.Map, - instance: string, + } + onUpdate: (items: [any?]) => {} + map: Y.Map + instance: string } export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin({ @@ -39,9 +39,7 @@ export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin return decorations } - const annotations = this - .getState(state) - .annotationsAt(selection.from) + const annotations = this.getState(state).annotationsAt(selection.from) options.onUpdate(annotations) diff --git a/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationState.ts b/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationState.ts index c363e39fe4..cef708290b 100644 --- a/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationState.ts +++ b/demos/src/Experiments/CollaborationAnnotation/Vue/extension/AnnotationState.ts @@ -1,18 +1,26 @@ -import { EditorState, Transaction } from 'prosemirror-state' -import { Decoration, DecorationSet } from 'prosemirror-view' -import { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from 'y-prosemirror' +import { EditorState, Transaction } from '@tiptap/pm/state' +import { Decoration, DecorationSet } from '@tiptap/pm/view' +import { + absolutePositionToRelativePosition, + relativePositionToAbsolutePosition, + ySyncPluginKey, +} from 'y-prosemirror' import * as Y from 'yjs' import { AnnotationItem } from './AnnotationItem' import { AnnotationPluginKey } from './AnnotationPlugin' -import { AddAnnotationAction, DeleteAnnotationAction, UpdateAnnotationAction } from './collaboration-annotation' +import { + AddAnnotationAction, + DeleteAnnotationAction, + UpdateAnnotationAction, +} from './collaboration-annotation' export interface AnnotationStateOptions { HTMLAttributes: { [key: string]: any - }, - map: Y.Map, - instance: string, + } + map: Y.Map + instance: string } export class AnnotationState { @@ -93,14 +101,27 @@ export class AnnotationState { } // eslint-disable-next-line - console.log(`[${this.options.instance}] Decoration.inline()`, from, to, HTMLAttributes, { id, data: annotation.data }) + console.log(`[${this.options.instance}] Decoration.inline()`, from, to, HTMLAttributes, { + id, + data: annotation.data, + }) if (from === to) { - console.warn(`[${this.options.instance}] corrupt decoration `, annotation.from, from, annotation.to, to) + console.warn( + `[${this.options.instance}] corrupt decoration `, + annotation.from, + from, + annotation.to, + to, + ) } decorations.push( - Decoration.inline(from, to, HTMLAttributes, { id, data: annotation.data, inclusiveEnd: true }), + Decoration.inline(from, to, HTMLAttributes, { + id, + data: annotation.data, + inclusiveEnd: true, + }), ) }) @@ -109,7 +130,10 @@ export class AnnotationState { apply(transaction: Transaction, state: EditorState) { // Add/Remove annotations - const action = transaction.getMeta(AnnotationPluginKey) as AddAnnotationAction | UpdateAnnotationAction | DeleteAnnotationAction + const action = transaction.getMeta(AnnotationPluginKey) as + | AddAnnotationAction + | UpdateAnnotationAction + | DeleteAnnotationAction if (action && action.type) { // eslint-disable-next-line diff --git a/demos/src/Experiments/GenericFigure/Vue/figure.ts b/demos/src/Experiments/GenericFigure/Vue/figure.ts index 83cce55089..5972b8362c 100644 --- a/demos/src/Experiments/GenericFigure/Vue/figure.ts +++ b/demos/src/Experiments/GenericFigure/Vue/figure.ts @@ -1,5 +1,5 @@ import { mergeAttributes, Node } from '@tiptap/core' -import { Plugin } from 'prosemirror-state' +import { Plugin } from '@tiptap/pm/state' export const Figure = Node.create({ name: 'figure', diff --git a/demos/src/Experiments/GlobalDragHandle/Vue/DragHandle.js b/demos/src/Experiments/GlobalDragHandle/Vue/DragHandle.js index feb71e0011..2499174a9e 100644 --- a/demos/src/Experiments/GlobalDragHandle/Vue/DragHandle.js +++ b/demos/src/Experiments/GlobalDragHandle/Vue/DragHandle.js @@ -1,6 +1,6 @@ import { Extension } from '@tiptap/core' -import { NodeSelection, Plugin } from 'prosemirror-state' -import { __serializeForClipboard as serializeForClipboard } from 'prosemirror-view' +import { NodeSelection, Plugin } from '@tiptap/pm/state' +import { __serializeForClipboard as serializeForClipboard } from '@tiptap/pm/view' function removeNode(node) { node.parentNode.removeChild(node) @@ -25,7 +25,8 @@ export default Extension.create({ node = node.node while (node && node.parentNode) { - if (node.parentNode?.classList?.contains('ProseMirror')) { // todo + if (node.parentNode?.classList?.contains('ProseMirror')) { + // todo break } @@ -131,7 +132,8 @@ export default Extension.create({ if (node) { node = node.node while (node && node.parentNode) { - if (node.parentNode?.classList?.contains('ProseMirror')) { // todo + if (node.parentNode?.classList?.contains('ProseMirror')) { + // todo break } node = node.parentNode @@ -145,7 +147,7 @@ export default Extension.create({ const rect = absoluteRect(node) const win = node.ownerDocument.defaultView - rect.top += win.pageYOffset + ((lineHeight - 24) / 2) + top + rect.top += win.pageYOffset + (lineHeight - 24) / 2 + top rect.left += win.pageXOffset rect.width = `${WIDTH}px` diff --git a/demos/src/Experiments/Linter/Vue/extension/Linter.ts b/demos/src/Experiments/Linter/Vue/extension/Linter.ts index 330c89502d..83b0e17e15 100644 --- a/demos/src/Experiments/Linter/Vue/extension/Linter.ts +++ b/demos/src/Experiments/Linter/Vue/extension/Linter.ts @@ -1,7 +1,7 @@ import { Extension } from '@tiptap/core' -import { Node as ProsemirrorNode } from 'prosemirror-model' -import { Plugin, PluginKey, TextSelection } from 'prosemirror-state' -import { Decoration, DecorationSet } from 'prosemirror-view' +import { Node as ProsemirrorNode } from '@tiptap/pm/model' +import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state' +import { Decoration, DecorationSet } from '@tiptap/pm/view' import LinterPlugin, { Result as Issue } from './LinterPlugin' @@ -22,9 +22,11 @@ function renderIcon(issue: Issue) { function runAllLinterPlugins(doc: ProsemirrorNode, plugins: Array) { const decorations: [any?] = [] - const results = plugins.map(RegisteredLinterPlugin => { - return new RegisteredLinterPlugin(doc).scan().getResults() - }).flat() + const results = plugins + .map(RegisteredLinterPlugin => { + return new RegisteredLinterPlugin(doc).scan().getResults() + }) + .flat() results.forEach(issue => { decorations.push( @@ -39,7 +41,7 @@ function runAllLinterPlugins(doc: ProsemirrorNode, plugins: Array, + plugins: Array } export const Linter = Extension.create({ @@ -62,9 +64,7 @@ export const Linter = Extension.create({ return runAllLinterPlugins(doc, plugins) }, apply(transaction, oldState) { - return transaction.docChanged - ? runAllLinterPlugins(transaction.doc, plugins) - : oldState + return transaction.docChanged ? runAllLinterPlugins(transaction.doc, plugins) : oldState }, }, props: { @@ -72,7 +72,7 @@ export const Linter = Extension.create({ return this.getState(state) }, handleClick(view, _, event) { - const target = (event.target as IconDivElement) + const target = event.target as IconDivElement if (/lint-icon/.test(target.className) && target.issue) { const { from, to } = target.issue @@ -89,7 +89,7 @@ export const Linter = Extension.create({ return false }, handleDoubleClick(view, _, event) { - const target = (event.target as IconDivElement) + const target = event.target as IconDivElement if (/lint-icon/.test((event.target as HTMLElement).className) && target.issue) { const prob = target.issue diff --git a/demos/src/Experiments/Linter/Vue/extension/LinterPlugin.ts b/demos/src/Experiments/Linter/Vue/extension/LinterPlugin.ts index 200b146b89..68e4a1a312 100644 --- a/demos/src/Experiments/Linter/Vue/extension/LinterPlugin.ts +++ b/demos/src/Experiments/Linter/Vue/extension/LinterPlugin.ts @@ -1,9 +1,9 @@ -import { Node as ProsemirrorNode } from 'prosemirror-model' +import { Node as ProsemirrorNode } from '@tiptap/pm/model' export interface Result { - message: string, - from: number, - to: number, + message: string + from: number + to: number fix?: Function } diff --git a/demos/src/Experiments/Linter/Vue/extension/plugins/HeadingLevel.ts b/demos/src/Experiments/Linter/Vue/extension/plugins/HeadingLevel.ts index 728097a340..b6273ab4ca 100644 --- a/demos/src/Experiments/Linter/Vue/extension/plugins/HeadingLevel.ts +++ b/demos/src/Experiments/Linter/Vue/extension/plugins/HeadingLevel.ts @@ -1,4 +1,4 @@ -import { EditorView } from 'prosemirror-view' +import { EditorView } from '@tiptap/pm/view' import LinterPlugin, { Result as Issue } from '../LinterPlugin' diff --git a/demos/src/Experiments/Linter/Vue/extension/plugins/Punctuation.ts b/demos/src/Experiments/Linter/Vue/extension/plugins/Punctuation.ts index 4ccb24396c..7e9d114da6 100644 --- a/demos/src/Experiments/Linter/Vue/extension/plugins/Punctuation.ts +++ b/demos/src/Experiments/Linter/Vue/extension/plugins/Punctuation.ts @@ -1,4 +1,4 @@ -import { EditorView } from 'prosemirror-view' +import { EditorView } from '@tiptap/pm/view' import LinterPlugin, { Result as Issue } from '../LinterPlugin' @@ -7,13 +7,7 @@ export class Punctuation extends LinterPlugin { fix(replacement: any) { return function ({ state, dispatch }: EditorView, issue: Issue) { - dispatch( - state.tr.replaceWith( - issue.from, - issue.to, - state.schema.text(replacement), - ), - ) + dispatch(state.tr.replaceWith(issue.from, issue.to, state.schema.text(replacement))) } } diff --git a/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts b/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts index f5b2520d52..ce52dedcc4 100644 --- a/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts +++ b/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts @@ -1,5 +1,5 @@ import { Extension } from '@tiptap/core' -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' // @ts-ignore function nodeEqualsType({ types, node }) { @@ -13,8 +13,8 @@ function nodeEqualsType({ types, node }) { */ export interface TrailingNodeOptions { - node: string, - notAfter: string[], + node: string + notAfter: string[] } export const TrailingNode = Extension.create({ @@ -23,9 +23,7 @@ export const TrailingNode = Extension.create({ addOptions() { return { node: 'paragraph', - notAfter: [ - 'paragraph', - ], + notAfter: ['paragraph'], } }, diff --git a/demos/vite.config.ts b/demos/vite.config.ts index 48086a0587..f198a550be 100644 --- a/demos/vite.config.ts +++ b/demos/vite.config.ts @@ -11,8 +11,30 @@ import { } from 'path' import { v4 as uuid } from 'uuid' import { defineConfig } from 'vite' + // import checker from 'vite-plugin-checker' +const getPackageDependencies = () => { + const paths: Array<{ find: string, replacement: any }> = [] + + fg.sync('../packages/*', { onlyDirectories: true }) + .map(name => name.replace('../packages/', '')) + .forEach(name => { + if (name === 'pm') { + fg.sync(`../packages/${name}/*`, { onlyDirectories: true }) + .forEach(subName => { + const subPkgName = subName.replace(`../packages/${name}/`, '') + + paths.push({ find: `@tiptap/${name}/${subPkgName}`, replacement: resolve(`../packages/${name}/${subPkgName}/index.ts`) }) + }) + } else { + paths.push({ find: `@tiptap/${name}`, replacement: resolve(`../packages/${name}/src/index.ts`) }) + } + }) + + return paths +} + const includeDependencies = fs.readFileSync('./includeDependencies.txt') .toString() .replace(/\r\n/g, '\n') @@ -271,12 +293,6 @@ export default defineConfig({ ], resolve: { - alias: [ - ...fg.sync('../packages/*', { onlyDirectories: true }) - .map(name => name.replace('../packages/', '')) - .map(name => { - return { find: `@tiptap/${name}`, replacement: resolve(`../packages/${name}/src/index.ts`) } - }), - ], + alias: getPackageDependencies(), }, }) diff --git a/docs/api/commands.md b/docs/api/commands.md index b941033210..47134adae2 100644 --- a/docs/api/commands.md +++ b/docs/api/commands.md @@ -120,7 +120,7 @@ addCommands() { If you’re just wrapping a plain ProseMirror command, you’ll need to pass `dispatch` anyway. Then there’s also no need to check it: ```js -import { exitCode } from 'prosemirror-commands' +import { exitCode } from '@tiptap/pm/commands' export default () => ({ state, dispatch }) => { return exitCode(state, dispatch) diff --git a/docs/api/extensions/bubble-menu.md b/docs/api/extensions/bubble-menu.md index 67138f9dd6..e1ddf0f401 100644 --- a/docs/api/extensions/bubble-menu.md +++ b/docs/api/extensions/bubble-menu.md @@ -112,7 +112,7 @@ Alternatively you can pass a ProseMirror `PluginKey`. ```js import { Editor } from '@tiptap/core' import BubbleMenu from '@tiptap/extension-bubble-menu' -import { PluginKey } from 'prosemirror-state' +import { PluginKey } from '@tiptap/pm/state' new Editor({ extensions: [ diff --git a/docs/api/extensions/collaboration-cursor.md b/docs/api/extensions/collaboration-cursor.md index 1a6f7175a4..7cd83aa6b9 100644 --- a/docs/api/extensions/collaboration-cursor.md +++ b/docs/api/extensions/collaboration-cursor.md @@ -20,10 +20,6 @@ We kindly ask you to [sponsor our work](/sponsor) when using this extension in p npm install @tiptap/extension-collaboration-cursor ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-collaboration-cursor) which packages are needed and how to install them. -::: - This extension requires the [`Collaboration`](/api/extensions/collaboration) extension. ## Settings diff --git a/docs/api/extensions/collaboration.md b/docs/api/extensions/collaboration.md index e8d2476144..fccc18457d 100644 --- a/docs/api/extensions/collaboration.md +++ b/docs/api/extensions/collaboration.md @@ -20,10 +20,6 @@ We kindly ask you to [sponsor our work](/sponsor) when using this extension in p npm install @tiptap/extension-collaboration yjs y-websocket ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-collaboration) which packages are needed and how to install them. -::: - ## Settings ### document diff --git a/docs/api/extensions/dropcursor.md b/docs/api/extensions/dropcursor.md index f87e15b01f..b23f4bc3d0 100644 --- a/docs/api/extensions/dropcursor.md +++ b/docs/api/extensions/dropcursor.md @@ -4,6 +4,7 @@ icon: drag-drop-line --- # Dropcursor + [![Version](https://img.shields.io/npm/v/@tiptap/extension-dropcursor.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-dropcursor) [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-dropcursor.svg)](https://npmcharts.com/compare/@tiptap/extension-dropcursor?minimal=true) @@ -12,28 +13,27 @@ This extension loads the [ProseMirror Dropcursor plugin](https://github.com/Pros Note that Tiptap is headless, but the dropcursor needs CSS for its appearance. There are settings for the color and width, and you’re free to add a custom CSS class. ## Installation + ```bash npm install @tiptap/extension-dropcursor ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-dropcursor) which packages are needed and how to install them. -::: - ## Settings ### color + Color of the dropcursor. Default: `'currentColor'` ```js Dropcursor.configure({ - color: '#ff0000' + color: '#ff0000', }) ``` ### width + Width of the dropcursor. Default: `1` @@ -45,6 +45,7 @@ Dropcursor.configure({ ``` ### class + One or multiple CSS classes that should be applied to the dropcursor. ```js @@ -54,7 +55,9 @@ Dropcursor.configure({ ``` ## Source code + [packages/extension-dropcursor/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-dropcursor/) ## Usage + https://embed.tiptap.dev/preview/Extensions/Dropcursor diff --git a/docs/api/extensions/floating-menu.md b/docs/api/extensions/floating-menu.md index 6091f1b506..da4d9dd00d 100644 --- a/docs/api/extensions/floating-menu.md +++ b/docs/api/extensions/floating-menu.md @@ -100,7 +100,7 @@ Alternatively you can pass a ProseMirror `PluginKey`. ```js import { Editor } from '@tiptap/core' import FloatingMenu from '@tiptap/extension-floating-menu' -import { PluginKey } from 'prosemirror-state' +import { PluginKey } from '@tiptap/pm/state' new Editor({ extensions: [ diff --git a/docs/api/extensions/gapcursor.md b/docs/api/extensions/gapcursor.md index a76aa94326..d18204a1d1 100644 --- a/docs/api/extensions/gapcursor.md +++ b/docs/api/extensions/gapcursor.md @@ -4,6 +4,7 @@ icon: space --- # Gapcursor + [![Version](https://img.shields.io/npm/v/@tiptap/extension-gapcursor.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-gapcursor) [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-gapcursor.svg)](https://npmcharts.com/compare/@tiptap/extension-gapcursor?minimal=true) @@ -12,16 +13,15 @@ This extension loads the [ProseMirror Gapcursor plugin](https://github.com/Prose Note that Tiptap is headless, but the gapcursor needs CSS for its appearance. The [default CSS](https://github.com/ueberdosis/tiptap/tree/main/packages/core/src/style.ts) is loaded through the Editor class. ## Installation + ```bash npm install @tiptap/extension-gapcursor ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-gapcursor) which packages are needed and how to install them. -::: - ## Source code + [packages/extension-gapcursor/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-gapcursor/) ## Usage + https://embed.tiptap.dev/preview/Extensions/Gapcursor diff --git a/docs/api/extensions/history.md b/docs/api/extensions/history.md index c1b1bf4dd3..798ca185c0 100644 --- a/docs/api/extensions/history.md +++ b/docs/api/extensions/history.md @@ -4,23 +4,22 @@ icon: history-line --- # History + [![Version](https://img.shields.io/npm/v/@tiptap/extension-history.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-history) [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-history.svg)](https://npmcharts.com/compare/@tiptap/extension-history?minimal=true) This extension provides history support. All changes to the document will be tracked and can be removed with `undo`. Undone changes can be applied with `redo` again. ## Installation + ```bash npm install @tiptap/extension-history ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-history) which packages are needed and how to install them. -::: - ## Settings ### depth + The amount of history events that are collected before the oldest events are discarded. Defaults to 100. Default: `100` @@ -32,6 +31,7 @@ History.configure({ ``` ### newGroupDelay + The delay between changes after which a new group should be started (in milliseconds). When changes aren’t adjacent, a new group is always started. Default: `500` @@ -45,12 +45,15 @@ History.configure({ ## Commands ### undo() + Undo the last change. ```js editor.commands.undo() ``` + ### redo() + Redo the last change. ```js @@ -58,13 +61,16 @@ editor.commands.redo() ``` ## Keyboard shortcuts + | Command | Windows/Linux | macOS | | ------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | | undo() | `Control` `Z`
`Control` `я` | `Cmd` `Z`
`Cmd` `я` | | redo() | `Shift` `Control` `Z`
`Control` `Y`
`Shift` `Control` `я` | `Shift` `Cmd` `Z`
`Cmd` `Y`
`Shift` `Cmd` `я` | ## Source code + [packages/extension-history/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-history/) ## Usage + https://embed.tiptap.dev/preview/Extensions/History diff --git a/docs/api/extensions/starter-kit.md b/docs/api/extensions/starter-kit.md index cf1600963c..224f457a57 100644 --- a/docs/api/extensions/starter-kit.md +++ b/docs/api/extensions/starter-kit.md @@ -14,10 +14,6 @@ The `StarterKit` is a collection of the most popular Tiptap extensions. If you npm install @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) which packages are needed and how to install them. -::: - ## Included extensions ### Nodes diff --git a/docs/api/introduction.md b/docs/api/introduction.md index 0a90cd7ed2..43dc5122ce 100644 --- a/docs/api/introduction.md +++ b/docs/api/introduction.md @@ -1,5 +1,5 @@ # Introduction -tiptap is a friendly wrapper around [ProseMirror](https://ProseMirror.net). Although Tiptap tries to hide most of the complexity of ProseMirror, it’s built on top of its APIs and we recommend you to read through the [ProseMirror Guide](https://ProseMirror.net/docs/guide/) for advanced usage. +Tiptap is a friendly wrapper around [ProseMirror](https://ProseMirror.net). Although Tiptap tries to hide most of the complexity of ProseMirror, it’s built on top of its APIs and we recommend you to read through the [ProseMirror Guide](https://ProseMirror.net/docs/guide/) for advanced usage. ### Structure ProseMirror works with a strict [Schema](/api/schema), which defines the allowed structure of a document. A document is a tree of headings, paragraphs and others elements, so called nodes. Marks can be attached to a node, e. g. to emphasize part of it. [Commands](/api/commands) change that document programmatically. diff --git a/docs/guide/collaborative-editing.md b/docs/guide/collaborative-editing.md index c8a4fd2160..d0f9b2392d 100644 --- a/docs/guide/collaborative-editing.md +++ b/docs/guide/collaborative-editing.md @@ -28,10 +28,6 @@ First, install the dependencies: npm install @tiptap/extension-collaboration yjs y-webrtc ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-collaboration) which packages are needed and how to install them. -::: - Now, create a new Y document, and register it with Tiptap: ```js @@ -78,10 +74,6 @@ For the client, the example is nearly the same, only the provider is different. npm install @tiptap/extension-collaboration @hocuspocus/provider ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [see here](https://tiptap.dev/installation/peer-dependencies#tiptapextension-collaboration) which packages are needed and how to install them. -::: - And then register the WebSocket provider with Tiptap: ```js @@ -293,7 +285,7 @@ server.listen() ## Pitfalls ### Schema updates -tiptap is very strict with the [schema](/api/schema), that means, if you add something that’s not allowed according to the configured schema it’ll be thrown away. That can lead to a strange behaviour when multiple clients with different schemas share changes to a document. +Tiptap is very strict with the [schema](/api/schema), that means, if you add something that’s not allowed according to the configured schema it’ll be thrown away. That can lead to a strange behaviour when multiple clients with different schemas share changes to a document. Let’s say you added an editor to your app and the first people use it already. They have all a loaded instance of Tiptap with all default extensions, and therefor a schema that only allows those. But you want to add task lists in the next update, so you add the extension and deploy again. diff --git a/docs/guide/custom-extensions.md b/docs/guide/custom-extensions.md index 9179bf013f..d8428bdd0a 100644 --- a/docs/guide/custom-extensions.md +++ b/docs/guide/custom-extensions.md @@ -114,7 +114,7 @@ const awesomeness = editor.storage.customExtension.awesomeness ``` ### Schema -tiptap works with a strict schema, which configures how the content can be structured, nested, how it behaves and many more things. You [can change all aspects of the schema](/api/schema) for existing extensions. Let’s walk through a few common use cases. +Tiptap works with a strict schema, which configures how the content can be structured, nested, how it behaves and many more things. You [can change all aspects of the schema](/api/schema) for existing extensions. Let’s walk through a few common use cases. The default `Blockquote` extension can wrap other nodes, like headings. If you want to allow nothing but paragraphs in your blockquotes, set the `content` attribute accordingly: @@ -531,7 +531,7 @@ After all, Tiptap is built on ProseMirror and ProseMirror has a pretty powerful You can wrap existing ProseMirror plugins in Tiptap extensions like shown in the example below. ```js -import { history } from 'prosemirror-history' +import { history } from '@tiptap/pm/history' const History = Extension.create({ addProseMirrorPlugins() { @@ -550,7 +550,7 @@ Or you can add them to a Tiptap extension like shown in the below example. ```js import { Extension } from '@tiptap/core' -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' export const EventHandler = Extension.create({ name: 'eventHandler', diff --git a/docs/guide/prosemirror.md b/docs/guide/prosemirror.md new file mode 100644 index 0000000000..12e12b9b96 --- /dev/null +++ b/docs/guide/prosemirror.md @@ -0,0 +1,39 @@ +--- +tableOfContents: true +--- + +# Accessing ProseMirror internals + +The ProseMirror internals are packaged in the `@tiptap/pm` package that you need to install with `npm install @tiptap/pm`. If you already have this done you can skip the following step. + +```bash +npm i @tiptap/pm +``` + +After that you can access all internal ProseMirror packages like this: + +```js +// this example loads the EditorState class from the ProseMirror state package +import { EditorState } from '@tiptap/pm/state' +``` + +The following packages are available: + +- `@tiptap/pm/changeset` +- `@tiptap/pm/collab` +- `@tiptap/pm/commands` +- `@tiptap/pm/dropcursor` +- `@tiptap/pm/gapcursor` +- `@tiptap/pm/history` +- `@tiptap/pm/inputrules` +- `@tiptap/pm/keymap` +- `@tiptap/pm/markdown` +- `@tiptap/pm/menu` +- `@tiptap/pm/model` +- `@tiptap/pm/schema-basic` +- `@tiptap/pm/schema-list` +- `@tiptap/pm/state` +- `@tiptap/pm/tables` +- `@tiptap/pm/trailing-node` +- `@tiptap/pm/transform` +- `@tiptap/pm/view` diff --git a/docs/installation.md b/docs/installation.md index 988d6f2419..d451999f06 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -5,24 +5,33 @@ tableOfContents: true # Installation ## Introduction + Tiptap is framework-agnostic and even works with Vanilla JavaScript (if that’s your thing). The following integration guides help you integrating Tiptap in your JavaScript project. +## Base Setup + +To get started you will need to install `@tiptap/core`, `@tiptap/pm` and `@tiptap/starter-kit` in your project like this: + +```bash +npm install @tiptap/core @tiptap/pm @tiptap/starter-kit +``` + +After that, you can start using Tiptap in your project. To integrate it into your framework, please follow the guides below. + ## Integration guides - -* [Vanilla JavaScript](/installation/vanilla-javascript) -* [React](/installation/react) -* [Next.js](/installation/nextjs) -* [Vue 3](/installation/vue3) -* [Vue 2](/installation/vue2) -* [Nuxt.js](/installation/nuxt) -* [Svelte](/installation/svelte) -* [Alpine.js](/installation/alpine) -* [PHP](/installation/php) - -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please [read this](https://tiptap.dev/installation/peer-dependencies) to understand what is needed in that case. -::: + +- [Vanilla JavaScript](/installation/vanilla-javascript) +- [React](/installation/react) +- [Next.js](/installation/nextjs) +- [Vue 3](/installation/vue3) +- [Vue 2](/installation/vue2) +- [Nuxt.js](/installation/nuxt) +- [Svelte](/installation/svelte) +- [Alpine.js](/installation/alpine) +- [PHP](/installation/php) + ### Community efforts -* [Angular](https://github.com/sibiraj-s/ngx-tiptap) -* [SolidJS](https://github.com/LXSMNSYC/solid-tiptap) + +- [Angular](https://github.com/sibiraj-s/ngx-tiptap) +- [SolidJS](https://github.com/LXSMNSYC/solid-tiptap) diff --git a/docs/installation/alpine.md b/docs/installation/alpine.md index fd085c4c00..02c82bd9ef 100644 --- a/docs/installation/alpine.md +++ b/docs/installation/alpine.md @@ -28,16 +28,12 @@ npm run dev ## 2. Install the dependencies -Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For the following example you’ll need `alpinejs`, the `@tiptap/core` package and the `@tiptap/starter-kit` which has the most common extensions to get started quickly. +Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For the following example you’ll need `alpinejs`, the `@tiptap/core` package, the `@tiptap/pm` package and the `@tiptap/starter-kit` which has the most common extensions to get started quickly. ```bash -npm install alpinejs @tiptap/core @tiptap/starter-kit +npm install alpinejs @tiptap/core @tiptap/pm @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1, you can now start your project with `npm run dev`, and open [http://localhost:5173](http://localhost:5173) in your favorite browser. This might be different, if you’re working with an existing project. ## 3. Initialize the editor @@ -74,7 +70,7 @@ document.addEventListener('alpine:init', () => { onSelectionUpdate({ editor }) { _this.updatedAt = Date.now() } - }); + }) }, isLoaded() { return editor @@ -91,9 +87,9 @@ document.addEventListener('alpine:init', () => { toggleItalic() { editor.chain().toggleItalic().focus().run() }, - }; - }); -}); + } + }) +}) window.Alpine = Alpine Alpine.start() diff --git a/docs/installation/nextjs.md b/docs/installation/nextjs.md index 28e026af0b..156315f263 100644 --- a/docs/installation/nextjs.md +++ b/docs/installation/nextjs.md @@ -25,16 +25,12 @@ cd my-tiptap-project ``` ## 2. Install the dependencies -Now that we have a standard boilerplate set up we can get started on getting Tiptap up and running! For this we will need to install two packages: `@tiptap/react` and `@tiptap/starter-kit` which includes all the extensions you need to get started quickly. +Now that we have a standard boilerplate set up we can get started on getting Tiptap up and running! For this we will need to install three packages: `@tiptap/react`, `@tiptap/pm` and `@tiptap/starter-kit` which includes all the extensions you need to get started quickly. ```bash -npm install @tiptap/react @tiptap/starter-kit +npm install @tiptap/react @tiptap/pm @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1 and 2, you can now start your project with `npm run dev`, and open [http://localhost:3000/](http://localhost:3000/) in your favorite browser. This might be different, if you’re working with an existing project. ## 3. Create a new component @@ -57,7 +53,7 @@ const Tiptap = () => { ) } -export default Tiptap; +export default Tiptap ``` ## 4. Add it to your app diff --git a/docs/installation/nuxt.md b/docs/installation/nuxt.md index 832568f741..ebc2105512 100644 --- a/docs/installation/nuxt.md +++ b/docs/installation/nuxt.md @@ -26,16 +26,12 @@ cd my-tiptap-project ``` ## 2. Install the dependencies -Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For the following example you’ll need the `@tiptap/vue-2` package, with a few components, and `@tiptap/starter-kit` which has the most common extensions to get started quickly. +Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For the following example you’ll need the `@tiptap/vue-2` package with a few components, the `@tiptap/pm` package, and `@tiptap/starter-kit` which has the most common extensions to get started quickly. ```bash -npm install @tiptap/vue-2 @tiptap/starter-kit +npm install @tiptap/vue-2 @tiptap/pm @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1 and 2, you can now start your project with `npm run serve`, and open [http://localhost:8080/](http://localhost:8080/) in your favorite browser. This might be different, if you’re working with an existing project. ## 3. Create a new component diff --git a/docs/installation/peer-dependencies.md b/docs/installation/peer-dependencies.md deleted file mode 100644 index bc03f635f9..0000000000 --- a/docs/installation/peer-dependencies.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -tableOfContents: true ---- - -# Peer dependencies - -## Introduction -With the release of version 2.0.0-beta.205 we introduced peer dependencies. Most packages require the installation of peer dependencies. - -## Why peer dependencies -In the past it has happened that users installed ProseMirror or Yjs packages to develope their own extensions, which had a different version than the ones included in Tiptap. This has caused version clashes. - -## How to install - -### NPM 7 or higher -If you are using NPM 7 or higher, you can ignore the following notes. NPM installs peer dependencies automatically and no further action is required. - -### Yarn, pNPM, npm 6 or less - -#### @tiptap/core - -| Package manager | Command | -| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add prosemirror-commands prosemirror-keymap prosemirror-model prosemirror-schema-list prosemirror-state prosemirror-transform prosemirror-view` | -| pNPM | `pnpm install prosemirror-commands prosemirror-keymap prosemirror-model prosemirror-schema-list prosemirror-state prosemirror-transform prosemirror-view` | -| npm 6 or less | `npm install prosemirror-commands prosemirror-keymap prosemirror-model prosemirror-schema-list prosemirror-state prosemirror-transform prosemirror-view` | - - -#### @tiptap/starter-kit - -| Package manager | Command | -| ------------------ | ---------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add prosemirror-history prosemirror-dropcursor prosemirror-gapcursor` | -| pNPM | `pnpm install prosemirror-history prosemirror-dropcursor prosemirror-gapcursor` | -| npm 6 or less | `npm install prosemirror-history prosemirror-dropcursor prosemirror-gapcursor` | - - -#### @tiptap/extension-history - -| Package manager | Command | -| ------------------ | ---------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add prosemirror-history` | -| pNPM | `pnpm install prosemirror-history` | -| npm 6 or less | `npm install prosemirror-history` | - - -#### @tiptap/extension-gapcursor - -| Package manager | Command | -| ------------------ | ---------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add prosemirror-gapcursor` | -| pNPM | `pnpm install prosemirror-gapcursor` | -| npm 6 or less | `npm install prosemirror-gapcursor` | - - -#### @tiptap/extension-dropcursor - -| Package manager | Command | -| ------------------ | ---------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add prosemirror-dropcursor` | -| pNPM | `pnpm install prosemirror-dropcursor` | -| npm 6 or less | `npm install prosemirror-dropcursor` | - - -#### @tiptap/extension-collaboration - -| Package manager | Command | -| ------------------ | ---------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add y-prosemirror` | -| pNPM | `pnpm install y-prosemirror` | -| npm 6 or less | `npm install y-prosemirror` | - - -#### @tiptap/extension-collaboration-cursor - -| Package manager | Command | -| ------------------ | ---------------------------------------------------------------------------------------------------------- | -| Yarn | `yarn add y-prosemirror` | -| pNPM | `pnpm install y-prosemirror` | -| npm 6 or less | `npm install y-prosemirror` | diff --git a/docs/installation/react.md b/docs/installation/react.md index 8b5ab22fbc..590ed176ba 100644 --- a/docs/installation/react.md +++ b/docs/installation/react.md @@ -37,13 +37,9 @@ cd my-tiptap-project Time to install the `@tiptap/react` package and our [`StarterKit`](/api/extensions/starter-kit), which has the most popular extensions to get started quickly. ```bash -npm install @tiptap/react @tiptap/starter-kit +npm install @tiptap/react @tiptap/pm @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1 and 2, you can now start your project with `npm run start`, and open [http://localhost:3000](http://localhost:3000) in your browser. #### 3. Create a new component diff --git a/docs/installation/svelte.md b/docs/installation/svelte.md index 8a80a30d37..9e93176442 100644 --- a/docs/installation/svelte.md +++ b/docs/installation/svelte.md @@ -28,16 +28,12 @@ npm run dev ``` ## 2. Install the dependencies -Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For the following example you’ll need the `@tiptap/core` package, with a few components, and `@tiptap/starter-kit` which has the most common extensions to get started quickly. +Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For the following example you’ll need the `@tiptap/core` package, with a few components, `@tiptap/pm` and `@tiptap/starter-kit` which has the most common extensions to get started quickly. ```bash -npm install @tiptap/core @tiptap/starter-kit +npm install @tiptap/core @tiptap/pm @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1 and 2, you can now start your project with `npm run dev`, and open [http://localhost:3000/](http://localhost:3000/) in your favorite browser. This might be different, if you’re working with an existing project. ## 3. Create a new component diff --git a/docs/installation/vanilla-javascript.md b/docs/installation/vanilla-javascript.md index a3bda04ed8..bc1cd6afa2 100644 --- a/docs/installation/vanilla-javascript.md +++ b/docs/installation/vanilla-javascript.md @@ -9,18 +9,14 @@ tableOfContents: true You are using plain JavaScript or a framework that is not listed here? No worries, we provide everything you need. ## 1. Install the dependencies -For the following example you will need `@tiptap/core` (the actual editor) and `@tiptap/starter-kit`. +For the following example you will need `@tiptap/core` (the actual editor), `@tiptap/pm` (the ProseMirror library) and `@tiptap/starter-kit`. The StarterKit doesn’t include all, but the most common extensions. ```bash -npm install @tiptap/core @tiptap/starter-kit +npm install @tiptap/core @tiptap/pm @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - ## 2. Add some markup Add the following HTML where you want the editor to be mounted: diff --git a/docs/installation/vue2.md b/docs/installation/vue2.md index 9fdf5ebeaa..39326addfb 100644 --- a/docs/installation/vue2.md +++ b/docs/installation/vue2.md @@ -33,10 +33,6 @@ Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For npm install @tiptap/vue-2 @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1 and 2, you can now start your project with `npm run dev`, and open [http://localhost:8080](http://localhost:8080) in your favorite browser. This might be different, if you’re working with an existing project. ## 3. Create a new component diff --git a/docs/installation/vue3.md b/docs/installation/vue3.md index 5de7c0f206..91c5d29e0d 100644 --- a/docs/installation/vue3.md +++ b/docs/installation/vue3.md @@ -33,10 +33,6 @@ Okay, enough of the boring boilerplate work. Let’s finally install Tiptap! For npm install @tiptap/vue-3 @tiptap/starter-kit ``` -:::warning Are you using Yarn, pNPM, npm 6 or less? -Unfortunately your package manager does not install peer dependencies automatically and you have to install them by your own. Please check the following links to find out what dependencies are needed and how to install them: [@tiptap/core](https://tiptap.dev/installation/peer-dependencies#tiptapcore), [@tiptap/starter-kit](https://tiptap.dev/installation/peer-dependencies#tiptapstarter-kit) -::: - If you followed step 1 and 2, you can now start your project with `npm run serve`, and open [http://localhost:8080](http://localhost:8080) in your favorite browser. This might be different, if you’re working with an existing project. ## 3. Create a new component diff --git a/docs/introduction.md b/docs/introduction.md index 126472edd5..9ecce8339a 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -10,7 +10,7 @@ tableOfContents: true [![License](https://img.shields.io/npm/l/@tiptap/core.svg)](https://www.npmjs.com/package/@tiptap/core) [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis) -tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. +Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. Create exactly the rich text editor you want out of customizable building blocks. Tiptap comes with sensible defaults, a lot of extensions and a friendly API to customize every aspect. It’s backed by a welcoming community, open source, and free. diff --git a/docs/links.yaml b/docs/links.yaml index d266774928..72347dcada 100644 --- a/docs/links.yaml +++ b/docs/links.yaml @@ -120,6 +120,8 @@ items: - title: Configuration link: /guide/configuration + - title: ProseMirror + link: /guide/prosemirror - title: Menus link: /guide/menus - title: Styling diff --git a/package-lock.json b/package-lock.json index 659d9cb9bb..1a00004145 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "lerna": "^5.5.1", "lint-staged": "^13.0.3", "minimist": "^1.2.5", - "ts-loader": "^9.2.6", + "ts-loader": "9.3.1", "tsup": "^6.5.0", "typescript": "4.7.4", "webpack": "^5.68.0" @@ -69,7 +69,7 @@ "sass": "^1.49.7", "svelte": "^3.49.0", "tailwindcss": "^2.2.19", - "typescript": "^4.5.5", + "typescript": "4.7.4", "uuid": "^8.3.2", "vite": "^2.9.13", "vite-plugin-checker": "^0.3.4", @@ -1628,7 +1628,6 @@ }, "node_modules/@babel/runtime": { "version": "7.18.3", - "dev": true, "license": "MIT", "dependencies": { "regenerator-runtime": "^0.13.4" @@ -5419,6 +5418,10 @@ "version": "3.0.3", "license": "MIT" }, + "node_modules/@linaria/core": { + "version": "3.0.0-beta.13", + "license": "MIT" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -6075,6 +6078,51 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@remirror/core-constants": { + "version": "2.0.0", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.13.10" + } + }, + "node_modules/@remirror/core-helpers": { + "version": "2.0.1", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@linaria/core": "3.0.0-beta.13", + "@remirror/core-constants": "^2.0.0", + "@remirror/types": "^1.0.0", + "@types/object.omit": "^3.0.0", + "@types/object.pick": "^1.3.1", + "@types/throttle-debounce": "^2.1.0", + "case-anything": "^2.1.10", + "dash-get": "^1.0.2", + "deepmerge": "^4.2.2", + "fast-deep-equal": "^3.1.3", + "make-error": "^1.3.6", + "object.omit": "^3.0.0", + "object.pick": "^1.3.0", + "throttle-debounce": "^3.0.1" + } + }, + "node_modules/@remirror/types": { + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "type-fest": "^2.0.0" + } + }, + "node_modules/@remirror/types/node_modules/type-fest": { + "version": "2.19.0", + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@sveltejs/vite-plugin-svelte": { "version": "1.0.0-next.49", "dev": true, @@ -6312,17 +6360,9 @@ "resolved": "packages/html", "link": true }, - "node_modules/@tiptap/prosemirror-tables": { - "version": "1.1.3", - "dev": true, - "license": "MIT", - "dependencies": { - "prosemirror-keymap": "^1.1.2", - "prosemirror-model": "^1.8.1", - "prosemirror-state": "^1.3.1", - "prosemirror-transform": "^1.2.1", - "prosemirror-view": "^1.13.3" - } + "node_modules/@tiptap/pm": { + "resolved": "packages/pm", + "link": true }, "node_modules/@tiptap/react": { "resolved": "packages/react", @@ -6417,6 +6457,14 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/object.omit": { + "version": "3.0.0", + "license": "MIT" + }, + "node_modules/@types/object.pick": { + "version": "1.3.2", + "license": "MIT" + }, "node_modules/@types/parse-json": { "version": "4.0.0", "dev": true, @@ -6460,6 +6508,10 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/throttle-debounce": { + "version": "2.1.0", + "license": "MIT" + }, "node_modules/@types/unist": { "version": "2.0.6", "license": "MIT" @@ -7269,7 +7321,6 @@ }, "node_modules/argparse": { "version": "2.0.1", - "dev": true, "license": "Python-2.0" }, "node_modules/array-differ": { @@ -7899,6 +7950,16 @@ ], "license": "CC-BY-4.0" }, + "node_modules/case-anything": { + "version": "2.1.10", + "license": "MIT", + "engines": { + "node": ">=12.13" + }, + "funding": { + "url": "https://github.com/sponsors/mesqueeb" + } + }, "node_modules/caseless": { "version": "0.12.0", "dev": true, @@ -8447,6 +8508,10 @@ "node": ">=10" } }, + "node_modules/crelt": { + "version": "1.0.5", + "license": "MIT" + }, "node_modules/cross-spawn": { "version": "7.0.3", "dev": true, @@ -9021,6 +9086,10 @@ "node": ">=8" } }, + "node_modules/dash-get": { + "version": "1.0.2", + "license": "MIT" + }, "node_modules/dashdash": { "version": "1.14.1", "dev": true, @@ -9111,7 +9180,6 @@ }, "node_modules/deepmerge": { "version": "4.2.2", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -9439,7 +9507,6 @@ }, "node_modules/entities": { "version": "3.0.1", - "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.12" @@ -10212,7 +10279,6 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", - "dev": true, "license": "MIT" }, "node_modules/fast-glob": { @@ -11573,6 +11639,26 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-extendable": { + "version": "1.0.1", + "license": "MIT", + "dependencies": { + "is-plain-object": "^2.0.4" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-extendable/node_modules/is-plain-object": { + "version": "2.0.4", + "license": "MIT", + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "license": "MIT", @@ -11824,7 +11910,6 @@ }, "node_modules/isobject": { "version": "3.0.1", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -12428,6 +12513,13 @@ "dev": true, "license": "MIT" }, + "node_modules/linkify-it": { + "version": "4.0.1", + "license": "MIT", + "dependencies": { + "uc.micro": "^1.0.1" + } + }, "node_modules/linkifyjs": { "version": "3.0.5", "license": "MIT" @@ -13165,6 +13257,10 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-error": { + "version": "1.3.6", + "license": "ISC" + }, "node_modules/make-fetch-happen": { "version": "10.2.1", "dev": true, @@ -13210,6 +13306,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/markdown-it": { + "version": "13.0.1", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "~3.0.1", + "linkify-it": "^4.0.1", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + }, + "bin": { + "markdown-it": "bin/markdown-it.js" + } + }, + "node_modules/mdurl": { + "version": "1.0.1", + "license": "MIT" + }, "node_modules/meow": { "version": "8.1.2", "dev": true, @@ -14513,6 +14627,26 @@ "node": ">= 0.4" } }, + "node_modules/object.omit": { + "version": "3.0.0", + "license": "MIT", + "dependencies": { + "is-extendable": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object.pick": { + "version": "1.3.0", + "license": "MIT", + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object.values": { "version": "1.1.5", "dev": true, @@ -15318,9 +15452,22 @@ "read": "1" } }, + "node_modules/prosemirror-changeset": { + "version": "2.2.0", + "license": "MIT", + "dependencies": { + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-collab": { + "version": "1.3.0", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0" + } + }, "node_modules/prosemirror-commands": { "version": "1.3.1", - "dev": true, "license": "MIT", "dependencies": { "prosemirror-model": "^1.0.0", @@ -15330,7 +15477,6 @@ }, "node_modules/prosemirror-dropcursor": { "version": "1.5.0", - "dev": true, "license": "MIT", "dependencies": { "prosemirror-state": "^1.0.0", @@ -15340,7 +15486,6 @@ }, "node_modules/prosemirror-gapcursor": { "version": "1.3.1", - "dev": true, "license": "MIT", "dependencies": { "prosemirror-keymap": "^1.0.0", @@ -15351,7 +15496,6 @@ }, "node_modules/prosemirror-history": { "version": "1.3.0", - "dev": true, "license": "MIT", "dependencies": { "prosemirror-state": "^1.2.2", @@ -15359,25 +15503,56 @@ "rope-sequence": "^1.3.0" } }, + "node_modules/prosemirror-inputrules": { + "version": "1.2.0", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.0.0" + } + }, "node_modules/prosemirror-keymap": { "version": "1.2.0", - "dev": true, "license": "MIT", "dependencies": { "prosemirror-state": "^1.0.0", "w3c-keyname": "^2.2.0" } }, + "node_modules/prosemirror-markdown": { + "version": "1.10.1", + "license": "MIT", + "dependencies": { + "markdown-it": "^13.0.1", + "prosemirror-model": "^1.0.0" + } + }, + "node_modules/prosemirror-menu": { + "version": "1.2.1", + "license": "MIT", + "dependencies": { + "crelt": "^1.0.0", + "prosemirror-commands": "^1.0.0", + "prosemirror-history": "^1.0.0", + "prosemirror-state": "^1.0.0" + } + }, "node_modules/prosemirror-model": { - "version": "1.18.1", + "version": "1.19.0", "license": "MIT", "dependencies": { "orderedmap": "^2.0.0" } }, + "node_modules/prosemirror-schema-basic": { + "version": "1.2.1", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.19.0" + } + }, "node_modules/prosemirror-schema-list": { "version": "1.2.2", - "dev": true, "license": "MIT", "dependencies": { "prosemirror-model": "^1.0.0", @@ -15393,6 +15568,42 @@ "prosemirror-transform": "^1.0.0" } }, + "node_modules/prosemirror-tables": { + "version": "1.3.2", + "license": "MIT", + "dependencies": { + "prosemirror-keymap": "^1.1.2", + "prosemirror-model": "^1.8.1", + "prosemirror-state": "^1.3.1", + "prosemirror-transform": "^1.2.1", + "prosemirror-view": "^1.13.3" + } + }, + "node_modules/prosemirror-trailing-node": { + "version": "2.0.3", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@remirror/core-constants": "^2.0.0", + "@remirror/core-helpers": "^2.0.1", + "escape-string-regexp": "^4.0.0" + }, + "peerDependencies": { + "prosemirror-model": "^1", + "prosemirror-state": "^1", + "prosemirror-view": "^1" + } + }, + "node_modules/prosemirror-trailing-node/node_modules/escape-string-regexp": { + "version": "4.0.0", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/prosemirror-transform": { "version": "1.7.0", "license": "MIT", @@ -15866,7 +16077,6 @@ }, "node_modules/regenerator-runtime": { "version": "0.13.9", - "dev": true, "license": "MIT" }, "node_modules/regenerator-transform": { @@ -16075,7 +16285,6 @@ }, "node_modules/rope-sequence": { "version": "1.3.3", - "dev": true, "license": "MIT" }, "node_modules/run-async": { @@ -17066,6 +17275,13 @@ "node": ">=0.8" } }, + "node_modules/throttle-debounce": { + "version": "3.0.1", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/throttleit": { "version": "1.0.0", "dev": true, @@ -17558,6 +17774,10 @@ "node": ">=4.2.0" } }, + "node_modules/uc.micro": { + "version": "1.0.6", + "license": "MIT" + }, "node_modules/uglify-js": { "version": "3.17.4", "dev": true, @@ -18056,7 +18276,6 @@ }, "node_modules/w3c-keyname": { "version": "2.2.4", - "dev": true, "license": "MIT" }, "node_modules/walk-up-path": { @@ -18579,26 +18798,14 @@ "version": "2.0.0-beta.209", "license": "MIT", "devDependencies": { - "prosemirror-commands": "^1.3.1", - "prosemirror-keymap": "^1.2.0", - "prosemirror-model": "^1.18.1", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.1", - "prosemirror-transform": "^1.7.0", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "prosemirror-commands": "^1.3.1", - "prosemirror-keymap": "^1.2.0", - "prosemirror-model": "^1.18.1", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.1", - "prosemirror-transform": "^1.7.0", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-blockquote": { @@ -18628,7 +18835,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-bubble-menu": { @@ -18636,23 +18843,21 @@ "version": "2.0.0-beta.209", "license": "MIT", "dependencies": { - "@tiptap/core": "^2.0.0-beta.209", "lodash": "^4.17.21", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", "tippy.js": "^6.3.7" }, "devDependencies": { - "@types/lodash": "^4.14.187" + "@types/lodash": "^4.14.187", + "prosemirror-state": "^1.4.1", + "prosemirror-view": "^1.28.2" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-bullet-list": { @@ -18667,7 +18872,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-character-count": { @@ -18676,17 +18881,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-code": { @@ -18701,7 +18904,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-code-block": { @@ -18710,15 +18913,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-code-block-lowlight": { @@ -18728,20 +18931,16 @@ "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", "@tiptap/extension-code-block": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/extension-code-block": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/extension-code-block": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-collaboration": { @@ -18750,7 +18949,7 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", + "@tiptap/pm": "^2.0.0-beta.209", "y-prosemirror": "1.0.20" }, "funding": { @@ -18758,9 +18957,8 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "y-prosemirror": "1.0.20" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-collaboration-cursor": { @@ -18776,7 +18974,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", + "@tiptap/core": "^2.0.0-beta.209", "y-prosemirror": "1.0.20" } }, @@ -18793,8 +18991,8 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/extension-text-style": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/extension-text-style": "^2.0.0-beta.209" } }, "packages/extension-document": { @@ -18809,7 +19007,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-dropcursor": { @@ -18818,15 +19016,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-dropcursor": "1.5.0" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-dropcursor": "1.5.0" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-floating-menu": { @@ -18838,17 +19036,15 @@ }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-focus": { @@ -18857,17 +19053,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-font-family": { @@ -18883,8 +19077,8 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/extension-text-style": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/extension-text-style": "^2.0.0-beta.209" } }, "packages/extension-gapcursor": { @@ -18893,15 +19087,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-gapcursor": "^1.3.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-gapcursor": "^1.3.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-hard-break": { @@ -18916,7 +19110,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-heading": { @@ -18931,7 +19125,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-highlight": { @@ -18946,7 +19140,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-history": { @@ -18955,15 +19149,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-history": "^1.3.0" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-history": "^1.3.0" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-horizontal-rule": { @@ -18972,15 +19166,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-image": { @@ -18995,7 +19189,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-italic": { @@ -19010,7 +19204,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-link": { @@ -19022,17 +19216,15 @@ }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-list-item": { @@ -19047,7 +19239,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-mention": { @@ -19056,19 +19248,17 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "@tiptap/suggestion": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209", + "@tiptap/suggestion": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/suggestion": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", + "@tiptap/suggestion": "^2.0.0-beta.209" } }, "packages/extension-ordered-list": { @@ -19083,7 +19273,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-paragraph": { @@ -19098,7 +19288,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-placeholder": { @@ -19107,19 +19297,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-strike": { @@ -19134,7 +19320,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-subscript": { @@ -19149,7 +19335,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-superscript": { @@ -19164,7 +19350,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-table": { @@ -19173,21 +19359,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "@tiptap/prosemirror-tables": "^1.1.3", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/prosemirror-tables": "^1.1.3", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-table-cell": { @@ -19202,7 +19382,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-table-header": { @@ -19217,7 +19397,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-table-row": { @@ -19232,7 +19412,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-task-item": { @@ -19241,15 +19421,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/extension-task-list": { @@ -19264,7 +19444,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-text": { @@ -19279,7 +19459,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-text-align": { @@ -19294,7 +19474,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-text-style": { @@ -19309,7 +19489,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-typography": { @@ -19324,7 +19504,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-underline": { @@ -19339,7 +19519,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/extension-youtube": { @@ -19354,7 +19534,7 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/html": { @@ -19366,15 +19546,47 @@ }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1" + "@tiptap/pm": "^2.0.0-beta.209" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" + } + }, + "packages/pm": { + "name": "@tiptap/pm", + "version": "2.0.0-beta.209", + "license": "MIT", + "dependencies": { + "prosemirror-changeset": "^2.2.0", + "prosemirror-collab": "^1.3.0", + "prosemirror-commands": "^1.3.1", + "prosemirror-dropcursor": "^1.5.0", + "prosemirror-gapcursor": "^1.3.1", + "prosemirror-history": "^1.3.0", + "prosemirror-inputrules": "^1.2.0", + "prosemirror-keymap": "^1.2.0", + "prosemirror-markdown": "^1.10.1", + "prosemirror-menu": "^1.2.1", + "prosemirror-model": "^1.18.1", + "prosemirror-schema-basic": "^1.2.0", + "prosemirror-schema-list": "^1.2.2", + "prosemirror-state": "^1.4.1", + "prosemirror-tables": "^1.3.0", + "prosemirror-trailing-node": "^2.0.2", + "prosemirror-transform": "^1.7.0", + "prosemirror-view": "^1.28.2" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.204", - "prosemirror-model": "^1.18.1" + "@tiptap/core": "^2.0.0-beta.209" } }, "packages/react": { @@ -19383,11 +19595,11 @@ "license": "MIT", "dependencies": { "@tiptap/extension-bubble-menu": "^2.0.0-beta.209", - "@tiptap/extension-floating-menu": "^2.0.0-beta.209", - "prosemirror-view": "^1.28.2" + "@tiptap/extension-floating-menu": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "@types/react": "^18.0.1", "@types/react-dom": "^18.0.0", "react": "^18.0.0", @@ -19398,7 +19610,8 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0" } @@ -19439,19 +19652,15 @@ "license": "MIT", "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" } }, "packages/vue-2": { @@ -19464,7 +19673,7 @@ }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^2.6.0" }, "funding": { @@ -19472,8 +19681,8 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-view": "^1.28.2", + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^2.6.0" } }, @@ -19492,8 +19701,7 @@ }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^3.0.0" }, "funding": { @@ -19501,9 +19709,8 @@ "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^3.0.0" } } @@ -20436,7 +20643,6 @@ }, "@babel/runtime": { "version": "7.18.3", - "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -23153,6 +23359,9 @@ "@lifeomic/attempt": { "version": "3.0.3" }, + "@linaria/core": { + "version": "3.0.0-beta.13" + }, "@nodelib/fs.scandir": { "version": "2.1.5", "requires": { @@ -23603,6 +23812,43 @@ "@popperjs/core": { "version": "2.11.5" }, + "@remirror/core-constants": { + "version": "2.0.0", + "requires": { + "@babel/runtime": "^7.13.10" + } + }, + "@remirror/core-helpers": { + "version": "2.0.1", + "requires": { + "@babel/runtime": "^7.13.10", + "@linaria/core": "3.0.0-beta.13", + "@remirror/core-constants": "^2.0.0", + "@remirror/types": "^1.0.0", + "@types/object.omit": "^3.0.0", + "@types/object.pick": "^1.3.1", + "@types/throttle-debounce": "^2.1.0", + "case-anything": "^2.1.10", + "dash-get": "^1.0.2", + "deepmerge": "^4.2.2", + "fast-deep-equal": "^3.1.3", + "make-error": "^1.3.6", + "object.omit": "^3.0.0", + "object.pick": "^1.3.0", + "throttle-debounce": "^3.0.1" + } + }, + "@remirror/types": { + "version": "1.0.0", + "requires": { + "type-fest": "^2.0.0" + }, + "dependencies": { + "type-fest": { + "version": "2.19.0" + } + } + }, "@sveltejs/vite-plugin-svelte": { "version": "1.0.0-next.49", "dev": true, @@ -23635,13 +23881,7 @@ "@tiptap/core": { "version": "file:packages/core", "requires": { - "prosemirror-commands": "^1.3.1", - "prosemirror-keymap": "^1.2.0", - "prosemirror-model": "^1.18.1", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.1", - "prosemirror-transform": "^1.7.0", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-blockquote": { @@ -23659,7 +23899,6 @@ "@tiptap/extension-bubble-menu": { "version": "file:packages/extension-bubble-menu", "requires": { - "@tiptap/core": "^2.0.0-beta.209", "@types/lodash": "^4.14.187", "lodash": "^4.17.21", "prosemirror-state": "^1.4.1", @@ -23677,8 +23916,7 @@ "version": "file:packages/extension-character-count", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-code": { @@ -23691,7 +23929,7 @@ "version": "file:packages/extension-code-block", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-code-block-lowlight": { @@ -23699,16 +23937,14 @@ "requires": { "@tiptap/core": "^2.0.0-beta.209", "@tiptap/extension-code-block": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-collaboration": { "version": "file:packages/extension-collaboration", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", + "@tiptap/pm": "^2.0.0-beta.209", "y-prosemirror": "1.0.20" } }, @@ -23736,15 +23972,14 @@ "version": "file:packages/extension-dropcursor", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-dropcursor": "1.5.0" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-floating-menu": { "version": "file:packages/extension-floating-menu", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "tippy.js": "^6.3.7" } }, @@ -23752,8 +23987,7 @@ "version": "file:packages/extension-focus", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-font-family": { @@ -23767,7 +24001,7 @@ "version": "file:packages/extension-gapcursor", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-gapcursor": "^1.3.1" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-hard-break": { @@ -23792,14 +24026,14 @@ "version": "file:packages/extension-history", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-history": "^1.3.0" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-horizontal-rule": { "version": "file:packages/extension-horizontal-rule", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-image": { @@ -23818,9 +24052,8 @@ "version": "file:packages/extension-link", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "linkifyjs": "^3.0.5", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209", + "linkifyjs": "^3.0.5" } }, "@tiptap/extension-list-item": { @@ -23833,9 +24066,8 @@ "version": "file:packages/extension-mention", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "@tiptap/suggestion": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209", + "@tiptap/suggestion": "^2.0.0-beta.209" } }, "@tiptap/extension-ordered-list": { @@ -23854,9 +24086,7 @@ "version": "file:packages/extension-placeholder", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-strike": { @@ -23881,10 +24111,7 @@ "version": "file:packages/extension-table", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "@tiptap/prosemirror-tables": "^1.1.3", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-table-cell": { @@ -23909,7 +24136,7 @@ "version": "file:packages/extension-task-item", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/extension-task-list": { @@ -23958,19 +24185,31 @@ "version": "file:packages/html", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", + "@tiptap/pm": "^2.0.0-beta.209", "zeed-dom": "^0.9.19" } }, - "@tiptap/prosemirror-tables": { - "version": "1.1.3", - "dev": true, + "@tiptap/pm": { + "version": "file:packages/pm", "requires": { - "prosemirror-keymap": "^1.1.2", - "prosemirror-model": "^1.8.1", - "prosemirror-state": "^1.3.1", - "prosemirror-transform": "^1.2.1", - "prosemirror-view": "^1.13.3" + "prosemirror-changeset": "^2.2.0", + "prosemirror-collab": "^1.3.0", + "prosemirror-commands": "^1.3.1", + "prosemirror-dropcursor": "^1.5.0", + "prosemirror-gapcursor": "^1.3.1", + "prosemirror-history": "^1.3.0", + "prosemirror-inputrules": "^1.2.0", + "prosemirror-keymap": "^1.2.0", + "prosemirror-markdown": "^1.10.1", + "prosemirror-menu": "^1.2.1", + "prosemirror-model": "^1.18.1", + "prosemirror-schema-basic": "^1.2.0", + "prosemirror-schema-list": "^1.2.2", + "prosemirror-state": "^1.4.1", + "prosemirror-tables": "^1.3.0", + "prosemirror-trailing-node": "^2.0.2", + "prosemirror-transform": "^1.7.0", + "prosemirror-view": "^1.28.2" } }, "@tiptap/react": { @@ -23979,9 +24218,9 @@ "@tiptap/core": "^2.0.0-beta.209", "@tiptap/extension-bubble-menu": "^2.0.0-beta.209", "@tiptap/extension-floating-menu": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "@types/react": "^18.0.1", "@types/react-dom": "^18.0.0", - "prosemirror-view": "^1.28.2", "react": "^18.0.0", "react-dom": "^18.0.0" } @@ -24014,9 +24253,7 @@ "version": "file:packages/suggestion", "requires": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" } }, "@tiptap/vue-2": { @@ -24025,7 +24262,7 @@ "@tiptap/core": "^2.0.0-beta.209", "@tiptap/extension-bubble-menu": "^2.0.0-beta.209", "@tiptap/extension-floating-menu": "^2.0.0-beta.209", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^2.6.0" }, "dependencies": { @@ -24041,8 +24278,7 @@ "@tiptap/core": "^2.0.0-beta.209", "@tiptap/extension-bubble-menu": "^2.0.0-beta.209", "@tiptap/extension-floating-menu": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^3.0.0" } }, @@ -24104,6 +24340,12 @@ "version": "2.4.1", "dev": true }, + "@types/object.omit": { + "version": "3.0.0" + }, + "@types/object.pick": { + "version": "1.3.2" + }, "@types/parse-json": { "version": "4.0.0", "dev": true @@ -24140,6 +24382,9 @@ "version": "2.3.3", "dev": true }, + "@types/throttle-debounce": { + "version": "2.1.0" + }, "@types/unist": { "version": "2.0.6" }, @@ -24697,8 +24942,7 @@ "dev": true }, "argparse": { - "version": "2.0.1", - "dev": true + "version": "2.0.1" }, "array-differ": { "version": "3.0.0", @@ -25077,6 +25321,9 @@ "version": "1.0.30001359", "dev": true }, + "case-anything": { + "version": "2.1.10" + }, "caseless": { "version": "0.12.0", "dev": true @@ -25450,6 +25697,9 @@ "yaml": "^1.10.0" } }, + "crelt": { + "version": "1.0.5" + }, "cross-spawn": { "version": "7.0.3", "dev": true, @@ -25805,6 +26055,9 @@ "version": "7.0.0", "dev": true }, + "dash-get": { + "version": "1.0.2" + }, "dashdash": { "version": "1.14.1", "dev": true, @@ -25857,8 +26110,7 @@ "dev": true }, "deepmerge": { - "version": "4.2.2", - "dev": true + "version": "4.2.2" }, "defaults": { "version": "1.0.4", @@ -26070,8 +26322,7 @@ } }, "entities": { - "version": "3.0.1", - "dev": true + "version": "3.0.1" }, "env-paths": { "version": "2.2.1", @@ -26573,8 +26824,7 @@ "dev": true }, "fast-deep-equal": { - "version": "3.1.3", - "dev": true + "version": "3.1.3" }, "fast-glob": { "version": "3.2.11", @@ -27432,6 +27682,20 @@ "version": "2.2.1", "dev": true }, + "is-extendable": { + "version": "1.0.1", + "requires": { + "is-plain-object": "^2.0.4" + }, + "dependencies": { + "is-plain-object": { + "version": "2.0.4", + "requires": { + "isobject": "^3.0.1" + } + } + } + }, "is-extglob": { "version": "2.1.1" }, @@ -27569,8 +27833,7 @@ "dev": true }, "isobject": { - "version": "3.0.1", - "dev": true + "version": "3.0.1" }, "isomorphic.js": { "version": "0.2.5" @@ -27966,6 +28229,12 @@ "version": "1.2.4", "dev": true }, + "linkify-it": { + "version": "4.0.1", + "requires": { + "uc.micro": "^1.0.1" + } + }, "linkifyjs": { "version": "3.0.5" }, @@ -28401,6 +28670,9 @@ "semver": "^6.0.0" } }, + "make-error": { + "version": "1.3.6" + }, "make-fetch-happen": { "version": "10.2.1", "dev": true, @@ -28433,6 +28705,19 @@ "version": "4.3.0", "dev": true }, + "markdown-it": { + "version": "13.0.1", + "requires": { + "argparse": "^2.0.1", + "entities": "~3.0.1", + "linkify-it": "^4.0.1", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + } + }, + "mdurl": { + "version": "1.0.1" + }, "meow": { "version": "8.1.2", "dev": true, @@ -29281,6 +29566,18 @@ "es-abstract": "^1.19.1" } }, + "object.omit": { + "version": "3.0.0", + "requires": { + "is-extendable": "^1.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "requires": { + "isobject": "^3.0.1" + } + }, "object.values": { "version": "1.1.5", "dev": true, @@ -29758,9 +30055,20 @@ "read": "1" } }, + "prosemirror-changeset": { + "version": "2.2.0", + "requires": { + "prosemirror-transform": "^1.0.0" + } + }, + "prosemirror-collab": { + "version": "1.3.0", + "requires": { + "prosemirror-state": "^1.0.0" + } + }, "prosemirror-commands": { "version": "1.3.1", - "dev": true, "requires": { "prosemirror-model": "^1.0.0", "prosemirror-state": "^1.0.0", @@ -29769,7 +30077,6 @@ }, "prosemirror-dropcursor": { "version": "1.5.0", - "dev": true, "requires": { "prosemirror-state": "^1.0.0", "prosemirror-transform": "^1.1.0", @@ -29778,7 +30085,6 @@ }, "prosemirror-gapcursor": { "version": "1.3.1", - "dev": true, "requires": { "prosemirror-keymap": "^1.0.0", "prosemirror-model": "^1.0.0", @@ -29788,30 +30094,56 @@ }, "prosemirror-history": { "version": "1.3.0", - "dev": true, "requires": { "prosemirror-state": "^1.2.2", "prosemirror-transform": "^1.0.0", "rope-sequence": "^1.3.0" } }, + "prosemirror-inputrules": { + "version": "1.2.0", + "requires": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.0.0" + } + }, "prosemirror-keymap": { "version": "1.2.0", - "dev": true, "requires": { "prosemirror-state": "^1.0.0", "w3c-keyname": "^2.2.0" } }, + "prosemirror-markdown": { + "version": "1.10.1", + "requires": { + "markdown-it": "^13.0.1", + "prosemirror-model": "^1.0.0" + } + }, + "prosemirror-menu": { + "version": "1.2.1", + "requires": { + "crelt": "^1.0.0", + "prosemirror-commands": "^1.0.0", + "prosemirror-history": "^1.0.0", + "prosemirror-state": "^1.0.0" + } + }, "prosemirror-model": { - "version": "1.18.1", + "version": "1.19.0", "requires": { "orderedmap": "^2.0.0" } }, + "prosemirror-schema-basic": { + "version": "1.2.1", + "requires": { + "prosemirror-model": "^1.19.0" + } + }, "prosemirror-schema-list": { "version": "1.2.2", - "dev": true, "requires": { "prosemirror-model": "^1.0.0", "prosemirror-state": "^1.0.0", @@ -29825,6 +30157,30 @@ "prosemirror-transform": "^1.0.0" } }, + "prosemirror-tables": { + "version": "1.3.2", + "requires": { + "prosemirror-keymap": "^1.1.2", + "prosemirror-model": "^1.8.1", + "prosemirror-state": "^1.3.1", + "prosemirror-transform": "^1.2.1", + "prosemirror-view": "^1.13.3" + } + }, + "prosemirror-trailing-node": { + "version": "2.0.3", + "requires": { + "@babel/runtime": "^7.13.10", + "@remirror/core-constants": "^2.0.0", + "@remirror/core-helpers": "^2.0.1", + "escape-string-regexp": "^4.0.0" + }, + "dependencies": { + "escape-string-regexp": { + "version": "4.0.0" + } + } + }, "prosemirror-transform": { "version": "1.7.0", "requires": { @@ -30142,8 +30498,7 @@ } }, "regenerator-runtime": { - "version": "0.13.9", - "dev": true + "version": "0.13.9" }, "regenerator-transform": { "version": "0.15.0", @@ -30273,8 +30628,7 @@ } }, "rope-sequence": { - "version": "1.3.3", - "dev": true + "version": "1.3.3" }, "run-async": { "version": "2.4.1", @@ -30887,6 +31241,9 @@ "thenify": ">= 3.1.0 < 4" } }, + "throttle-debounce": { + "version": "3.0.1" + }, "throttleit": { "version": "1.0.0", "dev": true @@ -30935,7 +31292,7 @@ "simplify-js": "^1.2.4", "svelte": "^3.49.0", "tailwindcss": "^2.2.19", - "typescript": "^4.5.5", + "typescript": "4.7.4", "uuid": "^8.3.2", "vite": "^2.9.13", "vite-plugin-checker": "^0.3.4", @@ -31231,6 +31588,9 @@ "version": "4.7.4", "dev": true }, + "uc.micro": { + "version": "1.0.6" + }, "uglify-js": { "version": "3.17.4", "dev": true, @@ -31535,8 +31895,7 @@ } }, "w3c-keyname": { - "version": "2.2.4", - "dev": true + "version": "2.2.4" }, "walk-up-path": { "version": "1.0.0", diff --git a/package.json b/package.json index 3d0c64336a..5801090a3d 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,10 @@ "lint": "eslint --quiet --no-error-on-unmatched-pattern ./", "lint:fix": "eslint --fix --quiet --no-error-on-unmatched-pattern ./", "lint:staged": "lint-staged", - "test:open": "cypress open --project tests", - "test": "cypress run --project tests", - "build": "npm run clean:packages && lerna run build", + "test:open": "npm run build:pm && cypress open --project tests", + "test": "npm run build:pm && cypress run --project tests", + "build": "npm run clean:packages && npm run clean:packs && lerna run build", + "build:pm": "npm --prefix ./packages/pm run build", "build:demos": "npm --prefix ./demos run build:demos", "build:ci": "npm run build", "release:major": "lerna version major --force-publish", @@ -26,9 +27,10 @@ "release:patch:pre": "lerna version prepatch --force-publish", "release:pre": "lerna version prerelease --force-publish", "publish": "npm run build:packages && lerna exec --since --no-private -- npm publish --access public", - "pack": "lerna exec -- npm pack", - "clean:packages": "rm -rf ./packages/*/dist", - "reset": "npm run clean:packages && rm -rf ./**/.cache && rm -rf ./**/node_modules && rm -rf ./package-lock.json && npm install", + "pack": "npm run clean:packs && lerna exec -- npm pack", + "clean:packages": "rm -rf ./packages/*/dist && rm -rf ./packages/pm/*/dist", + "clean:packs": "rm -rf ./packages/*/*.tgz", + "reset": "npm run clean:packages && npm run clean:packs && rm -rf ./**/.cache && rm -rf ./**/node_modules && rm -rf ./package-lock.json && npm install", "prepare": "husky install" }, "devDependencies": { @@ -56,7 +58,7 @@ "lerna": "^5.5.1", "lint-staged": "^13.0.3", "minimist": "^1.2.5", - "ts-loader": "^9.2.6", + "ts-loader": "9.3.1", "tsup": "^6.5.0", "typescript": "4.7.4", "webpack": "^5.68.0" diff --git a/packages/core/package.json b/packages/core/package.json index 53c0899502..31ea8e1108 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -31,22 +31,10 @@ "dist" ], "peerDependencies": { - "prosemirror-commands": "^1.3.1", - "prosemirror-keymap": "^1.2.0", - "prosemirror-model": "^1.18.1", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.1", - "prosemirror-transform": "^1.7.0", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { - "prosemirror-commands": "^1.3.1", - "prosemirror-keymap": "^1.2.0", - "prosemirror-model": "^1.18.1", - "prosemirror-schema-list": "^1.2.2", - "prosemirror-state": "^1.4.1", - "prosemirror-transform": "^1.7.0", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/core/src/CommandManager.ts b/packages/core/src/CommandManager.ts index 7e4dd561da..ae87c89bc1 100644 --- a/packages/core/src/CommandManager.ts +++ b/packages/core/src/CommandManager.ts @@ -1,27 +1,19 @@ -import { EditorState, Transaction } from 'prosemirror-state' +import { EditorState, Transaction } from '@tiptap/pm/state' import { Editor } from './Editor' import { createChainableState } from './helpers/createChainableState' import { - AnyCommands, - CanCommands, - ChainedCommands, - CommandProps, - SingleCommands, + AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands, } from './types' export class CommandManager { - editor: Editor rawCommands: AnyCommands customState?: EditorState - constructor(props: { - editor: Editor, - state?: EditorState, - }) { + constructor(props: { editor: Editor; state?: EditorState }) { this.editor = props.editor this.rawCommands = this.editor.extensionManager.commands this.customState = props.state @@ -41,9 +33,8 @@ export class CommandManager { const { tr } = state const props = this.buildProps(tr) - return Object.fromEntries(Object - .entries(rawCommands) - .map(([name, command]) => { + return Object.fromEntries( + Object.entries(rawCommands).map(([name, command]) => { const method = (...args: any[]) => { const callback = command(...args)(props) @@ -55,7 +46,8 @@ export class CommandManager { } return [name, method] - })) as unknown as SingleCommands + }), + ) as unknown as SingleCommands } get chain(): () => ChainedCommands { @@ -87,18 +79,20 @@ export class CommandManager { } const chain = { - ...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => { - const chainedCommand = (...args: never[]) => { - const props = this.buildProps(tr, shouldDispatch) - const callback = command(...args)(props) + ...Object.fromEntries( + Object.entries(rawCommands).map(([name, command]) => { + const chainedCommand = (...args: never[]) => { + const props = this.buildProps(tr, shouldDispatch) + const callback = command(...args)(props) - callbacks.push(callback) + callbacks.push(callback) - return chain - } + return chain + } - return [name, chainedCommand] - })), + return [name, chainedCommand] + }), + ), run, } as unknown as ChainedCommands @@ -110,11 +104,11 @@ export class CommandManager { const dispatch = false const tr = startTr || state.tr const props = this.buildProps(tr, dispatch) - const formattedCommands = Object.fromEntries(Object - .entries(rawCommands) - .map(([name, command]) => { + const formattedCommands = Object.fromEntries( + Object.entries(rawCommands).map(([name, command]) => { return [name, (...args: never[]) => command(...args)({ ...props, dispatch: undefined })] - })) as unknown as SingleCommands + }), + ) as unknown as SingleCommands return { ...formattedCommands, @@ -138,21 +132,18 @@ export class CommandManager { state, transaction: tr, }), - dispatch: shouldDispatch - ? () => undefined - : undefined, + dispatch: shouldDispatch ? () => undefined : undefined, chain: () => this.createChain(tr), can: () => this.createCan(tr), get commands() { - return Object.fromEntries(Object - .entries(rawCommands) - .map(([name, command]) => { + return Object.fromEntries( + Object.entries(rawCommands).map(([name, command]) => { return [name, (...args: never[]) => command(...args)(props)] - })) as unknown as SingleCommands + }), + ) as unknown as SingleCommands }, } return props } - } diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index e059273cac..ab60bcd2ec 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -1,11 +1,8 @@ -import { MarkType, NodeType, Schema } from 'prosemirror-model' +import { MarkType, NodeType, Schema } from '@tiptap/pm/model' import { - EditorState, - Plugin, - PluginKey, - Transaction, -} from 'prosemirror-state' -import { EditorView } from 'prosemirror-view' + EditorState, Plugin, PluginKey, Transaction, +} from '@tiptap/pm/state' +import { EditorView } from '@tiptap/pm/view' import { CommandManager } from './CommandManager' import { EventEmitter } from './EventEmitter' @@ -39,7 +36,6 @@ export interface HTMLElement { } export class Editor extends EventEmitter { - private commandManager!: CommandManager public extensionManager!: ExtensionManager @@ -182,9 +178,7 @@ export class Editor extends EventEmitter { // since plugins are applied after creating the view // `editable` is always `true` for one tick. // that’s why we also have to check for `options.editable` - return this.options.editable - && this.view - && this.view.editable + return this.options.editable && this.view && this.view.editable } /** @@ -200,7 +194,10 @@ export class Editor extends EventEmitter { * @param plugin A ProseMirror plugin * @param handlePlugins Control how to merge the plugin into the existing plugins. */ - public registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void { + public registerPlugin( + plugin: Plugin, + handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[], + ): void { const plugins = isFunction(handlePlugins) ? handlePlugins(plugin, [...this.state.plugins]) : [...this.state.plugins, plugin] @@ -220,10 +217,8 @@ export class Editor extends EventEmitter { return } - const name = typeof nameOrPluginKey === 'string' - ? `${nameOrPluginKey}$` - // @ts-ignore - : nameOrPluginKey.key + // @ts-ignore + const name = typeof nameOrPluginKey === 'string' ? `${nameOrPluginKey}$` : nameOrPluginKey.key const state = this.state.reconfigure({ // @ts-ignore @@ -237,9 +232,7 @@ export class Editor extends EventEmitter { * Creates an extension manager. */ private createExtensionManager(): void { - const coreExtensions = this.options.enableCoreExtensions - ? Object.values(extensions) - : [] + const coreExtensions = this.options.enableCoreExtensions ? Object.values(extensions) : [] const allExtensions = [...coreExtensions, ...this.options.extensions].filter(extension => { return ['extension', 'node', 'mark'].includes(extension?.type) }) @@ -397,16 +390,12 @@ export class Editor extends EventEmitter { * @param name Name of the node or mark * @param attributes Attributes of the node or mark */ - public isActive(name: string, attributes?: {}): boolean; - public isActive(attributes: {}): boolean; + public isActive(name: string, attributes?: {}): boolean + public isActive(attributes: {}): boolean public isActive(nameOrAttributes: string, attributesOrUndefined?: {}): boolean { - const name = typeof nameOrAttributes === 'string' - ? nameOrAttributes - : null + const name = typeof nameOrAttributes === 'string' ? nameOrAttributes : null - const attributes = typeof nameOrAttributes === 'string' - ? attributesOrUndefined - : nameOrAttributes + const attributes = typeof nameOrAttributes === 'string' ? attributesOrUndefined : nameOrAttributes return isActive(this.state, name, attributes) } @@ -429,13 +418,10 @@ export class Editor extends EventEmitter { * Get the document as text. */ public getText(options?: { - blockSeparator?: string, - textSerializers?: Record, + blockSeparator?: string + textSerializers?: Record }): string { - const { - blockSeparator = '\n\n', - textSerializers = {}, - } = options || {} + const { blockSeparator = '\n\n', textSerializers = {} } = options || {} return getText(this.state.doc, { blockSeparator, @@ -459,7 +445,9 @@ export class Editor extends EventEmitter { * @deprecated */ public getCharacterCount(): number { - console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.') + console.warn( + '[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.', + ) return this.state.doc.content.size - 2 } @@ -484,5 +472,4 @@ export class Editor extends EventEmitter { // @ts-ignore return !this.view?.docView } - } diff --git a/packages/core/src/Extension.ts b/packages/core/src/Extension.ts index c6a10afe98..3a0ca70223 100644 --- a/packages/core/src/Extension.ts +++ b/packages/core/src/Extension.ts @@ -1,4 +1,4 @@ -import { Plugin, Transaction } from 'prosemirror-state' +import { Plugin, Transaction } from '@tiptap/pm/state' import { ExtensionConfig } from '.' import { Editor } from './Editor' @@ -20,245 +20,265 @@ import { mergeDeep } from './utilities/mergeDeep' declare module '@tiptap/core' { interface ExtensionConfig { - [key: string]: any; + [key: string]: any /** * Name */ - name: string, + name: string /** * Priority */ - priority?: number, + priority?: number /** * Default options */ - defaultOptions?: Options, + defaultOptions?: Options /** * Default Options */ addOptions?: (this: { - name: string, - parent: Exclude>['addOptions'], undefined>, - }) => Options, + name: string + parent: Exclude>['addOptions'], undefined> + }) => Options /** * Default Storage */ addStorage?: (this: { - name: string, - options: Options, - parent: Exclude>['addStorage'], undefined>, - }) => Storage, + name: string + options: Options + parent: Exclude>['addStorage'], undefined> + }) => Storage /** * Global attributes */ addGlobalAttributes?: (this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addGlobalAttributes'], - }) => GlobalAttributes | {}, + name: string + options: Options + storage: Storage + parent: ParentConfig>['addGlobalAttributes'] + }) => GlobalAttributes | {} /** * Raw */ addCommands?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['addCommands'], - }) => Partial, + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['addCommands'] + }) => Partial /** * Keyboard shortcuts */ addKeyboardShortcuts?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['addKeyboardShortcuts'], + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['addKeyboardShortcuts'] }) => { - [key: string]: KeyboardShortcutCommand, - }, + [key: string]: KeyboardShortcutCommand + } /** * Input rules */ addInputRules?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['addInputRules'], - }) => InputRule[], + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['addInputRules'] + }) => InputRule[] /** * Paste rules */ addPasteRules?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['addPasteRules'], - }) => PasteRule[], + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['addPasteRules'] + }) => PasteRule[] /** * ProseMirror plugins */ addProseMirrorPlugins?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['addProseMirrorPlugins'], - }) => Plugin[], + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['addProseMirrorPlugins'] + }) => Plugin[] /** * Extensions */ addExtensions?: (this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addExtensions'], - }) => Extensions, + name: string + options: Options + storage: Storage + parent: ParentConfig>['addExtensions'] + }) => Extensions /** * Extend Node Schema */ - extendNodeSchema?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['extendNodeSchema'], - }, - extension: Node, - ) => Record) | null, + extendNodeSchema?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['extendNodeSchema'] + }, + extension: Node, + ) => Record) + | null /** * Extend Mark Schema */ - extendMarkSchema?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['extendMarkSchema'], - }, - extension: Mark, - ) => Record) | null, + extendMarkSchema?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['extendMarkSchema'] + }, + extension: Mark, + ) => Record) + | null /** * The editor is not ready yet. */ - onBeforeCreate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onBeforeCreate'], - }) => void) | null, + onBeforeCreate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onBeforeCreate'] + }) => void) + | null /** * The editor is ready. */ - onCreate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onCreate'], - }) => void) | null, + onCreate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onCreate'] + }) => void) + | null /** * The content has changed. */ - onUpdate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onUpdate'], - }) => void) | null, + onUpdate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onUpdate'] + }) => void) + | null /** * The selection has changed. */ - onSelectionUpdate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onSelectionUpdate'], - }) => void) | null, + onSelectionUpdate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onSelectionUpdate'] + }) => void) + | null /** * The editor state has changed. */ - onTransaction?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onTransaction'], - }, - props: { - transaction: Transaction, - }, - ) => void) | null, + onTransaction?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onTransaction'] + }, + props: { + transaction: Transaction + }, + ) => void) + | null /** * The editor is focused. */ - onFocus?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onFocus'], - }, - props: { - event: FocusEvent, - }, - ) => void) | null, + onFocus?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onFocus'] + }, + props: { + event: FocusEvent + }, + ) => void) + | null /** * The editor isn’t focused anymore. */ - onBlur?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onBlur'], - }, - props: { - event: FocusEvent, - }, - ) => void) | null, + onBlur?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onBlur'] + }, + props: { + event: FocusEvent + }, + ) => void) + | null /** * The editor is destroyed. */ - onDestroy?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - parent: ParentConfig>['onDestroy'], - }) => void) | null, + onDestroy?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + parent: ParentConfig>['onDestroy'] + }) => void) + | null } } @@ -289,30 +309,28 @@ export class Extension { this.name = this.config.name if (config.defaultOptions) { - console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`) + console.warn( + `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`, + ) } // TODO: remove `addOptions` fallback this.options = this.config.defaultOptions if (this.config.addOptions) { - this.options = callOrReturn(getExtensionField( - this, - 'addOptions', - { + this.options = callOrReturn( + getExtensionField(this, 'addOptions', { name: this.name, - }, - )) + }), + ) } - this.storage = callOrReturn(getExtensionField( - this, - 'addStorage', - { + this.storage = callOrReturn( + getExtensionField(this, 'addStorage', { name: this.name, options: this.options, - }, - )) || {} + }), + ) || {} } static create(config: Partial> = {}) { @@ -326,49 +344,45 @@ export class Extension { extension.options = mergeDeep(this.options as Record, options) as Options - extension.storage = callOrReturn(getExtensionField( - extension, - 'addStorage', - { + extension.storage = callOrReturn( + getExtensionField(extension, 'addStorage', { name: extension.name, options: extension.options, - }, - )) + }), + ) return extension } - extend(extendedConfig: Partial> = {}) { + extend( + extendedConfig: Partial> = {}, + ) { const extension = new Extension(extendedConfig) extension.parent = this this.child = extension - extension.name = extendedConfig.name - ? extendedConfig.name - : extension.parent.name + extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name if (extendedConfig.defaultOptions) { - console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`) + console.warn( + `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`, + ) } - extension.options = callOrReturn(getExtensionField( - extension, - 'addOptions', - { + extension.options = callOrReturn( + getExtensionField(extension, 'addOptions', { name: extension.name, - }, - )) + }), + ) - extension.storage = callOrReturn(getExtensionField( - extension, - 'addStorage', - { + extension.storage = callOrReturn( + getExtensionField(extension, 'addStorage', { name: extension.name, options: extension.options, - }, - )) + }), + ) return extension } diff --git a/packages/core/src/ExtensionManager.ts b/packages/core/src/ExtensionManager.ts index b00cd555a1..8f45a91485 100644 --- a/packages/core/src/ExtensionManager.ts +++ b/packages/core/src/ExtensionManager.ts @@ -1,7 +1,7 @@ -import { keymap } from 'prosemirror-keymap' -import { Node as ProsemirrorNode, Schema } from 'prosemirror-model' -import { Plugin } from 'prosemirror-state' -import { Decoration, EditorView } from 'prosemirror-view' +import { keymap } from '@tiptap/pm/keymap' +import { Node as ProsemirrorNode, Schema } from '@tiptap/pm/model' +import { Plugin } from '@tiptap/pm/state' +import { Decoration, EditorView } from '@tiptap/pm/view' import { Mark, NodeConfig } from '.' import { Editor } from './Editor' @@ -20,7 +20,6 @@ import { callOrReturn } from './utilities/callOrReturn' import { findDuplicates } from './utilities/findDuplicates' export class ExtensionManager { - editor: Editor schema: Schema @@ -64,21 +63,13 @@ export class ExtensionManager { this.editor.on('beforeCreate', onBeforeCreate) } - const onCreate = getExtensionField( - extension, - 'onCreate', - context, - ) + const onCreate = getExtensionField(extension, 'onCreate', context) if (onCreate) { this.editor.on('create', onCreate) } - const onUpdate = getExtensionField( - extension, - 'onUpdate', - context, - ) + const onUpdate = getExtensionField(extension, 'onUpdate', context) if (onUpdate) { this.editor.on('update', onUpdate) @@ -104,31 +95,19 @@ export class ExtensionManager { this.editor.on('transaction', onTransaction) } - const onFocus = getExtensionField( - extension, - 'onFocus', - context, - ) + const onFocus = getExtensionField(extension, 'onFocus', context) if (onFocus) { this.editor.on('focus', onFocus) } - const onBlur = getExtensionField( - extension, - 'onBlur', - context, - ) + const onBlur = getExtensionField(extension, 'onBlur', context) if (onBlur) { this.editor.on('blur', onBlur) } - const onDestroy = getExtensionField( - extension, - 'onDestroy', - context, - ) + const onDestroy = getExtensionField(extension, 'onDestroy', context) if (onDestroy) { this.editor.on('destroy', onDestroy) @@ -141,38 +120,41 @@ export class ExtensionManager { const duplicatedNames = findDuplicates(resolvedExtensions.map(extension => extension.name)) if (duplicatedNames.length) { - console.warn(`[tiptap warn]: Duplicate extension names found: [${duplicatedNames.map(item => `'${item}'`).join(', ')}]. This can lead to issues.`) + console.warn( + `[tiptap warn]: Duplicate extension names found: [${duplicatedNames + .map(item => `'${item}'`) + .join(', ')}]. This can lead to issues.`, + ) } return resolvedExtensions } static flatten(extensions: Extensions): Extensions { - return extensions - .map(extension => { - const context = { - name: extension.name, - options: extension.options, - storage: extension.storage, - } - - const addExtensions = getExtensionField( - extension, - 'addExtensions', - context, - ) - - if (addExtensions) { - return [ + return ( + extensions + .map(extension => { + const context = { + name: extension.name, + options: extension.options, + storage: extension.storage, + } + + const addExtensions = getExtensionField( extension, - ...this.flatten(addExtensions()), - ] - } + 'addExtensions', + context, + ) - return extension - }) - // `Infinity` will break TypeScript so we set a number that is probably high enough - .flat(10) + if (addExtensions) { + return [extension, ...this.flatten(addExtensions())] + } + + return extension + }) + // `Infinity` will break TypeScript so we set a number that is probably high enough + .flat(10) + ) } static sort(extensions: Extensions): Extensions { @@ -256,16 +238,14 @@ export class ExtensionManager { // bind exit handling if (extension.type === 'mark' && extension.config.exitable) { - defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: (extension as Mark) }) + defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension as Mark }) } if (addKeyboardShortcuts) { const bindings = Object.fromEntries( - Object - .entries(addKeyboardShortcuts()) - .map(([shortcut, method]) => { - return [shortcut, () => method({ editor })] - }), + Object.entries(addKeyboardShortcuts()).map(([shortcut, method]) => { + return [shortcut, () => method({ editor })] + }), ) defaultBindings = { ...defaultBindings, ...bindings } @@ -332,46 +312,50 @@ export class ExtensionManager { const { editor } = this const { nodeExtensions } = splitExtensions(this.extensions) - return Object.fromEntries(nodeExtensions - .filter(extension => !!getExtensionField(extension, 'addNodeView')) - .map(extension => { - const extensionAttributes = this.attributes.filter(attribute => attribute.type === extension.name) - const context = { - name: extension.name, - options: extension.options, - storage: extension.storage, - editor, - type: getNodeType(extension.name, this.schema), - } - const addNodeView = getExtensionField( - extension, - 'addNodeView', - context, - ) - - if (!addNodeView) { - return [] - } - - const nodeview = ( - node: ProsemirrorNode, - view: EditorView, - getPos: (() => number) | boolean, - decorations: Decoration[], - ) => { - const HTMLAttributes = getRenderedAttributes(node, extensionAttributes) - - return addNodeView()({ + return Object.fromEntries( + nodeExtensions + .filter(extension => !!getExtensionField(extension, 'addNodeView')) + .map(extension => { + const extensionAttributes = this.attributes.filter( + attribute => attribute.type === extension.name, + ) + const context = { + name: extension.name, + options: extension.options, + storage: extension.storage, editor, - node, - getPos, - decorations, - HTMLAttributes, + type: getNodeType(extension.name, this.schema), + } + const addNodeView = getExtensionField( extension, - }) - } + 'addNodeView', + context, + ) - return [extension.name, nodeview] - })) + if (!addNodeView) { + return [] + } + + const nodeview = ( + node: ProsemirrorNode, + view: EditorView, + getPos: (() => number) | boolean, + decorations: Decoration[], + ) => { + const HTMLAttributes = getRenderedAttributes(node, extensionAttributes) + + return addNodeView()({ + editor, + node, + getPos, + decorations, + HTMLAttributes, + extension, + }) + } + + return [extension.name, nodeview] + }), + ) } } diff --git a/packages/core/src/InputRule.ts b/packages/core/src/InputRule.ts index 545e413572..3d04c92da8 100644 --- a/packages/core/src/InputRule.ts +++ b/packages/core/src/InputRule.ts @@ -1,4 +1,4 @@ -import { EditorState, Plugin, TextSelection } from 'prosemirror-state' +import { EditorState, Plugin, TextSelection } from '@tiptap/pm/state' import { CommandManager } from './CommandManager' import { Editor } from './Editor' @@ -14,46 +14,47 @@ import { import { isRegExp } from './utilities/isRegExp' export type InputRuleMatch = { - index: number, - text: string, - replaceWith?: string, - match?: RegExpMatchArray, - data?: Record, + index: number + text: string + replaceWith?: string + match?: RegExpMatchArray + data?: Record } -export type InputRuleFinder = - | RegExp - | ((text: string) => InputRuleMatch | null) +export type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null) export class InputRule { find: InputRuleFinder handler: (props: { - state: EditorState, - range: Range, - match: ExtendedRegExpMatchArray, - commands: SingleCommands, - chain: () => ChainedCommands, - can: () => CanCommands, + state: EditorState + range: Range + match: ExtendedRegExpMatchArray + commands: SingleCommands + chain: () => ChainedCommands + can: () => CanCommands }) => void | null constructor(config: { - find: InputRuleFinder, + find: InputRuleFinder handler: (props: { - state: EditorState, - range: Range, - match: ExtendedRegExpMatchArray, - commands: SingleCommands, - chain: () => ChainedCommands, - can: () => CanCommands, - }) => void | null, + state: EditorState + range: Range + match: ExtendedRegExpMatchArray + commands: SingleCommands + chain: () => ChainedCommands + can: () => CanCommands + }) => void | null }) { this.find = config.find this.handler = config.handler } } -const inputRuleMatcherHandler = (text: string, find: InputRuleFinder): ExtendedRegExpMatchArray | null => { +const inputRuleMatcherHandler = ( + text: string, + find: InputRuleFinder, +): ExtendedRegExpMatchArray | null => { if (isRegExp(find)) { return find.exec(text) } @@ -72,7 +73,9 @@ const inputRuleMatcherHandler = (text: string, find: InputRuleFinder): ExtendedR if (inputRuleMatch.replaceWith) { if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) { - console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".') + console.warn( + '[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".', + ) } result.push(inputRuleMatch.replaceWith) @@ -82,20 +85,15 @@ const inputRuleMatcherHandler = (text: string, find: InputRuleFinder): ExtendedR } function run(config: { - editor: Editor, - from: number, - to: number, - text: string, - rules: InputRule[], - plugin: Plugin, + editor: Editor + from: number + to: number + text: string + rules: InputRule[] + plugin: Plugin }): boolean { const { - editor, - from, - to, - text, - rules, - plugin, + editor, from, to, text, rules, plugin, } = config const { view } = editor @@ -179,7 +177,7 @@ function run(config: { * input that matches any of the given rules to trigger the rule’s * action. */ -export function inputRulesPlugin(props: { editor: Editor, rules: InputRule[] }): Plugin { +export function inputRulesPlugin(props: { editor: Editor; rules: InputRule[] }): Plugin { const { editor, rules } = props const plugin = new Plugin({ state: { @@ -193,9 +191,7 @@ export function inputRulesPlugin(props: { editor: Editor, rules: InputRule[] }): return stored } - return tr.selectionSet || tr.docChanged - ? null - : prev + return tr.selectionSet || tr.docChanged ? null : prev }, }, diff --git a/packages/core/src/Mark.ts b/packages/core/src/Mark.ts index 1b9ca52d25..adf3c1d21a 100644 --- a/packages/core/src/Mark.ts +++ b/packages/core/src/Mark.ts @@ -1,10 +1,7 @@ import { - DOMOutputSpec, - Mark as ProseMirrorMark, - MarkSpec, - MarkType, -} from 'prosemirror-model' -import { Plugin, Transaction } from 'prosemirror-state' + DOMOutputSpec, Mark as ProseMirrorMark, MarkSpec, MarkType, +} from '@tiptap/pm/model' +import { Plugin, Transaction } from '@tiptap/pm/state' import { MarkConfig } from '.' import { Editor } from './Editor' @@ -26,358 +23,386 @@ import { mergeDeep } from './utilities/mergeDeep' declare module '@tiptap/core' { export interface MarkConfig { - [key: string]: any; + [key: string]: any /** * Name */ - name: string, + name: string /** * Priority */ - priority?: number, + priority?: number /** * Default options */ - defaultOptions?: Options, + defaultOptions?: Options /** * Default Options */ addOptions?: (this: { - name: string, - parent: Exclude>['addOptions'], undefined>, - }) => Options, + name: string + parent: Exclude>['addOptions'], undefined> + }) => Options /** * Default Storage */ addStorage?: (this: { - name: string, - options: Options, - parent: Exclude>['addStorage'], undefined>, - }) => Storage, + name: string + options: Options + parent: Exclude>['addStorage'], undefined> + }) => Storage /** * Global attributes */ addGlobalAttributes?: (this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addGlobalAttributes'], - }) => GlobalAttributes | {}, + name: string + options: Options + storage: Storage + parent: ParentConfig>['addGlobalAttributes'] + }) => GlobalAttributes | {} /** * Raw */ addCommands?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['addCommands'], - }) => Partial, + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['addCommands'] + }) => Partial /** * Keyboard shortcuts */ addKeyboardShortcuts?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['addKeyboardShortcuts'], + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['addKeyboardShortcuts'] }) => { - [key: string]: KeyboardShortcutCommand, - }, + [key: string]: KeyboardShortcutCommand + } /** * Input rules */ addInputRules?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['addInputRules'], - }) => InputRule[], + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['addInputRules'] + }) => InputRule[] /** * Paste rules */ addPasteRules?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['addPasteRules'], - }) => PasteRule[], + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['addPasteRules'] + }) => PasteRule[] /** * ProseMirror plugins */ addProseMirrorPlugins?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['addProseMirrorPlugins'], - }) => Plugin[], + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['addProseMirrorPlugins'] + }) => Plugin[] /** * Extensions */ addExtensions?: (this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addExtensions'], - }) => Extensions, + name: string + options: Options + storage: Storage + parent: ParentConfig>['addExtensions'] + }) => Extensions /** * Extend Node Schema */ - extendNodeSchema?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['extendNodeSchema'], - }, - extension: Node, - ) => Record) | null, + extendNodeSchema?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['extendNodeSchema'] + }, + extension: Node, + ) => Record) + | null /** * Extend Mark Schema */ - extendMarkSchema?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['extendMarkSchema'], - }, - extension: Mark, - ) => Record) | null, + extendMarkSchema?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['extendMarkSchema'] + }, + extension: Mark, + ) => Record) + | null /** * The editor is not ready yet. */ - onBeforeCreate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onBeforeCreate'], - }) => void) | null, + onBeforeCreate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onBeforeCreate'] + }) => void) + | null /** * The editor is ready. */ - onCreate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onCreate'], - }) => void) | null, + onCreate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onCreate'] + }) => void) + | null /** * The content has changed. */ - onUpdate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onUpdate'], - }) => void) | null, + onUpdate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onUpdate'] + }) => void) + | null /** * The selection has changed. */ - onSelectionUpdate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onSelectionUpdate'], - }) => void) | null, + onSelectionUpdate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onSelectionUpdate'] + }) => void) + | null /** * The editor state has changed. */ - onTransaction?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onTransaction'], - }, - props: { - transaction: Transaction, - }, - ) => void) | null, + onTransaction?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onTransaction'] + }, + props: { + transaction: Transaction + }, + ) => void) + | null /** * The editor is focused. */ - onFocus?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onFocus'], - }, - props: { - event: FocusEvent, - }, - ) => void) | null, + onFocus?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onFocus'] + }, + props: { + event: FocusEvent + }, + ) => void) + | null /** * The editor isn’t focused anymore. */ - onBlur?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onBlur'], - }, - props: { - event: FocusEvent, - }, - ) => void) | null, + onBlur?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onBlur'] + }, + props: { + event: FocusEvent + }, + ) => void) + | null /** * The editor is destroyed. */ - onDestroy?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: MarkType, - parent: ParentConfig>['onDestroy'], - }) => void) | null, + onDestroy?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: MarkType + parent: ParentConfig>['onDestroy'] + }) => void) + | null /** * Keep mark after split node */ - keepOnSplit?: boolean | (() => boolean), + keepOnSplit?: boolean | (() => boolean) /** * Inclusive */ - inclusive?: MarkSpec['inclusive'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['inclusive'], - }) => MarkSpec['inclusive']), + inclusive?: + | MarkSpec['inclusive'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['inclusive'] + }) => MarkSpec['inclusive']) /** * Excludes */ - excludes?: MarkSpec['excludes'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['excludes'], - }) => MarkSpec['excludes']), + excludes?: + | MarkSpec['excludes'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['excludes'] + }) => MarkSpec['excludes']) /** * Marks this Mark as exitable */ - exitable?: boolean | (() => boolean), + exitable?: boolean | (() => boolean) /** * Group */ - group?: MarkSpec['group'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['group'], - }) => MarkSpec['group']), + group?: + | MarkSpec['group'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['group'] + }) => MarkSpec['group']) /** * Spanning */ - spanning?: MarkSpec['spanning'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['spanning'], - }) => MarkSpec['spanning']), + spanning?: + | MarkSpec['spanning'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['spanning'] + }) => MarkSpec['spanning']) /** * Code */ - code?: boolean | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['code'], - }) => boolean), + code?: + | boolean + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['code'] + }) => boolean) /** * Parse HTML */ - parseHTML?: ( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['parseHTML'], - }, - ) => MarkSpec['parseDOM'], + parseHTML?: (this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['parseHTML'] + }) => MarkSpec['parseDOM'] /** * Render HTML */ - renderHTML?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['renderHTML'], - }, - props: { - mark: ProseMirrorMark, - HTMLAttributes: Record, - }, - ) => DOMOutputSpec) | null, + renderHTML?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['renderHTML'] + }, + props: { + mark: ProseMirrorMark + HTMLAttributes: Record + }, + ) => DOMOutputSpec) + | null /** * Attributes */ - addAttributes?: ( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addAttributes'], - }, - ) => Attributes | {}, + addAttributes?: (this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['addAttributes'] + }) => Attributes | {} } } @@ -408,30 +433,28 @@ export class Mark { this.name = this.config.name if (config.defaultOptions) { - console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`) + console.warn( + `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`, + ) } // TODO: remove `addOptions` fallback this.options = this.config.defaultOptions if (this.config.addOptions) { - this.options = callOrReturn(getExtensionField( - this, - 'addOptions', - { + this.options = callOrReturn( + getExtensionField(this, 'addOptions', { name: this.name, - }, - )) + }), + ) } - this.storage = callOrReturn(getExtensionField( - this, - 'addStorage', - { + this.storage = callOrReturn( + getExtensionField(this, 'addStorage', { name: this.name, options: this.options, - }, - )) || {} + }), + ) || {} } static create(config: Partial> = {}) { @@ -445,60 +468,50 @@ export class Mark { extension.options = mergeDeep(this.options as Record, options) as Options - extension.storage = callOrReturn(getExtensionField( - extension, - 'addStorage', - { + extension.storage = callOrReturn( + getExtensionField(extension, 'addStorage', { name: extension.name, options: extension.options, - }, - )) + }), + ) return extension } - extend(extendedConfig: Partial> = {}) { + extend( + extendedConfig: Partial> = {}, + ) { const extension = new Mark(extendedConfig) extension.parent = this this.child = extension - extension.name = extendedConfig.name - ? extendedConfig.name - : extension.parent.name + extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name if (extendedConfig.defaultOptions) { - console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`) + console.warn( + `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`, + ) } - extension.options = callOrReturn(getExtensionField( - extension, - 'addOptions', - { + extension.options = callOrReturn( + getExtensionField(extension, 'addOptions', { name: extension.name, - }, - )) + }), + ) - extension.storage = callOrReturn(getExtensionField( - extension, - 'addStorage', - { + extension.storage = callOrReturn( + getExtensionField(extension, 'addStorage', { name: extension.name, options: extension.options, - }, - )) + }), + ) return extension } - static handleExit({ - editor, - mark, - }: { - editor: Editor - mark: Mark - }) { + static handleExit({ editor, mark }: { editor: Editor; mark: Mark }) { const { tr } = editor.state const currentPos = editor.state.selection.$from const isAtEnd = currentPos.pos === currentPos.end() diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index 14323ef995..103e81914c 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -1,10 +1,7 @@ import { - DOMOutputSpec, - Node as ProseMirrorNode, - NodeSpec, - NodeType, -} from 'prosemirror-model' -import { Plugin, Transaction } from 'prosemirror-state' + DOMOutputSpec, Node as ProseMirrorNode, NodeSpec, NodeType, +} from '@tiptap/pm/model' +import { Plugin, Transaction } from '@tiptap/pm/state' import { NodeConfig } from '.' import { Editor } from './Editor' @@ -26,443 +23,487 @@ import { mergeDeep } from './utilities/mergeDeep' declare module '@tiptap/core' { interface NodeConfig { - [key: string]: any; + [key: string]: any /** * Name */ - name: string, + name: string /** * Priority */ - priority?: number, + priority?: number /** * Default options */ - defaultOptions?: Options, + defaultOptions?: Options /** * Default Options */ addOptions?: (this: { - name: string, - parent: Exclude>['addOptions'], undefined>, - }) => Options, + name: string + parent: Exclude>['addOptions'], undefined> + }) => Options /** * Default Storage */ addStorage?: (this: { - name: string, - options: Options, - parent: Exclude>['addStorage'], undefined>, - }) => Storage, + name: string + options: Options + parent: Exclude>['addStorage'], undefined> + }) => Storage /** * Global attributes */ addGlobalAttributes?: (this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addGlobalAttributes'], - }) => GlobalAttributes | {}, + name: string + options: Options + storage: Storage + parent: ParentConfig>['addGlobalAttributes'] + }) => GlobalAttributes | {} /** * Raw */ addCommands?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['addCommands'], - }) => Partial, + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['addCommands'] + }) => Partial /** * Keyboard shortcuts */ addKeyboardShortcuts?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['addKeyboardShortcuts'], + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['addKeyboardShortcuts'] }) => { - [key: string]: KeyboardShortcutCommand, - }, + [key: string]: KeyboardShortcutCommand + } /** * Input rules */ addInputRules?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['addInputRules'], - }) => InputRule[], + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['addInputRules'] + }) => InputRule[] /** * Paste rules */ addPasteRules?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['addPasteRules'], - }) => PasteRule[], + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['addPasteRules'] + }) => PasteRule[] /** * ProseMirror plugins */ addProseMirrorPlugins?: (this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['addProseMirrorPlugins'], - }) => Plugin[], + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['addProseMirrorPlugins'] + }) => Plugin[] /** * Extensions */ addExtensions?: (this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addExtensions'], - }) => Extensions, + name: string + options: Options + storage: Storage + parent: ParentConfig>['addExtensions'] + }) => Extensions /** * Extend Node Schema */ - extendNodeSchema?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['extendNodeSchema'], - }, - extension: Node, - ) => Record) | null, + extendNodeSchema?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['extendNodeSchema'] + }, + extension: Node, + ) => Record) + | null /** * Extend Mark Schema */ - extendMarkSchema?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['extendMarkSchema'], - }, - extension: Node, - ) => Record) | null, + extendMarkSchema?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['extendMarkSchema'] + }, + extension: Node, + ) => Record) + | null /** * The editor is not ready yet. */ - onBeforeCreate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onBeforeCreate'], - }) => void) | null, + onBeforeCreate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onBeforeCreate'] + }) => void) + | null /** * The editor is ready. */ - onCreate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onCreate'], - }) => void) | null, + onCreate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onCreate'] + }) => void) + | null /** * The content has changed. */ - onUpdate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onUpdate'], - }) => void) | null, + onUpdate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onUpdate'] + }) => void) + | null /** * The selection has changed. */ - onSelectionUpdate?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onSelectionUpdate'], - }) => void) | null, + onSelectionUpdate?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onSelectionUpdate'] + }) => void) + | null /** * The editor state has changed. */ - onTransaction?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onTransaction'], - }, - props: { - transaction: Transaction, - }, - ) => void) | null, + onTransaction?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onTransaction'] + }, + props: { + transaction: Transaction + }, + ) => void) + | null /** * The editor is focused. */ - onFocus?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onFocus'], - }, - props: { - event: FocusEvent, - }, - ) => void) | null, + onFocus?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onFocus'] + }, + props: { + event: FocusEvent + }, + ) => void) + | null /** * The editor isn’t focused anymore. */ - onBlur?: (( - this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onBlur'], - }, - props: { - event: FocusEvent, - }, - ) => void) | null, + onBlur?: + | (( + this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onBlur'] + }, + props: { + event: FocusEvent + }, + ) => void) + | null /** * The editor is destroyed. */ - onDestroy?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['onDestroy'], - }) => void) | null, + onDestroy?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['onDestroy'] + }) => void) + | null /** * Node View */ - addNodeView?: ((this: { - name: string, - options: Options, - storage: Storage, - editor: Editor, - type: NodeType, - parent: ParentConfig>['addNodeView'], - }) => NodeViewRenderer) | null, + addNodeView?: + | ((this: { + name: string + options: Options + storage: Storage + editor: Editor + type: NodeType + parent: ParentConfig>['addNodeView'] + }) => NodeViewRenderer) + | null /** * TopNode */ - topNode?: boolean, + topNode?: boolean /** * Content */ - content?: NodeSpec['content'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['content'], - }) => NodeSpec['content']), + content?: + | NodeSpec['content'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['content'] + }) => NodeSpec['content']) /** * Marks */ - marks?: NodeSpec['marks'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['marks'], - }) => NodeSpec['marks']), + marks?: + | NodeSpec['marks'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['marks'] + }) => NodeSpec['marks']) /** * Group */ - group?: NodeSpec['group'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['group'], - }) => NodeSpec['group']), + group?: + | NodeSpec['group'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['group'] + }) => NodeSpec['group']) /** * Inline */ - inline?: NodeSpec['inline'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['inline'], - }) => NodeSpec['inline']), + inline?: + | NodeSpec['inline'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['inline'] + }) => NodeSpec['inline']) /** * Atom */ - atom?: NodeSpec['atom'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['atom'], - }) => NodeSpec['atom']), + atom?: + | NodeSpec['atom'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['atom'] + }) => NodeSpec['atom']) /** * Selectable */ - selectable?: NodeSpec['selectable'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['selectable'], - }) => NodeSpec['selectable']), + selectable?: + | NodeSpec['selectable'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['selectable'] + }) => NodeSpec['selectable']) /** * Draggable */ - draggable?: NodeSpec['draggable'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['draggable'], - }) => NodeSpec['draggable']), + draggable?: + | NodeSpec['draggable'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['draggable'] + }) => NodeSpec['draggable']) /** * Code */ - code?: NodeSpec['code'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['code'], - }) => NodeSpec['code']), + code?: + | NodeSpec['code'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['code'] + }) => NodeSpec['code']) /** * Whitespace */ - whitespace?: NodeSpec['whitespace'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['whitespace'], - }) => NodeSpec['whitespace']), + whitespace?: + | NodeSpec['whitespace'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['whitespace'] + }) => NodeSpec['whitespace']) /** * Defining */ - defining?: NodeSpec['defining'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['defining'], - }) => NodeSpec['defining']), + defining?: + | NodeSpec['defining'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['defining'] + }) => NodeSpec['defining']) /** * Isolating */ - isolating?: NodeSpec['isolating'] | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['isolating'], - }) => NodeSpec['isolating']), + isolating?: + | NodeSpec['isolating'] + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['isolating'] + }) => NodeSpec['isolating']) /** * Parse HTML */ - parseHTML?: ( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['parseHTML'], - }, - ) => NodeSpec['parseDOM'], + parseHTML?: (this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['parseHTML'] + }) => NodeSpec['parseDOM'] /** * Render HTML */ - renderHTML?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['renderHTML'], - }, - props: { - node: ProseMirrorNode, - HTMLAttributes: Record, - } - ) => DOMOutputSpec) | null, + renderHTML?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['renderHTML'] + }, + props: { + node: ProseMirrorNode + HTMLAttributes: Record + }, + ) => DOMOutputSpec) + | null /** * Render Text */ - renderText?: (( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['renderText'], - }, - props: { - node: ProseMirrorNode, - pos: number, - parent: ProseMirrorNode, - index: number, - } - ) => string) | null, + renderText?: + | (( + this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['renderText'] + }, + props: { + node: ProseMirrorNode + pos: number + parent: ProseMirrorNode + index: number + }, + ) => string) + | null /** * Add Attributes */ - addAttributes?: ( - this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['addAttributes'], - }, - ) => Attributes | {}, + addAttributes?: (this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['addAttributes'] + }) => Attributes | {} } } @@ -493,30 +534,28 @@ export class Node { this.name = this.config.name if (config.defaultOptions) { - console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`) + console.warn( + `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`, + ) } // TODO: remove `addOptions` fallback this.options = this.config.defaultOptions if (this.config.addOptions) { - this.options = callOrReturn(getExtensionField( - this, - 'addOptions', - { + this.options = callOrReturn( + getExtensionField(this, 'addOptions', { name: this.name, - }, - )) + }), + ) } - this.storage = callOrReturn(getExtensionField( - this, - 'addStorage', - { + this.storage = callOrReturn( + getExtensionField(this, 'addStorage', { name: this.name, options: this.options, - }, - )) || {} + }), + ) || {} } static create(config: Partial> = {}) { @@ -530,49 +569,45 @@ export class Node { extension.options = mergeDeep(this.options as Record, options) as Options - extension.storage = callOrReturn(getExtensionField( - extension, - 'addStorage', - { + extension.storage = callOrReturn( + getExtensionField(extension, 'addStorage', { name: extension.name, options: extension.options, - }, - )) + }), + ) return extension } - extend(extendedConfig: Partial> = {}) { + extend( + extendedConfig: Partial> = {}, + ) { const extension = new Node(extendedConfig) extension.parent = this this.child = extension - extension.name = extendedConfig.name - ? extendedConfig.name - : extension.parent.name + extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name if (extendedConfig.defaultOptions) { - console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`) + console.warn( + `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`, + ) } - extension.options = callOrReturn(getExtensionField( - extension, - 'addOptions', - { + extension.options = callOrReturn( + getExtensionField(extension, 'addOptions', { name: extension.name, - }, - )) + }), + ) - extension.storage = callOrReturn(getExtensionField( - extension, - 'addStorage', - { + extension.storage = callOrReturn( + getExtensionField(extension, 'addStorage', { name: extension.name, options: extension.options, - }, - )) + }), + ) return extension } diff --git a/packages/core/src/NodeView.ts b/packages/core/src/NodeView.ts index 3ad241fb1b..c104e821f4 100644 --- a/packages/core/src/NodeView.ts +++ b/packages/core/src/NodeView.ts @@ -1,6 +1,6 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { NodeSelection } from 'prosemirror-state' -import { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { NodeSelection } from '@tiptap/pm/state' +import { Decoration, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view' import { Editor as CoreEditor } from './Editor' import { Node } from './Node' @@ -12,7 +12,6 @@ export class NodeView< Editor extends CoreEditor = CoreEditor, Options extends NodeViewRendererOptions = NodeViewRendererOptions, > implements ProseMirrorNodeView { - component: Component editor: Editor @@ -59,7 +58,7 @@ export class NodeView< onDragStart(event: DragEvent) { const { view } = this.editor - const target = (event.target as HTMLElement) + const target = event.target as HTMLElement // get the drag handle element // `closest` is not available for text nodes so we may have to use its parent @@ -67,11 +66,7 @@ export class NodeView< ? target.parentElement?.closest('[data-drag-handle]') : target.closest('[data-drag-handle]') - if ( - !this.dom - || this.contentDOM?.contains(target) - || !dragHandle - ) { + if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) { return } @@ -110,7 +105,7 @@ export class NodeView< return this.options.stopEvent({ event }) } - const target = (event.target as HTMLElement) + const target = event.target as HTMLElement const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target) // any event from child nodes should be handled by ProseMirror @@ -119,8 +114,7 @@ export class NodeView< } const isDropEvent = event.type === 'drop' - const isInput = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName) - || target.isContentEditable + const isInput = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName) || target.isContentEditable // any input event within node views should be ignored by ProseMirror if (isInput && !isDropEvent) { @@ -152,19 +146,26 @@ export class NodeView< // we have to store that dragging started if (isDraggable && isEditable && !isDragging && isClickEvent) { const dragHandle = target.closest('[data-drag-handle]') - const isValidDragHandle = dragHandle - && (this.dom === dragHandle || (this.dom.contains(dragHandle))) + const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle)) if (isValidDragHandle) { this.isDragging = true - document.addEventListener('dragend', () => { - this.isDragging = false - }, { once: true }) - - document.addEventListener('mouseup', () => { - this.isDragging = false - }, { once: true }) + document.addEventListener( + 'dragend', + () => { + this.isDragging = false + }, + { once: true }, + ) + + document.addEventListener( + 'mouseup', + () => { + this.isDragging = false + }, + { once: true }, + ) } } @@ -183,7 +184,7 @@ export class NodeView< return true } - ignoreMutation(mutation: MutationRecord | { type: 'selection', target: Element }) { + ignoreMutation(mutation: MutationRecord | { type: 'selection'; target: Element }) { if (!this.dom || !this.contentDOM) { return true } diff --git a/packages/core/src/PasteRule.ts b/packages/core/src/PasteRule.ts index ee9fcdbba3..287845ed61 100644 --- a/packages/core/src/PasteRule.ts +++ b/packages/core/src/PasteRule.ts @@ -1,4 +1,4 @@ -import { EditorState, Plugin } from 'prosemirror-state' +import { EditorState, Plugin } from '@tiptap/pm/state' import { CommandManager } from './CommandManager' import { Editor } from './Editor' @@ -14,46 +14,47 @@ import { isNumber } from './utilities/isNumber' import { isRegExp } from './utilities/isRegExp' export type PasteRuleMatch = { - index: number, - text: string, - replaceWith?: string, - match?: RegExpMatchArray, - data?: Record, + index: number + text: string + replaceWith?: string + match?: RegExpMatchArray + data?: Record } -export type PasteRuleFinder = - | RegExp - | ((text: string) => PasteRuleMatch[] | null | undefined) +export type PasteRuleFinder = RegExp | ((text: string) => PasteRuleMatch[] | null | undefined) export class PasteRule { find: PasteRuleFinder handler: (props: { - state: EditorState, - range: Range, - match: ExtendedRegExpMatchArray, - commands: SingleCommands, - chain: () => ChainedCommands, - can: () => CanCommands, + state: EditorState + range: Range + match: ExtendedRegExpMatchArray + commands: SingleCommands + chain: () => ChainedCommands + can: () => CanCommands }) => void | null constructor(config: { - find: PasteRuleFinder, + find: PasteRuleFinder handler: (props: { - state: EditorState, - range: Range, - match: ExtendedRegExpMatchArray, - commands: SingleCommands, - chain: () => ChainedCommands, - can: () => CanCommands, - }) => void | null, + state: EditorState + range: Range + match: ExtendedRegExpMatchArray + commands: SingleCommands + chain: () => ChainedCommands + can: () => CanCommands + }) => void | null }) { this.find = config.find this.handler = config.handler } } -const pasteRuleMatcherHandler = (text: string, find: PasteRuleFinder): ExtendedRegExpMatchArray[] => { +const pasteRuleMatcherHandler = ( + text: string, + find: PasteRuleFinder, +): ExtendedRegExpMatchArray[] => { if (isRegExp(find)) { return [...text.matchAll(find)] } @@ -73,7 +74,9 @@ const pasteRuleMatcherHandler = (text: string, find: PasteRuleFinder): ExtendedR if (pasteRuleMatch.replaceWith) { if (!pasteRuleMatch.text.includes(pasteRuleMatch.replaceWith)) { - console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".') + console.warn( + '[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".', + ) } result.push(pasteRuleMatch.replaceWith) @@ -84,18 +87,14 @@ const pasteRuleMatcherHandler = (text: string, find: PasteRuleFinder): ExtendedR } function run(config: { - editor: Editor, - state: EditorState, - from: number, - to: number, - rule: PasteRule, + editor: Editor + state: EditorState + from: number + to: number + rule: PasteRule }): boolean { const { - editor, - state, - from, - to, - rule, + editor, state, from, to, rule, } = config const { commands, chain, can } = new CommandManager({ @@ -112,12 +111,7 @@ function run(config: { const resolvedFrom = Math.max(from, pos) const resolvedTo = Math.min(to, pos + node.content.size) - const textToMatch = node.textBetween( - resolvedFrom - pos, - resolvedTo - pos, - undefined, - '\ufffc', - ) + const textToMatch = node.textBetween(resolvedFrom - pos, resolvedTo - pos, undefined, '\ufffc') const matches = pasteRuleMatcherHandler(textToMatch, rule.find) @@ -156,7 +150,7 @@ function run(config: { * text that matches any of the given rules to trigger the rule’s * action. */ -export function pasteRulesPlugin(props: { editor: Editor, rules: PasteRule[] }): Plugin[] { +export function pasteRulesPlugin(props: { editor: Editor; rules: PasteRule[] }): Plugin[] { const { editor, rules } = props let dragSourceElement: Element | null = null let isPastedFromProseMirror = false diff --git a/packages/core/src/Tracker.ts b/packages/core/src/Tracker.ts index e24ebd0867..7868d8feba 100644 --- a/packages/core/src/Tracker.ts +++ b/packages/core/src/Tracker.ts @@ -1,12 +1,11 @@ -import { Transaction } from 'prosemirror-state' +import { Transaction } from '@tiptap/pm/state' export interface TrackerResult { - position: number, - deleted: boolean, + position: number + deleted: boolean } export class Tracker { - transaction: Transaction currentStep: number @@ -22,9 +21,7 @@ export class Tracker { const mappedPosition = this.transaction.steps .slice(this.currentStep) .reduce((newPosition, step) => { - const mapResult = step - .getMap() - .mapResult(newPosition) + const mapResult = step.getMap().mapResult(newPosition) if (mapResult.deleted) { deleted = true @@ -38,5 +35,4 @@ export class Tracker { deleted, } } - } diff --git a/packages/core/src/commands/clearNodes.ts b/packages/core/src/commands/clearNodes.ts index b9d891a17f..e4173a811d 100644 --- a/packages/core/src/commands/clearNodes.ts +++ b/packages/core/src/commands/clearNodes.ts @@ -1,4 +1,4 @@ -import { liftTarget } from 'prosemirror-transform' +import { liftTarget } from '@tiptap/pm/transform' import { RawCommands } from '../types' diff --git a/packages/core/src/commands/createParagraphNear.ts b/packages/core/src/commands/createParagraphNear.ts index 5da87c4c82..8ad4fbac3c 100644 --- a/packages/core/src/commands/createParagraphNear.ts +++ b/packages/core/src/commands/createParagraphNear.ts @@ -1,4 +1,4 @@ -import { createParagraphNear as originalCreateParagraphNear } from 'prosemirror-commands' +import { createParagraphNear as originalCreateParagraphNear } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Create a paragraph nearby. */ - createParagraphNear: () => ReturnType, + createParagraphNear: () => ReturnType } } } diff --git a/packages/core/src/commands/deleteNode.ts b/packages/core/src/commands/deleteNode.ts index 8c7e2c24de..75ca079a1b 100644 --- a/packages/core/src/commands/deleteNode.ts +++ b/packages/core/src/commands/deleteNode.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'prosemirror-model' +import { NodeType } from '@tiptap/pm/model' import { getNodeType } from '../helpers/getNodeType' import { RawCommands } from '../types' diff --git a/packages/core/src/commands/deleteSelection.ts b/packages/core/src/commands/deleteSelection.ts index 787b89b716..8e8d5be69d 100644 --- a/packages/core/src/commands/deleteSelection.ts +++ b/packages/core/src/commands/deleteSelection.ts @@ -1,4 +1,4 @@ -import { deleteSelection as originalDeleteSelection } from 'prosemirror-commands' +import { deleteSelection as originalDeleteSelection } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Delete the selection, if there is one. */ - deleteSelection: () => ReturnType, + deleteSelection: () => ReturnType } } } diff --git a/packages/core/src/commands/exitCode.ts b/packages/core/src/commands/exitCode.ts index f23233d97c..7940a82d48 100644 --- a/packages/core/src/commands/exitCode.ts +++ b/packages/core/src/commands/exitCode.ts @@ -1,4 +1,4 @@ -import { exitCode as originalExitCode } from 'prosemirror-commands' +import { exitCode as originalExitCode } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Exit from a code block. */ - exitCode: () => ReturnType, + exitCode: () => ReturnType } } } diff --git a/packages/core/src/commands/extendMarkRange.ts b/packages/core/src/commands/extendMarkRange.ts index 8ecf4a1b17..a67badb68a 100644 --- a/packages/core/src/commands/extendMarkRange.ts +++ b/packages/core/src/commands/extendMarkRange.ts @@ -1,5 +1,5 @@ -import { MarkType } from 'prosemirror-model' -import { TextSelection } from 'prosemirror-state' +import { MarkType } from '@tiptap/pm/model' +import { TextSelection } from '@tiptap/pm/state' import { getMarkRange } from '../helpers/getMarkRange' import { getMarkType } from '../helpers/getMarkType' @@ -11,7 +11,10 @@ declare module '@tiptap/core' { /** * Extends the text selection to the current mark. */ - extendMarkRange: (typeOrName: string | MarkType, attributes?: Record) => ReturnType, + extendMarkRange: ( + typeOrName: string | MarkType, + attributes?: Record, + ) => ReturnType } } } diff --git a/packages/core/src/commands/insertContent.ts b/packages/core/src/commands/insertContent.ts index 8e3817cf7f..fe158410d9 100644 --- a/packages/core/src/commands/insertContent.ts +++ b/packages/core/src/commands/insertContent.ts @@ -1,4 +1,4 @@ -import { ParseOptions } from 'prosemirror-model' +import { ParseOptions } from '@tiptap/pm/model' import { Content, RawCommands } from '../types' @@ -11,14 +11,18 @@ declare module '@tiptap/core' { insertContent: ( value: Content, options?: { - parseOptions?: ParseOptions, - updateSelection?: boolean, + parseOptions?: ParseOptions + updateSelection?: boolean }, - ) => ReturnType, + ) => ReturnType } } } export const insertContent: RawCommands['insertContent'] = (value, options) => ({ tr, commands }) => { - return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options) + return commands.insertContentAt( + { from: tr.selection.from, to: tr.selection.to }, + value, + options, + ) } diff --git a/packages/core/src/commands/insertContentAt.ts b/packages/core/src/commands/insertContentAt.ts index 75bfe9f71c..63a1889913 100644 --- a/packages/core/src/commands/insertContentAt.ts +++ b/packages/core/src/commands/insertContentAt.ts @@ -1,12 +1,8 @@ -import { Fragment, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model' +import { Fragment, Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model' import { createNodeFromContent } from '../helpers/createNodeFromContent' import { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd' -import { - Content, - Range, - RawCommands, -} from '../types' +import { Content, Range, RawCommands } from '../types' declare module '@tiptap/core' { interface Commands { @@ -18,10 +14,10 @@ declare module '@tiptap/core' { position: number | Range, value: Content, options?: { - parseOptions?: ParseOptions, - updateSelection?: boolean, + parseOptions?: ParseOptions + updateSelection?: boolean }, - ) => ReturnType, + ) => ReturnType } } } @@ -50,27 +46,19 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value, return true } - let { from, to } = typeof position === 'number' - ? { from: position, to: position } - : position + let { from, to } = typeof position === 'number' ? { from: position, to: position } : position let isOnlyTextContent = true let isOnlyBlockContent = true - const nodes = isFragment(content) - ? content - : [content] + const nodes = isFragment(content) ? content : [content] nodes.forEach(node => { // check if added node is valid node.check() - isOnlyTextContent = isOnlyTextContent - ? node.isText && node.marks.length === 0 - : false + isOnlyTextContent = isOnlyTextContent ? node.isText && node.marks.length === 0 : false - isOnlyBlockContent = isOnlyBlockContent - ? node.isBlock - : false + isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false }) // check if we can replace the wrapping node by @@ -80,9 +68,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value, // instead of inserting the image below the paragraph if (from === to && isOnlyBlockContent) { const { parent } = tr.doc.resolve(from) - const isEmptyTextBlock = parent.isTextblock - && !parent.type.spec.code - && !parent.childCount + const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount if (isEmptyTextBlock) { from -= 1 diff --git a/packages/core/src/commands/join.ts b/packages/core/src/commands/join.ts index a872aeb21b..4167aef027 100644 --- a/packages/core/src/commands/join.ts +++ b/packages/core/src/commands/join.ts @@ -1,6 +1,9 @@ import { - joinBackward as originalJoinBackward, joinDown as originalJoinDown, joinForward as originalJoinForward, joinUp as originalJoinUp, -} from 'prosemirror-commands' + joinBackward as originalJoinBackward, + joinDown as originalJoinDown, + joinForward as originalJoinForward, + joinUp as originalJoinUp, +} from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -10,25 +13,25 @@ declare module '@tiptap/core' { /** * Join two nodes Up. */ - joinUp: () => ReturnType, + joinUp: () => ReturnType } joinDown: { /** * Join two nodes Down. */ - joinDown: () => ReturnType, + joinDown: () => ReturnType } joinBackward: { /** * Join two nodes Backwards. */ - joinBackward: () => ReturnType, + joinBackward: () => ReturnType } joinForward: { /** * Join two nodes Forwards. */ - joinForward: () => ReturnType, + joinForward: () => ReturnType } } } diff --git a/packages/core/src/commands/lift.ts b/packages/core/src/commands/lift.ts index c4190ebb75..783c23e542 100644 --- a/packages/core/src/commands/lift.ts +++ b/packages/core/src/commands/lift.ts @@ -1,5 +1,5 @@ -import { lift as originalLift } from 'prosemirror-commands' -import { NodeType } from 'prosemirror-model' +import { lift as originalLift } from '@tiptap/pm/commands' +import { NodeType } from '@tiptap/pm/model' import { getNodeType } from '../helpers/getNodeType' import { isNodeActive } from '../helpers/isNodeActive' @@ -11,7 +11,7 @@ declare module '@tiptap/core' { /** * Removes an existing wrap. */ - lift: (typeOrName: string | NodeType, attributes?: Record) => ReturnType, + lift: (typeOrName: string | NodeType, attributes?: Record) => ReturnType } } } diff --git a/packages/core/src/commands/liftEmptyBlock.ts b/packages/core/src/commands/liftEmptyBlock.ts index fdc8b93ea6..f32d95b6f7 100644 --- a/packages/core/src/commands/liftEmptyBlock.ts +++ b/packages/core/src/commands/liftEmptyBlock.ts @@ -1,4 +1,4 @@ -import { liftEmptyBlock as originalLiftEmptyBlock } from 'prosemirror-commands' +import { liftEmptyBlock as originalLiftEmptyBlock } from '@tiptap/pm/commands' import { RawCommands } from '../types' diff --git a/packages/core/src/commands/liftListItem.ts b/packages/core/src/commands/liftListItem.ts index 0c1896c274..2cdb06dcab 100644 --- a/packages/core/src/commands/liftListItem.ts +++ b/packages/core/src/commands/liftListItem.ts @@ -1,5 +1,5 @@ -import { NodeType } from 'prosemirror-model' -import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list' +import { NodeType } from '@tiptap/pm/model' +import { liftListItem as originalLiftListItem } from '@tiptap/pm/schema-list' import { getNodeType } from '../helpers/getNodeType' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Lift the list item into a wrapping list. */ - liftListItem: (typeOrName: string | NodeType) => ReturnType, + liftListItem: (typeOrName: string | NodeType) => ReturnType } } } diff --git a/packages/core/src/commands/newlineInCode.ts b/packages/core/src/commands/newlineInCode.ts index 7fd37fa6a9..5dedcf435c 100644 --- a/packages/core/src/commands/newlineInCode.ts +++ b/packages/core/src/commands/newlineInCode.ts @@ -1,4 +1,4 @@ -import { newlineInCode as originalNewlineInCode } from 'prosemirror-commands' +import { newlineInCode as originalNewlineInCode } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Add a newline character in code. */ - newlineInCode: () => ReturnType, + newlineInCode: () => ReturnType } } } diff --git a/packages/core/src/commands/resetAttributes.ts b/packages/core/src/commands/resetAttributes.ts index 5ce359e9eb..69460f8b2c 100644 --- a/packages/core/src/commands/resetAttributes.ts +++ b/packages/core/src/commands/resetAttributes.ts @@ -1,4 +1,4 @@ -import { MarkType, NodeType } from 'prosemirror-model' +import { MarkType, NodeType } from '@tiptap/pm/model' import { getMarkType } from '../helpers/getMarkType' import { getNodeType } from '../helpers/getNodeType' @@ -12,7 +12,10 @@ declare module '@tiptap/core' { /** * Resets some node attributes to the default value. */ - resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => ReturnType, + resetAttributes: ( + typeOrName: string | NodeType | MarkType, + attributes: string | string[], + ) => ReturnType } } } @@ -22,9 +25,7 @@ export const resetAttributes: RawCommands['resetAttributes'] = (typeOrName, attr let markType: MarkType | null = null const schemaType = getSchemaTypeNameByName( - typeof typeOrName === 'string' - ? typeOrName - : typeOrName.name, + typeof typeOrName === 'string' ? typeOrName : typeOrName.name, state.schema, ) @@ -50,7 +51,11 @@ export const resetAttributes: RawCommands['resetAttributes'] = (typeOrName, attr if (markType && node.marks.length) { node.marks.forEach(mark => { if (markType === mark.type) { - tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes))) + tr.addMark( + pos, + pos + node.nodeSize, + markType.create(deleteProps(mark.attrs, attributes)), + ) } }) } diff --git a/packages/core/src/commands/selectNodeBackward.ts b/packages/core/src/commands/selectNodeBackward.ts index c61bbf84c3..e2331c3293 100644 --- a/packages/core/src/commands/selectNodeBackward.ts +++ b/packages/core/src/commands/selectNodeBackward.ts @@ -1,4 +1,4 @@ -import { selectNodeBackward as originalSelectNodeBackward } from 'prosemirror-commands' +import { selectNodeBackward as originalSelectNodeBackward } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Select a node backward. */ - selectNodeBackward: () => ReturnType, + selectNodeBackward: () => ReturnType } } } diff --git a/packages/core/src/commands/selectNodeForward.ts b/packages/core/src/commands/selectNodeForward.ts index 5409aac467..4b0daa8dec 100644 --- a/packages/core/src/commands/selectNodeForward.ts +++ b/packages/core/src/commands/selectNodeForward.ts @@ -1,4 +1,4 @@ -import { selectNodeForward as originalSelectNodeForward } from 'prosemirror-commands' +import { selectNodeForward as originalSelectNodeForward } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Select a node forward. */ - selectNodeForward: () => ReturnType, + selectNodeForward: () => ReturnType } } } diff --git a/packages/core/src/commands/selectParentNode.ts b/packages/core/src/commands/selectParentNode.ts index 9bcf018c15..ea64ab92c1 100644 --- a/packages/core/src/commands/selectParentNode.ts +++ b/packages/core/src/commands/selectParentNode.ts @@ -1,4 +1,4 @@ -import { selectParentNode as originalSelectParentNode } from 'prosemirror-commands' +import { selectParentNode as originalSelectParentNode } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -8,7 +8,7 @@ declare module '@tiptap/core' { /** * Select the parent node. */ - selectParentNode: () => ReturnType, + selectParentNode: () => ReturnType } } } diff --git a/packages/core/src/commands/selectTextblockEnd.ts b/packages/core/src/commands/selectTextblockEnd.ts index 065ed70375..96b384cd9c 100644 --- a/packages/core/src/commands/selectTextblockEnd.ts +++ b/packages/core/src/commands/selectTextblockEnd.ts @@ -1,6 +1,6 @@ // @ts-ignore // TODO: add types to @types/prosemirror-commands -import { selectTextblockEnd as originalSelectTextblockEnd } from 'prosemirror-commands' +import { selectTextblockEnd as originalSelectTextblockEnd } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Moves the cursor to the end of current text block. */ - selectTextblockEnd: () => ReturnType, + selectTextblockEnd: () => ReturnType } } } diff --git a/packages/core/src/commands/selectTextblockStart.ts b/packages/core/src/commands/selectTextblockStart.ts index 919cd676e7..59d684d09a 100644 --- a/packages/core/src/commands/selectTextblockStart.ts +++ b/packages/core/src/commands/selectTextblockStart.ts @@ -1,6 +1,6 @@ // @ts-ignore // TODO: add types to @types/prosemirror-commands -import { selectTextblockStart as originalSelectTextblockStart } from 'prosemirror-commands' +import { selectTextblockStart as originalSelectTextblockStart } from '@tiptap/pm/commands' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Moves the cursor to the start of current text block. */ - selectTextblockStart: () => ReturnType, + selectTextblockStart: () => ReturnType } } } diff --git a/packages/core/src/commands/setContent.ts b/packages/core/src/commands/setContent.ts index 2ee8bc8d99..bd1cc107c4 100644 --- a/packages/core/src/commands/setContent.ts +++ b/packages/core/src/commands/setContent.ts @@ -1,4 +1,4 @@ -import { ParseOptions } from 'prosemirror-model' +import { ParseOptions } from '@tiptap/pm/model' import { createDocument } from '../helpers/createDocument' import { Content, RawCommands } from '../types' @@ -13,7 +13,7 @@ declare module '@tiptap/core' { content: Content, emitUpdate?: boolean, parseOptions?: ParseOptions, - ) => ReturnType, + ) => ReturnType } } } @@ -23,8 +23,7 @@ export const setContent: RawCommands['setContent'] = (content, emitUpdate = fals const document = createDocument(content, editor.schema, parseOptions) if (dispatch) { - tr.replaceWith(0, doc.content.size, document) - .setMeta('preventUpdate', !emitUpdate) + tr.replaceWith(0, doc.content.size, document).setMeta('preventUpdate', !emitUpdate) } return true diff --git a/packages/core/src/commands/setMark.ts b/packages/core/src/commands/setMark.ts index 79bdc4d34f..59aa1ee8f3 100644 --- a/packages/core/src/commands/setMark.ts +++ b/packages/core/src/commands/setMark.ts @@ -1,5 +1,5 @@ -import { MarkType, ResolvedPos } from 'prosemirror-model' -import { EditorState, Transaction } from 'prosemirror-state' +import { MarkType, ResolvedPos } from '@tiptap/pm/model' +import { EditorState, Transaction } from '@tiptap/pm/state' import { isTextSelection } from '../helpers' import { getMarkAttributes } from '../helpers/getMarkAttributes' @@ -12,7 +12,7 @@ declare module '@tiptap/core' { /** * Add a mark with new attributes. */ - setMark: (typeOrName: string | MarkType, attributes?: Record) => ReturnType, + setMark: (typeOrName: string | MarkType, attributes?: Record) => ReturnType } } } @@ -29,13 +29,18 @@ function canSetMark(state: EditorState, tr: Transaction, newMarkType: MarkType) const currentMarks = state.storedMarks ?? cursor.marks() // There can be no current marks that exclude the new mark - return !!newMarkType.isInSet(currentMarks) || !currentMarks.some(mark => mark.type.excludes(newMarkType)) + return ( + !!newMarkType.isInSet(currentMarks) + || !currentMarks.some(mark => mark.type.excludes(newMarkType)) + ) } const { ranges } = selection return ranges.some(({ $from, $to }) => { - let someNodeSupportsMark = $from.depth === 0 ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType) : false + let someNodeSupportsMark = $from.depth === 0 + ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType) + : false state.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => { // If we already found a mark that we can enable, return false to bypass the remaining search @@ -45,7 +50,8 @@ function canSetMark(state: EditorState, tr: Transaction, newMarkType: MarkType) if (node.isInline) { const parentAllowsMarkType = !parent || parent.type.allowsMarkType(newMarkType) - const currentMarksAllowMarkType = !!newMarkType.isInSet(node.marks) || !node.marks.some(otherMark => otherMark.type.excludes(newMarkType)) + const currentMarksAllowMarkType = !!newMarkType.isInSet(node.marks) + || !node.marks.some(otherMark => otherMark.type.excludes(newMarkType)) someNodeSupportsMark = parentAllowsMarkType && currentMarksAllowMarkType } @@ -54,7 +60,6 @@ function canSetMark(state: EditorState, tr: Transaction, newMarkType: MarkType) return someNodeSupportsMark }) - } export const setMark: RawCommands['setMark'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => { const { selection } = tr @@ -65,10 +70,12 @@ export const setMark: RawCommands['setMark'] = (typeOrName, attributes = {}) => if (empty) { const oldAttributes = getMarkAttributes(state, type) - tr.addStoredMark(type.create({ - ...oldAttributes, - ...attributes, - })) + tr.addStoredMark( + type.create({ + ...oldAttributes, + ...attributes, + }), + ) } else { ranges.forEach(range => { const from = range.$from.pos @@ -83,13 +90,16 @@ export const setMark: RawCommands['setMark'] = (typeOrName, attributes = {}) => // we know that we have to merge its attributes // otherwise we add a fresh new mark if (someHasMark) { - node.marks.forEach(mark => { if (type === mark.type) { - tr.addMark(trimmedFrom, trimmedTo, type.create({ - ...mark.attrs, - ...attributes, - })) + tr.addMark( + trimmedFrom, + trimmedTo, + type.create({ + ...mark.attrs, + ...attributes, + }), + ) } }) } else { diff --git a/packages/core/src/commands/setNode.ts b/packages/core/src/commands/setNode.ts index 2ed2b1bda0..7cb3df2a86 100644 --- a/packages/core/src/commands/setNode.ts +++ b/packages/core/src/commands/setNode.ts @@ -1,5 +1,5 @@ -import { setBlockType } from 'prosemirror-commands' -import { NodeType } from 'prosemirror-model' +import { setBlockType } from '@tiptap/pm/commands' +import { NodeType } from '@tiptap/pm/model' import { getNodeType } from '../helpers/getNodeType' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Replace a given range with a node. */ - setNode: (typeOrName: string | NodeType, attributes?: Record) => ReturnType, + setNode: (typeOrName: string | NodeType, attributes?: Record) => ReturnType } } } @@ -25,19 +25,21 @@ export const setNode: RawCommands['setNode'] = (typeOrName, attributes = {}) => return false } - return chain() + return ( + chain() // try to convert node to default node if needed - .command(({ commands }) => { - const canSetBlock = setBlockType(type, attributes)(state) - - if (canSetBlock) { - return true - } - - return commands.clearNodes() - }) - .command(({ state: updatedState }) => { - return setBlockType(type, attributes)(updatedState, dispatch) - }) - .run() + .command(({ commands }) => { + const canSetBlock = setBlockType(type, attributes)(state) + + if (canSetBlock) { + return true + } + + return commands.clearNodes() + }) + .command(({ state: updatedState }) => { + return setBlockType(type, attributes)(updatedState, dispatch) + }) + .run() + ) } diff --git a/packages/core/src/commands/setNodeSelection.ts b/packages/core/src/commands/setNodeSelection.ts index bbcf0f1f26..63756395c2 100644 --- a/packages/core/src/commands/setNodeSelection.ts +++ b/packages/core/src/commands/setNodeSelection.ts @@ -1,4 +1,4 @@ -import { NodeSelection } from 'prosemirror-state' +import { NodeSelection } from '@tiptap/pm/state' import { RawCommands } from '../types' import { minMax } from '../utilities/minMax' @@ -9,7 +9,7 @@ declare module '@tiptap/core' { /** * Creates a NodeSelection. */ - setNodeSelection: (position: number) => ReturnType, + setNodeSelection: (position: number) => ReturnType } } } diff --git a/packages/core/src/commands/setTextSelection.ts b/packages/core/src/commands/setTextSelection.ts index 7fe645e6fd..77cb4c27fa 100644 --- a/packages/core/src/commands/setTextSelection.ts +++ b/packages/core/src/commands/setTextSelection.ts @@ -1,4 +1,4 @@ -import { TextSelection } from 'prosemirror-state' +import { TextSelection } from '@tiptap/pm/state' import { Range, RawCommands } from '../types' import { minMax } from '../utilities/minMax' @@ -9,7 +9,7 @@ declare module '@tiptap/core' { /** * Creates a TextSelection. */ - setTextSelection: (position: number | Range) => ReturnType, + setTextSelection: (position: number | Range) => ReturnType } } } @@ -17,9 +17,7 @@ declare module '@tiptap/core' { export const setTextSelection: RawCommands['setTextSelection'] = position => ({ tr, dispatch }) => { if (dispatch) { const { doc } = tr - const { from, to } = typeof position === 'number' - ? { from: position, to: position } - : position + const { from, to } = typeof position === 'number' ? { from: position, to: position } : position const minPos = TextSelection.atStart(doc).from const maxPos = TextSelection.atEnd(doc).to const resolvedFrom = minMax(from, minPos, maxPos) diff --git a/packages/core/src/commands/sinkListItem.ts b/packages/core/src/commands/sinkListItem.ts index 85645cbfaa..1df2e0825d 100644 --- a/packages/core/src/commands/sinkListItem.ts +++ b/packages/core/src/commands/sinkListItem.ts @@ -1,5 +1,5 @@ -import { NodeType } from 'prosemirror-model' -import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list' +import { NodeType } from '@tiptap/pm/model' +import { sinkListItem as originalSinkListItem } from '@tiptap/pm/schema-list' import { getNodeType } from '../helpers/getNodeType' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Sink the list item down into an inner list. */ - sinkListItem: (typeOrName: string | NodeType) => ReturnType, + sinkListItem: (typeOrName: string | NodeType) => ReturnType } } } diff --git a/packages/core/src/commands/splitBlock.ts b/packages/core/src/commands/splitBlock.ts index 6127177de7..d1fd53705b 100644 --- a/packages/core/src/commands/splitBlock.ts +++ b/packages/core/src/commands/splitBlock.ts @@ -1,13 +1,12 @@ -import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state' -import { canSplit } from 'prosemirror-transform' +import { EditorState, NodeSelection, TextSelection } from '@tiptap/pm/state' +import { canSplit } from '@tiptap/pm/transform' import { defaultBlockAt } from '../helpers/defaultBlockAt' import { getSplittedAttributes } from '../helpers/getSplittedAttributes' import { RawCommands } from '../types' function ensureMarks(state: EditorState, splittableMarks?: string[]) { - const marks = state.storedMarks - || (state.selection.$to.parentOffset && state.selection.$from.marks()) + const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks()) if (marks) { const filteredMarks = marks.filter(mark => splittableMarks?.includes(mark.type.name)) @@ -22,16 +21,13 @@ declare module '@tiptap/core' { /** * Forks a new node from an existing node. */ - splitBlock: (options?: { keepMarks?: boolean }) => ReturnType, + splitBlock: (options?: { keepMarks?: boolean }) => ReturnType } } } export const splitBlock: RawCommands['splitBlock'] = ({ keepMarks = true } = {}) => ({ - tr, - state, - dispatch, - editor, + tr, state, dispatch, editor, }) => { const { selection, doc } = tr const { $from, $to } = selection @@ -74,37 +70,36 @@ export const splitBlock: RawCommands['splitBlock'] = ({ keepMarks = true } = {}) : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1))) let types = atEnd && deflt - ? [{ - type: deflt, - attrs: newAttributes, - }] + ? [ + { + type: deflt, + attrs: newAttributes, + }, + ] : undefined let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types) if ( !types - && !can - && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined) + && !can + && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined) ) { can = true types = deflt - ? [{ - type: deflt, - attrs: newAttributes, - }] + ? [ + { + type: deflt, + attrs: newAttributes, + }, + ] : undefined } if (can) { tr.split(tr.mapping.map($from.pos), 1, types) - if ( - deflt - && !atEnd - && !$from.parentOffset - && $from.parent.type !== deflt - ) { + if (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) { const first = tr.mapping.map($from.before()) const $first = tr.doc.resolve(first) diff --git a/packages/core/src/commands/splitListItem.ts b/packages/core/src/commands/splitListItem.ts index 25ee314273..00148942c7 100644 --- a/packages/core/src/commands/splitListItem.ts +++ b/packages/core/src/commands/splitListItem.ts @@ -1,11 +1,8 @@ import { - Fragment, - Node as ProseMirrorNode, - NodeType, - Slice, -} from 'prosemirror-model' -import { TextSelection } from 'prosemirror-state' -import { canSplit } from 'prosemirror-transform' + Fragment, Node as ProseMirrorNode, NodeType, Slice, +} from '@tiptap/pm/model' +import { TextSelection } from '@tiptap/pm/state' +import { canSplit } from '@tiptap/pm/transform' import { getNodeType } from '../helpers/getNodeType' import { getSplittedAttributes } from '../helpers/getSplittedAttributes' @@ -17,7 +14,7 @@ declare module '@tiptap/core' { /** * Splits one list item into two list items. */ - splitListItem: (typeOrName: string | NodeType) => ReturnType, + splitListItem: (typeOrName: string | NodeType) => ReturnType } } } @@ -30,7 +27,7 @@ export const splitListItem: RawCommands['splitListItem'] = typeOrName => ({ // @ts-ignore // eslint-disable-next-line - const node: ProseMirrorNode = state.selection.node + const node: ProseMirrorNode = state.selection.node if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) { return false @@ -50,8 +47,8 @@ export const splitListItem: RawCommands['splitListItem'] = typeOrName => ({ // command handle lifting. if ( $from.depth === 2 - || $from.node(-3).type !== type - || $from.index(-2) !== $from.node(-2).childCount - 1 + || $from.node(-3).type !== type + || $from.index(-2) !== $from.node(-2).childCount - 1 ) { return false } @@ -59,11 +56,7 @@ export const splitListItem: RawCommands['splitListItem'] = typeOrName => ({ if (dispatch) { let wrap = Fragment.empty // eslint-disable-next-line - const depthBefore = $from.index(-1) - ? 1 - : $from.index(-2) - ? 2 - : 3 + const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3 // Build a fragment containing empty versions of the structure // from the outer list item to the parent node of the cursor @@ -72,11 +65,7 @@ export const splitListItem: RawCommands['splitListItem'] = typeOrName => ({ } // eslint-disable-next-line - const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount - ? 1 - : $from.indexAfter(-2) < $from.node(-3).childCount - ? 2 - : 3 + const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3 // Add a second list item with an empty default start node const newNextTypeAttributes = getSplittedAttributes( @@ -114,9 +103,7 @@ export const splitListItem: RawCommands['splitListItem'] = typeOrName => ({ return true } - const nextType = $to.pos === $from.end() - ? grandParent.contentMatchAt(0).defaultType - : null + const nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null const newTypeAttributes = getSplittedAttributes( extensionAttributes, @@ -132,7 +119,10 @@ export const splitListItem: RawCommands['splitListItem'] = typeOrName => ({ tr.delete($from.pos, $to.pos) const types = nextType - ? [{ type, attrs: newTypeAttributes }, { type: nextType, attrs: newNextTypeAttributes }] + ? [ + { type, attrs: newTypeAttributes }, + { type: nextType, attrs: newNextTypeAttributes }, + ] : [{ type, attrs: newTypeAttributes }] if (!canSplit(tr.doc, $from.pos, 2)) { diff --git a/packages/core/src/commands/toggleList.ts b/packages/core/src/commands/toggleList.ts index 27de705ee0..23da857602 100644 --- a/packages/core/src/commands/toggleList.ts +++ b/packages/core/src/commands/toggleList.ts @@ -1,6 +1,6 @@ -import { NodeType } from 'prosemirror-model' -import { Transaction } from 'prosemirror-state' -import { canJoin } from 'prosemirror-transform' +import { NodeType } from '@tiptap/pm/model' +import { Transaction } from '@tiptap/pm/state' +import { canJoin } from '@tiptap/pm/transform' import { findParentNode } from '../helpers/findParentNode' import { getNodeType } from '../helpers/getNodeType' @@ -21,8 +21,7 @@ const joinListBackwards = (tr: Transaction, listType: NodeType): boolean => { } const nodeBefore = tr.doc.nodeAt(before) - const canJoinBackwards = list.node.type === nodeBefore?.type - && canJoin(tr.doc, list.pos) + const canJoinBackwards = list.node.type === nodeBefore?.type && canJoin(tr.doc, list.pos) if (!canJoinBackwards) { return true @@ -47,8 +46,7 @@ const joinListForwards = (tr: Transaction, listType: NodeType): boolean => { } const nodeAfter = tr.doc.nodeAt(after) - const canJoinForwards = list.node.type === nodeAfter?.type - && canJoin(tr.doc, after) + const canJoinForwards = list.node.type === nodeAfter?.type && canJoin(tr.doc, after) if (!canJoinForwards) { return true @@ -65,7 +63,10 @@ declare module '@tiptap/core' { /** * Toggle between different list types. */ - toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => ReturnType, + toggleList: ( + listTypeOrName: string | NodeType, + itemTypeOrName: string | NodeType, + ) => ReturnType } } } @@ -95,8 +96,8 @@ export const toggleList: RawCommands['toggleList'] = (listTypeOrName, itemTypeOr // change list type if ( isList(parentList.node.type.name, extensions) - && listType.validContent(parentList.node.content) - && dispatch + && listType.validContent(parentList.node.content) + && dispatch ) { return chain() .command(() => { @@ -110,19 +111,21 @@ export const toggleList: RawCommands['toggleList'] = (listTypeOrName, itemTypeOr } } - return chain() + return ( + chain() // try to convert node to default node if needed - .command(() => { - const canWrapInList = can().wrapInList(listType) - - if (canWrapInList) { - return true - } - - return commands.clearNodes() - }) - .wrapInList(listType) - .command(() => joinListBackwards(tr, listType)) - .command(() => joinListForwards(tr, listType)) - .run() + .command(() => { + const canWrapInList = can().wrapInList(listType) + + if (canWrapInList) { + return true + } + + return commands.clearNodes() + }) + .wrapInList(listType) + .command(() => joinListBackwards(tr, listType)) + .command(() => joinListForwards(tr, listType)) + .run() + ) } diff --git a/packages/core/src/commands/toggleMark.ts b/packages/core/src/commands/toggleMark.ts index b57ef506ac..745b4af0c7 100644 --- a/packages/core/src/commands/toggleMark.ts +++ b/packages/core/src/commands/toggleMark.ts @@ -1,4 +1,4 @@ -import { MarkType } from 'prosemirror-model' +import { MarkType } from '@tiptap/pm/model' import { getMarkType } from '../helpers/getMarkType' import { isMarkActive } from '../helpers/isMarkActive' @@ -17,9 +17,9 @@ declare module '@tiptap/core' { /** * Removes the mark even across the current selection. Defaults to `false`. */ - extendEmptyMarkRange?: boolean, + extendEmptyMarkRange?: boolean }, - ) => ReturnType, + ) => ReturnType } } } diff --git a/packages/core/src/commands/toggleNode.ts b/packages/core/src/commands/toggleNode.ts index 79ad24c4bd..796ea6919c 100644 --- a/packages/core/src/commands/toggleNode.ts +++ b/packages/core/src/commands/toggleNode.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'prosemirror-model' +import { NodeType } from '@tiptap/pm/model' import { getNodeType } from '../helpers/getNodeType' import { isNodeActive } from '../helpers/isNodeActive' @@ -10,7 +10,11 @@ declare module '@tiptap/core' { /** * Toggle a node with another node. */ - toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record) => ReturnType, + toggleNode: ( + typeOrName: string | NodeType, + toggleTypeOrName: string | NodeType, + attributes?: Record, + ) => ReturnType } } } diff --git a/packages/core/src/commands/toggleWrap.ts b/packages/core/src/commands/toggleWrap.ts index 68715d620f..9520800d6f 100644 --- a/packages/core/src/commands/toggleWrap.ts +++ b/packages/core/src/commands/toggleWrap.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'prosemirror-model' +import { NodeType } from '@tiptap/pm/model' import { getNodeType } from '../helpers/getNodeType' import { isNodeActive } from '../helpers/isNodeActive' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Wraps nodes in another node, or removes an existing wrap. */ - toggleWrap: (typeOrName: string | NodeType, attributes?: Record) => ReturnType, + toggleWrap: (typeOrName: string | NodeType, attributes?: Record) => ReturnType } } } diff --git a/packages/core/src/commands/unsetMark.ts b/packages/core/src/commands/unsetMark.ts index c8356c25d9..8f2e6b1491 100644 --- a/packages/core/src/commands/unsetMark.ts +++ b/packages/core/src/commands/unsetMark.ts @@ -1,4 +1,4 @@ -import { MarkType } from 'prosemirror-model' +import { MarkType } from '@tiptap/pm/model' import { getMarkRange } from '../helpers/getMarkRange' import { getMarkType } from '../helpers/getMarkType' @@ -16,9 +16,9 @@ declare module '@tiptap/core' { /** * Removes the mark even across the current selection. Defaults to `false`. */ - extendEmptyMarkRange?: boolean, + extendEmptyMarkRange?: boolean }, - ) => ReturnType, + ) => ReturnType } } } diff --git a/packages/core/src/commands/updateAttributes.ts b/packages/core/src/commands/updateAttributes.ts index 8f9e5de7e5..cc68e6e00d 100644 --- a/packages/core/src/commands/updateAttributes.ts +++ b/packages/core/src/commands/updateAttributes.ts @@ -1,4 +1,4 @@ -import { MarkType, NodeType } from 'prosemirror-model' +import { MarkType, NodeType } from '@tiptap/pm/model' import { getMarkType } from '../helpers/getMarkType' import { getNodeType } from '../helpers/getNodeType' @@ -11,7 +11,10 @@ declare module '@tiptap/core' { /** * Update attributes of a node or mark. */ - updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record) => ReturnType, + updateAttributes: ( + typeOrName: string | NodeType | MarkType, + attributes: Record, + ) => ReturnType } } } @@ -21,9 +24,7 @@ export const updateAttributes: RawCommands['updateAttributes'] = (typeOrName, at let markType: MarkType | null = null const schemaType = getSchemaTypeNameByName( - typeof typeOrName === 'string' - ? typeOrName - : typeOrName.name, + typeof typeOrName === 'string' ? typeOrName : typeOrName.name, state.schema, ) @@ -58,10 +59,14 @@ export const updateAttributes: RawCommands['updateAttributes'] = (typeOrName, at const trimmedFrom = Math.max(pos, from) const trimmedTo = Math.min(pos + node.nodeSize, to) - tr.addMark(trimmedFrom, trimmedTo, markType.create({ - ...mark.attrs, - ...attributes, - })) + tr.addMark( + trimmedFrom, + trimmedTo, + markType.create({ + ...mark.attrs, + ...attributes, + }), + ) } }) } diff --git a/packages/core/src/commands/wrapIn.ts b/packages/core/src/commands/wrapIn.ts index d14a2f1a37..81fb296742 100644 --- a/packages/core/src/commands/wrapIn.ts +++ b/packages/core/src/commands/wrapIn.ts @@ -1,5 +1,5 @@ -import { wrapIn as originalWrapIn } from 'prosemirror-commands' -import { NodeType } from 'prosemirror-model' +import { wrapIn as originalWrapIn } from '@tiptap/pm/commands' +import { NodeType } from '@tiptap/pm/model' import { getNodeType } from '../helpers/getNodeType' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Wraps nodes in another node. */ - wrapIn: (typeOrName: string | NodeType, attributes?: Record) => ReturnType, + wrapIn: (typeOrName: string | NodeType, attributes?: Record) => ReturnType } } } diff --git a/packages/core/src/commands/wrapInList.ts b/packages/core/src/commands/wrapInList.ts index b44c781b51..1f83d32e9b 100644 --- a/packages/core/src/commands/wrapInList.ts +++ b/packages/core/src/commands/wrapInList.ts @@ -1,5 +1,5 @@ -import { NodeType } from 'prosemirror-model' -import { wrapInList as originalWrapInList } from 'prosemirror-schema-list' +import { NodeType } from '@tiptap/pm/model' +import { wrapInList as originalWrapInList } from '@tiptap/pm/schema-list' import { getNodeType } from '../helpers/getNodeType' import { RawCommands } from '../types' @@ -10,7 +10,7 @@ declare module '@tiptap/core' { /** * Wrap a node in a list. */ - wrapInList: (typeOrName: string | NodeType, attributes?: Record) => ReturnType, + wrapInList: (typeOrName: string | NodeType, attributes?: Record) => ReturnType } } } diff --git a/packages/core/src/extensions/clipboardTextSerializer.ts b/packages/core/src/extensions/clipboardTextSerializer.ts index 6ab63535ee..99e908dcaa 100644 --- a/packages/core/src/extensions/clipboardTextSerializer.ts +++ b/packages/core/src/extensions/clipboardTextSerializer.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' import { Extension } from '../Extension' import { getTextBetween } from '../helpers/getTextBetween' diff --git a/packages/core/src/extensions/editable.ts b/packages/core/src/extensions/editable.ts index 826aa25177..d373b102c5 100644 --- a/packages/core/src/extensions/editable.ts +++ b/packages/core/src/extensions/editable.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' import { Extension } from '../Extension' diff --git a/packages/core/src/extensions/focusEvents.ts b/packages/core/src/extensions/focusEvents.ts index 2b747d52f0..851748da9d 100644 --- a/packages/core/src/extensions/focusEvents.ts +++ b/packages/core/src/extensions/focusEvents.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' import { Extension } from '../Extension' diff --git a/packages/core/src/extensions/keymap.ts b/packages/core/src/extensions/keymap.ts index 5335b1d81c..4b4a7a2103 100644 --- a/packages/core/src/extensions/keymap.ts +++ b/packages/core/src/extensions/keymap.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginKey, Selection } from 'prosemirror-state' +import { Plugin, PluginKey, Selection } from '@tiptap/pm/state' import { CommandManager } from '../CommandManager' import { Extension } from '../Extension' @@ -19,12 +19,7 @@ export const Keymap = Extension.create({ const { pos, parent } = $anchor const isAtStart = Selection.atStart(doc).from === pos - if ( - !empty - || !isAtStart - || !parent.type.isTextblock - || parent.textContent.length - ) { + if (!empty || !isAtStart || !parent.type.isTextblock || parent.textContent.length) { return false } diff --git a/packages/core/src/extensions/tabindex.ts b/packages/core/src/extensions/tabindex.ts index 47993f6ea3..7f26262a78 100644 --- a/packages/core/src/extensions/tabindex.ts +++ b/packages/core/src/extensions/tabindex.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginKey } from 'prosemirror-state' +import { Plugin, PluginKey } from '@tiptap/pm/state' import { Extension } from '../Extension' diff --git a/packages/core/src/helpers/combineTransactionSteps.ts b/packages/core/src/helpers/combineTransactionSteps.ts index 88020cfc7a..0341afcf75 100644 --- a/packages/core/src/helpers/combineTransactionSteps.ts +++ b/packages/core/src/helpers/combineTransactionSteps.ts @@ -1,11 +1,14 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { Transaction } from 'prosemirror-state' -import { Transform } from 'prosemirror-transform' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { Transaction } from '@tiptap/pm/state' +import { Transform } from '@tiptap/pm/transform' /** * Returns a new `Transform` based on all steps of the passed transactions. */ -export function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform { +export function combineTransactionSteps( + oldDoc: ProseMirrorNode, + transactions: Transaction[], +): Transform { const transform = new Transform(oldDoc) transactions.forEach(transaction => { diff --git a/packages/core/src/helpers/createChainableState.ts b/packages/core/src/helpers/createChainableState.ts index 7911c075c7..05a6935363 100644 --- a/packages/core/src/helpers/createChainableState.ts +++ b/packages/core/src/helpers/createChainableState.ts @@ -1,8 +1,8 @@ -import { EditorState, Transaction } from 'prosemirror-state' +import { EditorState, Transaction } from '@tiptap/pm/state' export function createChainableState(config: { - transaction: Transaction, - state: EditorState, + transaction: Transaction + state: EditorState }): EditorState { const { state, transaction } = config let { selection } = transaction diff --git a/packages/core/src/helpers/createDocument.ts b/packages/core/src/helpers/createDocument.ts index e790b081c1..066d1b109f 100644 --- a/packages/core/src/helpers/createDocument.ts +++ b/packages/core/src/helpers/createDocument.ts @@ -1,4 +1,4 @@ -import { Node as ProseMirrorNode, ParseOptions, Schema } from 'prosemirror-model' +import { Node as ProseMirrorNode, ParseOptions, Schema } from '@tiptap/pm/model' import { Content } from '../types' import { createNodeFromContent } from './createNodeFromContent' diff --git a/packages/core/src/helpers/createNodeFromContent.ts b/packages/core/src/helpers/createNodeFromContent.ts index 1914328756..277ccfb3da 100644 --- a/packages/core/src/helpers/createNodeFromContent.ts +++ b/packages/core/src/helpers/createNodeFromContent.ts @@ -4,14 +4,14 @@ import { Node as ProseMirrorNode, ParseOptions, Schema, -} from 'prosemirror-model' +} from '@tiptap/pm/model' import { Content } from '../types' import { elementFromString } from '../utilities/elementFromString' export type CreateNodeFromContentOptions = { - slice?: boolean, - parseOptions?: ParseOptions, + slice?: boolean + parseOptions?: ParseOptions } export function createNodeFromContent( @@ -33,13 +33,7 @@ export function createNodeFromContent( return schema.nodeFromJSON(content) } catch (error) { - console.warn( - '[tiptap warn]: Invalid content.', - 'Passed value:', - content, - 'Error:', - error, - ) + console.warn('[tiptap warn]: Invalid content.', 'Passed value:', content, 'Error:', error) return createNodeFromContent('', schema, options) } diff --git a/packages/core/src/helpers/defaultBlockAt.ts b/packages/core/src/helpers/defaultBlockAt.ts index 02b5caf7d7..9bd2757732 100644 --- a/packages/core/src/helpers/defaultBlockAt.ts +++ b/packages/core/src/helpers/defaultBlockAt.ts @@ -1,4 +1,4 @@ -import { ContentMatch, NodeType } from 'prosemirror-model' +import { ContentMatch, NodeType } from '@tiptap/pm/model' export function defaultBlockAt(match: ContentMatch): NodeType | null { for (let i = 0; i < match.edgeCount; i += 1) { diff --git a/packages/core/src/helpers/findChildren.ts b/packages/core/src/helpers/findChildren.ts index dee5a0212f..9c2c159c09 100644 --- a/packages/core/src/helpers/findChildren.ts +++ b/packages/core/src/helpers/findChildren.ts @@ -1,4 +1,4 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { NodeWithPos, Predicate } from '../types' diff --git a/packages/core/src/helpers/findChildrenInRange.ts b/packages/core/src/helpers/findChildrenInRange.ts index 168b7788e2..839804f50b 100644 --- a/packages/core/src/helpers/findChildrenInRange.ts +++ b/packages/core/src/helpers/findChildrenInRange.ts @@ -1,11 +1,15 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { NodeWithPos, Predicate, Range } from '../types' /** * Same as `findChildren` but searches only within a `range`. */ -export function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] { +export function findChildrenInRange( + node: ProseMirrorNode, + range: Range, + predicate: Predicate, +): NodeWithPos[] { const nodesWithPos: NodeWithPos[] = [] // if (range.from === range.to) { diff --git a/packages/core/src/helpers/findParentNode.ts b/packages/core/src/helpers/findParentNode.ts index 859e67f4fa..e5fe70c942 100644 --- a/packages/core/src/helpers/findParentNode.ts +++ b/packages/core/src/helpers/findParentNode.ts @@ -1,4 +1,4 @@ -import { Selection } from 'prosemirror-state' +import { Selection } from '@tiptap/pm/state' import { Predicate } from '../types' import { findParentNodeClosestToPos } from './findParentNodeClosestToPos' diff --git a/packages/core/src/helpers/findParentNodeClosestToPos.ts b/packages/core/src/helpers/findParentNodeClosestToPos.ts index c04945cf07..676bc44b34 100644 --- a/packages/core/src/helpers/findParentNodeClosestToPos.ts +++ b/packages/core/src/helpers/findParentNodeClosestToPos.ts @@ -1,13 +1,18 @@ -import { Node as ProseMirrorNode, ResolvedPos } from 'prosemirror-model' +import { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model' import { Predicate } from '../types' -export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ({ - pos: number, - start: number, - depth: number, - node: ProseMirrorNode, -} | undefined) { +export function findParentNodeClosestToPos( + $pos: ResolvedPos, + predicate: Predicate, +): + | { + pos: number + start: number + depth: number + node: ProseMirrorNode + } + | undefined { for (let i = $pos.depth; i > 0; i -= 1) { const node = $pos.node(i) diff --git a/packages/core/src/helpers/generateHTML.ts b/packages/core/src/helpers/generateHTML.ts index 77a2ce45a9..f3c9e8f08d 100644 --- a/packages/core/src/helpers/generateHTML.ts +++ b/packages/core/src/helpers/generateHTML.ts @@ -1,4 +1,4 @@ -import { Node } from 'prosemirror-model' +import { Node } from '@tiptap/pm/model' import { Extensions, JSONContent } from '../types' import { getHTMLFromFragment } from './getHTMLFromFragment' diff --git a/packages/core/src/helpers/generateJSON.ts b/packages/core/src/helpers/generateJSON.ts index 2342c4bb87..141f7bbf49 100644 --- a/packages/core/src/helpers/generateJSON.ts +++ b/packages/core/src/helpers/generateJSON.ts @@ -1,4 +1,4 @@ -import { DOMParser } from 'prosemirror-model' +import { DOMParser } from '@tiptap/pm/model' import { Extensions } from '../types' import { elementFromString } from '../utilities/elementFromString' @@ -8,7 +8,5 @@ export function generateJSON(html: string, extensions: Extensions): Record, + blockSeparator?: string + textSerializers?: Record }, ): string { - const { - blockSeparator = '\n\n', - textSerializers = {}, - } = options || {} + const { blockSeparator = '\n\n', textSerializers = {} } = options || {} const schema = getSchema(extensions) const contentNode = Node.fromJSON(schema, doc) diff --git a/packages/core/src/helpers/getAttributes.ts b/packages/core/src/helpers/getAttributes.ts index bbcd9368a5..8f283fd456 100644 --- a/packages/core/src/helpers/getAttributes.ts +++ b/packages/core/src/helpers/getAttributes.ts @@ -1,5 +1,5 @@ -import { MarkType, NodeType } from 'prosemirror-model' -import { EditorState } from 'prosemirror-state' +import { MarkType, NodeType } from '@tiptap/pm/model' +import { EditorState } from '@tiptap/pm/state' import { getMarkAttributes } from './getMarkAttributes' import { getNodeAttributes } from './getNodeAttributes' @@ -10,9 +10,7 @@ export function getAttributes( typeOrName: string | NodeType | MarkType, ): Record { const schemaType = getSchemaTypeNameByName( - typeof typeOrName === 'string' - ? typeOrName - : typeOrName.name, + typeof typeOrName === 'string' ? typeOrName : typeOrName.name, state.schema, ) diff --git a/packages/core/src/helpers/getChangedRanges.ts b/packages/core/src/helpers/getChangedRanges.ts index a9f03330fb..d866e1d145 100644 --- a/packages/core/src/helpers/getChangedRanges.ts +++ b/packages/core/src/helpers/getChangedRanges.ts @@ -1,4 +1,4 @@ -import { Step, Transform } from 'prosemirror-transform' +import { Step, Transform } from '@tiptap/pm/transform' import { Range } from '../types' import { removeDuplicates } from '../utilities/removeDuplicates' diff --git a/packages/core/src/helpers/getDebugJSON.ts b/packages/core/src/helpers/getDebugJSON.ts index bb9fa82e40..0c19aa2903 100644 --- a/packages/core/src/helpers/getDebugJSON.ts +++ b/packages/core/src/helpers/getDebugJSON.ts @@ -1,10 +1,10 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { JSONContent } from '../types' interface DebugJSONContent extends JSONContent { - from: number, - to: number, + from: number + to: number } export function getDebugJSON(node: ProseMirrorNode, startOffset = 0): DebugJSONContent { @@ -13,7 +13,7 @@ export function getDebugJSON(node: ProseMirrorNode, startOffset = 0): DebugJSONC const from = startOffset const to = from + node.nodeSize const marks = node.marks.map(mark => { - const output: { type: string, attrs?: Record } = { + const output: { type: string; attrs?: Record } = { type: mark.type.name, } diff --git a/packages/core/src/helpers/getHTMLFromFragment.ts b/packages/core/src/helpers/getHTMLFromFragment.ts index e4dc075881..a33a305868 100644 --- a/packages/core/src/helpers/getHTMLFromFragment.ts +++ b/packages/core/src/helpers/getHTMLFromFragment.ts @@ -1,9 +1,7 @@ -import { DOMSerializer, Fragment, Schema } from 'prosemirror-model' +import { DOMSerializer, Fragment, Schema } from '@tiptap/pm/model' export function getHTMLFromFragment(fragment: Fragment, schema: Schema): string { - const documentFragment = DOMSerializer - .fromSchema(schema) - .serializeFragment(fragment) + const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment) const temporaryDocument = document.implementation.createHTMLDocument() const container = temporaryDocument.createElement('div') diff --git a/packages/core/src/helpers/getMarkAttributes.ts b/packages/core/src/helpers/getMarkAttributes.ts index 5c46c46e6f..0b139609e5 100644 --- a/packages/core/src/helpers/getMarkAttributes.ts +++ b/packages/core/src/helpers/getMarkAttributes.ts @@ -1,9 +1,12 @@ -import { Mark, MarkType } from 'prosemirror-model' -import { EditorState } from 'prosemirror-state' +import { Mark, MarkType } from '@tiptap/pm/model' +import { EditorState } from '@tiptap/pm/state' import { getMarkType } from './getMarkType' -export function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record { +export function getMarkAttributes( + state: EditorState, + typeOrName: string | MarkType, +): Record { const type = getMarkType(typeOrName, state.schema) const { from, to, empty } = state.selection const marks: Mark[] = [] diff --git a/packages/core/src/helpers/getMarkRange.ts b/packages/core/src/helpers/getMarkRange.ts index b4c174bdd8..4353347d96 100644 --- a/packages/core/src/helpers/getMarkRange.ts +++ b/packages/core/src/helpers/getMarkRange.ts @@ -1,4 +1,4 @@ -import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from 'prosemirror-model' +import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@tiptap/pm/model' import { Range } from '../types' import { objectIncludes } from '../utilities/objectIncludes' diff --git a/packages/core/src/helpers/getMarkType.ts b/packages/core/src/helpers/getMarkType.ts index 2f79223bc5..64707a5cb0 100644 --- a/packages/core/src/helpers/getMarkType.ts +++ b/packages/core/src/helpers/getMarkType.ts @@ -1,9 +1,11 @@ -import { MarkType, Schema } from 'prosemirror-model' +import { MarkType, Schema } from '@tiptap/pm/model' export function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType { if (typeof nameOrType === 'string') { if (!schema.marks[nameOrType]) { - throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`) + throw Error( + `There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`, + ) } return schema.marks[nameOrType] diff --git a/packages/core/src/helpers/getMarksBetween.ts b/packages/core/src/helpers/getMarksBetween.ts index e209bbc04a..6275aa1891 100644 --- a/packages/core/src/helpers/getMarksBetween.ts +++ b/packages/core/src/helpers/getMarksBetween.ts @@ -1,4 +1,4 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { MarkRange } from '../types' import { getMarkRange } from './getMarkRange' @@ -26,11 +26,13 @@ export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): }) } else { doc.nodesBetween(from, to, (node, pos) => { - marks.push(...node.marks.map(mark => ({ - from: pos, - to: pos + node.nodeSize, - mark, - }))) + marks.push( + ...node.marks.map(mark => ({ + from: pos, + to: pos + node.nodeSize, + mark, + })), + ) }) } diff --git a/packages/core/src/helpers/getNodeAttributes.ts b/packages/core/src/helpers/getNodeAttributes.ts index 33aee129f6..3cd23c0ebc 100644 --- a/packages/core/src/helpers/getNodeAttributes.ts +++ b/packages/core/src/helpers/getNodeAttributes.ts @@ -1,9 +1,12 @@ -import { Node, NodeType } from 'prosemirror-model' -import { EditorState } from 'prosemirror-state' +import { Node, NodeType } from '@tiptap/pm/model' +import { EditorState } from '@tiptap/pm/state' import { getNodeType } from './getNodeType' -export function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record { +export function getNodeAttributes( + state: EditorState, + typeOrName: string | NodeType, +): Record { const type = getNodeType(typeOrName, state.schema) const { from, to } = state.selection const nodes: Node[] = [] @@ -12,9 +15,7 @@ export function getNodeAttributes(state: EditorState, typeOrName: string | NodeT nodes.push(node) }) - const node = nodes - .reverse() - .find(nodeItem => nodeItem.type.name === type.name) + const node = nodes.reverse().find(nodeItem => nodeItem.type.name === type.name) if (!node) { return {} diff --git a/packages/core/src/helpers/getNodeType.ts b/packages/core/src/helpers/getNodeType.ts index 00955340d6..8c10f27c79 100644 --- a/packages/core/src/helpers/getNodeType.ts +++ b/packages/core/src/helpers/getNodeType.ts @@ -1,9 +1,11 @@ -import { NodeType, Schema } from 'prosemirror-model' +import { NodeType, Schema } from '@tiptap/pm/model' export function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType { if (typeof nameOrType === 'string') { if (!schema.nodes[nameOrType]) { - throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`) + throw Error( + `There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`, + ) } return schema.nodes[nameOrType] diff --git a/packages/core/src/helpers/getRenderedAttributes.ts b/packages/core/src/helpers/getRenderedAttributes.ts index 28feb943a7..b0290ebfb0 100644 --- a/packages/core/src/helpers/getRenderedAttributes.ts +++ b/packages/core/src/helpers/getRenderedAttributes.ts @@ -1,9 +1,12 @@ -import { Mark, Node } from 'prosemirror-model' +import { Mark, Node } from '@tiptap/pm/model' import { ExtensionAttribute } from '../types' import { mergeAttributes } from '../utilities/mergeAttributes' -export function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): Record { +export function getRenderedAttributes( + nodeOrMark: Node | Mark, + extensionAttributes: ExtensionAttribute[], +): Record { return extensionAttributes .filter(item => item.attribute.rendered) .map(item => { diff --git a/packages/core/src/helpers/getSchema.ts b/packages/core/src/helpers/getSchema.ts index 15159f1934..4dcd8b86fb 100644 --- a/packages/core/src/helpers/getSchema.ts +++ b/packages/core/src/helpers/getSchema.ts @@ -1,4 +1,4 @@ -import { Schema } from 'prosemirror-model' +import { Schema } from '@tiptap/pm/model' import { ExtensionManager } from '../ExtensionManager' import { Extensions } from '../types' diff --git a/packages/core/src/helpers/getSchemaByResolvedExtensions.ts b/packages/core/src/helpers/getSchemaByResolvedExtensions.ts index 90ad6292d9..d06cc00cc2 100644 --- a/packages/core/src/helpers/getSchemaByResolvedExtensions.ts +++ b/packages/core/src/helpers/getSchemaByResolvedExtensions.ts @@ -1,4 +1,4 @@ -import { MarkSpec, NodeSpec, Schema } from 'prosemirror-model' +import { MarkSpec, NodeSpec, Schema } from '@tiptap/pm/model' import { MarkConfig, NodeConfig } from '..' import { AnyConfig, Extensions } from '../types' @@ -11,13 +11,15 @@ import { injectExtensionAttributesToParseRule } from './injectExtensionAttribute import { splitExtensions } from './splitExtensions' function cleanUpSchemaItem(data: T) { - return Object.fromEntries(Object.entries(data).filter(([key, value]) => { - if (key === 'attrs' && isEmptyObject(value)) { - return false - } + return Object.fromEntries( + Object.entries(data).filter(([key, value]) => { + if (key === 'attrs' && isEmptyObject(value)) { + return false + } - return value !== null && value !== undefined - })) as T + return value !== null && value !== undefined + }), + ) as T } export function getSchemaByResolvedExtensions(extensions: Extensions): Schema { @@ -25,120 +27,162 @@ export function getSchemaByResolvedExtensions(extensions: Extensions): Schema { const { nodeExtensions, markExtensions } = splitExtensions(extensions) const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name - const nodes = Object.fromEntries(nodeExtensions.map(extension => { - const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name) - const context = { - name: extension.name, - options: extension.options, - storage: extension.storage, - } - - const extraNodeFields = extensions.reduce((fields, e) => { - const extendNodeSchema = getExtensionField( - e, - 'extendNodeSchema', - context, + const nodes = Object.fromEntries( + nodeExtensions.map(extension => { + const extensionAttributes = allAttributes.filter( + attribute => attribute.type === extension.name, ) - - return { - ...fields, - ...(extendNodeSchema ? extendNodeSchema(extension) : {}), + const context = { + name: extension.name, + options: extension.options, + storage: extension.storage, } - }, {}) - - const schema: NodeSpec = cleanUpSchemaItem({ - ...extraNodeFields, - content: callOrReturn(getExtensionField(extension, 'content', context)), - marks: callOrReturn(getExtensionField(extension, 'marks', context)), - group: callOrReturn(getExtensionField(extension, 'group', context)), - inline: callOrReturn(getExtensionField(extension, 'inline', context)), - atom: callOrReturn(getExtensionField(extension, 'atom', context)), - selectable: callOrReturn(getExtensionField(extension, 'selectable', context)), - draggable: callOrReturn(getExtensionField(extension, 'draggable', context)), - code: callOrReturn(getExtensionField(extension, 'code', context)), - defining: callOrReturn(getExtensionField(extension, 'defining', context)), - isolating: callOrReturn(getExtensionField(extension, 'isolating', context)), - attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => { - return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }] - })), - }) - - const parseHTML = callOrReturn(getExtensionField(extension, 'parseHTML', context)) - - if (parseHTML) { - schema.parseDOM = parseHTML - .map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes)) - } - - const renderHTML = getExtensionField(extension, 'renderHTML', context) - - if (renderHTML) { - schema.toDOM = node => renderHTML({ - node, - HTMLAttributes: getRenderedAttributes(node, extensionAttributes), + + const extraNodeFields = extensions.reduce((fields, e) => { + const extendNodeSchema = getExtensionField( + e, + 'extendNodeSchema', + context, + ) + + return { + ...fields, + ...(extendNodeSchema ? extendNodeSchema(extension) : {}), + } + }, {}) + + const schema: NodeSpec = cleanUpSchemaItem({ + ...extraNodeFields, + content: callOrReturn( + getExtensionField(extension, 'content', context), + ), + marks: callOrReturn(getExtensionField(extension, 'marks', context)), + group: callOrReturn(getExtensionField(extension, 'group', context)), + inline: callOrReturn(getExtensionField(extension, 'inline', context)), + atom: callOrReturn(getExtensionField(extension, 'atom', context)), + selectable: callOrReturn( + getExtensionField(extension, 'selectable', context), + ), + draggable: callOrReturn( + getExtensionField(extension, 'draggable', context), + ), + code: callOrReturn(getExtensionField(extension, 'code', context)), + defining: callOrReturn( + getExtensionField(extension, 'defining', context), + ), + isolating: callOrReturn( + getExtensionField(extension, 'isolating', context), + ), + attrs: Object.fromEntries( + extensionAttributes.map(extensionAttribute => { + return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }] + }), + ), }) - } - const renderText = getExtensionField(extension, 'renderText', context) + const parseHTML = callOrReturn( + getExtensionField(extension, 'parseHTML', context), + ) - if (renderText) { - schema.toText = renderText - } + if (parseHTML) { + schema.parseDOM = parseHTML.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes)) + } - return [extension.name, schema] - })) + const renderHTML = getExtensionField( + extension, + 'renderHTML', + context, + ) - const marks = Object.fromEntries(markExtensions.map(extension => { - const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name) - const context = { - name: extension.name, - options: extension.options, - storage: extension.storage, - } + if (renderHTML) { + schema.toDOM = node => renderHTML({ + node, + HTMLAttributes: getRenderedAttributes(node, extensionAttributes), + }) + } - const extraMarkFields = extensions.reduce((fields, e) => { - const extendMarkSchema = getExtensionField( - e, - 'extendMarkSchema', + const renderText = getExtensionField( + extension, + 'renderText', context, ) - return { - ...fields, - ...(extendMarkSchema ? extendMarkSchema(extension) : {}), + if (renderText) { + schema.toText = renderText } - }, {}) - - const schema: MarkSpec = cleanUpSchemaItem({ - ...extraMarkFields, - inclusive: callOrReturn(getExtensionField(extension, 'inclusive', context)), - excludes: callOrReturn(getExtensionField(extension, 'excludes', context)), - group: callOrReturn(getExtensionField(extension, 'group', context)), - spanning: callOrReturn(getExtensionField(extension, 'spanning', context)), - code: callOrReturn(getExtensionField(extension, 'code', context)), - attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => { - return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }] - })), - }) - - const parseHTML = callOrReturn(getExtensionField(extension, 'parseHTML', context)) - - if (parseHTML) { - schema.parseDOM = parseHTML - .map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes)) - } - - const renderHTML = getExtensionField(extension, 'renderHTML', context) - - if (renderHTML) { - schema.toDOM = mark => renderHTML({ - mark, - HTMLAttributes: getRenderedAttributes(mark, extensionAttributes), + + return [extension.name, schema] + }), + ) + + const marks = Object.fromEntries( + markExtensions.map(extension => { + const extensionAttributes = allAttributes.filter( + attribute => attribute.type === extension.name, + ) + const context = { + name: extension.name, + options: extension.options, + storage: extension.storage, + } + + const extraMarkFields = extensions.reduce((fields, e) => { + const extendMarkSchema = getExtensionField( + e, + 'extendMarkSchema', + context, + ) + + return { + ...fields, + ...(extendMarkSchema ? extendMarkSchema(extension) : {}), + } + }, {}) + + const schema: MarkSpec = cleanUpSchemaItem({ + ...extraMarkFields, + inclusive: callOrReturn( + getExtensionField(extension, 'inclusive', context), + ), + excludes: callOrReturn( + getExtensionField(extension, 'excludes', context), + ), + group: callOrReturn(getExtensionField(extension, 'group', context)), + spanning: callOrReturn( + getExtensionField(extension, 'spanning', context), + ), + code: callOrReturn(getExtensionField(extension, 'code', context)), + attrs: Object.fromEntries( + extensionAttributes.map(extensionAttribute => { + return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }] + }), + ), }) - } - return [extension.name, schema] - })) + const parseHTML = callOrReturn( + getExtensionField(extension, 'parseHTML', context), + ) + + if (parseHTML) { + schema.parseDOM = parseHTML.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes)) + } + + const renderHTML = getExtensionField( + extension, + 'renderHTML', + context, + ) + + if (renderHTML) { + schema.toDOM = mark => renderHTML({ + mark, + HTMLAttributes: getRenderedAttributes(mark, extensionAttributes), + }) + } + + return [extension.name, schema] + }), + ) return new Schema({ topNode, diff --git a/packages/core/src/helpers/getSchemaTypeByName.ts b/packages/core/src/helpers/getSchemaTypeByName.ts index 2e5154265a..cfeb4661cd 100644 --- a/packages/core/src/helpers/getSchemaTypeByName.ts +++ b/packages/core/src/helpers/getSchemaTypeByName.ts @@ -1,4 +1,4 @@ -import { MarkType, NodeType, Schema } from 'prosemirror-model' +import { MarkType, NodeType, Schema } from '@tiptap/pm/model' export function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null { return schema.nodes[name] || schema.marks[name] || null diff --git a/packages/core/src/helpers/getSchemaTypeNameByName.ts b/packages/core/src/helpers/getSchemaTypeNameByName.ts index 0ad2e4b09b..81c4c0f65e 100644 --- a/packages/core/src/helpers/getSchemaTypeNameByName.ts +++ b/packages/core/src/helpers/getSchemaTypeNameByName.ts @@ -1,4 +1,4 @@ -import { Schema } from 'prosemirror-model' +import { Schema } from '@tiptap/pm/model' export function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null { if (schema.nodes[name]) { diff --git a/packages/core/src/helpers/getText.ts b/packages/core/src/helpers/getText.ts index 05878a5302..e8621a0171 100644 --- a/packages/core/src/helpers/getText.ts +++ b/packages/core/src/helpers/getText.ts @@ -1,4 +1,4 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { TextSerializer } from '../types' import { getTextBetween } from './getTextBetween' @@ -6,8 +6,8 @@ import { getTextBetween } from './getTextBetween' export function getText( node: ProseMirrorNode, options?: { - blockSeparator?: string, - textSerializers?: Record, + blockSeparator?: string + textSerializers?: Record }, ) { const range = { diff --git a/packages/core/src/helpers/getTextBetween.ts b/packages/core/src/helpers/getTextBetween.ts index 0e9e826b81..34e59667e9 100644 --- a/packages/core/src/helpers/getTextBetween.ts +++ b/packages/core/src/helpers/getTextBetween.ts @@ -1,4 +1,4 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { Range, TextSerializer } from '../types' @@ -6,15 +6,12 @@ export function getTextBetween( startNode: ProseMirrorNode, range: Range, options?: { - blockSeparator?: string, - textSerializers?: Record, + blockSeparator?: string + textSerializers?: Record }, ): string { const { from, to } = range - const { - blockSeparator = '\n\n', - textSerializers = {}, - } = options || {} + const { blockSeparator = '\n\n', textSerializers = {} } = options || {} let text = '' let separated = true diff --git a/packages/core/src/helpers/getTextContentFromNodes.ts b/packages/core/src/helpers/getTextContentFromNodes.ts index ca924b5e13..e92742f41f 100644 --- a/packages/core/src/helpers/getTextContentFromNodes.ts +++ b/packages/core/src/helpers/getTextContentFromNodes.ts @@ -1,4 +1,4 @@ -import { ResolvedPos } from 'prosemirror-model' +import { ResolvedPos } from '@tiptap/pm/model' export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => { let textBefore = '' @@ -10,8 +10,13 @@ export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => { sliceEndPos, (node, pos, parent, index) => { const chunk = node.type.spec.toText?.({ - node, pos, parent, index, - }) || node.textContent || '%leaf%' + node, + pos, + parent, + index, + }) + || node.textContent + || '%leaf%' textBefore += chunk.slice(0, Math.max(0, sliceEndPos - pos)) }, diff --git a/packages/core/src/helpers/getTextSerializersFromSchema.ts b/packages/core/src/helpers/getTextSerializersFromSchema.ts index 41d16ae816..f2eb80a107 100644 --- a/packages/core/src/helpers/getTextSerializersFromSchema.ts +++ b/packages/core/src/helpers/getTextSerializersFromSchema.ts @@ -1,10 +1,11 @@ -import { Schema } from 'prosemirror-model' +import { Schema } from '@tiptap/pm/model' import { TextSerializer } from '../types' export function getTextSerializersFromSchema(schema: Schema): Record { - return Object.fromEntries(Object - .entries(schema.nodes) - .filter(([, node]) => node.spec.toText) - .map(([name, node]) => [name, node.spec.toText])) + return Object.fromEntries( + Object.entries(schema.nodes) + .filter(([, node]) => node.spec.toText) + .map(([name, node]) => [name, node.spec.toText]), + ) } diff --git a/packages/core/src/helpers/injectExtensionAttributesToParseRule.ts b/packages/core/src/helpers/injectExtensionAttributesToParseRule.ts index 82ae99761f..516ef2ba48 100644 --- a/packages/core/src/helpers/injectExtensionAttributesToParseRule.ts +++ b/packages/core/src/helpers/injectExtensionAttributesToParseRule.ts @@ -1,4 +1,4 @@ -import { ParseRule } from 'prosemirror-model' +import { ParseRule } from '@tiptap/pm/model' import { ExtensionAttribute } from '../types' import { fromString } from '../utilities/fromString' @@ -9,7 +9,10 @@ import { fromString } from '../utilities/fromString' * @param parseRule ProseMirror ParseRule * @param extensionAttributes List of attributes to inject */ -export function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule { +export function injectExtensionAttributesToParseRule( + parseRule: ParseRule, + extensionAttributes: ExtensionAttribute[], +): ParseRule { if (parseRule.style) { return parseRule } @@ -17,9 +20,7 @@ export function injectExtensionAttributesToParseRule(parseRule: ParseRule, exten return { ...parseRule, getAttrs: node => { - const oldAttributes = parseRule.getAttrs - ? parseRule.getAttrs(node) - : parseRule.attrs + const oldAttributes = parseRule.getAttrs ? parseRule.getAttrs(node) : parseRule.attrs if (oldAttributes === false) { return false diff --git a/packages/core/src/helpers/isActive.ts b/packages/core/src/helpers/isActive.ts index 9398b7b416..d2634aedd0 100644 --- a/packages/core/src/helpers/isActive.ts +++ b/packages/core/src/helpers/isActive.ts @@ -1,10 +1,14 @@ -import { EditorState } from 'prosemirror-state' +import { EditorState } from '@tiptap/pm/state' import { getSchemaTypeNameByName } from './getSchemaTypeNameByName' import { isMarkActive } from './isMarkActive' import { isNodeActive } from './isNodeActive' -export function isActive(state: EditorState, name: string | null, attributes: Record = {}): boolean { +export function isActive( + state: EditorState, + name: string | null, + attributes: Record = {}, +): boolean { if (!name) { return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes) } diff --git a/packages/core/src/helpers/isMarkActive.ts b/packages/core/src/helpers/isMarkActive.ts index 82802a8490..c0869b6159 100644 --- a/packages/core/src/helpers/isMarkActive.ts +++ b/packages/core/src/helpers/isMarkActive.ts @@ -1,5 +1,5 @@ -import { MarkType } from 'prosemirror-model' -import { EditorState } from 'prosemirror-state' +import { MarkType } from '@tiptap/pm/model' +import { EditorState } from '@tiptap/pm/state' import { MarkRange } from '../types' import { objectIncludes } from '../utilities/objectIncludes' @@ -11,9 +11,7 @@ export function isMarkActive( attributes: Record = {}, ): boolean { const { empty, ranges } = state.selection - const type = typeOrName - ? getMarkType(typeOrName, state.schema) - : null + const type = typeOrName ? getMarkType(typeOrName, state.schema) : null if (empty) { return !!(state.storedMarks || state.selection.$from.marks()) @@ -45,11 +43,13 @@ export function isMarkActive( selectionRange += range - markRanges.push(...node.marks.map(mark => ({ - mark, - from: relativeFrom, - to: relativeTo, - }))) + markRanges.push( + ...node.marks.map(mark => ({ + mark, + from: relativeFrom, + to: relativeTo, + })), + ) }) }) @@ -77,16 +77,13 @@ export function isMarkActive( return true } - return markRange.mark.type !== type - && markRange.mark.type.excludes(type) + return markRange.mark.type !== type && markRange.mark.type.excludes(type) }) .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0) // we only include the result of `excludedRange` // if there is a match at all - const range = matchedRange > 0 - ? matchedRange + excludedRange - : matchedRange + const range = matchedRange > 0 ? matchedRange + excludedRange : matchedRange return range >= selectionRange } diff --git a/packages/core/src/helpers/isNodeActive.ts b/packages/core/src/helpers/isNodeActive.ts index 5540388e7c..5de5eebe8f 100644 --- a/packages/core/src/helpers/isNodeActive.ts +++ b/packages/core/src/helpers/isNodeActive.ts @@ -1,5 +1,5 @@ -import { NodeType } from 'prosemirror-model' -import { EditorState } from 'prosemirror-state' +import { NodeType } from '@tiptap/pm/model' +import { EditorState } from '@tiptap/pm/state' import { NodeRange } from '../types' import { objectIncludes } from '../utilities/objectIncludes' @@ -11,9 +11,7 @@ export function isNodeActive( attributes: Record = {}, ): boolean { const { from, to, empty } = state.selection - const type = typeOrName - ? getNodeType(typeOrName, state.schema) - : null + const type = typeOrName ? getNodeType(typeOrName, state.schema) : null const nodeRanges: NodeRange[] = [] @@ -47,8 +45,7 @@ export function isNodeActive( return !!matchedNodeRanges.length } - const range = matchedNodeRanges - .reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0) + const range = matchedNodeRanges.reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0) return range >= selectionRange } diff --git a/packages/core/src/helpers/isNodeEmpty.ts b/packages/core/src/helpers/isNodeEmpty.ts index 6cbaa4cd3e..6e9acea6c7 100644 --- a/packages/core/src/helpers/isNodeEmpty.ts +++ b/packages/core/src/helpers/isNodeEmpty.ts @@ -1,4 +1,4 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' export function isNodeEmpty(node: ProseMirrorNode): boolean { const defaultContent = node.type.createAndFill()?.toJSON() diff --git a/packages/core/src/helpers/isNodeSelection.ts b/packages/core/src/helpers/isNodeSelection.ts index cb40e62bd2..f915606028 100644 --- a/packages/core/src/helpers/isNodeSelection.ts +++ b/packages/core/src/helpers/isNodeSelection.ts @@ -1,4 +1,4 @@ -import { NodeSelection } from 'prosemirror-state' +import { NodeSelection } from '@tiptap/pm/state' export function isNodeSelection(value: unknown): value is NodeSelection { return value instanceof NodeSelection diff --git a/packages/core/src/helpers/isTextSelection.ts b/packages/core/src/helpers/isTextSelection.ts index 8d3ecd8a4a..651a1a5460 100644 --- a/packages/core/src/helpers/isTextSelection.ts +++ b/packages/core/src/helpers/isTextSelection.ts @@ -1,4 +1,4 @@ -import { TextSelection } from 'prosemirror-state' +import { TextSelection } from '@tiptap/pm/state' export function isTextSelection(value: unknown): value is TextSelection { return value instanceof TextSelection diff --git a/packages/core/src/helpers/posToDOMRect.ts b/packages/core/src/helpers/posToDOMRect.ts index 8c061bd095..7a47153487 100644 --- a/packages/core/src/helpers/posToDOMRect.ts +++ b/packages/core/src/helpers/posToDOMRect.ts @@ -1,4 +1,4 @@ -import { EditorView } from 'prosemirror-view' +import { EditorView } from '@tiptap/pm/view' import { minMax } from '../utilities/minMax' diff --git a/packages/core/src/helpers/resolveFocusPosition.ts b/packages/core/src/helpers/resolveFocusPosition.ts index f2b86574a1..20bea7bc0f 100644 --- a/packages/core/src/helpers/resolveFocusPosition.ts +++ b/packages/core/src/helpers/resolveFocusPosition.ts @@ -1,5 +1,5 @@ -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { Selection, TextSelection } from 'prosemirror-state' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { Selection, TextSelection } from '@tiptap/pm/state' import { FocusPosition } from '../types' import { minMax } from '../utilities/minMax' @@ -8,7 +8,6 @@ export function resolveFocusPosition( doc: ProseMirrorNode, position: FocusPosition = null, ): Selection | null { - if (!position) { return null } diff --git a/packages/core/src/helpers/selectionToInsertionEnd.ts b/packages/core/src/helpers/selectionToInsertionEnd.ts index c55cf4f9bd..09ac7beef9 100644 --- a/packages/core/src/helpers/selectionToInsertionEnd.ts +++ b/packages/core/src/helpers/selectionToInsertionEnd.ts @@ -1,5 +1,5 @@ -import { Selection, Transaction } from 'prosemirror-state' -import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform' +import { Selection, Transaction } from '@tiptap/pm/state' +import { ReplaceAroundStep, ReplaceStep } from '@tiptap/pm/transform' // source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466 export function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number) { diff --git a/packages/core/src/inputRules/markInputRule.ts b/packages/core/src/inputRules/markInputRule.ts index 589aa52dd5..896008756a 100644 --- a/packages/core/src/inputRules/markInputRule.ts +++ b/packages/core/src/inputRules/markInputRule.ts @@ -1,4 +1,4 @@ -import { MarkType } from 'prosemirror-model' +import { MarkType } from '@tiptap/pm/model' import { getMarksBetween } from '../helpers/getMarksBetween' import { InputRule, InputRuleFinder } from '../InputRule' @@ -10,14 +10,13 @@ import { callOrReturn } from '../utilities/callOrReturn' * matched text is typed into it. */ export function markInputRule(config: { - find: InputRuleFinder, - type: MarkType, + find: InputRuleFinder + type: MarkType getAttributes?: | Record | ((match: ExtendedRegExpMatchArray) => Record) | false | null - , }) { return new InputRule({ find: config.find, diff --git a/packages/core/src/inputRules/nodeInputRule.ts b/packages/core/src/inputRules/nodeInputRule.ts index 8fc1a2310a..7cb6e6c913 100644 --- a/packages/core/src/inputRules/nodeInputRule.ts +++ b/packages/core/src/inputRules/nodeInputRule.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'prosemirror-model' +import { NodeType } from '@tiptap/pm/model' import { InputRule, InputRuleFinder } from '../InputRule' import { ExtendedRegExpMatchArray } from '../types' @@ -9,14 +9,13 @@ import { callOrReturn } from '../utilities/callOrReturn' * matched text is typed into it. */ export function nodeInputRule(config: { - find: InputRuleFinder, - type: NodeType, + find: InputRuleFinder + type: NodeType getAttributes?: | Record | ((match: ExtendedRegExpMatchArray) => Record) | false | null - , }) { return new InputRule({ find: config.find, diff --git a/packages/core/src/inputRules/textblockTypeInputRule.ts b/packages/core/src/inputRules/textblockTypeInputRule.ts index e2f030b878..86be95ec73 100644 --- a/packages/core/src/inputRules/textblockTypeInputRule.ts +++ b/packages/core/src/inputRules/textblockTypeInputRule.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'prosemirror-model' +import { NodeType } from '@tiptap/pm/model' import { InputRule, InputRuleFinder } from '../InputRule' import { ExtendedRegExpMatchArray } from '../types' @@ -11,14 +11,13 @@ import { callOrReturn } from '../utilities/callOrReturn' * only occur at the start of a textblock. */ export function textblockTypeInputRule(config: { - find: InputRuleFinder, - type: NodeType, + find: InputRuleFinder + type: NodeType getAttributes?: | Record | ((match: ExtendedRegExpMatchArray) => Record) | false | null - , }) { return new InputRule({ find: config.find, diff --git a/packages/core/src/inputRules/wrappingInputRule.ts b/packages/core/src/inputRules/wrappingInputRule.ts index 380a824f11..c845a6dbca 100644 --- a/packages/core/src/inputRules/wrappingInputRule.ts +++ b/packages/core/src/inputRules/wrappingInputRule.ts @@ -1,5 +1,5 @@ -import { Node as ProseMirrorNode, NodeType } from 'prosemirror-model' -import { canJoin, findWrapping } from 'prosemirror-transform' +import { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model' +import { canJoin, findWrapping } from '@tiptap/pm/transform' import { InputRule, InputRuleFinder } from '../InputRule' import { ExtendedRegExpMatchArray } from '../types' @@ -20,15 +20,14 @@ import { callOrReturn } from '../utilities/callOrReturn' * return a boolean to indicate whether a join should happen. */ export function wrappingInputRule(config: { - find: InputRuleFinder, - type: NodeType, + find: InputRuleFinder + type: NodeType getAttributes?: | Record | ((match: ExtendedRegExpMatchArray) => Record) | false | null - , - joinPredicate?: (match: ExtendedRegExpMatchArray, node: ProseMirrorNode) => boolean, + joinPredicate?: (match: ExtendedRegExpMatchArray, node: ProseMirrorNode) => boolean }) { return new InputRule({ find: config.find, diff --git a/packages/core/src/pasteRules/markPasteRule.ts b/packages/core/src/pasteRules/markPasteRule.ts index 6aa2c21848..2b2789854f 100644 --- a/packages/core/src/pasteRules/markPasteRule.ts +++ b/packages/core/src/pasteRules/markPasteRule.ts @@ -1,4 +1,4 @@ -import { MarkType } from 'prosemirror-model' +import { MarkType } from '@tiptap/pm/model' import { getMarksBetween } from '../helpers/getMarksBetween' import { PasteRule, PasteRuleFinder } from '../PasteRule' @@ -10,14 +10,13 @@ import { callOrReturn } from '../utilities/callOrReturn' * matched text is pasted into it. */ export function markPasteRule(config: { - find: PasteRuleFinder, - type: MarkType, + find: PasteRuleFinder + type: MarkType getAttributes?: | Record | ((match: ExtendedRegExpMatchArray) => Record) | false | null - , }) { return new PasteRule({ find: config.find, diff --git a/packages/core/src/pasteRules/nodePasteRule.ts b/packages/core/src/pasteRules/nodePasteRule.ts index 94eeda5048..ccf1e11329 100644 --- a/packages/core/src/pasteRules/nodePasteRule.ts +++ b/packages/core/src/pasteRules/nodePasteRule.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'prosemirror-model' +import { NodeType } from '@tiptap/pm/model' import { PasteRule } from '../PasteRule' import { ExtendedRegExpMatchArray } from '../types' @@ -9,13 +9,13 @@ import { callOrReturn } from '../utilities' * matched text is pasted into it. */ export function nodePasteRule(config: { - find: RegExp, - type: NodeType, + find: RegExp + type: NodeType getAttributes?: | Record | ((match: ExtendedRegExpMatchArray) => Record) | false - | null, + | null }) { return new PasteRule({ find: config.find, @@ -27,12 +27,10 @@ export function nodePasteRule(config: { } if (match.input) { - chain() - .deleteRange(range) - .insertContentAt(range.from, { - type: config.type.name, - attrs: attributes, - }) + chain().deleteRange(range).insertContentAt(range.from, { + type: config.type.name, + attrs: attributes, + }) } }, }) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 596c8e68e3..76f84a8755 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1,21 +1,11 @@ +import { Mark as ProseMirrorMark, Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model' +import { EditorState, Transaction } from '@tiptap/pm/state' import { - Mark as ProseMirrorMark, - Node as ProseMirrorNode, - ParseOptions, -} from 'prosemirror-model' -import { EditorState, Transaction } from 'prosemirror-state' -import { - Decoration, - EditorProps, - EditorView, - NodeView, -} from 'prosemirror-view' + Decoration, EditorProps, EditorView, NodeView, +} from '@tiptap/pm/view' import { - Commands, - ExtensionConfig, - MarkConfig, - NodeConfig, + Commands, ExtensionConfig, MarkConfig, NodeConfig, } from '.' import { Editor } from './Editor' import { Extension } from './Extension' @@ -32,89 +22,80 @@ export type ParentConfig = Partial<{ : T[P] }> -export type Primitive = - | null - | undefined - | string - | number - | boolean - | symbol - | bigint +export type Primitive = null | undefined | string | number | boolean | symbol | bigint export type RemoveThis = T extends (...args: any) => any ? (...args: Parameters) => ReturnType : T -export type MaybeReturnType = T extends (...args: any) => any - ? ReturnType - : T +export type MaybeReturnType = T extends (...args: any) => any ? ReturnType : T export type MaybeThisParameterType = Exclude extends (...args: any) => any ? ThisParameterType> : any export interface EditorEvents { - beforeCreate: { editor: Editor }, - create: { editor: Editor }, - update: { editor: Editor, transaction: Transaction }, - selectionUpdate: { editor: Editor, transaction: Transaction }, - transaction: { editor: Editor, transaction: Transaction }, - focus: { editor: Editor, event: FocusEvent, transaction: Transaction }, - blur: { editor: Editor, event: FocusEvent, transaction: Transaction }, - destroy: void, + beforeCreate: { editor: Editor } + create: { editor: Editor } + update: { editor: Editor; transaction: Transaction } + selectionUpdate: { editor: Editor; transaction: Transaction } + transaction: { editor: Editor; transaction: Transaction } + focus: { editor: Editor; event: FocusEvent; transaction: Transaction } + blur: { editor: Editor; event: FocusEvent; transaction: Transaction } + destroy: void } export type EnableRules = (AnyExtension | string)[] | boolean export interface EditorOptions { - element: Element, - content: Content, - extensions: Extensions, - injectCSS: boolean, - injectNonce: string | undefined, - autofocus: FocusPosition, - editable: boolean, - editorProps: EditorProps, - parseOptions: ParseOptions, - enableInputRules: EnableRules, - enablePasteRules: EnableRules, - enableCoreExtensions: boolean, - onBeforeCreate: (props: EditorEvents['beforeCreate']) => void, - onCreate: (props: EditorEvents['create']) => void, - onUpdate: (props: EditorEvents['update']) => void, - onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void, - onTransaction: (props: EditorEvents['transaction']) => void, - onFocus: (props: EditorEvents['focus']) => void, - onBlur: (props: EditorEvents['blur']) => void, - onDestroy: (props: EditorEvents['destroy']) => void, + element: Element + content: Content + extensions: Extensions + injectCSS: boolean + injectNonce: string | undefined + autofocus: FocusPosition + editable: boolean + editorProps: EditorProps + parseOptions: ParseOptions + enableInputRules: EnableRules + enablePasteRules: EnableRules + enableCoreExtensions: boolean + onBeforeCreate: (props: EditorEvents['beforeCreate']) => void + onCreate: (props: EditorEvents['create']) => void + onUpdate: (props: EditorEvents['update']) => void + onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void + onTransaction: (props: EditorEvents['transaction']) => void + onFocus: (props: EditorEvents['focus']) => void + onBlur: (props: EditorEvents['blur']) => void + onDestroy: (props: EditorEvents['destroy']) => void } export type HTMLContent = string export type JSONContent = { - type?: string, - attrs?: Record, - content?: JSONContent[], + type?: string + attrs?: Record + content?: JSONContent[] marks?: { - type: string, - attrs?: Record, - [key: string]: any, - }[], - text?: string, - [key: string]: any, + type: string + attrs?: Record + [key: string]: any + }[] + text?: string + [key: string]: any } export type Content = HTMLContent | JSONContent | JSONContent[] | null export type CommandProps = { - editor: Editor, - tr: Transaction, - commands: SingleCommands, - can: () => CanCommands, - chain: () => ChainedCommands, - state: EditorState, - view: EditorView, - dispatch: ((args?: any) => any) | undefined, + editor: Editor + tr: Transaction + commands: SingleCommands + can: () => CanCommands + chain: () => ChainedCommands + state: EditorState + view: EditorView + dispatch: ((args?: any) => any) | undefined } export type Command = (props: CommandProps) => boolean @@ -124,80 +105,83 @@ export type CommandSpec = (...args: any[]) => Command export type KeyboardShortcutCommand = (props: { editor: Editor }) => boolean export type Attribute = { - default: any, - rendered?: boolean, - renderHTML?: ((attributes: Record) => Record | null) | null, - parseHTML?: ((element: HTMLElement) => any | null) | null, - keepOnSplit: boolean, - isRequired?: boolean, + default: any + rendered?: boolean + renderHTML?: ((attributes: Record) => Record | null) | null + parseHTML?: ((element: HTMLElement) => any | null) | null + keepOnSplit: boolean + isRequired?: boolean } export type Attributes = { - [key: string]: Attribute, + [key: string]: Attribute } export type ExtensionAttribute = { - type: string, - name: string, - attribute: Required, + type: string + name: string + attribute: Required } export type GlobalAttributes = { - types: string[], + types: string[] attributes: { [key: string]: Attribute - }, + } }[] export type PickValue = T[K] -export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) +export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I, +) => void ? I : never -export type Diff = - ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T] +export type Diff = ({ [P in T]: P } & { + [P in U]: never +} & { [x: string]: never })[T] export type Overwrite = Pick> & U export type ValuesOf = T[keyof T] -export type KeysWithTypeOf = ({ [P in keyof T]: T[P] extends Type ? P : never })[keyof T] +export type KeysWithTypeOf = { [P in keyof T]: T[P] extends Type ? P : never }[keyof T] export type NodeViewProps = { - editor: Editor, - node: ProseMirrorNode, - decorations: Decoration[], - selected: boolean, - extension: Node, - getPos: () => number, - updateAttributes: (attributes: Record) => void, - deleteNode: () => void, + editor: Editor + node: ProseMirrorNode + decorations: Decoration[] + selected: boolean + extension: Node + getPos: () => number + updateAttributes: (attributes: Record) => void + deleteNode: () => void } export interface NodeViewRendererOptions { - stopEvent: ((props: { - event: Event - }) => boolean) | null, - ignoreMutation: ((props: { - mutation: MutationRecord | { type: 'selection', target: Element } - }) => boolean) | null, + stopEvent: ((props: { event: Event }) => boolean) | null + ignoreMutation: + | ((props: { mutation: MutationRecord | { type: 'selection'; target: Element } }) => boolean) + | null } export type NodeViewRendererProps = { - editor: Editor, - node: ProseMirrorNode, - getPos: (() => number) | boolean, - HTMLAttributes: Record, - decorations: Decoration[], - extension: Node, + editor: Editor + node: ProseMirrorNode + getPos: (() => number) | boolean + HTMLAttributes: Record + decorations: Decoration[] + extension: Node } -export type NodeViewRenderer = (props: NodeViewRendererProps) => (NodeView | {}) +export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView | {} export type AnyCommands = Record Command> -export type UnionCommands = UnionToIntersection, KeysWithTypeOf, {}>>>> +export type UnionCommands = UnionToIntersection< + ValuesOf, KeysWithTypeOf, {}>>> +> export type RawCommands = { [Item in keyof UnionCommands]: UnionCommands[Item] @@ -218,39 +202,39 @@ export type CanCommands = SingleCommands & { chain: () => ChainedCommands } export type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null export type Range = { - from: number, - to: number, + from: number + to: number } export type NodeRange = { - node: ProseMirrorNode, - from: number, - to: number, + node: ProseMirrorNode + from: number + to: number } export type MarkRange = { - mark: ProseMirrorMark, - from: number, - to: number, + mark: ProseMirrorMark + from: number + to: number } export type Predicate = (node: ProseMirrorNode) => boolean export type NodeWithPos = { - node: ProseMirrorNode, - pos: number, + node: ProseMirrorNode + pos: number } export type TextSerializer = (props: { - node: ProseMirrorNode, - pos: number, - parent: ProseMirrorNode, - index: number, - range: Range, + node: ProseMirrorNode + pos: number + parent: ProseMirrorNode + index: number + range: Range }) => string export type ExtendedRegExpMatchArray = RegExpMatchArray & { - data?: Record, + data?: Record } export type Dispatch = ((args?: any) => any) | undefined diff --git a/packages/extension-bold/package.json b/packages/extension-bold/package.json index 70641a5028..396b5fbb65 100644 --- a/packages/extension-bold/package.json +++ b/packages/extension-bold/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-bubble-menu/package.json b/packages/extension-bubble-menu/package.json index b5a5021167..d64a4a151f 100644 --- a/packages/extension-bubble-menu/package.json +++ b/packages/extension-bubble-menu/package.json @@ -15,9 +15,9 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "types": "./dist/packages/extension-bubble-menu/src/index.d.ts", + "import": "./dist/tiptap-extension-bubble-menu.esm.js", + "require": "./dist/tiptap-extension-bubble-menu.cjs" } }, "main": "dist/index.cjs", @@ -28,15 +28,11 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "dependencies": { - "@tiptap/core": "^2.0.0-beta.209", "lodash": "^4.17.21", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", "tippy.js": "^6.3.7" }, "repository": { @@ -46,7 +42,9 @@ }, "sideEffects": false, "devDependencies": { - "@types/lodash": "^4.14.187" + "@types/lodash": "^4.14.187", + "prosemirror-state": "^1.4.1", + "prosemirror-view": "^1.28.2" }, "scripts": { "build": "tsup" diff --git a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts index 42fd6953d4..f297f43aca 100644 --- a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts +++ b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts @@ -1,32 +1,31 @@ import { - Editor, - isNodeSelection, - isTextSelection, - posToDOMRect, + Editor, isNodeSelection, isTextSelection, posToDOMRect, } from '@tiptap/core' +import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state' +import { EditorView } from '@tiptap/pm/view' import debounce from 'lodash/debounce' -import { EditorState, Plugin, PluginKey } from 'prosemirror-state' -import { EditorView } from 'prosemirror-view' import tippy, { Instance, Props } from 'tippy.js' export interface BubbleMenuPluginProps { - pluginKey: PluginKey | string, - editor: Editor, - element: HTMLElement, - tippyOptions?: Partial, - updateDelay?: number, - shouldShow?: ((props: { - editor: Editor, - view: EditorView, - state: EditorState, - oldState?: EditorState, - from: number, - to: number, - }) => boolean) | null, + pluginKey: PluginKey | string + editor: Editor + element: HTMLElement + tippyOptions?: Partial + updateDelay?: number + shouldShow?: + | ((props: { + editor: Editor + view: EditorView + state: EditorState + oldState?: EditorState + from: number + to: number + }) => boolean) + | null } export type BubbleMenuViewProps = BubbleMenuPluginProps & { - view: EditorView, + view: EditorView } export class BubbleMenuView { @@ -56,8 +55,7 @@ export class BubbleMenuView { // Sometime check for `empty` is not enough. // Doubleclick an empty paragraph returns a node size of 2. // So we check also for an empty text size. - const isEmptyTextBlock = !doc.textBetween(from, to).length - && isTextSelection(state.selection) + const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection) // When clicking on a element inside the bubble menu the editor "blur" event // is called and the bubble menu item is focussed. In this case we should @@ -66,12 +64,7 @@ export class BubbleMenuView { const hasEditorFocus = view.hasFocus() || isChildOfMenu - if ( - !hasEditorFocus - || empty - || isEmptyTextBlock - || !this.editor.isEditable - ) { + if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) { return false } @@ -125,17 +118,14 @@ export class BubbleMenuView { return } - if ( - event?.relatedTarget - && this.element.parentNode?.contains(event.relatedTarget as Node) - ) { + if (event?.relatedTarget && this.element.parentNode?.contains(event.relatedTarget as Node)) { return } this.hide() } - tippyBlurHandler = (event : FocusEvent) => { + tippyBlurHandler = (event: FocusEvent) => { this.blurHandler({ event }) } @@ -207,17 +197,19 @@ export class BubbleMenuView { } this.tippy?.setProps({ - getReferenceClientRect: this.tippyOptions?.getReferenceClientRect || (() => { - if (isNodeSelection(state.selection)) { - const node = view.nodeDOM(from) as HTMLElement - - if (node) { - return node.getBoundingClientRect() + getReferenceClientRect: + this.tippyOptions?.getReferenceClientRect + || (() => { + if (isNodeSelection(state.selection)) { + const node = view.nodeDOM(from) as HTMLElement + + if (node) { + return node.getBoundingClientRect() + } } - } - return posToDOMRect(view, from, to) - }), + return posToDOMRect(view, from, to) + }), }) this.show() @@ -233,7 +225,10 @@ export class BubbleMenuView { destroy() { if (this.tippy?.popper.firstChild) { - (this.tippy.popper.firstChild as HTMLElement).removeEventListener('blur', this.tippyBlurHandler) + (this.tippy.popper.firstChild as HTMLElement).removeEventListener( + 'blur', + this.tippyBlurHandler, + ) } this.tippy?.destroy() this.element.removeEventListener('mousedown', this.mousedownHandler, { capture: true }) @@ -245,9 +240,8 @@ export class BubbleMenuView { export const BubbleMenuPlugin = (options: BubbleMenuPluginProps) => { return new Plugin({ - key: typeof options.pluginKey === 'string' - ? new PluginKey(options.pluginKey) - : options.pluginKey, + key: + typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey, view: view => new BubbleMenuView({ view, ...options }), }) } diff --git a/packages/extension-bullet-list/package.json b/packages/extension-bullet-list/package.json index 894b8bb246..0a7d80bb86 100644 --- a/packages/extension-bullet-list/package.json +++ b/packages/extension-bullet-list/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-character-count/package.json b/packages/extension-character-count/package.json index 9d10d30069..ff33808e01 100644 --- a/packages/extension-character-count/package.json +++ b/packages/extension-character-count/package.json @@ -28,14 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-character-count/src/character-count.ts b/packages/extension-character-count/src/character-count.ts index 74651f0e7a..587df25ed0 100644 --- a/packages/extension-character-count/src/character-count.ts +++ b/packages/extension-character-count/src/character-count.ts @@ -1,33 +1,28 @@ import { Extension } from '@tiptap/core' -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { Plugin, PluginKey } from 'prosemirror-state' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { Plugin, PluginKey } from '@tiptap/pm/state' export interface CharacterCountOptions { /** * The maximum number of characters that should be allowed. Defaults to `0`. */ - limit: number | null | undefined, + limit: number | null | undefined /** * The mode by which the size is calculated. Defaults to 'textSize'. */ - mode: 'textSize' | 'nodeSize', + mode: 'textSize' | 'nodeSize' } export interface CharacterCountStorage { /** * Get the number of characters for the current document. */ - characters: (options?: { - node?: ProseMirrorNode, - mode?: 'textSize' | 'nodeSize', - }) => number, + characters: (options?: { node?: ProseMirrorNode; mode?: 'textSize' | 'nodeSize' }) => number /** * Get the number of words for the current document. */ - words: (options?: { - node?: ProseMirrorNode, - }) => number, + words: (options?: { node?: ProseMirrorNode }) => number } export const CharacterCount = Extension.create({ @@ -64,9 +59,7 @@ export const CharacterCount = Extension.create { const node = options?.node || this.editor.state.doc const text = node.textBetween(0, node.content.size, ' ', ' ') - const words = text - .split(' ') - .filter(word => word !== '') + const words = text.split(' ').filter(word => word !== '') return words.length } diff --git a/packages/extension-code-block-lowlight/package.json b/packages/extension-code-block-lowlight/package.json index 1511164ac2..486c27f225 100644 --- a/packages/extension-code-block-lowlight/package.json +++ b/packages/extension-code-block-lowlight/package.json @@ -28,18 +28,14 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/extension-code-block": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/extension-code-block": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", "@tiptap/extension-code-block": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-code-block-lowlight/src/lowlight-plugin.ts b/packages/extension-code-block-lowlight/src/lowlight-plugin.ts index 6c0ec1c268..5280ca5d9f 100644 --- a/packages/extension-code-block-lowlight/src/lowlight-plugin.ts +++ b/packages/extension-code-block-lowlight/src/lowlight-plugin.ts @@ -1,19 +1,14 @@ import { findChildren } from '@tiptap/core' +import { Node as ProsemirrorNode } from '@tiptap/pm/model' +import { Plugin, PluginKey } from '@tiptap/pm/state' +import { Decoration, DecorationSet } from '@tiptap/pm/view' // @ts-ignore import highlight from 'highlight.js/lib/core' -import { Node as ProsemirrorNode } from 'prosemirror-model' -import { Plugin, PluginKey } from 'prosemirror-state' -import { Decoration, DecorationSet } from 'prosemirror-view' -function parseNodes(nodes: any[], className: string[] = []): { text: string, classes: string[] }[] { +function parseNodes(nodes: any[], className: string[] = []): { text: string; classes: string[] }[] { return nodes .map(node => { - const classes = [ - ...className, - ...node.properties - ? node.properties.className - : [], - ] + const classes = [...className, ...(node.properties ? node.properties.className : [])] if (node.children) { return parseNodes(node.children, classes) @@ -41,33 +36,37 @@ function getDecorations({ name, lowlight, defaultLanguage, -}: { doc: ProsemirrorNode, name: string, lowlight: any, defaultLanguage: string | null | undefined }) { +}: { + doc: ProsemirrorNode + name: string + lowlight: any + defaultLanguage: string | null | undefined +}) { const decorations: Decoration[] = [] - findChildren(doc, node => node.type.name === name) - .forEach(block => { - let from = block.pos + 1 - const language = block.node.attrs.language || defaultLanguage - const languages = lowlight.listLanguages() + findChildren(doc, node => node.type.name === name).forEach(block => { + let from = block.pos + 1 + const language = block.node.attrs.language || defaultLanguage + const languages = lowlight.listLanguages() - const nodes = language && (languages.includes(language) || registered(language)) - ? getHighlightNodes(lowlight.highlight(language, block.node.textContent)) - : getHighlightNodes(lowlight.highlightAuto(block.node.textContent)) + const nodes = language && (languages.includes(language) || registered(language)) + ? getHighlightNodes(lowlight.highlight(language, block.node.textContent)) + : getHighlightNodes(lowlight.highlightAuto(block.node.textContent)) - parseNodes(nodes).forEach(node => { - const to = from + node.text.length + parseNodes(nodes).forEach(node => { + const to = from + node.text.length - if (node.classes.length) { - const decoration = Decoration.inline(from, to, { - class: node.classes.join(' '), - }) + if (node.classes.length) { + const decoration = Decoration.inline(from, to, { + class: node.classes.join(' '), + }) - decorations.push(decoration) - } + decorations.push(decoration) + } - from = to - }) + from = to }) + }) return DecorationSet.create(doc, decorations) } @@ -76,9 +75,19 @@ function isFunction(param: Function) { return typeof param === 'function' } -export function LowlightPlugin({ name, lowlight, defaultLanguage }: { name: string, lowlight: any, defaultLanguage: string | null | undefined }) { +export function LowlightPlugin({ + name, + lowlight, + defaultLanguage, +}: { + name: string + lowlight: any + defaultLanguage: string | null | undefined +}) { if (!['highlight', 'highlightAuto', 'listLanguages'].every(api => isFunction(lowlight[api]))) { - throw Error('You should provide an instance of lowlight to use the code-block-lowlight extension') + throw Error( + 'You should provide an instance of lowlight to use the code-block-lowlight extension', + ) } const lowlightPlugin: Plugin = new Plugin({ @@ -100,9 +109,8 @@ export function LowlightPlugin({ name, lowlight, defaultLanguage }: { name: stri if ( transaction.docChanged // Apply decorations if: - && ( - // selection includes named node, - [oldNodeName, newNodeName].includes(name) + // selection includes named node, + && ([oldNodeName, newNodeName].includes(name) // OR transaction adds/removes named node, || newNodes.length !== oldNodes.length // OR transaction has changes that completely encapsulte a node @@ -110,17 +118,22 @@ export function LowlightPlugin({ name, lowlight, defaultLanguage }: { name: stri // Such transactions can happen during collab syncing via y-prosemirror, for example. || transaction.steps.some(step => { // @ts-ignore - return step.from !== undefined + return ( + // @ts-ignore + step.from !== undefined // @ts-ignore && step.to !== undefined && oldNodes.some(node => { // @ts-ignore - return node.pos >= step.from + return ( + // @ts-ignore + node.pos >= step.from // @ts-ignore && node.pos + node.node.nodeSize <= step.to + ) }) - }) - ) + ) + })) ) { return getDecorations({ doc: transaction.doc, diff --git a/packages/extension-code-block/package.json b/packages/extension-code-block/package.json index 130809cc3c..f870b9cd74 100644 --- a/packages/extension-code-block/package.json +++ b/packages/extension-code-block/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-code-block/src/code-block.ts b/packages/extension-code-block/src/code-block.ts index fec3461bfe..9f8619487e 100644 --- a/packages/extension-code-block/src/code-block.ts +++ b/packages/extension-code-block/src/code-block.ts @@ -1,26 +1,26 @@ import { mergeAttributes, Node, textblockTypeInputRule } from '@tiptap/core' -import { Plugin, PluginKey, TextSelection } from 'prosemirror-state' +import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state' export interface CodeBlockOptions { /** * Adds a prefix to language classes that are applied to code tags. * Defaults to `'language-'`. */ - languageClassPrefix: string, + languageClassPrefix: string /** * Define whether the node should be exited on triple enter. * Defaults to `true`. */ - exitOnTripleEnter: boolean, + exitOnTripleEnter: boolean /** * Define whether the node should be exited on arrow down if there is no node after it. * Defaults to `true`. */ - exitOnArrowDown: boolean, + exitOnArrowDown: boolean /** * Custom HTML attributes that should be added to the rendered HTML tag. */ - HTMLAttributes: Record, + HTMLAttributes: Record } declare module '@tiptap/core' { @@ -29,11 +29,11 @@ declare module '@tiptap/core' { /** * Set a code block */ - setCodeBlock: (attributes?: { language: string }) => ReturnType, + setCodeBlock: (attributes?: { language: string }) => ReturnType /** * Toggle a code block */ - toggleCodeBlock: (attributes?: { language: string }) => ReturnType, + toggleCodeBlock: (attributes?: { language: string }) => ReturnType } } } @@ -69,7 +69,7 @@ export const CodeBlock = Node.create({ default: null, parseHTML: element => { const { languageClassPrefix } = this.options - const classNames = [...element.firstElementChild?.classList || []] + const classNames = [...(element.firstElementChild?.classList || [])] const languages = classNames .filter(className => className.startsWith(languageClassPrefix)) .map(className => className.replace(languageClassPrefix, '')) @@ -113,12 +113,14 @@ export const CodeBlock = Node.create({ addCommands() { return { - setCodeBlock: attributes => ({ commands }) => { - return commands.setNode(this.name, attributes) - }, - toggleCodeBlock: attributes => ({ commands }) => { - return commands.toggleNode(this.name, 'paragraph', attributes) - }, + setCodeBlock: + attributes => ({ commands }) => { + return commands.setNode(this.name, attributes) + }, + toggleCodeBlock: + attributes => ({ commands }) => { + return commands.toggleNode(this.name, 'paragraph', attributes) + }, } }, @@ -249,9 +251,7 @@ export const CodeBlock = Node.create({ const text = event.clipboardData.getData('text/plain') const vscode = event.clipboardData.getData('vscode-editor-data') - const vscodeData = vscode - ? JSON.parse(vscode) - : undefined + const vscodeData = vscode ? JSON.parse(vscode) : undefined const language = vscodeData?.mode if (!text || !language) { diff --git a/packages/extension-code/package.json b/packages/extension-code/package.json index 24edaccfa3..e6ba77426d 100644 --- a/packages/extension-code/package.json +++ b/packages/extension-code/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-collaboration-cursor/package.json b/packages/extension-collaboration-cursor/package.json index 2c1d3a2c38..2f8362d837 100644 --- a/packages/extension-collaboration-cursor/package.json +++ b/packages/extension-collaboration-cursor/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", + "@tiptap/core": "^2.0.0-beta.209", "y-prosemirror": "1.0.20" }, "devDependencies": { diff --git a/packages/extension-collaboration/package.json b/packages/extension-collaboration/package.json index a3b0685d90..7e3644683d 100644 --- a/packages/extension-collaboration/package.json +++ b/packages/extension-collaboration/package.json @@ -28,13 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "y-prosemirror": "1.0.20" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", + "@tiptap/pm": "^2.0.0-beta.209", "y-prosemirror": "1.0.20" }, "repository": { diff --git a/packages/extension-collaboration/src/helpers/isChangeOrigin.ts b/packages/extension-collaboration/src/helpers/isChangeOrigin.ts index e281148d69..754b7fbf07 100644 --- a/packages/extension-collaboration/src/helpers/isChangeOrigin.ts +++ b/packages/extension-collaboration/src/helpers/isChangeOrigin.ts @@ -1,4 +1,4 @@ -import { Transaction } from 'prosemirror-state' +import { Transaction } from '@tiptap/pm/state' import { ySyncPluginKey } from 'y-prosemirror' export function isChangeOrigin(transaction: Transaction): boolean { diff --git a/packages/extension-color/package.json b/packages/extension-color/package.json index fd93aa34f0..2e0b1e3678 100644 --- a/packages/extension-color/package.json +++ b/packages/extension-color/package.json @@ -28,8 +28,8 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/extension-text-style": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/extension-text-style": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", diff --git a/packages/extension-document/package.json b/packages/extension-document/package.json index 6db3f1266a..1baa5affb6 100644 --- a/packages/extension-document/package.json +++ b/packages/extension-document/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-dropcursor/package.json b/packages/extension-dropcursor/package.json index 2b192bdce5..f4c9470bc5 100644 --- a/packages/extension-dropcursor/package.json +++ b/packages/extension-dropcursor/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-dropcursor": "1.5.0" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-dropcursor": "1.5.0" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-dropcursor/src/dropcursor.ts b/packages/extension-dropcursor/src/dropcursor.ts index 681939a2db..4cc0a4a20b 100644 --- a/packages/extension-dropcursor/src/dropcursor.ts +++ b/packages/extension-dropcursor/src/dropcursor.ts @@ -1,5 +1,5 @@ import { Extension } from '@tiptap/core' -import { dropCursor } from 'prosemirror-dropcursor' +import { dropCursor } from '@tiptap/pm/dropcursor' export interface DropcursorOptions { color: string | undefined, diff --git a/packages/extension-floating-menu/package.json b/packages/extension-floating-menu/package.json index ac6493bed9..0652129abc 100644 --- a/packages/extension-floating-menu/package.json +++ b/packages/extension-floating-menu/package.json @@ -28,14 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "dependencies": { "tippy.js": "^6.3.7" diff --git a/packages/extension-floating-menu/src/floating-menu-plugin.ts b/packages/extension-floating-menu/src/floating-menu-plugin.ts index 6f4f6e2bcc..ed10798789 100644 --- a/packages/extension-floating-menu/src/floating-menu-plugin.ts +++ b/packages/extension-floating-menu/src/floating-menu-plugin.ts @@ -1,23 +1,25 @@ import { Editor, posToDOMRect } from '@tiptap/core' -import { EditorState, Plugin, PluginKey } from 'prosemirror-state' -import { EditorView } from 'prosemirror-view' +import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state' +import { EditorView } from '@tiptap/pm/view' import tippy, { Instance, Props } from 'tippy.js' export interface FloatingMenuPluginProps { - pluginKey: PluginKey | string, - editor: Editor, - element: HTMLElement, - tippyOptions?: Partial, - shouldShow?: ((props: { - editor: Editor, - view: EditorView, - state: EditorState, - oldState?: EditorState, - }) => boolean) | null, + pluginKey: PluginKey | string + editor: Editor + element: HTMLElement + tippyOptions?: Partial + shouldShow?: + | ((props: { + editor: Editor + view: EditorView + state: EditorState + oldState?: EditorState + }) => boolean) + | null } export type FloatingMenuViewProps = FloatingMenuPluginProps & { - view: EditorView, + view: EditorView } export class FloatingMenuView { @@ -37,9 +39,7 @@ export class FloatingMenuView { const { selection } = state const { $anchor, empty } = selection const isRootDepth = $anchor.depth === 1 - const isEmptyTextBlock = $anchor.parent.isTextblock - && !$anchor.parent.type.spec.code - && !$anchor.parent.textContent + const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent if ( !view.hasFocus() @@ -55,11 +55,7 @@ export class FloatingMenuView { } constructor({ - editor, - element, - view, - tippyOptions = {}, - shouldShow, + editor, element, view, tippyOptions = {}, shouldShow, }: FloatingMenuViewProps) { this.editor = editor this.element = element @@ -94,17 +90,14 @@ export class FloatingMenuView { return } - if ( - event?.relatedTarget - && this.element.parentNode?.contains(event.relatedTarget as Node) - ) { + if (event?.relatedTarget && this.element.parentNode?.contains(event.relatedTarget as Node)) { return } this.hide() } - tippyBlurHandler = (event : FocusEvent) => { + tippyBlurHandler = (event: FocusEvent) => { this.blurHandler({ event }) } @@ -159,7 +152,8 @@ export class FloatingMenuView { } this.tippy?.setProps({ - getReferenceClientRect: this.tippyOptions?.getReferenceClientRect || (() => posToDOMRect(view, from, to)), + getReferenceClientRect: + this.tippyOptions?.getReferenceClientRect || (() => posToDOMRect(view, from, to)), }) this.show() @@ -175,7 +169,10 @@ export class FloatingMenuView { destroy() { if (this.tippy?.popper.firstChild) { - (this.tippy.popper.firstChild as HTMLElement).removeEventListener('blur', this.tippyBlurHandler) + (this.tippy.popper.firstChild as HTMLElement).removeEventListener( + 'blur', + this.tippyBlurHandler, + ) } this.tippy?.destroy() this.element.removeEventListener('mousedown', this.mousedownHandler, { capture: true }) @@ -186,9 +183,8 @@ export class FloatingMenuView { export const FloatingMenuPlugin = (options: FloatingMenuPluginProps) => { return new Plugin({ - key: typeof options.pluginKey === 'string' - ? new PluginKey(options.pluginKey) - : options.pluginKey, + key: + typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey, view: view => new FloatingMenuView({ view, ...options }), }) } diff --git a/packages/extension-focus/package.json b/packages/extension-focus/package.json index 82e571109b..87abb49ddf 100644 --- a/packages/extension-focus/package.json +++ b/packages/extension-focus/package.json @@ -28,14 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-focus/src/focus.ts b/packages/extension-focus/src/focus.ts index 6e1d8f26fd..65e5e92442 100644 --- a/packages/extension-focus/src/focus.ts +++ b/packages/extension-focus/src/focus.ts @@ -1,10 +1,10 @@ import { Extension } from '@tiptap/core' -import { Plugin, PluginKey } from 'prosemirror-state' -import { Decoration, DecorationSet } from 'prosemirror-view' +import { Plugin, PluginKey } from '@tiptap/pm/state' +import { Decoration, DecorationSet } from '@tiptap/pm/view' export interface FocusOptions { - className: string, - mode: 'all' | 'deepest' | 'shallowest', + className: string + mode: 'all' | 'deepest' | 'shallowest' } export const FocusClasses = Extension.create({ @@ -40,7 +40,7 @@ export const FocusClasses = Extension.create({ return } - const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1) + const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1 if (!isCurrent) { return false @@ -58,7 +58,7 @@ export const FocusClasses = Extension.create({ return false } - const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1) + const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1 if (!isCurrent) { return false @@ -73,9 +73,11 @@ export const FocusClasses = Extension.create({ return this.options.mode === 'deepest' } - decorations.push(Decoration.node(pos, pos + node.nodeSize, { - class: this.options.className, - })) + decorations.push( + Decoration.node(pos, pos + node.nodeSize, { + class: this.options.className, + }), + ) }) return DecorationSet.create(doc, decorations) diff --git a/packages/extension-font-family/package.json b/packages/extension-font-family/package.json index ec62a8e67b..65b759e68a 100644 --- a/packages/extension-font-family/package.json +++ b/packages/extension-font-family/package.json @@ -28,8 +28,8 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/extension-text-style": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/extension-text-style": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", diff --git a/packages/extension-gapcursor/package.json b/packages/extension-gapcursor/package.json index 8ce980699a..cf6ada5696 100644 --- a/packages/extension-gapcursor/package.json +++ b/packages/extension-gapcursor/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-gapcursor": "^1.3.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-gapcursor": "^1.3.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-gapcursor/src/gapcursor.ts b/packages/extension-gapcursor/src/gapcursor.ts index 0ec66b4d98..cabfc49e20 100644 --- a/packages/extension-gapcursor/src/gapcursor.ts +++ b/packages/extension-gapcursor/src/gapcursor.ts @@ -4,7 +4,7 @@ import { getExtensionField, ParentConfig, } from '@tiptap/core' -import { gapCursor } from 'prosemirror-gapcursor' +import { gapCursor } from '@tiptap/pm/gapcursor' declare module '@tiptap/core' { interface NodeConfig { diff --git a/packages/extension-hard-break/package.json b/packages/extension-hard-break/package.json index 131187c04e..71480f7861 100644 --- a/packages/extension-hard-break/package.json +++ b/packages/extension-hard-break/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-heading/package.json b/packages/extension-heading/package.json index 85d87e2ffe..4f399facad 100644 --- a/packages/extension-heading/package.json +++ b/packages/extension-heading/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-highlight/package.json b/packages/extension-highlight/package.json index c0e88e3a85..6ff5d2fd92 100644 --- a/packages/extension-highlight/package.json +++ b/packages/extension-highlight/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-history/package.json b/packages/extension-history/package.json index 3adf45ef8c..bb20d4faf8 100644 --- a/packages/extension-history/package.json +++ b/packages/extension-history/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-history": "^1.3.0" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-history": "^1.3.0" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-history/src/history.ts b/packages/extension-history/src/history.ts index 9f6919fa6f..3c1255de8c 100644 --- a/packages/extension-history/src/history.ts +++ b/packages/extension-history/src/history.ts @@ -1,5 +1,5 @@ import { Extension } from '@tiptap/core' -import { history, redo, undo } from 'prosemirror-history' +import { history, redo, undo } from '@tiptap/pm/history' export interface HistoryOptions { depth: number, diff --git a/packages/extension-horizontal-rule/package.json b/packages/extension-horizontal-rule/package.json index c96cb23c90..0cb340ef85 100644 --- a/packages/extension-horizontal-rule/package.json +++ b/packages/extension-horizontal-rule/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-horizontal-rule/src/horizontal-rule.ts b/packages/extension-horizontal-rule/src/horizontal-rule.ts index 1f5c89734e..5d75a1be22 100644 --- a/packages/extension-horizontal-rule/src/horizontal-rule.ts +++ b/packages/extension-horizontal-rule/src/horizontal-rule.ts @@ -1,12 +1,8 @@ -import { - mergeAttributes, - Node, - nodeInputRule, -} from '@tiptap/core' -import { TextSelection } from 'prosemirror-state' +import { mergeAttributes, Node, nodeInputRule } from '@tiptap/core' +import { TextSelection } from '@tiptap/pm/state' export interface HorizontalRuleOptions { - HTMLAttributes: Record, + HTMLAttributes: Record } declare module '@tiptap/core' { @@ -15,7 +11,7 @@ declare module '@tiptap/core' { /** * Add a horizontal rule */ - setHorizontalRule: () => ReturnType, + setHorizontalRule: () => ReturnType } } } @@ -32,9 +28,7 @@ export const HorizontalRule = Node.create({ group: 'block', parseHTML() { - return [ - { tag: 'hr' }, - ] + return [{ tag: 'hr' }] }, renderHTML({ HTMLAttributes }) { @@ -43,34 +37,37 @@ export const HorizontalRule = Node.create({ addCommands() { return { - setHorizontalRule: () => ({ chain }) => { - return chain() - .insertContent({ type: this.name }) - // set cursor after horizontal rule - .command(({ tr, dispatch }) => { - if (dispatch) { - const { $to } = tr.selection - const posAfter = $to.end() + setHorizontalRule: + () => ({ chain }) => { + return ( + chain() + .insertContent({ type: this.name }) + // set cursor after horizontal rule + .command(({ tr, dispatch }) => { + if (dispatch) { + const { $to } = tr.selection + const posAfter = $to.end() - if ($to.nodeAfter) { - tr.setSelection(TextSelection.create(tr.doc, $to.pos)) - } else { - // add node after horizontal rule if it’s the end of the document - const node = $to.parent.type.contentMatch.defaultType?.create() + if ($to.nodeAfter) { + tr.setSelection(TextSelection.create(tr.doc, $to.pos)) + } else { + // add node after horizontal rule if it’s the end of the document + const node = $to.parent.type.contentMatch.defaultType?.create() - if (node) { - tr.insert(posAfter, node) - tr.setSelection(TextSelection.create(tr.doc, posAfter)) - } - } + if (node) { + tr.insert(posAfter, node) + tr.setSelection(TextSelection.create(tr.doc, posAfter)) + } + } - tr.scrollIntoView() - } + tr.scrollIntoView() + } - return true - }) - .run() - }, + return true + }) + .run() + ) + }, } }, diff --git a/packages/extension-image/package.json b/packages/extension-image/package.json index b69480e387..7267542b9b 100644 --- a/packages/extension-image/package.json +++ b/packages/extension-image/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-italic/package.json b/packages/extension-italic/package.json index 70a8c35773..fa7b86f41c 100644 --- a/packages/extension-italic/package.json +++ b/packages/extension-italic/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-link/package.json b/packages/extension-link/package.json index 6283d18b2e..a40960fe65 100644 --- a/packages/extension-link/package.json +++ b/packages/extension-link/package.json @@ -28,14 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "dependencies": { "linkifyjs": "^3.0.5" diff --git a/packages/extension-link/src/helpers/autolink.ts b/packages/extension-link/src/helpers/autolink.ts index 6a8c5e035f..123a610c29 100644 --- a/packages/extension-link/src/helpers/autolink.ts +++ b/packages/extension-link/src/helpers/autolink.ts @@ -5,21 +5,20 @@ import { getMarksBetween, NodeWithPos, } from '@tiptap/core' +import { MarkType } from '@tiptap/pm/model' +import { Plugin, PluginKey } from '@tiptap/pm/state' import { find, test } from 'linkifyjs' -import { MarkType } from 'prosemirror-model' -import { Plugin, PluginKey } from 'prosemirror-state' type AutolinkOptions = { - type: MarkType, - validate?: (url: string) => boolean, + type: MarkType + validate?: (url: string) => boolean } export function autolink(options: AutolinkOptions): Plugin { return new Plugin({ key: new PluginKey('autolink'), appendTransaction: (transactions, oldState, newState) => { - const docChanges = transactions.some(transaction => transaction.docChanged) - && !oldState.doc.eq(newState.doc) + const docChanges = transactions.some(transaction => transaction.docChanged) && !oldState.doc.eq(newState.doc) const preventAutolink = transactions.some(transaction => transaction.getMeta('preventAutolink')) if (!docChanges || preventAutolink) { @@ -38,8 +37,9 @@ export function autolink(options: AutolinkOptions): Plugin { .forEach(oldMark => { const newFrom = mapping.map(oldMark.from) const newTo = mapping.map(oldMark.to) - const newMarks = getMarksBetween(newFrom, newTo, newState.doc) - .filter(item => item.mark.type === options.type) + const newMarks = getMarksBetween(newFrom, newTo, newState.doc).filter( + item => item.mark.type === options.type, + ) if (!newMarks.length) { return @@ -59,7 +59,11 @@ export function autolink(options: AutolinkOptions): Plugin { }) // now let’s see if we can add new links - const nodesInChangedRanges = findChildrenInRange(newState.doc, newRange, node => node.isTextblock) + const nodesInChangedRanges = findChildrenInRange( + newState.doc, + newRange, + node => node.isTextblock, + ) let textBlock: NodeWithPos | undefined let textBeforeWhitespace: string | undefined @@ -117,9 +121,13 @@ export function autolink(options: AutolinkOptions): Plugin { })) // add link mark .forEach(link => { - tr.addMark(link.from, link.to, options.type.create({ - href: link.href, - })) + tr.addMark( + link.from, + link.to, + options.type.create({ + href: link.href, + }), + ) }) } }) diff --git a/packages/extension-link/src/helpers/clickHandler.ts b/packages/extension-link/src/helpers/clickHandler.ts index c74313e9f0..884628cf2f 100644 --- a/packages/extension-link/src/helpers/clickHandler.ts +++ b/packages/extension-link/src/helpers/clickHandler.ts @@ -1,9 +1,9 @@ import { getAttributes } from '@tiptap/core' -import { MarkType } from 'prosemirror-model' -import { Plugin, PluginKey } from 'prosemirror-state' +import { MarkType } from '@tiptap/pm/model' +import { Plugin, PluginKey } from '@tiptap/pm/state' type ClickHandlerOptions = { - type: MarkType, + type: MarkType } export function clickHandler(options: ClickHandlerOptions): Plugin { diff --git a/packages/extension-link/src/helpers/pasteHandler.ts b/packages/extension-link/src/helpers/pasteHandler.ts index 6fd31b8296..ed03e6903a 100644 --- a/packages/extension-link/src/helpers/pasteHandler.ts +++ b/packages/extension-link/src/helpers/pasteHandler.ts @@ -1,11 +1,11 @@ import { Editor } from '@tiptap/core' +import { MarkType } from '@tiptap/pm/model' +import { Plugin, PluginKey } from '@tiptap/pm/state' import { find } from 'linkifyjs' -import { MarkType } from 'prosemirror-model' -import { Plugin, PluginKey } from 'prosemirror-state' type PasteHandlerOptions = { - editor: Editor, - type: MarkType, + editor: Editor + type: MarkType } export function pasteHandler(options: PasteHandlerOptions): Plugin { diff --git a/packages/extension-link/src/link.ts b/packages/extension-link/src/link.ts index 1eacfc7f10..a8c77a7102 100644 --- a/packages/extension-link/src/link.ts +++ b/packages/extension-link/src/link.ts @@ -1,6 +1,6 @@ import { Mark, markPasteRule, mergeAttributes } from '@tiptap/core' +import { Plugin } from '@tiptap/pm/state' import { find, registerCustomProtocol, reset } from 'linkifyjs' -import { Plugin } from 'prosemirror-state' import { autolink } from './helpers/autolink' import { clickHandler } from './helpers/clickHandler' @@ -10,29 +10,29 @@ export interface LinkOptions { /** * If enabled, it adds links as you type. */ - autolink: boolean, + autolink: boolean /** * An array of custom protocols to be registered with linkifyjs. */ - protocols: Array, + protocols: Array /** * If enabled, links will be opened on click. */ - openOnClick: boolean, + openOnClick: boolean /** * Adds a link to the current selection if the pasted content only contains an url. */ - linkOnPaste: boolean, + linkOnPaste: boolean /** * A list of HTML attributes to be rendered. */ - HTMLAttributes: Record, + HTMLAttributes: Record /** * A validation function that modifies link verification for the auto linker. * @param url - The url to be validated. * @returns - True if the url is valid, false otherwise. */ - validate?: (url: string) => boolean, + validate?: (url: string) => boolean } declare module '@tiptap/core' { @@ -41,15 +41,15 @@ declare module '@tiptap/core' { /** * Set a link mark */ - setLink: (attributes: { href: string, target?: string | null }) => ReturnType, + setLink: (attributes: { href: string; target?: string | null }) => ReturnType /** * Toggle a link mark */ - toggleLink: (attributes: { href: string, target?: string | null }) => ReturnType, + toggleLink: (attributes: { href: string; target?: string | null }) => ReturnType /** * Unset a link mark */ - unsetLink: () => ReturnType, + unsetLink: () => ReturnType } } } @@ -103,41 +103,35 @@ export const Link = Mark.create({ }, parseHTML() { - return [ - { tag: 'a[href]:not([href *= "javascript:" i])' }, - ] + return [{ tag: 'a[href]:not([href *= "javascript:" i])' }] }, renderHTML({ HTMLAttributes }) { - return [ - 'a', - mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), - 0, - ] + return ['a', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0] }, addCommands() { return { - setLink: attributes => ({ chain }) => { - return chain() - .setMark(this.name, attributes) - .setMeta('preventAutolink', true) - .run() - }, - - toggleLink: attributes => ({ chain }) => { - return chain() - .toggleMark(this.name, attributes, { extendEmptyMarkRange: true }) - .setMeta('preventAutolink', true) - .run() - }, - - unsetLink: () => ({ chain }) => { - return chain() - .unsetMark(this.name, { extendEmptyMarkRange: true }) - .setMeta('preventAutolink', true) - .run() - }, + setLink: + attributes => ({ chain }) => { + return chain().setMark(this.name, attributes).setMeta('preventAutolink', true).run() + }, + + toggleLink: + attributes => ({ chain }) => { + return chain() + .toggleMark(this.name, attributes, { extendEmptyMarkRange: true }) + .setMeta('preventAutolink', true) + .run() + }, + + unsetLink: + () => ({ chain }) => { + return chain() + .unsetMark(this.name, { extendEmptyMarkRange: true }) + .setMeta('preventAutolink', true) + .run() + }, } }, @@ -170,23 +164,29 @@ export const Link = Mark.create({ const plugins: Plugin[] = [] if (this.options.autolink) { - plugins.push(autolink({ - type: this.type, - validate: this.options.validate, - })) + plugins.push( + autolink({ + type: this.type, + validate: this.options.validate, + }), + ) } if (this.options.openOnClick) { - plugins.push(clickHandler({ - type: this.type, - })) + plugins.push( + clickHandler({ + type: this.type, + }), + ) } if (this.options.linkOnPaste) { - plugins.push(pasteHandler({ - editor: this.editor, - type: this.type, - })) + plugins.push( + pasteHandler({ + editor: this.editor, + type: this.type, + }), + ) } return plugins diff --git a/packages/extension-list-item/package.json b/packages/extension-list-item/package.json index 3e00bd061f..24fe1069d2 100644 --- a/packages/extension-list-item/package.json +++ b/packages/extension-list-item/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-mention/package.json b/packages/extension-mention/package.json index d6d979af5f..031c8b7a17 100644 --- a/packages/extension-mention/package.json +++ b/packages/extension-mention/package.json @@ -28,16 +28,14 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/suggestion": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/suggestion": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", "@tiptap/suggestion": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-mention/src/mention.ts b/packages/extension-mention/src/mention.ts index f6b8a79bc4..97aea29574 100644 --- a/packages/extension-mention/src/mention.ts +++ b/packages/extension-mention/src/mention.ts @@ -1,15 +1,12 @@ import { mergeAttributes, Node } from '@tiptap/core' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { PluginKey } from '@tiptap/pm/state' import Suggestion, { SuggestionOptions } from '@tiptap/suggestion' -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { PluginKey } from 'prosemirror-state' export type MentionOptions = { - HTMLAttributes: Record, - renderLabel: (props: { - options: MentionOptions, - node: ProseMirrorNode, - }) => string, - suggestion: Omit, + HTMLAttributes: Record + renderLabel: (props: { options: MentionOptions; node: ProseMirrorNode }) => string + suggestion: Omit } export const MentionPluginKey = new PluginKey('mention') diff --git a/packages/extension-ordered-list/package.json b/packages/extension-ordered-list/package.json index ab514b4eda..20fc612efb 100644 --- a/packages/extension-ordered-list/package.json +++ b/packages/extension-ordered-list/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-paragraph/package.json b/packages/extension-paragraph/package.json index 7ed4c06aa4..ba12c8823c 100644 --- a/packages/extension-paragraph/package.json +++ b/packages/extension-paragraph/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-placeholder/package.json b/packages/extension-placeholder/package.json index 5fd2acd9ee..e73597fcd6 100644 --- a/packages/extension-placeholder/package.json +++ b/packages/extension-placeholder/package.json @@ -28,16 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-placeholder/src/placeholder.ts b/packages/extension-placeholder/src/placeholder.ts index 5e475c7402..175d7b6584 100644 --- a/packages/extension-placeholder/src/placeholder.ts +++ b/packages/extension-placeholder/src/placeholder.ts @@ -1,20 +1,22 @@ import { Editor, Extension } from '@tiptap/core' -import { Node as ProsemirrorNode } from 'prosemirror-model' -import { Plugin } from 'prosemirror-state' -import { Decoration, DecorationSet } from 'prosemirror-view' +import { Node as ProsemirrorNode } from '@tiptap/pm/model' +import { Plugin } from '@tiptap/pm/state' +import { Decoration, DecorationSet } from '@tiptap/pm/view' export interface PlaceholderOptions { - emptyEditorClass: string, - emptyNodeClass: string, - placeholder: ((PlaceholderProps: { - editor: Editor, - node: ProsemirrorNode, - pos: number, - hasAnchor: boolean, - }) => string) | string, - showOnlyWhenEditable: boolean, - showOnlyCurrent: boolean, - includeChildren: boolean, + emptyEditorClass: string + emptyNodeClass: string + placeholder: + | ((PlaceholderProps: { + editor: Editor + node: ProsemirrorNode + pos: number + hasAnchor: boolean + }) => string) + | string + showOnlyWhenEditable: boolean + showOnlyCurrent: boolean + includeChildren: boolean } export const Placeholder = Extension.create({ @@ -46,10 +48,11 @@ export const Placeholder = Extension.create({ // only calculate isEmpty once due to its performance impacts (see issue #3360) const emptyDocInstance = doc.type.createAndFill() - const isEditorEmpty = emptyDocInstance?.sameMarkup(doc) && emptyDocInstance.content.findDiffStart(doc.content) === null + const isEditorEmpty = emptyDocInstance?.sameMarkup(doc) + && emptyDocInstance.content.findDiffStart(doc.content) === null doc.descendants((node, pos) => { - const hasAnchor = anchor >= pos && anchor <= (pos + node.nodeSize) + const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize const isEmpty = !node.isLeaf && !node.childCount if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) { @@ -61,14 +64,15 @@ export const Placeholder = Extension.create({ const decoration = Decoration.node(pos, pos + node.nodeSize, { class: classes.join(' '), - 'data-placeholder': typeof this.options.placeholder === 'function' - ? this.options.placeholder({ - editor: this.editor, - node, - pos, - hasAnchor, - }) - : this.options.placeholder, + 'data-placeholder': + typeof this.options.placeholder === 'function' + ? this.options.placeholder({ + editor: this.editor, + node, + pos, + hasAnchor, + }) + : this.options.placeholder, }) decorations.push(decoration) diff --git a/packages/extension-strike/package.json b/packages/extension-strike/package.json index 4ba289e3cc..c169cf07d4 100644 --- a/packages/extension-strike/package.json +++ b/packages/extension-strike/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-subscript/package.json b/packages/extension-subscript/package.json index 663884a444..3a810662f1 100644 --- a/packages/extension-subscript/package.json +++ b/packages/extension-subscript/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-superscript/package.json b/packages/extension-superscript/package.json index 2c639af47e..694dec3f9d 100644 --- a/packages/extension-superscript/package.json +++ b/packages/extension-superscript/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-table-cell/package.json b/packages/extension-table-cell/package.json index 3063e355a1..4bb7ef2bcf 100644 --- a/packages/extension-table-cell/package.json +++ b/packages/extension-table-cell/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-table-header/package.json b/packages/extension-table-header/package.json index 9b803bfae7..e591c5bc2c 100644 --- a/packages/extension-table-header/package.json +++ b/packages/extension-table-header/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-table-row/package.json b/packages/extension-table-row/package.json index ccba7d6736..9d9ca242d6 100644 --- a/packages/extension-table-row/package.json +++ b/packages/extension-table-row/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-table/package.json b/packages/extension-table/package.json index dcd5be143e..3d4b15e8b5 100644 --- a/packages/extension-table/package.json +++ b/packages/extension-table/package.json @@ -28,18 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "@tiptap/prosemirror-tables": "^1.1.3", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "@tiptap/prosemirror-tables": "^1.1.3", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-table/src/TableView.ts b/packages/extension-table/src/TableView.ts index c37e531522..fbb451b237 100644 --- a/packages/extension-table/src/TableView.ts +++ b/packages/extension-table/src/TableView.ts @@ -1,8 +1,15 @@ // @ts-nocheck -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { NodeView } from 'prosemirror-view' - -export function updateColumns(node: ProseMirrorNode, colgroup: Element, table: Element, cellMinWidth: number, overrideCol?: number, overrideValue?: any) { +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { NodeView } from '@tiptap/pm/view' + +export function updateColumns( + node: ProseMirrorNode, + colgroup: Element, + table: Element, + cellMinWidth: number, + overrideCol?: number, + overrideValue?: any, +) { let totalWidth = 0 let fixedWidth = true let nextDOM = colgroup.firstChild @@ -50,7 +57,6 @@ export function updateColumns(node: ProseMirrorNode, colgroup: Element, table: E } export class TableView implements NodeView { - node: ProseMirrorNode cellMinWidth: number @@ -86,6 +92,9 @@ export class TableView implements NodeView { } ignoreMutation(mutation: MutationRecord | { type: 'selection'; target: Element }) { - return mutation.type === 'attributes' && (mutation.target === this.table || this.colgroup.contains(mutation.target)) + return ( + mutation.type === 'attributes' + && (mutation.target === this.table || this.colgroup.contains(mutation.target)) + ) } } diff --git a/packages/extension-table/src/table.ts b/packages/extension-table/src/table.ts index 342d2a76b6..58fb5cece5 100644 --- a/packages/extension-table/src/table.ts +++ b/packages/extension-table/src/table.ts @@ -1,10 +1,7 @@ import { - callOrReturn, - getExtensionField, - mergeAttributes, - Node, - ParentConfig, + callOrReturn, getExtensionField, mergeAttributes, Node, ParentConfig, } from '@tiptap/core' +import { TextSelection } from '@tiptap/pm/state' import { addColumnAfter, addColumnBefore, @@ -23,46 +20,49 @@ import { tableEditing, toggleHeader, toggleHeaderCell, -} from '@tiptap/prosemirror-tables' -import { TextSelection } from 'prosemirror-state' -import { NodeView } from 'prosemirror-view' +} from '@tiptap/pm/tables' +import { NodeView } from '@tiptap/pm/view' import { TableView } from './TableView' import { createTable } from './utilities/createTable' import { deleteTableWhenAllCellsSelected } from './utilities/deleteTableWhenAllCellsSelected' export interface TableOptions { - HTMLAttributes: Record, - resizable: boolean, - handleWidth: number, - cellMinWidth: number, - View: NodeView, - lastColumnResizable: boolean, - allowTableNodeSelection: boolean, + HTMLAttributes: Record + resizable: boolean + handleWidth: number + cellMinWidth: number + View: NodeView + lastColumnResizable: boolean + allowTableNodeSelection: boolean } declare module '@tiptap/core' { interface Commands { table: { - insertTable: (options?: { rows?: number, cols?: number, withHeaderRow?: boolean }) => ReturnType, - addColumnBefore: () => ReturnType, - addColumnAfter: () => ReturnType, - deleteColumn: () => ReturnType, - addRowBefore: () => ReturnType, - addRowAfter: () => ReturnType, - deleteRow: () => ReturnType, - deleteTable: () => ReturnType, - mergeCells: () => ReturnType, - splitCell: () => ReturnType, - toggleHeaderColumn: () => ReturnType, - toggleHeaderRow: () => ReturnType, - toggleHeaderCell: () => ReturnType, - mergeOrSplit: () => ReturnType, - setCellAttribute: (name: string, value: any) => ReturnType, - goToNextCell: () => ReturnType, - goToPreviousCell: () => ReturnType, - fixTables: () => ReturnType, - setCellSelection: (position: { anchorCell: number, headCell?: number }) => ReturnType, + insertTable: (options?: { + rows?: number + cols?: number + withHeaderRow?: boolean + }) => ReturnType + addColumnBefore: () => ReturnType + addColumnAfter: () => ReturnType + deleteColumn: () => ReturnType + addRowBefore: () => ReturnType + addRowAfter: () => ReturnType + deleteRow: () => ReturnType + deleteTable: () => ReturnType + mergeCells: () => ReturnType + splitCell: () => ReturnType + toggleHeaderColumn: () => ReturnType + toggleHeaderRow: () => ReturnType + toggleHeaderCell: () => ReturnType + mergeOrSplit: () => ReturnType + setCellAttribute: (name: string, value: any) => ReturnType + goToNextCell: () => ReturnType + goToPreviousCell: () => ReturnType + fixTables: () => ReturnType + setCellSelection: (position: { anchorCell: number; headCell?: number }) => ReturnType } } @@ -70,12 +70,14 @@ declare module '@tiptap/core' { /** * Table Role */ - tableRole?: string | ((this: { - name: string, - options: Options, - storage: Storage, - parent: ParentConfig>['tableRole'], - }) => string), + tableRole?: + | string + | ((this: { + name: string + options: Options + storage: Storage + parent: ParentConfig>['tableRole'] + }) => string) } } @@ -105,9 +107,7 @@ export const Table = Node.create({ group: 'block', parseHTML() { - return [ - { tag: 'table' }, - ] + return [{ tag: 'table' }] }, renderHTML({ HTMLAttributes }) { @@ -116,88 +116,107 @@ export const Table = Node.create({ addCommands() { return { - insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => { - const node = createTable(editor.schema, rows, cols, withHeaderRow) + insertTable: + ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => { + const node = createTable(editor.schema, rows, cols, withHeaderRow) - if (dispatch) { - const offset = tr.selection.anchor + 1 + if (dispatch) { + const offset = tr.selection.anchor + 1 - tr.replaceSelectionWith(node) - .scrollIntoView() - .setSelection(TextSelection.near(tr.doc.resolve(offset))) - } + tr.replaceSelectionWith(node) + .scrollIntoView() + .setSelection(TextSelection.near(tr.doc.resolve(offset))) + } - return true - }, - addColumnBefore: () => ({ state, dispatch }) => { - return addColumnBefore(state, dispatch) - }, - addColumnAfter: () => ({ state, dispatch }) => { - return addColumnAfter(state, dispatch) - }, - deleteColumn: () => ({ state, dispatch }) => { - return deleteColumn(state, dispatch) - }, - addRowBefore: () => ({ state, dispatch }) => { - return addRowBefore(state, dispatch) - }, - addRowAfter: () => ({ state, dispatch }) => { - return addRowAfter(state, dispatch) - }, - deleteRow: () => ({ state, dispatch }) => { - return deleteRow(state, dispatch) - }, - deleteTable: () => ({ state, dispatch }) => { - return deleteTable(state, dispatch) - }, - mergeCells: () => ({ state, dispatch }) => { - return mergeCells(state, dispatch) - }, - splitCell: () => ({ state, dispatch }) => { - return splitCell(state, dispatch) - }, - toggleHeaderColumn: () => ({ state, dispatch }) => { - return toggleHeader('column')(state, dispatch) - }, - toggleHeaderRow: () => ({ state, dispatch }) => { - return toggleHeader('row')(state, dispatch) - }, - toggleHeaderCell: () => ({ state, dispatch }) => { - return toggleHeaderCell(state, dispatch) - }, - mergeOrSplit: () => ({ state, dispatch }) => { - if (mergeCells(state, dispatch)) { return true - } + }, + addColumnBefore: + () => ({ state, dispatch }) => { + return addColumnBefore(state, dispatch) + }, + addColumnAfter: + () => ({ state, dispatch }) => { + return addColumnAfter(state, dispatch) + }, + deleteColumn: + () => ({ state, dispatch }) => { + return deleteColumn(state, dispatch) + }, + addRowBefore: + () => ({ state, dispatch }) => { + return addRowBefore(state, dispatch) + }, + addRowAfter: + () => ({ state, dispatch }) => { + return addRowAfter(state, dispatch) + }, + deleteRow: + () => ({ state, dispatch }) => { + return deleteRow(state, dispatch) + }, + deleteTable: + () => ({ state, dispatch }) => { + return deleteTable(state, dispatch) + }, + mergeCells: + () => ({ state, dispatch }) => { + return mergeCells(state, dispatch) + }, + splitCell: + () => ({ state, dispatch }) => { + return splitCell(state, dispatch) + }, + toggleHeaderColumn: + () => ({ state, dispatch }) => { + return toggleHeader('column')(state, dispatch) + }, + toggleHeaderRow: + () => ({ state, dispatch }) => { + return toggleHeader('row')(state, dispatch) + }, + toggleHeaderCell: + () => ({ state, dispatch }) => { + return toggleHeaderCell(state, dispatch) + }, + mergeOrSplit: + () => ({ state, dispatch }) => { + if (mergeCells(state, dispatch)) { + return true + } - return splitCell(state, dispatch) - }, - setCellAttribute: (name, value) => ({ state, dispatch }) => { - return setCellAttr(name, value)(state, dispatch) - }, - goToNextCell: () => ({ state, dispatch }) => { - return goToNextCell(1)(state, dispatch) - }, - goToPreviousCell: () => ({ state, dispatch }) => { - return goToNextCell(-1)(state, dispatch) - }, - fixTables: () => ({ state, dispatch }) => { - if (dispatch) { - fixTables(state) - } + return splitCell(state, dispatch) + }, + setCellAttribute: + (name, value) => ({ state, dispatch }) => { + return setCellAttr(name, value)(state, dispatch) + }, + goToNextCell: + () => ({ state, dispatch }) => { + return goToNextCell(1)(state, dispatch) + }, + goToPreviousCell: + () => ({ state, dispatch }) => { + return goToNextCell(-1)(state, dispatch) + }, + fixTables: + () => ({ state, dispatch }) => { + if (dispatch) { + fixTables(state) + } - return true - }, - setCellSelection: position => ({ tr, dispatch }) => { - if (dispatch) { - const selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell) + return true + }, + setCellSelection: + position => ({ tr, dispatch }) => { + if (dispatch) { + const selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell) - // @ts-ignore - tr.setSelection(selection) - } + // @ts-ignore + tr.setSelection(selection) + } - return true - }, + return true + }, } }, @@ -212,11 +231,7 @@ export const Table = Node.create({ return false } - return this.editor - .chain() - .addRowAfter() - .goToNextCell() - .run() + return this.editor.chain().addRowAfter().goToNextCell().run() }, 'Shift-Tab': () => this.editor.commands.goToPreviousCell(), Backspace: deleteTableWhenAllCellsSelected, @@ -230,14 +245,19 @@ export const Table = Node.create({ const isResizable = this.options.resizable && this.editor.isEditable return [ - ...(isResizable ? [columnResizing({ - handleWidth: this.options.handleWidth, - cellMinWidth: this.options.cellMinWidth, - View: this.options.View, - // TODO: PR for @types/prosemirror-tables - // @ts-ignore (incorrect type) - lastColumnResizable: this.options.lastColumnResizable, - })] : []), + ...(isResizable + ? [ + columnResizing({ + handleWidth: this.options.handleWidth, + cellMinWidth: this.options.cellMinWidth, + // @ts-ignore (incorrect type) + View: this.options.View, + // TODO: PR for @types/prosemirror-tables + // @ts-ignore (incorrect type) + lastColumnResizable: this.options.lastColumnResizable, + }), + ] + : []), tableEditing({ allowTableNodeSelection: this.options.allowTableNodeSelection, }), diff --git a/packages/extension-table/src/utilities/createCell.ts b/packages/extension-table/src/utilities/createCell.ts index 6a69c2035e..120ea7b43e 100644 --- a/packages/extension-table/src/utilities/createCell.ts +++ b/packages/extension-table/src/utilities/createCell.ts @@ -1,6 +1,9 @@ -import { Fragment, Node as ProsemirrorNode, NodeType } from 'prosemirror-model' +import { Fragment, Node as ProsemirrorNode, NodeType } from '@tiptap/pm/model' -export function createCell(cellType: NodeType, cellContent?: Fragment | ProsemirrorNode | Array): ProsemirrorNode | null | undefined { +export function createCell( + cellType: NodeType, + cellContent?: Fragment | ProsemirrorNode | Array, +): ProsemirrorNode | null | undefined { if (cellContent) { return cellType.createChecked(null, cellContent) } diff --git a/packages/extension-table/src/utilities/createTable.ts b/packages/extension-table/src/utilities/createTable.ts index 31506e238b..c28bbf37d6 100644 --- a/packages/extension-table/src/utilities/createTable.ts +++ b/packages/extension-table/src/utilities/createTable.ts @@ -1,9 +1,15 @@ -import { Fragment, Node as ProsemirrorNode, Schema } from 'prosemirror-model' +import { Fragment, Node as ProsemirrorNode, Schema } from '@tiptap/pm/model' import { createCell } from './createCell' import { getTableNodeTypes } from './getTableNodeTypes' -export function createTable(schema: Schema, rowsCount: number, colsCount: number, withHeaderRow: boolean, cellContent?: Fragment | ProsemirrorNode | Array): ProsemirrorNode { +export function createTable( + schema: Schema, + rowsCount: number, + colsCount: number, + withHeaderRow: boolean, + cellContent?: Fragment | ProsemirrorNode | Array, +): ProsemirrorNode { const types = getTableNodeTypes(schema) const headerCells: ProsemirrorNode[] = [] const cells: ProsemirrorNode[] = [] diff --git a/packages/extension-table/src/utilities/getTableNodeTypes.ts b/packages/extension-table/src/utilities/getTableNodeTypes.ts index 489e201cf5..aafee1cd49 100644 --- a/packages/extension-table/src/utilities/getTableNodeTypes.ts +++ b/packages/extension-table/src/utilities/getTableNodeTypes.ts @@ -1,4 +1,4 @@ -import { NodeType, Schema } from 'prosemirror-model' +import { NodeType, Schema } from '@tiptap/pm/model' export function getTableNodeTypes(schema: Schema): { [key: string]: NodeType } { if (schema.cached.tableNodeTypes) { diff --git a/packages/extension-table/src/utilities/isCellSelection.ts b/packages/extension-table/src/utilities/isCellSelection.ts index 32105e487d..59d8919f02 100644 --- a/packages/extension-table/src/utilities/isCellSelection.ts +++ b/packages/extension-table/src/utilities/isCellSelection.ts @@ -1,4 +1,4 @@ -import { CellSelection } from '@tiptap/prosemirror-tables' +import { CellSelection } from '@tiptap/pm/tables' export function isCellSelection(value: unknown): value is CellSelection { return value instanceof CellSelection diff --git a/packages/extension-task-item/package.json b/packages/extension-task-item/package.json index cb5bfd3875..91d4530d2e 100644 --- a/packages/extension-task-item/package.json +++ b/packages/extension-task-item/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/extension-task-item/src/task-item.ts b/packages/extension-task-item/src/task-item.ts index 8ff6583fb5..b365117cf1 100644 --- a/packages/extension-task-item/src/task-item.ts +++ b/packages/extension-task-item/src/task-item.ts @@ -1,5 +1,5 @@ import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core' -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' export interface TaskItemOptions { onReadOnlyChecked?: (node: ProseMirrorNode, checked: boolean) => boolean diff --git a/packages/extension-task-list/package.json b/packages/extension-task-list/package.json index e7912b0682..a8b52419f8 100644 --- a/packages/extension-task-list/package.json +++ b/packages/extension-task-list/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-text-align/package.json b/packages/extension-text-align/package.json index 93a1255fe0..a92b51027b 100644 --- a/packages/extension-text-align/package.json +++ b/packages/extension-text-align/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-text-style/package.json b/packages/extension-text-style/package.json index 5950695023..5f008dd58a 100644 --- a/packages/extension-text-style/package.json +++ b/packages/extension-text-style/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-text/package.json b/packages/extension-text/package.json index 0d81551115..3018ec0520 100644 --- a/packages/extension-text/package.json +++ b/packages/extension-text/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-typography/package.json b/packages/extension-typography/package.json index 1c9f906647..1db9859cac 100644 --- a/packages/extension-typography/package.json +++ b/packages/extension-typography/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-underline/package.json b/packages/extension-underline/package.json index 90161e26da..00f287c38f 100644 --- a/packages/extension-underline/package.json +++ b/packages/extension-underline/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/extension-youtube/package.json b/packages/extension-youtube/package.json index 5687357848..b6f6caa165 100644 --- a/packages/extension-youtube/package.json +++ b/packages/extension-youtube/package.json @@ -28,7 +28,7 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193" + "@tiptap/core": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209" diff --git a/packages/html/package.json b/packages/html/package.json index ef575c1eb0..53de1b5a42 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -28,12 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.204", - "prosemirror-model": "^1.18.1" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1" + "@tiptap/pm": "^2.0.0-beta.209" }, "dependencies": { "zeed-dom": "^0.9.19" diff --git a/packages/html/src/generateHTML.ts b/packages/html/src/generateHTML.ts index 09b8970ec4..b943737cc6 100644 --- a/packages/html/src/generateHTML.ts +++ b/packages/html/src/generateHTML.ts @@ -1,5 +1,5 @@ import { Extensions, getSchema, JSONContent } from '@tiptap/core' -import { Node } from 'prosemirror-model' +import { Node } from '@tiptap/pm/model' import { getHTMLFromFragment } from './getHTMLFromFragment' diff --git a/packages/html/src/generateJSON.ts b/packages/html/src/generateJSON.ts index 177c9c2c70..63ec8e9617 100644 --- a/packages/html/src/generateJSON.ts +++ b/packages/html/src/generateJSON.ts @@ -1,12 +1,10 @@ import { Extensions, getSchema } from '@tiptap/core' -import { DOMParser } from 'prosemirror-model' +import { DOMParser } from '@tiptap/pm/model' import { parseHTML } from 'zeed-dom' export function generateJSON(html: string, extensions: Extensions): Record { const schema = getSchema(extensions) const dom = parseHTML(html) as unknown as Node - return DOMParser.fromSchema(schema) - .parse(dom) - .toJSON() + return DOMParser.fromSchema(schema).parse(dom).toJSON() } diff --git a/packages/html/src/getHTMLFromFragment.ts b/packages/html/src/getHTMLFromFragment.ts index cc4bb14372..dcc46a931f 100644 --- a/packages/html/src/getHTMLFromFragment.ts +++ b/packages/html/src/getHTMLFromFragment.ts @@ -1,12 +1,10 @@ -import { DOMSerializer, Node, Schema } from 'prosemirror-model' +import { DOMSerializer, Node, Schema } from '@tiptap/pm/model' import { createHTMLDocument, VHTMLDocument } from 'zeed-dom' export function getHTMLFromFragment(doc: Node, schema: Schema): string { - const document = DOMSerializer - .fromSchema(schema) - .serializeFragment(doc.content, { - document: (createHTMLDocument() as unknown as Document), - }) as unknown as VHTMLDocument + const document = DOMSerializer.fromSchema(schema).serializeFragment(doc.content, { + document: createHTMLDocument() as unknown as Document, + }) as unknown as VHTMLDocument return document.render() } diff --git a/packages/pm/README.md b/packages/pm/README.md new file mode 100644 index 0000000000..42707a5b16 --- /dev/null +++ b/packages/pm/README.md @@ -0,0 +1,22 @@ +# @tiptap/pm + +[![Version](https://img.shields.io/npm/v/@tiptap/pm.svg?label=version)](https://www.npmjs.com/package/@tiptap/pm) +[![Downloads](https://img.shields.io/npm/dm/@tiptap/pm.svg)](https://npmcharts.com/compare/tiptap?minimal=true) +[![License](https://img.shields.io/npm/l/@tiptap/pm.svg)](https://www.npmjs.com/package/@tiptap/pm) +[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis) + +## Introduction + +Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_. + +## What is this `pm` package? + +The `pm` package is a wrapper package for [ProseMirror](https://ProseMirror.net). This includes all ProseMirror packages that are required to run Tiptap. + +## Official Documentation + +Documentation can be found on the [Tiptap website](https://tiptap.dev). + +## License + +tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md). diff --git a/packages/pm/changeset/index.ts b/packages/pm/changeset/index.ts new file mode 100644 index 0000000000..83f924c103 --- /dev/null +++ b/packages/pm/changeset/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-changeset' diff --git a/packages/pm/changeset/package.json b/packages/pm/changeset/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/changeset/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/collab/index.ts b/packages/pm/collab/index.ts new file mode 100644 index 0000000000..17cf4ff7e1 --- /dev/null +++ b/packages/pm/collab/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-collab' diff --git a/packages/pm/collab/package.json b/packages/pm/collab/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/collab/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/commands/index.ts b/packages/pm/commands/index.ts new file mode 100644 index 0000000000..50da9e9f70 --- /dev/null +++ b/packages/pm/commands/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-commands' diff --git a/packages/pm/commands/package.json b/packages/pm/commands/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/commands/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/dropcursor/index.ts b/packages/pm/dropcursor/index.ts new file mode 100644 index 0000000000..2f73bb580c --- /dev/null +++ b/packages/pm/dropcursor/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-dropcursor' diff --git a/packages/pm/dropcursor/package.json b/packages/pm/dropcursor/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/dropcursor/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/gapcursor/index.ts b/packages/pm/gapcursor/index.ts new file mode 100644 index 0000000000..fd3299b1c4 --- /dev/null +++ b/packages/pm/gapcursor/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-gapcursor' diff --git a/packages/pm/gapcursor/package.json b/packages/pm/gapcursor/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/gapcursor/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/history/index.ts b/packages/pm/history/index.ts new file mode 100644 index 0000000000..f0013a7498 --- /dev/null +++ b/packages/pm/history/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-history' diff --git a/packages/pm/history/package.json b/packages/pm/history/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/history/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/inputrules/index.ts b/packages/pm/inputrules/index.ts new file mode 100644 index 0000000000..1841be360b --- /dev/null +++ b/packages/pm/inputrules/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-inputrules' diff --git a/packages/pm/inputrules/package.json b/packages/pm/inputrules/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/inputrules/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/keymap/index.ts b/packages/pm/keymap/index.ts new file mode 100644 index 0000000000..d97e478e16 --- /dev/null +++ b/packages/pm/keymap/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-keymap' diff --git a/packages/pm/keymap/package.json b/packages/pm/keymap/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/keymap/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/markdown/index.ts b/packages/pm/markdown/index.ts new file mode 100644 index 0000000000..d623f5eae0 --- /dev/null +++ b/packages/pm/markdown/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-markdown' diff --git a/packages/pm/markdown/package.json b/packages/pm/markdown/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/markdown/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/menu/index.ts b/packages/pm/menu/index.ts new file mode 100644 index 0000000000..78cd963f2f --- /dev/null +++ b/packages/pm/menu/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-menu' diff --git a/packages/pm/menu/package.json b/packages/pm/menu/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/menu/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/model/index.ts b/packages/pm/model/index.ts new file mode 100644 index 0000000000..11cb9bf8d3 --- /dev/null +++ b/packages/pm/model/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-model' diff --git a/packages/pm/model/package.json b/packages/pm/model/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/model/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/package.json b/packages/pm/package.json new file mode 100644 index 0000000000..9875fbcdc2 --- /dev/null +++ b/packages/pm/package.json @@ -0,0 +1,177 @@ +{ + "name": "@tiptap/pm", + "description": "prosemirror wrapper package for tiptap", + "version": "2.0.0-beta.209", + "homepage": "https://tiptap.dev", + "keywords": [ + "tiptap", + "prosemirror" + ], + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "type": "module", + "exports": { + "./changeset": { + "types": "./changeset/dist/index.d.ts", + "import": "./changeset/dist/index.js", + "require": "./changeset/dist/index.cjs" + }, + "./collab": { + "types": "./collab/dist/index.d.ts", + "import": "./collab/dist/index.js", + "require": "./collab/dist/index.cjs" + }, + "./commands": { + "types": "./commands/dist/index.d.ts", + "import": "./commands/dist/index.js", + "require": "./commands/dist/index.cjs" + }, + "./dropcursor": { + "types": "./dropcursor/dist/index.d.ts", + "import": "./dropcursor/dist/index.js", + "require": "./dropcursor/dist/index.cjs" + }, + "./gapcursor": { + "types": "./gapcursor/dist/index.d.ts", + "import": "./gapcursor/dist/index.js", + "require": "./gapcursor/dist/index.cjs" + }, + "./history": { + "types": "./history/dist/index.d.ts", + "import": "./history/dist/index.js", + "require": "./history/dist/index.cjs" + }, + "./inputrules": { + "types": "./inputrules/dist/index.d.ts", + "import": "./inputrules/dist/index.js", + "require": "./inputrules/dist/index.cjs" + }, + "./keymap": { + "types": "./keymap/dist/index.d.ts", + "import": "./keymap/dist/index.js", + "require": "./keymap/dist/index.cjs" + }, + "./markdown": { + "types": "./markdown/dist/index.d.ts", + "import": "./markdown/dist/index.js", + "require": "./markdown/dist/index.cjs" + }, + "./menu": { + "types": "./menu/dist/index.d.ts", + "import": "./menu/dist/index.js", + "require": "./menu/dist/index.cjs" + }, + "./model": { + "types": "./model/dist/index.d.ts", + "import": "./model/dist/index.js", + "require": "./model/dist/index.cjs" + }, + "./schema-basic": { + "types": "./schema-basic/dist/index.d.ts", + "import": "./schema-basic/dist/index.js", + "require": "./schema-basic/dist/index.cjs" + }, + "./schema-list": { + "types": "./schema-list/dist/index.d.ts", + "import": "./schema-list/dist/index.js", + "require": "./schema-list/dist/index.cjs" + }, + "./state": { + "types": "./state/dist/index.d.ts", + "import": "./state/dist/index.js", + "require": "./state/dist/index.cjs" + }, + "./tables": { + "types": "./tables/dist/index.d.ts", + "import": "./tables/dist/index.js", + "require": "./tables/dist/index.cjs" + }, + "./trailing-node": { + "types": "./trailing-node/dist/index.d.ts", + "import": "./trailing-node/dist/index.js", + "require": "./trailing-node/dist/index.cjs" + }, + "./transform": { + "types": "./transform/dist/index.d.ts", + "import": "./transform/dist/index.js", + "require": "./transform/dist/index.cjs" + }, + "./view": { + "types": "./view/dist/index.d.ts", + "import": "./view/dist/index.js", + "require": "./view/dist/index.cjs" + } + }, + "files": [ + "changeset/**", + "collab/**", + "commands/**", + "dropcursor/**", + "gapcursor/**", + "history/**", + "inputrules/**", + "keymap/**", + "markdown/**", + "menu/**", + "model/**", + "schema-basic/**", + "schema-list/**", + "state/**", + "tables/**", + "trailing-node/**", + "transform/**", + "view/**" + ], + "peerDependencies": { + "@tiptap/core": "^2.0.0-beta.209" + }, + "dependencies": { + "prosemirror-changeset": "^2.2.0", + "prosemirror-collab": "^1.3.0", + "prosemirror-commands": "^1.3.1", + "prosemirror-dropcursor": "^1.5.0", + "prosemirror-gapcursor": "^1.3.1", + "prosemirror-history": "^1.3.0", + "prosemirror-inputrules": "^1.2.0", + "prosemirror-keymap": "^1.2.0", + "prosemirror-markdown": "^1.10.1", + "prosemirror-menu": "^1.2.1", + "prosemirror-model": "^1.18.1", + "prosemirror-schema-basic": "^1.2.0", + "prosemirror-schema-list": "^1.2.2", + "prosemirror-state": "^1.4.1", + "prosemirror-tables": "^1.3.0", + "prosemirror-trailing-node": "^2.0.2", + "prosemirror-transform": "^1.7.0", + "prosemirror-view": "^1.28.2" + }, + "repository": { + "type": "git", + "url": "https://github.com/ueberdosis/tiptap", + "directory": "packages/pm" + }, + "scripts": { + "build": "npm run build:changeset && npm run build:collab && npm run build:commands && npm run build:dropcursor && npm run build:gapcursor && npm run build:history && npm run build:inputrules && npm run build:keymap && npm run build:markdown && npm run build:menu && npm run build:model && npm run build:schema-basic && npm run build:schema-list && npm run build:state && npm run build:tables && npm run build:trailing-node && npm run build:transform && npm run build:view", + "build:changeset": "tsup \"changeset/index.ts\" --out-dir changeset/dist", + "build:collab": "tsup \"collab/index.ts\" --out-dir collab/dist", + "build:commands": "tsup \"commands/index.ts\" --out-dir commands/dist", + "build:dropcursor": "tsup \"dropcursor/index.ts\" --out-dir dropcursor/dist", + "build:gapcursor": "tsup \"gapcursor/index.ts\" --out-dir gapcursor/dist", + "build:history": "tsup \"history/index.ts\" --out-dir history/dist", + "build:inputrules": "tsup \"inputrules/index.ts\" --out-dir inputrules/dist", + "build:keymap": "tsup \"keymap/index.ts\" --out-dir keymap/dist", + "build:markdown": "tsup \"markdown/index.ts\" --out-dir markdown/dist", + "build:menu": "tsup \"menu/index.ts\" --out-dir menu/dist", + "build:model": "tsup \"model/index.ts\" --out-dir model/dist", + "build:schema-basic": "tsup \"schema-basic/index.ts\" --out-dir schema-basic/dist", + "build:schema-list": "tsup \"schema-list/index.ts\" --out-dir schema-list/dist", + "build:state": "tsup \"state/index.ts\" --out-dir state/dist", + "build:tables": "tsup \"tables/index.ts\" --out-dir tables/dist", + "build:trailing-node": "tsup \"trailing-node/index.ts\" --out-dir trailing-node/dist", + "build:transform": "tsup \"transform/index.ts\" --out-dir transform/dist", + "build:view": "tsup \"view/index.ts\" --out-dir view/dist" + } +} diff --git a/packages/pm/schema-basic/index.ts b/packages/pm/schema-basic/index.ts new file mode 100644 index 0000000000..dc91b3ed48 --- /dev/null +++ b/packages/pm/schema-basic/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-schema-basic' diff --git a/packages/pm/schema-basic/package.json b/packages/pm/schema-basic/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/schema-basic/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/schema-list/index.ts b/packages/pm/schema-list/index.ts new file mode 100644 index 0000000000..e931fed8b9 --- /dev/null +++ b/packages/pm/schema-list/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-schema-list' diff --git a/packages/pm/schema-list/package.json b/packages/pm/schema-list/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/schema-list/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/state/index.ts b/packages/pm/state/index.ts new file mode 100644 index 0000000000..0cfb285bc0 --- /dev/null +++ b/packages/pm/state/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-state' diff --git a/packages/pm/state/package.json b/packages/pm/state/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/state/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/tables/index.ts b/packages/pm/tables/index.ts new file mode 100644 index 0000000000..5716c717fa --- /dev/null +++ b/packages/pm/tables/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-tables' diff --git a/packages/pm/tables/package.json b/packages/pm/tables/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/tables/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/trailing-node/index.ts b/packages/pm/trailing-node/index.ts new file mode 100644 index 0000000000..5be3c1721c --- /dev/null +++ b/packages/pm/trailing-node/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-trailing-node' diff --git a/packages/pm/trailing-node/package.json b/packages/pm/trailing-node/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/trailing-node/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/transform/index.ts b/packages/pm/transform/index.ts new file mode 100644 index 0000000000..26df75c258 --- /dev/null +++ b/packages/pm/transform/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-transform' diff --git a/packages/pm/transform/package.json b/packages/pm/transform/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/transform/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/pm/tsconfig.json b/packages/pm/tsconfig.json new file mode 100644 index 0000000000..4082f16a5d --- /dev/null +++ b/packages/pm/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tsconfig.json" +} diff --git a/packages/pm/tsup.config.ts b/packages/pm/tsup.config.ts new file mode 100644 index 0000000000..303d657571 --- /dev/null +++ b/packages/pm/tsup.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'tsup' + +export default defineConfig(options => { + return { + entry: options.entry, + outDir: options.outDir, + dts: true, + splitting: true, + clean: true, + format: [ + 'esm', + 'cjs', + ], + } +}) diff --git a/packages/pm/view/index.ts b/packages/pm/view/index.ts new file mode 100644 index 0000000000..34d6b656d7 --- /dev/null +++ b/packages/pm/view/index.ts @@ -0,0 +1 @@ +export * from 'prosemirror-view' diff --git a/packages/pm/view/package.json b/packages/pm/view/package.json new file mode 100644 index 0000000000..a09224e223 --- /dev/null +++ b/packages/pm/view/package.json @@ -0,0 +1,14 @@ +{ + "type": "module", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/packages/react/package.json b/packages/react/package.json index 899063f5dc..fec93c5fd9 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -29,20 +29,21 @@ ], "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "@types/react": "^18.0.1", "@types/react-dom": "^18.0.0", "react": "^18.0.0", "react-dom": "^18.0.0" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0" }, "dependencies": { "@tiptap/extension-bubble-menu": "^2.0.0-beta.209", - "@tiptap/extension-floating-menu": "^2.0.0-beta.209", - "prosemirror-view": "^1.28.2" + "@tiptap/extension-floating-menu": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/react/src/EditorContent.tsx b/packages/react/src/EditorContent.tsx index 02a398ef37..802418461d 100644 --- a/packages/react/src/EditorContent.tsx +++ b/packages/react/src/EditorContent.tsx @@ -142,6 +142,7 @@ export class PureEditorContent extends React.Component
+ {/* @ts-ignore */} ) diff --git a/packages/react/src/ReactNodeViewRenderer.tsx b/packages/react/src/ReactNodeViewRenderer.tsx index 77d9721c24..d4cfc969be 100644 --- a/packages/react/src/ReactNodeViewRenderer.tsx +++ b/packages/react/src/ReactNodeViewRenderer.tsx @@ -5,8 +5,8 @@ import { NodeViewRendererOptions, NodeViewRendererProps, } from '@tiptap/core' -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { Decoration, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view' import React from 'react' import { Editor } from './Editor' @@ -16,15 +16,15 @@ import { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeV export interface ReactNodeViewRendererOptions extends NodeViewRendererOptions { update: | ((props: { - oldNode: ProseMirrorNode; - oldDecorations: Decoration[]; - newNode: ProseMirrorNode; - newDecorations: Decoration[]; - updateProps: () => void; + oldNode: ProseMirrorNode + oldDecorations: Decoration[] + newNode: ProseMirrorNode + newDecorations: Decoration[] + updateProps: () => void }) => boolean) - | null; - as?: string; - className?: string; + | null + as?: string + className?: string } class ReactNodeView extends NodeView< @@ -66,9 +66,13 @@ class ReactNodeView extends NodeView< } return ( - - - + <> + {/* @ts-ignore */} + + {/* @ts-ignore */} + + + ) } diff --git a/packages/suggestion/package.json b/packages/suggestion/package.json index c692de8f20..a6a460ff77 100644 --- a/packages/suggestion/package.json +++ b/packages/suggestion/package.json @@ -28,16 +28,12 @@ "dist" ], "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209" }, "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-model": "^1.18.1", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2" + "@tiptap/pm": "^2.0.0-beta.209" }, "repository": { "type": "git", diff --git a/packages/suggestion/src/findSuggestionMatch.ts b/packages/suggestion/src/findSuggestionMatch.ts index d245775253..3f22f94e41 100644 --- a/packages/suggestion/src/findSuggestionMatch.ts +++ b/packages/suggestion/src/findSuggestionMatch.ts @@ -1,27 +1,23 @@ import { escapeForRegEx, Range } from '@tiptap/core' -import { ResolvedPos } from 'prosemirror-model' +import { ResolvedPos } from '@tiptap/pm/model' export interface Trigger { - char: string, - allowSpaces: boolean, - allowedPrefixes: string[] | null, - startOfLine: boolean, - $position: ResolvedPos, + char: string + allowSpaces: boolean + allowedPrefixes: string[] | null + startOfLine: boolean + $position: ResolvedPos } export type SuggestionMatch = { - range: Range, - query: string, - text: string, + range: Range + query: string + text: string } | null export function findSuggestionMatch(config: Trigger): SuggestionMatch { const { - char, - allowSpaces, - allowedPrefixes, - startOfLine, - $position, + char, allowSpaces, allowedPrefixes, startOfLine, $position, } = config const escapedChar = escapeForRegEx(char) diff --git a/packages/suggestion/src/suggestion.ts b/packages/suggestion/src/suggestion.ts index aa45da8424..486d1aaf16 100644 --- a/packages/suggestion/src/suggestion.ts +++ b/packages/suggestion/src/suggestion.ts @@ -1,57 +1,46 @@ import { Editor, Range } from '@tiptap/core' -import { EditorState, Plugin, PluginKey } from 'prosemirror-state' -import { Decoration, DecorationSet, EditorView } from 'prosemirror-view' +import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state' +import { Decoration, DecorationSet, EditorView } from '@tiptap/pm/view' import { findSuggestionMatch } from './findSuggestionMatch' export interface SuggestionOptions { - pluginKey?: PluginKey, - editor: Editor, - char?: string, - allowSpaces?: boolean, - allowedPrefixes?: string[] | null, - startOfLine?: boolean, - decorationTag?: string, - decorationClass?: string, - command?: (props: { - editor: Editor, - range: Range, - props: I, - }) => void, - items?: (props: { - query: string, - editor: Editor, - }) => I[] | Promise, + pluginKey?: PluginKey + editor: Editor + char?: string + allowSpaces?: boolean + allowedPrefixes?: string[] | null + startOfLine?: boolean + decorationTag?: string + decorationClass?: string + command?: (props: { editor: Editor; range: Range; props: I }) => void + items?: (props: { query: string; editor: Editor }) => I[] | Promise render?: () => { onBeforeStart?: (props: SuggestionProps) => void - onStart?: (props: SuggestionProps) => void, + onStart?: (props: SuggestionProps) => void onBeforeUpdate?: (props: SuggestionProps) => void - onUpdate?: (props: SuggestionProps) => void, - onExit?: (props: SuggestionProps) => void, - onKeyDown?: (props: SuggestionKeyDownProps) => boolean, - }, - allow?: (props: { - editor: Editor, - state: EditorState, - range: Range, - }) => boolean, + onUpdate?: (props: SuggestionProps) => void + onExit?: (props: SuggestionProps) => void + onKeyDown?: (props: SuggestionKeyDownProps) => boolean + } + allow?: (props: { editor: Editor; state: EditorState; range: Range }) => boolean } export interface SuggestionProps { - editor: Editor, - range: Range, - query: string, - text: string, - items: I[], - command: (props: I) => void, - decorationNode: Element | null, - clientRect?: (() => DOMRect | null) | null, + editor: Editor + range: Range + query: string + text: string + items: I[] + command: (props: I) => void + decorationNode: Element | null + clientRect?: (() => DOMRect | null) | null } export interface SuggestionKeyDownProps { - view: EditorView, - event: KeyboardEvent, - range: Range, + view: EditorView + event: KeyboardEvent + range: Range } export const SuggestionPluginKey = new PluginKey('suggestion') @@ -70,7 +59,6 @@ export function Suggestion({ render = () => ({}), allow = () => true, }: SuggestionOptions) { - let props: SuggestionProps | undefined const renderer = render?.() @@ -97,10 +85,10 @@ export function Suggestion({ return } - const state = handleExit && !handleStart - ? prev - : next - const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) + const state = handleExit && !handleStart ? prev : next + const decorationNode = view.dom.querySelector( + `[data-decoration-id="${state.decorationId}"]`, + ) props = { editor, @@ -121,8 +109,10 @@ export function Suggestion({ clientRect: decorationNode ? () => { // because of `items` can be asynchrounous we’ll search for the current decoration node - const { decorationId } = this.key?.getState(editor.state) // eslint-disable-line - const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`) + const { decorationId } = this.key?.getState(editor.state) // eslint-disable-line + const currentDecorationNode = view.dom.querySelector( + `[data-decoration-id="${decorationId}"]`, + ) return currentDecorationNode?.getBoundingClientRect() || null } @@ -171,8 +161,8 @@ export function Suggestion({ // Initialize the plugin's internal state. init() { const state: { - active: boolean, - range: Range, + active: boolean + range: Range query: null | string text: null | string composing: boolean @@ -206,11 +196,7 @@ export function Suggestion({ // * a composition is active (see: https://github.com/ueberdosis/tiptap/issues/1449) if (isEditable && (empty || editor.view.composing)) { // Reset active state if we just left the previous suggestion range - if ( - ((from < prev.range.from) || from > prev.range.to) - && !composing - && !prev.composing - ) { + if ((from < prev.range.from || from > prev.range.to) && !composing && !prev.composing) { next.active = false } @@ -222,7 +208,7 @@ export function Suggestion({ startOfLine, $position: selection.$from, }) - const decorationId = `id_${Math.floor(Math.random() * 0xFFFFFFFF)}` + const decorationId = `id_${Math.floor(Math.random() * 0xffffffff)}` // If we found a match, update the current state to show it if (match && allow({ editor, state, range: match.range })) { diff --git a/packages/vue-2/package.json b/packages/vue-2/package.json index 4a4ae52ae9..ed91a694bf 100644 --- a/packages/vue-2/package.json +++ b/packages/vue-2/package.json @@ -29,12 +29,12 @@ ], "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^2.6.0" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-view": "^1.28.2", + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^2.6.0" }, "dependencies": { diff --git a/packages/vue-2/src/VueNodeViewRenderer.ts b/packages/vue-2/src/VueNodeViewRenderer.ts index 6de4319ffe..cb546fc76c 100644 --- a/packages/vue-2/src/VueNodeViewRenderer.ts +++ b/packages/vue-2/src/VueNodeViewRenderer.ts @@ -5,8 +5,8 @@ import { NodeViewRendererOptions, NodeViewRendererProps, } from '@tiptap/core' -import { Node as ProseMirrorNode } from 'prosemirror-model' -import { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { Decoration, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view' import Vue from 'vue' import { PropType, VueConstructor } from 'vue/types/umd' @@ -49,17 +49,18 @@ export const nodeViewProps = { } export interface VueNodeViewRendererOptions extends NodeViewRendererOptions { - update: ((props: { - oldNode: ProseMirrorNode, - oldDecorations: Decoration[], - newNode: ProseMirrorNode, - newDecorations: Decoration[], - updateProps: () => void, - }) => boolean) | null, + update: + | ((props: { + oldNode: ProseMirrorNode + oldDecorations: Decoration[] + newNode: ProseMirrorNode + newDecorations: Decoration[] + updateProps: () => void + }) => boolean) + | null } -class VueNodeView extends NodeView<(Vue | VueConstructor), Editor, VueNodeViewRendererOptions> { - +class VueNodeView extends NodeView { renderer!: VueRenderer decorationClasses!: { @@ -87,17 +88,15 @@ class VueNodeView extends NodeView<(Vue | VueConstructor), Editor, VueNodeViewRe // @ts-ignore const vue = this.editor.contentComponent?.$options._base ?? Vue // eslint-disable-line - const Component = vue - .extend(this.component) - .extend({ - props: Object.keys(props), - provide: () => { - return { - onDragStart, - decorationClasses: this.decorationClasses, - } - }, - }) + const Component = vue.extend(this.component).extend({ + props: Object.keys(props), + provide: () => { + return { + onDragStart, + decorationClasses: this.decorationClasses, + } + }, + }) this.renderer = new VueRenderer(Component, { parent: this.editor.contentComponent, @@ -174,20 +173,24 @@ class VueNodeView extends NodeView<(Vue | VueConstructor), Editor, VueNodeViewRe } getDecorationClasses() { - return this.decorations - // @ts-ignore - .map(item => item.type.attrs.class) - .flat() - .join(' ') + return ( + this.decorations + // @ts-ignore + .map(item => item.type.attrs.class) + .flat() + .join(' ') + ) } destroy() { this.renderer.destroy() } - } -export function VueNodeViewRenderer(component: Vue | VueConstructor, options?: Partial): NodeViewRenderer { +export function VueNodeViewRenderer( + component: Vue | VueConstructor, + options?: Partial, +): NodeViewRenderer { return (props: NodeViewRendererProps) => { // try to get the parent component // this is important for vue devtools to show the component hierarchy correctly diff --git a/packages/vue-3/package.json b/packages/vue-3/package.json index b19285c276..66c5b45ee6 100644 --- a/packages/vue-3/package.json +++ b/packages/vue-3/package.json @@ -29,14 +29,12 @@ ], "devDependencies": { "@tiptap/core": "^2.0.0-beta.209", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^3.0.0" }, "peerDependencies": { - "@tiptap/core": "^2.0.0-beta.193", - "prosemirror-state": "^1.4.1", - "prosemirror-view": "^1.28.2", + "@tiptap/core": "^2.0.0-beta.209", + "@tiptap/pm": "^2.0.0-beta.209", "vue": "^3.0.0" }, "dependencies": { @@ -48,5 +46,19 @@ "url": "https://github.com/ueberdosis/tiptap", "directory": "packages/vue-3" }, - "sideEffects": false + "sideEffects": false, + "scripts": { + "build": "tsup" + }, + "tsup": { + "entry": [ + "src/index.ts" + ], + "dts": true, + "splitting": true, + "format": [ + "esm", + "cjs" + ] + } } diff --git a/packages/vue-3/src/Editor.ts b/packages/vue-3/src/Editor.ts index 81cb0250e3..26b2a9bc22 100644 --- a/packages/vue-3/src/Editor.ts +++ b/packages/vue-3/src/Editor.ts @@ -1,5 +1,5 @@ import { Editor as CoreEditor, EditorOptions } from '@tiptap/core' -import { EditorState, Plugin, PluginKey } from 'prosemirror-state' +import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state' import { ComponentInternalInstance, ComponentPublicInstance, @@ -34,7 +34,7 @@ function useDebouncedRef(value: T) { } export type ContentComponent = ComponentInternalInstance & { - ctx: ComponentPublicInstance, + ctx: ComponentPublicInstance } export class Editor extends CoreEditor { @@ -61,21 +61,20 @@ export class Editor extends CoreEditor { } get state() { - return this.reactiveState - ? this.reactiveState.value - : this.view.state + return this.reactiveState ? this.reactiveState.value : this.view.state } get storage() { - return this.reactiveExtensionStorage - ? this.reactiveExtensionStorage.value - : super.storage + return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage } /** * Register a ProseMirror plugin. */ - public registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void { + public registerPlugin( + plugin: Plugin, + handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[], + ): void { super.registerPlugin(plugin, handlePlugins) this.reactiveState.value = this.view.state } diff --git a/packages/vue-3/src/VueNodeViewRenderer.ts b/packages/vue-3/src/VueNodeViewRenderer.ts index 96563d75b9..1367e92253 100644 --- a/packages/vue-3/src/VueNodeViewRenderer.ts +++ b/packages/vue-3/src/VueNodeViewRenderer.ts @@ -5,7 +5,7 @@ import { NodeViewRendererOptions, NodeViewRendererProps, } from '@tiptap/core' -import { Node as ProseMirrorNode } from 'prosemirror-model' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' import { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view' import { Component, @@ -55,17 +55,18 @@ export const nodeViewProps = { } export interface VueNodeViewRendererOptions extends NodeViewRendererOptions { - update: ((props: { - oldNode: ProseMirrorNode, - oldDecorations: Decoration[], - newNode: ProseMirrorNode, - newDecorations: Decoration[], - updateProps: () => void, - }) => boolean) | null, + update: + | ((props: { + oldNode: ProseMirrorNode + oldDecorations: Decoration[] + newNode: ProseMirrorNode + newDecorations: Decoration[] + updateProps: () => void + }) => boolean) + | null } class VueNodeView extends NodeView { - renderer!: VueRenderer decorationClasses!: Ref @@ -183,20 +184,24 @@ class VueNodeView extends NodeView item.type.attrs.class) - .flat() - .join(' ') + return ( + this.decorations + // @ts-ignore + .map(item => item.type.attrs.class) + .flat() + .join(' ') + ) } destroy() { this.renderer.destroy() } - } -export function VueNodeViewRenderer(component: Component, options?: Partial): NodeViewRenderer { +export function VueNodeViewRenderer( + component: Component, + options?: Partial, +): NodeViewRenderer { return (props: NodeViewRendererProps) => { // try to get the parent component // this is important for vue devtools to show the component hierarchy correctly diff --git a/tests/cypress.config.js b/tests/cypress.config.js index 9da19a5f11..2eab003fa4 100644 --- a/tests/cypress.config.js +++ b/tests/cypress.config.js @@ -1,7 +1,7 @@ const { defineConfig } = require('cypress') module.exports = defineConfig({ - defaultCommandTimeout: 15000, + defaultCommandTimeout: 12000, e2e: { setupNodeEvents(on, config) { return require('./cypress/plugins/index.js')(on, config) diff --git a/tests/cypress/integration/core/can.spec.ts b/tests/cypress/integration/core/can.spec.ts index f4f361cbc2..0c8abee503 100644 --- a/tests/cypress/integration/core/can.spec.ts +++ b/tests/cypress/integration/core/can.spec.ts @@ -12,12 +12,7 @@ import Text from '@tiptap/extension-text' describe('can', () => { it('not undo', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - ], + extensions: [Document, Paragraph, Text, History], }) const canUndo = editor.can().undo() @@ -27,12 +22,7 @@ describe('can', () => { it('undo', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - ], + extensions: [Document, Paragraph, Text, History], }) editor.commands.setContent('foo') @@ -44,12 +34,7 @@ describe('can', () => { it('not chain undo', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - ], + extensions: [Document, Paragraph, Text, History], }) const canUndo = editor.can().chain().undo().run() @@ -59,12 +44,7 @@ describe('can', () => { it('chain undo', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - ], + extensions: [Document, Paragraph, Text, History], }) editor.commands.setContent('foo') @@ -76,17 +56,11 @@ describe('can', () => { it('returns false for non-applicable marks when selection contains node in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - CodeBlock, - Bold, - ], + extensions: [Document, Paragraph, Text, History, CodeBlock, Bold], }) - editor.chain() + editor + .chain() .setCodeBlock() .insertContent('Test code block') .setTextSelection({ from: 2, to: 3 }) @@ -100,20 +74,10 @@ describe('can', () => { it('returns false for non-applicable marks when selection contains marks in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - Code, - Bold, - ], + extensions: [Document, Paragraph, Text, History, Code, Bold], }) - editor.chain() - .setContent('test') - .setTextSelection({ from: 2, to: 3 }) - .run() + editor.chain().setContent('test').setTextSelection({ from: 2, to: 3 }).run() const canSetMarkToBold = editor.can().setMark('bold') @@ -122,14 +86,7 @@ describe('can', () => { it('returns false for non-applicable marks when stored marks in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - Code, - Bold, - ], + extensions: [Document, Paragraph, Text, History, Code, Bold], }) editor.chain().setContent('test').run() @@ -141,14 +98,7 @@ describe('can', () => { it('returns false for non-applicable marks when selecting multiple nodes in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - Code, - Bold, - ], + extensions: [Document, Paragraph, Text, History, Code, Bold], }) editor.chain().setContent('test123').selectAll().run() @@ -160,17 +110,11 @@ describe('can', () => { it('returns true for applicable marks when selection does not contain nodes in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - CodeBlock, - Bold, - ], + extensions: [Document, Paragraph, Text, History, CodeBlock, Bold], }) - editor.chain() + editor + .chain() .setCodeBlock() .insertContent('Test code block') .exitCode() @@ -185,14 +129,7 @@ describe('can', () => { it('returns true for applicable marks when stored marks are not in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - Code, - Bold, - ], + extensions: [Document, Paragraph, Text, History, Code, Bold], }) editor.chain().setContent('test').toggleCode().run() @@ -204,17 +141,11 @@ describe('can', () => { it('returns true for applicable marks when selection does not contain marks in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - Code, - Bold, - ], + extensions: [Document, Paragraph, Text, History, Code, Bold], }) - editor.chain() + editor + .chain() .setContent('test') .setTextSelection({ from: 2, to: 3 }) .toggleCode() @@ -227,14 +158,7 @@ describe('can', () => { it('returns true for applicable marks if at least one node in selection has no marks in conflict', () => { const editor = new Editor({ - extensions: [ - Document, - Paragraph, - Text, - History, - Code, - Bold, - ], + extensions: [Document, Paragraph, Text, History, Code, Bold], }) editor.chain().setContent('test123').selectAll().run() diff --git a/tests/cypress/integration/core/mergeAttributes.spec.ts b/tests/cypress/integration/core/mergeAttributes.spec.ts index 7fea0e6640..4acc9f36d7 100644 --- a/tests/cypress/integration/core/mergeAttributes.spec.ts +++ b/tests/cypress/integration/core/mergeAttributes.spec.ts @@ -59,7 +59,6 @@ describe('mergeAttributes', () => { }) it('should ignore falsy values', () => { - // @ts-expect-error const value = mergeAttributes(undefined, { class: 'foo' }) expect(value).to.deep.eq({ diff --git a/tests/cypress/tsconfig.json b/tests/cypress/tsconfig.json index 974e84cd97..608b1b667b 100644 --- a/tests/cypress/tsconfig.json +++ b/tests/cypress/tsconfig.json @@ -1,13 +1,14 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "strict": false, "noEmit": false, "sourceMap": false, - "types": [ - "cypress", - ], + "types": ["cypress"], + "paths": { + "@tiptap/*": ["packages/*/dist", "packages/*/src"], + "@tiptap/pm/*": ["../../pm/*/dist"] + } }, - "include": [ - "./*/*.ts" - ] + "include": ["./*/*.ts", "../../**/*.ts"] }