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

@udecode/plate-excalidraw

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-excalidraw - npm Package Compare versions

Comparing version

to
37.0.0

dist/ExcalidrawPlugin-ClhgoGx4.d.mts

43

dist/index.d.ts

@@ -1,38 +0,9 @@

import * as _udecode_plate_common_server from '@udecode/plate-common/server';
import { Value, PlateEditor, PlatePluginKey, TNodeProps, InsertNodesOptions } from '@udecode/plate-common/server';
import * as _udecode_slate from '@udecode/slate';
import * as _udecode_utils from '@udecode/utils';
import { ImportedDataState } from '@excalidraw/excalidraw/types/data/types';
import { ExcalidrawElement } from '@excalidraw/excalidraw/types/element/types';
import { ExcalidrawProps, LibraryItems } from '@excalidraw/excalidraw/types/types';
import { TElement } from '@udecode/plate-common';
import { T as TExcalidrawElement } from './ExcalidrawPlugin-ClhgoGx4.js';
export { a as ExcalidrawDataState, E as ExcalidrawPlugin } from './ExcalidrawPlugin-ClhgoGx4.js';
import { SlateEditor, TNodeProps, InsertNodesOptions } from '@udecode/plate-common';
import '@excalidraw/excalidraw/types/data/types';
import '@excalidraw/excalidraw/types/element/types';
declare const ELEMENT_EXCALIDRAW = "excalidraw";
/** Enables support for Excalidraw drawing tool within a Slate document */
declare const createExcalidrawPlugin: <OP = _udecode_utils.AnyObject, OV extends _udecode_slate.Value = _udecode_slate.Value, OE extends _udecode_plate_common_server.PlateEditor<OV> = _udecode_plate_common_server.PlateEditor<OV>>(override?: Partial<_udecode_plate_common_server.PlatePlugin<_udecode_plate_common_server.NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: _udecode_plate_common_server.OverrideByKey<OV, OE> | undefined) => _udecode_plate_common_server.PlatePlugin<_udecode_plate_common_server.NoInfer<OP>, OV, OE>;
declare const insertExcalidraw: <E extends SlateEditor>(editor: E, props?: TNodeProps<TExcalidrawElement>, options?: InsertNodesOptions<E>) => void;
interface TExcalidrawElement extends TElement {
data?: {
elements: ExcalidrawDataState['elements'];
state: ExcalidrawDataState['appState'];
} | null;
}
interface ExcalidrawDataState extends Omit<ImportedDataState, 'elements'> {
elements?: null | readonly Partial<ExcalidrawElement>[];
}
interface TExcalidrawProps extends Omit<ExcalidrawProps, 'initialData'> {
initialData: ExcalidrawDataState | Promise<ExcalidrawDataState | null> | null;
}
declare const useExcalidrawElement: ({ element, libraryItems, scrollToContent, }: {
element: TExcalidrawElement;
libraryItems?: LibraryItems | undefined;
scrollToContent?: boolean | undefined;
}) => {
Excalidraw: any;
excalidrawProps: TExcalidrawProps;
};
declare const insertExcalidraw: <V extends Value>(editor: PlateEditor<V>, { key, ...props }?: PlatePluginKey & TNodeProps<TExcalidrawElement>, options?: InsertNodesOptions<V>) => void;
export { ELEMENT_EXCALIDRAW, type ExcalidrawDataState, type TExcalidrawElement, type TExcalidrawProps, createExcalidrawPlugin, insertExcalidraw, useExcalidrawElement };
export { TExcalidrawElement, insertExcalidraw };
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;

@@ -7,3 +6,2 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -23,14 +21,2 @@ var __propIsEnum = Object.prototype.propertyIsEnumerable;

};
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {

@@ -48,10 +34,2 @@ for (var name in all)

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -62,74 +40,28 @@

__export(src_exports, {
ELEMENT_EXCALIDRAW: () => ELEMENT_EXCALIDRAW,
createExcalidrawPlugin: () => createExcalidrawPlugin,
insertExcalidraw: () => insertExcalidraw,
useExcalidrawElement: () => useExcalidrawElement
ExcalidrawPlugin: () => ExcalidrawPlugin,
insertExcalidraw: () => insertExcalidraw
});
module.exports = __toCommonJS(src_exports);
// src/createExcalidrawPlugin.ts
var import_server = require("@udecode/plate-common/server");
var ELEMENT_EXCALIDRAW = "excalidraw";
var createExcalidrawPlugin = (0, import_server.createPluginFactory)({
isElement: true,
isVoid: true,
key: ELEMENT_EXCALIDRAW
// src/lib/ExcalidrawPlugin.ts
var import_plate_common = require("@udecode/plate-common");
var ExcalidrawPlugin = (0, import_plate_common.createSlatePlugin)({
key: "excalidraw",
node: { isElement: true, isVoid: true }
});
// src/hooks/useExcalidrawElement.ts
var import_react = __toESM(require("react"));
var useExcalidrawElement = ({
element,
libraryItems = [],
scrollToContent = true
}) => {
var _a, _b;
const [Excalidraw, setExcalidraw] = import_react.default.useState(null);
import_react.default.useEffect(() => {
void import("@excalidraw/excalidraw").then(
(comp) => setExcalidraw(comp.Excalidraw)
);
});
const _excalidrawRef = import_react.default.useRef(null);
const excalidrawProps = {
autoFocus: false,
excalidrawRef: _excalidrawRef,
initialData: {
appState: (_a = element.data) == null ? void 0 : _a.state,
elements: (_b = element.data) == null ? void 0 : _b.elements,
libraryItems,
scrollToContent
}
// onChange: (elements: readonly ExcalidrawElementType[], state: AppState) => {
// const path = findNodePath(editor, element);
// FIXME: setNodes triggers render loop as onChange is triggered on rerender
// in the meantime, the prop can be used to save the data outside slate
// setNodes(editor, { data: { elements, state } }, { at: path });
// },
};
return {
Excalidraw,
excalidrawProps
};
};
// src/transforms/insertExcalidraw.ts
var import_server2 = require("@udecode/plate-common/server");
var insertExcalidraw = (editor, _a = {}, options = {}) => {
var _b = _a, {
key = ELEMENT_EXCALIDRAW
} = _b, props = __objRest(_b, [
"key"
]);
// src/lib/transforms/insertExcalidraw.ts
var import_plate_common2 = require("@udecode/plate-common");
var insertExcalidraw = (editor, props = {}, options = {}) => {
if (!editor.selection)
return;
const selectionParentEntry = (0, import_server2.getParentNode)(editor, editor.selection);
const selectionParentEntry = (0, import_plate_common2.getParentNode)(editor, editor.selection);
if (!selectionParentEntry)
return;
const [, path] = selectionParentEntry;
(0, import_server2.insertNodes)(
(0, import_plate_common2.insertNodes)(
editor,
__spreadValues({
children: [{ text: "" }],
type: key
type: editor.getType(ExcalidrawPlugin)
}, props),

@@ -141,7 +73,5 @@ __spreadValues({ at: path, nextBlock: true }, options)

0 && (module.exports = {
ELEMENT_EXCALIDRAW,
createExcalidrawPlugin,
insertExcalidraw,
useExcalidrawElement
ExcalidrawPlugin,
insertExcalidraw
});
//# sourceMappingURL=index.js.map
{
"name": "@udecode/plate-excalidraw",
"version": "36.0.0",
"version": "37.0.0",
"description": "Excalidraw plugin for Plate",
"license": "MIT",
"keywords": [
"plate",
"plugin",
"slate"
],
"homepage": "https://platejs.org",
"bugs": {
"url": "https://github.com/udecode/plate/issues"
},
"repository": {

@@ -12,12 +19,4 @@ "type": "git",

},
"bugs": {
"url": "https://github.com/udecode/plate/issues"
},
"license": "MIT",
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*"
],
"exports": {

@@ -29,8 +28,20 @@ ".": {

"require": "./dist/index.js"
},
"./react": {
"types": "./dist/react/index.d.ts",
"import": "./dist/react/index.mjs",
"module": "./dist/react/index.mjs",
"require": "./dist/react/index.js"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*"
],
"scripts": {
"brl": "yarn p:brl",
"build": "yarn p:build",
"build:watch": "yarn p:build:watch",
"brl": "yarn p:brl",
"clean": "yarn p:clean",

@@ -50,15 +61,10 @@ "lint": "yarn p:lint",

"peerDependencies": {
"@udecode/plate-common": ">=36.0.0",
"@udecode/plate-common": ">=37.0.0",
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"slate": ">=0.94.0",
"slate": ">=0.103.0",
"slate-history": ">=0.93.0",
"slate-hyperscript": ">=0.66.0",
"slate-react": ">=0.99.0"
"slate-react": ">=0.108.0"
},
"keywords": [
"plate",
"plugin",
"slate"
],
"publishConfig": {

@@ -65,0 +71,0 @@ "access": "public"

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