@milkdown/preset-gfm 7.1.0 → 7.1.2-next.0

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.
@@ -7,6 +7,7 @@ import type { NodeType } from '@milkdown/prose/model'
7
7
  import { Selection, TextSelection } from '@milkdown/prose/state'
8
8
  import { CellSelection, addColumnAfter, addColumnBefore, deleteColumn, deleteRow, deleteTable, goToNextCell, isInTable, selectedRect, setCellAttr, tableNodes } from '@milkdown/prose/tables'
9
9
  import { $command, $inputRule, $nodeSchema, $useKeymap } from '@milkdown/utils'
10
+ import { withMeta } from '../../__internal__'
10
11
  import { addRowWithAlignment, createTable, moveCol, moveRow, selectCol, selectRow, selectTable } from './utils'
11
12
 
12
13
  const originalSchema = tableNodes({
@@ -56,9 +57,18 @@ export const tableSchema = $nodeSchema('table', () => ({
56
57
  state.closeNode()
57
58
  },
58
59
  },
59
-
60
60
  }))
61
61
 
62
+ withMeta(tableSchema.node, {
63
+ displayName: 'NodeSchema<table>',
64
+ group: 'Table',
65
+ })
66
+
67
+ withMeta(tableSchema.ctx, {
68
+ displayName: 'NodeSchemaCtx<table>',
69
+ group: 'Table',
70
+ })
71
+
62
72
  /// Schema for table row node.
63
73
  export const tableRowSchema = $nodeSchema('table_row', () => ({
64
74
  ...originalSchema.table_row,
@@ -86,6 +96,16 @@ export const tableRowSchema = $nodeSchema('table_row', () => ({
86
96
  },
87
97
  }))
88
98
 
99
+ withMeta(tableRowSchema.node, {
100
+ displayName: 'NodeSchema<tableRow>',
101
+ group: 'Table',
102
+ })
103
+
104
+ withMeta(tableRowSchema.ctx, {
105
+ displayName: 'NodeSchemaCtx<tableRow>',
106
+ group: 'Table',
107
+ })
108
+
89
109
  /// Schema for table cell node.
90
110
  export const tableCellSchema = $nodeSchema('table_cell', () => ({
91
111
  ...originalSchema.table_cell,
@@ -109,6 +129,16 @@ export const tableCellSchema = $nodeSchema('table_cell', () => ({
109
129
  },
110
130
  }))
111
131
 
132
+ withMeta(tableCellSchema.node, {
133
+ displayName: 'NodeSchema<tableCell>',
134
+ group: 'Table',
135
+ })
136
+
137
+ withMeta(tableCellSchema.ctx, {
138
+ displayName: 'NodeSchemaCtx<tableCell>',
139
+ group: 'Table',
140
+ })
141
+
112
142
  /// Schema for table header node.
113
143
  export const tableHeaderSchema = $nodeSchema('table_header', () => ({
114
144
  ...originalSchema.table_header,
@@ -133,6 +163,16 @@ export const tableHeaderSchema = $nodeSchema('table_header', () => ({
133
163
  },
134
164
  }))
135
165
 
166
+ withMeta(tableHeaderSchema.node, {
167
+ displayName: 'NodeSchema<tableHeader>',
168
+ group: 'Table',
169
+ })
170
+
171
+ withMeta(tableHeaderSchema.ctx, {
172
+ displayName: 'NodeSchemaCtx<tableHeader>',
173
+ group: 'Table',
174
+ })
175
+
136
176
  /// A input rule for creating table.
137
177
  /// For example, `|2x2|` will create a 2x2 table.
138
178
  export const insertTableInputRule = $inputRule(() => new InputRule(
@@ -150,12 +190,27 @@ export const insertTableInputRule = $inputRule(() => new InputRule(
150
190
  },
151
191
  ))
152
192
 
193
+ withMeta(insertTableInputRule, {
194
+ displayName: 'InputRule<insertTableInputRule>',
195
+ group: 'Table',
196
+ })
197
+
153
198
  /// A command for moving cursor to previous cell.
154
199
  export const goToPrevTableCellCommand = $command('GoToPrevTableCell', () => () => goToNextCell(-1))
155
200
 
201
+ withMeta(goToPrevTableCellCommand, {
202
+ displayName: 'Command<goToPrevTableCellCommand>',
203
+ group: 'Table',
204
+ })
205
+
156
206
  /// A command for moving cursor to next cell.
157
207
  export const goToNextTableCellCommand = $command('GoToNextTableCell', () => () => goToNextCell(1))
158
208
 
209
+ withMeta(goToNextTableCellCommand, {
210
+ displayName: 'Command<goToNextTableCellCommand>',
211
+ group: 'Table',
212
+ })
213
+
159
214
  /// A command for splitting current table into two tables.
160
215
  /// If the selection is at the end of the table,
161
216
  /// it will just quit the table and insert a new paragraph node.
@@ -173,6 +228,11 @@ export const breakTableCommand = $command('BreakTable', () => () => (state, disp
173
228
  return true
174
229
  })
175
230
 
231
+ withMeta(breakTableCommand, {
232
+ displayName: 'Command<breakTableCommand>',
233
+ group: 'Table',
234
+ })
235
+
176
236
  /// A command for inserting a table.
177
237
  /// You can specify the number of rows and columns.
178
238
  /// By default, it will insert a 3x3 table.
@@ -188,6 +248,11 @@ export const insertTableCommand = $command('InsertTable', () => ({ row, col }: {
188
248
  return true
189
249
  })
190
250
 
251
+ withMeta(insertTableCommand, {
252
+ displayName: 'Command<insertTableCommand>',
253
+ group: 'Table',
254
+ })
255
+
191
256
  /// A command for moving a row in a table.
192
257
  /// You should specify the `from` and `to` index.
193
258
  export const moveRowCommand = $command('MoveRow', () => ({ from, to }: { from?: number; to?: number } = {}) => (state, dispatch) => {
@@ -197,6 +262,11 @@ export const moveRowCommand = $command('MoveRow', () => ({ from, to }: { from?:
197
262
  return Boolean(result)
198
263
  })
199
264
 
265
+ withMeta(moveRowCommand, {
266
+ displayName: 'Command<moveRowCommand>',
267
+ group: 'Table',
268
+ })
269
+
200
270
  /// A command for moving a column in a table.
201
271
  /// You should specify the `from` and `to` index.
202
272
  export const moveColCommand = $command('MoveCol', () => ({ from, to }: { from?: number; to?: number } = {}) => (state, dispatch) => {
@@ -206,6 +276,11 @@ export const moveColCommand = $command('MoveCol', () => ({ from, to }: { from?:
206
276
  return Boolean(result)
207
277
  })
208
278
 
279
+ withMeta(moveColCommand, {
280
+ displayName: 'Command<moveColCommand>',
281
+ group: 'Table',
282
+ })
283
+
209
284
  /// A command for selecting a row.
210
285
  export const selectRowCommand = $command<number, 'SelectRow'>('SelectRow', () => (index = 0) => (state, dispatch) => {
211
286
  const { tr } = state
@@ -214,6 +289,11 @@ export const selectRowCommand = $command<number, 'SelectRow'>('SelectRow', () =>
214
289
  return Boolean(result)
215
290
  })
216
291
 
292
+ withMeta(selectRowCommand, {
293
+ displayName: 'Command<selectRowCommand>',
294
+ group: 'Table',
295
+ })
296
+
217
297
  /// A command for selecting a column.
218
298
  export const selectColCommand = $command<number, 'SelectCol'>('SelectCol', () => (index = 0) => (state, dispatch) => {
219
299
  const { tr } = state
@@ -222,6 +302,11 @@ export const selectColCommand = $command<number, 'SelectCol'>('SelectCol', () =>
222
302
  return Boolean(result)
223
303
  })
224
304
 
305
+ withMeta(selectColCommand, {
306
+ displayName: 'Command<selectColCommand>',
307
+ group: 'Table',
308
+ })
309
+
225
310
  /// A command for selecting a table.
226
311
  export const selectTableCommand = $command('SelectTable', () => () => (state, dispatch) => {
227
312
  const { tr } = state
@@ -230,6 +315,11 @@ export const selectTableCommand = $command('SelectTable', () => () => (state, di
230
315
  return Boolean(result)
231
316
  })
232
317
 
318
+ withMeta(selectTableCommand, {
319
+ displayName: 'Command<selectTableCommand>',
320
+ group: 'Table',
321
+ })
322
+
233
323
  /// A command for deleting selected cells.
234
324
  /// If the selection is a row or column, the row or column will be deleted.
235
325
  /// If all cells are selected, the table will be deleted.
@@ -251,12 +341,27 @@ export const deleteSelectedCellsCommand = $command('DeleteSelectedCells', () =>
251
341
  return deleteRow(state, dispatch)
252
342
  })
253
343
 
344
+ withMeta(deleteSelectedCellsCommand, {
345
+ displayName: 'Command<deleteSelectedCellsCommand>',
346
+ group: 'Table',
347
+ })
348
+
254
349
  /// A command for adding a column before the current column.
255
350
  export const addColBeforeCommand = $command('AddColBefore', () => () => addColumnBefore)
256
351
 
352
+ withMeta(addColBeforeCommand, {
353
+ displayName: 'Command<addColBeforeCommand>',
354
+ group: 'Table',
355
+ })
356
+
257
357
  /// A command for adding a column after the current column.
258
358
  export const addColAfterCommand = $command('AddColAfter', () => () => addColumnAfter)
259
359
 
360
+ withMeta(addColAfterCommand, {
361
+ displayName: 'Command<addColAfterCommand>',
362
+ group: 'Table',
363
+ })
364
+
260
365
  /// A command for adding a row before the current row.
261
366
  export const addRowBeforeCommand = $command('AddRowBefore', () => () => (state, dispatch) => {
262
367
  if (!isInTable(state))
@@ -268,6 +373,11 @@ export const addRowBeforeCommand = $command('AddRowBefore', () => () => (state,
268
373
  return true
269
374
  })
270
375
 
376
+ withMeta(addRowBeforeCommand, {
377
+ displayName: 'Command<addRowBeforeCommand>',
378
+ group: 'Table',
379
+ })
380
+
271
381
  /// A command for adding a row after the current row.
272
382
  export const addRowAfterCommand = $command('AddRowAfter', () => () => (state, dispatch) => {
273
383
  if (!isInTable(state))
@@ -279,11 +389,21 @@ export const addRowAfterCommand = $command('AddRowAfter', () => () => (state, di
279
389
  return true
280
390
  })
281
391
 
392
+ withMeta(addRowAfterCommand, {
393
+ displayName: 'Command<addRowAfterCommand>',
394
+ group: 'Table',
395
+ })
396
+
282
397
  /// A command for setting alignment property for selected cells.
283
398
  /// You can specify the alignment as `left`, `center`, or `right`.
284
399
  /// It's `left` by default.
285
400
  export const setAlignCommand = $command<'left' | 'center' | 'right', 'SetAlign'>('SetAlign', () => (alignment = 'left') => setCellAttr('alignment', alignment))
286
401
 
402
+ withMeta(setAlignCommand, {
403
+ displayName: 'Command<setAlignCommand>',
404
+ group: 'Table',
405
+ })
406
+
287
407
  /// Keymap for table commands.
288
408
  /// - `<Mod-]>`/`<Tab>`: Move to the next cell.
289
409
  /// - `<Mod-[>`/`<Shift-Tab>`: Move to the previous cell.
@@ -315,4 +435,14 @@ export const tableKeymap = $useKeymap('tableKeymap', {
315
435
  },
316
436
  })
317
437
 
438
+ withMeta(tableKeymap.ctx, {
439
+ displayName: 'KeymapCtx<table>',
440
+ group: 'Table',
441
+ })
442
+
443
+ withMeta(tableKeymap.shortcuts, {
444
+ displayName: 'Keymap<table>',
445
+ group: 'Table',
446
+ })
447
+
318
448
  export * from './utils'
@@ -3,6 +3,7 @@ import { expectDomTypeError } from '@milkdown/exception'
3
3
  import { listItemSchema } from '@milkdown/preset-commonmark'
4
4
  import { InputRule } from '@milkdown/prose/inputrules'
5
5
  import { $inputRule } from '@milkdown/utils'
6
+ import { withMeta } from '../__internal__'
6
7
 
7
8
  /// This schema extends the [list item](/preset-commonmark#list-item) schema and add task list support for it.
8
9
  export const extendListItemSchemaForTask = listItemSchema.extendSchema((prev) => {
@@ -89,6 +90,11 @@ export const extendListItemSchemaForTask = listItemSchema.extendSchema((prev) =>
89
90
  }
90
91
  })
91
92
 
93
+ withMeta(extendListItemSchemaForTask, {
94
+ displayName: 'NodeSchema<listItem>',
95
+ group: 'ListItem',
96
+ })
97
+
92
98
  /// Input rule for wrapping a block in task list node.
93
99
  /// Users can type `[ ] ` or `[x] ` to wrap the block in task list node with checked status.
94
100
  export const wrapInTaskListInputRule = $inputRule(() => {
@@ -115,3 +121,8 @@ export const wrapInTaskListInputRule = $inputRule(() => {
115
121
  return tr
116
122
  })
117
123
  })
124
+
125
+ withMeta(wrapInTaskListInputRule, {
126
+ displayName: 'InputRule<wrapInTaskListInputRule>',
127
+ group: 'ListItem',
128
+ })
@@ -5,6 +5,7 @@ import { isInTable } from '@milkdown/prose/tables'
5
5
  import { Plugin, PluginKey } from '@milkdown/prose/state'
6
6
  import { paragraphSchema } from '@milkdown/preset-commonmark'
7
7
  import { $prose } from '@milkdown/utils'
8
+ import { withMeta } from '../__internal__'
8
9
 
9
10
  /// This plugin is used to fix the bug of IME composing in table in Safari browser.
10
11
  /// original discussion in https://discuss.prosemirror.net/t/ime-composing-problems-on-td-or-th-element-in-safari-browser/4501
@@ -48,3 +49,8 @@ export const autoInsertZeroSpaceInTablePlugin = $prose(() => {
48
49
  },
49
50
  })
50
51
  })
52
+
53
+ withMeta(autoInsertZeroSpaceInTablePlugin, {
54
+ displayName: 'Prose<autoInsertZeroSpaceInTablePlugin>',
55
+ group: 'Prose',
56
+ })
@@ -1,6 +1,12 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { columnResizing } from '@milkdown/prose/tables'
3
3
  import { $prose } from '@milkdown/utils'
4
+ import { withMeta } from '../__internal__'
4
5
 
5
6
  /// This plugin is wrapping the `columnResizing` plugin from [prosemirror-tables](https://github.com/ProseMirror/prosemirror-tables).
6
7
  export const columnResizingPlugin = $prose(() => columnResizing({}))
8
+
9
+ withMeta(columnResizingPlugin, {
10
+ displayName: 'Prose<columnResizingPlugin>',
11
+ group: 'Prose',
12
+ })
@@ -1,6 +1,12 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { $remark } from '@milkdown/utils'
3
3
  import remarkGFM from 'remark-gfm'
4
+ import { withMeta } from '../__internal__'
4
5
 
5
6
  /// This plugin is wrapping the [remark-gfm](https://github.com/remarkjs/remark-gfm).
6
7
  export const remarkGFMPlugin = $remark(() => remarkGFM)
8
+
9
+ withMeta(remarkGFMPlugin, {
10
+ displayName: 'Remark<remarkGFMPlugin>',
11
+ group: 'Remark',
12
+ })
@@ -1,6 +1,12 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { tableEditing } from '@milkdown/prose/tables'
3
3
  import { $prose } from '@milkdown/utils'
4
+ import { withMeta } from '../__internal__'
4
5
 
5
6
  /// This plugin is wrapping the `tableEditing` plugin from [prosemirror-tables](https://github.com/ProseMirror/prosemirror-tables).
6
7
  export const tableEditingPlugin = $prose(() => tableEditing())
8
+
9
+ withMeta(tableEditingPlugin, {
10
+ displayName: 'Prose<tableEditingPlugin>',
11
+ group: 'Prose',
12
+ })