@atlaskit/editor-plugin-list
Version:
List plugin for @atlaskit/editor-core
44 lines (42 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.joinParagrapWithList = void 0;
var _utils = require("@atlaskit/editor-common/utils");
//Case for two adjacent nodes with the first being a list item and the last being a paragraph
var joinParagrapWithList = exports.joinParagrapWithList = function joinParagrapWithList(_ref) {
var tr = _ref.tr,
$next = _ref.$next,
$head = _ref.$head;
/* CASE 1
* Initial Structure:
*
* List A {
* ListItem B {
* ...Children C
* Paragraph D { text1 |$head||textInsertPos| }
* }
* }
* Paragraph E { |$next| text 2 }
*
* Converts to:
*
* List A {
* ListItem B {
* ...Children C
* Paragraph D { text1text2 }
* }
* }
*
*/
var paragraphE = $next.parent;
var beforeParagraphE = $next.before();
var afterParagraphE = $next.after();
var textInsertPos = $head.pos;
var textContent = paragraphE.content;
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
return tr.doc.resolve(textInsertPos);
}, [[textContent, textInsertPos]], [[beforeParagraphE, afterParagraphE]]);
return true;
};