@atlaskit/editor-plugin-list 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +14 -0
- package/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/cjs/actions/conversions.js +153 -0
- package/dist/cjs/actions/indent-list-items-selected.js +125 -0
- package/dist/cjs/actions/indent-list.js +49 -0
- package/dist/cjs/actions/join-list-items-forward.js +59 -0
- package/dist/cjs/actions/join-list-items-scenarios/index.js +40 -0
- package/dist/cjs/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +88 -0
- package/dist/cjs/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +85 -0
- package/dist/cjs/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +79 -0
- package/dist/cjs/actions/join-list-items-scenarios/join-paragraph-with-list.js +45 -0
- package/dist/cjs/actions/join-list-items-scenarios/join-sibling-list-items.js +56 -0
- package/dist/cjs/actions/merge-lists.js +27 -0
- package/dist/cjs/actions/outdent-list-items-selected.js +291 -0
- package/dist/cjs/actions/wrap-and-join-lists.js +100 -0
- package/dist/cjs/commands/indent-list.js +71 -0
- package/dist/cjs/commands/index.js +350 -0
- package/dist/cjs/commands/isFirstChildOfParent.js +12 -0
- package/dist/cjs/commands/join-list-item-forward.js +61 -0
- package/dist/cjs/commands/listBackspace.js +284 -0
- package/dist/cjs/commands/outdent-list.js +70 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/messages.js +37 -0
- package/dist/cjs/plugin.js +133 -0
- package/dist/cjs/pm-plugins/input-rules/create-list-input-rule.js +63 -0
- package/dist/cjs/pm-plugins/input-rules/index.js +38 -0
- package/dist/cjs/pm-plugins/input-rules/wrapping-join-rule.js +60 -0
- package/dist/cjs/pm-plugins/keymap.js +27 -0
- package/dist/cjs/pm-plugins/main.js +166 -0
- package/dist/cjs/transforms.js +99 -0
- package/dist/cjs/types.js +4 -1
- package/dist/cjs/utils/analytics.js +22 -0
- package/dist/cjs/utils/find.js +68 -0
- package/dist/cjs/utils/indentation.js +22 -0
- package/dist/cjs/utils/mark.js +40 -0
- package/dist/cjs/utils/node.js +16 -0
- package/dist/cjs/utils/selection.js +95 -0
- package/dist/es2019/actions/conversions.js +160 -0
- package/dist/es2019/actions/indent-list-items-selected.js +124 -0
- package/dist/es2019/actions/indent-list.js +44 -0
- package/dist/es2019/actions/join-list-items-forward.js +54 -0
- package/dist/es2019/actions/join-list-items-scenarios/index.js +5 -0
- package/dist/es2019/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +74 -0
- package/dist/es2019/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +77 -0
- package/dist/es2019/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +71 -0
- package/dist/es2019/actions/join-list-items-scenarios/join-paragraph-with-list.js +37 -0
- package/dist/es2019/actions/join-list-items-scenarios/join-sibling-list-items.js +48 -0
- package/dist/es2019/actions/merge-lists.js +24 -0
- package/dist/es2019/actions/outdent-list-items-selected.js +295 -0
- package/dist/es2019/actions/wrap-and-join-lists.js +93 -0
- package/dist/es2019/commands/indent-list.js +62 -0
- package/dist/es2019/commands/index.js +326 -0
- package/dist/es2019/commands/isFirstChildOfParent.js +7 -0
- package/dist/es2019/commands/join-list-item-forward.js +53 -0
- package/dist/es2019/commands/listBackspace.js +276 -0
- package/dist/es2019/commands/outdent-list.js +60 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/messages.js +29 -0
- package/dist/es2019/plugin.js +121 -0
- package/dist/es2019/pm-plugins/input-rules/create-list-input-rule.js +56 -0
- package/dist/es2019/pm-plugins/input-rules/index.js +35 -0
- package/dist/es2019/pm-plugins/input-rules/wrapping-join-rule.js +55 -0
- package/dist/es2019/pm-plugins/keymap.js +19 -0
- package/dist/es2019/pm-plugins/main.js +156 -0
- package/dist/es2019/transforms.js +101 -0
- package/dist/es2019/types.js +1 -1
- package/dist/es2019/utils/analytics.js +12 -0
- package/dist/es2019/utils/find.js +61 -0
- package/dist/es2019/utils/indentation.js +15 -0
- package/dist/es2019/utils/mark.js +30 -0
- package/dist/es2019/utils/node.js +12 -0
- package/dist/es2019/utils/selection.js +96 -0
- package/dist/esm/actions/conversions.js +147 -0
- package/dist/esm/actions/indent-list-items-selected.js +117 -0
- package/dist/esm/actions/indent-list.js +43 -0
- package/dist/esm/actions/join-list-items-forward.js +52 -0
- package/dist/esm/actions/join-list-items-scenarios/index.js +5 -0
- package/dist/esm/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +81 -0
- package/dist/esm/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +78 -0
- package/dist/esm/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +72 -0
- package/dist/esm/actions/join-list-items-scenarios/join-paragraph-with-list.js +38 -0
- package/dist/esm/actions/join-list-items-scenarios/join-sibling-list-items.js +49 -0
- package/dist/esm/actions/merge-lists.js +21 -0
- package/dist/esm/actions/outdent-list-items-selected.js +283 -0
- package/dist/esm/actions/wrap-and-join-lists.js +94 -0
- package/dist/esm/commands/indent-list.js +63 -0
- package/dist/esm/commands/index.js +324 -0
- package/dist/esm/commands/isFirstChildOfParent.js +5 -0
- package/dist/esm/commands/join-list-item-forward.js +53 -0
- package/dist/esm/commands/listBackspace.js +275 -0
- package/dist/esm/commands/outdent-list.js +62 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/messages.js +29 -0
- package/dist/esm/plugin.js +126 -0
- package/dist/esm/pm-plugins/input-rules/create-list-input-rule.js +57 -0
- package/dist/esm/pm-plugins/input-rules/index.js +32 -0
- package/dist/esm/pm-plugins/input-rules/wrapping-join-rule.js +54 -0
- package/dist/esm/pm-plugins/keymap.js +19 -0
- package/dist/esm/pm-plugins/main.js +156 -0
- package/dist/esm/transforms.js +91 -0
- package/dist/esm/types.js +1 -1
- package/dist/esm/utils/analytics.js +12 -0
- package/dist/esm/utils/find.js +59 -0
- package/dist/esm/utils/indentation.js +15 -0
- package/dist/esm/utils/mark.js +33 -0
- package/dist/esm/utils/node.js +10 -0
- package/dist/esm/utils/selection.js +81 -0
- package/dist/types/actions/conversions.d.ts +6 -0
- package/dist/types/actions/indent-list-items-selected.d.ts +2 -0
- package/dist/types/actions/indent-list.d.ts +2 -0
- package/dist/types/actions/join-list-items-forward.d.ts +13 -0
- package/dist/types/actions/join-list-items-scenarios/index.d.ts +5 -0
- package/dist/types/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +9 -0
- package/dist/types/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +9 -0
- package/dist/types/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +9 -0
- package/dist/types/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +9 -0
- package/dist/types/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +9 -0
- package/dist/types/actions/merge-lists.d.ts +7 -0
- package/dist/types/actions/outdent-list-items-selected.d.ts +3 -0
- package/dist/types/actions/wrap-and-join-lists.d.ts +17 -0
- package/dist/types/commands/indent-list.d.ts +6 -0
- package/dist/types/commands/index.d.ts +16 -0
- package/dist/types/commands/isFirstChildOfParent.d.ts +2 -0
- package/dist/types/commands/join-list-item-forward.d.ts +3 -0
- package/dist/types/commands/listBackspace.d.ts +10 -0
- package/dist/types/commands/outdent-list.d.ts +6 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/messages.d.ts +27 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/pm-plugins/input-rules/create-list-input-rule.d.ts +11 -0
- package/dist/types/pm-plugins/input-rules/index.d.ts +5 -0
- package/dist/types/pm-plugins/input-rules/wrapping-join-rule.d.ts +13 -0
- package/dist/types/pm-plugins/keymap.d.ts +5 -0
- package/dist/types/pm-plugins/main.d.ts +11 -0
- package/dist/types/transforms.d.ts +4 -0
- package/dist/types/types.d.ts +4 -6
- package/dist/types/utils/analytics.d.ts +5 -0
- package/dist/types/utils/find.d.ts +10 -0
- package/dist/types/utils/indentation.d.ts +2 -0
- package/dist/types/utils/mark.d.ts +8 -0
- package/dist/types/utils/node.d.ts +2 -0
- package/dist/types/utils/selection.d.ts +14 -0
- package/dist/types-ts4.5/actions/conversions.d.ts +6 -0
- package/dist/types-ts4.5/actions/indent-list-items-selected.d.ts +2 -0
- package/dist/types-ts4.5/actions/indent-list.d.ts +2 -0
- package/dist/types-ts4.5/actions/join-list-items-forward.d.ts +16 -0
- package/dist/types-ts4.5/actions/join-list-items-scenarios/index.d.ts +5 -0
- package/dist/types-ts4.5/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +9 -0
- package/dist/types-ts4.5/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +9 -0
- package/dist/types-ts4.5/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +9 -0
- package/dist/types-ts4.5/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +9 -0
- package/dist/types-ts4.5/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +9 -0
- package/dist/types-ts4.5/actions/merge-lists.d.ts +7 -0
- package/dist/types-ts4.5/actions/outdent-list-items-selected.d.ts +3 -0
- package/dist/types-ts4.5/actions/wrap-and-join-lists.d.ts +17 -0
- package/dist/types-ts4.5/commands/indent-list.d.ts +6 -0
- package/dist/types-ts4.5/commands/index.d.ts +16 -0
- package/dist/types-ts4.5/commands/isFirstChildOfParent.d.ts +2 -0
- package/dist/types-ts4.5/commands/join-list-item-forward.d.ts +3 -0
- package/dist/types-ts4.5/commands/listBackspace.d.ts +13 -0
- package/dist/types-ts4.5/commands/outdent-list.d.ts +6 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/messages.d.ts +27 -0
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/input-rules/create-list-input-rule.d.ts +11 -0
- package/dist/types-ts4.5/pm-plugins/input-rules/index.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/input-rules/wrapping-join-rule.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +11 -0
- package/dist/types-ts4.5/transforms.d.ts +4 -0
- package/dist/types-ts4.5/types.d.ts +4 -6
- package/dist/types-ts4.5/utils/analytics.d.ts +5 -0
- package/dist/types-ts4.5/utils/find.d.ts +10 -0
- package/dist/types-ts4.5/utils/indentation.d.ts +2 -0
- package/dist/types-ts4.5/utils/mark.d.ts +8 -0
- package/dist/types-ts4.5/utils/node.d.ts +2 -0
- package/dist/types-ts4.5/utils/selection.d.ts +14 -0
- package/package.json +8 -5
- package/report.api.md +6 -2
- package/tmp/api-report-tmp.d.ts +4 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
+
import { setGapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
6
|
+
import { CodeBlockSharedCssClassName, getOrderedListInlineStyles, listItemCounterPadding } from '@atlaskit/editor-common/styles';
|
|
7
|
+
import { getItemCounterDigitsSize, isListNode, pluginFactory } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
+
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import { isWrappingPossible } from '../utils/selection';
|
|
12
|
+
var listPluginKey = new PluginKey('listPlugin');
|
|
13
|
+
export var pluginKey = listPluginKey;
|
|
14
|
+
var initialState = {
|
|
15
|
+
bulletListActive: false,
|
|
16
|
+
bulletListDisabled: false,
|
|
17
|
+
orderedListActive: false,
|
|
18
|
+
orderedListDisabled: false,
|
|
19
|
+
decorationSet: DecorationSet.empty
|
|
20
|
+
};
|
|
21
|
+
export var getDecorations = function getDecorations(doc, state, featureFlags) {
|
|
22
|
+
var decorations = [];
|
|
23
|
+
|
|
24
|
+
// this stack keeps track of each (nested) list to calculate the indentation level
|
|
25
|
+
var processedListsStack = [];
|
|
26
|
+
doc.nodesBetween(0, doc.content.size, function (node, currentNodeStartPos) {
|
|
27
|
+
if (processedListsStack.length > 0) {
|
|
28
|
+
var isOutsideLastList = true;
|
|
29
|
+
while (isOutsideLastList && processedListsStack.length > 0) {
|
|
30
|
+
var lastList = processedListsStack[processedListsStack.length - 1];
|
|
31
|
+
var lastListEndPos = lastList.startPos + lastList.node.nodeSize;
|
|
32
|
+
isOutsideLastList = currentNodeStartPos >= lastListEndPos;
|
|
33
|
+
// once we finish iterating over each innermost list, pop the stack to
|
|
34
|
+
// decrease the indent level attribute accordingly
|
|
35
|
+
if (isOutsideLastList) {
|
|
36
|
+
processedListsStack.pop();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (isListNode(node)) {
|
|
41
|
+
processedListsStack.push({
|
|
42
|
+
node: node,
|
|
43
|
+
startPos: currentNodeStartPos
|
|
44
|
+
});
|
|
45
|
+
var from = currentNodeStartPos;
|
|
46
|
+
var to = currentNodeStartPos + node.nodeSize;
|
|
47
|
+
var depth = processedListsStack.length;
|
|
48
|
+
decorations.push(Decoration.node(from, to, {
|
|
49
|
+
'data-indent-level': "".concat(depth)
|
|
50
|
+
}));
|
|
51
|
+
if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
|
|
52
|
+
var _node$attrs;
|
|
53
|
+
// If a numbered list has item counters numbering >= 100, we'll need to add special
|
|
54
|
+
// spacing to account for the extra digit chars
|
|
55
|
+
var digitsSize = getItemCounterDigitsSize({
|
|
56
|
+
itemsCount: node === null || node === void 0 ? void 0 : node.childCount,
|
|
57
|
+
order: node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.order
|
|
58
|
+
});
|
|
59
|
+
if (digitsSize) {
|
|
60
|
+
decorations.push(Decoration.node(from, to, {
|
|
61
|
+
style: getOrderedListInlineStyles(digitsSize, 'string')
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
if (node.childCount >= 100) {
|
|
66
|
+
decorations.push(Decoration.node(from, to, {
|
|
67
|
+
'data-child-count': '100+'
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return DecorationSet.empty.add(doc, decorations);
|
|
74
|
+
};
|
|
75
|
+
var handleDocChanged = function handleDocChanged(featureFlags) {
|
|
76
|
+
return function (tr, pluginState, editorState) {
|
|
77
|
+
var nextPluginState = handleSelectionChanged(tr, pluginState);
|
|
78
|
+
var decorationSet = getDecorations(tr.doc, editorState, featureFlags);
|
|
79
|
+
return _objectSpread(_objectSpread({}, nextPluginState), {}, {
|
|
80
|
+
decorationSet: decorationSet
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
|
|
85
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
86
|
+
bulletList = _tr$doc$type$schema$n.bulletList,
|
|
87
|
+
orderedList = _tr$doc$type$schema$n.orderedList;
|
|
88
|
+
var listParent = findParentNodeOfType([bulletList, orderedList])(tr.selection);
|
|
89
|
+
var bulletListActive = !!listParent && listParent.node.type === bulletList;
|
|
90
|
+
var orderedListActive = !!listParent && listParent.node.type === orderedList;
|
|
91
|
+
var bulletListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(bulletList, tr.selection));
|
|
92
|
+
var orderedListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(orderedList, tr.selection));
|
|
93
|
+
if (bulletListActive !== pluginState.bulletListActive || orderedListActive !== pluginState.orderedListActive || bulletListDisabled !== pluginState.bulletListDisabled || orderedListDisabled !== pluginState.orderedListDisabled) {
|
|
94
|
+
var nextPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
95
|
+
bulletListActive: bulletListActive,
|
|
96
|
+
orderedListActive: orderedListActive,
|
|
97
|
+
bulletListDisabled: bulletListDisabled,
|
|
98
|
+
orderedListDisabled: orderedListDisabled
|
|
99
|
+
});
|
|
100
|
+
return nextPluginState;
|
|
101
|
+
}
|
|
102
|
+
return pluginState;
|
|
103
|
+
};
|
|
104
|
+
var reducer = function reducer() {
|
|
105
|
+
return function (state) {
|
|
106
|
+
return state;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
var createInitialState = function createInitialState(featureFlags) {
|
|
110
|
+
return function (state) {
|
|
111
|
+
return _objectSpread(_objectSpread({}, initialState), {}, {
|
|
112
|
+
decorationSet: getDecorations(state.doc, state, featureFlags)
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export var createPlugin = function createPlugin(eventDispatch, featureFlags) {
|
|
117
|
+
var _pluginFactory = pluginFactory(listPluginKey, reducer(), {
|
|
118
|
+
onDocChanged: handleDocChanged(featureFlags),
|
|
119
|
+
onSelectionChanged: handleSelectionChanged
|
|
120
|
+
}),
|
|
121
|
+
getPluginState = _pluginFactory.getPluginState,
|
|
122
|
+
createPluginState = _pluginFactory.createPluginState;
|
|
123
|
+
return new SafePlugin({
|
|
124
|
+
state: createPluginState(eventDispatch, createInitialState(featureFlags)),
|
|
125
|
+
key: listPluginKey,
|
|
126
|
+
props: {
|
|
127
|
+
decorations: function decorations(state) {
|
|
128
|
+
var _getPluginState = getPluginState(state),
|
|
129
|
+
decorationSet = _getPluginState.decorationSet;
|
|
130
|
+
return decorationSet;
|
|
131
|
+
},
|
|
132
|
+
handleClick: function handleClick(view, pos, event) {
|
|
133
|
+
var state = view.state;
|
|
134
|
+
if (['LI', 'UL'].includes((event === null || event === void 0 ? void 0 : event.target).tagName)) {
|
|
135
|
+
var _nodeAtPos$firstChild;
|
|
136
|
+
var nodeAtPos = state.tr.doc.nodeAt(pos);
|
|
137
|
+
var _view$state$schema$no = view.state.schema.nodes,
|
|
138
|
+
listItem = _view$state$schema$no.listItem,
|
|
139
|
+
codeBlock = _view$state$schema$no.codeBlock;
|
|
140
|
+
if ((nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type) === listItem && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : (_nodeAtPos$firstChild = nodeAtPos.firstChild) === null || _nodeAtPos$firstChild === void 0 ? void 0 : _nodeAtPos$firstChild.type) === codeBlock) {
|
|
141
|
+
var _document, _document$elementFrom;
|
|
142
|
+
var bufferPx = 50;
|
|
143
|
+
var isCodeBlockNextToListMarker = Boolean((_document = document) === null || _document === void 0 ? void 0 : (_document$elementFrom = _document.elementFromPoint(event.clientX + (listItemCounterPadding + bufferPx), event.clientY)) === null || _document$elementFrom === void 0 ? void 0 : _document$elementFrom.closest(".".concat(CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER)));
|
|
144
|
+
if (isCodeBlockNextToListMarker) {
|
|
145
|
+
// +1 needed to put cursor inside li
|
|
146
|
+
// otherwise gap cursor markup will be injected as immediate child of ul resulting in invalid html
|
|
147
|
+
setGapCursorSelection(view, pos + 1, Side.LEFT);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Fragment, NodeRange, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { liftTarget, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
import { getListLiftTarget } from './utils/indentation';
|
|
5
|
+
function liftListItem(selection, tr) {
|
|
6
|
+
var $from = selection.$from,
|
|
7
|
+
$to = selection.$to;
|
|
8
|
+
var nodeType = tr.doc.type.schema.nodes.listItem;
|
|
9
|
+
var range = $from.blockRange($to, function (node) {
|
|
10
|
+
return !!node.childCount && !!node.firstChild && node.firstChild.type === nodeType;
|
|
11
|
+
});
|
|
12
|
+
if (!range || range.depth < 2 || $from.node(range.depth - 1).type !== nodeType) {
|
|
13
|
+
return tr;
|
|
14
|
+
}
|
|
15
|
+
var end = range.end;
|
|
16
|
+
var endOfList = $to.end(range.depth);
|
|
17
|
+
if (end < endOfList) {
|
|
18
|
+
tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment.from(nodeType.create(undefined, range.parent.copy())), 1, 0), 1, true));
|
|
19
|
+
range = new NodeRange(tr.doc.resolve($from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
20
|
+
}
|
|
21
|
+
return tr.lift(range, liftTarget(range)).scrollIntoView();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Function will lift list item following selection to level-1.
|
|
25
|
+
export function liftFollowingList(from, to, rootListDepth, tr) {
|
|
26
|
+
var listItem = tr.doc.type.schema.nodes.listItem;
|
|
27
|
+
var lifted = false;
|
|
28
|
+
tr.doc.nodesBetween(from, to, function (node, pos) {
|
|
29
|
+
if (!lifted && node.type === listItem && pos > from) {
|
|
30
|
+
lifted = true;
|
|
31
|
+
var listDepth = rootListDepth + 3;
|
|
32
|
+
while (listDepth > rootListDepth + 2) {
|
|
33
|
+
var start = tr.doc.resolve(tr.mapping.map(pos));
|
|
34
|
+
listDepth = start.depth;
|
|
35
|
+
var end = tr.doc.resolve(tr.mapping.map(pos + node.textContent.length));
|
|
36
|
+
var sel = new TextSelection(start, end);
|
|
37
|
+
tr = liftListItem(sel, tr);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return tr;
|
|
42
|
+
}
|
|
43
|
+
export function liftNodeSelectionList(selection, tr) {
|
|
44
|
+
var from = selection.from;
|
|
45
|
+
var listItem = tr.doc.type.schema.nodes.listItem;
|
|
46
|
+
var mappedPosition = tr.mapping.map(from);
|
|
47
|
+
var nodeAtPos = tr.doc.nodeAt(mappedPosition);
|
|
48
|
+
var start = tr.doc.resolve(mappedPosition);
|
|
49
|
+
if ((start === null || start === void 0 ? void 0 : start.parent.type) !== listItem) {
|
|
50
|
+
return tr;
|
|
51
|
+
}
|
|
52
|
+
var end = tr.doc.resolve(mappedPosition + ((nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.nodeSize) || 1));
|
|
53
|
+
var range = start.blockRange(end);
|
|
54
|
+
if (range) {
|
|
55
|
+
var _liftTarget = getListLiftTarget(start);
|
|
56
|
+
tr.lift(range, _liftTarget);
|
|
57
|
+
}
|
|
58
|
+
return tr;
|
|
59
|
+
}
|
|
60
|
+
// The function will list paragraphs in selection out to level 1 below root list.
|
|
61
|
+
export function liftTextSelectionList(selection, tr) {
|
|
62
|
+
var from = selection.from,
|
|
63
|
+
to = selection.to;
|
|
64
|
+
var paragraph = tr.doc.type.schema.nodes.paragraph;
|
|
65
|
+
var listCol = [];
|
|
66
|
+
tr.doc.nodesBetween(from, to, function (node, pos) {
|
|
67
|
+
if (node.type === paragraph) {
|
|
68
|
+
listCol.push({
|
|
69
|
+
node: node,
|
|
70
|
+
pos: pos
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
for (var i = listCol.length - 1; i >= 0; i--) {
|
|
75
|
+
var _paragraph = listCol[i];
|
|
76
|
+
var start = tr.doc.resolve(tr.mapping.map(_paragraph.pos));
|
|
77
|
+
if (start.depth > 0) {
|
|
78
|
+
var end = void 0;
|
|
79
|
+
if (_paragraph.node.textContent && _paragraph.node.textContent.length > 0) {
|
|
80
|
+
end = tr.doc.resolve(tr.mapping.map(_paragraph.pos + _paragraph.node.textContent.length));
|
|
81
|
+
} else {
|
|
82
|
+
end = tr.doc.resolve(tr.mapping.map(_paragraph.pos + 1));
|
|
83
|
+
}
|
|
84
|
+
var range = start.blockRange(end);
|
|
85
|
+
if (range) {
|
|
86
|
+
tr.lift(range, getListLiftTarget(start));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return tr;
|
|
91
|
+
}
|
package/dist/esm/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var MAX_NESTED_LIST_INDENTATION = 6;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
export var RESTART_LISTS_ANALYTICS_KEY = 'restartListsAnalytics';
|
|
5
|
+
export var getRestartListsAttributes = function getRestartListsAttributes(tr) {
|
|
6
|
+
var _tr$getMeta;
|
|
7
|
+
return (_tr$getMeta = tr.getMeta(RESTART_LISTS_ANALYTICS_KEY)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {};
|
|
8
|
+
};
|
|
9
|
+
export var storeRestartListsAttributes = function storeRestartListsAttributes(tr, attributes) {
|
|
10
|
+
var meta = getRestartListsAttributes(tr);
|
|
11
|
+
tr.setMeta(RESTART_LISTS_ANALYTICS_KEY, _objectSpread(_objectSpread({}, meta), attributes));
|
|
12
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isListItemNode, isListNode } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
export function findFirstParentListNode($pos) {
|
|
4
|
+
var currentNode = $pos.doc.nodeAt($pos.pos);
|
|
5
|
+
var listNodePosition = null;
|
|
6
|
+
if (isListNode(currentNode)) {
|
|
7
|
+
listNodePosition = $pos.pos;
|
|
8
|
+
} else {
|
|
9
|
+
var result = findParentNodeClosestToPos($pos, isListNode);
|
|
10
|
+
listNodePosition = result && result.pos;
|
|
11
|
+
}
|
|
12
|
+
if (listNodePosition == null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
var node = $pos.doc.nodeAt(listNodePosition);
|
|
16
|
+
if (!node) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
node: node,
|
|
21
|
+
pos: listNodePosition
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function findFirstParentListItemNode($pos) {
|
|
25
|
+
var currentNode = $pos.doc.nodeAt($pos.pos);
|
|
26
|
+
var listItemNodePosition = isListItemNode(currentNode) ? $pos : findParentNodeClosestToPos($pos, isListItemNode);
|
|
27
|
+
if (!listItemNodePosition || listItemNodePosition.pos === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
var node = $pos.doc.nodeAt(listItemNodePosition.pos);
|
|
31
|
+
if (!node) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
node: node,
|
|
36
|
+
pos: listItemNodePosition.pos
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export var findRootParentListNode = function findRootParentListNode($pos) {
|
|
40
|
+
var doc = $pos.doc;
|
|
41
|
+
if ($pos.pos + 1 > doc.content.size) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if ($pos.depth === 0) {
|
|
45
|
+
return doc.resolve($pos.pos + 1);
|
|
46
|
+
}
|
|
47
|
+
var currentNode = doc.nodeAt($pos.pos);
|
|
48
|
+
var beforePosition = $pos.before();
|
|
49
|
+
var nodeBefore = doc.nodeAt(beforePosition);
|
|
50
|
+
if (isListNode(currentNode) && !isListItemNode(nodeBefore)) {
|
|
51
|
+
return doc.resolve($pos.pos + 1);
|
|
52
|
+
}
|
|
53
|
+
var parentList = findParentNodeClosestToPos($pos, isListNode);
|
|
54
|
+
if (!parentList) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
var listNodePosition = doc.resolve(parentList.pos);
|
|
58
|
+
return findRootParentListNode(listNodePosition);
|
|
59
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isListItemNode, isListNode } from '@atlaskit/editor-common/utils';
|
|
2
|
+
// This will return (depth - 1) for root list parent of a list.
|
|
3
|
+
export var getListLiftTarget = function getListLiftTarget(resPos) {
|
|
4
|
+
var target = resPos.depth;
|
|
5
|
+
for (var i = resPos.depth; i > 0; i--) {
|
|
6
|
+
var node = resPos.node(i);
|
|
7
|
+
if (isListNode(node)) {
|
|
8
|
+
target = i;
|
|
9
|
+
}
|
|
10
|
+
if (!isListItemNode(node) && !isListNode(node)) {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return target - 1;
|
|
15
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export var sanitiseMarksInSelection = function sanitiseMarksInSelection(tr, newParentType) {
|
|
2
|
+
var _tr$selection = tr.selection,
|
|
3
|
+
from = _tr$selection.from,
|
|
4
|
+
to = _tr$selection.to;
|
|
5
|
+
var nodesSanitized = [];
|
|
6
|
+
tr.doc.nodesBetween(from, to, function (node, pos, parent) {
|
|
7
|
+
if (node.isText) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
// Skip expands and layouts if they are outside selection
|
|
11
|
+
// but continue to iterate over their children.
|
|
12
|
+
if (['expand', 'layoutSection'].includes(node.type.name) && (pos < from || pos > to)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
node.marks.forEach(function (mark) {
|
|
16
|
+
if (!(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || newParentType && !newParentType.allowsMarkType(mark.type)) {
|
|
17
|
+
var filteredMarks = node.marks.filter(function (m) {
|
|
18
|
+
return m.type !== mark.type;
|
|
19
|
+
});
|
|
20
|
+
var position = pos > 0 ? pos : 0;
|
|
21
|
+
var marksRemoved = node.marks.filter(function (m) {
|
|
22
|
+
return m.type === mark.type;
|
|
23
|
+
});
|
|
24
|
+
nodesSanitized.push({
|
|
25
|
+
node: node,
|
|
26
|
+
marksRemoved: marksRemoved
|
|
27
|
+
});
|
|
28
|
+
tr.setNodeMarkup(position, undefined, node.attrs, filteredMarks);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return nodesSanitized;
|
|
33
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isListItemNode } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
export function isListNodeValidContent(node) {
|
|
4
|
+
var bulletList = node.type.schema.nodes.bulletList;
|
|
5
|
+
if (!bulletList) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
var listFragment = Fragment.from(bulletList.createAndFill());
|
|
9
|
+
return !isListItemNode(node) && node.type.validContent(listFragment);
|
|
10
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
2
|
+
import { isListItemNode, isListNode, isParagraphNode } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
import { findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
export var isPosInsideParagraph = function isPosInsideParagraph($pos) {
|
|
6
|
+
return $pos.parent.type.name === 'paragraph';
|
|
7
|
+
};
|
|
8
|
+
export var isPosInsideList = function isPosInsideList($pos) {
|
|
9
|
+
var posGrandParent = $pos.node(-1);
|
|
10
|
+
return isListItemNode($pos.parent) || isListNode($pos.parent) || isListItemNode(posGrandParent);
|
|
11
|
+
};
|
|
12
|
+
export var isWrappingPossible = function isWrappingPossible(nodeType, selection) {
|
|
13
|
+
var $from = selection.$from,
|
|
14
|
+
$to = selection.$to;
|
|
15
|
+
var range;
|
|
16
|
+
if (selection instanceof GapCursorSelection && $from.nodeAfter) {
|
|
17
|
+
var nodeSize = $from.nodeAfter.nodeSize || 1;
|
|
18
|
+
range = $from.blockRange($from.doc.resolve($from.pos + nodeSize));
|
|
19
|
+
} else {
|
|
20
|
+
range = $from.blockRange($to);
|
|
21
|
+
}
|
|
22
|
+
if (!range) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
var wrap = findWrapping(range, nodeType);
|
|
26
|
+
if (!wrap) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// canOutdent
|
|
33
|
+
export var isInsideListItem = function isInsideListItem(state) {
|
|
34
|
+
var parent = state.selection.$from.parent;
|
|
35
|
+
var listItem = state.schema.nodes.listItem;
|
|
36
|
+
if (state.selection instanceof GapCursorSelection) {
|
|
37
|
+
return isListItemNode(parent);
|
|
38
|
+
}
|
|
39
|
+
return hasParentNodeOfType(listItem)(state.selection) && isParagraphNode(parent);
|
|
40
|
+
};
|
|
41
|
+
export var isInsideTableCell = function isInsideTableCell(state) {
|
|
42
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
43
|
+
tableCell = _state$schema$nodes.tableCell,
|
|
44
|
+
tableHeader = _state$schema$nodes.tableHeader;
|
|
45
|
+
return !!findParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
46
|
+
};
|
|
47
|
+
export var canJoinToPreviousListItem = function canJoinToPreviousListItem(state) {
|
|
48
|
+
var $from = state.selection.$from;
|
|
49
|
+
var $before = state.doc.resolve($from.pos - 1);
|
|
50
|
+
var nodeBefore = $before ? $before.nodeBefore : null;
|
|
51
|
+
if (state.selection instanceof GapCursorSelection) {
|
|
52
|
+
nodeBefore = $from.nodeBefore;
|
|
53
|
+
}
|
|
54
|
+
return isListNode(nodeBefore);
|
|
55
|
+
};
|
|
56
|
+
export var selectionContainsList = function selectionContainsList(tr) {
|
|
57
|
+
var _tr$selection = tr.selection,
|
|
58
|
+
from = _tr$selection.from,
|
|
59
|
+
to = _tr$selection.to;
|
|
60
|
+
var foundListNode = null;
|
|
61
|
+
tr.doc.nodesBetween(from, to, function (node) {
|
|
62
|
+
if (isListNode(node)) {
|
|
63
|
+
foundListNode = node;
|
|
64
|
+
}
|
|
65
|
+
if (foundListNode) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
return foundListNode;
|
|
71
|
+
};
|
|
72
|
+
export var createListNodeRange = function createListNodeRange(_ref) {
|
|
73
|
+
var selection = _ref.selection;
|
|
74
|
+
var $from = selection.$from,
|
|
75
|
+
$to = selection.$to;
|
|
76
|
+
var range = $from.blockRange($to, isListNode);
|
|
77
|
+
if (!range) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return range;
|
|
81
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare function convertListType({ tr, nextListNodeType, }: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
nextListNodeType: NodeType;
|
|
6
|
+
}): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { WalkNode } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
type ScenariosAllowed = LIST_TEXT_SCENARIOS.JOIN_PARAGRAPH_WITH_LIST | LIST_TEXT_SCENARIOS.JOIN_SIBLINGS | LIST_TEXT_SCENARIOS.JOIN_DESCENDANT_TO_PARENT | LIST_TEXT_SCENARIOS.JOIN_PARENT_SIBLING_TO_PARENT_CHILD | LIST_TEXT_SCENARIOS.JOIN_LIST_ITEM_WITH_PARAGRAPH;
|
|
6
|
+
type DeleteAction = (props: {
|
|
7
|
+
tr: Transaction;
|
|
8
|
+
$next: ResolvedPos;
|
|
9
|
+
$head: ResolvedPos;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
type ScenarioAction = false | [ScenariosAllowed, DeleteAction];
|
|
12
|
+
export declare const calcJoinListScenario: (walkNode: WalkNode, $head: ResolvedPos) => ScenarioAction;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { joinParagrapWithList } from './join-paragraph-with-list';
|
|
2
|
+
export { joinSiblingListItems } from './join-sibling-list-items';
|
|
3
|
+
export { joinNestedListWithParentListItem } from './join-nested-list-with-parent-list-item';
|
|
4
|
+
export { joinListItemWithParentNestedList } from './join-list-item-with-parent-nested-list';
|
|
5
|
+
export { joinListItemWithParagraph } from './join-list-item-with-paragraph';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type DeleteAction = (props: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
$next: ResolvedPos;
|
|
6
|
+
$head: ResolvedPos;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
export declare const joinListItemWithParagraph: DeleteAction;
|
|
9
|
+
export {};
|
package/dist/types/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type DeleteAction = (props: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
$next: ResolvedPos;
|
|
6
|
+
$head: ResolvedPos;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
export declare const joinListItemWithParentNestedList: DeleteAction;
|
|
9
|
+
export {};
|
package/dist/types/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type DeleteAction = (props: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
$next: ResolvedPos;
|
|
6
|
+
$head: ResolvedPos;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
export declare const joinNestedListWithParentListItem: DeleteAction;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type DeleteAction = (props: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
$next: ResolvedPos;
|
|
6
|
+
$head: ResolvedPos;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
export declare const joinParagrapWithList: DeleteAction;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type DeleteAction = (props: {
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
$next: ResolvedPos;
|
|
6
|
+
$head: ResolvedPos;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
export declare const joinSiblingListItems: DeleteAction;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
type MergeNextListAtPositionProps = {
|
|
3
|
+
listPosition: number;
|
|
4
|
+
tr: Transaction;
|
|
5
|
+
};
|
|
6
|
+
export declare function mergeNextListAtPosition({ tr, listPosition, }: MergeNextListAtPositionProps): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const outdentListItemsSelected: (tr: Transaction, state: EditorState, featureFlags: FeatureFlags) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps the selection in a list with the given type. If this results in
|
|
5
|
+
* two adjacent lists of the same type, those will be joined together.
|
|
6
|
+
*/
|
|
7
|
+
export declare function wrapInListAndJoin(nodeType: NodeType, tr: Transaction): void;
|
|
8
|
+
type Attrs = {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Wraps the selection in a list with the given type and attributes.
|
|
13
|
+
*
|
|
14
|
+
* Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L64-L89
|
|
15
|
+
*/
|
|
16
|
+
export declare function wrapInList(listType: NodeType, attrs?: Attrs): (tr: Transaction) => boolean;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
type InputMethod = INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR;
|
|
5
|
+
export declare const indentList: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: InputMethod) => Command;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import { indentList } from './indent-list';
|
|
7
|
+
import { outdentList } from './outdent-list';
|
|
8
|
+
export { outdentList, indentList };
|
|
9
|
+
export type InputMethod = INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR;
|
|
10
|
+
export declare const enterKeyCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (featureFlags: FeatureFlags) => Command;
|
|
11
|
+
export declare const backspaceKeyCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (featureFlags: FeatureFlags) => Command;
|
|
12
|
+
export declare const deleteKeyCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
13
|
+
export declare const rootListDepth: (pos: ResolvedPos, nodes: Record<string, NodeType>) => number | undefined;
|
|
14
|
+
export declare const toggleList: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InputMethod, listType: 'bulletList' | 'orderedList') => Command;
|
|
15
|
+
export declare const toggleBulletList: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, inputMethod?: InputMethod) => boolean;
|
|
16
|
+
export declare const toggleOrderedList: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, inputMethod?: InputMethod) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { CommandDispatch } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { WalkNode } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
type ScenariosAllowed = LIST_TEXT_SCENARIOS.JOIN_SIBLINGS | LIST_TEXT_SCENARIOS.JOIN_DESCENDANT_TO_PARENT | LIST_TEXT_SCENARIOS.JOIN_TO_SIBLING_DESCENDANT;
|
|
8
|
+
export declare const calcJoinListScenario: (walkNode: WalkNode, $head: ResolvedPos, tr: Transaction) => [ScenariosAllowed, ResolvedPos | null] | false;
|
|
9
|
+
export declare const listBackspace: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, dispatch?: CommandDispatch) => boolean;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
+
type InputMethod = INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR;
|
|
5
|
+
export declare const outdentList: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InputMethod | undefined, featureFlags: FeatureFlags) => Command;
|
|
6
|
+
export {};
|