🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@udecode/plate-node-id

Package Overview
Dependencies
Maintainers
3
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-node-id - npm Package Compare versions

Comparing version

to
40.0.0

14

dist/index.d.ts

@@ -12,2 +12,8 @@ import * as _udecode_plate_core from '@udecode/plate-core';

/**
* Filter inline `Element` nodes.
*
* @default true
*/
filterInline?: boolean;
/**
* Filter `Text` nodes.

@@ -31,2 +37,10 @@ *

/**
* Normalize initial value. If false, normalize only the first and last node
* are missing id. To disable this behavior, use `NodeIdPlugin.configure({
* normalizeInitialValue: null })`.
*
* @default false
*/
normalizeInitialValue?: boolean;
/**
* Reuse ids on undo/redo and copy/pasting if not existing in the document.

@@ -33,0 +47,0 @@ * This is disabled by default to avoid duplicate ids across documents.

54

dist/index.js

@@ -184,7 +184,57 @@ "use strict";

extendEditor: withNodeId,
normalizeInitialValue: ({ editor, getOptions }) => {
const {
allow,
exclude,
filter,
filterInline,
filterText,
idKey,
normalizeInitialValue
} = getOptions();
if (!normalizeInitialValue) {
const firstNode = editor.children[0];
const lastNode = editor.children.at(-1);
if ((firstNode == null ? void 0 : firstNode.id) && (lastNode == null ? void 0 : lastNode.id)) {
return editor.children;
}
}
const addNodeId = (entry) => {
var _a;
const [node, path] = entry;
const newNode = __spreadValues({}, node);
if (!newNode[idKey] && (0, import_plate_common2.queryNode)([node, path], {
allow,
exclude,
filter: (entry2) => {
const [node2] = entry2;
if (filterText && !(0, import_plate_common2.isElement)(node2)) {
return false;
}
if (filterInline && (0, import_plate_common2.isElement)(node2) && !(0, import_plate_common2.isBlock)(editor, node2)) {
return false;
}
return filter(entry2);
}
})) {
newNode[idKey] = getOptions().idCreator();
}
if (((_a = newNode.children) == null ? void 0 : _a.length) > 0) {
newNode.children = newNode.children.map(
(child, index) => addNodeId([child, [...path, index]])
);
}
return newNode;
};
return editor.children.map(
(node, index) => addNodeId([node, [index]])
);
},
options: {
filter: () => true,
filterInline: true,
filterText: true,
idCreator: () => Math.random().toString(36).slice(2, 7),
idKey: "id"
idCreator: () => (0, import_plate_common2.nanoid)(10),
idKey: "id",
normalizeInitialValue: false
}

@@ -191,0 +241,0 @@ });

7

package.json
{
"name": "@udecode/plate-node-id",
"version": "39.0.0",
"version": "40.0.0",
"description": "Node ID plugin for Plate",

@@ -53,9 +53,10 @@ "keywords": [

"peerDependencies": {
"@udecode/plate-common": ">=39.0.0",
"@udecode/plate-common": ">=40.0.0",
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"slate": ">=0.103.0",
"slate-dom": ">=0.111.0",
"slate-history": ">=0.93.0",
"slate-hyperscript": ">=0.66.0",
"slate-react": ">=0.108.0"
"slate-react": ">=0.111.0"
},

@@ -62,0 +63,0 @@ "publishConfig": {

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

Sorry, the diff of this file is not supported yet