@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,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
require('slate');
|
|
8
|
+
|
|
9
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Create a schema definition with rules to normalize lists
|
|
13
|
+
*/
|
|
14
|
+
function schema(opts) {
|
|
15
|
+
var constructedSchema = {
|
|
16
|
+
blocks: _defineProperty({}, opts.typeItem, {
|
|
17
|
+
parent: { types: opts.types },
|
|
18
|
+
nodes: [{ objects: ['block'] }],
|
|
19
|
+
|
|
20
|
+
normalize: normalize({
|
|
21
|
+
parent_type_invalid: function parent_type_invalid(change, context) {
|
|
22
|
+
return change.unwrapBlockByKey(context.node.key, {
|
|
23
|
+
normalize: false
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
child_object_invalid: function child_object_invalid(change, context) {
|
|
27
|
+
return wrapChildrenInDefaultBlock(opts, change, context.node);
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// validate all list types, ensure they only have list item children
|
|
34
|
+
opts.types.forEach(function (type) {
|
|
35
|
+
constructedSchema.blocks[type] = {
|
|
36
|
+
nodes: [{ types: [opts.typeItem] }],
|
|
37
|
+
normalize: normalize({
|
|
38
|
+
child_type_invalid: function child_type_invalid(change, context) {
|
|
39
|
+
return change.wrapBlockByKey(context.child.key, opts.typeItem, {
|
|
40
|
+
normalize: false
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return constructedSchema;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Allows to define a normalize function through a keyed collection of functions
|
|
52
|
+
*/
|
|
53
|
+
function normalize(reasons) {
|
|
54
|
+
return function (change, reason, context) {
|
|
55
|
+
var reasonFn = reasons[reason];
|
|
56
|
+
if (reasonFn) {
|
|
57
|
+
reasonFn(change, context);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Wraps all child of a node in the default block type.
|
|
64
|
+
* Returns a change, for chaining purposes
|
|
65
|
+
*/
|
|
66
|
+
function wrapChildrenInDefaultBlock(opts, change, node) {
|
|
67
|
+
change.wrapBlockByKey(node.nodes.first().key, opts.typeDefault, {
|
|
68
|
+
normalize: false
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
var wrapper = change.value.document.getDescendant(node.key).nodes.first();
|
|
72
|
+
|
|
73
|
+
// Add in the remaining items
|
|
74
|
+
node.nodes.rest().forEach(function (child, index) {
|
|
75
|
+
return change.moveNodeByKey(child.key, wrapper.key, index + 1, {
|
|
76
|
+
normalize: false
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return change;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.default = schema;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change, type Node } from 'slate';
|
|
3
|
+
|
|
4
|
+
import type Options from '../options';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create a schema definition with rules to normalize lists
|
|
8
|
+
*/
|
|
9
|
+
function schema(opts: Options): Object {
|
|
10
|
+
const constructedSchema = {
|
|
11
|
+
blocks: {
|
|
12
|
+
[opts.typeItem]: {
|
|
13
|
+
parent: { types: opts.types },
|
|
14
|
+
nodes: [{ objects: ['block'] }],
|
|
15
|
+
|
|
16
|
+
normalize: normalize({
|
|
17
|
+
parent_type_invalid: (change, context) =>
|
|
18
|
+
change.unwrapBlockByKey(context.node.key, {
|
|
19
|
+
normalize: false
|
|
20
|
+
}),
|
|
21
|
+
child_object_invalid: (change, context) =>
|
|
22
|
+
wrapChildrenInDefaultBlock(opts, change, context.node)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// validate all list types, ensure they only have list item children
|
|
29
|
+
opts.types.forEach(type => {
|
|
30
|
+
constructedSchema.blocks[type] = {
|
|
31
|
+
nodes: [{ types: [opts.typeItem] }],
|
|
32
|
+
normalize: normalize({
|
|
33
|
+
child_type_invalid: (change, context) =>
|
|
34
|
+
change.wrapBlockByKey(context.child.key, opts.typeItem, {
|
|
35
|
+
normalize: false
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return constructedSchema;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Allows to define a normalize function through a keyed collection of functions
|
|
46
|
+
*/
|
|
47
|
+
function normalize(reasons: { [string]: (Change, context: any) => any }): * {
|
|
48
|
+
return (change, reason, context) => {
|
|
49
|
+
const reasonFn = reasons[reason];
|
|
50
|
+
if (reasonFn) {
|
|
51
|
+
reasonFn(change, context);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Wraps all child of a node in the default block type.
|
|
58
|
+
* Returns a change, for chaining purposes
|
|
59
|
+
*/
|
|
60
|
+
function wrapChildrenInDefaultBlock(
|
|
61
|
+
opts: Options,
|
|
62
|
+
change: Change,
|
|
63
|
+
node: Node
|
|
64
|
+
): Change {
|
|
65
|
+
change.wrapBlockByKey(node.nodes.first().key, opts.typeDefault, {
|
|
66
|
+
normalize: false
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const wrapper = change.value.document.getDescendant(node.key).nodes.first();
|
|
70
|
+
|
|
71
|
+
// Add in the remaining items
|
|
72
|
+
node.nodes.rest().forEach((child, index) =>
|
|
73
|
+
change.moveNodeByKey(child.key, wrapper.key, index + 1, {
|
|
74
|
+
normalize: false
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return change;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default schema;
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
* Create a schema definition with rules to normalize lists
|
|
15
|
+
*/
|
|
16
|
+
function validateNode(opts) {
|
|
17
|
+
return function (node) {
|
|
18
|
+
return joinAdjacentLists(opts, node);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A rule that joins adjacent lists of the same type
|
|
24
|
+
*/
|
|
25
|
+
function joinAdjacentLists(opts, node) {
|
|
26
|
+
if (node.object !== 'document' && node.object !== 'block') {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var invalids = node.nodes.map(function (child, i) {
|
|
31
|
+
if (!(0, _utils.isList)(opts, child)) return null;
|
|
32
|
+
var next = node.nodes.get(i + 1);
|
|
33
|
+
if (!next || next.type !== child.type) return null;
|
|
34
|
+
return [child, next];
|
|
35
|
+
}).filter(Boolean);
|
|
36
|
+
|
|
37
|
+
if (invalids.isEmpty()) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Join the list pairs
|
|
43
|
+
*/
|
|
44
|
+
// We join in reverse order, so that multiple lists folds onto the first one
|
|
45
|
+
return function (change) {
|
|
46
|
+
invalids.reverse().forEach(function (pair) {
|
|
47
|
+
var _pair = _slicedToArray(pair, 2),
|
|
48
|
+
first = _pair[0],
|
|
49
|
+
second = _pair[1];
|
|
50
|
+
|
|
51
|
+
var updatedSecond = change.value.document.getDescendant(second.key);
|
|
52
|
+
updatedSecond.nodes.forEach(function (secondNode, index) {
|
|
53
|
+
change.moveNodeByKey(secondNode.key, first.key, first.nodes.size + index, { normalize: false });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
change.removeNodeByKey(second.key, { normalize: false });
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.default = validateNode;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Change, type Node } from 'slate';
|
|
3
|
+
|
|
4
|
+
import { isList } from '../utils';
|
|
5
|
+
import type Options from '../options';
|
|
6
|
+
|
|
7
|
+
type Normalizer = Change => any;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a schema definition with rules to normalize lists
|
|
11
|
+
*/
|
|
12
|
+
function validateNode(opts: Options): Node => void | Normalizer {
|
|
13
|
+
return node => joinAdjacentLists(opts, node);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A rule that joins adjacent lists of the same type
|
|
18
|
+
*/
|
|
19
|
+
function joinAdjacentLists(opts: Options, node: Node): void | Normalizer {
|
|
20
|
+
if (node.object !== 'document' && node.object !== 'block') {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const invalids = node.nodes
|
|
25
|
+
.map((child, i) => {
|
|
26
|
+
if (!isList(opts, child)) return null;
|
|
27
|
+
const next = node.nodes.get(i + 1);
|
|
28
|
+
if (!next || next.type !== child.type) return null;
|
|
29
|
+
return [child, next];
|
|
30
|
+
})
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
|
|
33
|
+
if (invalids.isEmpty()) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Join the list pairs
|
|
39
|
+
*/
|
|
40
|
+
// We join in reverse order, so that multiple lists folds onto the first one
|
|
41
|
+
return change => {
|
|
42
|
+
invalids.reverse().forEach(pair => {
|
|
43
|
+
const [first, second] = pair;
|
|
44
|
+
const updatedSecond = change.value.document.getDescendant(
|
|
45
|
+
second.key
|
|
46
|
+
);
|
|
47
|
+
updatedSecond.nodes.forEach((secondNode, index) => {
|
|
48
|
+
change.moveNodeByKey(
|
|
49
|
+
secondNode.key,
|
|
50
|
+
first.key,
|
|
51
|
+
first.nodes.size + index,
|
|
52
|
+
{ normalize: false }
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
change.removeNodeByKey(second.key, { normalize: false });
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default validateNode;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "slate-edit-list",
|
|
3
|
+
"description": "A Slate plugin to handle keyboard events in lists.",
|
|
4
|
+
"version": "0.11.3",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": "git://github.com/GitbookIO/slate-edit-list.git",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"immutable": "^3.8.2",
|
|
10
|
+
"slate": "^0.32.0"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"*.md"
|
|
15
|
+
],
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"babel-cli": "^6.26.0",
|
|
18
|
+
"babel-core": "^6.26.0",
|
|
19
|
+
"babel-eslint": "^8.0.2",
|
|
20
|
+
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
|
21
|
+
"babel-plugin-transform-runtime": "^6.23.0",
|
|
22
|
+
"babel-preset-env": "^1.6.1",
|
|
23
|
+
"babel-preset-flow": "^6.23.0",
|
|
24
|
+
"babel-preset-react": "^6.24.1",
|
|
25
|
+
"babel-preset-stage-0": "^6.24.1",
|
|
26
|
+
"babelify": "^8.0.0",
|
|
27
|
+
"browserify": "^13.3.0",
|
|
28
|
+
"eslint": "^4.15.0",
|
|
29
|
+
"eslint-config-gitbook": "^3.0.0",
|
|
30
|
+
"eslint-plugin-flowtype": "^2.41.0",
|
|
31
|
+
"eslint-plugin-import": "^2.8.0",
|
|
32
|
+
"eslint-plugin-jsx-a11y": "^5.1.1",
|
|
33
|
+
"eslint-plugin-prettier": "^2.4.0",
|
|
34
|
+
"eslint-plugin-react": "^7.5.1",
|
|
35
|
+
"expect": "^1.20.2",
|
|
36
|
+
"flow-bin": "^0.57.3",
|
|
37
|
+
"flow-copy-source": "^1.2.1",
|
|
38
|
+
"gh-pages": "^0.11.0",
|
|
39
|
+
"http-server": "^0.9.0",
|
|
40
|
+
"immutable": "^3.8.2",
|
|
41
|
+
"mocha": "^3.0.1",
|
|
42
|
+
"prettier": "^1.9.2",
|
|
43
|
+
"react": "^16.0.0",
|
|
44
|
+
"react-dom": "^16.0.0",
|
|
45
|
+
"read-metadata": "^1.0.0",
|
|
46
|
+
"slate": "^0.32.0",
|
|
47
|
+
"slate-hyperscript": "^0.5.0",
|
|
48
|
+
"slate-plain-serializer": "^0.5.0",
|
|
49
|
+
"slate-react": "^0.11.0",
|
|
50
|
+
"stringify": "^5.1.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build:dist": "rm -r ./dist; babel ./lib --out-dir ./dist",
|
|
54
|
+
"build:flow": "flow-copy-source -v ./lib/ ./dist/",
|
|
55
|
+
"prepublish": "npm run build:dist && npm run build:flow",
|
|
56
|
+
"postpublish": "npm run deploy-example",
|
|
57
|
+
"lint": "eslint ./",
|
|
58
|
+
"build-example": "browserify ./example/main.js -o ./example/bundle.js -t [ babelify --presets [ env react stage-0 ] ] -t [ stringify --extensions [.yaml] ]",
|
|
59
|
+
"serve-example": "http-server ./example/ -p 8081",
|
|
60
|
+
"start": "npm run build-example && npm run serve-example",
|
|
61
|
+
"deploy-example": "npm run build-example && gh-pages -d ./example",
|
|
62
|
+
"test": "./node_modules/.bin/mocha ./tests/all.js --compilers js:babel-register --reporter=list"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"slate"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
|
+
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
## [0.17.0] - 2018-07-26
|
|
10
|
+
|
|
11
|
+
- Remove `key` parameter of getPosition, and create a function `getPositionByKey`
|
|
12
|
+
|
|
13
|
+
## [0.16.2] - 2018-07-16
|
|
14
|
+
|
|
15
|
+
- Add byKey variants to remove utils. removeRowByKey, removeColumnByKey, removeTableByKey
|
|
16
|
+
|
|
17
|
+
## [0.16.1] - 2018-06-28
|
|
18
|
+
|
|
19
|
+
- Improve behavior of Backspace when deleting whole cells https://github.com/GitbookIO/slate-edit-table/pull/79
|
|
20
|
+
|
|
21
|
+
## [0.16.0] - 2018-06-27
|
|
22
|
+
|
|
23
|
+
- Fix some case where pressing Backspace would unexpectedly clear the whole cell
|
|
24
|
+
|
|
25
|
+
## [0.16.0 (pre)] - 2018-06-27
|
|
26
|
+
|
|
27
|
+
- Add keyboard interactions to handle multiple blocks in cells:
|
|
28
|
+
- Split block when pressing <kbd>Shift+Enter</kbd>
|
|
29
|
+
- Split block when pressing <kbd>Enter</kbd> inside the cell
|
|
30
|
+
|
|
31
|
+
## [0.15.2] - 2018-06-19
|
|
32
|
+
|
|
33
|
+
* Export TablePosition type
|
|
34
|
+
|
|
35
|
+
## [0.15.1] - 2018-06-13
|
|
36
|
+
|
|
37
|
+
* Add key option to `getPosition`
|
|
38
|
+
|
|
39
|
+
## [0.15.0] - 2018-04-19
|
|
40
|
+
|
|
41
|
+
* Allow blocks in cells
|
|
42
|
+
* Align for columns have been removed
|
|
43
|
+
* Improve package size by publishing only the `dist` folder
|
|
44
|
+
|
|
45
|
+
## [0.14.3] - 2018-02-06
|
|
46
|
+
|
|
47
|
+
* Fix normalization of multiple blocks in cells
|
|
48
|
+
|
|
49
|
+
## [0.14.2] - 2018-02-06
|
|
50
|
+
|
|
51
|
+
## [0.14.1] - 2018-02-06
|
|
52
|
+
|
|
53
|
+
* Fixed build
|
|
54
|
+
|
|
55
|
+
## [0.14.0] - 2018-02-05
|
|
56
|
+
|
|
57
|
+
**BREAKING**
|
|
58
|
+
|
|
59
|
+
* Upgrade to be compatible with Slate 0.32.x
|
|
60
|
+
* Fixed missing peerDependencies for `eslint-config-gitbook`
|
|
61
|
+
|
|
62
|
+
## [0.13.3] - 2018-01-08
|
|
63
|
+
|
|
64
|
+
* Fix peer depedency range for slate to include 0.30 and 0.31
|
|
65
|
+
|
|
66
|
+
## [0.13.2] - 2018-01-08
|
|
67
|
+
|
|
68
|
+
* Add `isSelectionOutOfTable`
|
|
69
|
+
* Fix keys detection
|
|
70
|
+
* Fix selection errors when deleting table
|
|
71
|
+
|
|
72
|
+
## [0.13.1] - 2017-12-05
|
|
73
|
+
|
|
74
|
+
* Improve `isSelectionInTable` to check for both end of the selection to be in the same table.
|
|
75
|
+
|
|
76
|
+
## [0.13.0] - 2017-11-22
|
|
77
|
+
|
|
78
|
+
**BREAKING**
|
|
79
|
+
|
|
80
|
+
* Upgrade to be compatible with Slate 0.30.x
|
|
81
|
+
|
|
82
|
+
## [0.12.0] - 2017-11-02
|
|
83
|
+
|
|
84
|
+
**BREAKING**
|
|
85
|
+
|
|
86
|
+
* Upgrade to be compatible with Slate 0.27.x
|
|
87
|
+
|
|
88
|
+
## [0.11.0] - 2017-09-20
|
|
89
|
+
|
|
90
|
+
**BREAKING**
|
|
91
|
+
|
|
92
|
+
* Upgrade to be compatible with Slate after the `expose-transform` branch went in.
|
|
93
|
+
* Change all instances of `transform` to `change`
|
|
94
|
+
* Change the namespace of `plugin.transforms` to `plugin.changes`
|
|
95
|
+
|
|
96
|
+
## [0.10.2] - 2017-09-20
|
|
97
|
+
|
|
98
|
+
* New `utils.getPosition(state) => TablePosition` to know easily the current
|
|
99
|
+
position within a table (#39)
|
|
100
|
+
* New option `exitBlockType`. When provided, `Mod+Enter` will exit the current
|
|
101
|
+
table into a new block of this type.
|
|
102
|
+
* Fixed cursor issues when inserting rows using Tab (#26)
|
|
103
|
+
|
|
104
|
+
## [0.10.1] - 2017-07-13
|
|
105
|
+
|
|
106
|
+
[0.10.1]: https://github.com/GitbookIO/slate-edit-table/compare/0.10.0...0.10.1
|
|
107
|
+
|
|
108
|
+
* Fix rule to prevent extra blocks in rows
|
|
109
|
+
|
|
110
|
+
## [0.10.0] - 2017-07-13
|
|
111
|
+
|
|
112
|
+
[0.10.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.9.0...0.10.0
|
|
113
|
+
|
|
114
|
+
* Add rule to prevent nested blocks in cells
|
|
115
|
+
|
|
116
|
+
## [0.9.0] - 2017-04-21
|
|
117
|
+
|
|
118
|
+
[0.9.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.8.4...0.9.0
|
|
119
|
+
|
|
120
|
+
* Update slate to `^0.19.x`
|
|
121
|
+
|
|
122
|
+
## [0.8.4] - 2016-11-30
|
|
123
|
+
|
|
124
|
+
[0.8.4]: https://github.com/GitbookIO/slate-edit-table/compare/0.8.3...0.8.4
|
|
125
|
+
|
|
126
|
+
* Update slate peer dependency to prevent NPM warnings when used with `0.15.x`
|
|
127
|
+
|
|
128
|
+
## [0.8.3] - 2016-11-09
|
|
129
|
+
|
|
130
|
+
[0.8.3]: https://github.com/GitbookIO/slate-edit-table/compare/0.8.2...0.8.3
|
|
131
|
+
|
|
132
|
+
* Enforce align to be Immutable.List
|
|
133
|
+
* Undo is now fixed, using GitbookIO:slate
|
|
134
|
+
|
|
135
|
+
## [0.8.2] - 2016-11-03
|
|
136
|
+
|
|
137
|
+
[0.8.2]: https://github.com/GitbookIO/slate-edit-table/compare/0.8.1...0.8.2
|
|
138
|
+
|
|
139
|
+
* Move slate to `peerDependencies`
|
|
140
|
+
|
|
141
|
+
## [0.8.1] - 2016-11-01
|
|
142
|
+
|
|
143
|
+
[0.8.1]: https://github.com/GitbookIO/slate-edit-table/compare/0.8.0...0.8.1
|
|
144
|
+
|
|
145
|
+
* Add schema to normalize `align` in table
|
|
146
|
+
* `insertColumn` and `removeColumn` update correctly the alignment
|
|
147
|
+
|
|
148
|
+
## [0.8.0] - 2016-10-27
|
|
149
|
+
|
|
150
|
+
[0.8.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.7.0...0.8.0
|
|
151
|
+
|
|
152
|
+
* Expose `setColumnAlign` transform
|
|
153
|
+
* Expose `ALIGN.{LEFT,RIGHT,CENTER}` constants
|
|
154
|
+
* Rules to ensure cells or rows are always within a table. Fix
|
|
155
|
+
[#13](https://github.com/GitbookIO/slate-edit-table/issues/13)
|
|
156
|
+
|
|
157
|
+
## [0.7.0] - 2016-10-27
|
|
158
|
+
|
|
159
|
+
[0.7.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.6.0...0.7.0
|
|
160
|
+
|
|
161
|
+
* Adapt for upcoming Slate release
|
|
162
|
+
* Improve stability
|
|
163
|
+
|
|
164
|
+
## [0.6.0] - 2016-09-23
|
|
165
|
+
|
|
166
|
+
[0.6.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.5.1...0.6.0
|
|
167
|
+
|
|
168
|
+
* Expose `moveSelectionBy` transform
|
|
169
|
+
* `removeColumn` clears the column instead, if it is the last remaining column
|
|
170
|
+
* `removeRow` clears the row instead, if it is the last remaining row
|
|
171
|
+
* Undo of `insertColumn` when cursor is in inserted column
|
|
172
|
+
|
|
173
|
+
## [0.5.1] - 2016-09-15
|
|
174
|
+
|
|
175
|
+
[0.5.1]: https://github.com/GitbookIO/slate-edit-table/compare/0.5.0...0.5.1
|
|
176
|
+
|
|
177
|
+
* `insertTable` does not grab text from current block anymore, and simply inserts an empty table.
|
|
178
|
+
* Up/Down arrows behavior inside tables
|
|
179
|
+
|
|
180
|
+
## [0.5.0] - 2016-09-15
|
|
181
|
+
|
|
182
|
+
[0.5.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.4.0...0.5.0
|
|
183
|
+
|
|
184
|
+
* `TablePosition.is{First|Last}{Row|Column|Cell}` methods
|
|
185
|
+
* **BREAKING** Now uses `slate^0.14.x`
|
|
186
|
+
* Split transform `moveSelection` into `moveSelection` and `moveSelectionBy`
|
|
187
|
+
|
|
188
|
+
## [0.4.0] - 2016-09-06
|
|
189
|
+
|
|
190
|
+
[0.4.0]: https://github.com/GitbookIO/slate-edit-table/compare/0.3.0...0.4.0
|
|
191
|
+
|
|
192
|
+
* Schema normalization rules
|