@tiptap/core
Advanced tools
Comparing version 2.1.0-rc.14 to 2.1.0
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.1.0-rc.14", | ||
"version": "2.1.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/pm": "^2.1.0-rc.14" | ||
"@tiptap/pm": "^2.1.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependencies": { |
import { NodeType } from '@tiptap/pm/model' | ||
import { TextSelection } from '@tiptap/pm/state' | ||
import { NodeSelection, TextSelection } from '@tiptap/pm/state' | ||
@@ -55,2 +55,4 @@ import { InputRule, InputRuleFinder } from '../InputRule.js' | ||
const { $to } = tr.selection | ||
if (match[1]) { | ||
@@ -78,7 +80,13 @@ const offset = match[0].lastIndexOf(match[1]) | ||
if (config.blockReplace && config.addExtraNewline) { | ||
const { $to } = tr.selection | ||
const posAfter = $to.end() | ||
if ($to.nodeAfter) { | ||
tr.setSelection(TextSelection.create(tr.doc, $to.pos)) | ||
console.log($to.node().type.name) | ||
if ($to.nodeAfter.isTextblock) { | ||
tr.setSelection(TextSelection.create(tr.doc, $to.pos + 1)) | ||
} else if ($to.nodeAfter.isBlock) { | ||
tr.setSelection(NodeSelection.create(tr.doc, $to.pos)) | ||
} else { | ||
tr.setSelection(TextSelection.create(tr.doc, $to.pos)) | ||
} | ||
} else { | ||
@@ -90,3 +98,3 @@ // add node after horizontal rule if it’s the end of the document | ||
tr.insert(posAfter, node) | ||
tr.setSelection(TextSelection.create(tr.doc, posAfter)) | ||
tr.setSelection(TextSelection.create(tr.doc, posAfter + 1)) | ||
} | ||
@@ -93,0 +101,0 @@ } |
@@ -17,3 +17,10 @@ export function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> { | ||
if (key === 'class') { | ||
mergedAttributes[key] = [mergedAttributes[key], value].join(' ') | ||
const valueClasses: string[] = value.split(' ') | ||
const existingClasses: string[] = mergedAttributes[key].split(' ') | ||
const insertClasses = valueClasses.filter( | ||
valueClass => !existingClasses.includes(valueClass), | ||
) | ||
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ') | ||
} else if (key === 'style') { | ||
@@ -20,0 +27,0 @@ mergedAttributes[key] = [mergedAttributes[key], value].join('; ') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2026442
23586
0