@atlaskit/editor-core 190.1.15 → 190.1.18
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 +13 -0
- package/afm-cc/tsconfig.json +3 -3
- package/dist/cjs/plugins/collab-edit/actions.js +2 -2
- package/dist/cjs/plugins/collab-edit/index.js +4 -5
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/collab-edit/actions.js +2 -2
- package/dist/es2019/plugins/collab-edit/index.js +4 -4
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/collab-edit/actions.js +2 -2
- package/dist/esm/plugins/collab-edit/index.js +4 -5
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/collab-edit/actions.d.ts +1 -1
- package/dist/types/plugins/collab-edit/index.d.ts +2 -2
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/collab-edit/actions.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/package.json +6 -4
- package/tsconfig.json +1 -1
- package/dist/cjs/plugins/breakout/commands/remove-breakout.js +0 -30
- package/dist/cjs/plugins/breakout/commands/set-breakout-mode.js +0 -29
- package/dist/cjs/plugins/breakout/index.js +0 -218
- package/dist/cjs/plugins/breakout/plugin-key.js +0 -11
- package/dist/cjs/plugins/breakout/types.js +0 -5
- package/dist/cjs/plugins/breakout/ui/LayoutButton.js +0 -133
- package/dist/cjs/plugins/breakout/utils/find-breakout-node.js +0 -42
- package/dist/cjs/plugins/breakout/utils/get-breakout-mode.js +0 -24
- package/dist/cjs/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -27
- package/dist/cjs/plugins/breakout/utils/is-supported-node.js +0 -15
- package/dist/es2019/plugins/breakout/commands/remove-breakout.js +0 -22
- package/dist/es2019/plugins/breakout/commands/set-breakout-mode.js +0 -23
- package/dist/es2019/plugins/breakout/index.js +0 -208
- package/dist/es2019/plugins/breakout/plugin-key.js +0 -3
- package/dist/es2019/plugins/breakout/types.js +0 -1
- package/dist/es2019/plugins/breakout/ui/LayoutButton.js +0 -117
- package/dist/es2019/plugins/breakout/utils/find-breakout-node.js +0 -37
- package/dist/es2019/plugins/breakout/utils/get-breakout-mode.js +0 -16
- package/dist/es2019/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -22
- package/dist/es2019/plugins/breakout/utils/is-supported-node.js +0 -9
- package/dist/esm/plugins/breakout/commands/remove-breakout.js +0 -24
- package/dist/esm/plugins/breakout/commands/set-breakout-mode.js +0 -23
- package/dist/esm/plugins/breakout/index.js +0 -211
- package/dist/esm/plugins/breakout/plugin-key.js +0 -5
- package/dist/esm/plugins/breakout/types.js +0 -1
- package/dist/esm/plugins/breakout/ui/LayoutButton.js +0 -126
- package/dist/esm/plugins/breakout/utils/find-breakout-node.js +0 -37
- package/dist/esm/plugins/breakout/utils/get-breakout-mode.js +0 -18
- package/dist/esm/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -22
- package/dist/esm/plugins/breakout/utils/is-supported-node.js +0 -9
- package/dist/types/plugins/breakout/commands/remove-breakout.d.ts +0 -2
- package/dist/types/plugins/breakout/commands/set-breakout-mode.d.ts +0 -3
- package/dist/types/plugins/breakout/index.d.ts +0 -12
- package/dist/types/plugins/breakout/plugin-key.d.ts +0 -5
- package/dist/types/plugins/breakout/types.d.ts +0 -4
- package/dist/types/plugins/breakout/ui/LayoutButton.d.ts +0 -17
- package/dist/types/plugins/breakout/utils/find-breakout-node.d.ts +0 -9
- package/dist/types/plugins/breakout/utils/get-breakout-mode.d.ts +0 -7
- package/dist/types/plugins/breakout/utils/is-breakout-mark-allowed.d.ts +0 -9
- package/dist/types/plugins/breakout/utils/is-supported-node.d.ts +0 -6
- package/dist/types-ts4.5/plugins/breakout/commands/remove-breakout.d.ts +0 -2
- package/dist/types-ts4.5/plugins/breakout/commands/set-breakout-mode.d.ts +0 -3
- package/dist/types-ts4.5/plugins/breakout/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/breakout/plugin-key.d.ts +0 -5
- package/dist/types-ts4.5/plugins/breakout/types.d.ts +0 -4
- package/dist/types-ts4.5/plugins/breakout/ui/LayoutButton.d.ts +0 -17
- package/dist/types-ts4.5/plugins/breakout/utils/find-breakout-node.d.ts +0 -9
- package/dist/types-ts4.5/plugins/breakout/utils/get-breakout-mode.d.ts +0 -7
- package/dist/types-ts4.5/plugins/breakout/utils/is-breakout-mark-allowed.d.ts +0 -9
- package/dist/types-ts4.5/plugins/breakout/utils/is-supported-node.d.ts +0 -6
|
@@ -1,218 +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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _react = _interopRequireDefault(require("react"));
|
|
12
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
14
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
|
-
var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
|
|
16
|
-
var _pluginKey = require("./plugin-key");
|
|
17
|
-
var _findBreakoutNode = require("./utils/find-breakout-node");
|
|
18
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
20
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
21
|
-
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; }
|
|
22
|
-
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; }
|
|
23
|
-
var BreakoutView = /*#__PURE__*/function () {
|
|
24
|
-
function BreakoutView(
|
|
25
|
-
/**
|
|
26
|
-
* Note: this is actually a PMMark -- however our version
|
|
27
|
-
* of the prosemirror and prosemirror types mean using PMNode
|
|
28
|
-
* is not problematic.
|
|
29
|
-
*/
|
|
30
|
-
mark, view, pluginInjectionApi) {
|
|
31
|
-
var _this = this;
|
|
32
|
-
(0, _classCallCheck2.default)(this, BreakoutView);
|
|
33
|
-
(0, _defineProperty2.default)(this, "updateWidth", function (widthState) {
|
|
34
|
-
// we skip updating the width of breakout nodes if the editorView dom
|
|
35
|
-
// element was hidden (to avoid breakout width and button thrashing
|
|
36
|
-
// when an editor is hidden, re-rendered and unhidden).
|
|
37
|
-
if (widthState === undefined || widthState.width === 0) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
var containerStyle = "";
|
|
41
|
-
var contentStyle = "";
|
|
42
|
-
var breakoutWidthPx = (0, _utils.calcBreakoutWidthPx)(_this.mark.attrs.mode, widthState.width);
|
|
43
|
-
if (widthState.lineLength) {
|
|
44
|
-
if (breakoutWidthPx < widthState.lineLength) {
|
|
45
|
-
breakoutWidthPx = widthState.lineLength;
|
|
46
|
-
}
|
|
47
|
-
containerStyle += "\n transform: none;\n display: flex;\n justify-content: center;\n ";
|
|
48
|
-
|
|
49
|
-
// There is a delay in the animation because widthState is delayed.
|
|
50
|
-
// When the editor goes full width the animation for the editor
|
|
51
|
-
// begins and finishes before widthState can update the new dimensions.
|
|
52
|
-
contentStyle += "\n min-width: ".concat(breakoutWidthPx, "px;\n transition: min-width 0.5s ").concat(_editorSharedStyles.akEditorSwoopCubicBezier, ";\n ");
|
|
53
|
-
} else {
|
|
54
|
-
// fallback method
|
|
55
|
-
// (lineLength is not normally undefined, but might be in e.g. SSR or initial render)
|
|
56
|
-
//
|
|
57
|
-
// this approach doesn't work well with position: fixed, so
|
|
58
|
-
// it breaks things like sticky headers
|
|
59
|
-
containerStyle += "width: ".concat(breakoutWidthPx, "px; transform: translateX(-50%); margin-left: 50%;");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// NOTE: This is a hack to ignore mutation since mark NodeView doesn't support
|
|
63
|
-
// `ignoreMutation` life-cycle event. @see ED-9947
|
|
64
|
-
var viewDomObserver = _this.view.domObserver;
|
|
65
|
-
if (viewDomObserver && _this.view.dom) {
|
|
66
|
-
viewDomObserver.stop();
|
|
67
|
-
setTimeout(function () {
|
|
68
|
-
viewDomObserver.start();
|
|
69
|
-
}, 0);
|
|
70
|
-
}
|
|
71
|
-
if (typeof _this.dom.style.cssText !== 'undefined') {
|
|
72
|
-
_this.dom.style.cssText = containerStyle;
|
|
73
|
-
_this.contentDOM.style.cssText = contentStyle;
|
|
74
|
-
} else {
|
|
75
|
-
_this.dom.setAttribute('style', containerStyle);
|
|
76
|
-
_this.contentDOM.setAttribute('style', contentStyle);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
var contentDOM = document.createElement('div');
|
|
80
|
-
contentDOM.className = _styles.BreakoutCssClassName.BREAKOUT_MARK_DOM;
|
|
81
|
-
var dom = document.createElement('div');
|
|
82
|
-
dom.className = _styles.BreakoutCssClassName.BREAKOUT_MARK;
|
|
83
|
-
dom.setAttribute('data-layout', mark.attrs.mode);
|
|
84
|
-
dom.appendChild(contentDOM);
|
|
85
|
-
this.dom = dom;
|
|
86
|
-
this.mark = mark;
|
|
87
|
-
this.view = view;
|
|
88
|
-
this.contentDOM = contentDOM;
|
|
89
|
-
this.unsubscribe = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width.sharedState.onChange(function (_ref) {
|
|
90
|
-
var nextSharedState = _ref.nextSharedState;
|
|
91
|
-
return _this.updateWidth(nextSharedState);
|
|
92
|
-
});
|
|
93
|
-
this.updateWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width.sharedState.currentState());
|
|
94
|
-
}
|
|
95
|
-
(0, _createClass2.default)(BreakoutView, [{
|
|
96
|
-
key: "destroy",
|
|
97
|
-
value:
|
|
98
|
-
// NOTE: Lifecycle events doesn't work for mark NodeView. So currently this is a no-op.
|
|
99
|
-
// @see https://github.com/ProseMirror/prosemirror/issues/1082
|
|
100
|
-
function destroy() {
|
|
101
|
-
var _this$unsubscribe;
|
|
102
|
-
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
103
|
-
}
|
|
104
|
-
}]);
|
|
105
|
-
return BreakoutView;
|
|
106
|
-
}();
|
|
107
|
-
function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
|
|
108
|
-
if (newBreakoutNode && currentBreakoutNode) {
|
|
109
|
-
return newBreakoutNode !== currentBreakoutNode;
|
|
110
|
-
}
|
|
111
|
-
return newBreakoutNode || currentBreakoutNode ? true : false;
|
|
112
|
-
}
|
|
113
|
-
function createPlugin(pluginInjectionApi, _ref2) {
|
|
114
|
-
var dispatch = _ref2.dispatch;
|
|
115
|
-
return new _safePlugin.SafePlugin({
|
|
116
|
-
state: {
|
|
117
|
-
init: function init() {
|
|
118
|
-
return {
|
|
119
|
-
breakoutNode: undefined
|
|
120
|
-
};
|
|
121
|
-
},
|
|
122
|
-
apply: function apply(tr, pluginState) {
|
|
123
|
-
var breakoutNode = (0, _findBreakoutNode.findSupportedNodeForBreakout)(tr.selection);
|
|
124
|
-
if (shouldPluginStateUpdate(breakoutNode, pluginState.breakoutNode)) {
|
|
125
|
-
var nextPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
126
|
-
breakoutNode: breakoutNode
|
|
127
|
-
});
|
|
128
|
-
dispatch(_pluginKey.pluginKey, nextPluginState);
|
|
129
|
-
return nextPluginState;
|
|
130
|
-
}
|
|
131
|
-
return pluginState;
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
key: _pluginKey.pluginKey,
|
|
135
|
-
props: {
|
|
136
|
-
nodeViews: {
|
|
137
|
-
// Note: When we upgrade to prosemirror 1.27.2 -- we should
|
|
138
|
-
// move this to markViews.
|
|
139
|
-
// See the following link for more details:
|
|
140
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews.
|
|
141
|
-
breakout: function breakout(mark, view) {
|
|
142
|
-
return new BreakoutView(mark, view, pluginInjectionApi);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
var LayoutButtonWrapper = function LayoutButtonWrapper(_ref3) {
|
|
149
|
-
var _breakoutState$breako, _breakoutState$breako2;
|
|
150
|
-
var api = _ref3.api,
|
|
151
|
-
editorView = _ref3.editorView,
|
|
152
|
-
boundariesElement = _ref3.boundariesElement,
|
|
153
|
-
scrollableElement = _ref3.scrollableElement,
|
|
154
|
-
mountPoint = _ref3.mountPoint;
|
|
155
|
-
// Re-render with `width` (but don't use state) due to https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/24272
|
|
156
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'breakout']),
|
|
157
|
-
breakoutState = _useSharedPluginState.breakoutState;
|
|
158
|
-
return /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
|
159
|
-
editorView: editorView,
|
|
160
|
-
mountPoint: mountPoint,
|
|
161
|
-
boundariesElement: boundariesElement,
|
|
162
|
-
scrollableElement: scrollableElement,
|
|
163
|
-
node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 || (_breakoutState$breako2 = breakoutState.breakoutNode) === null || _breakoutState$breako2 === void 0 ? void 0 : _breakoutState$breako2.node) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
var breakoutPlugin = function breakoutPlugin(_ref4) {
|
|
167
|
-
var options = _ref4.config,
|
|
168
|
-
api = _ref4.api;
|
|
169
|
-
return {
|
|
170
|
-
name: 'breakout',
|
|
171
|
-
pmPlugins: function pmPlugins() {
|
|
172
|
-
return [{
|
|
173
|
-
name: 'breakout',
|
|
174
|
-
plugin: function plugin(props) {
|
|
175
|
-
return createPlugin(api, props);
|
|
176
|
-
}
|
|
177
|
-
}];
|
|
178
|
-
},
|
|
179
|
-
marks: function marks() {
|
|
180
|
-
return [{
|
|
181
|
-
name: 'breakout',
|
|
182
|
-
mark: _adfSchema.breakout
|
|
183
|
-
}];
|
|
184
|
-
},
|
|
185
|
-
getSharedState: function getSharedState(editorState) {
|
|
186
|
-
if (!editorState) {
|
|
187
|
-
return {
|
|
188
|
-
breakoutNode: undefined
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
var pluginState = _pluginKey.pluginKey.getState(editorState);
|
|
192
|
-
if (!pluginState) {
|
|
193
|
-
return {
|
|
194
|
-
breakoutNode: undefined
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
return pluginState;
|
|
198
|
-
},
|
|
199
|
-
contentComponent: function contentComponent(_ref5) {
|
|
200
|
-
var editorView = _ref5.editorView,
|
|
201
|
-
popupsMountPoint = _ref5.popupsMountPoint,
|
|
202
|
-
popupsBoundariesElement = _ref5.popupsBoundariesElement,
|
|
203
|
-
popupsScrollableElement = _ref5.popupsScrollableElement;
|
|
204
|
-
// This is a bit crappy, but should be resolved once we move to a static schema.
|
|
205
|
-
if (options && !options.allowBreakoutButton) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
return /*#__PURE__*/_react.default.createElement(LayoutButtonWrapper, {
|
|
209
|
-
api: api,
|
|
210
|
-
mountPoint: popupsMountPoint,
|
|
211
|
-
editorView: editorView,
|
|
212
|
-
boundariesElement: popupsBoundariesElement,
|
|
213
|
-
scrollableElement: popupsScrollableElement
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
var _default = exports.default = breakoutPlugin;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pluginKey = exports.getPluginState = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var pluginKey = exports.pluginKey = new _state.PluginKey('breakoutPlugin');
|
|
9
|
-
var getPluginState = exports.getPluginState = function getPluginState(state) {
|
|
10
|
-
return pluginKey.getState(state) || undefined;
|
|
11
|
-
};
|
|
@@ -1,133 +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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
16
|
-
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _react2 = require("@emotion/react");
|
|
18
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
19
|
-
var _reactIntlNext = require("react-intl-next");
|
|
20
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
21
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
22
|
-
var _collapse = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/collapse"));
|
|
23
|
-
var _expand = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/expand"));
|
|
24
|
-
var _ToolbarButton = _interopRequireDefault(require("../../../ui/ToolbarButton"));
|
|
25
|
-
var _getBreakoutMode = require("../utils/get-breakout-mode");
|
|
26
|
-
var _setBreakoutMode = require("../commands/set-breakout-mode");
|
|
27
|
-
var _removeBreakout = require("../commands/remove-breakout");
|
|
28
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
29
|
-
var _isBreakoutMarkAllowed = require("../utils/is-breakout-mark-allowed");
|
|
30
|
-
var _pluginKey = require("../plugin-key");
|
|
31
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
32
|
-
var _isSupportedNode = require("../utils/is-supported-node");
|
|
33
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
34
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
35
|
-
var _templateObject;
|
|
36
|
-
/** @jsx jsx */
|
|
37
|
-
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); }; }
|
|
38
|
-
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; } }
|
|
39
|
-
var toolbarButtonWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n && button {\n background: ", ";\n color: ", ";\n :hover {\n background: ", ";\n color: ", " !important;\n }\n }\n"])), "var(--ds-background-neutral, ".concat(_colors.N20A, ")"), "var(--ds-icon, ".concat(_colors.N300, ")"), "var(--ds-background-neutral-hovered, ".concat(_colors.B300, ")"), "var(--ds-icon, white)");
|
|
40
|
-
function getBreakoutNodeElement(pluginState, selection, editorView) {
|
|
41
|
-
if (!pluginState.breakoutNode) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
if (selection instanceof _state.NodeSelection && (0, _isSupportedNode.isSupportedNodeForBreakout)(selection.node)) {
|
|
45
|
-
return (0, _utils.findDomRefAtPos)(selection.from, editorView.domAtPos.bind(editorView));
|
|
46
|
-
}
|
|
47
|
-
return (0, _utils.findParentDomRefOfType)(pluginState.breakoutNode.node.type, editorView.domAtPos.bind(editorView))(selection);
|
|
48
|
-
}
|
|
49
|
-
var LayoutButton = /*#__PURE__*/function (_React$Component) {
|
|
50
|
-
(0, _inherits2.default)(LayoutButton, _React$Component);
|
|
51
|
-
var _super = _createSuper(LayoutButton);
|
|
52
|
-
function LayoutButton() {
|
|
53
|
-
var _this;
|
|
54
|
-
(0, _classCallCheck2.default)(this, LayoutButton);
|
|
55
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
56
|
-
args[_key] = arguments[_key];
|
|
57
|
-
}
|
|
58
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
59
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function (breakoutMode) {
|
|
60
|
-
return function () {
|
|
61
|
-
var _this$props$editorVie = _this.props.editorView,
|
|
62
|
-
state = _this$props$editorVie.state,
|
|
63
|
-
dispatch = _this$props$editorVie.dispatch;
|
|
64
|
-
if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
|
|
65
|
-
(0, _setBreakoutMode.setBreakoutMode)(breakoutMode)(state, dispatch);
|
|
66
|
-
} else {
|
|
67
|
-
(0, _removeBreakout.removeBreakout)()(state, dispatch);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
return _this;
|
|
72
|
-
}
|
|
73
|
-
(0, _createClass2.default)(LayoutButton, [{
|
|
74
|
-
key: "render",
|
|
75
|
-
value: function render() {
|
|
76
|
-
var _this$props = this.props,
|
|
77
|
-
formatMessage = _this$props.intl.formatMessage,
|
|
78
|
-
mountPoint = _this$props.mountPoint,
|
|
79
|
-
boundariesElement = _this$props.boundariesElement,
|
|
80
|
-
scrollableElement = _this$props.scrollableElement,
|
|
81
|
-
editorView = _this$props.editorView,
|
|
82
|
-
node = _this$props.node;
|
|
83
|
-
var state = editorView.state;
|
|
84
|
-
if (!node || !(0, _isBreakoutMarkAllowed.isBreakoutMarkAllowed)(state)) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
var breakoutMode = (0, _getBreakoutMode.getBreakoutMode)(editorView.state);
|
|
88
|
-
var titleMessage = (0, _utils2.getTitle)(breakoutMode);
|
|
89
|
-
var title = formatMessage(titleMessage);
|
|
90
|
-
var nextBreakoutMode = (0, _utils2.getNextBreakoutMode)(breakoutMode);
|
|
91
|
-
var belowOtherPopupsZIndex = _constants.layers.layer() - 1;
|
|
92
|
-
var pluginState = (0, _pluginKey.getPluginState)(state);
|
|
93
|
-
if (!pluginState) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
var element = getBreakoutNodeElement(pluginState, state.selection, editorView);
|
|
97
|
-
if (!element) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
var closestEl = element.querySelector(".".concat(_styles.BreakoutCssClassName.BREAKOUT_MARK_DOM));
|
|
101
|
-
if (closestEl && closestEl.firstChild) {
|
|
102
|
-
element = closestEl.firstChild;
|
|
103
|
-
}
|
|
104
|
-
return (0, _react2.jsx)(_ui.Popup, {
|
|
105
|
-
ariaLabel: title,
|
|
106
|
-
target: element,
|
|
107
|
-
offset: [5, 0],
|
|
108
|
-
alignY: "start",
|
|
109
|
-
alignX: "end",
|
|
110
|
-
mountTo: mountPoint,
|
|
111
|
-
boundariesElement: boundariesElement,
|
|
112
|
-
scrollableElement: scrollableElement,
|
|
113
|
-
stick: true,
|
|
114
|
-
forcePlacement: true,
|
|
115
|
-
zIndex: belowOtherPopupsZIndex
|
|
116
|
-
}, (0, _react2.jsx)("div", {
|
|
117
|
-
css: toolbarButtonWrapper
|
|
118
|
-
}, (0, _react2.jsx)(_ToolbarButton.default, {
|
|
119
|
-
title: title,
|
|
120
|
-
testId: titleMessage.id,
|
|
121
|
-
onClick: this.handleClick(nextBreakoutMode),
|
|
122
|
-
iconBefore: breakoutMode === 'full-width' ? (0, _react2.jsx)(_collapse.default, {
|
|
123
|
-
label: title
|
|
124
|
-
}) : (0, _react2.jsx)(_expand.default, {
|
|
125
|
-
label: title
|
|
126
|
-
})
|
|
127
|
-
})));
|
|
128
|
-
}
|
|
129
|
-
}]);
|
|
130
|
-
return LayoutButton;
|
|
131
|
-
}(_react.default.Component);
|
|
132
|
-
(0, _defineProperty2.default)(LayoutButton, "displayName", 'LayoutButton');
|
|
133
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(LayoutButton);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findSupportedNodeForBreakout = findSupportedNodeForBreakout;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
-
var _isSupportedNode = require("./is-supported-node");
|
|
10
|
-
/**
|
|
11
|
-
* Find the nearest parent node to the selection that supports breakout, or if the nearest
|
|
12
|
-
* matching parent node is the doc, return undefined.
|
|
13
|
-
* For depth, if a node is selected and supports breakout, return the depth of the node.
|
|
14
|
-
* @param selection Current editor selection
|
|
15
|
-
*/
|
|
16
|
-
function findSupportedNodeForBreakout(selection) {
|
|
17
|
-
if (selection instanceof _state.NodeSelection) {
|
|
18
|
-
var supportsBreakout = (0, _isSupportedNode.isSupportedNodeForBreakout)(selection.node);
|
|
19
|
-
if (supportsBreakout) {
|
|
20
|
-
return {
|
|
21
|
-
pos: selection.from,
|
|
22
|
-
start: selection.from,
|
|
23
|
-
node: selection.node,
|
|
24
|
-
// If a selected expand is in a doc, the depth of that expand is 0. Therefore
|
|
25
|
-
// we don't need to subtract 1 or instantly return false if the depth is 0
|
|
26
|
-
depth: selection.$anchor.depth
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
var breakoutNode = (0, _utils.findParentNode)(_isSupportedNode.isSupportedNodeForBreakout)(selection);
|
|
31
|
-
if (!breakoutNode || breakoutNode.depth === 0) {
|
|
32
|
-
// If this node doesn't exist or the only supporting node is the document
|
|
33
|
-
// (with depth 0), then we're not inside a node that supports breakout
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
node: breakoutNode.node,
|
|
38
|
-
start: breakoutNode.start,
|
|
39
|
-
pos: breakoutNode.pos,
|
|
40
|
-
depth: breakoutNode.depth - 1
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBreakoutMode = getBreakoutMode;
|
|
7
|
-
var _findBreakoutNode = require("./find-breakout-node");
|
|
8
|
-
/**
|
|
9
|
-
* Get the current mode of the breakout at the selection
|
|
10
|
-
* @param state Current EditorState
|
|
11
|
-
*/
|
|
12
|
-
function getBreakoutMode(state) {
|
|
13
|
-
var node = (0, _findBreakoutNode.findSupportedNodeForBreakout)(state.selection);
|
|
14
|
-
if (!node) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
var breakoutMark = node.node.marks.find(function (m) {
|
|
18
|
-
return m.type.name === 'breakout';
|
|
19
|
-
});
|
|
20
|
-
if (!breakoutMark) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
return breakoutMark.attrs.mode;
|
|
24
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isBreakoutMarkAllowed = isBreakoutMarkAllowed;
|
|
7
|
-
var _findBreakoutNode = require("./find-breakout-node");
|
|
8
|
-
/**
|
|
9
|
-
* Check if breakout should be allowed for the current selection. If a node is selected,
|
|
10
|
-
* can this node be broken out, if text, can the enclosing parent node be broken out.
|
|
11
|
-
*
|
|
12
|
-
* Currently breakout of a node is not possible if it's nested in anything but the document, however
|
|
13
|
-
* this logic supports this changing.
|
|
14
|
-
*/
|
|
15
|
-
function isBreakoutMarkAllowed(state) {
|
|
16
|
-
if (!state.schema.marks.breakout) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
var supportedNodeParent = (0, _findBreakoutNode.findSupportedNodeForBreakout)(state.selection);
|
|
20
|
-
if (!supportedNodeParent) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
// At the moment we can only breakout when the depth is 0, ie. doc is the only node
|
|
24
|
-
// that supports breakout. This *could* change though.
|
|
25
|
-
var parent = state.selection.$from.node(supportedNodeParent.depth);
|
|
26
|
-
return parent.type.allowsMarkType(state.schema.marks.breakout);
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSupportedNodeForBreakout = isSupportedNodeForBreakout;
|
|
7
|
-
var supportedNodesForBreakout = ['codeBlock', 'layoutSection', 'expand'];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Check if breakout can be applied to a node
|
|
11
|
-
* @param node Node to check
|
|
12
|
-
*/
|
|
13
|
-
function isSupportedNodeForBreakout(node) {
|
|
14
|
-
return supportedNodesForBreakout.indexOf(node.type.name) !== -1;
|
|
15
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { findSupportedNodeForBreakout } from '../utils/find-breakout-node';
|
|
2
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export function removeBreakout() {
|
|
4
|
-
return (state, dispatch) => {
|
|
5
|
-
const node = findSupportedNodeForBreakout(state.selection);
|
|
6
|
-
if (!node) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const marks = node.node.marks.filter(m => m.type.name !== 'breakout');
|
|
10
|
-
const tr = state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, marks);
|
|
11
|
-
tr.setMeta('scrollIntoView', false);
|
|
12
|
-
if (state.selection instanceof NodeSelection) {
|
|
13
|
-
if (state.selection.$anchor.pos === node.pos) {
|
|
14
|
-
tr.setSelection(NodeSelection.create(tr.doc, node.pos));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (dispatch) {
|
|
18
|
-
dispatch(tr);
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { findSupportedNodeForBreakout } from '../utils/find-breakout-node';
|
|
2
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export function setBreakoutMode(mode) {
|
|
4
|
-
return (state, dispatch) => {
|
|
5
|
-
const node = findSupportedNodeForBreakout(state.selection);
|
|
6
|
-
if (!node) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const tr = state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, [state.schema.marks.breakout.create({
|
|
10
|
-
mode
|
|
11
|
-
})]);
|
|
12
|
-
tr.setMeta('scrollIntoView', false);
|
|
13
|
-
if (state.selection instanceof NodeSelection) {
|
|
14
|
-
if (state.selection.$anchor.pos === node.pos) {
|
|
15
|
-
tr.setSelection(NodeSelection.create(tr.doc, node.pos));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (dispatch) {
|
|
19
|
-
dispatch(tr);
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
};
|
|
23
|
-
}
|