@tiptap/extension-horizontal-rule
Advanced tools
Comparing version 2.0.0-beta.18 to 2.0.0-beta.19
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.0.0-beta.19](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-horizontal-rule@2.0.0-beta.18...@tiptap/extension-horizontal-rule@2.0.0-beta.19) (2021-08-12) | ||
### Bug Fixes | ||
* remove node before hr if it’s an empty text block (fix [#1665](https://github.com/ueberdosis/tiptap/issues/1665)) ([6e76bb8](https://github.com/ueberdosis/tiptap/commit/6e76bb84fc65eb95157f900c35adfdd28e88a8e3)) | ||
# [2.0.0-beta.18](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-horizontal-rule@2.0.0-beta.17...@tiptap/extension-horizontal-rule@2.0.0-beta.18) (2021-07-26) | ||
@@ -8,0 +19,0 @@ |
@@ -26,3 +26,18 @@ 'use strict'; | ||
return chain() | ||
// remove node before hr if it’s an empty text block | ||
.command(({ tr, dispatch }) => { | ||
const { selection } = tr; | ||
const { empty, $anchor } = selection; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock | ||
&& !$anchor.parent.type.spec.code | ||
&& !$anchor.parent.textContent; | ||
if (!empty || !isEmptyTextBlock || !dispatch) { | ||
return true; | ||
} | ||
const posBefore = $anchor.before(); | ||
tr.deleteRange(posBefore, posBefore + 1); | ||
return true; | ||
}) | ||
.insertContent({ type: this.name }) | ||
// add node after hr if it’s the end of the document | ||
.command(({ tr, dispatch }) => { | ||
@@ -34,3 +49,2 @@ var _a; | ||
const nodeAfter = tr.doc.nodeAt(posAfter); | ||
// end of document | ||
if (!nodeAfter) { | ||
@@ -59,3 +73,3 @@ const node = (_a = parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create(); | ||
exports.HorizontalRule = HorizontalRule; | ||
exports.default = HorizontalRule; | ||
exports['default'] = HorizontalRule; | ||
//# sourceMappingURL=tiptap-extension-horizontal-rule.cjs.js.map |
@@ -22,3 +22,18 @@ import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core'; | ||
return chain() | ||
// remove node before hr if it’s an empty text block | ||
.command(({ tr, dispatch }) => { | ||
const { selection } = tr; | ||
const { empty, $anchor } = selection; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock | ||
&& !$anchor.parent.type.spec.code | ||
&& !$anchor.parent.textContent; | ||
if (!empty || !isEmptyTextBlock || !dispatch) { | ||
return true; | ||
} | ||
const posBefore = $anchor.before(); | ||
tr.deleteRange(posBefore, posBefore + 1); | ||
return true; | ||
}) | ||
.insertContent({ type: this.name }) | ||
// add node after hr if it’s the end of the document | ||
.command(({ tr, dispatch }) => { | ||
@@ -30,3 +45,2 @@ var _a; | ||
const nodeAfter = tr.doc.nodeAt(posAfter); | ||
// end of document | ||
if (!nodeAfter) { | ||
@@ -54,4 +68,3 @@ const node = (_a = parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create(); | ||
export default HorizontalRule; | ||
export { HorizontalRule }; | ||
export { HorizontalRule, HorizontalRule as default }; | ||
//# sourceMappingURL=tiptap-extension-horizontal-rule.esm.js.map |
@@ -25,3 +25,18 @@ (function (global, factory) { | ||
return chain() | ||
// remove node before hr if it’s an empty text block | ||
.command(({ tr, dispatch }) => { | ||
const { selection } = tr; | ||
const { empty, $anchor } = selection; | ||
const isEmptyTextBlock = $anchor.parent.isTextblock | ||
&& !$anchor.parent.type.spec.code | ||
&& !$anchor.parent.textContent; | ||
if (!empty || !isEmptyTextBlock || !dispatch) { | ||
return true; | ||
} | ||
const posBefore = $anchor.before(); | ||
tr.deleteRange(posBefore, posBefore + 1); | ||
return true; | ||
}) | ||
.insertContent({ type: this.name }) | ||
// add node after hr if it’s the end of the document | ||
.command(({ tr, dispatch }) => { | ||
@@ -33,3 +48,2 @@ var _a; | ||
const nodeAfter = tr.doc.nodeAt(posAfter); | ||
// end of document | ||
if (!nodeAfter) { | ||
@@ -58,3 +72,3 @@ const node = (_a = parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create(); | ||
exports.HorizontalRule = HorizontalRule; | ||
exports.default = HorizontalRule; | ||
exports['default'] = HorizontalRule; | ||
@@ -61,0 +75,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@tiptap/extension-horizontal-rule", | ||
"description": "horizontal rule extension for tiptap", | ||
"version": "2.0.0-beta.18", | ||
"version": "2.0.0-beta.19", | ||
"homepage": "https://tiptap.dev", | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "345ea8cf8abba6422dabc6e548594fb8e2c30409" | ||
"gitHead": "8fd75bc4b699caa693dbfc52568ef2554979920e" | ||
} |
@@ -46,3 +46,22 @@ import { | ||
return chain() | ||
// remove node before hr if it’s an empty text block | ||
.command(({ tr, dispatch }) => { | ||
const { selection } = tr | ||
const { empty, $anchor } = selection | ||
const isEmptyTextBlock = $anchor.parent.isTextblock | ||
&& !$anchor.parent.type.spec.code | ||
&& !$anchor.parent.textContent | ||
if (!empty || !isEmptyTextBlock || !dispatch) { | ||
return true | ||
} | ||
const posBefore = $anchor.before() | ||
tr.deleteRange(posBefore, posBefore + 1) | ||
return true | ||
}) | ||
.insertContent({ type: this.name }) | ||
// add node after hr if it’s the end of the document | ||
.command(({ tr, dispatch }) => { | ||
@@ -54,3 +73,2 @@ if (dispatch) { | ||
// end of document | ||
if (!nodeAfter) { | ||
@@ -57,0 +75,0 @@ const node = parent.type.contentMatch.defaultType?.create() |
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
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
36557
304