@atlaskit/adf-schema 25.1.0 → 25.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 +14 -0
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/json-schema/index.js +0 -3
- package/dist/cjs/schema/bitbucket-schema.js +0 -2
- package/dist/cjs/schema/confluence-schema.js +1 -4
- package/dist/cjs/schema/create-schema.js +12 -38
- package/dist/cjs/schema/default-schema.js +3 -16
- package/dist/cjs/schema/groups.js +13 -6
- package/dist/cjs/schema/index.js +0 -5
- package/dist/cjs/schema/inline-nodes.js +0 -5
- package/dist/cjs/schema/jira-schema.js +0 -36
- package/dist/cjs/schema/marks/alignment.js +0 -2
- package/dist/cjs/schema/marks/annotation.js +2 -14
- package/dist/cjs/schema/marks/code.js +0 -5
- package/dist/cjs/schema/marks/confluence-inline-comment.js +1 -1
- package/dist/cjs/schema/marks/data-consumer.js +2 -7
- package/dist/cjs/schema/marks/em.js +0 -2
- package/dist/cjs/schema/marks/fragment.js +0 -13
- package/dist/cjs/schema/marks/indentation.js +0 -2
- package/dist/cjs/schema/marks/index.js +0 -18
- package/dist/cjs/schema/marks/link.js +0 -17
- package/dist/cjs/schema/marks/strike.js +0 -2
- package/dist/cjs/schema/marks/strong.js +2 -3
- package/dist/cjs/schema/marks/subsup.js +0 -5
- package/dist/cjs/schema/marks/text-color.js +46 -37
- package/dist/cjs/schema/marks/type-ahead-query.js +0 -3
- package/dist/cjs/schema/marks/underline.js +0 -2
- package/dist/cjs/schema/nodes/block-card.js +1 -2
- package/dist/cjs/schema/nodes/blockquote.js +1 -1
- package/dist/cjs/schema/nodes/bodied-extension.js +0 -3
- package/dist/cjs/schema/nodes/caption.js +1 -1
- package/dist/cjs/schema/nodes/code-block.js +11 -29
- package/dist/cjs/schema/nodes/date.js +1 -1
- package/dist/cjs/schema/nodes/decision-item.js +2 -4
- package/dist/cjs/schema/nodes/decision-list.js +0 -2
- package/dist/cjs/schema/nodes/doc.js +1 -1
- package/dist/cjs/schema/nodes/embed-card.js +6 -6
- package/dist/cjs/schema/nodes/emoji.js +11 -9
- package/dist/cjs/schema/nodes/expand.js +1 -4
- package/dist/cjs/schema/nodes/extension.js +0 -3
- package/dist/cjs/schema/nodes/hard-break.js +1 -1
- package/dist/cjs/schema/nodes/heading.js +2 -2
- package/dist/cjs/schema/nodes/index.js +0 -45
- package/dist/cjs/schema/nodes/inline-card.js +4 -4
- package/dist/cjs/schema/nodes/inline-extension.js +0 -3
- package/dist/cjs/schema/nodes/layout-column.js +4 -5
- package/dist/cjs/schema/nodes/layout-section.js +1 -1
- package/dist/cjs/schema/nodes/media-group.js +1 -1
- package/dist/cjs/schema/nodes/media-inline.js +0 -2
- package/dist/cjs/schema/nodes/media-single.js +3 -14
- package/dist/cjs/schema/nodes/media.js +10 -28
- package/dist/cjs/schema/nodes/mention.js +4 -14
- package/dist/cjs/schema/nodes/nested-expand.js +1 -1
- package/dist/cjs/schema/nodes/ordered-list.js +3 -17
- package/dist/cjs/schema/nodes/panel.js +1 -13
- package/dist/cjs/schema/nodes/paragraph.js +1 -6
- package/dist/cjs/schema/nodes/placeholder.js +1 -1
- package/dist/cjs/schema/nodes/rule.js +1 -1
- package/dist/cjs/schema/nodes/status.js +4 -6
- package/dist/cjs/schema/nodes/tableNodes.js +12 -39
- package/dist/cjs/schema/nodes/task-item.js +2 -4
- package/dist/cjs/schema/nodes/task-list.js +0 -2
- package/dist/cjs/schema/nodes/text.js +1 -1
- package/dist/cjs/steps/analytics.js +4 -38
- package/dist/cjs/steps/set-attrs.js +0 -26
- package/dist/cjs/steps/table/add-column.js +33 -105
- package/dist/cjs/steps/table/constants.js +0 -1
- package/dist/cjs/steps/table/sort-column.js +0 -19
- package/dist/cjs/steps/table/utils/cell-step.js +18 -49
- package/dist/cjs/steps/table/utils/cells-at-column.js +2 -21
- package/dist/cjs/steps/table/utils/find-column.js +13 -17
- package/dist/cjs/steps/table/utils/get-table-rect-from-doc.js +6 -8
- package/dist/cjs/steps/table/utils/side-effects/rows.js +23 -78
- package/dist/cjs/steps/table/utils/side-effects/side-effects.js +0 -23
- package/dist/cjs/steps/table/utils/side-effects/table.js +2 -18
- package/dist/cjs/steps/table/utils/table-map.js +0 -6
- package/dist/cjs/steps/type-ahead.js +5 -25
- package/dist/cjs/steps.js +0 -6
- package/dist/cjs/utils/colors.js +13 -36
- package/dist/cjs/utils/confluence/emoji.js +6 -13
- package/dist/cjs/utils/extensions.js +0 -8
- package/dist/cjs/utils/index.js +0 -4
- package/dist/cjs/utils/parseDOM.js +0 -2
- package/dist/cjs/utils/url.js +3 -20
- package/dist/cjs/utils/uuid.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/schema/bitbucket-schema.js +1 -1
- package/dist/es2019/schema/confluence-schema.js +1 -2
- package/dist/es2019/schema/create-schema.js +12 -25
- package/dist/es2019/schema/default-schema.js +3 -11
- package/dist/es2019/schema/groups.js +13 -6
- package/dist/es2019/schema/index.js +1 -2
- package/dist/es2019/schema/jira-schema.js +0 -24
- package/dist/es2019/schema/marks/alignment.js +1 -3
- package/dist/es2019/schema/marks/annotation.js +3 -9
- package/dist/es2019/schema/marks/breakout.js +0 -4
- package/dist/es2019/schema/marks/code.js +1 -5
- package/dist/es2019/schema/marks/confluence-inline-comment.js +1 -2
- package/dist/es2019/schema/marks/data-consumer.js +3 -5
- package/dist/es2019/schema/marks/em.js +1 -2
- package/dist/es2019/schema/marks/fragment.js +0 -8
- package/dist/es2019/schema/marks/indentation.js +0 -4
- package/dist/es2019/schema/marks/link.js +2 -11
- package/dist/es2019/schema/marks/strike.js +1 -2
- package/dist/es2019/schema/marks/strong.js +3 -7
- package/dist/es2019/schema/marks/subsup.js +0 -6
- package/dist/es2019/schema/marks/text-color.js +44 -29
- package/dist/es2019/schema/marks/type-ahead-query.js +0 -2
- package/dist/es2019/schema/marks/underline.js +1 -2
- package/dist/es2019/schema/marks/unsupported-mark.js +0 -1
- package/dist/es2019/schema/marks/unsupported-node-attributes.js +0 -1
- package/dist/es2019/schema/nodes/block-card.js +1 -3
- package/dist/es2019/schema/nodes/blockquote.js +1 -2
- package/dist/es2019/schema/nodes/bodied-extension.js +0 -4
- package/dist/es2019/schema/nodes/bullet-list.js +0 -2
- package/dist/es2019/schema/nodes/caption.js +1 -2
- package/dist/es2019/schema/nodes/code-block.js +11 -28
- package/dist/es2019/schema/nodes/confluence-jira-issue.js +0 -2
- package/dist/es2019/schema/nodes/confluence-unsupported-block.js +0 -4
- package/dist/es2019/schema/nodes/confluence-unsupported-inline.js +0 -4
- package/dist/es2019/schema/nodes/date.js +1 -2
- package/dist/es2019/schema/nodes/decision-item.js +0 -2
- package/dist/es2019/schema/nodes/decision-list.js +1 -2
- package/dist/es2019/schema/nodes/doc.js +1 -0
- package/dist/es2019/schema/nodes/embed-card.js +1 -2
- package/dist/es2019/schema/nodes/emoji.js +9 -6
- package/dist/es2019/schema/nodes/expand.js +1 -3
- package/dist/es2019/schema/nodes/extension.js +0 -4
- package/dist/es2019/schema/nodes/hard-break.js +1 -2
- package/dist/es2019/schema/nodes/heading.js +2 -3
- package/dist/es2019/schema/nodes/image.js +0 -4
- package/dist/es2019/schema/nodes/inline-card.js +4 -5
- package/dist/es2019/schema/nodes/inline-extension.js +0 -4
- package/dist/es2019/schema/nodes/layout-column.js +4 -6
- package/dist/es2019/schema/nodes/layout-section.js +1 -4
- package/dist/es2019/schema/nodes/list-item.js +0 -2
- package/dist/es2019/schema/nodes/media-group.js +1 -2
- package/dist/es2019/schema/nodes/media-single.js +3 -6
- package/dist/es2019/schema/nodes/media.js +10 -20
- package/dist/es2019/schema/nodes/mention.js +0 -11
- package/dist/es2019/schema/nodes/nested-expand.js +1 -2
- package/dist/es2019/schema/nodes/ordered-list.js +4 -14
- package/dist/es2019/schema/nodes/panel.js +3 -10
- package/dist/es2019/schema/nodes/paragraph.js +1 -7
- package/dist/es2019/schema/nodes/placeholder.js +1 -2
- package/dist/es2019/schema/nodes/rule.js +1 -2
- package/dist/es2019/schema/nodes/status.js +1 -2
- package/dist/es2019/schema/nodes/tableNodes.js +10 -26
- package/dist/es2019/schema/nodes/task-item.js +0 -2
- package/dist/es2019/schema/nodes/task-list.js +0 -2
- package/dist/es2019/schema/nodes/text.js +1 -0
- package/dist/es2019/schema/nodes/unknown-block.js +0 -2
- package/dist/es2019/schema/nodes/unsupported-block.js +0 -2
- package/dist/es2019/schema/nodes/unsupported-inline.js +0 -2
- package/dist/es2019/steps/analytics.js +13 -30
- package/dist/es2019/steps/set-attrs.js +3 -12
- package/dist/es2019/steps/table/add-column.js +33 -76
- package/dist/es2019/steps/table/constants.js +0 -1
- package/dist/es2019/steps/table/sort-column.js +1 -8
- package/dist/es2019/steps/table/utils/cell-step.js +15 -32
- package/dist/es2019/steps/table/utils/cells-at-column.js +6 -11
- package/dist/es2019/steps/table/utils/find-column.js +12 -15
- package/dist/es2019/steps/table/utils/get-table-rect-from-doc.js +7 -6
- package/dist/es2019/steps/table/utils/side-effects/rows.js +19 -59
- package/dist/es2019/steps/table/utils/side-effects/side-effects.js +0 -21
- package/dist/es2019/steps/table/utils/side-effects/table.js +0 -17
- package/dist/es2019/steps/type-ahead.js +3 -15
- package/dist/es2019/utils/colors.js +8 -18
- package/dist/es2019/utils/confluence/emoji.js +5 -8
- package/dist/es2019/utils/extensions.js +0 -4
- package/dist/es2019/utils/url.js +2 -12
- package/dist/es2019/utils/uuid.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/schema/bitbucket-schema.js +1 -1
- package/dist/esm/schema/confluence-schema.js +1 -2
- package/dist/esm/schema/create-schema.js +12 -31
- package/dist/esm/schema/default-schema.js +3 -11
- package/dist/esm/schema/groups.js +13 -6
- package/dist/esm/schema/index.js +1 -2
- package/dist/esm/schema/jira-schema.js +0 -24
- package/dist/esm/schema/marks/alignment.js +1 -1
- package/dist/esm/schema/marks/annotation.js +3 -11
- package/dist/esm/schema/marks/code.js +1 -3
- package/dist/esm/schema/marks/confluence-inline-comment.js +1 -0
- package/dist/esm/schema/marks/data-consumer.js +3 -3
- package/dist/esm/schema/marks/em.js +1 -0
- package/dist/esm/schema/marks/fragment.js +0 -9
- package/dist/esm/schema/marks/link.js +0 -12
- package/dist/esm/schema/marks/strike.js +1 -0
- package/dist/esm/schema/marks/strong.js +3 -1
- package/dist/esm/schema/marks/subsup.js +0 -4
- package/dist/esm/schema/marks/text-color.js +46 -30
- package/dist/esm/schema/marks/underline.js +1 -0
- package/dist/esm/schema/nodes/block-card.js +1 -1
- package/dist/esm/schema/nodes/blockquote.js +1 -0
- package/dist/esm/schema/nodes/bodied-extension.js +0 -2
- package/dist/esm/schema/nodes/caption.js +1 -0
- package/dist/esm/schema/nodes/code-block.js +11 -26
- package/dist/esm/schema/nodes/date.js +1 -0
- package/dist/esm/schema/nodes/decision-item.js +2 -2
- package/dist/esm/schema/nodes/decision-list.js +1 -0
- package/dist/esm/schema/nodes/doc.js +1 -0
- package/dist/esm/schema/nodes/embed-card.js +6 -5
- package/dist/esm/schema/nodes/emoji.js +12 -7
- package/dist/esm/schema/nodes/expand.js +1 -1
- package/dist/esm/schema/nodes/extension.js +0 -2
- package/dist/esm/schema/nodes/hard-break.js +1 -0
- package/dist/esm/schema/nodes/heading.js +2 -1
- package/dist/esm/schema/nodes/inline-card.js +4 -3
- package/dist/esm/schema/nodes/inline-extension.js +0 -2
- package/dist/esm/schema/nodes/layout-column.js +4 -4
- package/dist/esm/schema/nodes/layout-section.js +1 -0
- package/dist/esm/schema/nodes/media-group.js +1 -0
- package/dist/esm/schema/nodes/media-single.js +3 -8
- package/dist/esm/schema/nodes/media.js +10 -18
- package/dist/esm/schema/nodes/mention.js +4 -13
- package/dist/esm/schema/nodes/nested-expand.js +1 -0
- package/dist/esm/schema/nodes/ordered-list.js +3 -13
- package/dist/esm/schema/nodes/panel.js +1 -10
- package/dist/esm/schema/nodes/paragraph.js +1 -5
- package/dist/esm/schema/nodes/placeholder.js +1 -0
- package/dist/esm/schema/nodes/rule.js +1 -0
- package/dist/esm/schema/nodes/status.js +5 -4
- package/dist/esm/schema/nodes/tableNodes.js +12 -25
- package/dist/esm/schema/nodes/task-item.js +2 -2
- package/dist/esm/schema/nodes/text.js +1 -0
- package/dist/esm/steps/analytics.js +5 -31
- package/dist/esm/steps/set-attrs.js +1 -17
- package/dist/esm/steps/table/add-column.js +33 -91
- package/dist/esm/steps/table/constants.js +0 -1
- package/dist/esm/steps/table/sort-column.js +1 -10
- package/dist/esm/steps/table/utils/cell-step.js +18 -42
- package/dist/esm/steps/table/utils/cells-at-column.js +2 -18
- package/dist/esm/steps/table/utils/find-column.js +13 -16
- package/dist/esm/steps/table/utils/get-table-rect-from-doc.js +7 -6
- package/dist/esm/steps/table/utils/side-effects/rows.js +23 -76
- package/dist/esm/steps/table/utils/side-effects/side-effects.js +0 -18
- package/dist/esm/steps/table/utils/side-effects/table.js +2 -13
- package/dist/esm/steps/type-ahead.js +6 -18
- package/dist/esm/utils/colors.js +12 -23
- package/dist/esm/utils/confluence/emoji.js +6 -10
- package/dist/esm/utils/extensions.js +0 -4
- package/dist/esm/utils/url.js +2 -12
- package/dist/esm/version.json +1 -1
- package/dist/types/schema/default-schema.d.ts +1 -1
- package/dist/types/utils/colors.d.ts +1 -1
- package/package.json +2 -2
@@ -29,34 +29,34 @@ export function findColumn(columnInfo, rect) {
|
|
29
29
|
* end = 1
|
30
30
|
* * Start === end return 1
|
31
31
|
*/
|
32
|
+
|
32
33
|
// Initial range (start and end column) to search for each row
|
33
34
|
let [start, end] = [0, rect.map.width - 1];
|
34
35
|
const iter = columnInfo.values();
|
35
|
-
let next = iter.next();
|
36
|
+
let next = iter.next();
|
36
37
|
|
38
|
+
// Iterate for each row
|
37
39
|
for (let row = 0; row < rect.map.height; row++) {
|
38
40
|
if (next.done) {
|
39
41
|
break;
|
40
|
-
}
|
41
|
-
|
42
|
-
|
42
|
+
}
|
43
|
+
// Iterate for the column. Starting with the current start range
|
43
44
|
for (let col = start; col <= end; col++) {
|
44
45
|
const i = row * rect.map.width + col;
|
45
46
|
const cell = rect.map.map[i];
|
46
|
-
const cellInfo = next.value.from - rect.tableStart;
|
47
|
+
const cellInfo = next.value.from - rect.tableStart;
|
47
48
|
|
49
|
+
// When cell is found update range with the new values
|
48
50
|
if (cell === cellInfo) {
|
49
51
|
start = col; // Start column will be the current column
|
50
52
|
// Try to find the end column. End column will be different that start when has merged cells.
|
51
|
-
|
52
53
|
const endIndex = end - start + i;
|
53
|
-
|
54
54
|
for (let j = i; j <= endIndex; j++) {
|
55
55
|
if (rect.map.map[j] !== cell) {
|
56
56
|
break;
|
57
|
-
}
|
58
|
-
|
57
|
+
}
|
59
58
|
|
59
|
+
// merged columns
|
60
60
|
end = start + j - i; // Update the end column with the new position
|
61
61
|
}
|
62
62
|
|
@@ -64,23 +64,20 @@ export function findColumn(columnInfo, rect) {
|
|
64
64
|
// We found the right column only when start and end columns are the same.
|
65
65
|
return start;
|
66
66
|
}
|
67
|
-
|
68
67
|
next = iter.next();
|
69
68
|
break;
|
70
|
-
}
|
69
|
+
}
|
70
|
+
|
71
|
+
// Sometimes I want to find a column at the end of the table (It doesn't exist, but we can add a new cell there).
|
71
72
|
// This is represented by the end position of the last cell in the column.
|
72
73
|
// In this case return, table width
|
73
|
-
|
74
|
-
|
75
74
|
if (col === rect.map.width - 1) {
|
76
75
|
const cellNode = rect.table.nodeAt(cell);
|
77
|
-
|
78
76
|
if (cell + cellNode.nodeSize === cellInfo) {
|
79
77
|
return rect.map.width;
|
80
78
|
}
|
81
79
|
}
|
82
80
|
}
|
83
81
|
}
|
84
|
-
|
85
82
|
return null;
|
86
83
|
}
|
@@ -1,21 +1,22 @@
|
|
1
1
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
2
|
+
|
2
3
|
/**
|
3
4
|
* Util to get the table rect from the docs
|
4
5
|
* @param doc
|
5
6
|
* @param tablePos
|
6
7
|
*/
|
7
|
-
|
8
8
|
export function getTableRectFromDoc(doc, tablePos) {
|
9
|
-
const table = doc.nodeAt(tablePos);
|
9
|
+
const table = doc.nodeAt(tablePos);
|
10
10
|
|
11
|
+
// Check for table existence
|
11
12
|
if (!table || table.type.name !== 'table') {
|
12
13
|
throw new Error(`No table at position "${tablePos}".`);
|
13
|
-
}
|
14
|
-
|
14
|
+
}
|
15
15
|
|
16
|
+
// Create transform base on the doc
|
16
17
|
const map = TableMap.get(table);
|
17
|
-
const $table = doc.resolve(tablePos);
|
18
|
-
|
18
|
+
const $table = doc.resolve(tablePos);
|
19
|
+
// Nested tables start position might differ from the original position
|
19
20
|
const start = $table.start($table.depth + 1);
|
20
21
|
return {
|
21
22
|
map,
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import { hasMergedColumns } from '../table-map';
|
3
|
-
|
4
3
|
function mergedRanges(first, second) {
|
5
4
|
const newRanges = [];
|
6
5
|
const firstLength = first.length;
|
7
6
|
const secondLength = second.length;
|
8
7
|
let i = 0;
|
9
8
|
let j = 0;
|
10
|
-
|
11
9
|
while (i < firstLength && j < secondLength) {
|
12
10
|
if (first[i] < second[j]) {
|
13
11
|
newRanges.push(first[i], first[i + 1], first[i + 2]);
|
@@ -17,36 +15,31 @@ function mergedRanges(first, second) {
|
|
17
15
|
j += 3;
|
18
16
|
}
|
19
17
|
}
|
20
|
-
|
21
18
|
if (i < firstLength) {
|
22
19
|
newRanges.push(...first.slice(i));
|
23
20
|
}
|
24
|
-
|
25
21
|
if (j < secondLength) {
|
26
22
|
newRanges.push(...second.slice(i));
|
27
23
|
}
|
28
|
-
|
29
24
|
return newRanges;
|
30
25
|
}
|
31
|
-
|
32
26
|
function increaseRowSpan(tr, rect, row) {
|
33
27
|
const {
|
34
28
|
map,
|
35
29
|
tableStart
|
36
30
|
} = rect;
|
37
|
-
|
38
31
|
for (let col = 0; col < map.width; col++) {
|
39
32
|
let index = row * map.width + col;
|
40
33
|
let pos = map.map[index];
|
41
34
|
const mappedPos = tr.mapping.map(pos + tableStart);
|
42
35
|
let attrs = tr.doc.nodeAt(mappedPos).attrs;
|
43
|
-
tr.setNodeMarkup(mappedPos, undefined, {
|
36
|
+
tr.setNodeMarkup(mappedPos, undefined, {
|
37
|
+
...attrs,
|
44
38
|
rowspan: attrs.rowspan + 1
|
45
39
|
});
|
46
40
|
col += attrs.colspan - 1;
|
47
41
|
}
|
48
42
|
}
|
49
|
-
|
50
43
|
function decreaseRowspan(tr, rect, row, colToRemove) {
|
51
44
|
let skipRows = 0;
|
52
45
|
const {
|
@@ -54,16 +47,15 @@ function decreaseRowspan(tr, rect, row, colToRemove) {
|
|
54
47
|
table,
|
55
48
|
tableStart
|
56
49
|
} = rect;
|
57
|
-
|
58
50
|
for (let col = 0; col < map.width; col++) {
|
59
51
|
let index = row * map.width + col;
|
60
52
|
let pos = map.map[index];
|
61
|
-
|
62
53
|
if (row > 0 && pos === map.map[index - map.width]) {
|
63
54
|
// If this cell starts in the row above, simply reduce its rowspan
|
64
55
|
const mappedPos = tr.mapping.map(pos + tableStart);
|
65
56
|
let attrs = tr.doc.nodeAt(mappedPos).attrs;
|
66
|
-
tr.setNodeMarkup(mappedPos, undefined, {
|
57
|
+
tr.setNodeMarkup(mappedPos, undefined, {
|
58
|
+
...attrs,
|
67
59
|
rowspan: attrs.rowspan - 1
|
68
60
|
});
|
69
61
|
col += attrs.colspan - 1;
|
@@ -71,34 +63,29 @@ function decreaseRowspan(tr, rect, row, colToRemove) {
|
|
71
63
|
skipRows = table.nodeAt(pos).attrs.rowspan - 1;
|
72
64
|
}
|
73
65
|
}
|
74
|
-
|
75
66
|
return skipRows;
|
76
67
|
}
|
77
|
-
|
78
68
|
function isLastCellInRow(rect, row, col) {
|
79
69
|
const rowNode = rect.table.child(row);
|
80
|
-
|
81
70
|
if (!rowNode) {
|
82
71
|
return false;
|
83
72
|
}
|
84
|
-
|
85
73
|
return rowNode.childCount === 1 && !hasMergedColumns(rect.map, row, col);
|
86
74
|
}
|
87
|
-
|
88
75
|
function removeRowWithLastCell(tr, rect, row, _col) {
|
89
76
|
// Get row pos
|
90
77
|
let from = rect.tableStart;
|
91
|
-
|
92
78
|
for (let i = 0; i < row; i++) {
|
93
79
|
from += rect.table.child(i).nodeSize;
|
94
80
|
}
|
95
|
-
|
96
81
|
const rowNode = rect.table.child(row);
|
97
|
-
let to = from + rowNode.nodeSize;
|
98
|
-
// We store original row position before modifications
|
82
|
+
let to = from + rowNode.nodeSize;
|
99
83
|
|
100
|
-
|
84
|
+
// Create sideEffect and delete the row
|
85
|
+
// We store original row position before modifications
|
86
|
+
tr.delete(tr.mapping.map(from), tr.mapping.map(to));
|
101
87
|
|
88
|
+
// Change rowspan of all cells except current col and get the rows to skip
|
102
89
|
const skipRows = decreaseRowspan(tr, rect, row, _col);
|
103
90
|
return {
|
104
91
|
skipRows,
|
@@ -109,14 +96,12 @@ function removeRowWithLastCell(tr, rect, row, _col) {
|
|
109
96
|
}
|
110
97
|
};
|
111
98
|
}
|
112
|
-
|
113
99
|
function addRow(tr, rect, prevRow, rowSideEffect) {
|
114
100
|
const cellNode = rowSideEffect.rowNode.child(0);
|
115
101
|
tr.insert(tr.mapping.map(rowSideEffect.from), rowSideEffect.rowNode);
|
116
102
|
increaseRowSpan(tr, rect, prevRow);
|
117
103
|
return cellNode.attrs.rowspan - 1;
|
118
104
|
}
|
119
|
-
|
120
105
|
export class RowsSideEffectHandler {
|
121
106
|
constructor(rowsSideEffect) {
|
122
107
|
_defineProperty(this, "deleteHandler", () => {
|
@@ -128,7 +113,6 @@ export class RowsSideEffectHandler {
|
|
128
113
|
handled: false
|
129
114
|
};
|
130
115
|
}
|
131
|
-
|
132
116
|
const {
|
133
117
|
row: rowSideEffect,
|
134
118
|
skipRows
|
@@ -148,7 +132,6 @@ export class RowsSideEffectHandler {
|
|
148
132
|
}
|
149
133
|
};
|
150
134
|
});
|
151
|
-
|
152
135
|
_defineProperty(this, "addHandler", () => {
|
153
136
|
let lastCellFrom = 0;
|
154
137
|
let i = 0;
|
@@ -159,26 +142,22 @@ export class RowsSideEffectHandler {
|
|
159
142
|
return {
|
160
143
|
handled: false
|
161
144
|
};
|
162
|
-
}
|
163
|
-
|
145
|
+
}
|
164
146
|
|
147
|
+
// Next row to add;
|
165
148
|
let skipRows;
|
166
149
|
let nextRow;
|
167
|
-
|
168
150
|
while ((nextRow = this.rows[i]) && nextRow.from > lastCellFrom && nextRow.from < cell.from) {
|
169
151
|
// I am in between of the previous and next row in the table;
|
170
152
|
skipRows = addRow(tr, rect, row - 1, nextRow);
|
171
153
|
i++;
|
172
154
|
}
|
173
|
-
|
174
155
|
lastCellFrom = cell.from;
|
175
|
-
|
176
156
|
if (!skipRows || skipRows === 0) {
|
177
157
|
return {
|
178
158
|
handled: false
|
179
159
|
};
|
180
160
|
}
|
181
|
-
|
182
161
|
return {
|
183
162
|
handled: true,
|
184
163
|
skipRows: skipRows - 1
|
@@ -187,11 +166,10 @@ export class RowsSideEffectHandler {
|
|
187
166
|
end: (tr, rect, col) => {
|
188
167
|
if (!this.rows || i >= this.rows.length) {
|
189
168
|
return;
|
190
|
-
}
|
191
|
-
|
169
|
+
}
|
192
170
|
|
171
|
+
// Add rows at the end of the table
|
193
172
|
let nextRow;
|
194
|
-
|
195
173
|
while (nextRow = this.rows[i]) {
|
196
174
|
addRow(tr, rect, rect.map.height - 1, nextRow);
|
197
175
|
i++;
|
@@ -199,76 +177,63 @@ export class RowsSideEffectHandler {
|
|
199
177
|
}
|
200
178
|
};
|
201
179
|
});
|
202
|
-
|
203
180
|
this.rows = rowsSideEffect;
|
204
181
|
}
|
205
|
-
|
206
182
|
start(isDelete) {
|
207
183
|
if (isDelete) {
|
208
184
|
return this.deleteHandler();
|
209
185
|
}
|
210
|
-
|
211
186
|
return this.addHandler();
|
212
187
|
}
|
213
|
-
|
214
188
|
addRowRanges(ranges, isDelete) {
|
215
189
|
if (!this.rows) {
|
216
190
|
return ranges;
|
217
191
|
}
|
218
|
-
|
219
192
|
const rowRanges = [];
|
220
|
-
|
221
193
|
for (const row of this.rows) {
|
222
194
|
const {
|
223
195
|
from,
|
224
196
|
to
|
225
197
|
} = row;
|
226
|
-
|
227
198
|
if (isDelete) {
|
228
199
|
rowRanges.push(from, to - from, 0);
|
229
200
|
} else {
|
230
201
|
rowRanges.push(from, 0, to - from);
|
231
202
|
}
|
232
|
-
}
|
233
|
-
|
203
|
+
}
|
234
204
|
|
205
|
+
// Merged ranges
|
235
206
|
return mergedRanges(ranges, rowRanges);
|
236
207
|
}
|
237
|
-
|
238
208
|
map(mapping) {
|
239
209
|
return [];
|
240
210
|
}
|
241
|
-
|
242
211
|
invert(originalDoc, isDelete, map) {
|
243
212
|
if (!this.rows) {
|
244
213
|
return;
|
245
214
|
}
|
246
|
-
|
247
215
|
const invertedRows = [];
|
248
|
-
|
249
216
|
for (const row of this.rows) {
|
250
217
|
if (isDelete) {
|
251
218
|
// Moving from delete to add keep the inverted rows + offset
|
252
219
|
let offset = map.map(row.from) - row.from;
|
253
|
-
invertedRows.push({
|
220
|
+
invertedRows.push({
|
221
|
+
...row,
|
254
222
|
from: row.from + offset,
|
255
223
|
to: row.from + offset
|
256
224
|
});
|
257
|
-
} else {
|
225
|
+
} else {
|
226
|
+
// Moving from add to delete keep
|
258
227
|
// TODO: I think we need to add the respective cell into the cellSteps...... not sure....
|
259
228
|
}
|
260
229
|
}
|
261
|
-
|
262
230
|
return invertedRows;
|
263
231
|
}
|
264
|
-
|
265
232
|
toJSON() {
|
266
233
|
if (!this.rows) {
|
267
234
|
return;
|
268
235
|
}
|
269
|
-
|
270
236
|
const rowsInJson = [];
|
271
|
-
|
272
237
|
for (const row of this.rows) {
|
273
238
|
rowsInJson.push({
|
274
239
|
from: row.from,
|
@@ -276,13 +241,10 @@ export class RowsSideEffectHandler {
|
|
276
241
|
rowNode: row.rowNode.toJSON()
|
277
242
|
});
|
278
243
|
}
|
279
|
-
|
280
244
|
return rowsInJson;
|
281
245
|
}
|
282
|
-
|
283
246
|
static fromJSON(schema, json) {
|
284
247
|
const rowSideEffects = [];
|
285
|
-
|
286
248
|
for (const row of json) {
|
287
249
|
rowSideEffects.push({
|
288
250
|
from: row.from,
|
@@ -290,8 +252,6 @@ export class RowsSideEffectHandler {
|
|
290
252
|
rowNode: schema.nodeFromJSON(row.rowNode)
|
291
253
|
});
|
292
254
|
}
|
293
|
-
|
294
255
|
return rowSideEffects;
|
295
256
|
}
|
296
|
-
|
297
257
|
}
|
@@ -5,77 +5,56 @@ export class SideEffectsHandler {
|
|
5
5
|
this.table = new TableSideEffectHandler(sideEffects && sideEffects.table);
|
6
6
|
this.rows = new RowsSideEffectHandler(sideEffects && sideEffects.rows);
|
7
7
|
}
|
8
|
-
|
9
8
|
getTableMap(isDelete) {
|
10
9
|
return this.table.getTableMap(isDelete);
|
11
10
|
}
|
12
|
-
|
13
11
|
map(mapping) {
|
14
12
|
const sideEffects = {};
|
15
13
|
const tableSideEffect = this.table.map(mapping);
|
16
14
|
const rowsSideEffect = this.rows.map(mapping);
|
17
|
-
|
18
15
|
if (tableSideEffect) {
|
19
16
|
sideEffects.table = tableSideEffect;
|
20
17
|
}
|
21
|
-
|
22
18
|
if (rowsSideEffect) {
|
23
19
|
sideEffects.rows = rowsSideEffect;
|
24
20
|
}
|
25
|
-
|
26
21
|
return sideEffects;
|
27
22
|
}
|
28
|
-
|
29
23
|
invert(originalDoc, isDelete, map) {
|
30
24
|
const sideEffects = {};
|
31
25
|
const tableSideEffect = this.table.invert(originalDoc);
|
32
|
-
|
33
26
|
if (tableSideEffect) {
|
34
27
|
sideEffects.table = tableSideEffect;
|
35
28
|
}
|
36
|
-
|
37
29
|
const rowsSideEffect = this.rows.invert(originalDoc, isDelete, map);
|
38
|
-
|
39
30
|
if (rowsSideEffect) {
|
40
31
|
sideEffects.rows = rowsSideEffect;
|
41
32
|
}
|
42
|
-
|
43
33
|
return sideEffects;
|
44
34
|
}
|
45
|
-
|
46
35
|
toJSON() {
|
47
36
|
const tableSideEffectJson = this.table.toJSON();
|
48
37
|
const rowsSideEffectJson = this.rows.toJSON();
|
49
|
-
|
50
38
|
if (!tableSideEffectJson && !rowsSideEffectJson) {
|
51
39
|
return;
|
52
40
|
}
|
53
|
-
|
54
41
|
const sideEffectsJSON = {};
|
55
|
-
|
56
42
|
if (tableSideEffectJson) {
|
57
43
|
sideEffectsJSON.table = tableSideEffectJson;
|
58
44
|
}
|
59
|
-
|
60
45
|
if (rowsSideEffectJson) {
|
61
46
|
sideEffectsJSON.rows = rowsSideEffectJson;
|
62
47
|
}
|
63
|
-
|
64
48
|
return sideEffectsJSON;
|
65
49
|
}
|
66
|
-
|
67
50
|
static fromJSON(schema, json) {
|
68
51
|
const sideEffects = {};
|
69
|
-
|
70
52
|
if (json.table) {
|
71
53
|
sideEffects.table = TableSideEffectHandler.fromJSON(schema, json.table);
|
72
54
|
}
|
73
|
-
|
74
55
|
if (json.rows) {
|
75
56
|
sideEffects.rows = RowsSideEffectHandler.fromJSON(schema, json.rows);
|
76
57
|
}
|
77
|
-
|
78
58
|
return sideEffects;
|
79
59
|
}
|
80
|
-
|
81
60
|
}
|
@@ -5,7 +5,6 @@ export class TableSideEffectHandler {
|
|
5
5
|
this.table = tableSideEffect;
|
6
6
|
}
|
7
7
|
}
|
8
|
-
|
9
8
|
addTableSideEffect(from, to, node) {
|
10
9
|
this.table = {
|
11
10
|
from,
|
@@ -13,16 +12,13 @@ export class TableSideEffectHandler {
|
|
13
12
|
node
|
14
13
|
};
|
15
14
|
}
|
16
|
-
|
17
15
|
handleAddTable(tr, isDelete) {
|
18
16
|
if (isDelete || !this.table) {
|
19
17
|
return false;
|
20
18
|
}
|
21
|
-
|
22
19
|
tr.insert(this.table.from, this.table.node);
|
23
20
|
return true;
|
24
21
|
}
|
25
|
-
|
26
22
|
handleRemoveTable(tr, tablePos, tableRect, column, isDelete) {
|
27
23
|
if (isDelete && tableRect.map.width === 1 && column === 0) {
|
28
24
|
// Add side effect
|
@@ -30,44 +26,35 @@ export class TableSideEffectHandler {
|
|
30
26
|
tr.delete(tablePos, tablePos + tableRect.table.nodeSize);
|
31
27
|
return true;
|
32
28
|
}
|
33
|
-
|
34
29
|
return false;
|
35
30
|
}
|
36
|
-
|
37
31
|
getTableMap(isDelete) {
|
38
32
|
if (!this.table) {
|
39
33
|
return;
|
40
34
|
}
|
41
|
-
|
42
35
|
const {
|
43
36
|
from,
|
44
37
|
to
|
45
38
|
} = this.table;
|
46
|
-
|
47
39
|
if (isDelete) {
|
48
40
|
return new StepMap([from, to - from, 0]);
|
49
41
|
}
|
50
|
-
|
51
42
|
return new StepMap([from, 0, to - from]);
|
52
43
|
}
|
53
|
-
|
54
44
|
map(mapping) {
|
55
45
|
if (!this.table) {
|
56
46
|
return;
|
57
47
|
}
|
58
|
-
|
59
48
|
return {
|
60
49
|
from: mapping.map(this.table.from),
|
61
50
|
to: mapping.map(this.table.to),
|
62
51
|
node: this.table.node
|
63
52
|
};
|
64
53
|
}
|
65
|
-
|
66
54
|
invert(doc) {
|
67
55
|
if (!this.table) {
|
68
56
|
return;
|
69
57
|
}
|
70
|
-
|
71
58
|
const tableNode = doc.nodeAt(this.table.from);
|
72
59
|
return {
|
73
60
|
from: this.table.from,
|
@@ -75,19 +62,16 @@ export class TableSideEffectHandler {
|
|
75
62
|
node: tableNode.copy(tableNode.content)
|
76
63
|
};
|
77
64
|
}
|
78
|
-
|
79
65
|
toJSON() {
|
80
66
|
if (!this.table) {
|
81
67
|
return;
|
82
68
|
}
|
83
|
-
|
84
69
|
return {
|
85
70
|
from: this.table.from,
|
86
71
|
to: this.table.to,
|
87
72
|
node: this.table.node.toJSON()
|
88
73
|
};
|
89
74
|
}
|
90
|
-
|
91
75
|
static fromJSON(schema, json) {
|
92
76
|
return {
|
93
77
|
from: json.from,
|
@@ -95,5 +79,4 @@ export class TableSideEffectHandler {
|
|
95
79
|
node: schema.nodeFromJSON(json.node)
|
96
80
|
};
|
97
81
|
}
|
98
|
-
|
99
82
|
}
|
@@ -2,12 +2,10 @@ import { Slice } from 'prosemirror-model';
|
|
2
2
|
import { ReplaceStep, Step, StepMap, StepResult } from 'prosemirror-transform';
|
3
3
|
export const insertTypeAheadStepType = 'atlaskit-insert-type-ahead';
|
4
4
|
export let InsertTypeAheadStages;
|
5
|
-
|
6
5
|
(function (InsertTypeAheadStages) {
|
7
6
|
InsertTypeAheadStages["DELETING_RAW_QUERY"] = "DELETING_RAW_QUERY";
|
8
7
|
InsertTypeAheadStages["INSERTING_ITEM"] = "INSERTING_ITEM";
|
9
8
|
})(InsertTypeAheadStages || (InsertTypeAheadStages = {}));
|
10
|
-
|
11
9
|
export class InsertTypeAheadStep extends Step {
|
12
10
|
constructor({
|
13
11
|
stage,
|
@@ -22,7 +20,6 @@ export class InsertTypeAheadStep extends Step {
|
|
22
20
|
this.trigger = trigger;
|
23
21
|
this.selectedIndex = selectedIndex;
|
24
22
|
}
|
25
|
-
|
26
23
|
invert() {
|
27
24
|
const config = {
|
28
25
|
stage: this.stage,
|
@@ -32,38 +29,31 @@ export class InsertTypeAheadStep extends Step {
|
|
32
29
|
};
|
33
30
|
return new InsertTypeAheadStep(config, !this.isInvertStep);
|
34
31
|
}
|
35
|
-
|
36
32
|
apply(doc) {
|
37
33
|
return StepResult.ok(doc);
|
38
34
|
}
|
39
|
-
|
40
35
|
merge() {
|
41
36
|
return null;
|
42
37
|
}
|
43
|
-
|
44
38
|
isInsertionStep() {
|
45
39
|
return !this.isInvertStep;
|
46
40
|
}
|
47
|
-
|
48
41
|
isUndoingStep() {
|
49
42
|
return this.isInvertStep;
|
50
43
|
}
|
51
|
-
|
52
44
|
map(mapping) {
|
53
45
|
const config = {
|
54
46
|
stage: this.stage,
|
55
47
|
query: this.query,
|
56
48
|
trigger: this.trigger,
|
57
49
|
selectedIndex: this.selectedIndex
|
58
|
-
};
|
59
|
-
|
50
|
+
};
|
51
|
+
// Return the same events, this step will never be removed
|
60
52
|
return new InsertTypeAheadStep(config, this.isInvertStep);
|
61
53
|
}
|
62
|
-
|
63
54
|
getMap() {
|
64
55
|
return new StepMap([0, 0, 0]);
|
65
56
|
}
|
66
|
-
|
67
57
|
toJSON() {
|
68
58
|
// When serialized we should create a noop Replace step
|
69
59
|
return {
|
@@ -72,14 +62,12 @@ export class InsertTypeAheadStep extends Step {
|
|
72
62
|
to: 0
|
73
63
|
};
|
74
64
|
}
|
75
|
-
|
76
65
|
static fromJSON() {
|
77
66
|
// This is a "local custom step" once serialized
|
78
67
|
// we need to transform it in a no-operation action
|
79
68
|
return new ReplaceStep(0, 0, Slice.empty);
|
80
69
|
}
|
81
|
-
|
82
70
|
}
|
83
|
-
/** Register this step with Prosemirror */
|
84
71
|
|
72
|
+
/** Register this step with Prosemirror */
|
85
73
|
Step.jsonID(insertTypeAheadStepType, InsertTypeAheadStep);
|