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.0.0-next-20231120040948 to 0.0.0-next-20240421132240

796

dist/_tsup-dts-rollup.d.ts

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

import type { ConditionalExcept } from 'type-fest';
import type { ContentMatch } from '@prosekit/pm/model';
import type { DirectEditorProps } from '@prosekit/pm/view';
import type { DOMEventMap } from '@prosekit/pm/view';
import { DOMParser as DOMParser_2 } from '@prosekit/pm/model';
import { DOMSerializer } from '@prosekit/pm/model';
import { EditorState } from '@prosekit/pm/state';

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

import type { EmptyObject } from 'type-fest';
import { InputRule } from '@prosekit/pm/inputrules';
import type { IsEqual } from 'type-fest';

@@ -20,2 +23,3 @@ import { Mark } from '@prosekit/pm/model';

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

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

import { NodeType as NodeType_2 } from 'prosemirror-model';
import { NodeView } from '@prosekit/pm/view';
import { NodeViewConstructor } from '@prosekit/pm/view';

@@ -36,6 +41,6 @@ import { Options } from 'tsup';

import type { Simplify } from 'type-fest';
import type { Slice } from '@prosekit/pm/model';
import { TextSelection } from '@prosekit/pm/state';
import { Transaction } from '@prosekit/pm/state';
import type { UnionToIntersection } from 'type-fest';
import { UserProjectConfigExport } from 'vitest/dist/config.js';

@@ -48,3 +53,5 @@ declare type Action = (options: {

/**
* Add the given mark to the inline content.
* Returns a command that adds the given mark with the given attributes.
*
* @public
*/

@@ -103,4 +110,51 @@ declare function addMark(options: {

/**
* Some basic props for custom node views.
*
* @public
*/
declare interface BaseNodeViewOptions {
/**
* The wrapping DOM element for the node view. Defaults to `div` for block nodes and `span` for inline nodes.
*/
as?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
/**
* The wrapping DOM element for the node view's content. Defaults to `div` for block nodes and `span` for inline nodes.
*/
contentAs?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
update?: NodeView['update'];
ignoreMutation?: NodeView['ignoreMutation'];
selectNode?: NodeView['selectNode'];
deselectNode?: NodeView['deselectNode'];
setSelection?: NodeView['setSelection'];
stopEvent?: NodeView['stopEvent'];
destroy?: NodeView['destroy'];
onUpdate?: () => void;
}
export { BaseNodeViewOptions }
export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
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 }
/**
* A utility for constructing `className` strings conditionally.
*
* It is a re-export of [clsx/lite](https://www.npmjs.com/package/clsx) with stricter types.
*
* @public
*/
declare const clsx: (...args: Array<string | boolean | null | undefined>) => string;
export { clsx }
export { clsx as clsx_alias_1 }
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
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[]> {

@@ -137,3 +191,3 @@ (...args: Args): boolean;

*/
declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultHTML, defaultSelection, }: EditorOptions<E>): Editor<E>;
declare function createEditor<E extends Extension>(options: EditorOptions<E>): Editor<E>;
export { createEditor }

@@ -148,4 +202,15 @@ export { createEditor as createEditor_alias_1 }

export declare const default_alias_1: UserProjectConfigExport;
export declare const default_alias_1: {
test: {
environment: "jsdom";
};
};
/**
* @internal
*/
declare function defaultBlockAt(match: ContentMatch): NodeType_2 | null;
export { defaultBlockAt }
export { defaultBlockAt as defaultBlockAt_alias_1 }
declare interface DefaultStateOptions {

@@ -204,2 +269,7 @@ /**

}];
setNodeAttrs: [options: {
type: string | NodeType_2;
attrs: Attrs_2;
pos?: number | undefined;
}];
selectAll: [];

@@ -224,8 +294,35 @@ addMark: [options: {

/**
* Defines some basic key bindings.
*
* @public
*/
declare function defineBaseKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
declare function defineBaseKeymap(options?: {
/**
* The priority of the keymap.
*
* @default Priority.low
*/
priority?: Priority;
}): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineBaseKeymap }
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
/**
* @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<{

@@ -253,2 +350,56 @@ COMMAND_ARGS: {

/**
* Registers a event handler that is called when the editor document is changed.
*
* @public
*/
declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineDocChangeHandler }
export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
/**
* 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.
*
* @public
*/
declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineFocusChangeHandler }
export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
/**
* Add undo/redo history to the editor.

@@ -266,14 +417,9 @@ */

/**
* Defines an input rule extension.
* @public
*
* @param rule - The ProseMirror input rule to add, or an array of input rules,
* or a function that returns one or multiple input rules.
*
* @public
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
*/
declare function defineInputRule(rule: InputRule | InputRule[] | ((context: {
schema: Schema;
}) => InputRule | InputRule[])): Extension;
export { defineInputRule }
export { defineInputRule as defineInputRule_alias_1 }
declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineKeyDownHandler }
export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }

@@ -289,3 +435,19 @@ /**

* @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;
export { defineMarkAttr }
export { defineMarkAttr as defineMarkAttr_alias_1 }
/**
* @public
*/
declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{

@@ -298,4 +460,24 @@ MARKS: Mark;

/**
* Registers a event handler that is called when the editor view is mounted.
*
* @public
*/
declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineMountHandler }
export { defineMountHandler as defineMountHandler_alias_1 }
/**
* Defines an attribute for a node type.
*
* @public
*/
declare function defineNodeAttr(options: NodeAttrOptions): Extension;
export { defineNodeAttr }
export { defineNodeAttr as defineNodeAttr_alias_1 }
/**
* Defines a node type.
*
* @public
*/
declare function defineNodeSpec<NodeName extends string>(options: NodeSpecOptions<NodeName>): Extension<{

@@ -311,5 +493,8 @@ NODES: NodeName;

declare function defineNodeViewEffect(options: NodeViewEffectOptions): Extension;
export { defineNodeViewEffect }
export { defineNodeViewEffect as defineNodeViewEffect_alias_1 }
/**
* @internal
*/
declare function defineNodeViewFactory<T>(options: NodeViewFactoryOptions<T>): Extension;
export { defineNodeViewFactory }
export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }

@@ -337,2 +522,11 @@ /**

/**
* @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.

@@ -353,3 +547,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< {

@@ -362,4 +565,42 @@ NODES: "text";

/**
* @internal
* @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.
*
* @public
*/
declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineUnmountHandler }
export { defineUnmountHandler as defineUnmountHandler_alias_1 }
/**
* Registers a event handler that is called when the editor state is updated.
*
* @public
*/
declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;

@@ -370,4 +611,80 @@ export { defineUpdateHandler }

/**
* A function that is called when the editor document is changed.
*
* @param view - The editor view.
* @param prevState - The previous editor state.
*
* @public
*/
declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => void;
export { DocChangeHandler }
export { DocChangeHandler as DocChangeHandler_alias_1 }
/**
* @internal
*/
export declare class DOMDocumentNotFoundError extends ProseKitError {
constructor();
}
/** @public */
declare type DOMDocumentOptions = {
document?: Document;
};
export { DOMDocumentOptions }
export { DOMDocumentOptions as DOMDocumentOptions_alias_1 }
/**
* @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];
export declare type DOMNode = InstanceType<typeof window.Node>;
/** @public */
declare type DOMParserOptions = {
DOMParser?: typeof DOMParser_2;
};
export { DOMParserOptions }
export { DOMParserOptions as DOMParserOptions_alias_1 }
/** @public */
declare type DOMSerializerOptions = {
DOMSerializer?: typeof DOMSerializer;
};
export { DOMSerializerOptions }
export { DOMSerializerOptions as DOMSerializerOptions_alias_1 }
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> {

@@ -381,17 +698,38 @@ private instance;

static create(instance: any): Editor<any>;
/**
* Whether the editor is mounted.
*/
get mounted(): boolean;
/**
* The editor view.
*/
get view(): EditorView;
/**
* The editor schema.
*/
get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
get commands(): ExtractCommandAppliers<E>;
mount(place: HTMLElement | null | undefined | void): void;
/**
* Whether the editor is focused.
*/
get focused(): boolean;
/**
* Mount the editor to the given HTML element.
* Pass `null` or `undefined` to unmount the editor.
*/
mount(place: HTMLElement | null | undefined): void;
/**
* Unmount the editor. This is equivalent to `mount(null)`.
*/
unmount(): void;
use(extension: Extension): VoidFunction;
/**
* @deprecated
* Focus the editor.
*/
isNodeActive(nodeType: string | NodeType, attrs?: Attrs): boolean;
focus(): void;
/**
* @deprecated
* Blur the editor.
*/
isMarkActive(markType: string | MarkType, attrs?: Attrs): boolean;
blur(): void;
use(extension: Extension): VoidFunction;
get state(): EditorState;
get nodes(): Record<ExtractNodes<E>, NodeBuilder>;

@@ -404,2 +742,11 @@ get marks(): Record<ExtractMarks<E>, MarkBuilder>;

/**
* @internal
*/
declare class EditorNotFoundError extends ProseKitError {
constructor();
}
export { EditorNotFoundError }
export { EditorNotFoundError as EditorNotFoundError_alias_1 }
/**
* @public

@@ -436,4 +783,22 @@ */

*/
export declare function elementFromHTML(html: string): HTMLElement;
export declare function elementFromHTML(html: string, options?: DOMDocumentOptions): HTMLElement;
/**
* Parse a ProseMirror document JSON object to a HTML element.
*
* @public
*/
declare function elementFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
export { elementFromJSON }
export { elementFromJSON as elementFromJSON_alias_1 }
/**
* Serialize a ProseMirror node to a HTML element.
*
* @public
*/
declare function elementFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
export { elementFromNode }
export { elementFromNode as elementFromNode_alias_1 }
declare type EmptyValue = undefined | null | EmptyObject;

@@ -444,4 +809,18 @@

/**
* Expands the selection to include the entire mark at the current position.
*
* @public
*/
declare function expandMark(options: {
/**
* The type of the mark to expand.
*/
type: string | MarkType;
}): Command;
export { expandMark }
export { expandMark as expandMark_alias_1 }
/**
* @public
*/
declare interface Extension<T extends ExtensionTyping = ExtensionTyping> {

@@ -588,6 +967,29 @@ extension: Extension | Extension[];

export declare function getBrowserDocument(): Document | undefined;
export declare function findBrowserDocument(options?: {
document?: Document;
}): Document | undefined;
export declare function getBrowserWindow(): (Window & typeof globalThis) | null | undefined;
export declare function findBrowserWindow(options?: {
document?: Document;
}): (Window & typeof globalThis) | null | undefined;
/**
* A function that is called when the editor gains or loses focus.
*
* @param hasFocus - Whether the editor has focus.
*
* @public
*/
declare type FocusChangeHandler = (hasFocus: boolean) => void;
export { FocusChangeHandler }
export { FocusChangeHandler as FocusChangeHandler_alias_1 }
export declare function getBrowserDocument(options?: {
document?: Document;
}): Document;
export declare function getBrowserWindow(options?: {
document?: Document;
}): Window & typeof globalThis;
export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;

@@ -598,4 +1000,13 @@

/**
* Returns a unique id in the current process that can be used in various places.
*
* @internal
*/
declare function getId(): string;
export { getId as _getId }
export { getId }
/**
* @internal
*/
declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;

@@ -612,2 +1023,37 @@ export { getMarkType }

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>;
/**
* @internal
*/
export declare function htmlFromElement(element: HTMLElement): string;
/**
* Parse a ProseMirror document JSON object to a HTML string.
*
* @public
*/
declare function htmlFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): string;
export { htmlFromJSON }
export { htmlFromJSON as htmlFromJSON_alias_1 }
/**
* Serialize a ProseMirror node to a HTML string
*
* @public
*/
declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): string;
export { htmlFromNode }
export { htmlFromNode as htmlFromNode_alias_1 }
/**
* Returns a command that inserts the given node at the current selection or at
* the given position.
*
* @public
*/
declare function insertNode(options: {

@@ -632,2 +1078,7 @@ node: ProseMirrorNode;

/**
* Returns a command that inserts the given text.
*
* @public
*/
export declare function insertText({ text, from, to, }: {

@@ -646,2 +1097,13 @@ text: string;

export declare function isElement(value: unknown): value is Element;
/**
* Check if the selection is in a code block.
*
* @internal
*/
declare function isInCodeBlock(selection: Selection_2): boolean | undefined;
export { isInCodeBlock }
export { isInCodeBlock as isInCodeBlock_alias_1 }
export declare const isMac: boolean;

@@ -656,2 +1118,5 @@

/**
* @internal
*/
export declare function isMarkActive(state: EditorState, type: string | MarkType, attrs?: Attrs | null): boolean;

@@ -685,16 +1150,14 @@

/**
* Parse a HTML element to a ProseMirror document JSON.
* Serialize a HTML element to a ProseMirror document JSON object.
*
* @public
*/
declare function jsonFromElement(element: HTMLElement, schema: Schema): NodeJSON;
export { jsonFromElement }
export { jsonFromElement as jsonFromElement_alias_1 }
export declare function jsonFromElement(element: DOMNode, options: DOMParserOptions & JSONParserOptions): NodeJSON;
/**
* Parse a HTML string to a ProseMirror document JSON.
* Parse a HTML string to a ProseMirror document JSON object.
*
* @public
*/
declare function jsonFromHTML(html: string, schema: Schema): NodeJSON;
declare function jsonFromHTML(html: string, options: DOMDocumentOptions & DOMParserOptions & JSONParserOptions): NodeJSON;
export { jsonFromHTML }

@@ -721,2 +1184,13 @@ export { jsonFromHTML as jsonFromHTML_alias_1 }

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

@@ -731,2 +1205,50 @@ * @public

/**
* @internal
*/
declare const keymapFacet: Facet<Keymap, PluginPayload>;
export { keymapFacet }
export { keymapFacet as keymapFacet_alias_1 }
/**
* @internal
*/
declare type KeymapPayload = Keymap;
export { KeymapPayload }
export { KeymapPayload as KeymapPayload_alias_1 }
declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
export { KeyPressHandler }
export { KeyPressHandler as KeyPressHandler_alias_1 }
/**
* @public
*/
declare interface MarkAttrOptions {
/**
* The name of the mark type.
*/
type: string;
/**
* The name of the attribute.
*/
attr: string;
/**
* The default value for this attribute, to use when no explicit value is
* provided. Attributes that have no default must be provided whenever a mark
* of a type that has them is created.
*/
default?: any;
/**
* Returns the attribute key and value to be set on the DOM node.
*/
toDOM?: (value: any) => [key: string, value: string] | null | void;
/**
* Parses the attribute value from the DOM.
*/
parseDOM?: (node: HTMLElement) => any;
}
export { MarkAttrOptions }
export { MarkAttrOptions as MarkAttrOptions_alias_1 }
export declare interface MarkBuilder {

@@ -747,2 +1269,43 @@ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];

/**
* A function that is called when the editor view is mounted.
*
* @param view - The editor view.
*
* @public
*/
declare type MountHandler = (view: EditorView) => void;
export { MountHandler }
export { MountHandler as MountHandler_alias_1 }
/**
* @public
*/
declare interface NodeAttrOptions {
/**
* The name of the node type.
*/
type: string;
/**
* The name of the attribute.
*/
attr: string;
/**
* The default value for this attribute, to use when no explicit value is
* provided. Attributes that have no default must be provided whenever a node
* of a type that has them is created.
*/
default?: any;
/**
* Returns the attribute key and value to be set on the DOM node.
*/
toDOM?: (value: any) => [key: string, value: string] | null | void;
/**
* Parses the attribute value from the DOM.
*/
parseDOM?: (node: HTMLElement) => any;
}
export { NodeAttrOptions }
export { NodeAttrOptions as NodeAttrOptions_alias_1 }
export declare interface NodeBuilder {

@@ -763,3 +1326,3 @@ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;

*/
declare function nodeFromElement(element: HTMLElement, schema: Schema): ProseMirrorNode;
declare function nodeFromElement(element: DOMNode, options: DOMParserOptions & JSONParserOptions): ProseMirrorNode;
export { nodeFromElement }

@@ -773,3 +1336,3 @@ export { nodeFromElement as nodeFromElement_alias_1 }

*/
declare function nodeFromHTML(html: string, schema: Schema): ProseMirrorNode;
declare function nodeFromHTML(html: string, options: DOMParserOptions & JSONParserOptions & DOMDocumentOptions): ProseMirrorNode;
export { nodeFromHTML }

@@ -783,3 +1346,3 @@ export { nodeFromHTML as nodeFromHTML_alias_1 }

*/
declare function nodeFromJSON(json: NodeJSON, schema: Schema): ProseMirrorNode;
declare function nodeFromJSON(json: NodeJSON, options: JSONParserOptions): ProseMirrorNode;
export { nodeFromJSON }

@@ -813,13 +1376,16 @@ export { nodeFromJSON as nodeFromJSON_alias_1 }

declare type NodeViewEffectOptions = {
/**
* @internal
*/
declare type NodeViewFactoryOptions<T> = {
group: string;
name: string;
args: unknown;
args: T;
} | {
group: string;
name?: undefined;
factory: (args: unknown) => NodeViewConstructor;
factory: (args: T) => NodeViewConstructor;
};
export { NodeViewEffectOptions }
export { NodeViewEffectOptions as NodeViewEffectOptions_alias_1 }
export { NodeViewFactoryOptions }
export { NodeViewFactoryOptions as NodeViewFactoryOptions_alias_1 }

@@ -833,4 +1399,30 @@ declare interface NodeViewOptions {

/**
* @internal
*/
declare const OBJECT_REPLACEMENT_CHARACTER = "\uFFFC";
export { OBJECT_REPLACEMENT_CHARACTER }
export { OBJECT_REPLACEMENT_CHARACTER as OBJECT_REPLACEMENT_CHARACTER_alias_1 }
/**
* @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;

@@ -859,2 +1451,4 @@

/**
* ProseKit extension priority.
*
* @public

@@ -874,2 +1468,4 @@ */

* Base class for all ProseKit errors.
*
* @internal
*/

@@ -882,3 +1478,5 @@ declare class ProseKitError extends Error {

/**
* Remove the given mark from the inline content.
* Returns a command that removes the given mark.
*
* @public
*/

@@ -910,2 +1508,11 @@ declare function removeMark(options: {

declare type ScrollToSelectionHandler = (view: EditorView) => boolean;
export { ScrollToSelectionHandler }
export { ScrollToSelectionHandler as ScrollToSelectionHandler_alias_1 }
/**
* Returns a command that selects the whole document.
*
* @public
*/
export declare function selectAll(): Command;

@@ -929,2 +1536,4 @@

* type with the given attributes.
*
* @public
*/

@@ -941,4 +1550,36 @@ declare function setBlockType(options: {

/**
* Returns a command that set the attributes of the current node.
*
* @public
*/
declare function setNodeAttrs(options: {
/**
* The type of node to set the attributes of.
*
* If current node is not of this type, the command will do nothing.
*/
type: string | NodeType;
/**
* The attributes to set.
*/
attrs: Attrs;
/**
* The position of the node. Defaults to the position of the wrapping node
* containing the current selection.
*/
pos?: number;
}): Command;
export { setNodeAttrs }
export { setNodeAttrs as setNodeAttrs_alias_1 }
export declare function setSelectionAround(tr: Transaction, pos: number): void;
/**
* @internal
*/
export declare type Setter<T> = (value: T) => void;
/**
* @internal
*/
declare type SimplifyExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<ExceptEmptyValue<{

@@ -966,3 +1607,3 @@ NODES: ExtractNodes<E[number]>;

*/
declare function stateFromJSON(json: StateJSON, schema: Schema): EditorState;
declare function stateFromJSON(json: StateJSON, options: JSONParserOptions): EditorState;
export { stateFromJSON }

@@ -993,2 +1634,6 @@ export { stateFromJSON as stateFromJSON_alias_1 }

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> = {

@@ -1006,2 +1651,7 @@ [K in keyof T]: CommandApplier<T[K]>;

/**
* Returns a command that toggles the given mark with the given attributes.
*
* @public
*/
declare function toggleMark({ type, attrs, }: {

@@ -1014,2 +1664,8 @@ type: string | MarkType;

/**
* Returns a command that set the selected textblocks to the given node type
* with the given attributes.
*
* @public
*/
declare function toggleNode({ type, attrs, }: {

@@ -1022,4 +1678,17 @@ type: string | NodeType;

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];
/**
* Merge multiple extensions into one.
*
* @public
*/
declare function union<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;

@@ -1042,2 +1711,11 @@ export { union }

/**
* A function that is called when the editor view is unmounted.
*
* @public
*/
declare type UnmountHandler = () => void;
export { UnmountHandler }
export { UnmountHandler as UnmountHandler_alias_1 }
export declare function updateExtension(prevInputs: Payloads, prevConverters: Converters, extension: Extension, mode: 'add' | 'remove'): {

@@ -1050,6 +1728,13 @@ schemaInput: SchemaPayload | null;

export declare type UpdateHandler = (options: {
view: EditorView;
prevState?: EditorState;
}) => void;
/**
* A function that is called when the editor state is updated.
*
* @param view - The editor view.
* @param prevState - The previous editor state.
*
* @public
*/
declare type UpdateHandler = (view: EditorView, prevState: EditorState) => void;
export { UpdateHandler }
export { UpdateHandler as UpdateHandler_alias_1 }

@@ -1069,2 +1754,15 @@ export declare const viewFacet: Facet<ViewPayload, ViewPayload>;

/**
* @internal
*/
declare function withSkipCodeBlock(command: Command): Command;
export { withSkipCodeBlock }
export { withSkipCodeBlock as withSkipCodeBlock_alias_1 }
/**
* Returns a command that wraps the selected textblock with the given node type
* with the given attributes.
*
* @public
*/
export declare function wrap({ nodeType, attrs, }: {

@@ -1071,0 +1769,0 @@ nodeType: NodeType;

export { addMark } from './_tsup-dts-rollup';
export { expandMark } from './_tsup-dts-rollup';
export { insertNode } from './_tsup-dts-rollup';
export { removeMark } from './_tsup-dts-rollup';
export { setBlockType } from './_tsup-dts-rollup';
export { setNodeAttrs } from './_tsup-dts-rollup';
export { toggleMark } from './_tsup-dts-rollup';

@@ -12,2 +14,3 @@ export { toggleNode } from './_tsup-dts-rollup';

export { withPriority } from './_tsup-dts-rollup';
export { EditorNotFoundError_alias_1 as EditorNotFoundError } from './_tsup-dts-rollup';
export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';

@@ -19,15 +22,56 @@ export { defineBaseCommands } from './_tsup-dts-rollup';

export { defineDoc } from './_tsup-dts-rollup';
export { defineDocChangeHandler } 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';
export { FocusChangeHandler } from './_tsup-dts-rollup';
export { defineMountHandler } from './_tsup-dts-rollup';
export { defineUnmountHandler } from './_tsup-dts-rollup';
export { defineUpdateHandler } from './_tsup-dts-rollup';
export { MountHandler } from './_tsup-dts-rollup';
export { UnmountHandler } from './_tsup-dts-rollup';
export { UpdateHandler } from './_tsup-dts-rollup';
export { defineHistory } from './_tsup-dts-rollup';
export { defineInputRule } from './_tsup-dts-rollup';
export { defineBaseKeymap } from './_tsup-dts-rollup';
export { defineKeymap } from './_tsup-dts-rollup';
export { keymapFacet } from './_tsup-dts-rollup';
export { Keymap } from './_tsup-dts-rollup';
export { KeymapPayload } from './_tsup-dts-rollup';
export { defineMarkAttr } from './_tsup-dts-rollup';
export { defineMarkSpec } from './_tsup-dts-rollup';
export { MarkAttrOptions } from './_tsup-dts-rollup';
export { MarkSpecOptions } from './_tsup-dts-rollup';
export { defineNodeAttr } from './_tsup-dts-rollup';
export { defineNodeSpec } from './_tsup-dts-rollup';
export { NodeAttrOptions } from './_tsup-dts-rollup';
export { NodeSpecOptions } from './_tsup-dts-rollup';
export { defineNodeView } from './_tsup-dts-rollup';
export { NodeViewOptions } from './_tsup-dts-rollup';
export { defineNodeViewEffect } from './_tsup-dts-rollup';
export { NodeViewEffectOptions } from './_tsup-dts-rollup';
export { defineNodeViewFactory } from './_tsup-dts-rollup';
export { NodeViewFactoryOptions } from './_tsup-dts-rollup';
export { defineParagraph } from './_tsup-dts-rollup';

@@ -38,5 +82,5 @@ export { definePlugin } from './_tsup-dts-rollup';

export { defineText } from './_tsup-dts-rollup';
export { defineUpdateHandler } from './_tsup-dts-rollup';
export { Facet } from './_tsup-dts-rollup';
export { FacetOptions } from './_tsup-dts-rollup';
export { BaseNodeViewOptions } from './_tsup-dts-rollup';
export { CommandArgs } from './_tsup-dts-rollup';

@@ -55,5 +99,12 @@ export { Extension } from './_tsup-dts-rollup';

export { SimplifyUnion } from './_tsup-dts-rollup';
export { clsx } from './_tsup-dts-rollup';
export { defaultBlockAt } from './_tsup-dts-rollup';
export { _getId } from './_tsup-dts-rollup';
export { getMarkType } from './_tsup-dts-rollup';
export { getNodeType } from './_tsup-dts-rollup';
export { jsonFromElement } from './_tsup-dts-rollup';
export { isInCodeBlock } from './_tsup-dts-rollup';
export { elementFromJSON } from './_tsup-dts-rollup';
export { elementFromNode } from './_tsup-dts-rollup';
export { htmlFromJSON } from './_tsup-dts-rollup';
export { htmlFromNode } from './_tsup-dts-rollup';
export { jsonFromHTML } from './_tsup-dts-rollup';

@@ -66,2 +117,6 @@ export { jsonFromNode } from './_tsup-dts-rollup';

export { stateFromJSON } from './_tsup-dts-rollup';
export { DOMDocumentOptions } from './_tsup-dts-rollup';
export { DOMParserOptions } from './_tsup-dts-rollup';
export { DOMSerializerOptions } from './_tsup-dts-rollup';
export { JSONParserOptions } from './_tsup-dts-rollup';
export { isAllSelection } from './_tsup-dts-rollup';

@@ -72,1 +127,3 @@ export { isMark } from './_tsup-dts-rollup';

export { isTextSelection } from './_tsup-dts-rollup';
export { withSkipCodeBlock } from './_tsup-dts-rollup';
export { OBJECT_REPLACEMENT_CHARACTER } from './_tsup-dts-rollup';

@@ -11,2 +11,16 @@ // src/commands/add-mark.ts

};
var EditorNotFoundError = class extends ProseKitError {
constructor() {
super(
"Unable to find editor. Pass it as an argument or call this function inside a ProseKit component."
);
}
};
var DOMDocumentNotFoundError = class extends ProseKitError {
constructor() {
super(
"Unable to find browser Document. When not in the browser environment, you need to pass a DOM Document."
);
}
};

@@ -40,4 +54,57 @@ // src/utils/get-mark-type.ts

// src/commands/expand-mark.ts
import { TextSelection } from "@prosekit/pm/state";
function expandMark(options) {
return (state, dispatch) => {
const markType = getMarkType(state.schema, options.type);
const predicate = (mark) => mark.type === markType;
const from = expandMarkBefore(state.selection.$from, predicate);
const to = expandMarkAfter(state.selection.$to, predicate);
if (from === state.selection.from && to === state.selection.to) {
return false;
}
if (dispatch) {
dispatch(state.tr.setSelection(TextSelection.create(state.doc, from, to)));
}
return true;
};
}
function expandMarkBefore($pos, predicate) {
const { parent } = $pos;
if (!$pos.marks().some(predicate)) {
return $pos.pos;
}
const index = $pos.index();
let boundaryIndex = index;
for (let i = index; i >= 0; i--) {
const node = parent.child(i);
if (node.marks.some(predicate)) {
boundaryIndex = i;
} else {
break;
}
}
return $pos.posAtIndex(boundaryIndex);
}
function expandMarkAfter($pos, predicate) {
const { parent } = $pos;
if (!$pos.marks().some(predicate)) {
return $pos.pos;
}
const index = Math.max(0, $pos.indexAfter() - 1);
const childCount = parent.childCount;
let boundaryIndex = index;
for (let i = index; i < childCount; i++) {
const node = parent.child(i);
if (node.marks.some(predicate)) {
boundaryIndex = i;
} else {
break;
}
}
return $pos.posAtIndex(boundaryIndex) + parent.child(boundaryIndex).nodeSize;
}
// src/commands/insert-node.ts
import { TextSelection } from "@prosekit/pm/state";
import "@prosekit/pm/state";
import { insertPoint } from "@prosekit/pm/transform";

@@ -58,2 +125,11 @@

// src/utils/set-selection-around.ts
import { TextSelection as TextSelection2 } from "@prosekit/pm/state";
function setSelectionAround(tr, pos) {
const docSize = tr.doc.content.size;
const $pos = tr.doc.resolve(pos > docSize ? docSize : pos < 0 ? 0 : pos);
const selection = TextSelection2.between($pos, $pos);
tr.setSelection(selection);
}
// src/commands/insert-node.ts

@@ -76,3 +152,3 @@ function insertNode(options) {

const tr = state.tr.insert(insertPos, node);
tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos)));
setSelectionAround(tr, insertPos + node.nodeSize);
dispatch(tr);

@@ -106,3 +182,3 @@ }

// src/utils/get-custom-selection.ts
import { TextSelection as TextSelection2 } from "@prosekit/pm/state";
import { TextSelection as TextSelection3 } from "@prosekit/pm/state";
function getCustomSelection(state, from, to) {

@@ -113,3 +189,3 @@ const pos = from != null ? from : to;

const $to = state.doc.resolve(to != null ? to : pos);
return TextSelection2.between($from, $to);
return TextSelection3.between($from, $to);
}

@@ -161,2 +237,25 @@ return state.selection;

// src/commands/set-node-attrs.ts
function setNodeAttrs(options) {
return (state, dispatch) => {
var _a;
const nodeType = getNodeType(state.schema, options.type);
const pos = (_a = options.pos) != null ? _a : state.selection.$from.before();
const node = state.doc.nodeAt(pos);
if (!node || node.type !== nodeType) {
return false;
}
if (dispatch) {
const { tr } = state;
for (const [key, value] of Object.entries(options.attrs)) {
if (value !== void 0) {
tr.setNodeAttribute(pos, key, value);
}
}
dispatch(tr);
}
return true;
};
}
// src/commands/toggle-mark.ts

@@ -351,7 +450,7 @@ import { toggleMark as baseToggleMark } from "@prosekit/pm/commands";

// src/utils/parse.ts
import { DOMParser } from "@prosekit/pm/model";
import { DOMParser, DOMSerializer } from "@prosekit/pm/model";
import { EditorState } from "@prosekit/pm/state";
// src/utils/get-dom-api.ts
function getGlobalBrowserDocument() {
function findGlobalBrowserDocument() {
if (typeof document !== "undefined") {

@@ -364,3 +463,3 @@ return document;

}
function getGlobalBrowserWindow() {
function findGlobalBrowserWindow() {
if (typeof window !== "undefined") {

@@ -373,46 +472,82 @@ return window;

}
function getBrowserWindow() {
var _a;
const win = getGlobalBrowserWindow();
if (win) {
function findBrowserDocument(options) {
var _a, _b, _c;
return (_c = (_a = options == null ? void 0 : options.document) != null ? _a : findGlobalBrowserDocument()) != null ? _c : (_b = findGlobalBrowserWindow()) == null ? void 0 : _b.document;
}
function findBrowserWindow(options) {
var _a, _b, _c, _d;
return (_d = (_b = (_a = options == null ? void 0 : options.document) == null ? void 0 : _a.defaultView) != null ? _b : findGlobalBrowserWindow()) != null ? _d : (_c = findBrowserDocument(options)) == null ? void 0 : _c.defaultView;
}
function getBrowserDocument(options) {
const doc = findBrowserDocument(options);
if (doc)
return doc;
throw new DOMDocumentNotFoundError();
}
function getBrowserWindow(options) {
const win = findBrowserWindow(options);
if (win)
return win;
}
return (_a = getGlobalBrowserDocument()) == null ? void 0 : _a.defaultView;
throw new DOMDocumentNotFoundError();
}
// src/utils/parse.ts
function nodeFromElement(element, schema) {
return DOMParser.fromSchema(schema).parse(element);
function jsonFromState(state) {
return state.toJSON();
}
function jsonFromElement(element, schema) {
return jsonFromNode(nodeFromElement(element, schema));
function stateFromJSON(json, options) {
return EditorState.fromJSON({ schema: options.schema }, json);
}
function nodeFromHTML(html, schema) {
return nodeFromElement(elementFromHTML(html), schema);
function jsonFromNode(node) {
return node.toJSON();
}
function jsonFromHTML(html, schema) {
return jsonFromElement(elementFromHTML(html), schema);
function nodeFromJSON(json, options) {
return options.schema.nodeFromJSON(json);
}
function elementFromHTML(html) {
const win = getBrowserWindow();
if (!win) {
throw new ProseKitError(
"No Browser Document Found. You can only parse a HTML string in the browser environment."
function nodeFromElement(element, options) {
const Parser = options.DOMParser || DOMParser;
const schema = options.schema;
return Parser.fromSchema(schema).parse(element);
}
function elementFromNode(node, options) {
const Serializer = (options == null ? void 0 : options.DOMSerializer) || DOMSerializer;
const document2 = getBrowserDocument(options);
const schema = node.type.schema;
const serializer = Serializer.fromSchema(schema);
if (schema.topNodeType !== node.type) {
return serializer.serializeNode(node, { document: document2 });
} else {
return serializer.serializeFragment(
node.content,
{ document: document2 },
document2.createElement("div")
);
}
}
function elementFromHTML(html, options) {
const win = getBrowserWindow(options);
const parser = new win.DOMParser();
return parser.parseFromString(`<body>${html}</body>`, "text/html").body;
return parser.parseFromString(`<body><div>${html}</div></body>`, "text/html").body.firstElementChild;
}
function jsonFromState(state) {
return state.toJSON();
function htmlFromElement(element) {
return element.outerHTML;
}
function jsonFromNode(node) {
return node.toJSON();
function nodeFromHTML(html, options) {
return nodeFromElement(elementFromHTML(html, options), options);
}
function nodeFromJSON(json, schema) {
return schema.nodeFromJSON(json);
function htmlFromNode(node, options) {
return elementFromNode(node, options).outerHTML;
}
function stateFromJSON(json, schema) {
return EditorState.fromJSON({ schema }, json);
function jsonFromElement(element, options) {
return jsonFromNode(nodeFromElement(element, options));
}
function elementFromJSON(json, options) {
return elementFromNode(nodeFromJSON(json, options), options);
}
function jsonFromHTML(html, options) {
return jsonFromElement(elementFromHTML(html, options), options);
}
function htmlFromJSON(json, options) {
return htmlFromElement(elementFromJSON(json, options));
}

@@ -435,5 +570,5 @@ // src/extensions/default-state.ts

if (typeof defaultHTML === "string") {
defaultDoc = jsonFromHTML(defaultHTML, schema);
defaultDoc = jsonFromHTML(defaultHTML, { schema });
} else {
defaultDoc = jsonFromElement(defaultHTML, schema);
defaultDoc = jsonFromElement(defaultHTML, { schema });
}

@@ -668,2 +803,18 @@ }

// src/editor/builder.ts
import "@prosekit/pm/model";
// src/utils/is-mark-active.ts
function isMarkActive(state, type, attrs) {
const { from, $from, to, empty } = state.selection;
const markType = getMarkType(state.schema, type);
if (empty) {
const mark = attrs ? markType.create(attrs) : markType;
return !!mark.isInSet(state.storedMarks || $from.marks());
} else {
const markOrType = attrs ? markType.create(attrs) : markType;
return state.doc.rangeHasMark(from, to, markOrType);
}
}
// src/utils/type-assertion.ts

@@ -674,3 +825,3 @@ import { Mark, ProseMirrorNode } from "@prosekit/pm/model";

NodeSelection,
TextSelection as TextSelection3
TextSelection as TextSelection4
} from "@prosekit/pm/state";

@@ -684,3 +835,3 @@ function isProseMirrorNode(node) {

function isTextSelection(sel) {
return sel instanceof TextSelection3;
return sel instanceof TextSelection4;
}

@@ -694,26 +845,3 @@ function isNodeSelection(sel) {

// src/utils/is-mark-active.ts
function isMarkActive(state, type, attrs) {
const markType = getMarkType(state.schema, type);
const mark = attrs ? markType.create(attrs) : markType;
const { from, $from, to, empty } = state.selection;
if (empty) {
return hasMark(state.storedMarks || $from.marks(), mark);
} else {
return state.doc.rangeHasMark(from, to, mark);
}
}
function hasMark(marks, mark) {
if (marks.length === 0) {
return false;
}
if (isMark(mark)) {
return marks.some((m) => m.eq(mark));
} else {
return marks.some((m) => m.type === mark);
}
}
// src/editor/builder.ts
import "@prosekit/pm/model";
function createNodeBuilder(getState, type) {

@@ -832,8 +960,5 @@ const builder = (...args) => buildNode(type, args);

// src/editor/editor.ts
function createEditor({
extension,
defaultDoc,
defaultHTML,
defaultSelection
}) {
function createEditor(options) {
const { defaultDoc, defaultHTML, defaultSelection } = options;
let extension = options.extension;
if (defaultDoc || defaultHTML) {

@@ -866,2 +991,3 @@ extension = union([

const state = EditorState2.create(stateConfig);
this.cachedState = state;
if (commandInput) {

@@ -874,6 +1000,3 @@ for (const [name, commandCreator] of Object.entries(commandInput)) {

this.schema = this.directEditorProps.state.schema;
const getState = () => {
var _a;
return (_a = this.view) == null ? void 0 : _a.state;
};
const getState = () => this.getState();
this.nodeBuilders = Object.fromEntries(

@@ -892,2 +1015,8 @@ Object.values(this.schema.nodes).map((type) => [

}
getState() {
if (this.view) {
this.cachedState = this.view.state;
}
return this.cachedState;
}
updateExtension(extension, mode) {

@@ -997,8 +1126,17 @@ var _a;

}
/**
* Whether the editor is mounted.
*/
get mounted() {
return !!this.instance.view;
}
/**
* The editor view.
*/
get view() {
return this.instance.assertView;
}
/**
* The editor schema.
*/
get schema() {

@@ -1010,2 +1148,13 @@ return this.instance.schema;

}
/**
* Whether the editor is focused.
*/
get focused() {
var _a, _b;
return (_b = (_a = this.instance.view) == null ? void 0 : _a.hasFocus()) != null ? _b : false;
}
/**
* Mount the editor to the given HTML element.
* Pass `null` or `undefined` to unmount the editor.
*/
mount(place) {

@@ -1018,2 +1167,5 @@ if (!place) {

}
/**
* Unmount the editor. This is equivalent to `mount(null)`.
*/
unmount() {

@@ -1024,2 +1176,16 @@ if (this.mounted) {

}
/**
* Focus the editor.
*/
focus() {
var _a;
(_a = this.instance.view) == null ? void 0 : _a.focus();
}
/**
* Blur the editor.
*/
blur() {
var _a;
(_a = this.instance.view) == null ? void 0 : _a.dom.blur();
}
use(extension) {

@@ -1039,14 +1205,5 @@ if (!this.mounted) {

}
/**
* @deprecated
*/
isNodeActive(nodeType, attrs) {
return isNodeActive(this.view.state, nodeType, attrs);
get state() {
return this.instance.getState();
}
/**
* @deprecated
*/
isMarkActive(markType, attrs) {
return isMarkActive(this.view.state, markType, attrs);
}
get nodes() {

@@ -1121,2 +1278,3 @@ return this.instance.nodeBuilders;

setBlockType,
setNodeAttrs,
selectAll,

@@ -1128,15 +1286,33 @@ addMark,

// src/utils/is-element.ts
var hasElement = typeof Element !== "undefined";
function isElement(value) {
return hasElement && value instanceof Element;
}
// src/utils/is-not-null.ts
function isNotNull(value) {
return value != null;
}
// src/extensions/node-spec.ts
function defineNodeSpec(options) {
return nodeSpecFacet.extension([options]);
const payload = [options, void 0];
return nodeSpecFacet.extension([payload]);
}
function defineNodeAttr(options) {
const payload = [void 0, options];
return nodeSpecFacet.extension([payload]);
}
var nodeSpecFacet = Facet.define({
convert: (options) => {
convert: (payloads) => {
const nodes = {};
let topNodeName = void 0;
for (const { name, topNode, ...spec } of options) {
const specPayloads = payloads.map((input) => input[0]).filter(isNotNull);
const attrPayloads = payloads.map((input) => input[1]).filter(isNotNull);
for (const { name, topNode, ...spec } of specPayloads) {
if (nodes[name]) {
throw new ProseKitError(`Node type ${name} has already been defined`);
}
if (topNodeName && !topNode) {
if (topNode) {
topNodeName = name;

@@ -1146,5 +1322,71 @@ }

}
for (const {
type,
attr,
default: defaultValue,
toDOM,
parseDOM
} of attrPayloads) {
const spec = nodes[type];
if (!spec) {
throw new ProseKitError(
`Node type ${type} must be defined before defining attributes`
);
}
if (!spec.attrs) {
spec.attrs = {};
}
spec.attrs[attr] = { default: defaultValue };
if (toDOM && spec.toDOM) {
const existingToDom = spec.toDOM;
spec.toDOM = (node) => {
const dom = existingToDom(node);
if (!dom) {
return dom;
}
const attrDOM = toDOM(node.attrs[attr]);
if (!attrDOM) {
return dom;
}
const [key, value] = attrDOM;
if (!key) {
return dom;
}
if (Array.isArray(dom)) {
if (typeof dom[1] === "object") {
return [dom[0], { ...dom[1], [key]: value }, ...dom.slice(2)];
} else {
return [dom[0], { [key]: value }, ...dom.slice(1)];
}
} else if (isElement(dom)) {
dom.setAttribute(key, value);
} else if (typeof dom === "object" && "dom" in dom && isElement(dom.dom)) {
dom.dom.setAttribute(key, value);
}
return dom;
};
}
if (parseDOM && spec.parseDOM) {
for (const rule of spec.parseDOM) {
const existingGetAttrs = rule.getAttrs;
const existingAttrs = rule.attrs;
rule.getAttrs = (dom) => {
var _a;
const attrs = (_a = existingGetAttrs == null ? void 0 : existingGetAttrs(dom)) != null ? _a : existingAttrs;
if (attrs === false || !dom || !isElement(dom)) {
return attrs != null ? attrs : null;
}
const value = parseDOM(dom);
return {
...attrs,
[attr]: value
};
};
}
}
}
return { nodes, topNode: topNodeName };
},
next: schemaFacet
next: schemaFacet,
singleton: true
});

@@ -1161,13 +1403,5 @@

// src/extensions/history.ts
import { history, redo, undo } from "@prosekit/pm/history";
// src/extensions/events/plugin-view.ts
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
// src/utils/env.ts
var isMac = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : false;
// src/extensions/keymap.ts
import { baseKeymap, chainCommands } from "@prosekit/pm/commands";
import { keydownHandler } from "@prosekit/pm/keymap";
import { Plugin as Plugin3, PluginKey } from "@prosekit/pm/state";
// src/extensions/plugin.ts

@@ -1189,7 +1423,18 @@ import "@prosekit/pm/model";

var pluginFacet = Facet.define({
convert: (callbacks) => {
return ({ schema }) => {
const plugins = callbacks.flatMap((func) => func({ schema }));
converter: () => {
let inputs = [];
const output = ({ schema }) => {
const plugins = inputs.flatMap((func) => func({ schema }));
return { plugins };
};
return {
create: (payloads) => {
inputs = payloads;
return output;
},
update: (payloads) => {
inputs = payloads;
return output;
}
};
},

@@ -1199,8 +1444,289 @@ next: stateFacet

// src/extensions/events/plugin-view.ts
function defineMountHandler(handler) {
return pluginViewFacet.extension([["mount", handler]]);
}
function defineUpdateHandler(handler) {
return pluginViewFacet.extension([["update", handler]]);
}
function defineUnmountHandler(handler) {
return pluginViewFacet.extension([["unmount", handler]]);
}
var pluginViewFacet = Facet.define({
converter: () => {
let mountHandlers = [];
let updateHandlers = [];
let unmountHandlers = [];
const plugin = new ProseMirrorPlugin({
key: pluginKey,
view: (view) => {
mountHandlers.forEach((fn) => fn(view));
return {
update: (view2, prevState) => {
updateHandlers.forEach((fn) => fn(view2, prevState));
},
destroy: () => {
unmountHandlers.forEach((fn) => fn());
}
};
}
});
const pluginFunc = () => [plugin];
const register = (input) => {
mountHandlers = [];
updateHandlers = [];
unmountHandlers = [];
for (const args of input) {
switch (args[0]) {
case "mount":
mountHandlers.push(args[1]);
break;
case "update":
updateHandlers.push(args[1]);
break;
case "unmount":
unmountHandlers.push(args[1]);
break;
}
}
};
return {
create: (input) => {
register(input);
return pluginFunc;
},
update: (input) => {
register(input);
return null;
}
};
},
next: pluginFacet,
singleton: true
});
var pluginKey = new PluginKey("prosekit-plugin-view-handler");
// src/extensions/events/doc-change.ts
function defineDocChangeHandler(handler) {
return defineUpdateHandler((view, prevState) => {
if (!view.state.doc.eq(prevState.doc)) {
handler(view, prevState);
}
});
}
// src/extensions/events/dom-event.ts
import { PluginKey as PluginKey2, ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
// 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 [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
import { history, redo, undo } from "@prosekit/pm/history";
// src/utils/env.ts
var isMac = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : false;
// src/extensions/keymap.ts
import { baseKeymap, chainCommands } from "@prosekit/pm/commands";
import { keydownHandler } from "@prosekit/pm/keymap";
import { Plugin as Plugin3, PluginKey as PluginKey4 } from "@prosekit/pm/state";
function defineKeymap(keymap) {
return keymapFacet.extension([keymap]);
}
function defineBaseKeymap() {
return defineKeymap(baseKeymap);
function defineBaseKeymap(options) {
var _a;
const priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 3 /* low */;
return withPriority(defineKeymap(baseKeymap), priority);
}

@@ -1249,3 +1775,3 @@ var keymapFacet = Facet.define({

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

@@ -1271,36 +1797,17 @@ // src/extensions/history.ts

// src/extensions/input-rules.ts
import { InputRule, inputRules } from "@prosekit/pm/inputrules";
import "@prosekit/pm/model";
import "@prosekit/pm/state";
function defineInputRule(rule) {
if (rule instanceof InputRule) {
return inputRuleFacet.extension([() => rule]);
}
if (Array.isArray(rule) && rule.every((r) => r instanceof InputRule)) {
return inputRuleFacet.extension([() => rule]);
}
if (typeof rule === "function") {
return inputRuleFacet.extension([rule]);
}
throw new TypeError("Invalid input rule");
}
var inputRuleFacet = Facet.define({
convert: (inputs) => {
return (context) => {
const rules = inputs.flatMap((callback) => callback(context));
return [inputRules({ rules })];
};
},
next: pluginFacet
});
// src/extensions/mark-spec.ts
function defineMarkSpec(options) {
return markSpecFacet.extension([options]);
const payload = [options, void 0];
return markSpecFacet.extension([payload]);
}
function defineMarkAttr(options) {
const payload = [void 0, options];
return markSpecFacet.extension([payload]);
}
var markSpecFacet = Facet.define({
convert: (options) => {
convert: (payloads) => {
const marks = {};
for (const { name, ...spec } of options) {
const specPayloads = payloads.map((input) => input[0]).filter(isNotNull);
const attrPayloads = payloads.map((input) => input[1]).filter(isNotNull);
for (const { name, ...spec } of specPayloads) {
if (marks[name]) {

@@ -1311,9 +1818,75 @@ throw new ProseKitError(`Mark type ${name} has already been defined`);

}
for (const {
type,
attr,
default: defaultValue,
toDOM,
parseDOM
} of attrPayloads) {
const spec = marks[type];
if (!spec) {
throw new ProseKitError(
`Mark type ${type} must be defined before defining attributes`
);
}
if (!spec.attrs) {
spec.attrs = {};
}
spec.attrs[attr] = { default: defaultValue };
if (toDOM && spec.toDOM) {
const existingToDom = spec.toDOM;
spec.toDOM = (mark, inline) => {
const dom = existingToDom(mark, inline);
if (!dom) {
return dom;
}
const attrDOM = toDOM(mark.attrs[attr]);
if (!attrDOM) {
return dom;
}
const [key, value] = attrDOM;
if (!key) {
return dom;
}
if (Array.isArray(dom)) {
if (typeof dom[1] === "object") {
return [dom[0], { ...dom[1], [key]: value }, ...dom.slice(2)];
} else {
return [dom[0], { [key]: value }, ...dom.slice(1)];
}
} else if (isElement(dom)) {
dom.setAttribute(key, value);
} else if (typeof dom === "object" && "dom" in dom && isElement(dom.dom)) {
dom.dom.setAttribute(key, value);
}
return dom;
};
}
if (parseDOM && spec.parseDOM) {
for (const rule of spec.parseDOM) {
const existingGetAttrs = rule.getAttrs;
const existingAttrs = rule.attrs;
rule.getAttrs = (dom) => {
var _a;
const attrs = (_a = existingGetAttrs == null ? void 0 : existingGetAttrs(dom)) != null ? _a : existingAttrs;
if (attrs === false || !dom || !isElement(dom)) {
return attrs != null ? attrs : null;
}
const value = parseDOM(dom);
return {
...attrs,
[attr]: value
};
};
}
}
}
return { marks, nodes: {} };
},
next: schemaFacet
next: schemaFacet,
singleton: true
});
// src/extensions/node-view.ts
import { ProseMirrorPlugin } from "@prosekit/pm/state";
import { ProseMirrorPlugin as ProseMirrorPlugin4 } from "@prosekit/pm/state";
import "@prosekit/pm/view";

@@ -1331,3 +1904,3 @@ function defineNodeView(options) {

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

@@ -1338,8 +1911,8 @@ next: pluginFacet

// src/extensions/node-view-effect.ts
import { ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
import { ProseMirrorPlugin as ProseMirrorPlugin5 } from "@prosekit/pm/state";
import "@prosekit/pm/view";
function defineNodeViewEffect(options) {
return nodeViewEffectFacet.extension([options]);
function defineNodeViewFactory(options) {
return nodeViewFactoryFacet.extension([options]);
}
var nodeViewEffectFacet = Facet.define({
var nodeViewFactoryFacet = Facet.define({
convert: (inputs) => {

@@ -1367,3 +1940,3 @@ const nodeViews = {};

}
return () => Object.keys(nodeViews).length > 0 ? [new ProseMirrorPlugin2({ props: { nodeViews } })] : [];
return () => [new ProseMirrorPlugin5({ props: { nodeViews } })];
},

@@ -1397,71 +1970,99 @@ next: pluginFacet

// src/extensions/update-handler.ts
import { PluginKey as PluginKey2, ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
// src/utils/clsx.ts
import clsxLite from "clsx/lite";
var clsx = clsxLite;
// src/utils/is-not-null.ts
function isNotNull(value) {
return value != null;
// src/utils/default-block-at.ts
function defaultBlockAt(match) {
for (let i = 0; i < match.edgeCount; i++) {
const { type } = match.edge(i);
if (type.isTextblock && !type.hasRequiredAttrs())
return type;
}
return null;
}
// src/extensions/update-handler.ts
function defineUpdateHandler(handler) {
return updateHandlerFacet.extension([handler]);
// src/utils/get-id.ts
var id = 0;
function getId() {
id = (id + 1) % Number.MAX_SAFE_INTEGER;
return `id:${id}`;
}
var updateHandlerFacet = Facet.define({
converter: () => {
let updateHandlers = [];
const plugin = new ProseMirrorPlugin3({
key: pluginKey,
view: (view) => {
updateHandlers.forEach((fn) => fn({ view }));
return {
update: (view2, prevState) => {
updateHandlers.forEach((fn) => fn({ view: view2, prevState }));
}
};
}
});
const pluginFunc = () => [plugin];
return {
create: (handlers) => {
updateHandlers = handlers.filter(isNotNull);
return pluginFunc;
},
update: (handlers) => {
updateHandlers = handlers.filter(isNotNull);
return null;
}
};
},
next: pluginFacet,
singleton: true
});
var pluginKey = new PluginKey2("prosekit-event-handler");
// src/utils/is-in-code-block.ts
function isCodeBlockType(type) {
return type.spec.code && type.isBlock;
}
function isInCodeBlock(selection) {
return isCodeBlockType(selection.$from.parent.type) || isCodeBlockType(selection.$to.parent.type);
}
// src/utils/unicode.ts
var OBJECT_REPLACEMENT_CHARACTER = "\uFFFC";
// src/utils/with-skip-code-block.ts
function withSkipCodeBlock(command) {
return (state, dispatch, view) => {
if (isInCodeBlock(state.selection)) {
return false;
}
return command(state, dispatch, view);
};
}
export {
Editor,
EditorNotFoundError,
Facet,
OBJECT_REPLACEMENT_CHARACTER,
Priority,
ProseKitError,
getId as _getId,
addMark,
clsx,
createEditor,
defaultBlockAt,
defineBaseCommands,
defineBaseKeymap,
defineClickHandler,
defineClickOnHandler,
defineCommands,
defineDOMEventHandler,
defineDefaultState,
defineDoc,
defineDocChangeHandler,
defineDoubleClickHandler,
defineDoubleClickOnHandler,
defineDropHandler,
defineFocusChangeHandler,
defineHistory,
defineInputRule,
defineKeyDownHandler,
defineKeyPressHandler,
defineKeymap,
defineMarkAttr,
defineMarkSpec,
defineMountHandler,
defineNodeAttr,
defineNodeSpec,
defineNodeView,
defineNodeViewEffect,
defineNodeViewFactory,
defineParagraph,
definePasteHandler,
definePlugin,
defineScrollToSelectionHandler,
defineText,
defineTextInputHandler,
defineTripleClickHandler,
defineTripleClickOnHandler,
defineUnmountHandler,
defineUpdateHandler,
elementFromJSON,
elementFromNode,
expandMark,
getMarkType,
getNodeType,
htmlFromJSON,
htmlFromNode,
insertNode,
isAllSelection,
isInCodeBlock,
isMark,

@@ -1471,6 +2072,6 @@ isNodeSelection,

isTextSelection,
jsonFromElement,
jsonFromHTML,
jsonFromNode,
jsonFromState,
keymapFacet,
nodeFromElement,

@@ -1482,2 +2083,3 @@ nodeFromHTML,

setBlockType,
setNodeAttrs,
stateFromJSON,

@@ -1487,3 +2089,4 @@ toggleMark,

union,
withPriority
withPriority,
withSkipCodeBlock
};

16

package.json
{
"name": "@prosekit/core",
"type": "module",
"version": "0.0.0-next-20231120040948",
"version": "0.0.0-next-20240421132240",
"private": false,

@@ -32,5 +32,2 @@ "author": {

"default": "./dist/prosekit-core.js"
},
"./style.css": {
"default": "./dist/style.css"
}

@@ -42,11 +39,12 @@ },

"dependencies": {
"@prosekit/pm": "0.0.0-next-20231120040948",
"@prosekit/pm": "0.0.0-next-20240421132240",
"clsx": "^2.1.0",
"orderedmap": "^2.1.1",
"type-fest": "^4.8.0"
"type-fest": "^4.15.0"
},
"devDependencies": {
"@prosekit/dev": "*",
"tsup": "^8.0.0",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vitest": "^1.5.0"
},

@@ -53,0 +51,0 @@ "scripts": {

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