@prosekit/extensions 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,7 +60,7 @@ interface AutocompleteRuleOptions {
60
60
  * The regular expression to match against the text before the cursor. The
61
61
  * last match before the cursor is used.
62
62
  *
63
- * For a slash menu, you might use `/\/(|\S.*)$/u`.
63
+ * For a slash menu, you might use `/(?<!\S)\/(|\S.*)$/u`.
64
64
  * For a mention, you might use `/@\w*$/`
65
65
  */
66
66
  regex: RegExp;
@@ -102,4 +102,4 @@ declare class AutocompleteRule {
102
102
  //#region src/autocomplete/autocomplete.d.ts
103
103
  declare function defineAutocomplete(rule: AutocompleteRule): Extension;
104
104
  //#endregion
105
- export { AutocompleteRule, AutocompleteRuleOptions, CanMatchOptions, CanMatchPredicate, MatchHandler, MatchHandlerOptions, defineAutocomplete };
105
+ export { AutocompleteRule, type AutocompleteRuleOptions, type CanMatchOptions, type CanMatchPredicate, type MatchHandler, type MatchHandlerOptions, defineAutocomplete };
@@ -45,4 +45,4 @@ declare function defineBlockquoteInputRule(): PlainExtension;
45
45
  */
46
46
  declare function defineBlockquoteKeymap(): PlainExtension;
47
47
  //#endregion
48
- export { BlockquoteCommandsExtension, BlockquoteExtension, BlockquoteSpecExtension, defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
48
+ export { type BlockquoteCommandsExtension, type BlockquoteExtension, type BlockquoteSpecExtension, defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
@@ -51,4 +51,4 @@ declare function defineBoldInputRule(): PlainExtension;
51
51
  */
52
52
  declare function defineBoldKeymap(): PlainExtension;
53
53
  //#endregion
54
- export { BoldCommandsExtension, BoldExtension, BoldSpecExtension, defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
54
+ export { type BoldCommandsExtension, type BoldExtension, type BoldSpecExtension, defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
@@ -156,4 +156,4 @@ declare function defineCodeBlockShiki({
156
156
  ...rest
157
157
  }?: CodeBlockShikiOptions): Extension;
158
158
  //#endregion
159
- export { CodeBlockAttrs, CodeBlockCommandsExtension, CodeBlockExtension, CodeBlockHighlightOptions, CodeBlockSpecExtension, HighlightParser, ShikiBundledLanguage, ShikiBundledLanguageInfo, ShikiBundledTheme, ShikiBundledThemeInfo, defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
159
+ export { type CodeBlockAttrs, type CodeBlockCommandsExtension, type CodeBlockExtension, type CodeBlockHighlightOptions, type CodeBlockSpecExtension, type HighlightParser, type ShikiBundledLanguage, type ShikiBundledLanguageInfo, type ShikiBundledTheme, type ShikiBundledThemeInfo, defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
@@ -130,18 +130,34 @@ function defineCodeBlockSpec() {
130
130
  parseDOM: [{
131
131
  tag: "pre",
132
132
  preserveWhitespace: "full",
133
- getAttrs: (node) => ({ language: node.getAttribute("data-language") || "" })
133
+ getAttrs: (node) => {
134
+ const language = extractLanguageFromElement(node) || extractLanguageFromElement(node.querySelector("code"));
135
+ return { language };
136
+ }
134
137
  }],
135
138
  toDOM(node) {
136
- const attrs = node.attrs;
139
+ const { language } = node.attrs;
137
140
  return [
138
141
  "pre",
139
- { "data-language": attrs.language },
140
- ["code", 0]
142
+ { "data-language": language || void 0 },
143
+ [
144
+ "code",
145
+ { class: language ? `language-${language}` : void 0 },
146
+ 0
147
+ ]
141
148
  ];
142
149
  }
143
150
  });
144
151
  }
152
+ function extractLanguageFromElement(element) {
153
+ if (!element) return "";
154
+ const attr = element.getAttribute("data-language");
155
+ if (attr) return attr;
156
+ const className = element.className;
157
+ const match = className.match(/language-(\w+)/);
158
+ if (match) return match[1];
159
+ return "";
160
+ }
145
161
 
146
162
  //#endregion
147
163
  //#region src/code-block/code-block.ts
@@ -51,4 +51,4 @@ declare function defineCodeInputRule(): PlainExtension;
51
51
  */
52
52
  declare function defineCodeKeymap(): PlainExtension;
53
53
  //#endregion
54
- export { CodeCommandsExtension, CodeExtension, CodeSpecExtension, defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
54
+ export { type CodeCommandsExtension, type CodeExtension, type CodeSpecExtension, defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
@@ -49,4 +49,4 @@ declare class CommitRecorder {
49
49
  */
50
50
  declare function defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension;
51
51
  //#endregion
52
- export { Commit, CommitRecorder, defineCommitRecorder, defineCommitViewer };
52
+ export { type Commit, CommitRecorder, defineCommitRecorder, defineCommitViewer };
@@ -32,4 +32,4 @@ type DropCursorExtension = PlainExtension;
32
32
  */
33
33
  declare function defineDropCursor(options?: DropCursorOptions): DropCursorExtension;
34
34
  //#endregion
35
- export { DropCursorExtension, DropCursorOptions, defineDropCursor };
35
+ export { type DropCursorExtension, type DropCursorOptions, defineDropCursor };
@@ -58,11 +58,7 @@ declare function defineFilePasteHandler(handler: FilePasteHandler): PlainExtensi
58
58
  * An interface representing the upload progress.
59
59
  */
60
60
  interface UploadProgress {
61
- // A number representing the amount of work already performed by the
62
- // underlying process.
63
61
  loaded: number;
64
- // A number representing the total amount of work that the underlying
65
- // process is in the progress of performing.
66
62
  total: number;
67
63
  }
68
64
  interface UploaderOptions {
@@ -126,4 +122,4 @@ declare class UploadTask<Result> {
126
122
  static delete(objectURL: string): void;
127
123
  }
128
124
  //#endregion
129
- export { FileDropHandlerOptions, FilePasteHandlerOptions, UploadProgress, UploadTask, Uploader, UploaderOptions, defineFileDropHandler, defineFilePasteHandler };
125
+ export { type FileDropHandlerOptions, type FilePasteHandlerOptions, type UploadProgress, UploadTask, type Uploader, type UploaderOptions, defineFileDropHandler, defineFilePasteHandler };
@@ -23,4 +23,4 @@ type GapCursorExtension = PlainExtension;
23
23
  */
24
24
  declare function defineGapCursor(): GapCursorExtension;
25
25
  //#endregion
26
- export { GapCursorExtension, defineGapCursor };
26
+ export { type GapCursorExtension, defineGapCursor };
@@ -50,4 +50,4 @@ declare function defineHardBreak(): HardBreakExtension;
50
50
  */
51
51
  declare function defineHardBreakKeymap(): PlainExtension;
52
52
  //#endregion
53
- export { HardBreakCommandsExtension, HardBreakExtension, HardBreakSpecExtension, defineHardBreak, defineHardBreakCommands, defineHardBreakKeymap, defineHardBreakSpec };
53
+ export { type HardBreakCommandsExtension, type HardBreakExtension, type HardBreakSpecExtension, defineHardBreak, defineHardBreakCommands, defineHardBreakKeymap, defineHardBreakSpec };
@@ -60,4 +60,4 @@ declare function defineHeadingInputRule(): PlainExtension;
60
60
  */
61
61
  declare function defineHeadingKeymap(): PlainExtension;
62
62
  //#endregion
63
- export { HeadingAttrs, HeadingCommandsExtension, HeadingExtension, HeadingSpecExtension, defineHeading, defineHeadingCommands, defineHeadingInputRule, defineHeadingKeymap, defineHeadingSpec };
63
+ export { type HeadingAttrs, type HeadingCommandsExtension, type HeadingExtension, type HeadingSpecExtension, defineHeading, defineHeadingCommands, defineHeadingInputRule, defineHeadingKeymap, defineHeadingSpec };
@@ -35,4 +35,4 @@ declare function defineHorizontalRule(): HorizontalRuleExtension;
35
35
  */
36
36
  declare function defineHorizontalRuleInputRule(): PlainExtension;
37
37
  //#endregion
38
- export { HorizontalRuleCommandsExtension, HorizontalRuleExtension, HorizontalRuleSpecExtension, defineHorizontalRule, defineHorizontalRuleCommands, defineHorizontalRuleInputRule, defineHorizontalRuleSpec, insertHorizontalRule };
38
+ export { type HorizontalRuleCommandsExtension, type HorizontalRuleExtension, type HorizontalRuleSpecExtension, defineHorizontalRule, defineHorizontalRuleCommands, defineHorizontalRuleInputRule, defineHorizontalRuleSpec, insertHorizontalRule };
@@ -47,4 +47,4 @@ type ImageExtension = Union<[ImageSpecExtension, ImageCommandsExtension]>;
47
47
  */
48
48
  declare function defineImage(): ImageExtension;
49
49
  //#endregion
50
- export { ImageAttrs, ImageCommandsExtension, ImageExtension, ImageSpecExtension, defineImage, defineImageCommands, defineImageSpec };
50
+ export { type ImageAttrs, type ImageCommandsExtension, type ImageExtension, type ImageSpecExtension, defineImage, defineImageCommands, defineImageSpec };
@@ -51,4 +51,4 @@ declare function defineItalicInputRule(): PlainExtension;
51
51
  */
52
52
  declare function defineItalicKeymap(): PlainExtension;
53
53
  //#endregion
54
- export { ItalicCommandsExtension, ItalicExtension, ItalicSpecExtension, defineItalic, defineItalicCommands, defineItalicInputRule, defineItalicKeymap, defineItalicSpec };
54
+ export { type ItalicCommandsExtension, type ItalicExtension, type ItalicSpecExtension, defineItalic, defineItalicCommands, defineItalicInputRule, defineItalicKeymap, defineItalicSpec };
@@ -101,4 +101,4 @@ declare function defineList(): ListExtension;
101
101
  */
102
102
  declare function defineListSerializer(): PlainExtension;
103
103
  //#endregion
104
- export { DedentListOptions, IndentListOptions, ListAttrs, ListCommandsExtension, ListDOMSerializer, ListExtension, ListSpecExtension, ToggleCollapsedOptions, UnwrapListOptions, WrapInListGetAttrs, defineList, defineListCommands, defineListInputRules, defineListKeymap, defineListPlugins, defineListSerializer, defineListSpec };
104
+ export { type DedentListOptions, type IndentListOptions, type ListAttrs, type ListCommandsExtension, ListDOMSerializer, type ListExtension, type ListSpecExtension, type ToggleCollapsedOptions, type UnwrapListOptions, type WrapInListGetAttrs, defineList, defineListCommands, defineListInputRules, defineListKeymap, defineListPlugins, defineListSerializer, defineListSpec };
@@ -66,4 +66,4 @@ type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>;
66
66
  */
67
67
  declare function defineLoro(options: LoroOptions): LoroExtension;
68
68
  //#endregion
69
- export { LoroCursorOptions, LoroExtension, LoroOptions, LoroSyncPluginProps, LoroUndoPluginProps, defineLoro, defineLoroCommands, defineLoroCursorPlugin, defineLoroKeymap, defineLoroSyncPlugin, defineLoroUndoPlugin };
69
+ export { type LoroCursorOptions, type LoroExtension, type LoroOptions, type LoroSyncPluginProps, type LoroUndoPluginProps, defineLoro, defineLoroCommands, defineLoroCursorPlugin, defineLoroKeymap, defineLoroSyncPlugin, defineLoroUndoPlugin };
@@ -34,4 +34,4 @@ interface MarkRuleOptions {
34
34
  */
35
35
  declare function defineMarkRule(options: MarkRuleOptions): PlainExtension;
36
36
  //#endregion
37
- export { MarkRuleOptions, defineMarkRule };
37
+ export { type MarkRuleOptions, defineMarkRule };
@@ -57,4 +57,4 @@ declare function defineParagraph(): ParagraphExtension;
57
57
  */
58
58
  declare function defineParagraphKeymap(): PlainExtension;
59
59
  //#endregion
60
- export { ParagraphCommandsExtension, ParagraphExtension, ParagraphSpecExtension, defineParagraph, defineParagraphCommands, defineParagraphKeymap, defineParagraphSpec };
60
+ export { type ParagraphCommandsExtension, type ParagraphExtension, type ParagraphSpecExtension, defineParagraph, defineParagraphCommands, defineParagraphKeymap, defineParagraphSpec };
@@ -296,4 +296,4 @@ declare function findTable($pos: ResolvedPos): FindParentNodeResult | undefined;
296
296
  */
297
297
 
298
298
  //#endregion
299
- export { InsertTableOptions, MoveTableColumnOptions, MoveTableRowOptions, SelectTableCellOptions, SelectTableColumnOptions, SelectTableOptions, SelectTableRowOptions, TableCellSpecExtension, TableCommandsExtension, TableExtension, TableHeaderCellSpecExtension, TableRowSpecExtension, TableSpecExtension, defineTable, defineTableCellSpec, defineTableCommands, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
299
+ export { type InsertTableOptions, type MoveTableColumnOptions, type MoveTableRowOptions, type SelectTableCellOptions, type SelectTableColumnOptions, type SelectTableOptions, type SelectTableRowOptions, type TableCellSpecExtension, type TableCommandsExtension, type TableExtension, type TableHeaderCellSpecExtension, type TableRowSpecExtension, type TableSpecExtension, defineTable, defineTableCellSpec, defineTableCommands, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
@@ -86,4 +86,4 @@ declare function defineYjs(options: YjsOptions): YjsExtension;
86
86
  //#region src/yjs/yjs-keymap.d.ts
87
87
  declare function defineYjsKeymap(): PlainExtension;
88
88
  //#endregion
89
- export { YjsCursorOptions, YjsCursorPluginOptions, YjsExtension, YjsOptions, YjsSyncOptions, YjsSyncPluginOptions, YjsUndoOptions, YjsUndoPluginOptions, defineYjs, defineYjsCommands, defineYjsCursorPlugin, defineYjsKeymap, defineYjsSyncPlugin, defineYjsUndoPlugin };
89
+ export { type YjsCursorOptions, type YjsCursorPluginOptions, type YjsExtension, type YjsOptions, type YjsSyncOptions, type YjsSyncPluginOptions, type YjsUndoOptions, type YjsUndoPluginOptions, defineYjs, defineYjsCommands, defineYjsCursorPlugin, defineYjsKeymap, defineYjsSyncPlugin, defineYjsUndoPlugin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.10.0",
4
+ "version": "0.10.1",
5
5
  "private": false,
6
6
  "description": "A collection of common extensions for ProseKit",
7
7
  "author": {
@@ -206,9 +206,9 @@
206
206
  "prosemirror-highlight": "^0.13.0",
207
207
  "prosemirror-search": "^1.1.0",
208
208
  "prosemirror-tables": "^1.7.1",
209
- "shiki": "^3.7.0",
210
- "@prosekit/pm": "^0.1.11",
211
- "@prosekit/core": "^0.8.3"
209
+ "shiki": "^3.8.1",
210
+ "@prosekit/core": "^0.8.3",
211
+ "@prosekit/pm": "^0.1.11"
212
212
  },
213
213
  "peerDependencies": {
214
214
  "loro-crdt": ">= 0.16.7",
@@ -231,20 +231,27 @@
231
231
  }
232
232
  },
233
233
  "devDependencies": {
234
+ "@types/diffable-html": "^5.0.2",
234
235
  "@vitest/browser": "^3.2.4",
236
+ "diffable-html": "^6.0.1",
235
237
  "just-pick": "^4.2.0",
236
238
  "loro-crdt": "^1.5.9",
237
239
  "loro-prosemirror": "^0.2.3",
238
- "prettier": "^3.6.0",
239
- "tsdown": "^0.12.9",
240
+ "rehype-parse": "^9.0.1",
241
+ "rehype-remark": "^10.0.1",
242
+ "remark-html": "^16.0.1",
243
+ "remark-parse": "^11.0.0",
244
+ "remark-stringify": "^11.0.0",
245
+ "tsdown": "^0.13.0",
240
246
  "type-fest": "^4.41.0",
241
247
  "typescript": "~5.8.3",
248
+ "unified": "^11.0.5",
242
249
  "vitest": "^3.2.4",
243
- "y-prosemirror": "^1.3.6",
250
+ "y-prosemirror": "^1.3.7",
244
251
  "y-protocols": "^1.0.6",
245
252
  "yjs": "^13.6.27",
246
- "@prosekit/config-vitest": "0.0.0",
247
- "@prosekit/config-tsdown": "0.0.0"
253
+ "@prosekit/config-tsdown": "0.0.0",
254
+ "@prosekit/config-vitest": "0.0.0"
248
255
  },
249
256
  "publishConfig": {
250
257
  "dev": {}