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

This commit is contained in:
svenadlung
2022-07-06 13:20:48 +02:00
6 changed files with 821 additions and 68 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run lint:fix
npm run lint:staged

3
.lintstagedrc.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
"./**/*.{ts,tsx,js,jsx,vue}": ["eslint --fix --quiet --no-error-on-unmatched-pattern"],
};

875
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,7 @@
"start": "npm --prefix ./demos run start",
"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:demos": "npm --prefix ./demos run build",
@@ -50,6 +51,7 @@
"eslint-plugin-vue": "^9.1.0",
"husky": "^8.0.1",
"lerna": "^4.0.0",
"lint-staged": "^13.0.3",
"minimist": "^1.2.5",
"rollup": "^2.67.0",
"rollup-plugin-auto-external": "^2.0.0",

View File

@@ -1,5 +1,4 @@
import { ParseOptions } from 'prosemirror-model'
import { TextSelection } from 'prosemirror-state'
import { createDocument } from '../helpers/createDocument'
import { Content, RawCommands } from '../types'
@@ -22,11 +21,9 @@ declare module '@tiptap/core' {
export const setContent: RawCommands['setContent'] = (content, emitUpdate = false, parseOptions = {}) => ({ tr, editor, dispatch }) => {
const { doc } = tr
const document = createDocument(content, editor.schema, parseOptions)
const selection = TextSelection.create(doc, 0, doc.content.size)
if (dispatch) {
tr.setSelection(selection)
.replaceSelectionWith(document, false)
tr.replaceWith(0, doc.content.size, document)
.setMeta('preventUpdate', !emitUpdate)
}

View File

@@ -9,7 +9,7 @@ export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => {
(node, pos, parent, index) => {
textBefore += node.type.spec.toText?.({
node, pos, parent, index,
}) || node.textContent || '%leaf%'
}) || $from.nodeBefore?.text || '%leaf%'
},
)