Socket
Socket
Sign inDemoInstall

@lexical/mark

Package Overview
Dependencies
Maintainers
8
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/mark - npm Package Compare versions

Comparing version 0.12.2 to 0.12.3

71

LexicalMark.dev.js

@@ -19,18 +19,15 @@ /**

*/
/** @noInheritDoc */
class MarkNode extends lexical.ElementNode {
/** @internal */
static getType() {
return 'mark';
}
static clone(node) {
return new MarkNode(Array.from(node.__ids), node.__key);
}
static importDOM() {
return null;
}
static importJSON(serializedNode) {

@@ -43,5 +40,5 @@ const node = $createMarkNode(serializedNode.ids);

}
exportJSON() {
return { ...super.exportJSON(),
return {
...super.exportJSON(),
ids: this.getIDs(),

@@ -52,3 +49,2 @@ type: 'mark',

}
constructor(ids, key) {

@@ -58,14 +54,10 @@ super(key);

}
createDOM(config) {
const element = document.createElement('mark');
utils.addClassNamesToElement(element, config.theme.mark);
if (this.__ids.length > 1) {
utils.addClassNamesToElement(element, config.theme.markOverlap);
}
return element;
}
updateDOM(prevNode, element, config) {

@@ -77,3 +69,2 @@ const prevIDs = prevNode.__ids;

const overlapTheme = config.theme.markOverlap;
if (prevIDsCount !== nextIDsCount) {

@@ -88,9 +79,6 @@ if (prevIDsCount === 1) {

}
return false;
}
hasID(id) {
const ids = this.getIDs();
for (let i = 0; i < ids.length; i++) {

@@ -101,6 +89,4 @@ if (id === ids[i]) {

}
return false;
}
getIDs() {

@@ -110,10 +96,7 @@ const self = this.getLatest();

}
addID(id) {
const self = this.getWritable();
if ($isMarkNode(self)) {
const ids = self.__ids;
self.__ids = ids;
for (let i = 0; i < ids.length; i++) {

@@ -123,14 +106,10 @@ // If we already have it, don't add again

}
ids.push(id);
}
}
deleteID(id) {
const self = this.getWritable();
if ($isMarkNode(self)) {
const ids = self.__ids;
self.__ids = ids;
for (let i = 0; i < ids.length; i++) {

@@ -144,6 +123,4 @@ if (id === ids[i]) {

}
insertNewAfter(selection, restoreSelection = true) {
const element = this.getParentOrThrow().insertNewAfter(selection, restoreSelection);
if (lexical.$isElementNode(element)) {

@@ -154,22 +131,16 @@ const markNode = $createMarkNode(this.__ids);

}
return null;
}
canInsertTextBefore() {
return false;
}
canInsertTextAfter() {
return false;
}
canBeEmpty() {
return false;
}
isInline() {
return true;
}
extractWithChild(child, selection, destination) {

@@ -179,3 +150,2 @@ if (!lexical.$isRangeSelection(selection) || destination === 'html') {

}
const anchor = selection.anchor;

@@ -189,7 +159,5 @@ const focus = selection.focus;

}
excludeFromCopy(destination) {
return destination !== 'clone';
}
}

@@ -207,6 +175,4 @@ function $createMarkNode(ids) {

let target = null;
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (target === null) {

@@ -217,6 +183,4 @@ node.insertBefore(child);

}
target = child;
}
node.remove();

@@ -232,10 +196,10 @@ }

let currentNodeParent;
let lastCreatedMarkNode; // We only want wrap adjacent text nodes, line break nodes
let lastCreatedMarkNode;
// We only want wrap adjacent text nodes, line break nodes
// and inline element nodes. For decorator nodes and block
// element nodes, we step out of their boundary and start
// again after, if there are more nodes.
for (let i = 0; i < nodesLength; i++) {
const node = nodes[i];
if (lexical.$isElementNode(lastCreatedMarkNode) && lastCreatedMarkNode.isParentOf(node)) {

@@ -245,7 +209,5 @@ // If the current node is a child of the last created mark node, there is nothing to do here

}
const isFirstNode = i === 0;
const isLastNode = i === nodesLength - 1;
let targetNode = null;
if (lexical.$isTextNode(node)) {

@@ -256,7 +218,5 @@ // Case 1: The node is a text node and we can split it

const endTextOffset = isLastNode ? endOffset : textContentSize;
if (startTextOffset === 0 && endTextOffset === 0) {
continue;
}
const splitNodes = node.splitText(startTextOffset, endTextOffset);

@@ -270,2 +230,3 @@ targetNode = splitNodes.length > 1 && (splitNodes.length === 3 || isFirstNode && !isLastNode || endTextOffset === textContentSize) ? splitNodes[1] : splitNodes[0];

// codebase.
continue;

@@ -277,3 +238,2 @@ } else if (lexical.$isElementNode(node) && node.isInline()) {

}
if (targetNode !== null) {

@@ -287,5 +247,3 @@ // Now that we have a target node for wrapping with a mark, we can run

}
const parentNode = targetNode.getParent();
if (parentNode == null || !parentNode.is(currentNodeParent)) {

@@ -296,5 +254,3 @@ // If the parent node is not the current node's parent node, we can

}
currentNodeParent = parentNode;
if (lastCreatedMarkNode === undefined) {

@@ -305,5 +261,5 @@ // If we don't have a created mark node, we can make one

targetNode.insertBefore(lastCreatedMarkNode);
} // Add the target node to be wrapped in the latest created mark node
}
// Add the target node to be wrapped in the latest created mark node
lastCreatedMarkNode.append(targetNode);

@@ -316,5 +272,4 @@ } else {

}
} // Make selection collapsed at the end
}
// Make selection collapsed at the end
if (lexical.$isElementNode(lastCreatedMarkNode)) {

@@ -327,3 +282,2 @@ // eslint-disable-next-line no-unused-expressions

let currentNode = node;
while (currentNode !== null) {

@@ -334,3 +288,2 @@ if ($isMarkNode(currentNode)) {

const nextSibling = currentNode.getNextSibling();
if ($isMarkNode(nextSibling)) {

@@ -340,6 +293,4 @@ return nextSibling.getIDs();

}
currentNode = currentNode.getParent();
}
return null;

@@ -346,0 +297,0 @@ }

6

package.json

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.12.2",
"version": "0.12.3",
"main": "LexicalMark.js",
"peerDependencies": {
"lexical": "0.12.2"
"lexical": "0.12.3"
},
"dependencies": {
"@lexical/utils": "0.12.2"
"@lexical/utils": "0.12.3"
},

@@ -20,0 +20,0 @@ "repository": {

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