@prosekit/extensions
Advanced tools
Comparing version 0.0.0-next-20240724173606 to 0.0.0-next-20240901092634
import { Attrs } from '@prosekit/pm/model'; | ||
import { Attrs as Attrs_2 } from 'prosemirror-model'; | ||
import type { Awareness } from 'y-protocols/awareness'; | ||
import { BaseCommandsExtension } from '@prosekit/core'; | ||
import { BaseKeymapExtension } from '@prosekit/core'; | ||
import type { BundledHighlighterOptions } from 'shiki'; | ||
import { BundledLanguage } from 'shiki'; | ||
@@ -11,3 +12,6 @@ import { BundledLanguageInfo } from 'shiki'; | ||
import { bundledThemesInfo } from 'shiki'; | ||
import { CellSelection } from 'prosemirror-tables'; | ||
import { Command } from '@prosekit/pm/state'; | ||
import { CursorAwareness } from 'loro-prosemirror'; | ||
import type { DecorationAttrs } from '@prosekit/pm/view'; | ||
import { DedentListOptions } from 'prosemirror-flat-list'; | ||
@@ -21,4 +25,4 @@ import { config as default_alias_1 } from '@prosekit/dev/config-vitest'; | ||
import { ExtractNodeActions } from '@prosekit/core'; | ||
import { FindParentNodeResult } from '@prosekit/core'; | ||
import { GapCursor } from 'prosemirror-gapcursor'; | ||
import { getSingletonHighlighter } from 'shiki/bundle/full'; | ||
import type { Highlighter } from 'shiki'; | ||
@@ -29,4 +33,7 @@ import { HistoryExtension } from '@prosekit/core'; | ||
import type { IsEqual } from 'type-fest'; | ||
import type { ListAttributes } from 'prosemirror-flat-list'; | ||
import { ListAttributes } from 'prosemirror-flat-list'; | ||
import { ListDOMSerializer } from 'prosemirror-flat-list'; | ||
import type { LoroDocType } from 'loro-prosemirror'; | ||
import { LoroSyncPluginProps } from 'loro-prosemirror'; | ||
import { LoroUndoPluginProps } from 'loro-prosemirror'; | ||
import { MarkType } from '@prosekit/pm/model'; | ||
@@ -37,9 +44,12 @@ import { Node as Node_2 } from 'prosemirror-model'; | ||
import { NodeJSON } from '@prosekit/core'; | ||
import { NodeType } from '@prosekit/pm/model'; | ||
import type { NodeType } from '@prosekit/pm/model'; | ||
import { Options } from 'tsup'; | ||
import { Parser } from 'prosemirror-highlight'; | ||
import type { PeerID } from 'loro-crdt'; | ||
import { PlainExtension } from '@prosekit/core'; | ||
import { Plugin as Plugin_2 } from '@prosekit/pm/state'; | ||
import { PluginExtension } from '@prosekit/core'; | ||
import { PluginKey } from '@prosekit/pm/state'; | ||
import { ProseMirrorNode } from '@prosekit/pm/model'; | ||
import type { ResolvedPos } from '@prosekit/pm/model'; | ||
import type { Selection as Selection_2 } from '@prosekit/pm/state'; | ||
import { SimplifyDeeper } from '@prosekit/core'; | ||
@@ -56,2 +66,6 @@ import type { SpecialLanguage } from 'shiki'; | ||
import { WrapInListGetAttrs } from 'prosemirror-flat-list'; | ||
import type * as Y from 'yjs'; | ||
import { yCursorPlugin } from 'y-prosemirror'; | ||
import { ySyncPlugin } from 'y-prosemirror'; | ||
import { yUndoPlugin } from 'y-prosemirror'; | ||
@@ -186,5 +200,16 @@ export declare function applyMarkRules(rules: MarkRuleOptions[], transactions: readonly Transaction[], oldState: EditorState, newState: EditorState): Transaction | null; | ||
*/ | ||
export declare interface CodeBlockShikiOptions { | ||
declare type CodeBlockHighlightOptions = { | ||
parser: HighlightParser; | ||
}; | ||
export { CodeBlockHighlightOptions } | ||
export { CodeBlockHighlightOptions as CodeBlockHighlightOptions_alias_1 } | ||
/** | ||
* The options to configure the Shiki highlighter. | ||
* | ||
* @public | ||
*/ | ||
export declare interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs'> { | ||
/** | ||
* A list of shiki themes to pre-load. The first theme in the list will be | ||
* A list of Shiki themes to pre-load. The first theme in the list will be | ||
* used to render the code block. | ||
@@ -196,3 +221,3 @@ * | ||
/** | ||
* A list of shiki languages to pre-load. | ||
* A list of Shiki languages to pre-load. | ||
* | ||
@@ -202,8 +227,2 @@ * @default ['text'] | ||
langs?: (BundledLanguage | SpecialLanguage)[]; | ||
/** | ||
* Alias of languages | ||
* | ||
* @example { 'my-lang': 'javascript' } | ||
*/ | ||
langAlias?: Record<string, BundledLanguage>; | ||
} | ||
@@ -297,2 +316,6 @@ | ||
export declare function createOrGetHighlighter(options: HighlighterOptions): HighlighterResult; | ||
export declare function createOrGetHighlighter_alias_1(options: HighlighterOptions): HighlighterResult; | ||
export { DedentListOptions } | ||
@@ -319,9 +342,5 @@ | ||
*/ | ||
export declare function defineBlockquoteInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineBlockquoteInputRule(): PlainExtension; | ||
export declare function defineBlockquoteSpec(): Extension<{ | ||
Nodes: { | ||
blockquote: Attrs; | ||
}; | ||
}>; | ||
export declare function defineBlockquoteSpec(): BlockquoteSpecExtension; | ||
@@ -341,3 +360,3 @@ /** | ||
*/ | ||
export declare function defineBoldInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineBoldInputRule(): PlainExtension; | ||
@@ -347,3 +366,3 @@ /** | ||
*/ | ||
export declare function defineBoldKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineBoldKeymap(): PlainExtension; | ||
@@ -389,3 +408,3 @@ /** | ||
*/ | ||
declare function defineCodeBlockEnterRule(): Extension<ExtensionTyping<any, any, any>>; | ||
declare function defineCodeBlockEnterRule(): PlainExtension; | ||
export { defineCodeBlockEnterRule } | ||
@@ -400,7 +419,7 @@ export { defineCodeBlockEnterRule as defineCodeBlockEnterRule_alias_1 } | ||
* | ||
* @param options | ||
* | ||
* @public | ||
*/ | ||
declare function defineCodeBlockHighlight({ parser, }: { | ||
parser: HighlightParser; | ||
}): Extension; | ||
declare function defineCodeBlockHighlight({ parser, }: CodeBlockHighlightOptions): Extension; | ||
export { defineCodeBlockHighlight } | ||
@@ -414,3 +433,3 @@ export { defineCodeBlockHighlight as defineCodeBlockHighlight_alias_1 } | ||
*/ | ||
declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
declare function defineCodeBlockInputRule(): PlainExtension; | ||
export { defineCodeBlockInputRule } | ||
@@ -422,10 +441,12 @@ export { defineCodeBlockInputRule as defineCodeBlockInputRule_alias_1 } | ||
*/ | ||
export declare function defineCodeBlockKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineCodeBlockKeymap(): PlainExtension; | ||
/** | ||
* Adds syntax highlighting to code blocks using the [shiki](https://github.com/shikijs/shiki) package. | ||
* Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package. | ||
* | ||
* @param options - The options to configure the Shiki highlighter. | ||
* | ||
* @public | ||
*/ | ||
declare function defineCodeBlockShiki({ themes, langs, langAlias, }?: CodeBlockShikiOptions): Extension; | ||
declare function defineCodeBlockShiki({ themes, langs, ...rest }?: CodeBlockShikiOptions): Extension; | ||
export { defineCodeBlockShiki } | ||
@@ -451,3 +472,3 @@ export { defineCodeBlockShiki as defineCodeBlockShiki_alias_1 } | ||
*/ | ||
export declare function defineCodeInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineCodeInputRule(): PlainExtension; | ||
@@ -457,3 +478,3 @@ /** | ||
*/ | ||
export declare function defineCodeKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineCodeKeymap(): PlainExtension; | ||
@@ -468,3 +489,3 @@ /** | ||
*/ | ||
export declare function defineCommitRecorder(commitRecorder: CommitRecorder): PluginExtension; | ||
export declare function defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension; | ||
@@ -474,3 +495,3 @@ /** | ||
*/ | ||
export declare function defineCommitViewer(commit: Commit): Union<readonly [Extension<ExtensionTyping<any, any, any>>, PluginExtension]>; | ||
export declare function defineCommitViewer(commit: Commit): PlainExtension; | ||
@@ -491,5 +512,7 @@ /** | ||
* | ||
* @param options | ||
* | ||
* @public | ||
*/ | ||
export declare function defineEnterRule({ regex, handler, stop, }: EnterRuleOptions): Extension; | ||
export declare function defineEnterRule({ regex, handler, stop, }: EnterRuleOptions): PlainExtension; | ||
@@ -510,3 +533,3 @@ /** | ||
*/ | ||
export declare function defineGapCursor(): PluginExtension; | ||
export declare function defineGapCursor(): GapCursorExtension; | ||
@@ -531,3 +554,3 @@ /** | ||
*/ | ||
declare function defineHeadingInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
declare function defineHeadingInputRule(): PlainExtension; | ||
export { defineHeadingInputRule } | ||
@@ -539,3 +562,3 @@ export { defineHeadingInputRule as defineHeadingInputRule_alias_1 } | ||
*/ | ||
declare function defineHeadingKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
declare function defineHeadingKeymap(): PlainExtension; | ||
export { defineHeadingKeymap } | ||
@@ -573,3 +596,3 @@ export { defineHeadingKeymap as defineHeadingKeymap_alias_1 } | ||
*/ | ||
export declare function defineInputRule(rule: InputRule): Extension; | ||
export declare function defineInputRule(rule: InputRule): PlainExtension; | ||
@@ -589,3 +612,3 @@ /** | ||
*/ | ||
export declare function defineItalicInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineItalicInputRule(): PlainExtension; | ||
@@ -595,3 +618,3 @@ /** | ||
*/ | ||
export declare function defineItalicKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineItalicKeymap(): PlainExtension; | ||
@@ -615,3 +638,3 @@ /** | ||
*/ | ||
export declare function defineLinkEnterRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineLinkEnterRule(): PlainExtension; | ||
@@ -623,3 +646,3 @@ /** | ||
*/ | ||
export declare function defineLinkInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineLinkInputRule(): PlainExtension; | ||
@@ -664,3 +687,3 @@ /** | ||
*/ | ||
declare function defineListKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
declare function defineListKeymap(): PlainExtension; | ||
export { defineListKeymap } | ||
@@ -672,3 +695,3 @@ export { defineListKeymap as defineListKeymap_alias_1 } | ||
*/ | ||
declare function defineListPlugins(): PluginExtension; | ||
declare function defineListPlugins(): PlainExtension; | ||
export { defineListPlugins } | ||
@@ -685,2 +708,27 @@ export { defineListPlugins as defineListPlugins_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
export declare function defineLoro(options: LoroOptions): LoroExtension; | ||
declare function defineLoroCommands(): LoroCommandsExtension; | ||
export { defineLoroCommands } | ||
export { defineLoroCommands as defineLoroCommands_alias_1 } | ||
declare function defineLoroCursorPlugin(options: LoroCursorOptions): PlainExtension; | ||
export { defineLoroCursorPlugin } | ||
export { defineLoroCursorPlugin as defineLoroCursorPlugin_alias_1 } | ||
declare function defineLoroKeymap(): PlainExtension; | ||
export { defineLoroKeymap } | ||
export { defineLoroKeymap as defineLoroKeymap_alias_1 } | ||
declare function defineLoroSyncPlugin(options: LoroSyncPluginProps): PlainExtension; | ||
export { defineLoroSyncPlugin } | ||
export { defineLoroSyncPlugin as defineLoroSyncPlugin_alias_1 } | ||
declare function defineLoroUndoPlugin(options: LoroUndoPluginProps): PlainExtension; | ||
export { defineLoroUndoPlugin } | ||
export { defineLoroUndoPlugin as defineLoroUndoPlugin_alias_1 } | ||
/** | ||
* Defines an input rule for automatically adding inline marks when a given | ||
@@ -691,3 +739,3 @@ * pattern is typed. | ||
*/ | ||
export declare function defineMarkInputRule(options: MarkInputRuleOptions): Extension; | ||
export declare function defineMarkInputRule(options: MarkInputRuleOptions): PlainExtension; | ||
@@ -742,3 +790,3 @@ /** | ||
*/ | ||
export declare function definePlaceholder(options: PlaceholderOptions): PluginExtension; | ||
export declare function definePlaceholder(options: PlaceholderOptions): PlainExtension; | ||
@@ -748,3 +796,3 @@ /** | ||
*/ | ||
export declare function defineReadonly(): PluginExtension; | ||
export declare function defineReadonly(): PlainExtension; | ||
@@ -774,3 +822,3 @@ /** | ||
*/ | ||
export declare function defineSearchQuery(options: SearchQueryOptions): PluginExtension; | ||
export declare function defineSearchQuery(options: SearchQueryOptions): PlainExtension; | ||
@@ -790,3 +838,3 @@ /** | ||
*/ | ||
export declare function defineStrikeInputRule(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineStrikeInputRule(): PlainExtension; | ||
@@ -796,3 +844,3 @@ /** | ||
*/ | ||
export declare function defineStrikeKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineStrikeKeymap(): PlainExtension; | ||
@@ -802,7 +850,3 @@ /** | ||
*/ | ||
export declare function defineStrikeSpec(): Extension<{ | ||
Marks: { | ||
strike: Attrs; | ||
}; | ||
}>; | ||
export declare function defineStrikeSpec(): StrikeSpecExtension; | ||
@@ -812,3 +856,5 @@ /** | ||
*/ | ||
export declare function defineTable(): TableExtension; | ||
declare function defineTable(): TableExtension; | ||
export { defineTable } | ||
export { defineTable as defineTable_alias_1 } | ||
@@ -838,3 +884,3 @@ /** | ||
*/ | ||
declare function defineTablePlugins(): PluginExtension; | ||
declare function defineTablePlugins(): PlainExtension; | ||
export { defineTablePlugins } | ||
@@ -860,3 +906,3 @@ export { defineTablePlugins as defineTablePlugins_alias_1 } | ||
*/ | ||
export declare function defineTestExtension(): Union<readonly [DocExtension, TextExtension, HeadingExtension, HistoryExtension, ListExtension, BlockquoteExtension, BaseKeymapExtension, BaseCommandsExtension, ItalicExtension, BoldExtension, UnderlineExtension, StrikeExtension, CodeExtension, LinkExtension, ImageExtension, Extension<{ | ||
export declare function defineTestExtension(): Union<readonly [DocExtension, TextExtension, HeadingExtension, HistoryExtension, ListExtension, BlockquoteExtension, PlainExtension, BaseCommandsExtension, ItalicExtension, BoldExtension, UnderlineExtension, StrikeExtension, CodeExtension, LinkExtension, ImageExtension, Extension<{ | ||
Nodes: { | ||
@@ -873,10 +919,3 @@ paragraph: Attrs_2; | ||
*/ | ||
export declare function defineTextAlign<NodeName extends string = string>(options: TextAlignOptions<NodeName>): Extension<{ | ||
Nodes: { | ||
[K in NodeName]: { | ||
textAlign: string | null; | ||
}; | ||
}; | ||
Commands: TextAlignCommandTyping; | ||
}>; | ||
export declare function defineTextAlign<NodeName extends string = string>(options: TextAlignOptions<NodeName>): TextAlignExtension<NodeName>; | ||
@@ -886,5 +925,3 @@ /** | ||
*/ | ||
export declare function defineTextAlignCommands(types: string[]): Extension<{ | ||
Commands: TextAlignCommandTyping; | ||
}>; | ||
export declare function defineTextAlignCommands(types: string[]): TextAlignCommandsExtension; | ||
@@ -894,3 +931,3 @@ /** | ||
*/ | ||
export declare function defineTextAlignKeymap(types: string[]): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineTextAlignKeymap(types: string[]): PlainExtension; | ||
@@ -902,5 +939,7 @@ /** | ||
* | ||
* @param options | ||
* | ||
* @public | ||
*/ | ||
export declare function defineTextBlockEnterRule({ regex, type, attrs, stop, }: TextBlockEnterRuleOptions): Extension; | ||
export declare function defineTextBlockEnterRule({ regex, type, attrs, stop, }: TextBlockEnterRuleOptions): PlainExtension; | ||
@@ -913,2 +952,4 @@ /** | ||
* | ||
* @param options | ||
* | ||
* @public | ||
@@ -931,3 +972,3 @@ */ | ||
attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null); | ||
}): Extension; | ||
}): PlainExtension; | ||
@@ -947,3 +988,3 @@ /** | ||
*/ | ||
export declare function defineUnderlineKeymap(): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineUnderlineKeymap(): PlainExtension; | ||
@@ -973,2 +1014,4 @@ /** | ||
* | ||
* @param options | ||
* | ||
* @public | ||
@@ -1000,8 +1043,33 @@ */ | ||
join?: (match: RegExpMatchArray, node: ProseMirrorNode) => boolean; | ||
}): Extension; | ||
}): PlainExtension; | ||
/** | ||
* @public | ||
*/ | ||
export declare function defineYjs(options: YjsOptions): YjsExtension; | ||
declare function defineYjsCommands(): YjsCommandsExtension; | ||
export { defineYjsCommands } | ||
export { defineYjsCommands as defineYjsCommands_alias_1 } | ||
declare function defineYjsCursorPlugin(options: YjsCursorOptions): PlainExtension; | ||
export { defineYjsCursorPlugin } | ||
export { defineYjsCursorPlugin as defineYjsCursorPlugin_alias_1 } | ||
declare function defineYjsKeymap(): PlainExtension; | ||
export { defineYjsKeymap } | ||
export { defineYjsKeymap as defineYjsKeymap_alias_1 } | ||
declare function defineYjsSyncPlugin(options: YjsSyncOptions): PlainExtension; | ||
export { defineYjsSyncPlugin } | ||
export { defineYjsSyncPlugin as defineYjsSyncPlugin_alias_1 } | ||
declare function defineYjsUndoPlugin(options: YjsUndoOptions): PlainExtension; | ||
export { defineYjsUndoPlugin } | ||
export { defineYjsUndoPlugin as defineYjsUndoPlugin_alias_1 } | ||
/** | ||
* @internal | ||
*/ | ||
export declare type DropCursorExtension = PluginExtension; | ||
export declare type DropCursorExtension = PlainExtension; | ||
@@ -1077,6 +1145,31 @@ export declare interface DropCursorOptions { | ||
*/ | ||
export declare const exitTable: Command; | ||
declare const exitTable: Command; | ||
export { exitTable } | ||
export { exitTable as exitTable_alias_1 } | ||
/** | ||
* Try to find a resolved pos of a cell by using the given pos as a hit point. | ||
* | ||
* @internal | ||
*/ | ||
export declare function findCellPos(doc: ProseMirrorNode, pos: number): ResolvedPos | undefined; | ||
/** | ||
* Try to find the anchor and head cell in the same table by using the given | ||
* anchor and head as hit points, or fallback to the selection's anchor and | ||
* head. | ||
* | ||
* @internal | ||
*/ | ||
export declare function findCellRange(selection: Selection_2, anchorHit?: number, headHit?: number): [ResolvedPos, ResolvedPos] | undefined; | ||
export declare function findTable($pos: ResolvedPos): FindParentNodeResult | undefined; | ||
export { GapCursor } | ||
/** | ||
* @internal | ||
*/ | ||
export declare type GapCursorExtension = PlainExtension; | ||
export declare function getCheckRanges(transactions: readonly Transaction[], oldState: EditorState, newState: EditorState): Array<[number, number]>; | ||
@@ -1086,4 +1179,2 @@ | ||
export { getSingletonHighlighter } | ||
export declare function getTrMeta(tr: Transaction): PredictionPluginState; | ||
@@ -1129,9 +1220,10 @@ | ||
export declare type HighlighterOptions = { | ||
declare interface HighlighterOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs'> { | ||
themes: BundledTheme[]; | ||
langs: (BundledLanguage | SpecialLanguage)[]; | ||
langAlias?: Record<string, BundledLanguage>; | ||
}; | ||
} | ||
export { HighlighterOptions } | ||
export { HighlighterOptions as HighlighterOptions_alias_1 } | ||
declare type HighlighterResult = { | ||
export declare type HighlighterResult = { | ||
highlighter: Highlighter; | ||
@@ -1185,2 +1277,4 @@ promise?: undefined; | ||
export declare function inputText(input: string): Promise<void>; | ||
/** | ||
@@ -1190,5 +1284,9 @@ * Insert a table node with the given number of rows and columns, and optionally | ||
* | ||
* @param options | ||
* | ||
* @public | ||
*/ | ||
export declare function insertTable({ row, col, header }: InsertTableOptions): Command; | ||
declare function insertTable(options: InsertTableOptions): Command; | ||
export { insertTable } | ||
export { insertTable as insertTable_alias_1 } | ||
@@ -1198,3 +1296,3 @@ /** | ||
*/ | ||
export declare interface InsertTableOptions { | ||
declare interface InsertTableOptions { | ||
row: number; | ||
@@ -1204,4 +1302,15 @@ col: number; | ||
} | ||
export { InsertTableOptions } | ||
export { InsertTableOptions as InsertTableOptions_alias_1 } | ||
/** | ||
* Checks if the given object is a `CellSelection` instance. | ||
* | ||
* @public | ||
*/ | ||
declare function isCellSelection(value: unknown): value is CellSelection; | ||
export { isCellSelection } | ||
export { isCellSelection as isCellSelection_alias_1 } | ||
/** | ||
* @internal | ||
@@ -1335,2 +1444,53 @@ */ | ||
/** | ||
* @internal | ||
*/ | ||
export declare type LoroCommandsExtension = Extension<{ | ||
Commands: { | ||
undo: []; | ||
redo: []; | ||
}; | ||
}>; | ||
declare interface LoroCursorOptions { | ||
awareness: CursorAwareness; | ||
getSelection?: (state: EditorState) => Selection_2; | ||
createCursor?: (user: PeerID) => Element; | ||
createSelection?: (user: PeerID) => DecorationAttrs; | ||
} | ||
export { LoroCursorOptions } | ||
export { LoroCursorOptions as LoroCursorOptions_alias_1 } | ||
/** | ||
* @internal | ||
*/ | ||
export declare type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>; | ||
export declare interface LoroOptions { | ||
/** | ||
* The Loro instance handles the state of shared data. | ||
*/ | ||
doc: LoroDocType; | ||
/** | ||
* The Awareness instance. | ||
*/ | ||
awareness: CursorAwareness; | ||
/** | ||
* Extra options for `LoroSyncPlugin`. | ||
*/ | ||
sync?: Omit<LoroSyncPluginProps, 'doc'>; | ||
/** | ||
* Extra options for the `LoroUndoPlugin`. | ||
*/ | ||
undo?: Omit<LoroUndoPluginProps, 'doc'>; | ||
/** | ||
* Extra options for `LoroCursorPlugin`. | ||
*/ | ||
cursor?: Omit<LoroCursorOptions, 'awareness'>; | ||
} | ||
export { LoroSyncPluginProps } | ||
export { LoroUndoPluginProps } | ||
/** | ||
* Options for {@link defineMarkInputRule}. | ||
@@ -1403,3 +1563,3 @@ * | ||
*/ | ||
export declare type ModClickPreventionExtension = PluginExtension; | ||
export declare type ModClickPreventionExtension = PlainExtension; | ||
@@ -1434,4 +1594,2 @@ export declare interface PlaceholderOptions { | ||
export declare function prepareHighlighter(options: HighlighterOptions): HighlighterResult; | ||
/** | ||
@@ -1450,2 +1608,7 @@ * @example | ||
/** | ||
* @internal | ||
*/ | ||
export declare const redo: Command; | ||
/** | ||
* Options for {@link defineSearchQuery} | ||
@@ -1493,2 +1656,92 @@ * | ||
/** | ||
* @public | ||
*/ | ||
declare function selectTable(options?: SelectTableOptions): Command; | ||
export { selectTable } | ||
export { selectTable as selectTable_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare function selectTableCell(options?: SelectTableCellOptions): Command; | ||
export { selectTableCell } | ||
export { selectTableCell as selectTableCell_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare interface SelectTableCellOptions { | ||
/** | ||
* A hit position of the table cell to select from. By default, the selection | ||
* anchor will be used. | ||
*/ | ||
pos?: number; | ||
} | ||
export { SelectTableCellOptions } | ||
export { SelectTableCellOptions as SelectTableCellOptions_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare function selectTableColumn(options?: SelectTableColumnOptions): Command; | ||
export { selectTableColumn } | ||
export { selectTableColumn as selectTableColumn_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare interface SelectTableColumnOptions { | ||
/** | ||
* A hit position of the table cell to select from. By default, the selection | ||
* anchor will be used. | ||
*/ | ||
anchor?: number; | ||
/** | ||
* A hit position of the table cell to select to. By default, the selection | ||
* head will be used. | ||
*/ | ||
head?: number; | ||
} | ||
export { SelectTableColumnOptions } | ||
export { SelectTableColumnOptions as SelectTableColumnOptions_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare interface SelectTableOptions { | ||
/** | ||
* A hit position of the table to select from. By default, the selection | ||
* anchor will be used. | ||
*/ | ||
pos?: number; | ||
} | ||
export { SelectTableOptions } | ||
export { SelectTableOptions as SelectTableOptions_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare function selectTableRow(options?: SelectTableRowOptions): Command; | ||
export { selectTableRow } | ||
export { selectTableRow as selectTableRow_alias_1 } | ||
/** | ||
* @public | ||
*/ | ||
declare interface SelectTableRowOptions { | ||
/** | ||
* A hit position of the table cell to select from. By default, the selection | ||
* anchor will be used. | ||
*/ | ||
anchor?: number; | ||
/** | ||
* A hit position of the table cell to select to. By default, the selection | ||
* head will be used. | ||
*/ | ||
head?: number; | ||
} | ||
export { SelectTableRowOptions } | ||
export { SelectTableRowOptions as SelectTableRowOptions_alias_1 } | ||
/** | ||
* @internal | ||
@@ -1507,3 +1760,3 @@ */ | ||
export declare function setupTest(): { | ||
editor: TestEditor<Union<readonly [DocExtension, TextExtension, HeadingExtension, HistoryExtension, ListExtension, BlockquoteExtension, BaseKeymapExtension, BaseCommandsExtension, ItalicExtension, BoldExtension, UnderlineExtension, StrikeExtension, CodeExtension, LinkExtension, ImageExtension, Extension<{ | ||
editor: TestEditor<Union<readonly [DocExtension, TextExtension, HeadingExtension, HistoryExtension, ListExtension, BlockquoteExtension, PlainExtension, BaseCommandsExtension, ItalicExtension, BoldExtension, UnderlineExtension, StrikeExtension, CodeExtension, LinkExtension, ImageExtension, Extension<{ | ||
Nodes: { | ||
@@ -1565,9 +1818,9 @@ paragraph: Attrs_2; | ||
image: NodeAction< { | ||
src?: string | null; | ||
src?: (string | null) | undefined; | ||
}>; | ||
list: NodeAction< { | ||
kind?: "bullet" | "ordered" | "task" | "toggle"; | ||
order?: number | null; | ||
checked?: boolean; | ||
collapsed?: boolean; | ||
kind?: ("bullet" | "ordered" | "task" | "toggle") | undefined; | ||
order?: (number | null) | undefined; | ||
checked?: boolean | undefined; | ||
collapsed?: boolean | undefined; | ||
}>; | ||
@@ -1602,2 +1855,5 @@ table: NodeAction< { | ||
export declare interface ShikiHighlighterOptions extends BundledHighlighterOptions<BundledLanguage, BundledTheme> { | ||
} | ||
/** | ||
@@ -1647,2 +1903,16 @@ * @internal | ||
exitTable: []; | ||
selectTable: [options?: SelectTableOptions]; | ||
selectTableCell: [options?: SelectTableCellOptions]; | ||
selectTableColumn: [options?: SelectTableColumnOptions]; | ||
selectTableRow: [options?: SelectTableRowOptions]; | ||
addTableColumnBefore: []; | ||
addTableColumnAfter: []; | ||
addTableRowAbove: []; | ||
addTableRowBelow: []; | ||
deleteTable: []; | ||
deleteTableColumn: []; | ||
deleteTableRow: []; | ||
deleteCellSelection: []; | ||
mergeTableCells: []; | ||
splitTableCell: []; | ||
}; | ||
@@ -1656,3 +1926,3 @@ }>; | ||
*/ | ||
export declare type TableExtension = Union<[ | ||
declare type TableExtension = Union<[ | ||
TableSpecExtension, | ||
@@ -1664,2 +1934,4 @@ TableRowSpecExtension, | ||
]>; | ||
export { TableExtension } | ||
export { TableExtension as TableExtension_alias_1 } | ||
@@ -1702,6 +1974,30 @@ /** | ||
*/ | ||
export declare type TextAlignCommandTyping = { | ||
setTextAlign: [value: string | null]; | ||
}; | ||
export declare type TextAlignAttrsExtension<NodeName extends string> = Extension<{ | ||
Nodes: { | ||
[K in NodeName]: { | ||
textAlign: string | null; | ||
}; | ||
}; | ||
}>; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type TextAlignCommandsExtension = Extension<{ | ||
Commands: { | ||
setTextAlign: [value: string | null]; | ||
}; | ||
}>; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type TextAlignExtension<NodeName extends string> = Union<[ | ||
TextAlignAttrsExtension<NodeName>, | ||
TextAlignCommandsExtension | ||
]>; | ||
/** | ||
* @public | ||
*/ | ||
export declare interface TextAlignOptions<NodeName extends string = string> { | ||
@@ -1779,2 +2075,7 @@ /** | ||
/** | ||
* @internal | ||
*/ | ||
export declare const undo: Command; | ||
export { UnwrapListOptions } | ||
@@ -1785,6 +2086,87 @@ | ||
*/ | ||
export declare type VirtualSelectionExtension = PluginExtension; | ||
export declare type VirtualSelectionExtension = PlainExtension; | ||
export { WrapInListGetAttrs } | ||
/** | ||
* @internal | ||
*/ | ||
export declare type YjsCommandsExtension = Extension<{ | ||
Commands: { | ||
undo: []; | ||
redo: []; | ||
}; | ||
}>; | ||
declare interface YjsCursorOptions extends YjsCursorPluginOptions { | ||
awareness: Awareness; | ||
} | ||
export { YjsCursorOptions } | ||
export { YjsCursorOptions as YjsCursorOptions_alias_1 } | ||
/** | ||
* Options for `y-prosemirror`'s `yCursorPlugin`. | ||
*/ | ||
declare type YjsCursorPluginOptions = NonNullable<Parameters<typeof yCursorPlugin>[1]>; | ||
export { YjsCursorPluginOptions } | ||
export { YjsCursorPluginOptions as YjsCursorPluginOptions_alias_1 } | ||
/** | ||
* @internal | ||
*/ | ||
export declare type YjsExtension = Union<[YjsCommandsExtension, PlainExtension]>; | ||
export declare interface YjsOptions { | ||
/** | ||
* The Yjs instance handles the state of shared data. | ||
*/ | ||
doc: Y.Doc; | ||
/** | ||
* The Awareness instance. | ||
*/ | ||
awareness: Awareness; | ||
/** | ||
* The Yjs XmlFragment to use. If not provided, | ||
* `doc.getXmlFragment('prosemirror')` will be used. | ||
*/ | ||
fragment?: Y.XmlFragment; | ||
/** | ||
* Options for `y-prosemirror`'s `ySyncPlugin`. | ||
*/ | ||
sync?: YjsSyncPluginOptions; | ||
/** | ||
* Options for the `y-prosemirror`'s `yUndoPlugin`. | ||
*/ | ||
undo?: YjsUndoPluginOptions; | ||
/** | ||
* Options for `y-prosemirror`'s `yCursorPlugin`. | ||
*/ | ||
cursor?: YjsCursorPluginOptions; | ||
} | ||
declare interface YjsSyncOptions extends YjsSyncPluginOptions { | ||
fragment: Y.XmlFragment; | ||
} | ||
export { YjsSyncOptions } | ||
export { YjsSyncOptions as YjsSyncOptions_alias_1 } | ||
/** | ||
* Options for `y-prosemirror`'s `ySyncPlugin`. | ||
*/ | ||
declare type YjsSyncPluginOptions = NonNullable<Parameters<typeof ySyncPlugin>[1]>; | ||
export { YjsSyncPluginOptions } | ||
export { YjsSyncPluginOptions as YjsSyncPluginOptions_alias_1 } | ||
declare interface YjsUndoOptions extends YjsUndoPluginOptions { | ||
} | ||
export { YjsUndoOptions } | ||
export { YjsUndoOptions as YjsUndoOptions_alias_1 } | ||
/** | ||
* Options for the `y-prosemirror`'s `yUndoPlugin`. | ||
*/ | ||
declare type YjsUndoPluginOptions = NonNullable<Parameters<typeof yUndoPlugin>[0]>; | ||
export { YjsUndoPluginOptions } | ||
export { YjsUndoPluginOptions as YjsUndoPluginOptions_alias_1 } | ||
export { } |
@@ -14,4 +14,5 @@ // src/autocomplete/index.ts | ||
// src/autocomplete/helpers.ts | ||
import "@prosekit/pm/model"; | ||
import { PluginKey } from "@prosekit/pm/state"; | ||
import { | ||
PluginKey | ||
} from "@prosekit/pm/state"; | ||
function defaultCanMatch({ state }) { | ||
@@ -18,0 +19,0 @@ return state.selection.empty && !isInsideCode(state.selection.$from); |
import { | ||
defineWrappingInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -29,3 +29,3 @@ // src/blockquote/index.ts | ||
function defineBlockquote() { | ||
return union([defineBlockquoteSpec(), defineBlockquoteInputRule()]); | ||
return union(defineBlockquoteSpec(), defineBlockquoteInputRule()); | ||
} | ||
@@ -32,0 +32,0 @@ export { |
import { | ||
defineMarkInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -58,3 +58,3 @@ // src/bold/index.ts | ||
function defineBold() { | ||
return union([ | ||
return union( | ||
defineBoldSpec(), | ||
@@ -64,3 +64,3 @@ defineBoldCommands(), | ||
defineBoldInputRule() | ||
]); | ||
); | ||
} | ||
@@ -67,0 +67,0 @@ export { |
@@ -6,2 +6,3 @@ export { defineCodeBlock_alias_1 as defineCodeBlock } from './_tsup-dts-rollup'; | ||
export { defineCodeBlockHighlight_alias_1 as defineCodeBlockHighlight } from './_tsup-dts-rollup'; | ||
export { CodeBlockHighlightOptions_alias_1 as CodeBlockHighlightOptions } from './_tsup-dts-rollup'; | ||
export { HighlightParser_alias_1 as HighlightParser } from './_tsup-dts-rollup'; | ||
@@ -8,0 +9,0 @@ export { defineCodeBlockEnterRule_alias_1 as defineCodeBlockEnterRule } from './_tsup-dts-rollup'; |
import { | ||
defineTextBlockEnterRule | ||
} from "./chunk-OJCMRVEY.js"; | ||
} from "./chunk-RE23OQPF.js"; | ||
import { | ||
defineTextBlockInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -121,3 +121,3 @@ // src/code-block/code-block.ts | ||
function defineCodeBlock() { | ||
return union([ | ||
return union( | ||
defineCodeBlockSpec(), | ||
@@ -128,3 +128,3 @@ defineCodeBlockInputRule(), | ||
defineCodeBlockCommands() | ||
]); | ||
); | ||
} | ||
@@ -147,39 +147,13 @@ | ||
// src/code-block/shiki-highlighter.ts | ||
var highlighter; | ||
var loadedLangs = /* @__PURE__ */ new Set(); | ||
var loadedThemes = /* @__PURE__ */ new Set(); | ||
async function createHighlighter(options) { | ||
const { getSingletonHighlighter } = await import("./shiki-import-UFUFVKJ2.js"); | ||
if (!highlighter) { | ||
highlighter = await getSingletonHighlighter(options); | ||
} | ||
var loaded; | ||
async function load() { | ||
const { createOrGetHighlighter: createOrGetHighlighter2 } = await import("./shiki-highlighter-chunk-C5VVQ2TD.js"); | ||
loaded = createOrGetHighlighter2; | ||
} | ||
async function loadLanguages(langs) { | ||
for (const lang of langs) { | ||
if (!highlighter) break; | ||
await highlighter.loadLanguage(lang); | ||
loadedLangs.add(lang); | ||
function createOrGetHighlighter(options) { | ||
if (!loaded) { | ||
return { promise: load() }; | ||
} | ||
return loaded(options); | ||
} | ||
async function loadThemes(themes) { | ||
for (const theme of themes) { | ||
if (!highlighter) break; | ||
await highlighter.loadTheme(theme); | ||
loadedThemes.add(theme); | ||
} | ||
} | ||
function prepareHighlighter(options) { | ||
if (!highlighter) { | ||
return { promise: createHighlighter(options) }; | ||
} | ||
const langs = options.langs.filter((lang) => !loadedLangs.has(lang)); | ||
if (langs.length > 0) { | ||
return { promise: loadLanguages(langs) }; | ||
} | ||
const themes = options.themes.filter((theme) => !loadedThemes.has(theme)); | ||
if (themes.length > 0) { | ||
return { promise: loadThemes(themes) }; | ||
} | ||
return { highlighter }; | ||
} | ||
@@ -189,14 +163,14 @@ // src/code-block/shiki-parser.ts | ||
let parser; | ||
prepareHighlighter(highlighterOptions); | ||
createOrGetHighlighter(highlighterOptions); | ||
return function lazyParser(options) { | ||
const language = options.language || ""; | ||
const { highlighter: highlighter2, promise } = prepareHighlighter({ | ||
langs: [language], | ||
themes: highlighterOptions.themes | ||
const { highlighter, promise } = createOrGetHighlighter({ | ||
...highlighterOptions, | ||
langs: [language] | ||
}); | ||
if (!highlighter2) { | ||
if (!highlighter) { | ||
return promise; | ||
} | ||
if (!parser) { | ||
parser = createParser(highlighter2, { | ||
parser = createParser(highlighter, { | ||
theme: highlighterOptions.themes[0] | ||
@@ -213,5 +187,5 @@ }); | ||
langs = ["text"], | ||
langAlias = {} | ||
...rest | ||
} = {}) { | ||
const parser = createLazyParser({ themes, langs, langAlias }); | ||
const parser = createLazyParser({ themes, langs, ...rest }); | ||
return defineCodeBlockHighlight({ parser }); | ||
@@ -218,0 +192,0 @@ } |
import { | ||
defineMarkInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -40,3 +40,3 @@ // src/code/index.ts | ||
function defineCode() { | ||
return union([ | ||
return union( | ||
defineCodeSpec(), | ||
@@ -46,3 +46,3 @@ defineCodeCommands(), | ||
defineCodeInputRule() | ||
]); | ||
); | ||
} | ||
@@ -49,0 +49,0 @@ export { |
// src/commit/index.ts | ||
import { | ||
collectNodes, | ||
collectChildren, | ||
defineDefaultState, | ||
@@ -14,3 +14,6 @@ definePlugin, | ||
} from "@prosekit/pm/model"; | ||
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state"; | ||
import { | ||
PluginKey, | ||
ProseMirrorPlugin | ||
} from "@prosekit/pm/state"; | ||
import { Step } from "@prosekit/pm/transform"; | ||
@@ -52,3 +55,3 @@ import { Decoration, DecorationSet } from "@prosekit/pm/view"; | ||
if (openStart > 0 && content.childCount >= 2) { | ||
const nodes = collectNodes(content); | ||
const nodes = collectChildren(content); | ||
const head = Fragment.from(nodes.slice(0, 1)); | ||
@@ -62,3 +65,3 @@ const body = Fragment.from(nodes.slice(1)); | ||
if (openEnd > 0 && content.childCount >= 2) { | ||
const nodes = collectNodes(content); | ||
const nodes = collectChildren(content); | ||
const body = Fragment.from(nodes.slice(0, -1)); | ||
@@ -140,6 +143,6 @@ const tail = Fragment.from(nodes.slice(-1)); | ||
function defineCommitViewer(commit) { | ||
return union([ | ||
return union( | ||
defineDefaultState({ defaultDoc: commit.doc }), | ||
defineCommitDecoration(commit) | ||
]); | ||
); | ||
} | ||
@@ -146,0 +149,0 @@ var CommitRecorder = class { |
import { | ||
defineEnterRule, | ||
defineTextBlockEnterRule | ||
} from "./chunk-OJCMRVEY.js"; | ||
} from "./chunk-RE23OQPF.js"; | ||
export { | ||
@@ -6,0 +6,0 @@ defineEnterRule, |
export { defineGapCursor } from './_tsup-dts-rollup'; | ||
export { GapCursor } from './_tsup-dts-rollup'; | ||
export { GapCursorExtension } from './_tsup-dts-rollup'; |
@@ -7,4 +7,4 @@ export { defineHeading } from './_tsup-dts-rollup'; | ||
export { defineHeadingSpec } from './_tsup-dts-rollup'; | ||
export { HeadingAttrs } from './_tsup-dts-rollup'; | ||
export { HeadingCommandsExtension_alias_1 as HeadingCommandsExtension } from './_tsup-dts-rollup'; | ||
export { HeadingSpecExtension } from './_tsup-dts-rollup'; | ||
export { HeadingAttrs } from './_tsup-dts-rollup'; |
import { | ||
defineTextBlockInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -97,3 +97,3 @@ // src/heading/index.ts | ||
function defineHeading() { | ||
return union([ | ||
return union( | ||
defineHeadingSpec(), | ||
@@ -103,3 +103,3 @@ defineHeadingInputRule(), | ||
defineHeadingCommands() | ||
]); | ||
); | ||
} | ||
@@ -106,0 +106,0 @@ export { |
@@ -43,3 +43,3 @@ // src/image/index.ts | ||
function defineImage() { | ||
return union([defineImageSpec(), defineImageCommands()]); | ||
return union(defineImageSpec(), defineImageCommands()); | ||
} | ||
@@ -46,0 +46,0 @@ export { |
@@ -7,3 +7,3 @@ import { | ||
defineWrappingInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
export { | ||
@@ -10,0 +10,0 @@ createMarkInputRule, |
import { | ||
defineMarkInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -48,3 +48,3 @@ // src/italic/index.ts | ||
function defineItalic() { | ||
return union([ | ||
return union( | ||
defineItalicSpec(), | ||
@@ -54,3 +54,3 @@ defineItalicCommands(), | ||
defineItalicInputRule() | ||
]); | ||
); | ||
} | ||
@@ -57,0 +57,0 @@ export { |
import { | ||
defineMarkRule | ||
} from "./chunk-GPSAJOJA.js"; | ||
} from "./chunk-GITDYNLT.js"; | ||
import { | ||
defineEnterRule | ||
} from "./chunk-OJCMRVEY.js"; | ||
} from "./chunk-RE23OQPF.js"; | ||
import { | ||
defineInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -101,3 +101,3 @@ // src/link/index.ts | ||
function defineLink() { | ||
return union([ | ||
return union( | ||
defineLinkSpec(), | ||
@@ -107,3 +107,3 @@ defineLinkCommands(), | ||
defineLinkEnterRule() | ||
]); | ||
); | ||
} | ||
@@ -110,0 +110,0 @@ export { |
import { | ||
defineInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -97,3 +97,3 @@ // src/list/index.ts | ||
function defineList() { | ||
return union2([ | ||
return union2( | ||
defineListSpec(), | ||
@@ -104,3 +104,3 @@ defineListPlugins(), | ||
defineListCommands() | ||
]); | ||
); | ||
} | ||
@@ -107,0 +107,0 @@ export { |
import { | ||
defineMarkRule | ||
} from "./chunk-GPSAJOJA.js"; | ||
} from "./chunk-GITDYNLT.js"; | ||
export { | ||
defineMarkRule | ||
}; |
@@ -50,3 +50,3 @@ // src/mention/index.ts | ||
function defineMention() { | ||
return union([defineMentionSpec(), defineMentionCommands()]); | ||
return union(defineMentionSpec(), defineMentionCommands()); | ||
} | ||
@@ -53,0 +53,0 @@ export { |
// src/placeholder/index.ts | ||
import { definePlugin, isInCodeBlock } from "@prosekit/core"; | ||
import "@prosekit/pm/model"; | ||
import { Plugin, PluginKey } from "@prosekit/pm/state"; | ||
@@ -5,0 +4,0 @@ import { Decoration, DecorationSet } from "@prosekit/pm/view"; |
import { | ||
defineMarkInputRule | ||
} from "./chunk-LVMTQOWG.js"; | ||
} from "./chunk-LAQZC3ZM.js"; | ||
@@ -47,3 +47,3 @@ // src/strike/index.ts | ||
function defineStrike() { | ||
return union([ | ||
return union( | ||
defineStrikeSpec(), | ||
@@ -53,3 +53,3 @@ defineStrikeCommands(), | ||
defineStrikeInputRule() | ||
]); | ||
); | ||
} | ||
@@ -56,0 +56,0 @@ export { |
export { defineTable } from './_tsup-dts-rollup'; | ||
export { TableExtension } from './_tsup-dts-rollup'; | ||
export { defineTableCommands } from './_tsup-dts-rollup'; | ||
export { exitTable } from './_tsup-dts-rollup'; | ||
export { insertTable } from './_tsup-dts-rollup'; | ||
export { selectTable } from './_tsup-dts-rollup'; | ||
export { selectTableCell } from './_tsup-dts-rollup'; | ||
export { selectTableColumn } from './_tsup-dts-rollup'; | ||
export { selectTableRow } from './_tsup-dts-rollup'; | ||
export { InsertTableOptions } from './_tsup-dts-rollup'; | ||
export { SelectTableCellOptions } from './_tsup-dts-rollup'; | ||
export { SelectTableColumnOptions } from './_tsup-dts-rollup'; | ||
export { SelectTableOptions } from './_tsup-dts-rollup'; | ||
export { SelectTableRowOptions } from './_tsup-dts-rollup'; | ||
export { TableCommandsExtension } from './_tsup-dts-rollup'; | ||
export { defineTablePlugins } from './_tsup-dts-rollup'; | ||
export { defineTableCellSpec } from './_tsup-dts-rollup'; | ||
export { defineTableCommands } from './_tsup-dts-rollup'; | ||
export { defineTableHeaderCellSpec } from './_tsup-dts-rollup'; | ||
export { defineTablePlugins } from './_tsup-dts-rollup'; | ||
export { defineTableRowSpec } from './_tsup-dts-rollup'; | ||
export { defineTableSpec } from './_tsup-dts-rollup'; | ||
export { TableCellSpecExtension } from './_tsup-dts-rollup'; | ||
export { TableCommandsExtension } from './_tsup-dts-rollup'; | ||
export { TableHeaderCellSpecExtension } from './_tsup-dts-rollup'; | ||
export { TableRowSpecExtension } from './_tsup-dts-rollup'; | ||
export { TableSpecExtension } from './_tsup-dts-rollup'; | ||
export { isCellSelection } from './_tsup-dts-rollup'; |
@@ -1,2 +0,2 @@ | ||
// src/table/index.ts | ||
// src/table/table.ts | ||
import { union } from "@prosekit/core"; | ||
@@ -12,27 +12,79 @@ | ||
import { TextSelection } from "@prosekit/pm/state"; | ||
import { | ||
addColumnAfter, | ||
addColumnBefore, | ||
addRowAfter, | ||
addRowBefore, | ||
CellSelection as CellSelection2, | ||
deleteCellSelection, | ||
deleteColumn, | ||
deleteRow, | ||
deleteTable, | ||
mergeCells, | ||
splitCell, | ||
TableMap | ||
} from "prosemirror-tables"; | ||
// src/table/table-utils.ts | ||
import { findParentNode } from "@prosekit/core"; | ||
import { | ||
cellAround, | ||
cellNear, | ||
CellSelection, | ||
inSameTable | ||
} from "prosemirror-tables"; | ||
function isCellSelection(value) { | ||
return value instanceof CellSelection; | ||
} | ||
function findTable($pos) { | ||
return findParentNode((node) => node.type.spec.tableRole === "table", $pos); | ||
} | ||
function findCellRange(selection, anchorHit, headHit) { | ||
var _a, _b; | ||
if (anchorHit == null && headHit == null && isCellSelection(selection)) { | ||
return [selection.$anchorCell, selection.$headCell]; | ||
} | ||
const anchor = (_a = anchorHit != null ? anchorHit : headHit) != null ? _a : selection.anchor; | ||
const head = (_b = headHit != null ? headHit : anchorHit) != null ? _b : selection.head; | ||
const doc = selection.$head.doc; | ||
const $anchorCell = findCellPos(doc, anchor); | ||
const $headCell = findCellPos(doc, head); | ||
if ($anchorCell && $headCell && inSameTable($anchorCell, $headCell)) { | ||
return [$anchorCell, $headCell]; | ||
} | ||
} | ||
function findCellPos(doc, pos) { | ||
const $pos = doc.resolve(pos); | ||
return cellAround($pos) || cellNear($pos); | ||
} | ||
// src/table/table-commands.ts | ||
function createEmptyTable(schema, row, col, header) { | ||
const table = getNodeType(schema, "table"); | ||
const tableRow = getNodeType(schema, "tableRow"); | ||
const tableCell = getNodeType(schema, "tableCell"); | ||
const tableHeaderCell = getNodeType(schema, "tableHeaderCell"); | ||
const createHeaderRow = () => { | ||
return tableRow.createAndFill( | ||
null, | ||
Array.from({ length: col }, () => tableHeaderCell.createAndFill()) | ||
); | ||
}; | ||
const createBodyRow = () => { | ||
return tableRow.createAndFill( | ||
null, | ||
Array.from({ length: col }, () => tableCell.createAndFill()) | ||
); | ||
}; | ||
const rows = [ | ||
...Array.from({ length: header ? 1 : 0 }, createHeaderRow), | ||
...Array.from({ length: header ? row - 1 : row }, createBodyRow) | ||
]; | ||
return table.createAndFill(null, rows); | ||
const tableType = getNodeType(schema, "table"); | ||
const tableRowType = getNodeType(schema, "tableRow"); | ||
const tableCellType = getNodeType(schema, "tableCell"); | ||
const tableHeaderCellType = getNodeType(schema, "tableHeaderCell"); | ||
if (header) { | ||
const headerCell = tableHeaderCellType.createAndFill(); | ||
const headerCells = repeat(headerCell, col); | ||
const headerRow = tableRowType.createAndFill(null, headerCells); | ||
const bodyCell = tableCellType.createAndFill(); | ||
const bodyCells = repeat(bodyCell, col); | ||
const bodyRow = tableRowType.createAndFill(null, bodyCells); | ||
const bodyRows = repeat(bodyRow, row - 1); | ||
return tableType.createAndFill(null, [headerRow, ...bodyRows]); | ||
} else { | ||
const bodyCell = tableCellType.createAndFill(); | ||
const bodyCells = repeat(bodyCell, col); | ||
const bodyRow = tableRowType.createAndFill(null, bodyCells); | ||
const bodyRows = repeat(bodyRow, row); | ||
return tableType.createAndFill(null, bodyRows); | ||
} | ||
} | ||
function insertTable({ row, col, header }) { | ||
function repeat(node, length) { | ||
return Array(length).fill(node); | ||
} | ||
function insertTable(options) { | ||
return (state, dispatch, view) => { | ||
const { row, col, header } = options; | ||
const table = createEmptyTable(state.schema, row, col, header); | ||
@@ -74,6 +126,91 @@ return insertNode({ node: table })(state, dispatch, view); | ||
}; | ||
function selectTableColumn(options) { | ||
return (state, dispatch) => { | ||
const range = findCellRange(state.selection, options == null ? void 0 : options.anchor, options == null ? void 0 : options.head); | ||
if (!range) { | ||
return false; | ||
} | ||
if (dispatch) { | ||
const [$anchorCell, $headCell] = range; | ||
const selection = CellSelection2.colSelection($anchorCell, $headCell); | ||
dispatch(state.tr.setSelection(selection)); | ||
} | ||
return true; | ||
}; | ||
} | ||
function selectTableRow(options) { | ||
return (state, dispatch) => { | ||
const range = findCellRange(state.selection, options == null ? void 0 : options.anchor, options == null ? void 0 : options.head); | ||
if (!range) { | ||
return false; | ||
} | ||
if (dispatch) { | ||
const [$anchorCell, $headCell] = range; | ||
const selection = CellSelection2.rowSelection($anchorCell, $headCell); | ||
dispatch(state.tr.setSelection(selection)); | ||
} | ||
return true; | ||
}; | ||
} | ||
function selectTableCell(options) { | ||
return (state, dispatch) => { | ||
var _a; | ||
const $cellPos = findCellPos( | ||
state.doc, | ||
(_a = options == null ? void 0 : options.pos) != null ? _a : state.selection.anchor | ||
); | ||
if (!$cellPos) { | ||
return false; | ||
} | ||
if (dispatch) { | ||
const selection = new CellSelection2($cellPos); | ||
dispatch(state.tr.setSelection(selection)); | ||
} | ||
return true; | ||
}; | ||
} | ||
function selectTable(options) { | ||
return (state, dispatch) => { | ||
const $pos = (options == null ? void 0 : options.pos) ? state.doc.resolve(options.pos) : state.selection.$anchor; | ||
const table = findTable($pos); | ||
if (!table) { | ||
return false; | ||
} | ||
const map = TableMap.get(table.node); | ||
if (map.map.length === 0) { | ||
return false; | ||
} | ||
if (dispatch) { | ||
let tr = state.tr; | ||
const firstCellPosInTable = map.map[0]; | ||
const lastCellPosInTable = map.map[map.map.length - 1]; | ||
const firstCellPos = table.pos + firstCellPosInTable + 1; | ||
const lastCellPos = table.pos + lastCellPosInTable + 1; | ||
const $firstCellPos = tr.doc.resolve(firstCellPos); | ||
const $lastCellPos = tr.doc.resolve(lastCellPos); | ||
const selection = new CellSelection2($firstCellPos, $lastCellPos); | ||
tr = tr.setSelection(selection); | ||
dispatch == null ? void 0 : dispatch(tr); | ||
} | ||
return true; | ||
}; | ||
} | ||
function defineTableCommands() { | ||
return defineCommands({ | ||
insertTable, | ||
exitTable: () => exitTable | ||
exitTable: () => exitTable, | ||
selectTable, | ||
selectTableCell, | ||
selectTableColumn, | ||
selectTableRow, | ||
addTableColumnBefore: () => addColumnBefore, | ||
addTableColumnAfter: () => addColumnAfter, | ||
addTableRowAbove: () => addRowBefore, | ||
addTableRowBelow: () => addRowAfter, | ||
deleteTable: () => deleteTable, | ||
deleteTableColumn: () => deleteColumn, | ||
deleteTableRow: () => deleteRow, | ||
deleteCellSelection: () => deleteCellSelection, | ||
mergeTableCells: () => mergeCells, | ||
splitTableCell: () => splitCell | ||
}); | ||
@@ -91,41 +228,19 @@ } | ||
import { defineNodeSpec } from "@prosekit/core"; | ||
import { tableNodes } from "prosemirror-tables"; | ||
var cellContent = "block+"; | ||
function getCellAttrs(dom) { | ||
if (typeof dom === "string") { | ||
return {}; | ||
} | ||
const widthAttr = dom.getAttribute("data-colwidth"); | ||
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map((s) => Number(s)) : null; | ||
const colspan = Number(dom.getAttribute("colspan") || 1); | ||
return { | ||
colspan, | ||
rowspan: Number(dom.getAttribute("rowspan") || 1), | ||
colwidth: widths && widths.length == colspan ? widths : null | ||
}; | ||
} | ||
function setCellAttrs(node) { | ||
const pmAttrs = node.attrs; | ||
const domAttrs = {}; | ||
if (pmAttrs.colspan !== 1) { | ||
domAttrs.colspan = pmAttrs.colspan; | ||
} | ||
if (pmAttrs.rowspan !== 1) { | ||
domAttrs.rowspan = pmAttrs.rowspan; | ||
} | ||
if (pmAttrs.colwidth) { | ||
domAttrs["data-colwidth"] = pmAttrs.colwidth.join(","); | ||
} | ||
return domAttrs; | ||
} | ||
var cellAttrs = { | ||
colspan: { default: 1 }, | ||
rowspan: { default: 1 }, | ||
colwidth: { default: null } | ||
}; | ||
var specs = tableNodes({ | ||
tableGroup: "block", | ||
cellContent, | ||
cellAttributes: {} | ||
}); | ||
function defineTableSpec() { | ||
return defineNodeSpec({ | ||
name: "table", | ||
tableRole: "table", | ||
...specs["table"], | ||
content: "tableRow+", | ||
isolating: true, | ||
group: "block", | ||
parseDOM: [{ tag: "table" }], | ||
toDOM() { | ||
return ["table", ["tbody", 0]]; | ||
} | ||
name: "table" | ||
}); | ||
@@ -135,27 +250,12 @@ } | ||
return defineNodeSpec({ | ||
name: "tableRow", | ||
tableRole: "row", | ||
...specs["table_row"], | ||
content: "(tableCell | tableHeaderCell)*", | ||
parseDOM: [{ tag: "tr" }], | ||
toDOM() { | ||
return ["tr", 0]; | ||
} | ||
name: "tableRow" | ||
}); | ||
} | ||
var cellAttrs = { | ||
colspan: { default: 1 }, | ||
rowspan: { default: 1 }, | ||
colwidth: { default: null } | ||
}; | ||
function defineTableCellSpec() { | ||
return defineNodeSpec({ | ||
...specs["table_cell"], | ||
name: "tableCell", | ||
tableRole: "cell", | ||
content: cellContent, | ||
attrs: cellAttrs, | ||
isolating: true, | ||
parseDOM: [{ tag: "td", getAttrs: (dom) => getCellAttrs(dom) }], | ||
toDOM(node) { | ||
return ["td", setCellAttrs(node), 0]; | ||
} | ||
attrs: cellAttrs | ||
}); | ||
@@ -165,17 +265,11 @@ } | ||
return defineNodeSpec({ | ||
...specs["table_header"], | ||
name: "tableHeaderCell", | ||
tableRole: "header_cell", | ||
content: cellContent, | ||
attrs: cellAttrs, | ||
isolating: true, | ||
parseDOM: [{ tag: "th", getAttrs: (dom) => getCellAttrs(dom) }], | ||
toDOM(node) { | ||
return ["th", setCellAttrs(node), 0]; | ||
} | ||
attrs: cellAttrs | ||
}); | ||
} | ||
// src/table/index.ts | ||
// src/table/table.ts | ||
function defineTable() { | ||
return union([ | ||
return union( | ||
defineTableSpec(), | ||
@@ -187,3 +281,3 @@ defineTableRowSpec(), | ||
defineTableCommands() | ||
]); | ||
); | ||
} | ||
@@ -197,3 +291,10 @@ export { | ||
defineTableRowSpec, | ||
defineTableSpec | ||
defineTableSpec, | ||
exitTable, | ||
insertTable, | ||
isCellSelection, | ||
selectTable, | ||
selectTableCell, | ||
selectTableColumn, | ||
selectTableRow | ||
}; |
@@ -6,2 +6,4 @@ export { setTextAlign } from './_tsup-dts-rollup'; | ||
export { TextAlignOptions } from './_tsup-dts-rollup'; | ||
export { TextAlignCommandTyping } from './_tsup-dts-rollup'; | ||
export { TextAlignAttrsExtension } from './_tsup-dts-rollup'; | ||
export { TextAlignCommandsExtension } from './_tsup-dts-rollup'; | ||
export { TextAlignExtension } from './_tsup-dts-rollup'; |
@@ -44,7 +44,7 @@ // src/text-align/index.ts | ||
function defineTextAlign(options) { | ||
return union([ | ||
return union( | ||
defineTextAlignAttrs(options.types, options.default || "left"), | ||
defineTextAlignKeymap(options.types), | ||
defineTextAlignCommands(options.types) | ||
]); | ||
); | ||
} | ||
@@ -51,0 +51,0 @@ export { |
@@ -34,7 +34,7 @@ // src/underline/index.ts | ||
function defineUnderline() { | ||
return union([ | ||
return union( | ||
defineUnderlineSpec(), | ||
defineUnderlineCommands(), | ||
defineUnderlineKeymap() | ||
]); | ||
); | ||
} | ||
@@ -41,0 +41,0 @@ export { |
{ | ||
"name": "@prosekit/extensions", | ||
"type": "module", | ||
"version": "0.0.0-next-20240724173606", | ||
"version": "0.0.0-next-20240901092634", | ||
"private": false, | ||
@@ -117,2 +117,10 @@ "author": { | ||
}, | ||
"./loro": { | ||
"types": "./dist/prosekit-extensions-loro.d.ts", | ||
"import": "./dist/prosekit-extensions-loro.js", | ||
"default": "./dist/prosekit-extensions-loro.js" | ||
}, | ||
"./loro/style.css": { | ||
"default": "./dist/loro/style.css" | ||
}, | ||
"./mark-rule": { | ||
@@ -184,2 +192,10 @@ "types": "./dist/prosekit-extensions-mark-rule.d.ts", | ||
"default": "./dist/virtual-selection/style.css" | ||
}, | ||
"./yjs": { | ||
"types": "./dist/prosekit-extensions-yjs.d.ts", | ||
"import": "./dist/prosekit-extensions-yjs.js", | ||
"default": "./dist/prosekit-extensions-yjs.js" | ||
}, | ||
"./yjs/style.css": { | ||
"default": "./dist/yjs/style.css" | ||
} | ||
@@ -197,13 +213,39 @@ }, | ||
"prosemirror-search": "^1.0.0", | ||
"prosemirror-tables": "^1.4.0", | ||
"shiki": "^1.11.1", | ||
"@prosekit/core": "^0.0.0-next-20240724173606", | ||
"@prosekit/pm": "^0.0.0-next-20240724173606" | ||
"prosemirror-tables": "^1.5.0", | ||
"shiki": "^1.15.2", | ||
"@prosekit/core": "^0.0.0-next-20240901092634", | ||
"@prosekit/pm": "^0.0.0-next-20240901092634" | ||
}, | ||
"peerDependencies": { | ||
"loro-crdt": ">= 0.16.7", | ||
"loro-prosemirror": ">= 0.0.7", | ||
"y-prosemirror": ">= 1.2.9", | ||
"yjs": ">= 13.6.18" | ||
}, | ||
"peerDependenciesMeta": { | ||
"loro-crdt": { | ||
"optional": true | ||
}, | ||
"loro-prosemirror": { | ||
"optional": true | ||
}, | ||
"y-prosemirror": { | ||
"optional": true | ||
}, | ||
"yjs": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"@vitest/browser": "^2.0.4", | ||
"tsup": "^8.2.2", | ||
"type-fest": "^4.23.0", | ||
"typescript": "^5.5.3", | ||
"vitest": "^2.0.4", | ||
"@vitest/browser": "^2.0.5", | ||
"just-pick": "^4.2.0", | ||
"loro-crdt": "^0.16.7", | ||
"loro-prosemirror": "^0.0.7", | ||
"tsup": "^8.2.4", | ||
"type-fest": "^4.25.0", | ||
"typescript": "^5.5.4", | ||
"vitest": "^2.0.5", | ||
"y-prosemirror": "^1.2.12", | ||
"y-protocols": "^1.0.6", | ||
"yjs": "^13.6.18", | ||
"@prosekit/dev": "0.0.0" | ||
@@ -266,2 +308,5 @@ }, | ||
], | ||
"loro": [ | ||
"./dist/prosekit-extensions-loro.d.ts" | ||
], | ||
"mark-rule": [ | ||
@@ -299,2 +344,5 @@ "./dist/prosekit-extensions-mark-rule.d.ts" | ||
"./dist/prosekit-extensions-virtual-selection.d.ts" | ||
], | ||
"yjs": [ | ||
"./dist/prosekit-extensions-yjs.d.ts" | ||
] | ||
@@ -301,0 +349,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159901
75
4885
14
12
+ Addedisomorphic.js@0.2.5(transitive)
+ Addedlib0@0.2.99(transitive)
+ Addedloro-crdt@1.2.2(transitive)
+ Addedloro-prosemirror@0.2.0(transitive)
+ Addedy-prosemirror@1.2.15(transitive)
+ Addedy-protocols@1.0.6(transitive)
+ Addedyjs@13.6.21(transitive)
Updatedprosemirror-tables@^1.5.0
Updatedshiki@^1.15.2