@atlaskit/adf-schema 28.1.12 → 28.2.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.
- package/CHANGELOG.md +12 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/json-schema/v1.ts +0 -55
- package/src/__tests__/unit/schema/create-schema.ts +0 -214
- package/src/__tests__/unit/schema/default-schema.ts +0 -192
- package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
- package/src/__tests__/unit/schema/marks/border.ts +0 -76
- package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
- package/src/__tests__/unit/schema/marks/code.ts +0 -44
- package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
- package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
- package/src/__tests__/unit/schema/marks/em.ts +0 -37
- package/src/__tests__/unit/schema/marks/link.ts +0 -188
- package/src/__tests__/unit/schema/marks/strike.ts +0 -37
- package/src/__tests__/unit/schema/marks/strong.ts +0 -43
- package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
- package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
- package/src/__tests__/unit/schema/marks/underline.ts +0 -36
- package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
- package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
- package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
- package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
- package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
- package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
- package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
- package/src/__tests__/unit/schema/nodes/date.ts +0 -51
- package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
- package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
- package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
- package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
- package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
- package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
- package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
- package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
- package/src/__tests__/unit/schema/nodes/image.ts +0 -32
- package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
- package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
- package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
- package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
- package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
- package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
- package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
- package/src/__tests__/unit/schema/nodes/media.ts +0 -384
- package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
- package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
- package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
- package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
- package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
- package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
- package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
- package/src/__tests__/unit/schema/nodes/status.ts +0 -120
- package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
- package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
- package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
- package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
- package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
- package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
- package/src/__tests__/unit/utils/colors.ts +0 -42
- package/src/__tests__/unit/utils/url.ts +0 -209
- package/src/schema/bitbucket-schema.ts +0 -43
- package/src/schema/confluence-schema.ts +0 -76
- package/src/schema/create-schema.ts +0 -337
- package/src/schema/default-schema.ts +0 -180
- package/src/schema/groups.ts +0 -30
- package/src/schema/inline-nodes.ts +0 -9
- package/src/schema/jira-schema.ts +0 -158
- package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
- package/src/schema/marks/alignment.ts +0 -48
- package/src/schema/marks/annotation.ts +0 -107
- package/src/schema/marks/border.ts +0 -74
- package/src/schema/marks/breakout.ts +0 -42
- package/src/schema/marks/code.ts +0 -45
- package/src/schema/marks/confluence-inline-comment.ts +0 -32
- package/src/schema/marks/data-consumer.ts +0 -100
- package/src/schema/marks/em.ts +0 -19
- package/src/schema/marks/fragment.ts +0 -77
- package/src/schema/marks/indentation.ts +0 -47
- package/src/schema/marks/link.ts +0 -139
- package/src/schema/marks/strike.ts +0 -26
- package/src/schema/marks/strong.ts +0 -45
- package/src/schema/marks/subsup.ts +0 -53
- package/src/schema/marks/text-color.ts +0 -172
- package/src/schema/marks/type-ahead-query.ts +0 -22
- package/src/schema/marks/underline.ts +0 -24
- package/src/schema/marks/unsupported-mark.ts +0 -9
- package/src/schema/marks/unsupported-node-attributes.ts +0 -8
- package/src/schema/nodes/block-card.ts +0 -121
- package/src/schema/nodes/blockquote.ts +0 -25
- package/src/schema/nodes/bodied-extension.ts +0 -75
- package/src/schema/nodes/bullet-list.ts +0 -17
- package/src/schema/nodes/caption.ts +0 -51
- package/src/schema/nodes/code-block.ts +0 -176
- package/src/schema/nodes/confluence-jira-issue.ts +0 -43
- package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
- package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
- package/src/schema/nodes/date.ts +0 -38
- package/src/schema/nodes/decision-item.ts +0 -50
- package/src/schema/nodes/decision-list.ts +0 -56
- package/src/schema/nodes/doc.ts +0 -30
- package/src/schema/nodes/embed-card.ts +0 -62
- package/src/schema/nodes/emoji.ts +0 -89
- package/src/schema/nodes/expand.ts +0 -101
- package/src/schema/nodes/extension.ts +0 -60
- package/src/schema/nodes/hard-break.ts +0 -21
- package/src/schema/nodes/heading.ts +0 -64
- package/src/schema/nodes/image.ts +0 -32
- package/src/schema/nodes/inline-card.ts +0 -70
- package/src/schema/nodes/inline-extension.ts +0 -57
- package/src/schema/nodes/layout-column.ts +0 -68
- package/src/schema/nodes/layout-section.ts +0 -93
- package/src/schema/nodes/list-item.ts +0 -13
- package/src/schema/nodes/media-group.ts +0 -44
- package/src/schema/nodes/media-inline.ts +0 -19
- package/src/schema/nodes/media-single.ts +0 -179
- package/src/schema/nodes/media.ts +0 -253
- package/src/schema/nodes/mention.ts +0 -86
- package/src/schema/nodes/nested-expand.ts +0 -77
- package/src/schema/nodes/ordered-list.ts +0 -62
- package/src/schema/nodes/panel.ts +0 -133
- package/src/schema/nodes/paragraph.ts +0 -79
- package/src/schema/nodes/placeholder.ts +0 -40
- package/src/schema/nodes/rule.ts +0 -17
- package/src/schema/nodes/status.ts +0 -58
- package/src/schema/nodes/tableNodes.ts +0 -478
- package/src/schema/nodes/task-item.ts +0 -51
- package/src/schema/nodes/task-list.ts +0 -61
- package/src/schema/nodes/text.ts +0 -19
- package/src/schema/nodes/types/block-content.ts +0 -51
- package/src/schema/nodes/types/extensions.ts +0 -36
- package/src/schema/nodes/types/inline-content.ts +0 -56
- package/src/schema/nodes/types/list.ts +0 -54
- package/src/schema/nodes/types/mark.ts +0 -16
- package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
- package/src/schema/nodes/types/rich-media-common.ts +0 -51
- package/src/schema/nodes/unknown-block.ts +0 -13
- package/src/schema/nodes/unsupported-block.ts +0 -28
- package/src/schema/nodes/unsupported-inline.ts +0 -27
- package/src/schema/unsupported.ts +0 -4
- package/src/steps/__tests__/unit/analytics.ts +0 -72
- package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
- package/src/steps/__tests__/unit/override-document-step.ts +0 -174
- package/src/steps/__tests__/unit/set-attrs.ts +0 -71
- package/src/steps/analytics.ts +0 -189
- package/src/steps/link-meta-step.ts +0 -105
- package/src/steps/override-document-step.ts +0 -97
- package/src/steps/set-attrs.tsx +0 -74
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
- package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
- package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
- package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
- package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
- package/src/steps/table/__tests__/_utils.ts +0 -102
- package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
- package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
- package/src/steps/table/__tests__/add-column.ts +0 -638
- package/src/steps/table/add-column.ts +0 -443
- package/src/steps/table/constants.ts +0 -4
- package/src/steps/table/sort-column.ts +0 -57
- package/src/steps/table/types.ts +0 -48
- package/src/steps/table/utils/cell-step.ts +0 -239
- package/src/steps/table/utils/cells-at-column.ts +0 -75
- package/src/steps/table/utils/find-column.ts +0 -90
- package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
- package/src/steps/table/utils/side-effects/rows.ts +0 -327
- package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
- package/src/steps/table/utils/side-effects/table.ts +0 -112
- package/src/steps/table/utils/side-effects/types.ts +0 -34
- package/src/steps/table/utils/table-map.ts +0 -28
- package/src/steps/type-ahead.ts +0 -100
- package/src/steps.ts +0 -16
- package/src/utils/colors.ts +0 -171
- package/src/utils/confluence/emoji.ts +0 -99
- package/src/utils/extensions.ts +0 -32
- package/src/utils/parseDOM.ts +0 -2
- package/src/utils/url.ts +0 -173
- package/src/utils/uuid.ts +0 -19
- package/src/version.json +0 -6
package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"stepType": "ak-add-column",
|
3
|
-
"tablePos": 0,
|
4
|
-
"cells": [
|
5
|
-
{
|
6
|
-
"from": 2,
|
7
|
-
"to": 6,
|
8
|
-
"newCell": {
|
9
|
-
"type": "tableCell",
|
10
|
-
"attrs": {
|
11
|
-
"colspan": 1,
|
12
|
-
"rowspan": 2,
|
13
|
-
"colwidth": null,
|
14
|
-
"background": "#AAAAAA"
|
15
|
-
},
|
16
|
-
"content": [
|
17
|
-
{
|
18
|
-
"type": "paragraph"
|
19
|
-
}
|
20
|
-
]
|
21
|
-
}
|
22
|
-
}
|
23
|
-
],
|
24
|
-
"isDelete": false,
|
25
|
-
"sideEffects": {
|
26
|
-
"rows": [
|
27
|
-
{
|
28
|
-
"from": 17,
|
29
|
-
"to": 17,
|
30
|
-
"rowNode": {
|
31
|
-
"type": "tableRow",
|
32
|
-
"content": [
|
33
|
-
{
|
34
|
-
"type": "tableCell",
|
35
|
-
"attrs": {
|
36
|
-
"colspan": 1,
|
37
|
-
"rowspan": 1,
|
38
|
-
"colwidth": null,
|
39
|
-
"background": "#AAAAAA"
|
40
|
-
},
|
41
|
-
"content": [
|
42
|
-
{
|
43
|
-
"type": "paragraph"
|
44
|
-
}
|
45
|
-
]
|
46
|
-
}
|
47
|
-
]
|
48
|
-
}
|
49
|
-
}
|
50
|
-
]
|
51
|
-
}
|
52
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"stepType": "ak-add-column",
|
3
|
-
"tablePos": 0,
|
4
|
-
"cells": [
|
5
|
-
{
|
6
|
-
"from": 2,
|
7
|
-
"to": 6
|
8
|
-
}
|
9
|
-
],
|
10
|
-
"isDelete": true,
|
11
|
-
"sideEffects": {
|
12
|
-
"rows": [
|
13
|
-
{
|
14
|
-
"from": 21,
|
15
|
-
"to": 27,
|
16
|
-
"rowNode": {
|
17
|
-
"type": "tableRow",
|
18
|
-
"content": [
|
19
|
-
{
|
20
|
-
"type": "tableCell",
|
21
|
-
"attrs": {
|
22
|
-
"colspan": 1,
|
23
|
-
"rowspan": 1,
|
24
|
-
"colwidth": null,
|
25
|
-
"background": "#AAAAAA"
|
26
|
-
},
|
27
|
-
"content": [
|
28
|
-
{
|
29
|
-
"type": "paragraph"
|
30
|
-
}
|
31
|
-
]
|
32
|
-
}
|
33
|
-
]
|
34
|
-
}
|
35
|
-
}
|
36
|
-
]
|
37
|
-
}
|
38
|
-
}
|
package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"stepType": "ak-add-column",
|
3
|
-
"tablePos": 0,
|
4
|
-
"cells": [
|
5
|
-
{
|
6
|
-
"from": 6,
|
7
|
-
"to": 10,
|
8
|
-
"newCell": {
|
9
|
-
"type": "tableCell",
|
10
|
-
"attrs": {
|
11
|
-
"colspan": 1,
|
12
|
-
"rowspan": 1,
|
13
|
-
"colwidth": null,
|
14
|
-
"background": "#BBBBBB"
|
15
|
-
},
|
16
|
-
"content": [
|
17
|
-
{
|
18
|
-
"type": "paragraph"
|
19
|
-
}
|
20
|
-
]
|
21
|
-
}
|
22
|
-
}
|
23
|
-
],
|
24
|
-
"isDelete": false,
|
25
|
-
"sideEffects": {
|
26
|
-
"rows": [
|
27
|
-
{
|
28
|
-
"from": 11,
|
29
|
-
"to": 11,
|
30
|
-
"rowNode": {
|
31
|
-
"type": "tableRow",
|
32
|
-
"content": [
|
33
|
-
{
|
34
|
-
"type": "tableCell",
|
35
|
-
"attrs": {
|
36
|
-
"colspan": 1,
|
37
|
-
"rowspan": 2,
|
38
|
-
"colwidth": null,
|
39
|
-
"background": "#BBBBBB"
|
40
|
-
},
|
41
|
-
"content": [
|
42
|
-
{
|
43
|
-
"type": "paragraph"
|
44
|
-
}
|
45
|
-
]
|
46
|
-
}
|
47
|
-
]
|
48
|
-
}
|
49
|
-
}
|
50
|
-
]
|
51
|
-
}
|
52
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"stepType": "ak-add-column",
|
3
|
-
"tablePos": 0,
|
4
|
-
"cells": [
|
5
|
-
{
|
6
|
-
"from": 6,
|
7
|
-
"to": 10
|
8
|
-
}
|
9
|
-
],
|
10
|
-
"isDelete": true,
|
11
|
-
"sideEffects": {
|
12
|
-
"rows": [
|
13
|
-
{
|
14
|
-
"from": 15,
|
15
|
-
"to": 21,
|
16
|
-
"rowNode": {
|
17
|
-
"type": "tableRow",
|
18
|
-
"content": [
|
19
|
-
{
|
20
|
-
"type": "tableCell",
|
21
|
-
"attrs": {
|
22
|
-
"colspan": 1,
|
23
|
-
"rowspan": 2,
|
24
|
-
"colwidth": null,
|
25
|
-
"background": "#BBBBBB"
|
26
|
-
},
|
27
|
-
"content": [
|
28
|
-
{
|
29
|
-
"type": "paragraph"
|
30
|
-
}
|
31
|
-
]
|
32
|
-
}
|
33
|
-
]
|
34
|
-
}
|
35
|
-
}
|
36
|
-
]
|
37
|
-
}
|
38
|
-
}
|
package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"stepType": "ak-add-column",
|
3
|
-
"tablePos": 0,
|
4
|
-
"cells": [
|
5
|
-
{
|
6
|
-
"from": 10,
|
7
|
-
"to": 14,
|
8
|
-
"newCell": {
|
9
|
-
"type": "tableCell",
|
10
|
-
"attrs": {
|
11
|
-
"colspan": 1,
|
12
|
-
"rowspan": 3,
|
13
|
-
"colwidth": null,
|
14
|
-
"background": "#CCCCCC"
|
15
|
-
},
|
16
|
-
"content": [
|
17
|
-
{
|
18
|
-
"type": "paragraph"
|
19
|
-
}
|
20
|
-
]
|
21
|
-
}
|
22
|
-
}
|
23
|
-
],
|
24
|
-
"isDelete": false
|
25
|
-
}
|
@@ -1,102 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import {
|
3
|
-
EditorState,
|
4
|
-
Plugin,
|
5
|
-
Transaction,
|
6
|
-
} from '@atlaskit/editor-prosemirror/state';
|
7
|
-
import { history, undo } from '@atlaskit/editor-prosemirror/history';
|
8
|
-
import { DocBuilder, p, Refs, td } from 'adf-test-helpers/src/doc-builder';
|
9
|
-
import { setSelectionTransform } from 'adf-test-helpers/src/set-selection-transform';
|
10
|
-
|
11
|
-
import { defaultSchema } from '../../../schema/default-schema';
|
12
|
-
import { AddColumnStep } from '../add-column';
|
13
|
-
|
14
|
-
const createCell = (
|
15
|
-
color: string,
|
16
|
-
colspan?: number,
|
17
|
-
rowspan?: number,
|
18
|
-
text: string = '',
|
19
|
-
) => td({ background: color, colspan, rowspan })(p(text));
|
20
|
-
|
21
|
-
export const createCellColorA = createCell.bind(null, '#AAAAAA');
|
22
|
-
export const createCellColorB = createCell.bind(null, '#BBBBBB');
|
23
|
-
export const createCellColorC = createCell.bind(null, '#CCCCCC');
|
24
|
-
|
25
|
-
export const tdColorA = createCellColorA();
|
26
|
-
export const tdColorB = createCellColorB();
|
27
|
-
export const tdColorC = createCellColorC();
|
28
|
-
|
29
|
-
// Helper functions
|
30
|
-
export const applyAndInvertTransaction =
|
31
|
-
(doc: ProseMirrorNode) =>
|
32
|
-
(transaction: Transaction, editorState: EditorState) => {
|
33
|
-
let localState = editorState;
|
34
|
-
const addColumnEndStep = transaction.steps[0];
|
35
|
-
|
36
|
-
// apply original transaction
|
37
|
-
localState = localState.apply(transaction);
|
38
|
-
|
39
|
-
const inverted = addColumnEndStep.invert(doc);
|
40
|
-
|
41
|
-
// apply inverted step
|
42
|
-
localState = localState.apply(localState.tr.step(inverted));
|
43
|
-
return localState;
|
44
|
-
};
|
45
|
-
|
46
|
-
export type CreateTransaction = (
|
47
|
-
editorState: EditorState,
|
48
|
-
refs: Refs,
|
49
|
-
) => Transaction;
|
50
|
-
|
51
|
-
export const setup = (doc: DocBuilder, plugins: Plugin[] = []) => {
|
52
|
-
const docWithRefs = doc(defaultSchema);
|
53
|
-
const editorState = EditorState.create({
|
54
|
-
doc: docWithRefs,
|
55
|
-
plugins,
|
56
|
-
});
|
57
|
-
|
58
|
-
const { tr, refs } = setSelectionTransform(docWithRefs, editorState.tr);
|
59
|
-
|
60
|
-
return {
|
61
|
-
editorState: editorState.apply(tr),
|
62
|
-
refs,
|
63
|
-
};
|
64
|
-
};
|
65
|
-
|
66
|
-
export const testHistory = (
|
67
|
-
doc: DocBuilder,
|
68
|
-
firstTransaction: CreateTransaction,
|
69
|
-
historyTransactions: CreateTransaction[],
|
70
|
-
) => {
|
71
|
-
let { editorState, refs } = setup(doc, [history()]);
|
72
|
-
|
73
|
-
const dispatch = (tr: Transaction) => {
|
74
|
-
editorState = editorState.apply(tr);
|
75
|
-
};
|
76
|
-
|
77
|
-
dispatch(firstTransaction(editorState, refs));
|
78
|
-
|
79
|
-
historyTransactions.forEach((createTransaction) => {
|
80
|
-
dispatch(
|
81
|
-
createTransaction(editorState, refs).setMeta('addToHistory', false),
|
82
|
-
);
|
83
|
-
});
|
84
|
-
|
85
|
-
undo(editorState, dispatch);
|
86
|
-
|
87
|
-
return editorState;
|
88
|
-
};
|
89
|
-
|
90
|
-
// Factories
|
91
|
-
export const addColumnAtFactory =
|
92
|
-
(ref: string, column: number): CreateTransaction =>
|
93
|
-
(editorState, refs) =>
|
94
|
-
editorState.tr.step(
|
95
|
-
AddColumnStep.create(editorState.doc, refs[ref], column, false),
|
96
|
-
);
|
97
|
-
export const removeColumnAtFactory =
|
98
|
-
(ref: string, column: number): CreateTransaction =>
|
99
|
-
(editorState, refs) =>
|
100
|
-
editorState.tr.step(
|
101
|
-
AddColumnStep.create(editorState.doc, refs[ref], column, true),
|
102
|
-
);
|