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

@prosekit/extensions

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prosekit/extensions - npm Package Compare versions

Comparing version 0.0.0-next-20231120040948 to 0.0.0-next-20240421132240

dist/chunk-ASTUC4KT.js

604

dist/_tsup-dts-rollup.d.ts

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

import { Attrs } from '@prosekit/pm/model';
import { BundledLanguage } from 'shiki';
import { BundledLanguageInfo } from 'shiki';
import { bundledLanguagesInfo } from 'shiki';
import { BundledTheme } from 'shiki';
import { BundledThemeInfo } from 'shiki';
import { bundledThemesInfo } from 'shiki';
import { Command } from '@prosekit/pm/state';
import { CommandArgs } from '@prosekit/core';

@@ -6,13 +14,18 @@ import { DedentListOptions } from 'prosemirror-flat-list';

import { ExtensionTyping } from '@prosekit/core';
import type { HLJSApi } from 'highlight.js';
import { getHighlighter } from 'shiki/bundle/full';
import { IndentListOptions } from 'prosemirror-flat-list';
import { InputRule } from '@prosekit/pm/inputrules';
import { ListAttributes } from 'prosemirror-flat-list';
import { ListDOMSerializer } from 'prosemirror-flat-list';
import { NodeRange } from 'prosemirror-model';
import { NodeType } from '@prosekit/pm/model';
import { Options } from 'tsup';
import { Parser } from 'prosemirror-highlight';
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
import { PluginKey } from '@prosekit/pm/state';
import { ProseMirrorNode } from '@prosekit/pm/model';
import type { SpecialLanguage } from 'shiki';
import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
import { Transaction } from '@prosekit/pm/state';
import { UnwrapListOptions } from 'prosemirror-flat-list';
import { UserProjectConfigExport } from 'vitest/dist/config.js';

@@ -38,2 +51,31 @@ declare class AutocompleteRule {

export { BundledLanguage as ShikiBundledLanguage }
export { BundledLanguage as ShikiBundledLanguage_alias_1 }
export { BundledLanguageInfo as ShikiBundledLanguageInfo }
export { BundledLanguageInfo as ShikiBundledLanguageInfo_alias_1 }
export { bundledLanguagesInfo as shikiBundledLanguagesInfo }
export { bundledLanguagesInfo as shikiBundledLanguagesInfo_alias_1 }
export { BundledTheme as ShikiBundledTheme }
export { BundledTheme as ShikiBundledTheme_alias_1 }
export { BundledThemeInfo as ShikiBundledThemeInfo }
export { BundledThemeInfo as ShikiBundledThemeInfo_alias_1 }
export { bundledThemesInfo as shikiBundledThemesInfo }
export { bundledThemesInfo as shikiBundledThemesInfo_alias_1 }
export declare interface CellAttrs {
colspan: number;
rowspan: number;
colwidth: number[] | null;
}
/**
* The attributes for the `codeBlock` node.
*
* @public
*/
declare interface CodeBlockAttrs {

@@ -45,2 +87,26 @@ language?: string;

/**
* @public
*/
export declare interface CodeBlockShikiOptions {
/**
* Theme registation
*
* @default ['one-dark-pro']
*/
themes?: BundledTheme[];
/**
* Language registation
*
* @default ['text']
*/
langs?: (BundledLanguage | SpecialLanguage)[];
/**
* Alias of languages
*
* @example { 'my-lang': 'javascript' }
*/
langAlias?: Record<string, BundledLanguage>;
}
export declare function createAutocompletePlugin({ getRules, }: {

@@ -50,7 +116,14 @@ getRules: () => AutocompleteRule[];

export declare function createPredictionPlugin(options: SuggestionOptions): Plugin_2;
/**
* @internal
*/
export declare function createLazyParser(highlighterOptions: HighlighterOptions): Parser;
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
export declare const default_alias_1: UserProjectConfigExport;
export declare const default_alias_1: {
test: {
environment: "jsdom";
};
};

@@ -61,6 +134,2 @@ export declare function defaultCanMatch({ state }: {

export declare function defaultIsValid({ state }: {
state: EditorState;
}): boolean;
export declare function defineAutocomplete(rule: AutocompleteRule): Extension;

@@ -75,2 +144,8 @@

/**
* Wraps the text block in a blockquote when `>` is typed at the start of a new
* line followed by a space.
*/
export declare function defineBlockquoteInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export declare function defineBlockquoteSpec(): Extension< {

@@ -113,28 +188,96 @@ NODES: "blockquote";

/**
* Adds `codeBlock` nodes to the editor. This includes the following extensions:
*
* - {@link defineCodeBlockSpec}
* - {@link defineCodeBlockInputRule}
* - {@link defineCodeBlockEnterRule}
* - {@link defineCodeBlockKeymap}
* - {@link defineCodeBlockCommands}.
*
* @public
*/
export declare function defineCodeBlock(options?: {
hljs?: HLJSApi;
}): Extension< {
declare function defineCodeBlock(): Extension< {
NODES: "codeBlock";
COMMAND_ARGS: {
setCodeBlockLanguage: [language: string];
setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
};
}>;
export { defineCodeBlock }
export { defineCodeBlock as defineCodeBlock_alias_1 }
export declare function defineCodeBlockCommands(): Extension< {
/**
* Adds commands for working with `codeBlock` nodes.
*
* @public
*/
declare function defineCodeBlockCommands(): Extension< {
COMMAND_ARGS: {
setCodeBlockLanguage: [language: string];
setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
};
}>;
export { defineCodeBlockCommands }
export { defineCodeBlockCommands as defineCodeBlockCommands_alias_1 }
export declare function defineCodeBlockHighlight(options: {
hljs?: HLJSApi;
}): Extension<ExtensionTyping<string, string, CommandArgs>>;
/**
* Adds enter rules for `codeBlock` nodes.
*
* @public
*/
declare function defineCodeBlockEnterRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineCodeBlockEnterRule }
export { defineCodeBlockEnterRule as defineCodeBlockEnterRule_alias_1 }
export declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
/**
* Adds syntax highlighting to code blocks. This function requires a `Parser`
* instance from the `prosemirror-highlight` package. See the
* [documentation](https://github.com/ocavue/prosemirror-highlight) for more
* information.
*
* @public
*/
declare function defineCodeBlockHighlight({ parser, }: {
parser: HighlightParser;
}): Extension;
export { defineCodeBlockHighlight }
export { defineCodeBlockHighlight as defineCodeBlockHighlight_alias_1 }
export declare function defineCodeBlockSpec(): Extension< {
/**
* Adds input rules for `codeBlock` nodes.
*
* @public
*/
declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineCodeBlockInputRule }
export { defineCodeBlockInputRule as defineCodeBlockInputRule_alias_1 }
/**
* Defines the keymap for code blocks.
*/
export declare function defineCodeBlockKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
/**
* Adds syntax highlighting to code blocks using the [shiki](https://github.com/shikijs/shiki) package.
*
* @public
*/
declare function defineCodeBlockShiki({ themes, langs, langAlias, }?: CodeBlockShikiOptions): Extension;
export { defineCodeBlockShiki }
export { defineCodeBlockShiki as defineCodeBlockShiki_alias_1 }
/**
* Defines the `codeBlock` node spec.
*
* @public
*/
declare function defineCodeBlockSpec(): Extension< {
NODES: "codeBlock";
}>;
export { defineCodeBlockSpec }
export { defineCodeBlockSpec as defineCodeBlockSpec_alias_1 }

@@ -155,4 +298,22 @@ export declare function defineCodeCommands(): Extension< {

/**
* Show up a decoration at the drop position when something is dragged over the editor.
*
* See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.
*
* @public
*/
export declare function defineDropCursor(options?: DropCursorOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
/**
* Defines an enter rule. An enter rule applies when the text directly in front of
* the cursor matches `regex` and user presses Enter. The `regex` should end
* with `$`.
*
* @public
*/
export declare function defineEnterRule({ regex, handler, stop, }: EnterRuleOptions): Extension;
/**
* @public
*/
export declare function defineHeading(): Extension< {

@@ -175,2 +336,6 @@ NODES: "heading";

/**
* Converts the text block to a heading when `#` is typed at the start of a new
* line followed by a space.
*/
export declare function defineHeadingInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;

@@ -205,4 +370,13 @@

/**
* Defines an input rule extension.
*
* @param rule - The ProseMirror input rule to add.
*
* @public
*/
export declare function defineInputRule(rule: InputRule): Extension;
/**
* @public
*/
export declare function defineItalic(): Extension< {

@@ -236,3 +410,5 @@ MARKS: "italic";

addLink: [attrs: LinkAttrs];
removeLink: [];
toggleLink: [attrs: LinkAttrs];
expandLink: [];
};

@@ -244,6 +420,12 @@ }>;

addLink: [attrs: LinkAttrs];
removeLink: [];
toggleLink: [attrs: LinkAttrs];
expandLink: [];
};
}>;
export declare function defineLinkEnterRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export declare function defineLinkInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export declare function defineLinkSpec(): Extension< {

@@ -256,32 +438,32 @@ MARKS: "link";

*/
export declare function defineList(): Extension< {
NODES: "list";
COMMAND_ARGS: {
dedentList: [options?: DedentListOptions | undefined];
indentList: [options?: IndentListOptions | undefined];
moveList: [direction: "up" | "down"];
splitList: [];
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
toggleList: [attrs: ListAttributes];
unwrapList: [options?: UnwrapListOptions | undefined];
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
insertList: [attrs?: ListAttributes | undefined];
};
export declare function defineList(): Extension<{
NODES: "list";
COMMAND_ARGS: {
dedentList: [options?: DedentListOptions | undefined];
indentList: [options?: IndentListOptions | undefined];
moveList: [direction: "up" | "down"];
splitList: [];
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
toggleList: [attrs: ListAttributes];
unwrapList: [options?: UnwrapListOptions | undefined];
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
insertList: [attrs?: ListAttributes | undefined];
};
}>;
export declare function defineListCommands(): Extension< {
COMMAND_ARGS: {
dedentList: [options?: DedentListOptions | undefined];
indentList: [options?: IndentListOptions | undefined];
moveList: [direction: "up" | "down"];
splitList: [];
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
toggleList: [attrs: ListAttributes];
unwrapList: [options?: UnwrapListOptions | undefined];
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
insertList: [attrs?: ListAttributes | undefined];
};
export declare function defineListCommands(): Extension<{
COMMAND_ARGS: {
dedentList: [options?: DedentListOptions | undefined];
indentList: [options?: IndentListOptions | undefined];
moveList: [direction: "up" | "down"];
splitList: [];
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
toggleList: [attrs: ListAttributes];
unwrapList: [options?: UnwrapListOptions | undefined];
wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
insertList: [attrs?: ListAttributes | undefined];
};
}>;
export declare function defineListInputRules(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export declare function defineListInputRules(): Extension;

@@ -297,4 +479,4 @@ /**

export declare function defineListSpec(): Extension< {
NODES: "list";
export declare function defineListSpec(): Extension<{
NODES: "list";
}>;

@@ -307,4 +489,13 @@

NODES: "mention";
COMMAND_ARGS: {
insertMention: [attrs: MentionAttrs];
};
}>;
export declare function defineMentionCommands(): Extension< {
COMMAND_ARGS: {
insertMention: [attrs: MentionAttrs];
};
}>;
/**

@@ -324,2 +515,7 @@ * @public

/**
* Make the editor read-only.
*/
export declare function defineReadonly(): Extension<ExtensionTyping<string, string, CommandArgs>>;
/**
* @public

@@ -346,7 +542,102 @@ */

export declare function defineSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
/**
* @public
*/
export declare function defineTable(): Extension< {
NODES: "table" | "tableRow" | "tableCell" | "tableHeaderCell";
COMMAND_ARGS: {
insertTable: [{
row: number;
col: number;
header: boolean;
}];
exitTable: [];
};
}>;
declare function defineTableCellSpec(): Extension< {
NODES: "tableCell";
}>;
export { defineTableCellSpec }
export { defineTableCellSpec as defineTableCellSpec_alias_1 }
/**
* Adds commands for working with `table` nodes.
*
* @public
*/
declare function defineTableCommands(): Extension< {
COMMAND_ARGS: {
insertTable: [{
row: number;
col: number;
header: boolean;
}];
exitTable: [];
};
}>;
export { defineTableCommands }
export { defineTableCommands as defineTableCommands_alias_1 }
declare function defineTableHeaderCellSpec(): Extension< {
NODES: "tableHeaderCell";
}>;
export { defineTableHeaderCellSpec }
export { defineTableHeaderCellSpec as defineTableHeaderCellSpec_alias_1 }
/**
* @public
*/
declare function defineTablePlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
export { defineTablePlugins }
export { defineTablePlugins as defineTablePlugins_alias_1 }
declare function defineTableRowSpec(): Extension< {
NODES: "tableRow";
}>;
export { defineTableRowSpec }
export { defineTableRowSpec as defineTableRowSpec_alias_1 }
declare function defineTableSpec(): Extension< {
NODES: "table";
}>;
export { defineTableSpec }
export { defineTableSpec as defineTableSpec_alias_1 }
/**
* Defines an enter rule that replaces the matched text with a block node.
*
* See also {@link defineEnterRule}.
*
* @public
*/
export declare function defineTextBlockEnterRule({ regex, type, attrs, stop, }: TextBlockEnterRuleOptions): Extension;
/**
* Defines an input rule that changes the type of a textblock when the matched
* text is typed into it.
*
* See also [textblockTypeInputRule](https://prosemirror.net/docs/ref/#inputrules.textblockTypeInputRule)
*
* @public
*/
export declare function defineTextBlockInputRule({ regex, type, attrs, }: {
/**
* The regular expression to match against. You'll usually want to start it
* with `^` to that it is only matched at the start of a textblock.
*/
regex: RegExp;
/**
* The node type to replace the matched text with.
*/
type: string | NodeType;
/**
* Attributes to set on the node.
*/
attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
}): Extension;
/**
* @public
*/
export declare function defineUnderline(): Extension< {

@@ -371,2 +662,120 @@ MARKS: "underline";

/**
* Shows a virtual selection when the editor is not focused. When the editor is
* not focused, the selected inline content will be wrapped in a `<span>`
* element with the class `prosekit-virtual-selection`.
*
* This is useful when you want to move the focus to an element outside the
* editor, but still want to show the selection.
*
* @public
*/
export declare function defineVirtualSelection(): Extension;
/**
* Defines an input rule for automatically wrapping a textblock when a given
* string is typed.
*
* See also [wrappingInputRule](https://prosemirror.net/docs/ref/#inputrules.wrappingInputRule)
*
* @public
*/
export declare function defineWrappingInputRule({ regex, type, attrs, join, }: {
/**
* The regular expression to match against. You'll usually want to start it
* with `^` to that it is only matched at the start of a textblock.
*/
regex: RegExp;
/**
* The type of node to wrap in.
*/
type: string | NodeType;
/**
* Attributes to set on the node.
*/
attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
/**
* By default, if there's a node with the same type above the newly wrapped
* node, the rule will try to
* [join](https://prosemirror.net/docs/ref/#transform.Transform.join) those
* two nodes. You can pass a join predicate, which takes a regular expression
* match and the node before the wrapped node, and can return a boolean to
* indicate whether a join should happen.
*/
join?: (match: RegExpMatchArray, node: ProseMirrorNode) => boolean;
}): Extension;
export declare interface DropCursorOptions {
/**
* The color of the cursor. Use `false` to apply no color and rely only on class.
*
* @default 'black'
*/
color?: string | false;
/**
* The precise width of the cursor in pixels.
*
* @default 1
*/
width?: number;
/**
* A CSS class name to add to the cursor element.
*/
class?: string;
}
/**
* @public
*/
export declare type EnterRuleHandler = (options: {
/**
* The current editor state.
*/
state: EditorState;
/**
* The start position of the matched text.
*/
from: number;
/**
* The end position of the matched text.
*/
to: number;
/**
* The matched result from the regular expression.
*/
match: RegExpExecArray;
}) => Transaction | null;
/**
* Options for {@link defineEnterRule}.
*
* @public
*/
export declare type EnterRuleOptions = {
/**
* The regular expression to match against. It should end with `$`.
*/
regex: RegExp;
/**
* A function to be called when an enter rule is triggered.
*/
handler: EnterRuleHandler;
/**
* Whether to stop further handlers from being called if this rule is triggered.
*
* @default false
*/
stop?: boolean;
};
/**
* When the selection is in a table node, create a default block after the table
* table, and move the cursor there.
*
* @public
*/
export declare const exitTable: Command;
export { getHighlighter }
export declare function getPluginState(state: EditorState): PredictionPluginState | undefined;

@@ -380,2 +789,17 @@

declare type HighlighterOptions = {
themes: BundledTheme[];
langs: (BundledLanguage | SpecialLanguage)[];
langAlias?: Record<string, BundledLanguage>;
};
/**
* @public
*
* An alias for the `Parser` type from the `prosemirror-highlight` package.
*/
declare type HighlightParser = Parser;
export { HighlightParser }
export { HighlightParser as HighlightParser_alias_1 }
export declare interface ImageAttrs {

@@ -386,4 +810,20 @@ src?: string | null;

/**
* Insert a table node with the given number of rows and columns, and optionally
* a header row.
*
* @public
*/
export declare function insertTable({ row, col, header, }: {
row: number;
col: number;
header: boolean;
}): Command;
export declare const LINK_RE: RegExp;
export declare const LINK_SPACE_RE: RegExp;
/**
* @public
*/
export declare interface LinkAttrs {

@@ -393,2 +833,4 @@ href: string;

export { ListDOMSerializer }
declare type MatchHandler = (options: {

@@ -401,18 +843,6 @@ state: EditorState;

deleteMatch: () => void;
}) => Transaction | null | void;
}) => void;
export { MatchHandler }
export { MatchHandler as MatchHandler_alias_1 }
/**
* @returns Return a Transaction object if you want to append a transaction to current state (using )
*/
declare type MatchHandler_2 = (options: {
rule: PredictionRule;
match: RegExpMatchArray;
matchAfter: RegExpMatchArray | null;
state: EditorState;
dismiss: VoidFunction;
deleteMatch: VoidFunction;
}) => void;
export declare interface MentionAttrs {

@@ -424,4 +854,2 @@ id: string;

export declare const OBJECT_REPLACEMENT = "\uFFFC";
export declare interface PlaceholderOptions {

@@ -434,4 +862,4 @@ /**

* By default, the placeholder text will be shown whenever the current text
* cursor is in an empty node. If you only want to show the placeholder when
* the whole doc is empty, you can set this option to 'doc'.
* cursor is in an empty text node. If you only want to show the placeholder
* when the whole doc is empty, you can set this option to 'doc'.
*

@@ -456,29 +884,31 @@ * @default 'block'

declare interface PredictionRule {
match: RegExp;
matchAfter?: RegExp;
}
export { PredictionRule }
export { PredictionRule as PredictionRule_alias_1 }
export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState): Transaction;
declare interface SuggestionOptions {
rules: PredictionRule[];
onMatch: MatchHandler_2;
onDeactivate: VoidFunction;
/**
* Options for {@link defineTextBlockEnterRule}.
*
* @public
*/
export declare type TextBlockEnterRuleOptions = {
/**
* You can pass this function if you want to skip the matching in some cases.
* By default, the plugin will only run the matching if the current selection
* is empty, and the selection is not inside a
* [code](https://prosemirror.net/docs/ref/#model.NodeSpec.code) node nor
* inside a mark with the name as `code`.
* The regular expression to match against. It should end with `$`.
*/
isValid?: (options: {
state: EditorState;
}) => boolean;
}
export { SuggestionOptions }
export { SuggestionOptions as SuggestionOptions_alias_1 }
regex: RegExp;
/**
* The node type to replace the matched text with.
*/
type: string | NodeType;
/**
* Attributes to set on the node. If a function is provided, it will be called
* with the matched result from the regular expression.
*/
attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
/**
* Whether to stop further handlers from being called if this rule is triggered.
*
* @default true
*/
stop?: boolean;
};
export { }

12

dist/prosekit-extensions-autocomplete.js

@@ -8,2 +8,3 @@ // src/autocomplete/index.ts

// src/autocomplete/plugin.ts
import { OBJECT_REPLACEMENT_CHARACTER } from "@prosekit/core";
import { Plugin } from "@prosekit/pm/state";

@@ -26,3 +27,2 @@ import { Decoration, DecorationSet } from "@prosekit/pm/view";

}
var OBJECT_REPLACEMENT = "\uFFFC";
function getPluginState(state) {

@@ -80,6 +80,10 @@ return pluginKey.getState(state);

to,
OBJECT_REPLACEMENT
OBJECT_REPLACEMENT_CHARACTER
);
const deleteMatch = () => {
if (view.state.doc.textBetween(from, to, OBJECT_REPLACEMENT) === textContent) {
if (view.state.doc.textBetween(
from,
to,
OBJECT_REPLACEMENT_CHARACTER
) === textContent) {
view.dispatch(view.state.tr.delete(from, to));

@@ -131,3 +135,3 @@ }

null,
OBJECT_REPLACEMENT
OBJECT_REPLACEMENT_CHARACTER
);

@@ -134,0 +138,0 @@ for (const rule of rules) {

export { defineBlockquoteSpec } from './_tsup-dts-rollup';
export { defineBlockquoteInputRule } from './_tsup-dts-rollup';
export { defineBlockquote } from './_tsup-dts-rollup';

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

import {
defineWrappingInputRule
} from "./chunk-DYFRBXUX.js";
// src/blockquote/index.ts

@@ -15,8 +19,15 @@ import { defineNodeSpec, union } from "@prosekit/core";

}
function defineBlockquoteInputRule() {
return defineWrappingInputRule({
regex: /^>\s/,
type: "blockquote"
});
}
function defineBlockquote() {
return union([defineBlockquoteSpec()]);
return union([defineBlockquoteSpec(), defineBlockquoteInputRule()]);
}
export {
defineBlockquote,
defineBlockquoteInputRule,
defineBlockquoteSpec
};

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

export { defineCodeBlockSpec } from './_tsup-dts-rollup';
export { defineCodeBlockInputRule } from './_tsup-dts-rollup';
export { defineCodeBlockCommands } from './_tsup-dts-rollup';
export { defineCodeBlock } from './_tsup-dts-rollup';
export { defineCodeBlock_alias_1 as defineCodeBlock } from './_tsup-dts-rollup';
export { defineCodeBlockCommands_alias_1 as defineCodeBlockCommands } from './_tsup-dts-rollup';
export { defineCodeBlockHighlight_alias_1 as defineCodeBlockHighlight } from './_tsup-dts-rollup';
export { HighlightParser_alias_1 as HighlightParser } from './_tsup-dts-rollup';
export { defineCodeBlockEnterRule_alias_1 as defineCodeBlockEnterRule } from './_tsup-dts-rollup';
export { defineCodeBlockInputRule_alias_1 as defineCodeBlockInputRule } from './_tsup-dts-rollup';
export { defineCodeBlockShiki_alias_1 as defineCodeBlockShiki } from './_tsup-dts-rollup';
export { defineCodeBlockSpec_alias_1 as defineCodeBlockSpec } from './_tsup-dts-rollup';
export { CodeBlockAttrs_alias_1 as CodeBlockAttrs } from './_tsup-dts-rollup';
export { shikiBundledLanguagesInfo } from './_tsup-dts-rollup';
export { shikiBundledThemesInfo } from './_tsup-dts-rollup';
export { ShikiBundledLanguage } from './_tsup-dts-rollup';
export { ShikiBundledLanguageInfo } from './_tsup-dts-rollup';
export { ShikiBundledTheme } from './_tsup-dts-rollup';
export { ShikiBundledThemeInfo } from './_tsup-dts-rollup';

@@ -1,53 +0,94 @@

// src/code-block/index.ts
import {
defineTextBlockInputRule
} from "./chunk-DYFRBXUX.js";
import {
defineTextBlockEnterRule
} from "./chunk-ASTUC4KT.js";
// src/code-block/code-block.ts
import { union } from "@prosekit/core";
// src/code-block/code-block-commands.ts
import {
defineCommands,
defineInputRule,
defineNodeSpec,
union,
getNodeType
insertNode,
setBlockType,
setNodeAttrs,
toggleNode
} from "@prosekit/core";
import { textblockTypeInputRule } from "@prosekit/pm/inputrules";
// src/code-block/code-block-highlight.ts
import { definePlugin } from "@prosekit/core";
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
import { DecorationSet } from "@prosekit/pm/view";
import { getHighlightDecorations } from "prosemirror-highlightjs";
function defineCodeBlockHighlight(options) {
const hljs = options.hljs;
const plugin = new ProseMirrorPlugin({
key,
state: {
init(_config, state) {
const decorations = hljs ? getHighlightDecorations(
state.doc,
hljs,
blockTypes,
languageExtractor
) : [];
return DecorationSet.create(state.doc, decorations);
},
apply(tr, set) {
if (!tr.docChanged) {
return set.map(tr.mapping, tr.doc);
}
const decorations = hljs ? getHighlightDecorations(tr.doc, hljs, blockTypes, languageExtractor) : [];
return DecorationSet.create(tr.doc, decorations);
}
function defineCodeBlockCommands() {
return defineCommands({
setCodeBlock: (attrs) => {
return setBlockType({ type: "codeBlock", attrs });
},
props: {
decorations(state) {
return key.getState(state);
}
insertCodeBlock: (attrs) => {
return insertNode({ type: "codeBlock", attrs });
},
toggleCodeBlock: (attrs) => {
return toggleNode({ type: "codeBlock", attrs });
},
setCodeBlockAttrs: (attrs) => {
return setNodeAttrs({ type: "codeBlock", attrs });
}
});
return definePlugin(plugin);
}
var key = new PluginKey("prosekit-code-block-highlight");
var blockTypes = ["codeBlock"];
function languageExtractor(node) {
return node.attrs.language || "javascript";
// src/code-block/code-block-input-rule.ts
function defineCodeBlockInputRule() {
return defineTextBlockInputRule({
regex: /^```(\S*)\s$/,
type: "codeBlock",
attrs: getAttrs
});
}
function defineCodeBlockEnterRule() {
return defineTextBlockEnterRule({
regex: /^```(\S*)$/,
type: "codeBlock",
attrs: getAttrs
});
}
function getAttrs(match) {
return { language: match[1] || "" };
}
// src/code-block/index.ts
// src/code-block/code-block-keymap.ts
import { defaultBlockAt, defineKeymap } from "@prosekit/core";
import { TextSelection } from "@prosekit/pm/state";
function defineCodeBlockKeymap() {
return defineKeymap({
Enter: existCodeBlock
});
}
var existCodeBlock = (state, dispatch) => {
if (!state.selection.empty) {
return false;
}
const { $head } = state.selection;
const parent = $head.parent;
if (parent.isTextblock && parent.type.spec.code && $head.parentOffset === parent.content.size && parent.textContent.endsWith("\n\n")) {
const grandParent = $head.node(-1);
const insertIndex = $head.indexAfter(-1);
const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex));
if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) {
return false;
}
if (dispatch) {
const { tr } = state;
tr.delete($head.pos - 2, $head.pos);
const pos = tr.selection.$head.after();
const node = type.createAndFill();
if (node) {
tr.replaceWith(pos, pos, node);
tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1));
dispatch(tr.scrollIntoView());
}
}
return true;
}
return false;
};
// src/code-block/code-block-spec.ts
import { defineNodeSpec } from "@prosekit/core";
function defineCodeBlockSpec() {

@@ -73,47 +114,102 @@ return defineNodeSpec({

const attrs = node.attrs;
return [
"pre",
{ "data-language": attrs.language, class: "hljs" },
["code", 0]
];
return ["pre", { "data-language": attrs.language }, ["code", 0]];
}
});
}
function defineCodeBlockInputRule() {
return defineInputRule(({ schema }) => {
const nodeType = getNodeType(schema, "codeBlock");
const getAttrs = (match) => {
return { language: match[1] || "" };
};
return textblockTypeInputRule(/^```(\S*)\s$/, nodeType, getAttrs);
});
}
function defineCodeBlockCommands() {
return defineCommands({
setCodeBlockLanguage: (language) => (state, dispatch) => {
const pos = state.selection.$from.before();
const codeBlock = state.doc.nodeAt(pos);
if (!codeBlock || codeBlock.type.name !== "codeBlock") {
return false;
}
const { tr } = state;
tr.setNodeMarkup(pos, void 0, { language });
dispatch == null ? void 0 : dispatch(tr);
return true;
}
});
}
function defineCodeBlock(options) {
// src/code-block/code-block.ts
function defineCodeBlock() {
return union([
defineCodeBlockSpec(),
defineCodeBlockInputRule(),
defineCodeBlockHighlight({ hljs: options == null ? void 0 : options.hljs }),
defineCodeBlockEnterRule(),
defineCodeBlockKeymap(),
defineCodeBlockCommands()
]);
}
// src/code-block/code-block-highlight.ts
import { definePlugin } from "@prosekit/core";
import { createHighlightPlugin } from "prosemirror-highlight";
function defineCodeBlockHighlight({
parser
}) {
return definePlugin(
createHighlightPlugin({ parser, nodeTypes: ["codeBlock"] })
);
}
// src/code-block/shiki-parser.ts
import { createParser } from "prosemirror-highlight/shiki";
function createHighlighterLoader() {
let highlighterPromise;
let highlighter;
const loadLangs = /* @__PURE__ */ new Set();
return function highlighterLoader(lang, options) {
if (!highlighterPromise) {
highlighterPromise = import("./shiki-import-25BJYIO2.js").then(({ getHighlighter }) => {
return getHighlighter(options);
}).then((h) => {
highlighter = h;
});
return { promise: highlighterPromise };
}
if (!highlighter) {
return { promise: highlighterPromise };
}
if (!loadLangs.has(lang)) {
const promise = highlighter.loadLanguage(lang).then(() => {
loadLangs.add(lang);
}).catch((error) => {
console.warn(`Failed to load language '${lang}'`, error);
});
return { promise };
}
return { highlighter };
};
}
function createLazyParser(highlighterOptions) {
let parser;
const highlighterLoader = createHighlighterLoader();
return function lazyParser(options) {
const language = options.language || "";
const { highlighter, promise } = highlighterLoader(
language,
highlighterOptions
);
if (!highlighter) {
return promise || [];
}
if (!parser) {
parser = createParser(highlighter);
}
return parser(options);
};
}
// src/code-block/code-block-shiki.ts
function defineCodeBlockShiki({
themes = ["one-dark-pro"],
langs = ["text"],
langAlias = {}
} = {}) {
const parser = createLazyParser({ themes, langs, langAlias });
return defineCodeBlockHighlight({ parser });
}
// src/code-block/shiki-bundle.ts
import {
bundledLanguagesInfo,
bundledThemesInfo
} from "shiki";
export {
defineCodeBlock,
defineCodeBlockCommands,
defineCodeBlockEnterRule,
defineCodeBlockHighlight,
defineCodeBlockInputRule,
defineCodeBlockSpec
defineCodeBlockShiki,
defineCodeBlockSpec,
bundledLanguagesInfo as shikiBundledLanguagesInfo,
bundledThemesInfo as shikiBundledThemesInfo
};

@@ -0,14 +1,16 @@

import {
defineTextBlockInputRule
} from "./chunk-DYFRBXUX.js";
// src/heading/index.ts
import {
defineCommands,
defineInputRule,
defineKeymap,
defineNodeSpec,
getNodeType,
insertNode,
setBlockType,
toggleNode,
union
union,
withSkipCodeBlock
} from "@prosekit/core";
import { textblockTypeInputRule } from "@prosekit/pm/inputrules";
function defineHeadingSpec() {

@@ -36,18 +38,22 @@ return defineNodeSpec({

return defineKeymap({
"mod-1": toggleNode({ type: "heading", attrs: { level: 1 } }),
"mod-2": toggleNode({ type: "heading", attrs: { level: 2 } }),
"mod-3": toggleNode({ type: "heading", attrs: { level: 3 } }),
"mod-4": toggleNode({ type: "heading", attrs: { level: 4 } }),
"mod-5": toggleNode({ type: "heading", attrs: { level: 5 } }),
"mod-6": toggleNode({ type: "heading", attrs: { level: 6 } })
"mod-1": toggleHeadingKeybinding(1),
"mod-2": toggleHeadingKeybinding(2),
"mod-3": toggleHeadingKeybinding(3),
"mod-4": toggleHeadingKeybinding(4),
"mod-5": toggleHeadingKeybinding(5),
"mod-6": toggleHeadingKeybinding(6)
});
}
function toggleHeadingKeybinding(level) {
return withSkipCodeBlock(toggleNode({ type: "heading", attrs: { level } }));
}
function defineHeadingInputRule() {
return defineInputRule(({ schema }) => {
const nodeSpec = getNodeType(schema, "heading");
return textblockTypeInputRule(/^(#{1,6})\s/, nodeSpec, (match) => {
return defineTextBlockInputRule({
regex: /^(#{1,6})\s$/,
type: "heading",
attrs: (match) => {
var _a, _b;
const level = (_b = (_a = match[1]) == null ? void 0 : _a.length) != null ? _b : 1;
return { level };
});
}
});

@@ -54,0 +60,0 @@ }

@@ -16,2 +16,3 @@ // src/image/index.ts

defining: true,
draggable: true,
parseDOM: [

@@ -18,0 +19,0 @@ {

export { defineLinkSpec } from './_tsup-dts-rollup';
export { defineLinkCommands } from './_tsup-dts-rollup';
export { defineLinkInputRule } from './_tsup-dts-rollup';
export { defineLinkEnterRule } from './_tsup-dts-rollup';
export { defineLink } from './_tsup-dts-rollup';
export { LinkAttrs } from './_tsup-dts-rollup';

@@ -0,12 +1,37 @@

import {
defineInputRule
} from "./chunk-DYFRBXUX.js";
import {
defineEnterRule
} from "./chunk-ASTUC4KT.js";
// src/link/index.ts
import {
addMark,
defineCommands,
addMark,
defineMarkSpec,
union,
toggleMark
expandMark,
removeMark,
toggleMark,
union
} from "@prosekit/core";
import { InputRule } from "@prosekit/pm/inputrules";
// src/link/link-regex.ts
var TLD_RE_PATTERN = "a(?:a(?:a|rp)|b(?:arth|b(?:ott|vie)?|c|le|ogado|udhabi)|c(?:ademy|c(?:enture|ountants?)|o|tor)?|d(?:s|ult)?|e(?:g|ro|tna)?|f(?:l|rica)?|g(?:akhan|ency)?|i(?:g|r(?:bus|force|tel))?|kdn|l(?:faromeo|i(?:baba|pay)|l(?:finanz|state|y)|s(?:ace|tom))?|m(?:azon|e(?:rican(?:express|family)|x)|fam|ica|sterdam)?|n(?:alytics|droid|quan|z)|ol?|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:a(?:b|mco)|chi|my|pa|te?)?|s(?:da|ia|sociates)?|t(?:hleta|torney)?|u(?:ction|di(?:ble|o)?|spost|t(?:hor|os?))?|vianca|ws?|xa?|z(?:ure)?)|b(?:a(?:by|idu|n(?:a(?:mex|narepublic)|d|k)|r(?:c(?:elona|lay(?:card|s))|efoot|gains)?|s(?:eball|ketball)|uhaus|yern)?|b(?:c|t|va)?|c[gn]|d|e(?:a(?:ts|uty)|er|ntley|rlin|st(?:buy)?|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ngo?|o|z)?|j|l(?:ack(?:friday)?|o(?:ckbuster|g|omberg)|ue)|m[sw]?|n(?:pparibas)?|o(?:ats|ehringer|fa|m|nd|o(?:k(?:ing)?)?|s(?:ch|t(?:ik|on))|t|utique|x)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:ild(?:ers)?|siness|y|zz)|v|w|y|zh?)|c(?:a(?:b|fe|l(?:l|vinklein)?|m(?:era|p)?|non|p(?:etown|ital(?:one)?)|r(?:avan|ds|e(?:ers?)?|s)?|s(?:a|e|h|ino)|t(?:ering|holic)?)?|b(?:a|n|re|s)|c|d|e(?:nter|o|rn)|f[ad]?|g|h(?:a(?:n(?:el|nel)|rity|se|t)|eap|intai|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:adel|ic?|y(?:eats)?))?|k|l(?:aims|eaning|i(?:ck|ni(?:c|que))|o(?:thing|ud)|ub(?:med)?)?|m|n|o(?:ach|des|ffee|l(?:lege|ogne)|m(?:cast|m(?:bank|unity)|p(?:a(?:ny|re)|uter)|sec)?|n(?:dos|s(?:truction|ulting)|t(?:act|ractors))|o(?:king(?:channel)?|l|p)|rsica|u(?:ntry|pons?|rses))?|pa|r(?:edit(?:card|union)?|icket|own|s|uises?)?|u(?:isinella)?|v|w|x|y(?:mru|ou)?|z)|d(?:a(?:bur|d|nce|t(?:a|e|ing|sun)|y)|clk|ds|e(?:al(?:er|s)?|gree|l(?:ivery|l|oitte|ta)|mocrat|nt(?:al|ist)|si(?:gn)?|v)?|hl|i(?:amonds|et|gital|rect(?:ory)?|s(?:co(?:unt|ver)|h)|y)|j|k|m|np|o(?:c(?:s|tor)|g|mains|t|wnload)?|rive|tv|u(?:bai|nlop|pont|rban)|v(?:ag|r)|z)|e(?:a(?:rth|t)|co?|d(?:eka|u(?:cation)?)|e|g|m(?:ail|erck)|n(?:ergy|gineer(?:ing)?|terprises)|pson|quipment|r(?:icsson|ni)?|s(?:q|tate)?|t(?:isalat)?|u(?:rovision|s)?|vents|x(?:change|p(?:ert|osed|ress)|traspace))|f(?:a(?:ge|i(?:l|rwinds|th)|mily|ns?|rm(?:ers)?|s(?:hion|t))|e(?:dex|edback|rr(?:ari|ero))|i(?:at|d(?:elity|o)|lm|na(?:l|nc(?:e|ial))|r(?:e(?:stone)?|mdale)|sh(?:ing)?|t(?:ness)?)?|j|k|l(?:i(?:ckr|ghts|r)|o(?:rist|wers)|y)|m|o(?:o(?:d(?:network)?|tball)?|r(?:d|ex|sale|um)|undation|x)?|r(?:e(?:e|senius)|l|o(?:gans|nt(?:door|ier)))?|tr|u(?:jitsu|nd?|rniture|tbol)|yi)|g(?:a(?:l(?:l(?:ery|o|up))?|mes?|p|rden|y)?|b(?:iz)?|dn?|e(?:a|nt(?:ing)?|orge)?|f|g(?:ee)?|h|i(?:fts?|v(?:es|ing))?|l(?:ass|e|ob(?:al|o))?|m(?:ail|bh|o|x)?|n|o(?:daddy|l(?:d(?:point)?|f)|o(?:dyear|g(?:le)?)?|p|t|v)|p|q|r(?:a(?:inger|phics|tis)|een|ipe|o(?:cery|up))?|s|t|u(?:ardian|cci|ge|i(?:de|tars)|ru)?|w|y)|h(?:a(?:ir|mburg|ngout|us)|bo|dfc(?:bank)?|e(?:alth(?:care)?|l(?:p|sinki)|r(?:e|mes))|gtv|i(?:phop|samitsu|tachi|v)|kt?|m|n|o(?:ckey|l(?:dings|iday)|me(?:depot|goods|s(?:ense)?)|nda|rse|s(?:pital|t(?:ing)?)|t(?:el(?:es|s)|mail)?|use|w)|r|sbc|t|u(?:ghes)?|y(?:att|undai))|i(?:bm|c(?:bc|e|u)|d|e(?:ee)?|fm|kano|l|m(?:amat|db|mo(?:bilien)?)?|n(?:c|dustries|f(?:initi|o)|g|k|s(?:titute|ur(?:ance|e))|t(?:ernational|uit)?|vestments)?|o|piranga|q|r(?:ish)?|s(?:maili|t(?:anbul)?)?|t(?:au|v)?)|j(?:a(?:guar|va)|cb|e(?:ep|tzt|welry)?|io|ll|mp?|nj|o(?:b(?:s|urg)|t|y)?|p(?:morgan|rs)?|u(?:egos|niper))|k(?:aufen|ddi|e(?:rry(?:hotels|logistics|properties))?|fh|g|h|i(?:a|ds|m|nd(?:er|le)|tchen|wi)?|m|n|o(?:eln|matsu|sher)|p(?:mg|n)?|r(?:d|ed)?|uokgroup|w|y(?:oto)?|z)|l(?:a(?:caixa|m(?:borghini|er)|n(?:c(?:aster|ia)|d(?:rover)?|xess)|salle|t(?:ino|robe)?|w(?:yer)?)?|b|c|ds|e(?:ase|clerc|frak|g(?:al|o)|xus)|gbt|i(?:dl|fe(?:insurance|style)?|ghting|ke|lly|m(?:ited|o)|n(?:coln|de|k)|psy|v(?:e|ing))?|k|l[cp]|o(?:ans?|c(?:ker|us)|l|ndon|tt[eo]|ve)|pl(?:financial)?|r|s|t(?:da?)?|u(?:ndbeck|x(?:e|ury))?|v|y)|m(?:a(?:cys|drid|i(?:f|son)|keup|n(?:agement|go)?|p|r(?:ket(?:ing|s)?|riott|shalls)|serati|ttel)?|ba|c(?:kinsey)?|d|e(?:d(?:ia)?|et|lbourne|m(?:e|orial)|nu?|rckmsd)?|g|h|i(?:ami|crosoft|l|n[it]|t(?:subishi)?)|k|l[bs]?|ma?|n|o(?:bi(?:le)?|da|e|i|m|n(?:ash|ey|ster)|r(?:mon|tgage)|scow|to(?:rcycles)?|v(?:ie)?)?|p|q|r|sd?|t[nr]?|u(?:s(?:eum|ic)|tual)?|v|w|x|y|z)|n(?:a(?:b|goya|me|tura|vy)?|ba|c|e(?:c|t(?:bank|flix|work)?|ustar|ws?|x(?:t(?:direct)?|us))?|fl?|go?|hk|i(?:co|k(?:e|on)|nja|ssa[ny])?|l|o(?:kia|rt(?:hwesternmutual|on)|w(?:ruz|tv)?)?|p|r[aw]?|tt|u|yc|z)|o(?:b(?:i|server)|ffice|kinawa|l(?:ayan(?:group)?|dnavy|lo)|m(?:ega)?|n(?:e|g|l(?:ine)?)|oo|pen|r(?:a(?:cle|nge)|g(?:anic)?|igins)|saka|t(?:suka|t)|vh)|p(?:a(?:ge|nasonic|r(?:is|s|t(?:ners|s|y))|ssagens|y)?|ccw|et?|f(?:izer)?|g|h(?:armacy|d|ilips|o(?:ne|to(?:graphy|s)?)|ysio)?|i(?:c(?:s|t(?:et|ures))|d|n[gk]?|oneer|zza)|k|l(?:a(?:ce|y(?:station)?)|u(?:mbing|s))?|m|nc?|o(?:hl|ker|litie|rn|st)|r(?:a(?:merica|xi)|ess|ime|o(?:d(?:uctions)?|f|gressive|mo|pert(?:ies|y)|tection)?|u(?:dential)?)?|s|t|ub|wc?|y)|q(?:a|pon|ue(?:bec|st))|r(?:a(?:cing|dio)|e(?:a(?:d|l(?:estate|t(?:or|y)))|cipes|d(?:stone|umbrella)?|hab|i(?:sen?|t)|liance|n(?:t(?:als)?)?|p(?:air|ort|ublican)|st(?:aurant)?|views?|xroth)?|i(?:c(?:h(?:ardli)?|oh)|l|o|p)|o(?:c(?:her|ks)|deo|gers|om)?|s(?:vp)?|u(?:gby|hr|n)?|we?|yukyu)|s(?:a(?:arland|fe(?:ty)?|kura|l(?:e|on)|ms(?:club|ung)|n(?:dvik(?:coromant)?|ofi)|p|rl|s|ve|xo)?|b[is]?|c(?:a|b|h(?:aeffler|midt|o(?:larships|ol)|ule|warz)|ience|ot)?|d|e(?:a(?:rch|t)|cur(?:e|ity)|ek|lect|ner|rvices|ven|w|xy?)?|fr|g|h(?:a(?:ngrila|rp|w)|ell|i(?:a|ksha)|o(?:es|p(?:ping)?|uji|w(?:time)?))?|i(?:lk|n(?:a|gles)|te)?|j|k(?:in?|y(?:pe)?)?|l(?:ing)?|m(?:art|ile)?|n(?:cf)?|o(?:c(?:cer|ial)|ft(?:bank|ware)|hu|l(?:ar|utions)|n[gy]|y)?|p(?:a(?:ce)?|o(?:rt|t))|rl?|s|t(?:a(?:da|ples|r|te(?:bank|farm))|c(?:group)?|o(?:ckholm|r(?:age|e))|ream|ud(?:io|y)|yle)?|u(?:cks|pp(?:l(?:ies|y)|ort)|r(?:f|gery)|zuki)?|v|w(?:atch|iss)|x|y(?:dney|stems)?|z)|t(?:a(?:b|ipei|lk|obao|rget|t(?:a(?:motors|r)|too)|xi?)|ci?|dk?|e(?:am|ch(?:nology)?|l|masek|nnis|va)|f|g|h(?:d|eat(?:er|re))?|i(?:aa|ckets|enda|ffany|ps|r(?:es|ol))|j(?:maxx|x)?|k(?:maxx)?|l|m(?:all)?|n|o(?:day|kyo|ols|p|ray|shiba|tal|urs|wn|y(?:ota|s))?|r(?:a(?:d(?:e|ing)|ining|vel(?:channel|ers(?:insurance)?)?)|ust|v)?|t|u(?:be|i|nes|shu)|vs?|w|z)|u(?:a|b(?:ank|s)|g|k|n(?:i(?:com|versity)|o)|ol|ps|s|y|z)|v(?:a(?:cations|n(?:a|guard))?|c|e(?:gas|ntures|r(?:isign|sicherung)|t)?|g|i(?:ajes|deo|g|king|llas|n|p|rgin|s(?:a|ion)|v[ao])?|laanderen|n|o(?:dka|l(?:kswagen|vo)|t(?:e|ing|o)|yage)|u(?:elos)?)|w(?:a(?:l(?:es|mart|ter)|ng(?:gou)?|tch(?:es)?)|e(?:ather(?:channel)?|b(?:cam|er|site)|d(?:ding)?|i(?:bo|r))|f|hoswho|i(?:en|ki|lliamhill|n(?:dows|e|ners)?)|me|o(?:lterskluwer|odside|r(?:ks?|ld)|w)|s|t[cf])|x(?:box|erox|finity|i(?:huan|n)|xx|yz)|y(?:a(?:chts|hoo|maxun|ndex)|e|o(?:dobashi|ga|kohama|u(?:tube)?)|t|un)|z(?:a(?:ppos|ra)?|ero|ip|m|one|uerich|w)";
var LINK_RE_BASE_PATTERN = (
// start of the link group
"((?:(?:(?:https?:)?\\/\\/)?(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:" + TLD_RE_PATTERN + "))(?::\\d{2,5})?(?:[/?#]\\S*)?)"
);
var LINK_STOP_PATTERN = "(?:\\.|\\,|\\;\\!)?";
var LINK_RE_PATTERN = LINK_RE_BASE_PATTERN + LINK_STOP_PATTERN + "$";
var LINK_SPACE_RE_PATTERN = LINK_RE_BASE_PATTERN + LINK_STOP_PATTERN + "\\s$";
var LINK_RE = new RegExp(LINK_RE_PATTERN, "gi");
var LINK_SPACE_RE = new RegExp(LINK_SPACE_RE_PATTERN, "gi");
// src/link/index.ts
function defineLinkSpec() {
return defineMarkSpec({
name: "link",
inclusive: false,
parseDOM: [

@@ -34,7 +59,38 @@ {

addLink: (attrs) => addMark({ type: "link", attrs }),
toggleLink: (attrs) => toggleMark({ type: "link", attrs })
removeLink: () => removeMark({ type: "link" }),
toggleLink: (attrs) => toggleMark({ type: "link", attrs }),
expandLink: () => expandMark({ type: "link" })
});
}
function defineLinkInputRule() {
return defineInputRule(
new InputRule(LINK_SPACE_RE, (state, match, from) => {
const href = match[1];
if (!href)
return null;
const mark = state.schema.marks.link.create({ href });
return state.tr.addMark(from, from + href.length, mark).insertText(" ");
})
);
}
function defineLinkEnterRule() {
return defineEnterRule({
regex: LINK_RE,
handler: ({ state, from, match }) => {
const href = match[1];
if (!href)
return null;
const mark = state.schema.marks.link.create({ href });
const tr = state.tr.addMark(from, from + href.length, mark);
return tr.docChanged ? tr : null;
}
});
}
function defineLink() {
return union([defineLinkSpec(), defineLinkCommands()]);
return union([
defineLinkSpec(),
defineLinkCommands(),
defineLinkInputRule(),
defineLinkEnterRule()
]);
}

@@ -44,3 +100,5 @@ export {

defineLinkCommands,
defineLinkEnterRule,
defineLinkInputRule,
defineLinkSpec
};

@@ -7,1 +7,2 @@ export { defineListSpec } from './_tsup-dts-rollup';

export { defineList } from './_tsup-dts-rollup';
export { ListDOMSerializer } from './_tsup-dts-rollup';

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

import {
defineInputRule
} from "./chunk-DYFRBXUX.js";
// src/list/index.ts

@@ -5,3 +9,2 @@ import {

defineCommands,
defineInputRule,
defineKeymap,

@@ -28,2 +31,3 @@ defineNodeSpec,

} from "prosemirror-flat-list";
import { ListDOMSerializer } from "prosemirror-flat-list";
function defineListSpec() {

@@ -39,3 +43,3 @@ return defineNodeSpec({ ...createListSpec(), name: "list" });

function defineListInputRules() {
return defineInputRule(() => listInputRules);
return union(listInputRules.map(defineInputRule));
}

@@ -68,2 +72,3 @@ function defineListCommands() {

export {
ListDOMSerializer,
defineList,

@@ -70,0 +75,0 @@ defineListCommands,

export { defineMentionSpec } from './_tsup-dts-rollup';
export { defineMentionCommands } from './_tsup-dts-rollup';
export { defineMention } from './_tsup-dts-rollup';
export { MentionAttrs } from './_tsup-dts-rollup';
// src/mention/index.ts
import { defineNodeSpec, union } from "@prosekit/core";
import {
defineCommands,
defineNodeSpec,
insertNode,
union
} from "@prosekit/core";
function defineMentionSpec() {

@@ -37,8 +42,16 @@ return defineNodeSpec({

}
function defineMentionCommands() {
return defineCommands({
insertMention: (attrs) => {
return insertNode({ type: "mention", attrs });
}
});
}
function defineMention() {
return union([defineMentionSpec()]);
return union([defineMentionSpec(), defineMentionCommands()]);
}
export {
defineMention,
defineMentionCommands,
defineMentionSpec
};
// src/placeholder/index.ts
import { definePlugin } from "@prosekit/core";
import { definePlugin, isInCodeBlock } from "@prosekit/core";
import "@prosekit/pm/model";

@@ -17,2 +17,5 @@ import { Plugin, PluginKey } from "@prosekit/pm/state";

}
if (isInCodeBlock(state.selection)) {
return null;
}
const placeholderText = options.placeholder;

@@ -19,0 +22,0 @@ const deco = createPlaceholderDecoration(state, placeholderText);

{
"name": "@prosekit/extensions",
"type": "module",
"version": "0.0.0-next-20231120040948",
"version": "0.0.0-next-20240421132240",
"private": false,

@@ -58,2 +58,12 @@ "author": {

},
"./drop-cursor": {
"types": "./dist/prosekit-extensions-drop-cursor.d.ts",
"import": "./dist/prosekit-extensions-drop-cursor.js",
"default": "./dist/prosekit-extensions-drop-cursor.js"
},
"./enter-rule": {
"types": "./dist/prosekit-extensions-enter-rule.d.ts",
"import": "./dist/prosekit-extensions-enter-rule.js",
"default": "./dist/prosekit-extensions-enter-rule.js"
},
"./heading": {

@@ -69,2 +79,7 @@ "types": "./dist/prosekit-extensions-heading.d.ts",

},
"./input-rule": {
"types": "./dist/prosekit-extensions-input-rule.d.ts",
"import": "./dist/prosekit-extensions-input-rule.js",
"default": "./dist/prosekit-extensions-input-rule.js"
},
"./italic": {

@@ -101,2 +116,7 @@ "types": "./dist/prosekit-extensions-italic.d.ts",

},
"./readonly": {
"types": "./dist/prosekit-extensions-readonly.d.ts",
"import": "./dist/prosekit-extensions-readonly.js",
"default": "./dist/prosekit-extensions-readonly.js"
},
"./strike": {

@@ -107,7 +127,10 @@ "types": "./dist/prosekit-extensions-strike.d.ts",

},
"./suggestion": {
"types": "./dist/prosekit-extensions-suggestion.d.ts",
"import": "./dist/prosekit-extensions-suggestion.js",
"default": "./dist/prosekit-extensions-suggestion.js"
"./table": {
"types": "./dist/prosekit-extensions-table.d.ts",
"import": "./dist/prosekit-extensions-table.js",
"default": "./dist/prosekit-extensions-table.js"
},
"./table/style.css": {
"default": "./dist/table/style.css"
},
"./underline": {

@@ -117,2 +140,10 @@ "types": "./dist/prosekit-extensions-underline.d.ts",

"default": "./dist/prosekit-extensions-underline.js"
},
"./virtual-selection": {
"types": "./dist/prosekit-extensions-virtual-selection.d.ts",
"import": "./dist/prosekit-extensions-virtual-selection.js",
"default": "./dist/prosekit-extensions-virtual-selection.js"
},
"./virtual-selection/style.css": {
"default": "./dist/virtual-selection/style.css"
}

@@ -124,13 +155,15 @@ },

"dependencies": {
"@prosekit/core": "0.0.0-next-20231120040948",
"@prosekit/pm": "0.0.0-next-20231120040948",
"highlight.js": "^11.9.0",
"prosemirror-flat-list": "^0.4.3",
"prosemirror-highlightjs": "^0.9.1"
"@prosekit/core": "0.0.0-next-20240421132240",
"@prosekit/pm": "0.0.0-next-20240421132240",
"prosemirror-dropcursor": "^1.8.1",
"prosemirror-flat-list": "^0.5.0",
"prosemirror-highlight": "^0.5.0",
"prosemirror-tables": "^1.3.7",
"shiki": "^1.3.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"
},

@@ -162,2 +195,8 @@ "scripts": {

],
"drop-cursor": [
"./dist/prosekit-extensions-drop-cursor.d.ts"
],
"enter-rule": [
"./dist/prosekit-extensions-enter-rule.d.ts"
],
"heading": [

@@ -169,2 +208,5 @@ "./dist/prosekit-extensions-heading.d.ts"

],
"input-rule": [
"./dist/prosekit-extensions-input-rule.d.ts"
],
"italic": [

@@ -185,10 +227,16 @@ "./dist/prosekit-extensions-italic.d.ts"

],
"readonly": [
"./dist/prosekit-extensions-readonly.d.ts"
],
"strike": [
"./dist/prosekit-extensions-strike.d.ts"
],
"suggestion": [
"./dist/prosekit-extensions-suggestion.d.ts"
"table": [
"./dist/prosekit-extensions-table.d.ts"
],
"underline": [
"./dist/prosekit-extensions-underline.d.ts"
],
"virtual-selection": [
"./dist/prosekit-extensions-virtual-selection.d.ts"
]

@@ -195,0 +243,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc