Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lilium-text

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lilium-text - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

54

build/liliumtext.js

@@ -159,6 +159,8 @@ "use strict";

var fragWrap = !leftExistWrap && !rightExistWrap && frag.querySelector(nodetype);
var fragWrap = !leftExistWrap && !rightExistWrap && frag.querySelectorAll(nodetype);
if (left.parentElement === right.parentElement && !leftExistWrap && !fragWrap) {
if (left.parentElement === right.parentElement && !leftExistWrap && !fragWrap.length) {
this.editor.log("Quick range wrap with element of node type " + nodetype);
// Might be worth looking at Range.surroundContents()
var newElem = document.createElement(nodetype);

@@ -183,27 +185,19 @@ newElem.appendChild(frag);

});
} else if (fragWrap) {
this.highlightNode(node);
} else if (fragWrap.length != 0) {
// There is an element inside the fragment with requested node name
// Unwrap child element
this.editor.log('Fragment child unwrap with node type ' + nodetype);
while (fragWrap) {
if (fragWrap.parentNode) {
while (fragWrap.firstChild) {
fragWrap.parentNode.insertBefore(fragWrap.firstChild, fragWrap);
}
} else {
var newFrag = document.createDocumentFragment();
while (fragWrap.firstChild) {
newFrag.appendChild(fragWrap.firstChild);
}
var target = fragWrap.Node || frag;
target.insertBefore(newFrag, target.firstChild);
Array.prototype.forEach.call(fragWrap, function (elem) {
while (elem.firstChild) {
elem.parentNode ? elem.parentNode.insertBefore(elem.firstChild, elem) : frag.insertBefore(elem.firstChild, frag);
}
});
fragWrap.remove();
fragWrap = frag.querySelector(nodetype);
}
Array.prototype.forEach.call(fragWrap, function (elem) {
return elem && elem.remove && elem.remove();
});
var _range = selection.getRangeAt(0);
_range.insertNode(frag);
selection.getRangeAt(0).insertNode(frag);
} else if (leftExistWrap && rightExistWrap && leftExistWrap === rightExistWrap) {

@@ -231,2 +225,4 @@ // Unwrap both ends, possible solution : while (textnode has next sibling) { insert sibling after wrapper node }

clonePlaceholder.remove();
this.highlightNode(clone);
} else if (leftExistWrap && rightExistWrap) {

@@ -260,8 +256,8 @@ this.editor.log("Merge wrap from two sources with node types : " + nodetype);

var _range2 = selection.getRangeAt(0);
_range2.insertNode(_newElem2);
_range2.selectNode(_newElem2);
var _range = selection.getRangeAt(0);
_range.insertNode(_newElem2);
_range.selectNode(_newElem2);
selection.removeAllRanges();
selection.addRange(_range2);
selection.addRange(_range);
}

@@ -838,8 +834,8 @@ }

if (selection.focusOffset != 0) {
var _range3 = selection.getRangeAt(0).cloneRange();
_range3.setEndAfter(element);
_range3.collapse(false);
var _range2 = selection.getRangeAt(0).cloneRange();
_range2.setEndAfter(element);
_range2.collapse(false);
selection.removeAllRanges();
selection.addRange(_range3);
selection.addRange(_range2);
}

@@ -846,0 +842,0 @@ }

@@ -106,6 +106,8 @@ class LiliumTextCommand {

let fragWrap = !leftExistWrap && !rightExistWrap && frag.querySelector(nodetype);
let fragWrap = !leftExistWrap && !rightExistWrap && frag.querySelectorAll(nodetype);
if (left.parentElement === right.parentElement && !leftExistWrap && !fragWrap) {
if (left.parentElement === right.parentElement && !leftExistWrap && !fragWrap.length) {
this.editor.log("Quick range wrap with element of node type " + nodetype);
// Might be worth looking at Range.surroundContents()
const newElem = document.createElement(nodetype);

@@ -130,27 +132,19 @@ newElem.appendChild(frag);

});
} else if (fragWrap) {
this.highlightNode(node);
} else if (fragWrap.length != 0) {
// There is an element inside the fragment with requested node name
// Unwrap child element
this.editor.log('Fragment child unwrap with node type ' + nodetype);
while (fragWrap) {
if (fragWrap.parentNode) {
while (fragWrap.firstChild) {
fragWrap.parentNode.insertBefore(fragWrap.firstChild, fragWrap);
}
} else {
const newFrag = document.createDocumentFragment();
while (fragWrap.firstChild) {
newFrag.appendChild(fragWrap.firstChild);
}
const target = fragWrap.Node || frag;
target.insertBefore(newFrag, target.firstChild);
Array.prototype.forEach.call(fragWrap, elem => {
while (elem.firstChild) {
elem.parentNode ?
elem.parentNode.insertBefore(elem.firstChild, elem) :
frag.insertBefore(elem.firstChild, frag);
}
});
fragWrap.remove();
fragWrap = frag.querySelector(nodetype);
}
Array.prototype.forEach.call(fragWrap, elem => elem && elem.remove && elem.remove());
const range = selection.getRangeAt(0)
range.insertNode(frag);
selection.getRangeAt(0).insertNode(frag);
} else if (leftExistWrap && rightExistWrap && leftExistWrap === rightExistWrap) {

@@ -178,2 +172,4 @@ // Unwrap both ends, possible solution : while (textnode has next sibling) { insert sibling after wrapper node }

clonePlaceholder.remove();
this.highlightNode(clone);
} else if (leftExistWrap && rightExistWrap) {

@@ -180,0 +176,0 @@ this.editor.log("Merge wrap from two sources with node types : " + nodetype);

{
"name": "lilium-text",
"version": "0.2.3",
"version": "0.2.4",
"description": "Web rich text editor. Ready to be used in a test environment.",

@@ -5,0 +5,0 @@ "main": "build/liliumtext.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc