@pie-element/ebsr 6.6.3-next.411 → 6.6.3-next.412
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/configure/node_modules/immutable/LICENSE +21 -0
- package/configure/node_modules/immutable/README.md +657 -0
- package/configure/node_modules/immutable/dist/immutable-nonambient.d.ts +5607 -0
- package/configure/node_modules/immutable/dist/immutable.d.ts +5611 -0
- package/configure/node_modules/immutable/dist/immutable.es.js +5893 -0
- package/configure/node_modules/immutable/dist/immutable.js +5948 -0
- package/configure/node_modules/immutable/dist/immutable.js.flow +2340 -0
- package/configure/node_modules/immutable/dist/immutable.min.js +55 -0
- package/configure/node_modules/immutable/package.json +41 -0
- package/configure/node_modules/slate-edit-list/CHANGELOG.md +124 -0
- package/configure/node_modules/slate-edit-list/LICENSE +201 -0
- package/configure/node_modules/slate-edit-list/README.md +159 -0
- package/configure/node_modules/slate-edit-list/dist/changes/decreaseItemDepth.js +73 -0
- package/configure/node_modules/slate-edit-list/dist/changes/decreaseItemDepth.js.flow +88 -0
- package/configure/node_modules/slate-edit-list/dist/changes/increaseItemDepth.js +70 -0
- package/configure/node_modules/slate-edit-list/dist/changes/increaseItemDepth.js.flow +77 -0
- package/configure/node_modules/slate-edit-list/dist/changes/index.js +34 -0
- package/configure/node_modules/slate-edit-list/dist/changes/index.js.flow +13 -0
- package/configure/node_modules/slate-edit-list/dist/changes/splitListItem.js +27 -0
- package/configure/node_modules/slate-edit-list/dist/changes/splitListItem.js.flow +26 -0
- package/configure/node_modules/slate-edit-list/dist/changes/unwrapList.js +52 -0
- package/configure/node_modules/slate-edit-list/dist/changes/unwrapList.js.flow +46 -0
- package/configure/node_modules/slate-edit-list/dist/changes/wrapInList.js +67 -0
- package/configure/node_modules/slate-edit-list/dist/changes/wrapInList.js.flow +67 -0
- package/configure/node_modules/slate-edit-list/dist/core.js +80 -0
- package/configure/node_modules/slate-edit-list/dist/core.js.flow +76 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/index.js +24 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/index.js.flow +5 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/onBackspace.js +45 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/onBackspace.js.flow +44 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/onEnter.js +54 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/onEnter.js.flow +54 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/onTab.js +39 -0
- package/configure/node_modules/slate-edit-list/dist/handlers/onTab.js.flow +34 -0
- package/configure/node_modules/slate-edit-list/dist/index.js +58 -0
- package/configure/node_modules/slate-edit-list/dist/index.js.flow +45 -0
- package/configure/node_modules/slate-edit-list/dist/options.js +34 -0
- package/configure/node_modules/slate-edit-list/dist/options.js.flow +26 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getCurrentItem.js +24 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getCurrentItem.js.flow +20 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getCurrentList.js +31 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getCurrentList.js.flow +21 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getItemDepth.js +34 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getItemDepth.js.flow +24 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getItemsAtRange.js +60 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getItemsAtRange.js.flow +51 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getListForItem.js +25 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getListForItem.js.flow +16 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getPreviousItem.js +39 -0
- package/configure/node_modules/slate-edit-list/dist/utils/getPreviousItem.js.flow +29 -0
- package/configure/node_modules/slate-edit-list/dist/utils/index.js +49 -0
- package/configure/node_modules/slate-edit-list/dist/utils/index.js.flow +19 -0
- package/configure/node_modules/slate-edit-list/dist/utils/isList.js +15 -0
- package/configure/node_modules/slate-edit-list/dist/utils/isList.js.flow +13 -0
- package/configure/node_modules/slate-edit-list/dist/utils/isSelectionInList.js +22 -0
- package/configure/node_modules/slate-edit-list/dist/utils/isSelectionInList.js.flow +14 -0
- package/configure/node_modules/slate-edit-list/dist/validation/index.js +19 -0
- package/configure/node_modules/slate-edit-list/dist/validation/index.js.flow +4 -0
- package/configure/node_modules/slate-edit-list/dist/validation/schema.js +83 -0
- package/configure/node_modules/slate-edit-list/dist/validation/schema.js.flow +81 -0
- package/configure/node_modules/slate-edit-list/dist/validation/validateNode.js +61 -0
- package/configure/node_modules/slate-edit-list/dist/validation/validateNode.js.flow +61 -0
- package/configure/node_modules/slate-edit-list/package.json +67 -0
- package/configure/node_modules/slate-edit-table/CHANGELOG.md +192 -0
- package/configure/node_modules/slate-edit-table/LICENSE +201 -0
- package/configure/node_modules/slate-edit-table/README.md +269 -0
- package/configure/node_modules/slate-edit-table/dist/changes/clearCell.js +29 -0
- package/configure/node_modules/slate-edit-table/dist/changes/clearCell.js.flow +26 -0
- package/configure/node_modules/slate-edit-table/dist/changes/index.js +69 -0
- package/configure/node_modules/slate-edit-table/dist/changes/index.js.flow +27 -0
- package/configure/node_modules/slate-edit-table/dist/changes/insertColumn.js +43 -0
- package/configure/node_modules/slate-edit-table/dist/changes/insertColumn.js.flow +46 -0
- package/configure/node_modules/slate-edit-table/dist/changes/insertRow.js +36 -0
- package/configure/node_modules/slate-edit-table/dist/changes/insertRow.js.flow +35 -0
- package/configure/node_modules/slate-edit-table/dist/changes/insertTable.js +29 -0
- package/configure/node_modules/slate-edit-table/dist/changes/insertTable.js.flow +27 -0
- package/configure/node_modules/slate-edit-table/dist/changes/moveSelection.js +32 -0
- package/configure/node_modules/slate-edit-table/dist/changes/moveSelection.js.flow +31 -0
- package/configure/node_modules/slate-edit-table/dist/changes/moveSelectionBy.js +84 -0
- package/configure/node_modules/slate-edit-table/dist/changes/moveSelectionBy.js.flow +80 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeColumn.js +36 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeColumn.js.flow +28 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeColumnByKey.js +52 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeColumnByKey.js.flow +40 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeRow.js +36 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeRow.js.flow +27 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeRowByKey.js +41 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeRowByKey.js.flow +30 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeTable.js +26 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeTable.js.flow +17 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeTableByKey.js +56 -0
- package/configure/node_modules/slate-edit-table/dist/changes/removeTableByKey.js.flow +54 -0
- package/configure/node_modules/slate-edit-table/dist/core.js +88 -0
- package/configure/node_modules/slate-edit-table/dist/core.js.flow +94 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/index.js +39 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/index.js.flow +8 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onBackspace.js +82 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onBackspace.js.flow +87 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onEnter.js +34 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onEnter.js.flow +37 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onKeyDown.js +71 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onKeyDown.js.flow +56 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onModEnter.js +35 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onModEnter.js.flow +38 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onTab.js +56 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onTab.js.flow +51 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onUpDown.js +38 -0
- package/configure/node_modules/slate-edit-table/dist/handlers/onUpDown.js.flow +41 -0
- package/configure/node_modules/slate-edit-table/dist/index.js +36 -0
- package/configure/node_modules/slate-edit-table/dist/index.js.flow +27 -0
- package/configure/node_modules/slate-edit-table/dist/options.js +61 -0
- package/configure/node_modules/slate-edit-table/dist/options.js.flow +42 -0
- package/configure/node_modules/slate-edit-table/dist/utils/TablePosition.js +306 -0
- package/configure/node_modules/slate-edit-table/dist/utils/TablePosition.js.flow +211 -0
- package/configure/node_modules/slate-edit-table/dist/utils/createCell.js +30 -0
- package/configure/node_modules/slate-edit-table/dist/utils/createCell.js.flow +26 -0
- package/configure/node_modules/slate-edit-table/dist/utils/createRow.js +30 -0
- package/configure/node_modules/slate-edit-table/dist/utils/createRow.js.flow +28 -0
- package/configure/node_modules/slate-edit-table/dist/utils/createTable.js +30 -0
- package/configure/node_modules/slate-edit-table/dist/utils/createTable.js.flow +33 -0
- package/configure/node_modules/slate-edit-table/dist/utils/forEachCells.js +21 -0
- package/configure/node_modules/slate-edit-table/dist/utils/forEachCells.js.flow +22 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtColumn.js +22 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtColumn.js.flow +19 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtRow.js +20 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtRow.js.flow +19 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getPosition.js +24 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getPosition.js.flow +19 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getPositionByKey.js +26 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getPositionByKey.js.flow +21 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getRow.js +24 -0
- package/configure/node_modules/slate-edit-table/dist/utils/getRow.js.flow +19 -0
- package/configure/node_modules/slate-edit-table/dist/utils/index.js +64 -0
- package/configure/node_modules/slate-edit-table/dist/utils/index.js.flow +25 -0
- package/configure/node_modules/slate-edit-table/dist/utils/isSelectionInTable.js +34 -0
- package/configure/node_modules/slate-edit-table/dist/utils/isSelectionInTable.js.flow +27 -0
- package/configure/node_modules/slate-edit-table/dist/utils/isSelectionOutOfTable.js +30 -0
- package/configure/node_modules/slate-edit-table/dist/utils/isSelectionOutOfTable.js.flow +23 -0
- package/configure/node_modules/slate-edit-table/dist/validation/index.js +19 -0
- package/configure/node_modules/slate-edit-table/dist/validation/index.js.flow +4 -0
- package/configure/node_modules/slate-edit-table/dist/validation/schema.js +101 -0
- package/configure/node_modules/slate-edit-table/dist/validation/schema.js.flow +98 -0
- package/configure/node_modules/slate-edit-table/dist/validation/validateNode.js +56 -0
- package/configure/node_modules/slate-edit-table/dist/validation/validateNode.js.flow +49 -0
- package/configure/node_modules/slate-edit-table/package.json +69 -0
- package/package.json +2 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change, type Block } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition, createCell } from '../utils';
|
|
5
|
+
import moveSelection from './moveSelection';
|
|
6
|
+
|
|
7
|
+
import type Options from '../options';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Insert a new column in current table
|
|
11
|
+
*/
|
|
12
|
+
function insertColumn(
|
|
13
|
+
opts: Options,
|
|
14
|
+
change: Change,
|
|
15
|
+
at?: number, // Column index
|
|
16
|
+
getCell?: (column: number, row: number) => Block
|
|
17
|
+
): Change {
|
|
18
|
+
const { value } = change;
|
|
19
|
+
const { startKey } = value;
|
|
20
|
+
|
|
21
|
+
const pos = TablePosition.create(opts, value.document, startKey);
|
|
22
|
+
const { table } = pos;
|
|
23
|
+
|
|
24
|
+
const columnIndex =
|
|
25
|
+
typeof at === 'undefined' ? pos.getColumnIndex() + 1 : at;
|
|
26
|
+
|
|
27
|
+
// Insert the new cell
|
|
28
|
+
table.nodes.forEach((row, rowIndex) => {
|
|
29
|
+
const newCell = getCell
|
|
30
|
+
? getCell(columnIndex, rowIndex)
|
|
31
|
+
: createCell(opts);
|
|
32
|
+
change.insertNodeByKey(row.key, columnIndex, newCell, {
|
|
33
|
+
normalize: false
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Update the selection (not doing can break the undo)
|
|
38
|
+
return moveSelection(
|
|
39
|
+
opts,
|
|
40
|
+
change,
|
|
41
|
+
pos.getColumnIndex() + 1,
|
|
42
|
+
pos.getRowIndex()
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default insertColumn;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Insert a new row in current table
|
|
13
|
+
*/
|
|
14
|
+
function insertRow(opts, change, at, // row index
|
|
15
|
+
getRow // Generate the row yourself
|
|
16
|
+
) {
|
|
17
|
+
var value = change.value;
|
|
18
|
+
var startKey = value.startKey;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var pos = _utils.TablePosition.create(opts, value.document, startKey);
|
|
22
|
+
var table = pos.table;
|
|
23
|
+
|
|
24
|
+
// Create a new row with the right count of cells
|
|
25
|
+
|
|
26
|
+
var columns = table.nodes.get(0).nodes.size;
|
|
27
|
+
var newRow = getRow ? getRow(columns) : (0, _utils.createRow)(opts, columns);
|
|
28
|
+
|
|
29
|
+
if (typeof at === 'undefined') {
|
|
30
|
+
at = pos.getRowIndex() + 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return change.insertNodeByKey(table.key, at, newRow).collapseToEndOf(newRow.nodes.get(pos.getColumnIndex()));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.default = insertRow;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change, type Block } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition, createRow } from '../utils';
|
|
5
|
+
import type Options from '../options';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Insert a new row in current table
|
|
9
|
+
*/
|
|
10
|
+
function insertRow(
|
|
11
|
+
opts: Options,
|
|
12
|
+
change: Change,
|
|
13
|
+
at?: number, // row index
|
|
14
|
+
getRow?: (columns: number) => Block // Generate the row yourself
|
|
15
|
+
) {
|
|
16
|
+
const { value } = change;
|
|
17
|
+
const { startKey } = value;
|
|
18
|
+
|
|
19
|
+
const pos = TablePosition.create(opts, value.document, startKey);
|
|
20
|
+
const { table } = pos;
|
|
21
|
+
|
|
22
|
+
// Create a new row with the right count of cells
|
|
23
|
+
const columns = table.nodes.get(0).nodes.size;
|
|
24
|
+
const newRow = getRow ? getRow(columns) : createRow(opts, columns);
|
|
25
|
+
|
|
26
|
+
if (typeof at === 'undefined') {
|
|
27
|
+
at = pos.getRowIndex() + 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return change
|
|
31
|
+
.insertNodeByKey(table.key, at, newRow)
|
|
32
|
+
.collapseToEndOf(newRow.nodes.get(pos.getColumnIndex()));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default insertRow;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Insert a new table
|
|
13
|
+
*/
|
|
14
|
+
function insertTable(opts, change) {
|
|
15
|
+
var columns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
16
|
+
var rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
|
|
17
|
+
var getCellContent = arguments[4];
|
|
18
|
+
var value = change.value;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if (!value.selection.startKey) return change;
|
|
22
|
+
|
|
23
|
+
// Create the table node
|
|
24
|
+
var table = (0, _utils.createTable)(opts, columns, rows, getCellContent);
|
|
25
|
+
|
|
26
|
+
return change.insertBlock(table);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.default = insertTable;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change, type Node } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { createTable } from '../utils';
|
|
5
|
+
import type Options from '../options';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Insert a new table
|
|
9
|
+
*/
|
|
10
|
+
function insertTable(
|
|
11
|
+
opts: Options,
|
|
12
|
+
change: Change,
|
|
13
|
+
columns?: number = 2,
|
|
14
|
+
rows?: number = 2,
|
|
15
|
+
getCellContent?: (column: number, row: number) => Node[]
|
|
16
|
+
): Change {
|
|
17
|
+
const { value } = change;
|
|
18
|
+
|
|
19
|
+
if (!value.selection.startKey) return change;
|
|
20
|
+
|
|
21
|
+
// Create the table node
|
|
22
|
+
const table = createTable(opts, columns, rows, getCellContent);
|
|
23
|
+
|
|
24
|
+
return change.insertBlock(table);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default insertTable;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Move selection to {x,y}
|
|
13
|
+
*/
|
|
14
|
+
function moveSelection(opts, change, x, y) {
|
|
15
|
+
var value = change.value;
|
|
16
|
+
var startKey = value.startKey;
|
|
17
|
+
|
|
18
|
+
var pos = _utils.TablePosition.create(opts, value.document, startKey);
|
|
19
|
+
|
|
20
|
+
if (!pos.isInCell()) {
|
|
21
|
+
throw new Error('moveSelection can only be applied from within a cell');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var table = pos.table;
|
|
25
|
+
|
|
26
|
+
var row = table.nodes.get(y);
|
|
27
|
+
var cell = row.nodes.get(x);
|
|
28
|
+
|
|
29
|
+
return change.collapseToStartOf(cell);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.default = moveSelection;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition } from '../utils';
|
|
5
|
+
import type Options from '../options';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Move selection to {x,y}
|
|
9
|
+
*/
|
|
10
|
+
function moveSelection(
|
|
11
|
+
opts: Options,
|
|
12
|
+
change: Change,
|
|
13
|
+
x: number,
|
|
14
|
+
y: number
|
|
15
|
+
): Change {
|
|
16
|
+
const { value } = change;
|
|
17
|
+
const { startKey } = value;
|
|
18
|
+
const pos = TablePosition.create(opts, value.document, startKey);
|
|
19
|
+
|
|
20
|
+
if (!pos.isInCell()) {
|
|
21
|
+
throw new Error('moveSelection can only be applied from within a cell');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { table } = pos;
|
|
25
|
+
const row = table.nodes.get(y);
|
|
26
|
+
const cell = row.nodes.get(x);
|
|
27
|
+
|
|
28
|
+
return change.collapseToStartOf(cell);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default moveSelection;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
8
|
+
|
|
9
|
+
require('slate');
|
|
10
|
+
|
|
11
|
+
var _utils = require('../utils');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Move selection by a {x,y} relative movement
|
|
15
|
+
*/
|
|
16
|
+
function moveSelectionBy(opts, change, x, // Move horizontally by x
|
|
17
|
+
y // Move vertically by y
|
|
18
|
+
) {
|
|
19
|
+
var value = change.value;
|
|
20
|
+
var startKey = value.startKey;
|
|
21
|
+
|
|
22
|
+
var pos = _utils.TablePosition.create(opts, value.document, startKey);
|
|
23
|
+
if (!pos.isInCell()) {
|
|
24
|
+
throw new Error('moveSelectionBy can only be applied in a cell');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var rowIndex = pos.getRowIndex();
|
|
28
|
+
var colIndex = pos.getColumnIndex();
|
|
29
|
+
var width = pos.getWidth();
|
|
30
|
+
var height = pos.getHeight();
|
|
31
|
+
|
|
32
|
+
var _normPos = normPos(x + colIndex, y + rowIndex, width, height),
|
|
33
|
+
_normPos2 = _slicedToArray(_normPos, 2),
|
|
34
|
+
absX = _normPos2[0],
|
|
35
|
+
absY = _normPos2[1];
|
|
36
|
+
|
|
37
|
+
var isGoingUp = y < 0;
|
|
38
|
+
|
|
39
|
+
if (absX === -1) {
|
|
40
|
+
// Out of table
|
|
41
|
+
return change;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var table = pos.table;
|
|
45
|
+
|
|
46
|
+
var row = table.nodes.get(absY);
|
|
47
|
+
var cell = row.nodes.get(absX);
|
|
48
|
+
|
|
49
|
+
if (isGoingUp) {
|
|
50
|
+
change.collapseToEndOf(cell);
|
|
51
|
+
} else {
|
|
52
|
+
change.collapseToStartOf(cell);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return change;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Normalize position in a table. If x is out of the row, update y accordingly.
|
|
60
|
+
* Returns [-1, -1] if the new selection is out of table
|
|
61
|
+
*/
|
|
62
|
+
function normPos(x, y, width, height) {
|
|
63
|
+
if (x < 0) {
|
|
64
|
+
x = width - 1;
|
|
65
|
+
y -= 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (y < 0) {
|
|
69
|
+
return [-1, -1];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (x >= width) {
|
|
73
|
+
x = 0;
|
|
74
|
+
y += 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (y >= height) {
|
|
78
|
+
return [-1, -1];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return [x, y];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.default = moveSelectionBy;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition } from '../utils';
|
|
5
|
+
import type Options from '../options';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Move selection by a {x,y} relative movement
|
|
9
|
+
*/
|
|
10
|
+
function moveSelectionBy(
|
|
11
|
+
opts: Options,
|
|
12
|
+
change: Change,
|
|
13
|
+
x: number, // Move horizontally by x
|
|
14
|
+
y: number // Move vertically by y
|
|
15
|
+
): Change {
|
|
16
|
+
const { value } = change;
|
|
17
|
+
const { startKey } = value;
|
|
18
|
+
const pos = TablePosition.create(opts, value.document, startKey);
|
|
19
|
+
if (!pos.isInCell()) {
|
|
20
|
+
throw new Error('moveSelectionBy can only be applied in a cell');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const rowIndex = pos.getRowIndex();
|
|
24
|
+
const colIndex = pos.getColumnIndex();
|
|
25
|
+
const width = pos.getWidth();
|
|
26
|
+
const height = pos.getHeight();
|
|
27
|
+
|
|
28
|
+
const [absX, absY] = normPos(x + colIndex, y + rowIndex, width, height);
|
|
29
|
+
const isGoingUp = y < 0;
|
|
30
|
+
|
|
31
|
+
if (absX === -1) {
|
|
32
|
+
// Out of table
|
|
33
|
+
return change;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { table } = pos;
|
|
37
|
+
const row = table.nodes.get(absY);
|
|
38
|
+
const cell = row.nodes.get(absX);
|
|
39
|
+
|
|
40
|
+
if (isGoingUp) {
|
|
41
|
+
change.collapseToEndOf(cell);
|
|
42
|
+
} else {
|
|
43
|
+
change.collapseToStartOf(cell);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return change;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Normalize position in a table. If x is out of the row, update y accordingly.
|
|
51
|
+
* Returns [-1, -1] if the new selection is out of table
|
|
52
|
+
*/
|
|
53
|
+
function normPos(
|
|
54
|
+
x: number,
|
|
55
|
+
y: number,
|
|
56
|
+
width: number,
|
|
57
|
+
height: number
|
|
58
|
+
): number[] {
|
|
59
|
+
if (x < 0) {
|
|
60
|
+
x = width - 1;
|
|
61
|
+
y -= 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (y < 0) {
|
|
65
|
+
return [-1, -1];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (x >= width) {
|
|
69
|
+
x = 0;
|
|
70
|
+
y += 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (y >= height) {
|
|
74
|
+
return [-1, -1];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return [x, y];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default moveSelectionBy;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
var _removeColumnByKey = require('./removeColumnByKey');
|
|
12
|
+
|
|
13
|
+
var _removeColumnByKey2 = _interopRequireDefault(_removeColumnByKey);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Delete current column in a table
|
|
19
|
+
*/
|
|
20
|
+
function removeColumn(opts, change, at) {
|
|
21
|
+
var value = change.value;
|
|
22
|
+
var startKey = value.startKey;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var pos = _utils.TablePosition.create(opts, value.document, startKey);
|
|
26
|
+
|
|
27
|
+
var columnKey = void 0;
|
|
28
|
+
if (typeof at === 'undefined') {
|
|
29
|
+
columnKey = pos.cell.key;
|
|
30
|
+
} else {
|
|
31
|
+
columnKey = pos.row.nodes.get(at).key;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (0, _removeColumnByKey2.default)(opts, change, columnKey);
|
|
35
|
+
}
|
|
36
|
+
exports.default = removeColumn;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition } from '../utils';
|
|
5
|
+
import removeColumnByKey from './removeColumnByKey';
|
|
6
|
+
|
|
7
|
+
import type Options from '../options';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Delete current column in a table
|
|
11
|
+
*/
|
|
12
|
+
function removeColumn(opts: Options, change: Change, at: number): Change {
|
|
13
|
+
const { value } = change;
|
|
14
|
+
const { startKey } = value;
|
|
15
|
+
|
|
16
|
+
const pos = TablePosition.create(opts, value.document, startKey);
|
|
17
|
+
|
|
18
|
+
let columnKey;
|
|
19
|
+
if (typeof at === 'undefined') {
|
|
20
|
+
columnKey = pos.cell.key;
|
|
21
|
+
} else {
|
|
22
|
+
columnKey = pos.row.nodes.get(at).key;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return removeColumnByKey(opts, change, columnKey);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default removeColumn;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
var _clearCell = require('./clearCell');
|
|
12
|
+
|
|
13
|
+
var _clearCell2 = _interopRequireDefault(_clearCell);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Delete the column associated with the given cell key in a table
|
|
19
|
+
*/
|
|
20
|
+
function removeColumnByKey(opts, change, key) {
|
|
21
|
+
var value = change.value;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var pos = _utils.TablePosition.create(opts, value.document, key);
|
|
25
|
+
var table = pos.table;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var colIndex = pos.getColumnIndex();
|
|
29
|
+
|
|
30
|
+
var rows = table.nodes;
|
|
31
|
+
|
|
32
|
+
// Remove the cell from every row
|
|
33
|
+
if (pos.getWidth() > 1) {
|
|
34
|
+
rows.forEach(function (row) {
|
|
35
|
+
var cell = row.nodes.get(colIndex);
|
|
36
|
+
change.removeNodeByKey(cell.key, { normalize: false });
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
// If last column, clear text in cells instead
|
|
40
|
+
rows.forEach(function (row) {
|
|
41
|
+
row.nodes.forEach(function (cell) {
|
|
42
|
+
cell.nodes.forEach(function (node) {
|
|
43
|
+
return (0, _clearCell2.default)(opts, change, cell);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Replace the table
|
|
50
|
+
return change;
|
|
51
|
+
}
|
|
52
|
+
exports.default = removeColumnByKey;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition } from '../utils';
|
|
5
|
+
import clearCell from './clearCell';
|
|
6
|
+
import type Options from '../options';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Delete the column associated with the given cell key in a table
|
|
10
|
+
*/
|
|
11
|
+
function removeColumnByKey(opts: Options, change: Change, key: string): Change {
|
|
12
|
+
const { value } = change;
|
|
13
|
+
|
|
14
|
+
const pos = TablePosition.create(opts, value.document, key);
|
|
15
|
+
const { table } = pos;
|
|
16
|
+
|
|
17
|
+
const colIndex = pos.getColumnIndex();
|
|
18
|
+
|
|
19
|
+
const rows = table.nodes;
|
|
20
|
+
|
|
21
|
+
// Remove the cell from every row
|
|
22
|
+
if (pos.getWidth() > 1) {
|
|
23
|
+
rows.forEach(row => {
|
|
24
|
+
const cell = row.nodes.get(colIndex);
|
|
25
|
+
change.removeNodeByKey(cell.key, { normalize: false });
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
// If last column, clear text in cells instead
|
|
29
|
+
rows.forEach(row => {
|
|
30
|
+
row.nodes.forEach(cell => {
|
|
31
|
+
cell.nodes.forEach(node => clearCell(opts, change, cell));
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Replace the table
|
|
37
|
+
return change;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default removeColumnByKey;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
var _removeRowByKey = require('./removeRowByKey');
|
|
12
|
+
|
|
13
|
+
var _removeRowByKey2 = _interopRequireDefault(_removeRowByKey);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Remove current row in a table. Clear it if last remaining row
|
|
19
|
+
*/
|
|
20
|
+
function removeRow(opts, change, at) {
|
|
21
|
+
var value = change.value;
|
|
22
|
+
var startKey = value.startKey;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var pos = _utils.TablePosition.create(opts, value.document, startKey);
|
|
26
|
+
|
|
27
|
+
var rowKey = void 0;
|
|
28
|
+
if (typeof at === 'undefined') {
|
|
29
|
+
rowKey = pos.row.key;
|
|
30
|
+
} else {
|
|
31
|
+
rowKey = pos.table.nodes.get(at).key;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (0, _removeRowByKey2.default)(opts, change, rowKey);
|
|
35
|
+
}
|
|
36
|
+
exports.default = removeRow;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { TablePosition } from '../utils';
|
|
5
|
+
import type Options from '../options';
|
|
6
|
+
import removeRowByKey from './removeRowByKey';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Remove current row in a table. Clear it if last remaining row
|
|
10
|
+
*/
|
|
11
|
+
function removeRow(opts: Options, change: Change, at: number): Change {
|
|
12
|
+
const { value } = change;
|
|
13
|
+
const { startKey } = value;
|
|
14
|
+
|
|
15
|
+
const pos = TablePosition.create(opts, value.document, startKey);
|
|
16
|
+
|
|
17
|
+
let rowKey;
|
|
18
|
+
if (typeof at === 'undefined') {
|
|
19
|
+
rowKey = pos.row.key;
|
|
20
|
+
} else {
|
|
21
|
+
rowKey = pos.table.nodes.get(at).key;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return removeRowByKey(opts, change, rowKey);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default removeRow;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
var _utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
var _clearCell = require('./clearCell');
|
|
12
|
+
|
|
13
|
+
var _clearCell2 = _interopRequireDefault(_clearCell);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Remove the row associated to a given key in a table.
|
|
19
|
+
* Clear thw row if last remaining row
|
|
20
|
+
*/
|
|
21
|
+
function removeRowByKey(opts, change, key) {
|
|
22
|
+
var value = change.value;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var pos = _utils.TablePosition.create(opts, value.document, key);
|
|
26
|
+
|
|
27
|
+
// Update table by removing the row
|
|
28
|
+
if (pos.getHeight() > 1) {
|
|
29
|
+
change.removeNodeByKey(key);
|
|
30
|
+
} else {
|
|
31
|
+
// If last remaining row, clear it instead
|
|
32
|
+
pos.row.nodes.forEach(function (cell) {
|
|
33
|
+
cell.nodes.forEach(function (node) {
|
|
34
|
+
return (0, _clearCell2.default)(opts, change, cell);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return change;
|
|
40
|
+
}
|
|
41
|
+
exports.default = removeRowByKey;
|