@atlaskit/editor-core 184.0.4 → 185.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/CHANGELOG.md +38 -0
- package/dist/cjs/create-editor/feature-flags-from-props.js +1 -2
- package/dist/cjs/editor-next/index.js +41 -34
- package/dist/cjs/editor.js +30 -269
- package/dist/cjs/i18n/en_ZZ.js +32 -6
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/labs/next/presets/default.js +2 -1
- package/dist/cjs/plugins/base/index.js +0 -12
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +7 -0
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +7 -0
- package/dist/cjs/plugins/card/nodeviews/inlineCard.js +5 -1
- package/dist/cjs/plugins/card/pm-plugins/doc.js +1 -2
- package/dist/cjs/plugins/card/toolbar.js +11 -9
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +4 -4
- package/dist/cjs/plugins/code-block/index.js +7 -5
- package/dist/cjs/plugins/code-block/toolbar.js +5 -5
- package/dist/cjs/plugins/copy-button/commands.js +2 -3
- package/dist/cjs/plugins/copy-button/toolbar.js +7 -8
- package/dist/cjs/plugins/expand/index.js +1 -1
- package/dist/cjs/plugins/expand/toolbar.js +40 -39
- package/dist/cjs/plugins/extension/index.js +1 -1
- package/dist/cjs/plugins/extension/toolbar.js +5 -5
- package/dist/cjs/plugins/floating-toolbar/index.js +3 -2
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +2 -4
- package/dist/cjs/plugins/layout/index.js +8 -4
- package/dist/cjs/plugins/layout/toolbar.js +5 -6
- package/dist/cjs/plugins/media/toolbar/index.js +31 -24
- package/dist/cjs/plugins/panel/index.js +2 -1
- package/dist/cjs/plugins/panel/toolbar.js +7 -7
- package/dist/cjs/plugins/placeholder-text/index.js +7 -5
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +19 -0
- package/dist/cjs/ui/CollapsedEditor/index.js +1 -2
- package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/feature-flags-from-props.js +1 -2
- package/dist/es2019/editor-next/index.js +39 -30
- package/dist/es2019/editor.js +29 -232
- package/dist/es2019/i18n/en_ZZ.js +32 -6
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/labs/next/presets/default.js +2 -1
- package/dist/es2019/plugins/base/index.js +0 -7
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +8 -0
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +8 -0
- package/dist/es2019/plugins/card/nodeviews/inlineCard.js +5 -1
- package/dist/es2019/plugins/card/pm-plugins/doc.js +1 -2
- package/dist/es2019/plugins/card/toolbar.js +8 -6
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +2 -2
- package/dist/es2019/plugins/code-block/index.js +7 -5
- package/dist/es2019/plugins/code-block/toolbar.js +5 -6
- package/dist/es2019/plugins/copy-button/commands.js +2 -3
- package/dist/es2019/plugins/copy-button/toolbar.js +7 -8
- package/dist/es2019/plugins/expand/index.js +1 -1
- package/dist/es2019/plugins/expand/toolbar.js +5 -6
- package/dist/es2019/plugins/extension/index.js +1 -1
- package/dist/es2019/plugins/extension/toolbar.js +5 -6
- package/dist/es2019/plugins/floating-toolbar/index.js +3 -2
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +2 -4
- package/dist/es2019/plugins/layout/index.js +8 -5
- package/dist/es2019/plugins/layout/toolbar.js +5 -6
- package/dist/es2019/plugins/media/toolbar/index.js +35 -24
- package/dist/es2019/plugins/panel/index.js +2 -2
- package/dist/es2019/plugins/panel/toolbar.js +7 -8
- package/dist/es2019/plugins/placeholder-text/index.js +7 -5
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +21 -0
- package/dist/es2019/ui/CollapsedEditor/index.js +1 -2
- package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/feature-flags-from-props.js +1 -2
- package/dist/esm/editor-next/index.js +42 -33
- package/dist/esm/editor.js +29 -270
- package/dist/esm/i18n/en_ZZ.js +32 -6
- package/dist/esm/index.js +1 -2
- package/dist/esm/labs/next/presets/default.js +2 -1
- package/dist/esm/plugins/base/index.js +0 -9
- package/dist/esm/plugins/card/nodeviews/blockCard.js +7 -0
- package/dist/esm/plugins/card/nodeviews/embedCard.js +7 -0
- package/dist/esm/plugins/card/nodeviews/inlineCard.js +5 -1
- package/dist/esm/plugins/card/pm-plugins/doc.js +1 -2
- package/dist/esm/plugins/card/toolbar.js +7 -6
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +2 -2
- package/dist/esm/plugins/code-block/index.js +7 -5
- package/dist/esm/plugins/code-block/toolbar.js +5 -5
- package/dist/esm/plugins/copy-button/commands.js +2 -3
- package/dist/esm/plugins/copy-button/toolbar.js +7 -8
- package/dist/esm/plugins/expand/index.js +1 -1
- package/dist/esm/plugins/expand/toolbar.js +40 -39
- package/dist/esm/plugins/extension/index.js +1 -1
- package/dist/esm/plugins/extension/toolbar.js +5 -5
- package/dist/esm/plugins/floating-toolbar/index.js +3 -2
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +2 -4
- package/dist/esm/plugins/layout/index.js +8 -4
- package/dist/esm/plugins/layout/toolbar.js +5 -6
- package/dist/esm/plugins/media/toolbar/index.js +31 -24
- package/dist/esm/plugins/panel/index.js +2 -1
- package/dist/esm/plugins/panel/toolbar.js +7 -7
- package/dist/esm/plugins/placeholder-text/index.js +7 -5
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +19 -0
- package/dist/esm/ui/CollapsedEditor/index.js +1 -2
- package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/editor-next/index.d.ts +0 -6
- package/dist/types/editor.d.ts +1 -137
- package/dist/types/i18n/en_ZZ.d.ts +28 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/labs/next/presets/cxhtml.d.ts +106 -0
- package/dist/types/labs/next/presets/default.d.ts +212 -0
- package/dist/types/labs/next/presets/mobile.d.ts +106 -0
- package/dist/types/plugins/base/index.d.ts +0 -4
- package/dist/types/plugins/card/index.d.ts +2 -2
- package/dist/types/plugins/card/nodeviews/blockCard.d.ts +3 -0
- package/dist/types/plugins/card/nodeviews/embedCard.d.ts +3 -0
- package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -1
- package/dist/types/plugins/card/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/plugins/card/pm-plugins/main.d.ts +1 -2
- package/dist/types/plugins/card/toolbar.d.ts +1 -2
- package/dist/types/plugins/card/types.d.ts +1 -1
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +1 -2
- package/dist/types/plugins/card/ui/link-toolbar-button-group-options.d.ts +1 -1
- package/dist/types/plugins/card/ui/types.d.ts +1 -1
- package/dist/types/plugins/code-block/index.d.ts +7 -1
- package/dist/types/plugins/code-block/toolbar.d.ts +2 -1
- package/dist/types/plugins/copy-button/commands.d.ts +2 -1
- package/dist/types/plugins/copy-button/toolbar.d.ts +3 -2
- package/dist/types/plugins/expand/index.d.ts +2 -1
- package/dist/types/plugins/expand/toolbar.d.ts +2 -1
- package/dist/types/plugins/extension/index.d.ts +7 -2
- package/dist/types/plugins/extension/toolbar.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/index.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -1
- package/dist/types/plugins/layout/index.d.ts +7 -1
- package/dist/types/plugins/layout/toolbar.d.ts +2 -1
- package/dist/types/plugins/media/index.d.ts +3 -1
- package/dist/types/plugins/panel/index.d.ts +2 -0
- package/dist/types/plugins/panel/toolbar.d.ts +3 -2
- package/dist/types/plugins/placeholder-text/index.d.ts +3 -1
- package/dist/types/ui/CollapsedEditor/index.d.ts +1 -2
- package/dist/types-ts4.5/editor-next/index.d.ts +0 -6
- package/dist/types-ts4.5/editor.d.ts +1 -137
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +28 -2
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +122 -0
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +244 -0
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +122 -0
- package/dist/types-ts4.5/plugins/base/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/card/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +3 -0
- package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +3 -0
- package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/main.d.ts +1 -2
- package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -2
- package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +1 -2
- package/dist/types-ts4.5/plugins/card/ui/link-toolbar-button-group-options.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +7 -1
- package/dist/types-ts4.5/plugins/code-block/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/copy-button/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +3 -2
- package/dist/types-ts4.5/plugins/expand/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/expand/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/extension/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/extension/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -1
- package/dist/types-ts4.5/plugins/layout/index.d.ts +7 -1
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/panel/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +3 -2
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +5 -1
- package/dist/types-ts4.5/ui/CollapsedEditor/index.d.ts +1 -2
- package/package.json +13 -8
- package/report.api.md +5 -93
- package/dist/cjs/editor-next/editor-migration-component.js +0 -54
- package/dist/cjs/plugins/base/pm-plugins/decoration.js +0 -122
- package/dist/es2019/editor-next/editor-migration-component.js +0 -30
- package/dist/es2019/plugins/base/pm-plugins/decoration.js +0 -111
- package/dist/esm/editor-next/editor-migration-component.js +0 -47
- package/dist/esm/plugins/base/pm-plugins/decoration.js +0 -113
- package/dist/types/editor-next/editor-migration-component.d.ts +0 -6
- package/dist/types/plugins/base/pm-plugins/decoration.d.ts +0 -24
- package/dist/types-ts4.5/editor-next/editor-migration-component.d.ts +0 -6
- package/dist/types-ts4.5/plugins/base/pm-plugins/decoration.d.ts +0 -24
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
|
|
5
|
-
import Editor from '../editor';
|
|
6
|
-
import EditorNext from './index';
|
|
7
|
-
import { defaultProps } from './utils/editorPropTypes';
|
|
8
|
-
import useUniversalPreset from '../labs/next/presets/useUniversalPreset';
|
|
9
|
-
const EditorNextWrapper = ({
|
|
10
|
-
props
|
|
11
|
-
}) => {
|
|
12
|
-
const preset = useUniversalPreset({
|
|
13
|
-
props
|
|
14
|
-
});
|
|
15
|
-
return /*#__PURE__*/React.createElement(EditorNext, _extends({
|
|
16
|
-
preset: preset
|
|
17
|
-
}, props));
|
|
18
|
-
};
|
|
19
|
-
export default class EditorMigrationComponent extends React.Component {
|
|
20
|
-
render() {
|
|
21
|
-
const featureFlags = createFeatureFlagsFromProps(this.props);
|
|
22
|
-
if (!featureFlags.useEditorNext) {
|
|
23
|
-
return /*#__PURE__*/React.createElement(Editor, this.props);
|
|
24
|
-
}
|
|
25
|
-
return /*#__PURE__*/React.createElement(EditorNextWrapper, {
|
|
26
|
-
props: this.props
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
_defineProperty(EditorMigrationComponent, "defaultProps", defaultProps);
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { DecorationSet, Decoration } from 'prosemirror-view';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey, NodeSelection } from 'prosemirror-state';
|
|
4
|
-
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
5
|
-
export const decorationStateKey = new PluginKey('decorationPlugin');
|
|
6
|
-
export let ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
7
|
-
ACTIONS[ACTIONS["DECORATION_ADD"] = 0] = "DECORATION_ADD";
|
|
8
|
-
ACTIONS[ACTIONS["DECORATION_REMOVE"] = 1] = "DECORATION_REMOVE";
|
|
9
|
-
return ACTIONS;
|
|
10
|
-
}({});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @private
|
|
15
|
-
* @deprecated
|
|
16
|
-
*
|
|
17
|
-
* Please use the actions of the base plugin rather than this function
|
|
18
|
-
* directly
|
|
19
|
-
*/
|
|
20
|
-
export const hoverDecoration = (nodeType, add, className = 'danger') => (state, dispatch) => {
|
|
21
|
-
let from;
|
|
22
|
-
let parentNode;
|
|
23
|
-
if (state.selection instanceof NodeSelection) {
|
|
24
|
-
const selectedNode = state.selection.node;
|
|
25
|
-
const nodeTypes = Array.isArray(nodeType) ? nodeType : [nodeType];
|
|
26
|
-
const isNodeTypeMatching = nodeTypes.indexOf(selectedNode.type) > -1;
|
|
27
|
-
// This adds danger styling if the selected node is the one that requires
|
|
28
|
-
// the decoration to be added, e.g. if a layout is selected and the user
|
|
29
|
-
// hovers over the layout's delete button.
|
|
30
|
-
if (isNodeTypeMatching) {
|
|
31
|
-
from = state.selection.from;
|
|
32
|
-
parentNode = selectedNode;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// This adds danger styling if the selection is not a node selection, OR if
|
|
37
|
-
// the selected node is a child of the one that requires the decoration to
|
|
38
|
-
// be added, e.g. if a decision item is selected inside a layout and the
|
|
39
|
-
// user hovers over the layout's delete button.
|
|
40
|
-
const foundParentNode = findParentNodeOfType(nodeType)(state.selection);
|
|
41
|
-
if (from === undefined && foundParentNode) {
|
|
42
|
-
from = foundParentNode.pos;
|
|
43
|
-
parentNode = foundParentNode.node;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Note: can't use !from as from could be 0, which is falsy but valid
|
|
47
|
-
if (from === undefined || parentNode === undefined) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
if (dispatch) {
|
|
51
|
-
dispatch(state.tr.setMeta(decorationStateKey, {
|
|
52
|
-
action: add ? ACTIONS.DECORATION_ADD : ACTIONS.DECORATION_REMOVE,
|
|
53
|
-
data: Decoration.node(from, from + parentNode.nodeSize, {
|
|
54
|
-
class: className
|
|
55
|
-
}, {
|
|
56
|
-
key: 'decorationNode'
|
|
57
|
-
})
|
|
58
|
-
}).setMeta('addToHistory', false));
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
};
|
|
62
|
-
export default (() => {
|
|
63
|
-
return new SafePlugin({
|
|
64
|
-
key: decorationStateKey,
|
|
65
|
-
state: {
|
|
66
|
-
init: () => ({
|
|
67
|
-
decoration: undefined
|
|
68
|
-
}),
|
|
69
|
-
apply(tr, pluginState) {
|
|
70
|
-
if (pluginState.decoration) {
|
|
71
|
-
const mapResult = tr.mapping.mapResult(pluginState.decoration.from);
|
|
72
|
-
if (mapResult.deleted) {
|
|
73
|
-
pluginState = {
|
|
74
|
-
decoration: undefined
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const meta = tr.getMeta(decorationStateKey);
|
|
79
|
-
if (!meta) {
|
|
80
|
-
return pluginState;
|
|
81
|
-
}
|
|
82
|
-
switch (meta.action) {
|
|
83
|
-
case ACTIONS.DECORATION_ADD:
|
|
84
|
-
return {
|
|
85
|
-
decoration: meta.data
|
|
86
|
-
};
|
|
87
|
-
case ACTIONS.DECORATION_REMOVE:
|
|
88
|
-
return {
|
|
89
|
-
decoration: undefined
|
|
90
|
-
};
|
|
91
|
-
default:
|
|
92
|
-
return pluginState;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
props: {
|
|
97
|
-
decorations(state) {
|
|
98
|
-
const {
|
|
99
|
-
doc
|
|
100
|
-
} = state;
|
|
101
|
-
const {
|
|
102
|
-
decoration
|
|
103
|
-
} = decorationStateKey.getState(state);
|
|
104
|
-
if (decoration) {
|
|
105
|
-
return DecorationSet.create(doc, [decoration]);
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
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; } }
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
|
|
12
|
-
import Editor from '../editor';
|
|
13
|
-
import EditorNext from './index';
|
|
14
|
-
import { defaultProps } from './utils/editorPropTypes';
|
|
15
|
-
import useUniversalPreset from '../labs/next/presets/useUniversalPreset';
|
|
16
|
-
var EditorNextWrapper = function EditorNextWrapper(_ref) {
|
|
17
|
-
var props = _ref.props;
|
|
18
|
-
var preset = useUniversalPreset({
|
|
19
|
-
props: props
|
|
20
|
-
});
|
|
21
|
-
return /*#__PURE__*/React.createElement(EditorNext, _extends({
|
|
22
|
-
preset: preset
|
|
23
|
-
}, props));
|
|
24
|
-
};
|
|
25
|
-
var EditorMigrationComponent = /*#__PURE__*/function (_React$Component) {
|
|
26
|
-
_inherits(EditorMigrationComponent, _React$Component);
|
|
27
|
-
var _super = _createSuper(EditorMigrationComponent);
|
|
28
|
-
function EditorMigrationComponent() {
|
|
29
|
-
_classCallCheck(this, EditorMigrationComponent);
|
|
30
|
-
return _super.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
_createClass(EditorMigrationComponent, [{
|
|
33
|
-
key: "render",
|
|
34
|
-
value: function render() {
|
|
35
|
-
var featureFlags = createFeatureFlagsFromProps(this.props);
|
|
36
|
-
if (!featureFlags.useEditorNext) {
|
|
37
|
-
return /*#__PURE__*/React.createElement(Editor, this.props);
|
|
38
|
-
}
|
|
39
|
-
return /*#__PURE__*/React.createElement(EditorNextWrapper, {
|
|
40
|
-
props: this.props
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}]);
|
|
44
|
-
return EditorMigrationComponent;
|
|
45
|
-
}(React.Component);
|
|
46
|
-
_defineProperty(EditorMigrationComponent, "defaultProps", defaultProps);
|
|
47
|
-
export { EditorMigrationComponent as default };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { DecorationSet, Decoration } from 'prosemirror-view';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey, NodeSelection } from 'prosemirror-state';
|
|
4
|
-
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
5
|
-
export var decorationStateKey = new PluginKey('decorationPlugin');
|
|
6
|
-
export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
7
|
-
ACTIONS[ACTIONS["DECORATION_ADD"] = 0] = "DECORATION_ADD";
|
|
8
|
-
ACTIONS[ACTIONS["DECORATION_REMOVE"] = 1] = "DECORATION_REMOVE";
|
|
9
|
-
return ACTIONS;
|
|
10
|
-
}({});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @private
|
|
15
|
-
* @deprecated
|
|
16
|
-
*
|
|
17
|
-
* Please use the actions of the base plugin rather than this function
|
|
18
|
-
* directly
|
|
19
|
-
*/
|
|
20
|
-
export var hoverDecoration = function hoverDecoration(nodeType, add) {
|
|
21
|
-
var className = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'danger';
|
|
22
|
-
return function (state, dispatch) {
|
|
23
|
-
var from;
|
|
24
|
-
var parentNode;
|
|
25
|
-
if (state.selection instanceof NodeSelection) {
|
|
26
|
-
var selectedNode = state.selection.node;
|
|
27
|
-
var nodeTypes = Array.isArray(nodeType) ? nodeType : [nodeType];
|
|
28
|
-
var isNodeTypeMatching = nodeTypes.indexOf(selectedNode.type) > -1;
|
|
29
|
-
// This adds danger styling if the selected node is the one that requires
|
|
30
|
-
// the decoration to be added, e.g. if a layout is selected and the user
|
|
31
|
-
// hovers over the layout's delete button.
|
|
32
|
-
if (isNodeTypeMatching) {
|
|
33
|
-
from = state.selection.from;
|
|
34
|
-
parentNode = selectedNode;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// This adds danger styling if the selection is not a node selection, OR if
|
|
39
|
-
// the selected node is a child of the one that requires the decoration to
|
|
40
|
-
// be added, e.g. if a decision item is selected inside a layout and the
|
|
41
|
-
// user hovers over the layout's delete button.
|
|
42
|
-
var foundParentNode = findParentNodeOfType(nodeType)(state.selection);
|
|
43
|
-
if (from === undefined && foundParentNode) {
|
|
44
|
-
from = foundParentNode.pos;
|
|
45
|
-
parentNode = foundParentNode.node;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Note: can't use !from as from could be 0, which is falsy but valid
|
|
49
|
-
if (from === undefined || parentNode === undefined) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
if (dispatch) {
|
|
53
|
-
dispatch(state.tr.setMeta(decorationStateKey, {
|
|
54
|
-
action: add ? ACTIONS.DECORATION_ADD : ACTIONS.DECORATION_REMOVE,
|
|
55
|
-
data: Decoration.node(from, from + parentNode.nodeSize, {
|
|
56
|
-
class: className
|
|
57
|
-
}, {
|
|
58
|
-
key: 'decorationNode'
|
|
59
|
-
})
|
|
60
|
-
}).setMeta('addToHistory', false));
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export default (function () {
|
|
66
|
-
return new SafePlugin({
|
|
67
|
-
key: decorationStateKey,
|
|
68
|
-
state: {
|
|
69
|
-
init: function init() {
|
|
70
|
-
return {
|
|
71
|
-
decoration: undefined
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
apply: function apply(tr, pluginState) {
|
|
75
|
-
if (pluginState.decoration) {
|
|
76
|
-
var mapResult = tr.mapping.mapResult(pluginState.decoration.from);
|
|
77
|
-
if (mapResult.deleted) {
|
|
78
|
-
pluginState = {
|
|
79
|
-
decoration: undefined
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
var meta = tr.getMeta(decorationStateKey);
|
|
84
|
-
if (!meta) {
|
|
85
|
-
return pluginState;
|
|
86
|
-
}
|
|
87
|
-
switch (meta.action) {
|
|
88
|
-
case ACTIONS.DECORATION_ADD:
|
|
89
|
-
return {
|
|
90
|
-
decoration: meta.data
|
|
91
|
-
};
|
|
92
|
-
case ACTIONS.DECORATION_REMOVE:
|
|
93
|
-
return {
|
|
94
|
-
decoration: undefined
|
|
95
|
-
};
|
|
96
|
-
default:
|
|
97
|
-
return pluginState;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
props: {
|
|
102
|
-
decorations: function decorations(state) {
|
|
103
|
-
var doc = state.doc;
|
|
104
|
-
var _ref = decorationStateKey.getState(state),
|
|
105
|
-
decoration = _ref.decoration;
|
|
106
|
-
if (decoration) {
|
|
107
|
-
return DecorationSet.create(doc, [decoration]);
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NodeType } from 'prosemirror-model';
|
|
2
|
-
import { Decoration } from 'prosemirror-view';
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import { PluginKey } from 'prosemirror-state';
|
|
5
|
-
import { Command } from '../../../types';
|
|
6
|
-
export declare const decorationStateKey: PluginKey<any, any>;
|
|
7
|
-
export declare enum ACTIONS {
|
|
8
|
-
DECORATION_ADD = 0,
|
|
9
|
-
DECORATION_REMOVE = 1
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
14
|
-
* @deprecated
|
|
15
|
-
*
|
|
16
|
-
* Please use the actions of the base plugin rather than this function
|
|
17
|
-
* directly
|
|
18
|
-
*/
|
|
19
|
-
export declare const hoverDecoration: (nodeType: NodeType | Array<NodeType>, add: boolean, className?: string) => Command;
|
|
20
|
-
export type DecorationState = {
|
|
21
|
-
decoration?: Decoration;
|
|
22
|
-
};
|
|
23
|
-
declare const _default: () => SafePlugin<DecorationState, any>;
|
|
24
|
-
export default _default;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NodeType } from 'prosemirror-model';
|
|
2
|
-
import { Decoration } from 'prosemirror-view';
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import { PluginKey } from 'prosemirror-state';
|
|
5
|
-
import { Command } from '../../../types';
|
|
6
|
-
export declare const decorationStateKey: PluginKey<any, any>;
|
|
7
|
-
export declare enum ACTIONS {
|
|
8
|
-
DECORATION_ADD = 0,
|
|
9
|
-
DECORATION_REMOVE = 1
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
14
|
-
* @deprecated
|
|
15
|
-
*
|
|
16
|
-
* Please use the actions of the base plugin rather than this function
|
|
17
|
-
* directly
|
|
18
|
-
*/
|
|
19
|
-
export declare const hoverDecoration: (nodeType: NodeType | Array<NodeType>, add: boolean, className?: string) => Command;
|
|
20
|
-
export type DecorationState = {
|
|
21
|
-
decoration?: Decoration;
|
|
22
|
-
};
|
|
23
|
-
declare const _default: () => SafePlugin<DecorationState, any>;
|
|
24
|
-
export default _default;
|