@tiptap/extension-hard-break
Advanced tools
Comparing version
@@ -16,5 +16,3 @@ // src/hard-break.ts | ||
parseHTML() { | ||
return [ | ||
{ tag: "br" } | ||
]; | ||
return [{ tag: "br" }]; | ||
}, | ||
@@ -29,8 +27,3 @@ renderHTML({ HTMLAttributes }) { | ||
return { | ||
setHardBreak: () => ({ | ||
commands, | ||
chain, | ||
state, | ||
editor | ||
}) => { | ||
setHardBreak: () => ({ commands, chain, state, editor }) => { | ||
return commands.first([ | ||
@@ -67,7 +60,7 @@ () => commands.exitCode(), | ||
// src/index.ts | ||
var src_default = HardBreak; | ||
var index_default = HardBreak; | ||
export { | ||
HardBreak, | ||
src_default as default | ||
index_default as default | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-hard-break", | ||
"description": "hard break extension for tiptap", | ||
"version": "3.0.0-next.3", | ||
"version": "3.0.0-next.4", | ||
"homepage": "https://tiptap.dev", | ||
@@ -18,3 +18,6 @@ "keywords": [ | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"types": { | ||
"import": "./dist/index.d.ts", | ||
"require": "./dist/index.d.cts" | ||
}, | ||
"import": "./dist/index.js", | ||
@@ -32,3 +35,3 @@ "require": "./dist/index.cjs" | ||
"devDependencies": { | ||
"@tiptap/core": "^3.0.0-next.3" | ||
"@tiptap/core": "^3.0.0-next.4" | ||
}, | ||
@@ -44,4 +47,5 @@ "peerDependencies": { | ||
"scripts": { | ||
"build": "tsup" | ||
"build": "tsup", | ||
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/" | ||
} | ||
} | ||
} |
# @tiptap/extension-hard-break | ||
[](https://www.npmjs.com/package/@tiptap/extension-hard-break) | ||
@@ -8,8 +9,11 @@ [](https://npmcharts.com/compare/tiptap?minimal=true) | ||
## 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*. | ||
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_. | ||
## 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). |
@@ -9,3 +9,3 @@ import { mergeAttributes, Node } from '@tiptap/core' | ||
*/ | ||
keepMarks: boolean, | ||
keepMarks: boolean | ||
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
HTMLAttributes: Record<string, any>, | ||
HTMLAttributes: Record<string, any> | ||
} | ||
@@ -28,3 +28,3 @@ | ||
*/ | ||
setHardBreak: () => ReturnType, | ||
setHardBreak: () => ReturnType | ||
} | ||
@@ -57,5 +57,3 @@ } | ||
parseHTML() { | ||
return [ | ||
{ tag: 'br' }, | ||
] | ||
return [{ tag: 'br' }] | ||
}, | ||
@@ -73,38 +71,34 @@ | ||
return { | ||
setHardBreak: () => ({ | ||
commands, | ||
chain, | ||
state, | ||
editor, | ||
}) => { | ||
return commands.first([ | ||
() => commands.exitCode(), | ||
() => commands.command(() => { | ||
const { selection, storedMarks } = state | ||
setHardBreak: | ||
() => | ||
({ commands, chain, state, editor }) => { | ||
return commands.first([ | ||
() => commands.exitCode(), | ||
() => | ||
commands.command(() => { | ||
const { selection, storedMarks } = state | ||
if (selection.$from.parent.type.spec.isolating) { | ||
return false | ||
} | ||
if (selection.$from.parent.type.spec.isolating) { | ||
return false | ||
} | ||
const { keepMarks } = this.options | ||
const { splittableMarks } = editor.extensionManager | ||
const marks = storedMarks | ||
|| (selection.$to.parentOffset && selection.$from.marks()) | ||
const { keepMarks } = this.options | ||
const { splittableMarks } = editor.extensionManager | ||
const marks = storedMarks || (selection.$to.parentOffset && selection.$from.marks()) | ||
return chain() | ||
.insertContent({ type: this.name }) | ||
.command(({ tr, dispatch }) => { | ||
if (dispatch && marks && keepMarks) { | ||
const filteredMarks = marks | ||
.filter(mark => splittableMarks.includes(mark.type.name)) | ||
return chain() | ||
.insertContent({ type: this.name }) | ||
.command(({ tr, dispatch }) => { | ||
if (dispatch && marks && keepMarks) { | ||
const filteredMarks = marks.filter(mark => splittableMarks.includes(mark.type.name)) | ||
tr.ensureMarks(filteredMarks) | ||
} | ||
tr.ensureMarks(filteredMarks) | ||
} | ||
return true | ||
}) | ||
.run() | ||
}), | ||
]) | ||
}, | ||
return true | ||
}) | ||
.run() | ||
}), | ||
]) | ||
}, | ||
} | ||
@@ -111,0 +105,0 @@ }, |
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 not supported yet
20611
5.89%11
10%19
26.67%271
-6.87%