New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@udecode/plate-indent

Package Overview
Dependencies
Maintainers
3
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-indent - npm Package Compare versions

Comparing version 41.0.0 to 42.0.0

dist/BaseIndentPlugin-SYPntbjC.d.mts

18

dist/index.d.ts

@@ -1,5 +0,5 @@

import { I as IndentConfig } from './BaseIndentPlugin-DziNJeAx.js';
export { B as BaseIndentPlugin, T as TIndentElement } from './BaseIndentPlugin-DziNJeAx.js';
import { I as IndentConfig } from './BaseIndentPlugin-SYPntbjC.js';
export { B as BaseIndentPlugin, T as TIndentElement } from './BaseIndentPlugin-SYPntbjC.js';
import * as _udecode_plate_core from '@udecode/plate-core';
import { PluginConfig, ExtendEditor, TEditor, GetNodeEntriesOptions, UnhangRangeOptions, AnyObject, SlateEditor } from '@udecode/plate-common';
import { PluginConfig, OverrideEditor, EditorNodesOptions, AnyObject, SlateEditor } from '@udecode/plate';

@@ -13,7 +13,7 @@ type TextIndentConfig = PluginConfig<'textIndent', IndentConfig['options']>;

*/
declare const withIndent: ExtendEditor<IndentConfig>;
declare const withIndent: OverrideEditor<IndentConfig>;
interface SetIndentOptions<E extends TEditor = TEditor> {
interface SetIndentOptions {
/** GetNodeEntries options */
getNodesOptions?: GetNodeEntriesOptions<E> & UnhangRangeOptions;
getNodesOptions?: EditorNodesOptions;
/**

@@ -33,10 +33,10 @@ * 1 to indent -1 to outdent

/** Add offset to the indentation of the selected blocks. */
declare const setIndent: <E extends SlateEditor>(editor: E, { getNodesOptions, offset, setNodesProps, unsetNodesProps, }: SetIndentOptions<E>) => void;
declare const setIndent: (editor: SlateEditor, { getNodesOptions, offset, setNodesProps, unsetNodesProps, }: SetIndentOptions) => void;
/** Increase the indentation of the selected blocks. */
declare const indent: <E extends SlateEditor>(editor: E, options?: SetIndentOptions<E>) => void;
declare const indent: (editor: SlateEditor, options?: SetIndentOptions) => void;
/** Decrease the indentation of the selected blocks. */
declare const outdent: <E extends SlateEditor>(editor: E, options?: SetIndentOptions<E>) => void;
declare const outdent: (editor: SlateEditor, options?: SetIndentOptions) => void;
export { BaseTextIndentPlugin, IndentConfig, type SetIndentOptions, type TextIndentConfig, indent, outdent, setIndent, withIndent };

@@ -5,17 +5,3 @@ "use strict";

var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {

@@ -36,4 +22,4 @@ for (var name in all)

// src/index.ts
var src_exports = {};
__export(src_exports, {
var index_exports = {};
__export(index_exports, {
BaseIndentPlugin: () => BaseIndentPlugin,

@@ -46,41 +32,42 @@ BaseTextIndentPlugin: () => BaseTextIndentPlugin,

});
module.exports = __toCommonJS(src_exports);
module.exports = __toCommonJS(index_exports);
// src/lib/BaseIndentPlugin.ts
var import_plate_common3 = require("@udecode/plate-common");
var import_plate2 = require("@udecode/plate");
// src/lib/withIndent.ts
var import_plate_common = require("@udecode/plate-common");
var import_plate_common2 = require("@udecode/plate-common");
var import_plate = require("@udecode/plate");
var withIndent = ({
editor,
getOptions,
plugin
plugin,
tf: { normalizeNode }
}) => {
const { normalizeNode } = editor;
editor.normalizeNode = ([node, path]) => {
const { indentMax } = getOptions();
const element = node;
const { type } = element;
const match = (0, import_plate_common.getInjectMatch)(editor, plugin);
if (type) {
if (match(element, path)) {
if (indentMax && element.indent && element.indent > indentMax) {
(0, import_plate_common2.setElements)(editor, { indent: indentMax }, { at: path });
return;
return {
transforms: {
normalizeNode([node, path]) {
const { indentMax } = getOptions();
const element = node;
const { type } = element;
const match = (0, import_plate.getInjectMatch)(editor, plugin);
if (type) {
if (match(element, path)) {
if (indentMax && element.indent && element.indent > indentMax) {
editor.tf.setNodes({ indent: indentMax }, { at: path });
return;
}
} else if (element.indent) {
editor.tf.unsetNodes("indent", { at: path });
return;
}
}
} else if (element.indent) {
(0, import_plate_common2.unsetNodes)(editor, "indent", { at: path });
return;
return normalizeNode([node, path]);
}
}
return normalizeNode([node, path]);
};
return editor;
};
// src/lib/BaseIndentPlugin.ts
var BaseIndentPlugin = (0, import_plate_common3.createTSlatePlugin)({
var BaseIndentPlugin = (0, import_plate2.createTSlatePlugin)({
key: "indent",
extendEditor: withIndent,
inject: {

@@ -96,3 +83,3 @@ isBlock: true,

},
targetPlugins: [import_plate_common3.BaseParagraphPlugin.key]
targetPlugins: [import_plate2.BaseParagraphPlugin.key]
},

@@ -103,7 +90,7 @@ options: {

}
});
}).overrideEditor(withIndent);
// src/lib/BaseTextIndentPlugin.ts
var import_plate_common4 = require("@udecode/plate-common");
var BaseTextIndentPlugin = (0, import_plate_common4.createTSlatePlugin)({
var import_plate3 = require("@udecode/plate");
var BaseTextIndentPlugin = (0, import_plate3.createTSlatePlugin)({
key: "textIndent",

@@ -120,3 +107,3 @@ inject: {

},
targetPlugins: [import_plate_common4.BaseParagraphPlugin.key]
targetPlugins: [import_plate3.BaseParagraphPlugin.key]
},

@@ -130,3 +117,2 @@ options: {

// src/lib/transforms/setIndent.ts
var import_plate_common5 = require("@udecode/plate-common");
var setIndent = (editor, {

@@ -139,19 +125,19 @@ getNodesOptions,

const { nodeKey } = editor.getInjectProps(BaseIndentPlugin);
const _nodes = (0, import_plate_common5.getNodeEntries)(editor, __spreadValues({
const _nodes = editor.api.nodes({
block: true,
mode: "lowest"
}, getNodesOptions));
mode: "lowest",
...getNodesOptions
});
const nodes = Array.from(_nodes);
(0, import_plate_common5.withoutNormalizing)(editor, () => {
editor.tf.withoutNormalizing(() => {
nodes.forEach(([node, path]) => {
var _a, _b;
const blockIndent = (_a = node[nodeKey]) != null ? _a : 0;
const blockIndent = node[nodeKey] ?? 0;
const newIndent = blockIndent + offset;
const props = (_b = setNodesProps == null ? void 0 : setNodesProps({ indent: newIndent })) != null ? _b : {};
const props = setNodesProps?.({ indent: newIndent }) ?? {};
if (newIndent <= 0) {
(0, import_plate_common5.unsetNodes)(editor, [nodeKey, ...unsetNodesProps], {
editor.tf.unsetNodes([nodeKey, ...unsetNodesProps], {
at: path
});
} else {
(0, import_plate_common5.setElements)(editor, __spreadValues({ [nodeKey]: newIndent }, props), { at: path });
editor.tf.setNodes({ [nodeKey]: newIndent, ...props }, { at: path });
}

@@ -164,3 +150,3 @@ });

var indent = (editor, options) => {
setIndent(editor, __spreadValues({ offset: 1 }, options));
setIndent(editor, { offset: 1, ...options });
};

@@ -170,3 +156,3 @@

var outdent = (editor, options) => {
setIndent(editor, __spreadValues({ offset: -1 }, options));
setIndent(editor, { offset: -1, ...options });
};

@@ -173,0 +159,0 @@ // Annotate the CommonJS export names for ESM import in node:

import * as _udecode_plate_core_react from '@udecode/plate-core/react';
import * as _udecode_plate_core from '@udecode/plate-core';
import { KeyboardHandler } from '@udecode/plate-common/react';
import { I as IndentConfig } from '../BaseIndentPlugin-DziNJeAx.js';
import '@udecode/plate-common';
import { KeyboardHandler } from '@udecode/plate/react';
import { I as IndentConfig } from '../BaseIndentPlugin-SYPntbjC.js';
import '@udecode/plate';

@@ -7,0 +7,0 @@ declare const IndentPlugin: _udecode_plate_core_react.PlatePlugin<_udecode_plate_core.PluginConfig<"indent", {

@@ -5,17 +5,3 @@ "use strict";

var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {

@@ -47,41 +33,42 @@ for (var name in all)

// src/react/IndentPlugin.tsx
var import_react2 = require("@udecode/plate-common/react");
var import_react = require("@udecode/plate/react");
// src/lib/BaseIndentPlugin.ts
var import_plate_common3 = require("@udecode/plate-common");
var import_plate2 = require("@udecode/plate");
// src/lib/withIndent.ts
var import_plate_common = require("@udecode/plate-common");
var import_plate_common2 = require("@udecode/plate-common");
var import_plate = require("@udecode/plate");
var withIndent = ({
editor,
getOptions,
plugin
plugin,
tf: { normalizeNode }
}) => {
const { normalizeNode } = editor;
editor.normalizeNode = ([node, path]) => {
const { indentMax } = getOptions();
const element = node;
const { type } = element;
const match = (0, import_plate_common.getInjectMatch)(editor, plugin);
if (type) {
if (match(element, path)) {
if (indentMax && element.indent && element.indent > indentMax) {
(0, import_plate_common2.setElements)(editor, { indent: indentMax }, { at: path });
return;
return {
transforms: {
normalizeNode([node, path]) {
const { indentMax } = getOptions();
const element = node;
const { type } = element;
const match = (0, import_plate.getInjectMatch)(editor, plugin);
if (type) {
if (match(element, path)) {
if (indentMax && element.indent && element.indent > indentMax) {
editor.tf.setNodes({ indent: indentMax }, { at: path });
return;
}
} else if (element.indent) {
editor.tf.unsetNodes("indent", { at: path });
return;
}
}
} else if (element.indent) {
(0, import_plate_common2.unsetNodes)(editor, "indent", { at: path });
return;
return normalizeNode([node, path]);
}
}
return normalizeNode([node, path]);
};
return editor;
};
// src/lib/BaseIndentPlugin.ts
var BaseIndentPlugin = (0, import_plate_common3.createTSlatePlugin)({
var BaseIndentPlugin = (0, import_plate2.createTSlatePlugin)({
key: "indent",
extendEditor: withIndent,
inject: {

@@ -97,3 +84,3 @@ isBlock: true,

},
targetPlugins: [import_plate_common3.BaseParagraphPlugin.key]
targetPlugins: [import_plate2.BaseParagraphPlugin.key]
},

@@ -104,9 +91,8 @@ options: {

}
});
}).overrideEditor(withIndent);
// src/react/onKeyDownIndent.ts
var import_react = require("@udecode/plate-common/react");
var import_plate3 = require("@udecode/plate");
// src/lib/transforms/setIndent.ts
var import_plate_common4 = require("@udecode/plate-common");
var setIndent = (editor, {

@@ -119,19 +105,19 @@ getNodesOptions,

const { nodeKey } = editor.getInjectProps(BaseIndentPlugin);
const _nodes = (0, import_plate_common4.getNodeEntries)(editor, __spreadValues({
const _nodes = editor.api.nodes({
block: true,
mode: "lowest"
}, getNodesOptions));
mode: "lowest",
...getNodesOptions
});
const nodes = Array.from(_nodes);
(0, import_plate_common4.withoutNormalizing)(editor, () => {
editor.tf.withoutNormalizing(() => {
nodes.forEach(([node, path]) => {
var _a, _b;
const blockIndent = (_a = node[nodeKey]) != null ? _a : 0;
const blockIndent = node[nodeKey] ?? 0;
const newIndent = blockIndent + offset;
const props = (_b = setNodesProps == null ? void 0 : setNodesProps({ indent: newIndent })) != null ? _b : {};
const props = setNodesProps?.({ indent: newIndent }) ?? {};
if (newIndent <= 0) {
(0, import_plate_common4.unsetNodes)(editor, [nodeKey, ...unsetNodesProps], {
editor.tf.unsetNodes([nodeKey, ...unsetNodesProps], {
at: path
});
} else {
(0, import_plate_common4.setElements)(editor, __spreadValues({ [nodeKey]: newIndent }, props), { at: path });
editor.tf.setNodes({ [nodeKey]: newIndent, ...props }, { at: path });
}

@@ -144,3 +130,3 @@ });

var indent = (editor, options) => {
setIndent(editor, __spreadValues({ offset: 1 }, options));
setIndent(editor, { offset: 1, ...options });
};

@@ -150,3 +136,3 @@

var outdent = (editor, options) => {
setIndent(editor, __spreadValues({ offset: -1 }, options));
setIndent(editor, { offset: -1, ...options });
};

@@ -160,7 +146,7 @@

if (event.defaultPrevented) return;
if (import_react.Hotkeys.isTab(editor, event)) {
if (import_plate3.Hotkeys.isTab(editor, event)) {
event.preventDefault();
indent(editor);
}
if (import_react.Hotkeys.isUntab(editor, event)) {
if (import_plate3.Hotkeys.isUntab(editor, event)) {
event.preventDefault();

@@ -172,3 +158,3 @@ outdent(editor);

// src/react/IndentPlugin.tsx
var IndentPlugin = (0, import_react2.toPlatePlugin)(BaseIndentPlugin, {
var IndentPlugin = (0, import_react.toPlatePlugin)(BaseIndentPlugin, {
handlers: {

@@ -180,7 +166,7 @@ onKeyDown: onKeyDownIndent

// src/react/TextIndentPlugin.tsx
var import_react3 = require("@udecode/plate-common/react");
var import_react2 = require("@udecode/plate/react");
// src/lib/BaseTextIndentPlugin.ts
var import_plate_common5 = require("@udecode/plate-common");
var BaseTextIndentPlugin = (0, import_plate_common5.createTSlatePlugin)({
var import_plate4 = require("@udecode/plate");
var BaseTextIndentPlugin = (0, import_plate4.createTSlatePlugin)({
key: "textIndent",

@@ -197,3 +183,3 @@ inject: {

},
targetPlugins: [import_plate_common5.BaseParagraphPlugin.key]
targetPlugins: [import_plate4.BaseParagraphPlugin.key]
},

@@ -207,8 +193,8 @@ options: {

// src/react/TextIndentPlugin.tsx
var TextIndentPlugin = (0, import_react3.toPlatePlugin)(BaseTextIndentPlugin);
var TextIndentPlugin = (0, import_react2.toPlatePlugin)(BaseTextIndentPlugin);
// src/react/hooks/useIndentButton.ts
var import_react4 = require("@udecode/plate-common/react");
var import_react3 = require("@udecode/plate/react");
var useIndentButton = () => {
const editor = (0, import_react4.useEditorRef)();
const editor = (0, import_react3.useEditorRef)();
return {

@@ -227,5 +213,5 @@ props: {

// src/react/hooks/useOutdentButton.ts
var import_react5 = require("@udecode/plate-common/react");
var import_react4 = require("@udecode/plate/react");
var useOutdentButton = () => {
const editor = (0, import_react5.useEditorRef)();
const editor = (0, import_react4.useEditorRef)();
return {

@@ -232,0 +218,0 @@ props: {

{
"name": "@udecode/plate-indent",
"version": "41.0.0",
"version": "42.0.0",
"description": "Indent plugin for Plate",

@@ -53,13 +53,8 @@ "keywords": [

"devDependencies": {
"@udecode/plate-common": "workspace:^"
"@udecode/plate": "workspace:^"
},
"peerDependencies": {
"@udecode/plate-common": ">=41.0.0",
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"slate": ">=0.112.0",
"slate-dom": ">=0.111.0",
"slate-history": ">=0.93.0",
"slate-hyperscript": ">=0.66.0",
"slate-react": ">=0.111.0"
"@udecode/plate": ">=42.0.0",
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},

@@ -66,0 +61,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

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

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