@milkdown/preset-gfm 7.2.3 → 7.2.4
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.
- package/lib/index.es.js +159 -160
- package/lib/index.es.js.map +1 -1
- package/lib/mark/strike-through.d.ts.map +1 -1
- package/lib/node/table/index.d.ts.map +1 -1
- package/lib/node/table/utils.d.ts +3 -2
- package/lib/node/table/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/mark/strike-through.ts +3 -5
- package/src/node/table/index.ts +16 -13
- package/src/node/table/utils.ts +9 -8
- package/src/plugin/auto-insert-zero-space-plugin.ts +2 -2
package/src/node/table/utils.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { Selection, Transaction } from '@milkdown/prose/state'
|
|
|
7
7
|
import type { TableRect } from '@milkdown/prose/tables'
|
|
8
8
|
import { CellSelection, TableMap } from '@milkdown/prose/tables'
|
|
9
9
|
|
|
10
|
+
import type { Ctx } from '@milkdown/ctx'
|
|
10
11
|
import { tableCellSchema, tableHeaderSchema, tableRowSchema, tableSchema } from '.'
|
|
11
12
|
|
|
12
13
|
/// @internal
|
|
@@ -17,20 +18,20 @@ export interface CellPos {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/// @internal
|
|
20
|
-
export const createTable = (rowsCount = 3, colsCount = 3): Node => {
|
|
21
|
+
export const createTable = (ctx: Ctx, rowsCount = 3, colsCount = 3): Node => {
|
|
21
22
|
const cells = Array(colsCount)
|
|
22
23
|
.fill(0)
|
|
23
|
-
.map(() => tableCellSchema.type().createAndFill()!)
|
|
24
|
+
.map(() => tableCellSchema.type(ctx).createAndFill()!)
|
|
24
25
|
|
|
25
26
|
const headerCells = Array(colsCount)
|
|
26
27
|
.fill(0)
|
|
27
|
-
.map(() => tableHeaderSchema.type().createAndFill()!)
|
|
28
|
+
.map(() => tableHeaderSchema.type(ctx).createAndFill()!)
|
|
28
29
|
|
|
29
30
|
const rows = Array(rowsCount)
|
|
30
31
|
.fill(0)
|
|
31
|
-
.map((_, i) => tableRowSchema.type().create(null, i === 0 ? headerCells : cells))
|
|
32
|
+
.map((_, i) => tableRowSchema.type(ctx).create(null, i === 0 ? headerCells : cells))
|
|
32
33
|
|
|
33
|
-
return tableSchema.type().create(null, rows)
|
|
34
|
+
return tableSchema.type(ctx).create(null, rows)
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
/// Find the table node with position information for current selection.
|
|
@@ -122,7 +123,7 @@ export const selectTable = (tr: Transaction) => {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
/// @internal
|
|
125
|
-
export function addRowWithAlignment(tr: Transaction, { map, tableStart, table }: TableRect, row: number) {
|
|
126
|
+
export function addRowWithAlignment(ctx: Ctx, tr: Transaction, { map, tableStart, table }: TableRect, row: number) {
|
|
126
127
|
const rowPos = Array(row)
|
|
127
128
|
.fill(0)
|
|
128
129
|
.reduce((acc, _, i) => {
|
|
@@ -133,10 +134,10 @@ export function addRowWithAlignment(tr: Transaction, { map, tableStart, table }:
|
|
|
133
134
|
.fill(0)
|
|
134
135
|
.map((_, col) => {
|
|
135
136
|
const headerCol = table.nodeAt(map.map[col] as number)
|
|
136
|
-
return tableCellSchema.type().createAndFill({ alignment: headerCol?.attrs.alignment }) as Node
|
|
137
|
+
return tableCellSchema.type(ctx).createAndFill({ alignment: headerCol?.attrs.alignment }) as Node
|
|
137
138
|
})
|
|
138
139
|
|
|
139
|
-
tr.insert(rowPos, tableRowSchema.type().create(null, cells))
|
|
140
|
+
tr.insert(rowPos, tableRowSchema.type(ctx).create(null, cells))
|
|
140
141
|
return tr
|
|
141
142
|
}
|
|
142
143
|
|
|
@@ -9,10 +9,10 @@ import { withMeta } from '../__internal__'
|
|
|
9
9
|
|
|
10
10
|
/// This plugin is used to fix the bug of IME composing in table in Safari browser.
|
|
11
11
|
/// original discussion in https://discuss.prosemirror.net/t/ime-composing-problems-on-td-or-th-element-in-safari-browser/4501
|
|
12
|
-
export const autoInsertZeroSpaceInTablePlugin = $prose(() => {
|
|
12
|
+
export const autoInsertZeroSpaceInTablePlugin = $prose((ctx) => {
|
|
13
13
|
const pluginKey = new PluginKey('MILKDOWN_AUTO_INSERT_ZERO_SPACE')
|
|
14
14
|
|
|
15
|
-
const isParagraph = (node: Node) => node.type === paragraphSchema.type()
|
|
15
|
+
const isParagraph = (node: Node) => node.type === paragraphSchema.type(ctx)
|
|
16
16
|
|
|
17
17
|
const isEmptyParagraph = (node: Node) => isParagraph(node) && node.nodeSize === 2
|
|
18
18
|
|