@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.
Files changed (146) hide show
  1. package/configure/node_modules/immutable/LICENSE +21 -0
  2. package/configure/node_modules/immutable/README.md +657 -0
  3. package/configure/node_modules/immutable/dist/immutable-nonambient.d.ts +5607 -0
  4. package/configure/node_modules/immutable/dist/immutable.d.ts +5611 -0
  5. package/configure/node_modules/immutable/dist/immutable.es.js +5893 -0
  6. package/configure/node_modules/immutable/dist/immutable.js +5948 -0
  7. package/configure/node_modules/immutable/dist/immutable.js.flow +2340 -0
  8. package/configure/node_modules/immutable/dist/immutable.min.js +55 -0
  9. package/configure/node_modules/immutable/package.json +41 -0
  10. package/configure/node_modules/slate-edit-list/CHANGELOG.md +124 -0
  11. package/configure/node_modules/slate-edit-list/LICENSE +201 -0
  12. package/configure/node_modules/slate-edit-list/README.md +159 -0
  13. package/configure/node_modules/slate-edit-list/dist/changes/decreaseItemDepth.js +73 -0
  14. package/configure/node_modules/slate-edit-list/dist/changes/decreaseItemDepth.js.flow +88 -0
  15. package/configure/node_modules/slate-edit-list/dist/changes/increaseItemDepth.js +70 -0
  16. package/configure/node_modules/slate-edit-list/dist/changes/increaseItemDepth.js.flow +77 -0
  17. package/configure/node_modules/slate-edit-list/dist/changes/index.js +34 -0
  18. package/configure/node_modules/slate-edit-list/dist/changes/index.js.flow +13 -0
  19. package/configure/node_modules/slate-edit-list/dist/changes/splitListItem.js +27 -0
  20. package/configure/node_modules/slate-edit-list/dist/changes/splitListItem.js.flow +26 -0
  21. package/configure/node_modules/slate-edit-list/dist/changes/unwrapList.js +52 -0
  22. package/configure/node_modules/slate-edit-list/dist/changes/unwrapList.js.flow +46 -0
  23. package/configure/node_modules/slate-edit-list/dist/changes/wrapInList.js +67 -0
  24. package/configure/node_modules/slate-edit-list/dist/changes/wrapInList.js.flow +67 -0
  25. package/configure/node_modules/slate-edit-list/dist/core.js +80 -0
  26. package/configure/node_modules/slate-edit-list/dist/core.js.flow +76 -0
  27. package/configure/node_modules/slate-edit-list/dist/handlers/index.js +24 -0
  28. package/configure/node_modules/slate-edit-list/dist/handlers/index.js.flow +5 -0
  29. package/configure/node_modules/slate-edit-list/dist/handlers/onBackspace.js +45 -0
  30. package/configure/node_modules/slate-edit-list/dist/handlers/onBackspace.js.flow +44 -0
  31. package/configure/node_modules/slate-edit-list/dist/handlers/onEnter.js +54 -0
  32. package/configure/node_modules/slate-edit-list/dist/handlers/onEnter.js.flow +54 -0
  33. package/configure/node_modules/slate-edit-list/dist/handlers/onTab.js +39 -0
  34. package/configure/node_modules/slate-edit-list/dist/handlers/onTab.js.flow +34 -0
  35. package/configure/node_modules/slate-edit-list/dist/index.js +58 -0
  36. package/configure/node_modules/slate-edit-list/dist/index.js.flow +45 -0
  37. package/configure/node_modules/slate-edit-list/dist/options.js +34 -0
  38. package/configure/node_modules/slate-edit-list/dist/options.js.flow +26 -0
  39. package/configure/node_modules/slate-edit-list/dist/utils/getCurrentItem.js +24 -0
  40. package/configure/node_modules/slate-edit-list/dist/utils/getCurrentItem.js.flow +20 -0
  41. package/configure/node_modules/slate-edit-list/dist/utils/getCurrentList.js +31 -0
  42. package/configure/node_modules/slate-edit-list/dist/utils/getCurrentList.js.flow +21 -0
  43. package/configure/node_modules/slate-edit-list/dist/utils/getItemDepth.js +34 -0
  44. package/configure/node_modules/slate-edit-list/dist/utils/getItemDepth.js.flow +24 -0
  45. package/configure/node_modules/slate-edit-list/dist/utils/getItemsAtRange.js +60 -0
  46. package/configure/node_modules/slate-edit-list/dist/utils/getItemsAtRange.js.flow +51 -0
  47. package/configure/node_modules/slate-edit-list/dist/utils/getListForItem.js +25 -0
  48. package/configure/node_modules/slate-edit-list/dist/utils/getListForItem.js.flow +16 -0
  49. package/configure/node_modules/slate-edit-list/dist/utils/getPreviousItem.js +39 -0
  50. package/configure/node_modules/slate-edit-list/dist/utils/getPreviousItem.js.flow +29 -0
  51. package/configure/node_modules/slate-edit-list/dist/utils/index.js +49 -0
  52. package/configure/node_modules/slate-edit-list/dist/utils/index.js.flow +19 -0
  53. package/configure/node_modules/slate-edit-list/dist/utils/isList.js +15 -0
  54. package/configure/node_modules/slate-edit-list/dist/utils/isList.js.flow +13 -0
  55. package/configure/node_modules/slate-edit-list/dist/utils/isSelectionInList.js +22 -0
  56. package/configure/node_modules/slate-edit-list/dist/utils/isSelectionInList.js.flow +14 -0
  57. package/configure/node_modules/slate-edit-list/dist/validation/index.js +19 -0
  58. package/configure/node_modules/slate-edit-list/dist/validation/index.js.flow +4 -0
  59. package/configure/node_modules/slate-edit-list/dist/validation/schema.js +83 -0
  60. package/configure/node_modules/slate-edit-list/dist/validation/schema.js.flow +81 -0
  61. package/configure/node_modules/slate-edit-list/dist/validation/validateNode.js +61 -0
  62. package/configure/node_modules/slate-edit-list/dist/validation/validateNode.js.flow +61 -0
  63. package/configure/node_modules/slate-edit-list/package.json +67 -0
  64. package/configure/node_modules/slate-edit-table/CHANGELOG.md +192 -0
  65. package/configure/node_modules/slate-edit-table/LICENSE +201 -0
  66. package/configure/node_modules/slate-edit-table/README.md +269 -0
  67. package/configure/node_modules/slate-edit-table/dist/changes/clearCell.js +29 -0
  68. package/configure/node_modules/slate-edit-table/dist/changes/clearCell.js.flow +26 -0
  69. package/configure/node_modules/slate-edit-table/dist/changes/index.js +69 -0
  70. package/configure/node_modules/slate-edit-table/dist/changes/index.js.flow +27 -0
  71. package/configure/node_modules/slate-edit-table/dist/changes/insertColumn.js +43 -0
  72. package/configure/node_modules/slate-edit-table/dist/changes/insertColumn.js.flow +46 -0
  73. package/configure/node_modules/slate-edit-table/dist/changes/insertRow.js +36 -0
  74. package/configure/node_modules/slate-edit-table/dist/changes/insertRow.js.flow +35 -0
  75. package/configure/node_modules/slate-edit-table/dist/changes/insertTable.js +29 -0
  76. package/configure/node_modules/slate-edit-table/dist/changes/insertTable.js.flow +27 -0
  77. package/configure/node_modules/slate-edit-table/dist/changes/moveSelection.js +32 -0
  78. package/configure/node_modules/slate-edit-table/dist/changes/moveSelection.js.flow +31 -0
  79. package/configure/node_modules/slate-edit-table/dist/changes/moveSelectionBy.js +84 -0
  80. package/configure/node_modules/slate-edit-table/dist/changes/moveSelectionBy.js.flow +80 -0
  81. package/configure/node_modules/slate-edit-table/dist/changes/removeColumn.js +36 -0
  82. package/configure/node_modules/slate-edit-table/dist/changes/removeColumn.js.flow +28 -0
  83. package/configure/node_modules/slate-edit-table/dist/changes/removeColumnByKey.js +52 -0
  84. package/configure/node_modules/slate-edit-table/dist/changes/removeColumnByKey.js.flow +40 -0
  85. package/configure/node_modules/slate-edit-table/dist/changes/removeRow.js +36 -0
  86. package/configure/node_modules/slate-edit-table/dist/changes/removeRow.js.flow +27 -0
  87. package/configure/node_modules/slate-edit-table/dist/changes/removeRowByKey.js +41 -0
  88. package/configure/node_modules/slate-edit-table/dist/changes/removeRowByKey.js.flow +30 -0
  89. package/configure/node_modules/slate-edit-table/dist/changes/removeTable.js +26 -0
  90. package/configure/node_modules/slate-edit-table/dist/changes/removeTable.js.flow +17 -0
  91. package/configure/node_modules/slate-edit-table/dist/changes/removeTableByKey.js +56 -0
  92. package/configure/node_modules/slate-edit-table/dist/changes/removeTableByKey.js.flow +54 -0
  93. package/configure/node_modules/slate-edit-table/dist/core.js +88 -0
  94. package/configure/node_modules/slate-edit-table/dist/core.js.flow +94 -0
  95. package/configure/node_modules/slate-edit-table/dist/handlers/index.js +39 -0
  96. package/configure/node_modules/slate-edit-table/dist/handlers/index.js.flow +8 -0
  97. package/configure/node_modules/slate-edit-table/dist/handlers/onBackspace.js +82 -0
  98. package/configure/node_modules/slate-edit-table/dist/handlers/onBackspace.js.flow +87 -0
  99. package/configure/node_modules/slate-edit-table/dist/handlers/onEnter.js +34 -0
  100. package/configure/node_modules/slate-edit-table/dist/handlers/onEnter.js.flow +37 -0
  101. package/configure/node_modules/slate-edit-table/dist/handlers/onKeyDown.js +71 -0
  102. package/configure/node_modules/slate-edit-table/dist/handlers/onKeyDown.js.flow +56 -0
  103. package/configure/node_modules/slate-edit-table/dist/handlers/onModEnter.js +35 -0
  104. package/configure/node_modules/slate-edit-table/dist/handlers/onModEnter.js.flow +38 -0
  105. package/configure/node_modules/slate-edit-table/dist/handlers/onTab.js +56 -0
  106. package/configure/node_modules/slate-edit-table/dist/handlers/onTab.js.flow +51 -0
  107. package/configure/node_modules/slate-edit-table/dist/handlers/onUpDown.js +38 -0
  108. package/configure/node_modules/slate-edit-table/dist/handlers/onUpDown.js.flow +41 -0
  109. package/configure/node_modules/slate-edit-table/dist/index.js +36 -0
  110. package/configure/node_modules/slate-edit-table/dist/index.js.flow +27 -0
  111. package/configure/node_modules/slate-edit-table/dist/options.js +61 -0
  112. package/configure/node_modules/slate-edit-table/dist/options.js.flow +42 -0
  113. package/configure/node_modules/slate-edit-table/dist/utils/TablePosition.js +306 -0
  114. package/configure/node_modules/slate-edit-table/dist/utils/TablePosition.js.flow +211 -0
  115. package/configure/node_modules/slate-edit-table/dist/utils/createCell.js +30 -0
  116. package/configure/node_modules/slate-edit-table/dist/utils/createCell.js.flow +26 -0
  117. package/configure/node_modules/slate-edit-table/dist/utils/createRow.js +30 -0
  118. package/configure/node_modules/slate-edit-table/dist/utils/createRow.js.flow +28 -0
  119. package/configure/node_modules/slate-edit-table/dist/utils/createTable.js +30 -0
  120. package/configure/node_modules/slate-edit-table/dist/utils/createTable.js.flow +33 -0
  121. package/configure/node_modules/slate-edit-table/dist/utils/forEachCells.js +21 -0
  122. package/configure/node_modules/slate-edit-table/dist/utils/forEachCells.js.flow +22 -0
  123. package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtColumn.js +22 -0
  124. package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtColumn.js.flow +19 -0
  125. package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtRow.js +20 -0
  126. package/configure/node_modules/slate-edit-table/dist/utils/getCellsAtRow.js.flow +19 -0
  127. package/configure/node_modules/slate-edit-table/dist/utils/getPosition.js +24 -0
  128. package/configure/node_modules/slate-edit-table/dist/utils/getPosition.js.flow +19 -0
  129. package/configure/node_modules/slate-edit-table/dist/utils/getPositionByKey.js +26 -0
  130. package/configure/node_modules/slate-edit-table/dist/utils/getPositionByKey.js.flow +21 -0
  131. package/configure/node_modules/slate-edit-table/dist/utils/getRow.js +24 -0
  132. package/configure/node_modules/slate-edit-table/dist/utils/getRow.js.flow +19 -0
  133. package/configure/node_modules/slate-edit-table/dist/utils/index.js +64 -0
  134. package/configure/node_modules/slate-edit-table/dist/utils/index.js.flow +25 -0
  135. package/configure/node_modules/slate-edit-table/dist/utils/isSelectionInTable.js +34 -0
  136. package/configure/node_modules/slate-edit-table/dist/utils/isSelectionInTable.js.flow +27 -0
  137. package/configure/node_modules/slate-edit-table/dist/utils/isSelectionOutOfTable.js +30 -0
  138. package/configure/node_modules/slate-edit-table/dist/utils/isSelectionOutOfTable.js.flow +23 -0
  139. package/configure/node_modules/slate-edit-table/dist/validation/index.js +19 -0
  140. package/configure/node_modules/slate-edit-table/dist/validation/index.js.flow +4 -0
  141. package/configure/node_modules/slate-edit-table/dist/validation/schema.js +101 -0
  142. package/configure/node_modules/slate-edit-table/dist/validation/schema.js.flow +98 -0
  143. package/configure/node_modules/slate-edit-table/dist/validation/validateNode.js +56 -0
  144. package/configure/node_modules/slate-edit-table/dist/validation/validateNode.js.flow +49 -0
  145. package/configure/node_modules/slate-edit-table/package.json +69 -0
  146. package/package.json +2 -2
@@ -0,0 +1,45 @@
1
+ // @flow
2
+ import Options, { type OptionsFormat } from './options';
3
+ import { onEnter, onTab, onBackspace } from './handlers';
4
+ import core from './core';
5
+
6
+ const KEY_ENTER = 'Enter';
7
+ const KEY_TAB = 'Tab';
8
+ const KEY_BACKSPACE = 'Backspace';
9
+
10
+ /**
11
+ * A Slate plugin to handle keyboard events in lists.
12
+ */
13
+ function EditList(
14
+ // Options for the plugin
15
+ opts: OptionsFormat = {}
16
+ ): Object {
17
+ opts = new Options(opts);
18
+ const corePlugin = core(opts);
19
+
20
+ return {
21
+ ...corePlugin,
22
+
23
+ onKeyDown: onKeyDown.bind(null, opts)
24
+ };
25
+ }
26
+
27
+ /**
28
+ * User is pressing a key in the editor
29
+ */
30
+ function onKeyDown(opts: Options, event, change, editor: *): void | any {
31
+ const args = [event, change, editor, opts];
32
+
33
+ switch (event.key) {
34
+ case KEY_ENTER:
35
+ return onEnter(...args);
36
+ case KEY_TAB:
37
+ return onTab(...args);
38
+ case KEY_BACKSPACE:
39
+ return onBackspace(...args);
40
+ default:
41
+ return undefined;
42
+ }
43
+ }
44
+
45
+ export default EditList;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _immutable = require('immutable');
8
+
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+
11
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
12
+
13
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
14
+
15
+ /**
16
+ * The plugin options
17
+ */
18
+ var Options = function (_Record) {
19
+ _inherits(Options, _Record);
20
+
21
+ function Options() {
22
+ _classCallCheck(this, Options);
23
+
24
+ return _possibleConstructorReturn(this, (Options.__proto__ || Object.getPrototypeOf(Options)).apply(this, arguments));
25
+ }
26
+
27
+ return Options;
28
+ }((0, _immutable.Record)({
29
+ types: ['ul_list', 'ol_list'],
30
+ typeItem: 'list_item',
31
+ typeDefault: 'paragraph'
32
+ }));
33
+
34
+ exports.default = Options;
@@ -0,0 +1,26 @@
1
+ // @flow
2
+ import { Record } from 'immutable';
3
+
4
+ export type OptionsFormat = {
5
+ types?: string[],
6
+ typeItem?: string,
7
+ typeDefault?: string
8
+ };
9
+
10
+ /**
11
+ * The plugin options
12
+ */
13
+ class Options extends Record({
14
+ types: ['ul_list', 'ol_list'],
15
+ typeItem: 'list_item',
16
+ typeDefault: 'paragraph'
17
+ }) {
18
+ // The possibles types for list containers
19
+ types: string[];
20
+ // The type of list items
21
+ typeItem: string;
22
+ // The type of default block in items
23
+ typeDefault: string;
24
+ }
25
+
26
+ export default Options;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ /**
10
+ * Return the current list item, from current selection or from a node.
11
+ */
12
+ function getCurrentItem(opts, value, block) {
13
+ var document = value.document;
14
+
15
+
16
+ if (!block) {
17
+ if (!value.selection.startKey) return null;
18
+ block = value.startBlock;
19
+ }
20
+
21
+ var parent = document.getParent(block.key);
22
+ return parent && parent.type === opts.typeItem ? parent : null;
23
+ }
24
+ exports.default = getCurrentItem;
@@ -0,0 +1,20 @@
1
+ // @flow
2
+ import { type Value, type Block } from 'slate';
3
+ import type Options from '../options';
4
+
5
+ /**
6
+ * Return the current list item, from current selection or from a node.
7
+ */
8
+ function getCurrentItem(opts: Options, value: Value, block?: Block): ?Block {
9
+ const { document } = value;
10
+
11
+ if (!block) {
12
+ if (!value.selection.startKey) return null;
13
+ block = value.startBlock;
14
+ }
15
+
16
+ const parent = document.getParent(block.key);
17
+ return parent && parent.type === opts.typeItem ? parent : null;
18
+ }
19
+
20
+ export default getCurrentItem;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ var _getCurrentItem = require('./getCurrentItem');
10
+
11
+ var _getCurrentItem2 = _interopRequireDefault(_getCurrentItem);
12
+
13
+ var _getListForItem = require('./getListForItem');
14
+
15
+ var _getListForItem2 = _interopRequireDefault(_getListForItem);
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
19
+ /**
20
+ * Return the parent list block, from current selection or from a node (paragraph in a list item).
21
+ */
22
+ function getCurrentList(opts, value, block) {
23
+ var item = (0, _getCurrentItem2.default)(opts, value, block);
24
+
25
+ if (!item) {
26
+ return null;
27
+ }
28
+
29
+ return (0, _getListForItem2.default)(opts, value, item);
30
+ }
31
+ exports.default = getCurrentList;
@@ -0,0 +1,21 @@
1
+ // @flow
2
+ import { type Value, type Block } from 'slate';
3
+
4
+ import type Options from '../options';
5
+ import getCurrentItem from './getCurrentItem';
6
+ import getListForItem from './getListForItem';
7
+
8
+ /**
9
+ * Return the parent list block, from current selection or from a node (paragraph in a list item).
10
+ */
11
+ function getCurrentList(opts: Options, value: Value, block?: Block): ?Block {
12
+ const item = getCurrentItem(opts, value, block);
13
+
14
+ if (!item) {
15
+ return null;
16
+ }
17
+
18
+ return getListForItem(opts, value, item);
19
+ }
20
+
21
+ export default getCurrentList;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ var _getCurrentItem = require('./getCurrentItem');
10
+
11
+ var _getCurrentItem2 = _interopRequireDefault(_getCurrentItem);
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ /**
16
+ * Get depth of current block in a document list
17
+ */
18
+ function getItemDepth(opts, value, block) {
19
+ var document = value.document,
20
+ startBlock = value.startBlock;
21
+
22
+ block = block || startBlock;
23
+
24
+ var currentItem = (0, _getCurrentItem2.default)(opts, value, block);
25
+ if (!currentItem) {
26
+ return 0;
27
+ }
28
+
29
+ var list = document.getParent(currentItem.key);
30
+
31
+ return 1 + getItemDepth(opts, value, list);
32
+ }
33
+
34
+ exports.default = getItemDepth;
@@ -0,0 +1,24 @@
1
+ // @flow
2
+ import { type Value, type Block } from 'slate';
3
+
4
+ import type Options from '../options';
5
+ import getCurrentItem from './getCurrentItem';
6
+
7
+ /**
8
+ * Get depth of current block in a document list
9
+ */
10
+ function getItemDepth(opts: Options, value: Value, block?: Block): number {
11
+ const { document, startBlock } = value;
12
+ block = block || startBlock;
13
+
14
+ const currentItem = getCurrentItem(opts, value, block);
15
+ if (!currentItem) {
16
+ return 0;
17
+ }
18
+
19
+ const list = document.getParent(currentItem.key);
20
+
21
+ return 1 + getItemDepth(opts, value, list);
22
+ }
23
+
24
+ export default getItemDepth;
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ var _immutable = require('immutable');
10
+
11
+ var _isList = require('./isList');
12
+
13
+ var _isList2 = _interopRequireDefault(_isList);
14
+
15
+ var _getCurrentItem = require('./getCurrentItem');
16
+
17
+ var _getCurrentItem2 = _interopRequireDefault(_getCurrentItem);
18
+
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
21
+ /**
22
+ * Return the list of items at the given range. The returned items are
23
+ * the highest list item blocks that cover the range.
24
+ *
25
+ * Returns an empty list if no list of items can cover the range
26
+ */
27
+ function getItemsAtRange(opts, value, range) {
28
+ range = range || value.selection;
29
+
30
+ if (!range.startKey) {
31
+ return (0, _immutable.List)();
32
+ }
33
+
34
+ var document = value.document;
35
+
36
+
37
+ var startBlock = document.getClosestBlock(range.startKey);
38
+ var endBlock = document.getClosestBlock(range.endKey);
39
+
40
+ if (startBlock === endBlock) {
41
+ var item = (0, _getCurrentItem2.default)(opts, value, startBlock);
42
+ return item ? (0, _immutable.List)([item]) : (0, _immutable.List)();
43
+ }
44
+
45
+ var ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);
46
+
47
+ if ((0, _isList2.default)(opts, ancestor)) {
48
+ var startPath = ancestor.getPath(startBlock.key);
49
+ var endPath = ancestor.getPath(endBlock.key);
50
+
51
+ return ancestor.nodes.slice(startPath[0], endPath[0] + 1);
52
+ } else if (ancestor.type === opts.typeItem) {
53
+ // The ancestor is the highest list item that covers the range
54
+ return (0, _immutable.List)([ancestor]);
55
+ }
56
+ // No list of items can cover the range
57
+ return (0, _immutable.List)();
58
+ }
59
+
60
+ exports.default = getItemsAtRange;
@@ -0,0 +1,51 @@
1
+ // @flow
2
+ import { type Value, type Block, type Range } from 'slate';
3
+ import { List } from 'immutable';
4
+
5
+ import type Options from '../options';
6
+ import isList from './isList';
7
+ import getCurrentItem from './getCurrentItem';
8
+
9
+ /**
10
+ * Return the list of items at the given range. The returned items are
11
+ * the highest list item blocks that cover the range.
12
+ *
13
+ * Returns an empty list if no list of items can cover the range
14
+ */
15
+ function getItemsAtRange(
16
+ opts: Options,
17
+ value: Value,
18
+ range?: Range
19
+ ): List<Block> {
20
+ range = range || value.selection;
21
+
22
+ if (!range.startKey) {
23
+ return List();
24
+ }
25
+
26
+ const { document } = value;
27
+
28
+ const startBlock = document.getClosestBlock(range.startKey);
29
+ const endBlock = document.getClosestBlock(range.endKey);
30
+
31
+ if (startBlock === endBlock) {
32
+ const item = getCurrentItem(opts, value, startBlock);
33
+ return item ? List([item]) : List();
34
+ }
35
+
36
+ const ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);
37
+
38
+ if (isList(opts, ancestor)) {
39
+ const startPath = ancestor.getPath(startBlock.key);
40
+ const endPath = ancestor.getPath(endBlock.key);
41
+
42
+ return ancestor.nodes.slice(startPath[0], endPath[0] + 1);
43
+ } else if (ancestor.type === opts.typeItem) {
44
+ // The ancestor is the highest list item that covers the range
45
+ return List([ancestor]);
46
+ }
47
+ // No list of items can cover the range
48
+ return List();
49
+ }
50
+
51
+ export default getItemsAtRange;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ var _isList = require('./isList');
10
+
11
+ var _isList2 = _interopRequireDefault(_isList);
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ /**
16
+ * Return the parent list block for an item block.
17
+ */
18
+ function getListForItem(opts, value, item) {
19
+ var document = value.document;
20
+
21
+ var parent = document.getParent(item.key);
22
+ return parent && (0, _isList2.default)(opts, parent) ? parent : null;
23
+ }
24
+
25
+ exports.default = getListForItem;
@@ -0,0 +1,16 @@
1
+ // @flow
2
+ import { type Value, type Block } from 'slate';
3
+
4
+ import type Options from '../options';
5
+ import isList from './isList';
6
+
7
+ /**
8
+ * Return the parent list block for an item block.
9
+ */
10
+ function getListForItem(opts: Options, value: Value, item: Block): ?Block {
11
+ const { document } = value;
12
+ const parent = document.getParent(item.key);
13
+ return parent && isList(opts, parent) ? parent : null;
14
+ }
15
+
16
+ export default getListForItem;
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ var _getCurrentItem = require('./getCurrentItem');
10
+
11
+ var _getCurrentItem2 = _interopRequireDefault(_getCurrentItem);
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ /**
16
+ * Return the previous item, from current selection or from a node.
17
+ */
18
+ function getPreviousItem(opts, value, block) {
19
+ var document = value.document,
20
+ startBlock = value.startBlock;
21
+
22
+ block = block || startBlock;
23
+
24
+ var currentItem = (0, _getCurrentItem2.default)(opts, value, block);
25
+ if (!currentItem) {
26
+ return null;
27
+ }
28
+
29
+ var previousSibling = document.getPreviousSibling(currentItem.key);
30
+
31
+ if (!previousSibling) {
32
+ return null;
33
+ } else if (previousSibling.type === opts.typeItem) {
34
+ return previousSibling;
35
+ }
36
+ return null;
37
+ }
38
+
39
+ exports.default = getPreviousItem;
@@ -0,0 +1,29 @@
1
+ // @flow
2
+ import { type Value, type Block } from 'slate';
3
+
4
+ import type Options from '../options';
5
+ import getCurrentItem from './getCurrentItem';
6
+
7
+ /**
8
+ * Return the previous item, from current selection or from a node.
9
+ */
10
+ function getPreviousItem(opts: Options, value: Value, block?: Block): ?Block {
11
+ const { document, startBlock } = value;
12
+ block = block || startBlock;
13
+
14
+ const currentItem = getCurrentItem(opts, value, block);
15
+ if (!currentItem) {
16
+ return null;
17
+ }
18
+
19
+ const previousSibling = document.getPreviousSibling(currentItem.key);
20
+
21
+ if (!previousSibling) {
22
+ return null;
23
+ } else if (previousSibling.type === opts.typeItem) {
24
+ return previousSibling;
25
+ }
26
+ return null;
27
+ }
28
+
29
+ export default getPreviousItem;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isSelectionInList = exports.isList = exports.getPreviousItem = exports.getListForItem = exports.getItemsAtRange = exports.getItemDepth = exports.getCurrentList = exports.getCurrentItem = undefined;
7
+
8
+ var _getCurrentItem = require('./getCurrentItem');
9
+
10
+ var _getCurrentItem2 = _interopRequireDefault(_getCurrentItem);
11
+
12
+ var _getCurrentList = require('./getCurrentList');
13
+
14
+ var _getCurrentList2 = _interopRequireDefault(_getCurrentList);
15
+
16
+ var _getItemDepth = require('./getItemDepth');
17
+
18
+ var _getItemDepth2 = _interopRequireDefault(_getItemDepth);
19
+
20
+ var _getItemsAtRange = require('./getItemsAtRange');
21
+
22
+ var _getItemsAtRange2 = _interopRequireDefault(_getItemsAtRange);
23
+
24
+ var _getListForItem = require('./getListForItem');
25
+
26
+ var _getListForItem2 = _interopRequireDefault(_getListForItem);
27
+
28
+ var _getPreviousItem = require('./getPreviousItem');
29
+
30
+ var _getPreviousItem2 = _interopRequireDefault(_getPreviousItem);
31
+
32
+ var _isList = require('./isList');
33
+
34
+ var _isList2 = _interopRequireDefault(_isList);
35
+
36
+ var _isSelectionInList = require('./isSelectionInList');
37
+
38
+ var _isSelectionInList2 = _interopRequireDefault(_isSelectionInList);
39
+
40
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
+
42
+ exports.getCurrentItem = _getCurrentItem2.default;
43
+ exports.getCurrentList = _getCurrentList2.default;
44
+ exports.getItemDepth = _getItemDepth2.default;
45
+ exports.getItemsAtRange = _getItemsAtRange2.default;
46
+ exports.getListForItem = _getListForItem2.default;
47
+ exports.getPreviousItem = _getPreviousItem2.default;
48
+ exports.isList = _isList2.default;
49
+ exports.isSelectionInList = _isSelectionInList2.default;
@@ -0,0 +1,19 @@
1
+ import getCurrentItem from './getCurrentItem';
2
+ import getCurrentList from './getCurrentList';
3
+ import getItemDepth from './getItemDepth';
4
+ import getItemsAtRange from './getItemsAtRange';
5
+ import getListForItem from './getListForItem';
6
+ import getPreviousItem from './getPreviousItem';
7
+ import isList from './isList';
8
+ import isSelectionInList from './isSelectionInList';
9
+
10
+ export {
11
+ getCurrentItem,
12
+ getCurrentList,
13
+ getItemDepth,
14
+ getItemsAtRange,
15
+ getListForItem,
16
+ getPreviousItem,
17
+ isList,
18
+ isSelectionInList
19
+ };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ /**
10
+ * True if the node is a list container
11
+ */
12
+ function isList(opts, node) {
13
+ return opts.types.includes(node.type);
14
+ }
15
+ exports.default = isList;
@@ -0,0 +1,13 @@
1
+ // @flow
2
+ import { type Node } from 'slate';
3
+
4
+ import type Options from '../options';
5
+
6
+ /**
7
+ * True if the node is a list container
8
+ */
9
+ function isList(opts: Options, node: Node): boolean {
10
+ return opts.types.includes(node.type);
11
+ }
12
+
13
+ export default isList;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require('slate');
8
+
9
+ var _getItemsAtRange = require('./getItemsAtRange');
10
+
11
+ var _getItemsAtRange2 = _interopRequireDefault(_getItemsAtRange);
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ /**
16
+ * True if selection is inside a list (and can be unwrapped)
17
+ */
18
+ function isSelectionInList(opts, value) {
19
+ return !(0, _getItemsAtRange2.default)(opts, value).isEmpty();
20
+ }
21
+
22
+ exports.default = isSelectionInList;
@@ -0,0 +1,14 @@
1
+ // @flow
2
+ import { type Value } from 'slate';
3
+
4
+ import type Options from '../options';
5
+ import getItemsAtRange from './getItemsAtRange';
6
+
7
+ /**
8
+ * True if selection is inside a list (and can be unwrapped)
9
+ */
10
+ function isSelectionInList(opts: Options, value: Value): boolean {
11
+ return !getItemsAtRange(opts, value).isEmpty();
12
+ }
13
+
14
+ export default isSelectionInList;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateNode = exports.schema = undefined;
7
+
8
+ var _schema = require('./schema');
9
+
10
+ var _schema2 = _interopRequireDefault(_schema);
11
+
12
+ var _validateNode = require('./validateNode');
13
+
14
+ var _validateNode2 = _interopRequireDefault(_validateNode);
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ exports.schema = _schema2.default;
19
+ exports.validateNode = _validateNode2.default;
@@ -0,0 +1,4 @@
1
+ import schema from './schema';
2
+ import validateNode from './validateNode';
3
+
4
+ export { schema, validateNode };