You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@udecode/plate-selection

Package Overview
Dependencies
Maintainers
0
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-selection - npm Package Compare versions

Comparing version

to
42.2.0

83

dist/index.js

@@ -106,17 +106,33 @@ "use strict";

var import_plate9 = require("@udecode/plate");
var import_react9 = require("@udecode/plate/react");
var import_react10 = require("@udecode/plate/react");
// src/internal/transforms/selectBlocks.ts
var selectBlocks = (editor, at) => {
const blockSelection = editor.getApi(BlockSelectionPlugin).blockSelection.getNodes();
const entry = editor.api.node(at);
if (!entry) return;
const [element, path] = entry;
const selectedBlocks = blockSelection.length > 0 ? blockSelection : editor.api.blocks({
match: (_, p) => p.length === path.length,
mode: "lowest"
});
const ids = selectedBlocks.map((block) => block[0].id);
editor.getApi(BlockSelectionPlugin).blockSelection.setSelectedIds({
ids: ids.includes(element.id) ? ids : [element.id]
});
};
// src/react/components/BlockSelectionAfterEditable.tsx
var import_react5 = __toESM(require("react"));
var import_react6 = __toESM(require("react"));
var import_react_dom = __toESM(require("react-dom"));
var import_plate4 = require("@udecode/plate");
var import_react6 = require("@udecode/plate/react");
var import_react7 = require("@udecode/plate/react");
// src/react/hooks/useBlockSelectable.ts
var import_plate = require("@udecode/plate");
var import_react2 = require("@udecode/plate/react");
var import_react3 = require("@udecode/plate/react");
var useBlockSelectable = () => {
const element = (0, import_react2.useElement)();
const path = (0, import_react2.usePath)();
const { api, editor, getOption, getOptions } = (0, import_react2.useEditorPlugin)({
const element = (0, import_react3.useElement)();
const path = (0, import_react3.usePath)();
const { api, editor, getOption, getOptions } = (0, import_react3.useEditorPlugin)({
key: "blockSelection"

@@ -154,4 +170,4 @@ });

// src/react/hooks/useSelectionArea.ts
var import_react3 = __toESM(require("react"));
var import_react4 = require("@udecode/plate/react");
var import_react4 = __toESM(require("react"));
var import_react5 = require("@udecode/plate/react");

@@ -908,5 +924,5 @@ // src/internal/EventEmitter.ts

var useSelectionArea = () => {
const { api, editor, getOptions, setOption } = (0, import_react4.useEditorPlugin)(BlockSelectionPlugin);
const { api, editor, getOptions, setOption } = (0, import_react5.useEditorPlugin)(BlockSelectionPlugin);
const { areaOptions } = getOptions();
import_react3.default.useEffect(() => {
import_react4.default.useEffect(() => {
const selection = new SelectionArea({

@@ -1021,10 +1037,10 @@ boundaries: `#${editor.uid}`,

var BlockSelectionAfterEditable = () => {
const editor = (0, import_react6.useEditorRef)();
const { api, getOption, getOptions, setOption, useOption } = (0, import_react6.useEditorPlugin)({ key: "blockSelection" });
const editor = (0, import_react7.useEditorRef)();
const { api, getOption, getOptions, setOption, useOption } = (0, import_react7.useEditorPlugin)({ key: "blockSelection" });
const isSelecting2 = useOption("isSelecting");
const selectedIds = useOption("selectedIds");
useSelectionArea();
const inputRef = import_react5.default.useRef(null);
const [isMounted, setIsMounted] = import_react5.default.useState(false);
import_react5.default.useEffect(() => {
const inputRef = import_react6.default.useRef(null);
const [isMounted, setIsMounted] = import_react6.default.useState(false);
import_react6.default.useEffect(() => {
setIsMounted(true);

@@ -1036,3 +1052,3 @@ setOption("shadowInputRef", inputRef);

}, [setOption]);
import_react5.default.useEffect(() => {
import_react6.default.useEffect(() => {
if (!isSelecting2) {

@@ -1042,3 +1058,3 @@ setOption("anchorId", null);

}, [isSelecting2, setOption]);
import_react5.default.useEffect(() => {
import_react6.default.useEffect(() => {
if (isSelecting2 && inputRef.current) {

@@ -1050,3 +1066,3 @@ inputRef.current.focus({ preventScroll: true });

}, [isSelecting2]);
const handleKeyDown = import_react5.default.useCallback(
const handleKeyDown = import_react6.default.useCallback(
(e) => {

@@ -1125,3 +1141,3 @@ const isReadonly = editor.api.isReadOnly();

);
const handleCopy = import_react5.default.useCallback(
const handleCopy = import_react6.default.useCallback(
(e) => {

@@ -1135,3 +1151,3 @@ e.preventDefault();

);
const handleCut = import_react5.default.useCallback(
const handleCut = import_react6.default.useCallback(
(e) => {

@@ -1152,3 +1168,3 @@ e.preventDefault();

);
const handlePaste = import_react5.default.useCallback(
const handlePaste = import_react6.default.useCallback(
(e) => {

@@ -1166,3 +1182,3 @@ e.preventDefault();

return import_react_dom.default.createPortal(
/* @__PURE__ */ import_react5.default.createElement(
/* @__PURE__ */ import_react6.default.createElement(
"input",

@@ -1190,5 +1206,5 @@ {

// src/react/internal/transforms/moveSelection.ts
var import_react7 = require("@udecode/plate/react");
var import_react8 = require("@udecode/plate/react");
var moveSelection = (editor, direction) => {
const { api, setOption } = (0, import_react7.getEditorPlugin)(editor, BlockSelectionPlugin);
const { api, setOption } = (0, import_react8.getEditorPlugin)(editor, BlockSelectionPlugin);
const blocks = api.blockSelection.getNodes();

@@ -1225,5 +1241,5 @@ if (blocks.length === 0) return;

var import_plate5 = require("@udecode/plate");
var import_react8 = require("@udecode/plate/react");
var import_react9 = require("@udecode/plate/react");
var shiftSelection = (editor, direction) => {
const { api, getOption, getOptions, setOption } = (0, import_react8.getEditorPlugin)(
const { api, getOption, getOptions, setOption } = (0, import_react9.getEditorPlugin)(
editor,

@@ -1425,3 +1441,3 @@ BlockSelectionPlugin

// src/react/BlockSelectionPlugin.tsx
var BlockSelectionPlugin = (0, import_react9.createTPlatePlugin)({
var BlockSelectionPlugin = (0, import_react10.createTPlatePlugin)({
key: "blockSelection",

@@ -1552,4 +1568,13 @@ inject: {

removeNodes: (0, import_plate9.bindFirst)(removeBlockSelectionNodes, editor),
/** Select blocks */
/** Set selection based on block selection */
select: (0, import_plate9.bindFirst)(selectBlockSelectionNodes, editor),
/**
* Selects blocks in the editor based on the provided block ID.
*
* Uses block selection if any blocks are selected, otherwise falls back to
* editor selection. If the provided block ID is already in the current
* selection, maintains the existing selection. Otherwise, clears the
* current selection and selects only the specified block.
*/
selectBlocks: (0, import_plate9.bindFirst)(selectBlocks, editor),
/** Set block indent */

@@ -1556,0 +1581,0 @@ setIndent: (0, import_plate9.bindFirst)(setBlockSelectionIndent, editor),

@@ -177,4 +177,13 @@ import * as _udecode_plate_core_react from '@udecode/plate-core/react';

removeNodes: () => void;
/** Select blocks */
/** Set selection based on block selection */
select: () => void;
/**
* Selects blocks in the editor based on the provided block ID.
*
* Uses block selection if any blocks are selected, otherwise falls back to
* editor selection. If the provided block ID is already in the current
* selection, maintains the existing selection. Otherwise, clears the
* current selection and selects only the specified block.
*/
selectBlocks: (at: Path | _udecode_slate.TNode) => void;
/** Set block indent */

@@ -181,0 +190,0 @@ setIndent: (indent: number, options?: _udecode_slate.SetNodesOptions | undefined) => void;

{
"name": "@udecode/plate-selection",
"version": "42.0.3",
"version": "42.2.0",
"description": "Plate selection plugins",

@@ -59,3 +59,3 @@ "keywords": [

"peerDependencies": {
"@udecode/plate": ">=42.0.3",
"@udecode/plate": ">=42.1.2",
"react": ">=18.0.0",

@@ -62,0 +62,0 @@ "react-dom": ">=18.0.0"

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 too big to display

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