@atlaskit/editor-core 189.3.14 → 189.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/cjs/plugins/analytics/index.js +0 -6
- package/dist/cjs/plugins/analytics/utils.js +0 -29
- package/dist/cjs/plugins/breakout/index.js +3 -3
- package/dist/cjs/plugins/breakout/ui/LayoutButton.js +4 -4
- package/dist/cjs/plugins/extension/extension-api.js +3 -3
- package/dist/cjs/plugins/extension/index.js +14 -3
- package/dist/cjs/plugins/{macro → extension/pm-plugins/macro}/actions.js +3 -4
- package/dist/cjs/plugins/{macro → extension/pm-plugins/macro}/index.js +2 -18
- package/dist/cjs/plugins/extension/toolbar.js +1 -1
- package/dist/cjs/plugins/find-replace/FindReplaceToolbarButtonWithState.js +32 -30
- package/dist/cjs/plugins/find-replace/commands-with-analytics.js +85 -71
- package/dist/cjs/plugins/find-replace/index.js +5 -2
- package/dist/cjs/plugins/find-replace/keymap.js +4 -4
- package/dist/cjs/plugins/index.js +1 -24
- package/dist/cjs/plugins/insert-block/index.js +36 -53
- package/dist/cjs/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.js +3 -9
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +3 -3
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -5
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/item.js +7 -8
- package/dist/cjs/plugins/paste/handlers.js +3 -3
- package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/cjs/presets/context.js +5 -3
- package/dist/cjs/presets/universal.js +12 -8
- package/dist/cjs/ui/Appearance/Comment/Comment.js +1 -1
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +3 -2
- package/dist/cjs/{plugins/expand/ui/styles.js → ui/ContentStyles/expand.js} +11 -8
- package/dist/cjs/ui/ContentStyles/index.js +4 -4
- package/dist/cjs/ui/ToolbarFeedback/index.js +1 -1
- package/dist/cjs/use-preset.js +0 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/es2019/plugins/analytics/index.js +1 -1
- package/dist/es2019/plugins/analytics/utils.js +0 -24
- package/dist/es2019/plugins/breakout/index.js +1 -1
- package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -1
- package/dist/es2019/plugins/extension/extension-api.js +2 -2
- package/dist/es2019/plugins/extension/index.js +13 -3
- package/dist/es2019/plugins/{macro → extension/pm-plugins/macro}/actions.js +2 -2
- package/dist/es2019/plugins/{macro → extension/pm-plugins/macro}/index.js +1 -14
- package/dist/es2019/plugins/extension/toolbar.js +1 -1
- package/dist/es2019/plugins/find-replace/FindReplaceToolbarButtonWithState.js +20 -19
- package/dist/es2019/plugins/find-replace/commands-with-analytics.js +15 -15
- package/dist/es2019/plugins/find-replace/index.js +7 -2
- package/dist/es2019/plugins/find-replace/keymap.js +4 -4
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/plugins/insert-block/index.js +19 -36
- package/dist/es2019/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.js +4 -8
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +2 -2
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -3
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/item.js +2 -2
- package/dist/es2019/plugins/paste/handlers.js +4 -3
- package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/es2019/presets/context.js +2 -2
- package/dist/es2019/presets/universal.js +10 -6
- package/dist/es2019/ui/Appearance/Comment/Comment.js +1 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +3 -2
- package/dist/es2019/{plugins/expand/ui/styles.js → ui/ContentStyles/expand.js} +9 -4
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/ui/ToolbarFeedback/index.js +2 -2
- package/dist/es2019/use-preset.js +0 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/esm/plugins/analytics/index.js +1 -1
- package/dist/esm/plugins/analytics/utils.js +0 -28
- package/dist/esm/plugins/breakout/index.js +1 -1
- package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -1
- package/dist/esm/plugins/extension/extension-api.js +2 -2
- package/dist/esm/plugins/extension/index.js +14 -3
- package/dist/esm/plugins/{macro → extension/pm-plugins/macro}/actions.js +2 -2
- package/dist/esm/plugins/{macro → extension/pm-plugins/macro}/index.js +1 -17
- package/dist/esm/plugins/extension/toolbar.js +1 -1
- package/dist/esm/plugins/find-replace/FindReplaceToolbarButtonWithState.js +32 -30
- package/dist/esm/plugins/find-replace/commands-with-analytics.js +84 -70
- package/dist/esm/plugins/find-replace/index.js +5 -2
- package/dist/esm/plugins/find-replace/keymap.js +4 -4
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/plugins/insert-block/index.js +36 -53
- package/dist/esm/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.js +4 -10
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +2 -2
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -3
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/item.js +2 -2
- package/dist/esm/plugins/paste/handlers.js +4 -3
- package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/esm/presets/context.js +2 -2
- package/dist/esm/presets/universal.js +9 -6
- package/dist/esm/ui/Appearance/Comment/Comment.js +1 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +3 -2
- package/dist/esm/{plugins/expand/ui/styles.js → ui/ContentStyles/expand.js} +9 -4
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/ui/ToolbarFeedback/index.js +1 -1
- package/dist/esm/use-preset.js +0 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/utils.d.ts +0 -11
- package/dist/types/plugins/extension/extension-api.d.ts +1 -1
- package/dist/{types-ts4.5/plugins → types/plugins/extension/pm-plugins}/macro/index.d.ts +1 -4
- package/dist/types/plugins/extension/pm-plugins/macro/types.d.ts +4 -0
- package/dist/types/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +4 -2
- package/dist/types/plugins/find-replace/commands-with-analytics.d.ts +9 -9
- package/dist/types/plugins/find-replace/index.d.ts +5 -3
- package/dist/types/plugins/find-replace/keymap.d.ts +2 -1
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +4 -2
- package/dist/{types-ts4.5 → types/plugins/insert-block}/ui/ElementBrowser/types.d.ts +2 -2
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -2
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -1
- package/dist/types/plugins/mobile-dimensions/index.d.ts +2 -1
- package/dist/types/plugins/paste/handlers.d.ts +2 -1
- package/dist/types/presets/context.d.ts +2 -2
- package/dist/types/presets/default.d.ts +8 -0
- package/dist/types/presets/universal.d.ts +5 -0
- package/dist/types/{plugins/expand/ui/styles.d.ts → ui/ContentStyles/expand.d.ts} +1 -1
- package/dist/types-ts4.5/plugins/analytics/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/analytics/utils.d.ts +0 -11
- package/dist/types-ts4.5/plugins/extension/extension-api.d.ts +1 -1
- package/dist/{types/plugins → types-ts4.5/plugins/extension/pm-plugins}/macro/index.d.ts +1 -4
- package/dist/types-ts4.5/plugins/extension/pm-plugins/macro/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +4 -2
- package/dist/types-ts4.5/plugins/find-replace/commands-with-analytics.d.ts +9 -9
- package/dist/types-ts4.5/plugins/find-replace/index.d.ts +6 -3
- package/dist/types-ts4.5/plugins/find-replace/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
- package/dist/{types → types-ts4.5/plugins/insert-block}/ui/ElementBrowser/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -1
- package/dist/types-ts4.5/plugins/mobile-dimensions/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
- package/dist/types-ts4.5/presets/context.d.ts +2 -2
- package/dist/types-ts4.5/presets/default.d.ts +8 -0
- package/dist/types-ts4.5/presets/universal.d.ts +5 -0
- package/dist/types-ts4.5/{plugins/expand/ui/styles.d.ts → ui/ContentStyles/expand.d.ts} +1 -1
- package/package.json +5 -9
- package/dist/cjs/plugins/breakout/constants.js +0 -10
- package/dist/cjs/plugins/expand/commands.js +0 -184
- package/dist/cjs/plugins/expand/index.js +0 -111
- package/dist/cjs/plugins/expand/nodeviews/index.js +0 -485
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +0 -171
- package/dist/cjs/plugins/expand/pm-plugins/main.js +0 -85
- package/dist/cjs/plugins/expand/pm-plugins/plugin-factory.js +0 -15
- package/dist/cjs/plugins/expand/reducer.js +0 -20
- package/dist/cjs/plugins/expand/toolbar.js +0 -59
- package/dist/cjs/plugins/expand/ui/ExpandIconButton.js +0 -104
- package/dist/cjs/plugins/expand/ui/class-names.js +0 -20
- package/dist/cjs/plugins/expand/utils.js +0 -24
- package/dist/cjs/ui/ElementBrowser/types.js +0 -5
- package/dist/es2019/plugins/breakout/constants.js +0 -4
- package/dist/es2019/plugins/expand/commands.js +0 -161
- package/dist/es2019/plugins/expand/index.js +0 -95
- package/dist/es2019/plugins/expand/nodeviews/index.js +0 -475
- package/dist/es2019/plugins/expand/pm-plugins/keymap.js +0 -197
- package/dist/es2019/plugins/expand/pm-plugins/main.js +0 -73
- package/dist/es2019/plugins/expand/pm-plugins/plugin-factory.js +0 -9
- package/dist/es2019/plugins/expand/reducer.js +0 -11
- package/dist/es2019/plugins/expand/toolbar.js +0 -52
- package/dist/es2019/plugins/expand/ui/ExpandIconButton.js +0 -85
- package/dist/es2019/plugins/expand/ui/class-names.js +0 -12
- package/dist/es2019/plugins/expand/utils.js +0 -1
- package/dist/esm/plugins/breakout/constants.js +0 -4
- package/dist/esm/plugins/expand/commands.js +0 -177
- package/dist/esm/plugins/expand/index.js +0 -97
- package/dist/esm/plugins/expand/nodeviews/index.js +0 -477
- package/dist/esm/plugins/expand/pm-plugins/keymap.js +0 -165
- package/dist/esm/plugins/expand/pm-plugins/main.js +0 -77
- package/dist/esm/plugins/expand/pm-plugins/plugin-factory.js +0 -9
- package/dist/esm/plugins/expand/reducer.js +0 -13
- package/dist/esm/plugins/expand/toolbar.js +0 -52
- package/dist/esm/plugins/expand/ui/ExpandIconButton.js +0 -95
- package/dist/esm/plugins/expand/ui/class-names.js +0 -14
- package/dist/esm/plugins/expand/utils.js +0 -1
- package/dist/esm/plugins/macro/types.js +0 -1
- package/dist/esm/ui/ElementBrowser/types.js +0 -1
- package/dist/types/plugins/breakout/constants.d.ts +0 -4
- package/dist/types/plugins/expand/commands.d.ts +0 -13
- package/dist/types/plugins/expand/index.d.ts +0 -31
- package/dist/types/plugins/expand/nodeviews/index.d.ts +0 -55
- package/dist/types/plugins/expand/pm-plugins/keymap.d.ts +0 -4
- package/dist/types/plugins/expand/pm-plugins/main.d.ts +0 -8
- package/dist/types/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -3
- package/dist/types/plugins/expand/reducer.d.ts +0 -3
- package/dist/types/plugins/expand/toolbar.d.ts +0 -3
- package/dist/types/plugins/expand/types.d.ts +0 -9
- package/dist/types/plugins/expand/ui/ExpandIconButton.d.ts +0 -43
- package/dist/types/plugins/expand/ui/class-names.d.ts +0 -11
- package/dist/types/plugins/expand/utils.d.ts +0 -1
- package/dist/types/plugins/macro/types.d.ts +0 -4
- package/dist/types-ts4.5/plugins/breakout/constants.d.ts +0 -4
- package/dist/types-ts4.5/plugins/expand/commands.d.ts +0 -13
- package/dist/types-ts4.5/plugins/expand/index.d.ts +0 -31
- package/dist/types-ts4.5/plugins/expand/nodeviews/index.d.ts +0 -55
- package/dist/types-ts4.5/plugins/expand/pm-plugins/keymap.d.ts +0 -4
- package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +0 -8
- package/dist/types-ts4.5/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -3
- package/dist/types-ts4.5/plugins/expand/reducer.d.ts +0 -3
- package/dist/types-ts4.5/plugins/expand/toolbar.d.ts +0 -3
- package/dist/types-ts4.5/plugins/expand/types.d.ts +0 -9
- package/dist/types-ts4.5/plugins/expand/ui/ExpandIconButton.d.ts +0 -43
- package/dist/types-ts4.5/plugins/expand/ui/class-names.d.ts +0 -11
- package/dist/types-ts4.5/plugins/expand/utils.d.ts +0 -1
- package/dist/types-ts4.5/plugins/macro/types.d.ts +0 -4
- /package/dist/cjs/plugins/{macro → extension/pm-plugins/macro}/plugin-key.js +0 -0
- /package/dist/cjs/plugins/{expand → extension/pm-plugins/macro}/types.js +0 -0
- /package/dist/cjs/plugins/{macro → insert-block/ui/ElementBrowser}/types.js +0 -0
- /package/dist/es2019/plugins/{macro → extension/pm-plugins/macro}/plugin-key.js +0 -0
- /package/dist/es2019/plugins/{expand → extension/pm-plugins/macro}/types.js +0 -0
- /package/dist/es2019/plugins/{macro → insert-block/ui/ElementBrowser}/types.js +0 -0
- /package/dist/esm/plugins/{macro → extension/pm-plugins/macro}/plugin-key.js +0 -0
- /package/dist/{es2019/ui/ElementBrowser → esm/plugins/extension/pm-plugins/macro}/types.js +0 -0
- /package/dist/esm/plugins/{expand → insert-block/ui/ElementBrowser}/types.js +0 -0
- /package/dist/types/plugins/{macro → extension/pm-plugins/macro}/actions.d.ts +0 -0
- /package/dist/types/plugins/{macro → extension/pm-plugins/macro}/plugin-key.d.ts +0 -0
- /package/dist/types/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.d.ts +0 -0
- /package/dist/types-ts4.5/plugins/{macro → extension/pm-plugins/macro}/actions.d.ts +0 -0
- /package/dist/types-ts4.5/plugins/{macro → extension/pm-plugins/macro}/plugin-key.d.ts +0 -0
- /package/dist/types-ts4.5/{ui → plugins/insert-block/ui}/ElementBrowser/InsertMenu.d.ts +0 -0
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.containsClass = containsClass;
|
|
8
|
-
exports.createPlugin = void 0;
|
|
9
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
12
|
-
var _nodeviews = _interopRequireDefault(require("../nodeviews"));
|
|
13
|
-
var _commands = require("../commands");
|
|
14
|
-
var _utils2 = require("../utils");
|
|
15
|
-
var _classNames = require("../ui/class-names");
|
|
16
|
-
var _pluginFactory = require("./plugin-factory");
|
|
17
|
-
function containsClass(element, className) {
|
|
18
|
-
var _element$classList;
|
|
19
|
-
return Boolean(element === null || element === void 0 || (_element$classList = element.classList) === null || _element$classList === void 0 ? void 0 : _element$classList.contains(className));
|
|
20
|
-
}
|
|
21
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatch, getIntl) {
|
|
22
|
-
var appearance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'full-page';
|
|
23
|
-
var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
24
|
-
var featureFlags = arguments.length > 4 ? arguments[4] : undefined;
|
|
25
|
-
var api = arguments.length > 5 ? arguments[5] : undefined;
|
|
26
|
-
var state = (0, _pluginFactory.createPluginState)(dispatch, {});
|
|
27
|
-
var isMobile = appearance === 'mobile';
|
|
28
|
-
return new _safePlugin.SafePlugin({
|
|
29
|
-
state: state,
|
|
30
|
-
key: _pluginFactory.pluginKey,
|
|
31
|
-
props: {
|
|
32
|
-
nodeViews: {
|
|
33
|
-
expand: (0, _nodeviews.default)({
|
|
34
|
-
getIntl: getIntl,
|
|
35
|
-
isMobile: isMobile,
|
|
36
|
-
featureFlags: featureFlags,
|
|
37
|
-
api: api
|
|
38
|
-
}),
|
|
39
|
-
nestedExpand: (0, _nodeviews.default)({
|
|
40
|
-
getIntl: getIntl,
|
|
41
|
-
isMobile: isMobile,
|
|
42
|
-
featureFlags: featureFlags,
|
|
43
|
-
api: api
|
|
44
|
-
})
|
|
45
|
-
},
|
|
46
|
-
handleKeyDown: function handleKeyDown(_view, event) {
|
|
47
|
-
return containsClass(event.target, _classNames.expandClassNames.titleContainer);
|
|
48
|
-
},
|
|
49
|
-
handleKeyPress: function handleKeyPress(_view, event) {
|
|
50
|
-
return containsClass(event.target, _classNames.expandClassNames.titleContainer);
|
|
51
|
-
},
|
|
52
|
-
handleScrollToSelection: function handleScrollToSelection() {
|
|
53
|
-
return containsClass(document.activeElement, _classNames.expandClassNames.titleInput);
|
|
54
|
-
},
|
|
55
|
-
handleClickOn: (0, _selection.createSelectionClickHandler)(['expand', 'nestedExpand'], function (target) {
|
|
56
|
-
return target.classList.contains(_classNames.expandClassNames.prefix);
|
|
57
|
-
}, {
|
|
58
|
-
useLongPressSelection: useLongPressSelection
|
|
59
|
-
})
|
|
60
|
-
},
|
|
61
|
-
// @see ED-8027 to follow up on this work-around
|
|
62
|
-
filterTransaction: function filterTransaction(tr) {
|
|
63
|
-
if (containsClass(document.activeElement, _classNames.expandClassNames.titleInput) && tr.selectionSet && (!tr.steps.length || tr.isGeneric)) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
},
|
|
68
|
-
view: function view(editorView) {
|
|
69
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
70
|
-
return {
|
|
71
|
-
update: function update(view) {
|
|
72
|
-
var state = view.state,
|
|
73
|
-
dispatch = view.dispatch;
|
|
74
|
-
var node = (0, _utils2.findExpand)(state);
|
|
75
|
-
if (node) {
|
|
76
|
-
var expandRef = (0, _utils.findDomRefAtPos)(node.pos, domAtPos);
|
|
77
|
-
if ((0, _pluginFactory.getPluginState)(state).expandRef !== expandRef) {
|
|
78
|
-
(0, _commands.setExpandRef)(expandRef)(state, dispatch);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.pluginKey = exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _pluginStateFactory = require("../../../utils/plugin-state-factory");
|
|
10
|
-
var _reducer = _interopRequireDefault(require("../reducer"));
|
|
11
|
-
var pluginKey = exports.pluginKey = new _state.PluginKey('expandPlugin');
|
|
12
|
-
var _pluginFactory = (0, _pluginStateFactory.pluginFactory)(pluginKey, _reducer.default),
|
|
13
|
-
createPluginState = exports.createPluginState = _pluginFactory.createPluginState,
|
|
14
|
-
createCommand = exports.createCommand = _pluginFactory.createCommand,
|
|
15
|
-
getPluginState = exports.getPluginState = _pluginFactory.getPluginState;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
var _default = exports.default = function _default(pluginState, action) {
|
|
12
|
-
switch (action.type) {
|
|
13
|
-
case 'SET_EXPAND_REF':
|
|
14
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
15
|
-
expandRef: action.data.ref
|
|
16
|
-
});
|
|
17
|
-
default:
|
|
18
|
-
return pluginState;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getToolbarConfig = void 0;
|
|
8
|
-
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
9
|
-
var _messages = _interopRequireDefault(require("../../messages"));
|
|
10
|
-
var _commands = require("./commands");
|
|
11
|
-
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
12
|
-
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(api) {
|
|
13
|
-
return function (state, _ref) {
|
|
14
|
-
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
15
|
-
var formatMessage = _ref.formatMessage;
|
|
16
|
-
var _ref2 = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
|
|
17
|
-
hoverDecoration = _ref2.hoverDecoration;
|
|
18
|
-
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
19
|
-
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
20
|
-
expandRef = _getPluginState.expandRef;
|
|
21
|
-
if (expandRef) {
|
|
22
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
23
|
-
nestedExpand = _state$schema$nodes.nestedExpand,
|
|
24
|
-
expand = _state$schema$nodes.expand;
|
|
25
|
-
return {
|
|
26
|
-
title: 'Expand toolbar',
|
|
27
|
-
getDomRef: function getDomRef() {
|
|
28
|
-
return expandRef;
|
|
29
|
-
},
|
|
30
|
-
nodeType: [nestedExpand, expand],
|
|
31
|
-
offset: [0, 6],
|
|
32
|
-
items: [{
|
|
33
|
-
type: 'copy-button',
|
|
34
|
-
items: [{
|
|
35
|
-
state: state,
|
|
36
|
-
formatMessage: formatMessage,
|
|
37
|
-
nodeType: [nestedExpand, expand]
|
|
38
|
-
}, {
|
|
39
|
-
type: 'separator'
|
|
40
|
-
}]
|
|
41
|
-
}, {
|
|
42
|
-
id: 'editor.expand.delete',
|
|
43
|
-
type: 'button',
|
|
44
|
-
appearance: 'danger',
|
|
45
|
-
focusEditoronEnter: true,
|
|
46
|
-
icon: _remove.default,
|
|
47
|
-
onClick: (0, _commands.deleteExpand)(editorAnalyticsAPI),
|
|
48
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], true),
|
|
49
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], false),
|
|
50
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], true),
|
|
51
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], false),
|
|
52
|
-
title: formatMessage(_messages.default.remove),
|
|
53
|
-
tabIndex: null
|
|
54
|
-
}]
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.withTooltip = exports.ExpandIconButton = exports.CustomButton = void 0;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
18
|
-
var _react2 = require("@emotion/react");
|
|
19
|
-
var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
|
|
20
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
21
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
22
|
-
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-right"));
|
|
23
|
-
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
24
|
-
var _classNames = require("./class-names");
|
|
25
|
-
var _excluded = ["buttonStyles"];
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
31
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
32
|
-
var withTooltip = exports.withTooltip = function withTooltip(WrapperComponent) {
|
|
33
|
-
return /*#__PURE__*/function (_React$Component) {
|
|
34
|
-
(0, _inherits2.default)(WithSortableColumn, _React$Component);
|
|
35
|
-
var _super = _createSuper(WithSortableColumn);
|
|
36
|
-
function WithSortableColumn(props) {
|
|
37
|
-
(0, _classCallCheck2.default)(this, WithSortableColumn);
|
|
38
|
-
return _super.call(this, props);
|
|
39
|
-
}
|
|
40
|
-
(0, _createClass2.default)(WithSortableColumn, [{
|
|
41
|
-
key: "render",
|
|
42
|
-
value: function render() {
|
|
43
|
-
var label = this.props.label;
|
|
44
|
-
return (0, _react2.jsx)(_tooltip.default, {
|
|
45
|
-
content: label,
|
|
46
|
-
position: "top",
|
|
47
|
-
tag: _ui.ExpandLayoutWrapperWithRef
|
|
48
|
-
}, (0, _react2.jsx)(WrapperComponent, this.props));
|
|
49
|
-
}
|
|
50
|
-
}]);
|
|
51
|
-
return WithSortableColumn;
|
|
52
|
-
}(_react.default.Component);
|
|
53
|
-
};
|
|
54
|
-
var CustomButton = exports.CustomButton = function CustomButton(props) {
|
|
55
|
-
var label = props.label,
|
|
56
|
-
allowInteractiveExpand = props.allowInteractiveExpand;
|
|
57
|
-
var useTheme = (0, _react.useCallback)(function (currentTheme, themeProps) {
|
|
58
|
-
var _currentTheme = currentTheme(themeProps),
|
|
59
|
-
buttonStyles = _currentTheme.buttonStyles,
|
|
60
|
-
rest = (0, _objectWithoutProperties2.default)(_currentTheme, _excluded);
|
|
61
|
-
return _objectSpread({
|
|
62
|
-
buttonStyles: _objectSpread(_objectSpread({}, buttonStyles), {}, {
|
|
63
|
-
height: '100%',
|
|
64
|
-
'& svg': {
|
|
65
|
-
transform: props.expanded ? 'transform: rotate(90deg);' : 'transform: rotate(0deg);',
|
|
66
|
-
transition: "transform 0.2s ".concat(_editorSharedStyles.akEditorSwoopCubicBezier, ";")
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
}, rest);
|
|
70
|
-
}, [props]);
|
|
71
|
-
return (0, _react2.jsx)(_customThemeButton.default, {
|
|
72
|
-
appearance: "subtle",
|
|
73
|
-
className: _classNames.expandClassNames.iconContainer,
|
|
74
|
-
iconBefore: (0, _react2.jsx)(_chevronRight.default, {
|
|
75
|
-
label: label
|
|
76
|
-
}),
|
|
77
|
-
shouldFitContainer: true,
|
|
78
|
-
theme: useTheme,
|
|
79
|
-
isDisabled: !allowInteractiveExpand
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
var ButtonWithTooltip = withTooltip(CustomButton);
|
|
83
|
-
var ButtonWithoutTooltip = CustomButton;
|
|
84
|
-
var ExpandIconButton = exports.ExpandIconButton = function ExpandIconButton(props) {
|
|
85
|
-
var expanded = props.expanded,
|
|
86
|
-
intl = props.intl;
|
|
87
|
-
var message = expanded ? _ui.expandMessages.collapseNode : _ui.expandMessages.expandNode;
|
|
88
|
-
var label = intl && intl.formatMessage(message) || message.defaultMessage;
|
|
89
|
-
// check to ensure device supports any-hover
|
|
90
|
-
var supportsAnyHover = !!window.matchMedia ? window.matchMedia('(any-hover: hover)').matches !== window.matchMedia('(any-hover: none)').matches : false;
|
|
91
|
-
var hoverEventCheck = supportsAnyHover ? window.matchMedia('(any-hover: hover)').matches : true;
|
|
92
|
-
|
|
93
|
-
// hoverEventCheck is to disable tooltips for mobile to prevent incorrect hover state causing issues on iOS
|
|
94
|
-
if (props.allowInteractiveExpand && hoverEventCheck) {
|
|
95
|
-
return (0, _react2.jsx)(ButtonWithTooltip, (0, _extends2.default)({
|
|
96
|
-
label: label
|
|
97
|
-
}, props));
|
|
98
|
-
}
|
|
99
|
-
return (0, _react2.jsx)("div", {
|
|
100
|
-
css: _ui.expandLayoutWrapperStyle
|
|
101
|
-
}, (0, _react2.jsx)(ButtonWithoutTooltip, (0, _extends2.default)({
|
|
102
|
-
label: label
|
|
103
|
-
}, props)));
|
|
104
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.expandClassNames = void 0;
|
|
7
|
-
var prefix = 'ak-editor-expand';
|
|
8
|
-
var expandClassNames = exports.expandClassNames = {
|
|
9
|
-
prefix: prefix,
|
|
10
|
-
expanded: "".concat(prefix, "__expanded"),
|
|
11
|
-
titleContainer: "".concat(prefix, "__title-container"),
|
|
12
|
-
inputContainer: "".concat(prefix, "__input-container"),
|
|
13
|
-
iconContainer: "".concat(prefix, "__icon-container"),
|
|
14
|
-
icon: "".concat(prefix, "__icon"),
|
|
15
|
-
titleInput: "".concat(prefix, "__title-input"),
|
|
16
|
-
content: "".concat(prefix, "__content"),
|
|
17
|
-
type: function type(_type) {
|
|
18
|
-
return "".concat(prefix, "__type-").concat(_type);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "findExpand", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _transforms.findExpand;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "transformSliceNestedExpandToExpand", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _transforms.transformSliceNestedExpandToExpand;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "transformSliceToRemoveOpenExpand", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _transforms.transformSliceToRemoveOpenExpand;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, PLATFORMS, MODE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
5
|
-
import { findExpand } from './utils';
|
|
6
|
-
import { createCommand } from './pm-plugins/plugin-factory';
|
|
7
|
-
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
-
export const setExpandRef = ref => createCommand({
|
|
10
|
-
type: 'SET_EXPAND_REF',
|
|
11
|
-
data: {
|
|
12
|
-
ref
|
|
13
|
-
}
|
|
14
|
-
}, tr => tr.setMeta('addToHistory', false));
|
|
15
|
-
export const deleteExpandAtPos = editorAnalyticsAPI => (expandNodePos, expandNode) => (state, dispatch) => {
|
|
16
|
-
if (!expandNode || isNaN(expandNodePos)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const payload = {
|
|
20
|
-
action: ACTION.DELETED,
|
|
21
|
-
actionSubject: expandNode.type === state.schema.nodes.expand ? ACTION_SUBJECT.EXPAND : ACTION_SUBJECT.NESTED_EXPAND,
|
|
22
|
-
attributes: {
|
|
23
|
-
inputMethod: INPUT_METHOD.TOOLBAR
|
|
24
|
-
},
|
|
25
|
-
eventType: EVENT_TYPE.TRACK
|
|
26
|
-
};
|
|
27
|
-
if (expandNode && dispatch) {
|
|
28
|
-
const {
|
|
29
|
-
tr
|
|
30
|
-
} = state;
|
|
31
|
-
tr.delete(expandNodePos, expandNodePos + expandNode.nodeSize);
|
|
32
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
33
|
-
dispatch(tr);
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
|
-
export const deleteExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
38
|
-
const expandNode = findExpand(state);
|
|
39
|
-
if (!expandNode) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return deleteExpandAtPos(editorAnalyticsAPI)(expandNode.pos, expandNode.node)(state, dispatch);
|
|
43
|
-
};
|
|
44
|
-
export const updateExpandTitle = (title, pos, nodeType) => (state, dispatch) => {
|
|
45
|
-
const node = state.doc.nodeAt(pos);
|
|
46
|
-
if (node && node.type === nodeType && dispatch) {
|
|
47
|
-
const {
|
|
48
|
-
tr
|
|
49
|
-
} = state;
|
|
50
|
-
tr.setNodeMarkup(pos, node.type, {
|
|
51
|
-
...node.attrs,
|
|
52
|
-
title
|
|
53
|
-
}, node.marks);
|
|
54
|
-
dispatch(tr);
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
};
|
|
58
|
-
export const toggleExpandExpanded = editorAnalyticsAPI => (pos, nodeType) => (state, dispatch) => {
|
|
59
|
-
const node = state.doc.nodeAt(pos);
|
|
60
|
-
if (node && node.type === nodeType && dispatch) {
|
|
61
|
-
const {
|
|
62
|
-
tr
|
|
63
|
-
} = state;
|
|
64
|
-
const isExpandedNext = !node.attrs.__expanded;
|
|
65
|
-
tr.setNodeMarkup(pos, node.type, {
|
|
66
|
-
...node.attrs,
|
|
67
|
-
__expanded: isExpandedNext
|
|
68
|
-
}, node.marks);
|
|
69
|
-
|
|
70
|
-
// If we're going to collapse the expand and our cursor is currently inside
|
|
71
|
-
// Move to a right gap cursor, if the toolbar is interacted (or an API),
|
|
72
|
-
// it will insert below rather than inside (which will be invisible).
|
|
73
|
-
if (isExpandedNext === false && findExpand(state)) {
|
|
74
|
-
tr.setSelection(new GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), Side.RIGHT));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// log when people open/close expands
|
|
78
|
-
// TODO: ED-8523 make platform/mode global attributes?
|
|
79
|
-
const payload = {
|
|
80
|
-
action: ACTION.TOGGLE_EXPAND,
|
|
81
|
-
actionSubject: nodeType === state.schema.nodes.expand ? ACTION_SUBJECT.EXPAND : ACTION_SUBJECT.NESTED_EXPAND,
|
|
82
|
-
attributes: {
|
|
83
|
-
platform: PLATFORMS.WEB,
|
|
84
|
-
mode: MODE.EDITOR,
|
|
85
|
-
expanded: isExpandedNext
|
|
86
|
-
},
|
|
87
|
-
eventType: EVENT_TYPE.TRACK
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// `isRemote` meta prevents this step from being
|
|
91
|
-
// sync'd between sessions in collab edit
|
|
92
|
-
tr.setMeta('isRemote', true);
|
|
93
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
94
|
-
dispatch(tr);
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Creates either an expand or a nestedExpand node based on the current selection
|
|
100
|
-
export const createExpandNode = state => {
|
|
101
|
-
const {
|
|
102
|
-
expand,
|
|
103
|
-
nestedExpand
|
|
104
|
-
} = state.schema.nodes;
|
|
105
|
-
const expandType = findTable(state.selection) ? nestedExpand : expand;
|
|
106
|
-
return expandType.createAndFill({});
|
|
107
|
-
};
|
|
108
|
-
export const insertExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
109
|
-
const expandNode = createExpandNode(state);
|
|
110
|
-
if (!expandNode) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const tr = state.selection.empty ? safeInsert(expandNode)(state.tr).scrollIntoView() : createWrapSelectionTransaction({
|
|
114
|
-
state,
|
|
115
|
-
type: expandNode.type
|
|
116
|
-
});
|
|
117
|
-
const payload = {
|
|
118
|
-
action: ACTION.INSERTED,
|
|
119
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
120
|
-
actionSubjectId: (expandNode === null || expandNode === void 0 ? void 0 : expandNode.type) === state.schema.nodes.expand ? ACTION_SUBJECT_ID.EXPAND : ACTION_SUBJECT_ID.NESTED_EXPAND,
|
|
121
|
-
attributes: {
|
|
122
|
-
inputMethod: INPUT_METHOD.INSERT_MENU
|
|
123
|
-
},
|
|
124
|
-
eventType: EVENT_TYPE.TRACK
|
|
125
|
-
};
|
|
126
|
-
if (dispatch && expandNode) {
|
|
127
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
128
|
-
dispatch(tr);
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
};
|
|
132
|
-
export const focusTitle = pos => (state, dispatch, editorView) => {
|
|
133
|
-
if (editorView) {
|
|
134
|
-
const dom = editorView.domAtPos(pos);
|
|
135
|
-
const expandWrapper = dom.node.parentElement;
|
|
136
|
-
if (expandWrapper) {
|
|
137
|
-
setSelectionInsideExpand(pos)(state, dispatch, editorView);
|
|
138
|
-
const input = expandWrapper.querySelector('input');
|
|
139
|
-
if (input) {
|
|
140
|
-
input.focus();
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// Used to clear any node or cell selection when expand title is focused
|
|
149
|
-
export const setSelectionInsideExpand = expandPos => (state, dispatch, editorView) => {
|
|
150
|
-
if (editorView) {
|
|
151
|
-
if (!editorView.hasFocus()) {
|
|
152
|
-
editorView.focus();
|
|
153
|
-
}
|
|
154
|
-
const sel = Selection.findFrom(editorView.state.doc.resolve(expandPos), 1, true);
|
|
155
|
-
if (sel && dispatch) {
|
|
156
|
-
dispatch(editorView.state.tr.setSelection(sel));
|
|
157
|
-
}
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { expand, nestedExpand } from '@atlaskit/adf-schema';
|
|
3
|
-
import { createPlugin } from './pm-plugins/main';
|
|
4
|
-
import { expandKeymap } from './pm-plugins/keymap';
|
|
5
|
-
import { IconExpand } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
-
import { getToolbarConfig } from './toolbar';
|
|
8
|
-
import { createExpandNode, insertExpand } from './commands';
|
|
9
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
|
-
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
11
|
-
const expandPlugin = ({
|
|
12
|
-
config: options = {},
|
|
13
|
-
api
|
|
14
|
-
}) => {
|
|
15
|
-
var _api$featureFlags, _api$analytics;
|
|
16
|
-
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
17
|
-
return {
|
|
18
|
-
name: 'expand',
|
|
19
|
-
nodes() {
|
|
20
|
-
return [{
|
|
21
|
-
name: 'expand',
|
|
22
|
-
node: expand
|
|
23
|
-
}, {
|
|
24
|
-
name: 'nestedExpand',
|
|
25
|
-
node: nestedExpand
|
|
26
|
-
}];
|
|
27
|
-
},
|
|
28
|
-
actions: {
|
|
29
|
-
insertExpand: insertExpand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
30
|
-
},
|
|
31
|
-
pmPlugins() {
|
|
32
|
-
return [{
|
|
33
|
-
name: 'expand',
|
|
34
|
-
plugin: ({
|
|
35
|
-
dispatch,
|
|
36
|
-
getIntl
|
|
37
|
-
}) => {
|
|
38
|
-
return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, featureFlags, api);
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
|
-
name: 'expandKeymap',
|
|
42
|
-
plugin: () => expandKeymap(api)
|
|
43
|
-
}];
|
|
44
|
-
},
|
|
45
|
-
pluginsOptions: {
|
|
46
|
-
floatingToolbar: getToolbarConfig(api),
|
|
47
|
-
quickInsert: ({
|
|
48
|
-
formatMessage
|
|
49
|
-
}) => {
|
|
50
|
-
if (options && options.allowInsertion !== true) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
return [{
|
|
54
|
-
id: 'expand',
|
|
55
|
-
title: formatMessage(messages.expand),
|
|
56
|
-
description: formatMessage(messages.expandDescription),
|
|
57
|
-
keywords: ['accordion', 'collapse'],
|
|
58
|
-
priority: 600,
|
|
59
|
-
icon: () => /*#__PURE__*/React.createElement(IconExpand, null),
|
|
60
|
-
action(insert, state) {
|
|
61
|
-
var _api$analytics2;
|
|
62
|
-
const node = createExpandNode(state);
|
|
63
|
-
if (!node) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
const tr = state.selection.empty ? insert(node) : createWrapSelectionTransaction({
|
|
67
|
-
state,
|
|
68
|
-
type: node.type
|
|
69
|
-
});
|
|
70
|
-
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
|
|
71
|
-
action: ACTION.INSERTED,
|
|
72
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
73
|
-
actionSubjectId: node.type === state.schema.nodes.nestedExpand ? ACTION_SUBJECT_ID.NESTED_EXPAND : ACTION_SUBJECT_ID.EXPAND,
|
|
74
|
-
attributes: {
|
|
75
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
76
|
-
},
|
|
77
|
-
eventType: EVENT_TYPE.TRACK
|
|
78
|
-
})(tr);
|
|
79
|
-
return tr;
|
|
80
|
-
}
|
|
81
|
-
}];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export default expandPlugin;
|
|
87
|
-
export function isExpandInsertionEnabled({
|
|
88
|
-
allowExpand
|
|
89
|
-
}) {
|
|
90
|
-
if (allowExpand && typeof allowExpand === 'object') {
|
|
91
|
-
return !!allowExpand.allowInsertion;
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
export { pluginKey } from './pm-plugins/plugin-factory';
|