Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prosekit/core

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prosekit/core - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

218

dist/_tsup-dts-rollup.d.ts

@@ -8,2 +8,3 @@ import { AllSelection } from '@prosekit/pm/state';

import type { DirectEditorProps } from '@prosekit/pm/view';
import type { DOMEventMap } from '@prosekit/pm/view';
import { EditorState } from '@prosekit/pm/state';

@@ -19,2 +20,3 @@ import type { EditorStateConfig } from '@prosekit/pm/state';

import { Node as Node_2 } from 'prosemirror-model';
import type { Node as Node_3 } from '@prosekit/pm/model';
import { NodeSelection } from '@prosekit/pm/state';

@@ -35,2 +37,3 @@ import type { NodeSpec } from '@prosekit/pm/model';

import type { Simplify } from 'type-fest';
import type { Slice } from '@prosekit/pm/model';
import { TextSelection } from '@prosekit/pm/state';

@@ -128,2 +131,10 @@ import { Transaction } from '@prosekit/pm/state';

declare type ClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
export { ClickHandler }
export { ClickHandler as ClickHandler_alias_1 }
declare type ClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
export { ClickOnHandler }
export { ClickOnHandler as ClickOnHandler_alias_1 }
/**

@@ -142,2 +153,4 @@ * A utility for constructing `className` strings conditionally.

export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
export declare interface CommandApplier<Args extends any[] = any[]> {

@@ -289,2 +302,20 @@ (...args: Args): boolean;

/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClick}
*/
declare function defineClickHandler(handler: ClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineClickHandler }
export { defineClickHandler as defineClickHandler_alias_1 }
/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn}
*/
declare function defineClickOnHandler(handler: ClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineClickOnHandler }
export { defineClickOnHandler as defineClickOnHandler_alias_1 }
declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{

@@ -321,2 +352,38 @@ COMMAND_ARGS: {

/**
* Register a new event handler for the given event type.
*
* @public
*/
declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineDOMEventHandler }
export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick}
*/
declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineDoubleClickHandler }
export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn}
*/
declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineDoubleClickOnHandler }
export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop}
*/
declare function defineDropHandler(handler: DropHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineDropHandler }
export { defineDropHandler as defineDropHandler_alias_1 }
/**
* Registers a event handler that is called when the editor gains or loses focus.

@@ -344,3 +411,12 @@ *

* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
*/
declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineKeyDownHandler }
export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
/**
* @public
*/
declare function defineKeymap(keymap: Keymap): Extension;

@@ -352,3 +428,12 @@ export { defineKeymap }

* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress}
*/
declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineKeyPressHandler }
export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
/**
* @public
*/
declare function defineMarkAttr(options: MarkAttrOptions): Extension;

@@ -428,2 +513,11 @@ export { defineMarkAttr }

/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste}
*/
declare function definePasteHandler(handler: PasteHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { definePasteHandler }
export { definePasteHandler as definePasteHandler_alias_1 }
/**
* Adds a ProseMirror plugin to the editor.

@@ -444,3 +538,12 @@ *

* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection}
*/
declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineScrollToSelectionHandler }
export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_1 }
/**
* @public
*/
declare function defineText(): Extension< {

@@ -453,2 +556,29 @@ NODES: "text";

/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput}
*/
declare function defineTextInputHandler(handler: TextInputHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineTextInputHandler }
export { defineTextInputHandler as defineTextInputHandler_alias_1 }
/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick}
*/
declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineTripleClickHandler }
export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
/**
* @public
*
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn}
*/
declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineTripleClickOnHandler }
export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
/**
* Registers a event handler that is called when the editor view is unmounted.

@@ -484,4 +614,38 @@ *

/**
* @internal
*/
export declare const domEventFacet: Facet<DOMEventPayload, PluginPayload>;
/**
* A function to handle the events fired on the editable DOM element. Returns
* `true` to indicate that it handled the given event. you are responsible for
* calling `preventDefault` yourself (or not, if you want to allow the default
* behavior).
*
* @public
*/
declare type DOMEventHandler<Event extends keyof DOMEventMap = string> = (view: EditorView, event: DOMEventMap[Event]) => boolean | void;
export { DOMEventHandler }
export { DOMEventHandler as DOMEventHandler_alias_1 }
/**
* @internal
*/
export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
declare type DoubleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
export { DoubleClickHandler }
export { DoubleClickHandler as DoubleClickHandler_alias_1 }
declare type DoubleClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
export { DoubleClickOnHandler }
export { DoubleClickOnHandler as DoubleClickOnHandler_alias_1 }
declare type DropHandler = (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
export { DropHandler }
export { DropHandler as DropHandler_alias_1 }
/**
* @public
*/
declare class Editor<E extends Extension = any> {

@@ -784,2 +948,8 @@ private instance;

export declare type GroupedEntries<T extends Record<string, any>> = {
[K in keyof T]?: T[K][];
};
export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
/**

@@ -914,2 +1084,6 @@ * Returns a command that inserts the given node at the current selection or at

declare type KeyDownHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
export { KeyDownHandler }
export { KeyDownHandler as KeyDownHandler_alias_1 }
/**

@@ -938,2 +1112,6 @@ * @public

declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
export { KeyPressHandler }
export { KeyPressHandler as KeyPressHandler_alias_1 }
/**

@@ -1116,4 +1294,23 @@ * @public

/**
* @internal
*
* @example
*
* ```
* type MyObject = { a: 1; b: 'B' }
* type MyEntries = ObjectEntries<MyObject>
* // ^ ["a", 1] | ["b", "B"]
*
*/
export declare type ObjectEntries<T extends Record<string, any>> = {
[K in keyof T]: [K, T[K]];
}[keyof T];
export declare function objectEqual<T>(a: T, b: T): boolean;
declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
export { PasteHandler }
export { PasteHandler as PasteHandler_alias_1 }
declare type Payload = unknown;

@@ -1196,2 +1393,6 @@

declare type ScrollToSelectionHandler = (view: EditorView) => boolean;
export { ScrollToSelectionHandler }
export { ScrollToSelectionHandler as ScrollToSelectionHandler_alias_1 }
/**

@@ -1262,2 +1463,7 @@ * Returns a command that selects the whole document.

*/
export declare type Setter<T> = (value: T) => void;
/**
* @internal
*/
declare type SimplifyExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<ExceptEmptyValue<{

@@ -1311,2 +1517,6 @@ NODES: ExtractNodes<E[number]>;

declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
export { TextInputHandler }
export { TextInputHandler as TextInputHandler_alias_1 }
export declare type ToCommandApplier<T extends CommandArgs> = {

@@ -1349,2 +1559,10 @@ [K in keyof T]: CommandApplier<T[K]>;

declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
export { TripleClickHandler }
export { TripleClickHandler as TripleClickHandler_alias_1 }
declare type TripleClickOnHandler = (view: EditorView, pos: number, node: Node_3, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
export { TripleClickOnHandler }
export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
declare type Tuple5<T> = [T, T, T, T, T];

@@ -1351,0 +1569,0 @@

@@ -23,2 +23,28 @@ export { addMark } from './_tsup-dts-rollup';

export { DocChangeHandler } from './_tsup-dts-rollup';
export { defineDOMEventHandler } from './_tsup-dts-rollup';
export { DOMEventHandler } from './_tsup-dts-rollup';
export { defineClickHandler } from './_tsup-dts-rollup';
export { defineClickOnHandler } from './_tsup-dts-rollup';
export { defineDoubleClickHandler } from './_tsup-dts-rollup';
export { defineDoubleClickOnHandler } from './_tsup-dts-rollup';
export { defineDropHandler } from './_tsup-dts-rollup';
export { defineKeyDownHandler } from './_tsup-dts-rollup';
export { defineKeyPressHandler } from './_tsup-dts-rollup';
export { definePasteHandler } from './_tsup-dts-rollup';
export { defineScrollToSelectionHandler } from './_tsup-dts-rollup';
export { defineTextInputHandler } from './_tsup-dts-rollup';
export { defineTripleClickHandler } from './_tsup-dts-rollup';
export { defineTripleClickOnHandler } from './_tsup-dts-rollup';
export { ClickHandler } from './_tsup-dts-rollup';
export { ClickOnHandler } from './_tsup-dts-rollup';
export { DoubleClickHandler } from './_tsup-dts-rollup';
export { DoubleClickOnHandler } from './_tsup-dts-rollup';
export { DropHandler } from './_tsup-dts-rollup';
export { KeyDownHandler } from './_tsup-dts-rollup';
export { KeyPressHandler } from './_tsup-dts-rollup';
export { PasteHandler } from './_tsup-dts-rollup';
export { ScrollToSelectionHandler } from './_tsup-dts-rollup';
export { TextInputHandler } from './_tsup-dts-rollup';
export { TripleClickHandler } from './_tsup-dts-rollup';
export { TripleClickOnHandler } from './_tsup-dts-rollup';
export { defineFocusChangeHandler } from './_tsup-dts-rollup';

@@ -25,0 +51,0 @@ export { FocusChangeHandler } from './_tsup-dts-rollup';

227

dist/prosekit-core.js

@@ -1445,19 +1445,199 @@ // src/commands/add-mark.ts

// src/extensions/events/focus.ts
// src/extensions/events/dom-event.ts
import { PluginKey as PluginKey2, ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
function defineFocusChangeHandler(handler) {
const handleFocus = () => handler(true);
const handleBlur = () => handler(false);
const plugin = new ProseMirrorPlugin2({
key: new PluginKey2("prosekit-focus-handler"),
props: {
handleDOMEvents: {
focus: handleFocus,
blur: handleBlur
// src/utils/combine-event-handlers.ts
function combineEventHandlers() {
let _handlers = [];
function setHandlers(handlers) {
_handlers = handlers;
}
function combinedEventHandler(...args) {
for (const handler of _handlers) {
if (handler(...args)) {
return true;
}
}
return false;
}
return [setHandlers, combinedEventHandler];
}
// src/utils/group-entries.ts
function groupEntries(entries) {
const map = {};
for (const [key, value] of entries) {
const values = map[key];
if (!values) {
map[key] = [value];
} else {
values.push(value);
}
}
return map;
}
// src/extensions/events/dom-event.ts
function defineDOMEventHandler(event, handler) {
return domEventFacet.extension([
[event, handler]
]);
}
var domEventFacet = Facet.define({
converter: () => {
const setHandlersMap = {};
const combinedHandlerMap = {};
const update = (payloads) => {
let hasNewEvent = false;
for (const [event] of payloads) {
if (!setHandlersMap[event]) {
hasNewEvent = true;
const [setHandlers, combinedHandler] = combineEventHandlers();
setHandlersMap[event] = setHandlers;
combinedHandlerMap[event] = combinedHandler;
}
}
const map = groupEntries(payloads);
for (const [event, handlers] of Object.entries(map)) {
const setHandlers = setHandlersMap[event];
setHandlers(handlers != null ? handlers : []);
}
if (hasNewEvent) {
return new ProseMirrorPlugin2({
key: new PluginKey2("prosekit-dom-event-handler"),
props: { handleDOMEvents: combinedHandlerMap }
});
} else {
return null;
}
};
return {
create: (payloads) => {
const plugin = update(payloads);
return plugin ? () => plugin : () => [];
},
update: (payloads) => {
const plugin = update(payloads);
return plugin ? () => plugin : null;
}
};
},
next: pluginFacet,
singleton: true
});
// src/extensions/events/editor-event.ts
import { PluginKey as PluginKey3, ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
function defineKeyDownHandler(handler) {
return editorEventFacet.extension([["keyDown", handler]]);
}
function defineKeyPressHandler(handler) {
return editorEventFacet.extension([["keyPress", handler]]);
}
function defineTextInputHandler(handler) {
return editorEventFacet.extension([["textInput", handler]]);
}
function defineClickOnHandler(handler) {
return editorEventFacet.extension([["clickOn", handler]]);
}
function defineClickHandler(handler) {
return editorEventFacet.extension([["click", handler]]);
}
function defineDoubleClickOnHandler(handler) {
return editorEventFacet.extension([["doubleClickOn", handler]]);
}
function defineDoubleClickHandler(handler) {
return editorEventFacet.extension([["doubleClick", handler]]);
}
function defineTripleClickOnHandler(handler) {
return editorEventFacet.extension([["tripleClickOn", handler]]);
}
function defineTripleClickHandler(handler) {
return editorEventFacet.extension([["tripleClick", handler]]);
}
function definePasteHandler(handler) {
return editorEventFacet.extension([["paste", handler]]);
}
function defineDropHandler(handler) {
return editorEventFacet.extension([["drop", handler]]);
}
function defineScrollToSelectionHandler(handler) {
return editorEventFacet.extension([["scrollToSelection", handler]]);
}
var editorEventFacet = Facet.define({
converter: () => {
const [update, plugin] = setupEditorEventPlugin();
return {
create: (entries) => {
update(entries);
return () => plugin;
},
update: (entries) => {
update(entries);
return null;
}
};
},
next: pluginFacet,
singleton: true
});
function setupEditorEventPlugin() {
const [setKeyDownHandlers, handleKeyDown] = combineEventHandlers();
const [setKeyPressHandlers, handleKeyPress] = combineEventHandlers();
const [setTextInputHandlers, handleTextInput] = combineEventHandlers();
const [setClickOnHandlers, handleClickOn] = combineEventHandlers();
const [setClickHandlers, handleClick] = combineEventHandlers();
const [setDoubleClickOnHandlers, handleDoubleClickOn] = combineEventHandlers();
const [setDoubleClickHandlers, handleDoubleClick] = combineEventHandlers();
const [setTripleClickOnHandlers, handleTripleClickOn] = combineEventHandlers();
const [setTripleClickHandlers, handleTripleClick] = combineEventHandlers();
const [setPasteHandlers, handlePaste] = combineEventHandlers();
const [setDropHandlers, handleDrop] = combineEventHandlers();
const [setScrollToSelectionHandlers, handleScrollToSelection] = combineEventHandlers();
const update = (entries) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
const map = groupEntries(entries);
setKeyDownHandlers((_a = map.keyDown) != null ? _a : []);
setKeyPressHandlers((_b = map.keyPress) != null ? _b : []);
setTextInputHandlers((_c = map.textInput) != null ? _c : []);
setClickOnHandlers((_d = map.clickOn) != null ? _d : []);
setClickHandlers((_e = map.click) != null ? _e : []);
setDoubleClickOnHandlers((_f = map.doubleClickOn) != null ? _f : []);
setDoubleClickHandlers((_g = map.doubleClick) != null ? _g : []);
setTripleClickOnHandlers((_h = map.tripleClickOn) != null ? _h : []);
setTripleClickHandlers((_i = map.tripleClick) != null ? _i : []);
setPasteHandlers((_j = map.paste) != null ? _j : []);
setDropHandlers((_k = map.drop) != null ? _k : []);
setScrollToSelectionHandlers((_l = map.scrollToSelection) != null ? _l : []);
};
const plugin = new ProseMirrorPlugin3({
key: new PluginKey3("prosekit-editor-handler"),
props: {
handleKeyDown,
handleKeyPress,
handleTextInput,
handleClickOn,
handleClick,
handleDoubleClickOn,
handleDoubleClick,
handleTripleClickOn,
handleTripleClick,
handlePaste,
handleDrop,
handleScrollToSelection
}
});
return definePlugin(plugin);
return [update, plugin];
}
// src/extensions/events/focus.ts
function defineFocusChangeHandler(handler) {
const handleFocus = () => handler(true);
const handleBlur = () => handler(false);
return domEventFacet.extension([
["focus", handleFocus],
["blur", handleBlur]
]);
}
// src/extensions/history.ts

@@ -1472,3 +1652,3 @@ import { history, redo, undo } from "@prosekit/pm/history";

import { keydownHandler } from "@prosekit/pm/keymap";
import { Plugin as Plugin3, PluginKey as PluginKey3 } from "@prosekit/pm/state";
import { Plugin as Plugin3, PluginKey as PluginKey4 } from "@prosekit/pm/state";
function defineKeymap(keymap) {

@@ -1524,3 +1704,3 @@ return keymapFacet.extension([keymap]);

}
var keymapPluginKey = new PluginKey3("prosekit-keymap");
var keymapPluginKey = new PluginKey4("prosekit-keymap");

@@ -1638,3 +1818,3 @@ // src/extensions/history.ts

// src/extensions/node-view.ts
import { ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
import { ProseMirrorPlugin as ProseMirrorPlugin4 } from "@prosekit/pm/state";
import "@prosekit/pm/view";

@@ -1652,3 +1832,3 @@ function defineNodeView(options) {

}
return () => [new ProseMirrorPlugin3({ props: { nodeViews } })];
return () => [new ProseMirrorPlugin4({ props: { nodeViews } })];
},

@@ -1659,3 +1839,3 @@ next: pluginFacet

// src/extensions/node-view-effect.ts
import { ProseMirrorPlugin as ProseMirrorPlugin4 } from "@prosekit/pm/state";
import { ProseMirrorPlugin as ProseMirrorPlugin5 } from "@prosekit/pm/state";
import "@prosekit/pm/view";

@@ -1688,3 +1868,3 @@ function defineNodeViewFactory(options) {

}
return () => [new ProseMirrorPlugin4({ props: { nodeViews } })];
return () => [new ProseMirrorPlugin5({ props: { nodeViews } })];
},

@@ -1773,8 +1953,16 @@ next: pluginFacet

defineBaseKeymap,
defineClickHandler,
defineClickOnHandler,
defineCommands,
defineDOMEventHandler,
defineDefaultState,
defineDoc,
defineDocChangeHandler,
defineDoubleClickHandler,
defineDoubleClickOnHandler,
defineDropHandler,
defineFocusChangeHandler,
defineHistory,
defineKeyDownHandler,
defineKeyPressHandler,
defineKeymap,

@@ -1789,4 +1977,9 @@ defineMarkAttr,

defineParagraph,
definePasteHandler,
definePlugin,
defineScrollToSelectionHandler,
defineText,
defineTextInputHandler,
defineTripleClickHandler,
defineTripleClickOnHandler,
defineUnmountHandler,

@@ -1793,0 +1986,0 @@ defineUpdateHandler,

4

package.json
{
"name": "@prosekit/core",
"type": "module",
"version": "0.3.0",
"version": "0.3.1",
"private": false,

@@ -45,3 +45,3 @@ "author": {

"@prosekit/dev": "*",
"tsup": "^8.0.1",
"tsup": "^8.0.2",
"typescript": "^5.3.3",

@@ -48,0 +48,0 @@ "vitest": "^1.2.2"

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