@atlaskit/editor-core 189.1.11 → 189.1.13
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 +14 -0
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/plugins/insert-block/index.js +6 -10
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/cjs/presets/universal.js +4 -2
- package/dist/cjs/ui/ContentStyles/index.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/plugins/insert-block/index.js +5 -9
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/es2019/presets/universal.js +3 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/plugins/insert-block/index.js +5 -9
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/esm/presets/universal.js +3 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +4 -2
- package/dist/types/types/editor-props.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -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-ts4.5/types/editor-props.d.ts +2 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/package.json +4 -2
- package/report.api.md +2 -16
- package/tmp/api-report-tmp.d.ts +2 -16
- package/dist/cjs/plugins/layout/actions.js +0 -345
- package/dist/cjs/plugins/layout/index.js +0 -91
- package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
- package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
- package/dist/cjs/plugins/layout/toolbar.js +0 -116
- package/dist/cjs/plugins/layout/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/actions.js +0 -35
- package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
- package/dist/cjs/plugins/placeholder-text/index.js +0 -20
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
- package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
- package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
- package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
- package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
- package/dist/cjs/plugins/placeholder-text/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
- package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
- package/dist/es2019/plugins/layout/actions.js +0 -328
- package/dist/es2019/plugins/layout/index.js +0 -75
- package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
- package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
- package/dist/es2019/plugins/layout/toolbar.js +0 -101
- package/dist/es2019/plugins/layout/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/actions.js +0 -27
- package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
- package/dist/es2019/plugins/placeholder-text/index.js +0 -2
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
- package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
- package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
- package/dist/es2019/plugins/placeholder-text/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
- package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
- package/dist/esm/plugins/layout/actions.js +0 -336
- package/dist/esm/plugins/layout/index.js +0 -79
- package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
- package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
- package/dist/esm/plugins/layout/toolbar.js +0 -109
- package/dist/esm/plugins/layout/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/actions.js +0 -29
- package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
- package/dist/esm/plugins/placeholder-text/index.js +0 -2
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
- package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
- package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/esm/plugins/placeholder-text/styles.js +0 -6
- package/dist/esm/plugins/placeholder-text/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
- package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
- package/dist/types/plugins/layout/actions.d.ts +0 -22
- package/dist/types/plugins/layout/index.d.ts +0 -15
- package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types/plugins/layout/types.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
- package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
- package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
- package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
|
@@ -1,13 +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.placeholderTextStyles = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
11
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
-
var _templateObject;
|
|
13
|
-
var placeholderTextStyles = exports.placeholderTextStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .ProseMirror span[data-placeholder] {\n color: ", ";\n display: inline;\n }\n\n .ProseMirror span.pm-placeholder {\n display: inline;\n color: ", ";\n }\n .ProseMirror span.pm-placeholder__text {\n display: inline;\n color: ", ";\n }\n\n .ProseMirror span.pm-placeholder.", " {\n ", "\n }\n\n .ProseMirror span.pm-placeholder__text[data-placeholder]::after {\n color: ", ";\n cursor: text;\n content: attr(data-placeholder);\n display: inline;\n }\n\n .ProseMirror {\n .ProseMirror-fake-text-cursor {\n display: inline;\n pointer-events: none;\n position: relative;\n }\n\n .ProseMirror-fake-text-cursor::after {\n content: '';\n display: inline;\n top: 0;\n position: absolute;\n border-right: 1px solid ", ";\n }\n\n .ProseMirror-fake-text-selection {\n display: inline;\n pointer-events: none;\n position: relative;\n background-color: ", ";\n }\n }\n"])), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), _editorSharedStyles.akEditorSelectedNodeClassName, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.Background]), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), "var(--ds-border, rgba(0, 0, 0, 0.4))", "var(--ds-background-selected, ".concat(_colors.B75, ")"));
|
|
@@ -1,86 +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
|
-
Object.defineProperty(exports, "getNearestNonTextNode", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _utils.getNearestNonTextNode;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "getOffsetParent", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function get() {
|
|
17
|
-
return _utils.getOffsetParent;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "handlePositionCalculatedWith", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function get() {
|
|
23
|
-
return _utils.handlePositionCalculatedWith;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
27
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
28
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
29
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
30
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
31
|
-
var _react = require("@emotion/react");
|
|
32
|
-
var _react2 = require("react");
|
|
33
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
34
|
-
var _styles = require("./styles");
|
|
35
|
-
var _utils = require("./utils");
|
|
36
|
-
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); }; }
|
|
37
|
-
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 */
|
|
38
|
-
var FloatingToolbar = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
39
|
-
(0, _inherits2.default)(FloatingToolbar, _PureComponent);
|
|
40
|
-
var _super = _createSuper(FloatingToolbar);
|
|
41
|
-
function FloatingToolbar() {
|
|
42
|
-
(0, _classCallCheck2.default)(this, FloatingToolbar);
|
|
43
|
-
return _super.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
(0, _createClass2.default)(FloatingToolbar, [{
|
|
46
|
-
key: "render",
|
|
47
|
-
value: function render() {
|
|
48
|
-
var _this$props = this.props,
|
|
49
|
-
children = _this$props.children,
|
|
50
|
-
target = _this$props.target,
|
|
51
|
-
offset = _this$props.offset,
|
|
52
|
-
fitWidth = _this$props.fitWidth,
|
|
53
|
-
_this$props$fitHeight = _this$props.fitHeight,
|
|
54
|
-
fitHeight = _this$props$fitHeight === void 0 ? 40 : _this$props$fitHeight,
|
|
55
|
-
onPositionCalculated = _this$props.onPositionCalculated,
|
|
56
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
57
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
58
|
-
className = _this$props.className,
|
|
59
|
-
absoluteOffset = _this$props.absoluteOffset,
|
|
60
|
-
alignX = _this$props.alignX,
|
|
61
|
-
alignY = _this$props.alignY,
|
|
62
|
-
zIndex = _this$props.zIndex;
|
|
63
|
-
if (!target) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return (0, _react.jsx)(_ui.Popup, {
|
|
67
|
-
absoluteOffset: absoluteOffset,
|
|
68
|
-
alignX: alignX,
|
|
69
|
-
alignY: alignY,
|
|
70
|
-
target: target,
|
|
71
|
-
zIndex: zIndex,
|
|
72
|
-
mountTo: popupsMountPoint,
|
|
73
|
-
boundariesElement: popupsBoundariesElement,
|
|
74
|
-
offset: offset,
|
|
75
|
-
fitWidth: fitWidth,
|
|
76
|
-
fitHeight: fitHeight,
|
|
77
|
-
onPositionCalculated: onPositionCalculated
|
|
78
|
-
}, (0, _react.jsx)("div", {
|
|
79
|
-
css: (0, _styles.container)(fitHeight),
|
|
80
|
-
"data-testid": "popup-container",
|
|
81
|
-
className: className
|
|
82
|
-
}, children));
|
|
83
|
-
}
|
|
84
|
-
}]);
|
|
85
|
-
return FloatingToolbar;
|
|
86
|
-
}(_react2.PureComponent);
|
|
@@ -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.container = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
11
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
12
|
-
var _templateObject, _templateObject2;
|
|
13
|
-
var container = exports.container = function container(height) {
|
|
14
|
-
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n border-radius: ", "px;\n box-shadow: ", ";\n display: flex;\n align-items: center;\n box-sizing: border-box;\n padding: ", " ", ";\n background-color: ", ";\n ", ";\n"])), (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 12px 24px -6px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"), "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)", "var(--ds-background-input, ".concat(_colors.N0, ")"), height ? (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n height: ", "px;\n "])), height) : '');
|
|
15
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handlePositionCalculatedWith = exports.getOffsetParent = exports.getNearestNonTextNode = void 0;
|
|
7
|
-
var getCursorHeightFrom = function getCursorHeightFrom(node) {
|
|
8
|
-
return parseFloat(window.getComputedStyle(node, undefined).lineHeight || '');
|
|
9
|
-
};
|
|
10
|
-
var getOffsetParent = exports.getOffsetParent = function getOffsetParent(editorViewDom, popupsMountPoint) {
|
|
11
|
-
return popupsMountPoint ? popupsMountPoint.offsetParent : editorViewDom.offsetParent;
|
|
12
|
-
};
|
|
13
|
-
var getNearestNonTextNode = exports.getNearestNonTextNode = function getNearestNonTextNode(node) {
|
|
14
|
-
return node.nodeType === Node.TEXT_NODE ? node.parentNode : node;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* We need to translate the co-ordinates because `coordsAtPos` returns co-ordinates
|
|
19
|
-
* relative to `window`. And, also need to adjust the cursor container height.
|
|
20
|
-
* (0, 0)
|
|
21
|
-
* +--------------------- [window] ---------------------+
|
|
22
|
-
* | (left, top) +-------- [Offset Parent] --------+ |
|
|
23
|
-
* | {coordsAtPos} | [Cursor] <- cursorHeight | |
|
|
24
|
-
* | | [FloatingToolbar] | |
|
|
25
|
-
*/
|
|
26
|
-
var convertFixedCoordinatesToAbsolutePositioning = function convertFixedCoordinatesToAbsolutePositioning(coordinates, offsetParent, cursorHeight) {
|
|
27
|
-
var _offsetParent$getBoun = offsetParent.getBoundingClientRect(),
|
|
28
|
-
offsetParentLeft = _offsetParent$getBoun.left,
|
|
29
|
-
offsetParentTop = _offsetParent$getBoun.top,
|
|
30
|
-
offsetParentHeight = _offsetParent$getBoun.height;
|
|
31
|
-
return {
|
|
32
|
-
left: coordinates.left - offsetParentLeft,
|
|
33
|
-
right: coordinates.right - offsetParentLeft,
|
|
34
|
-
top: coordinates.top - (offsetParentTop - cursorHeight) + offsetParent.scrollTop,
|
|
35
|
-
bottom: offsetParentHeight - (coordinates.top - (offsetParentTop - cursorHeight) - offsetParent.scrollTop)
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
var handlePositionCalculatedWith = exports.handlePositionCalculatedWith = function handlePositionCalculatedWith(offsetParent, node, getCurrentFixedCoordinates) {
|
|
39
|
-
return function (position) {
|
|
40
|
-
if (!offsetParent) {
|
|
41
|
-
return position;
|
|
42
|
-
}
|
|
43
|
-
var target = getNearestNonTextNode(node);
|
|
44
|
-
var cursorHeight = getCursorHeightFrom(target);
|
|
45
|
-
var fixedCoordinates = getCurrentFixedCoordinates();
|
|
46
|
-
var absoluteCoordinates = convertFixedCoordinatesToAbsolutePositioning(fixedCoordinates, offsetParent, cursorHeight);
|
|
47
|
-
return {
|
|
48
|
-
left: position.left ? absoluteCoordinates.left : undefined,
|
|
49
|
-
right: position.right ? absoluteCoordinates.right : undefined,
|
|
50
|
-
top: position.top ? absoluteCoordinates.top : undefined,
|
|
51
|
-
bottom: position.bottom ? absoluteCoordinates.bottom : undefined
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
@@ -1,89 +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.messages = exports.default = void 0;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _reactIntlNext = require("react-intl-next");
|
|
18
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
|
-
var _FloatingToolbar = _interopRequireWildcard(require("../FloatingToolbar"));
|
|
20
|
-
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); }
|
|
21
|
-
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; }
|
|
22
|
-
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); }; }
|
|
23
|
-
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; } }
|
|
24
|
-
var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
|
|
25
|
-
placeholderTextPlaceholder: {
|
|
26
|
-
id: 'fabric.editor.placeholderTextPlaceholder',
|
|
27
|
-
defaultMessage: 'Add placeholder text',
|
|
28
|
-
description: ''
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
var PlaceholderFloatingToolbar = /*#__PURE__*/function (_React$Component) {
|
|
32
|
-
(0, _inherits2.default)(PlaceholderFloatingToolbar, _React$Component);
|
|
33
|
-
var _super = _createSuper(PlaceholderFloatingToolbar);
|
|
34
|
-
function PlaceholderFloatingToolbar() {
|
|
35
|
-
var _this;
|
|
36
|
-
(0, _classCallCheck2.default)(this, PlaceholderFloatingToolbar);
|
|
37
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
-
args[_key] = arguments[_key];
|
|
39
|
-
}
|
|
40
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSubmit", function (value) {
|
|
42
|
-
if (value) {
|
|
43
|
-
_this.props.insertPlaceholder(value);
|
|
44
|
-
_this.props.setFocusInEditor();
|
|
45
|
-
} else {
|
|
46
|
-
_this.props.hidePlaceholderFloatingToolbar();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleBlur", function () {
|
|
50
|
-
_this.props.hidePlaceholderFloatingToolbar();
|
|
51
|
-
});
|
|
52
|
-
return _this;
|
|
53
|
-
}
|
|
54
|
-
(0, _createClass2.default)(PlaceholderFloatingToolbar, [{
|
|
55
|
-
key: "render",
|
|
56
|
-
value: function render() {
|
|
57
|
-
var _this$props = this.props,
|
|
58
|
-
getNodeFromPos = _this$props.getNodeFromPos,
|
|
59
|
-
showInsertPanelAt = _this$props.showInsertPanelAt,
|
|
60
|
-
editorViewDOM = _this$props.editorViewDOM,
|
|
61
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
62
|
-
getFixedCoordinatesFromPos = _this$props.getFixedCoordinatesFromPos,
|
|
63
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
64
|
-
formatMessage = _this$props.intl.formatMessage;
|
|
65
|
-
var target = getNodeFromPos(showInsertPanelAt);
|
|
66
|
-
var offsetParent = (0, _FloatingToolbar.getOffsetParent)(editorViewDOM, popupsMountPoint);
|
|
67
|
-
var getFixedCoordinates = function getFixedCoordinates() {
|
|
68
|
-
return getFixedCoordinatesFromPos(showInsertPanelAt);
|
|
69
|
-
};
|
|
70
|
-
var handlePositionCalculated = (0, _FloatingToolbar.handlePositionCalculatedWith)(offsetParent, target, getFixedCoordinates);
|
|
71
|
-
return /*#__PURE__*/_react.default.createElement(_FloatingToolbar.default, {
|
|
72
|
-
target: (0, _FloatingToolbar.getNearestNonTextNode)(target),
|
|
73
|
-
onPositionCalculated: handlePositionCalculated,
|
|
74
|
-
popupsMountPoint: popupsMountPoint,
|
|
75
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
76
|
-
fitHeight: 32,
|
|
77
|
-
offset: [0, 12]
|
|
78
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.PanelTextInput, {
|
|
79
|
-
placeholder: formatMessage(messages.placeholderTextPlaceholder),
|
|
80
|
-
onSubmit: this.handleSubmit,
|
|
81
|
-
onBlur: this.handleBlur,
|
|
82
|
-
autoFocus: true,
|
|
83
|
-
width: 300
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
}]);
|
|
87
|
-
return PlaceholderFloatingToolbar;
|
|
88
|
-
}(_react.default.Component);
|
|
89
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(PlaceholderFloatingToolbar);
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { flatmap, mapChildren, getStepRange, isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, LAYOUT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
7
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
8
|
-
export const ONE_COL_LAYOUTS = ['single'];
|
|
9
|
-
export const TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
10
|
-
export const THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
11
|
-
const getWidthsForPreset = presetLayout => {
|
|
12
|
-
switch (presetLayout) {
|
|
13
|
-
case 'single':
|
|
14
|
-
return [100];
|
|
15
|
-
case 'two_equal':
|
|
16
|
-
return [50, 50];
|
|
17
|
-
case 'three_equal':
|
|
18
|
-
return [33.33, 33.33, 33.33];
|
|
19
|
-
case 'two_left_sidebar':
|
|
20
|
-
return [33.33, 66.66];
|
|
21
|
-
case 'two_right_sidebar':
|
|
22
|
-
return [66.66, 33.33];
|
|
23
|
-
case 'three_with_sidebars':
|
|
24
|
-
return [25, 50, 25];
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Finds layout preset based on the width attrs of all the layoutColumn nodes
|
|
30
|
-
* inside the layoutSection node
|
|
31
|
-
*/
|
|
32
|
-
export const getPresetLayout = section => {
|
|
33
|
-
const widths = mapChildren(section, column => column.attrs.width).join(',');
|
|
34
|
-
switch (widths) {
|
|
35
|
-
case '100':
|
|
36
|
-
return 'single';
|
|
37
|
-
case '33.33,33.33,33.33':
|
|
38
|
-
return 'three_equal';
|
|
39
|
-
case '25,50,25':
|
|
40
|
-
return 'three_with_sidebars';
|
|
41
|
-
case '50,50':
|
|
42
|
-
return 'two_equal';
|
|
43
|
-
case '33.33,66.66':
|
|
44
|
-
return 'two_left_sidebar';
|
|
45
|
-
case '66.66,33.33':
|
|
46
|
-
return 'two_right_sidebar';
|
|
47
|
-
}
|
|
48
|
-
return;
|
|
49
|
-
};
|
|
50
|
-
export const getSelectedLayout = (maybeLayoutSection, current) => {
|
|
51
|
-
if (maybeLayoutSection && getPresetLayout(maybeLayoutSection)) {
|
|
52
|
-
return getPresetLayout(maybeLayoutSection) || current;
|
|
53
|
-
}
|
|
54
|
-
return current;
|
|
55
|
-
};
|
|
56
|
-
export const createDefaultLayoutSection = state => {
|
|
57
|
-
const {
|
|
58
|
-
layoutSection,
|
|
59
|
-
layoutColumn
|
|
60
|
-
} = state.schema.nodes;
|
|
61
|
-
|
|
62
|
-
// create a 50-50 layout by default
|
|
63
|
-
const columns = Fragment.fromArray([layoutColumn.createAndFill({
|
|
64
|
-
width: 50
|
|
65
|
-
}), layoutColumn.createAndFill({
|
|
66
|
-
width: 50
|
|
67
|
-
})]);
|
|
68
|
-
return layoutSection.createAndFill(undefined, columns);
|
|
69
|
-
};
|
|
70
|
-
export const insertLayoutColumns = (state, dispatch) => {
|
|
71
|
-
if (dispatch) {
|
|
72
|
-
dispatch(safeInsert(createDefaultLayoutSection(state))(state.tr));
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
};
|
|
76
|
-
export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => inputMethod => withAnalytics(editorAnalyticsAPI, {
|
|
77
|
-
action: ACTION.INSERTED,
|
|
78
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
79
|
-
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
|
|
80
|
-
attributes: {
|
|
81
|
-
inputMethod
|
|
82
|
-
},
|
|
83
|
-
eventType: EVENT_TYPE.TRACK
|
|
84
|
-
})(insertLayoutColumns);
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Add a column to the right of existing layout
|
|
88
|
-
*/
|
|
89
|
-
function addColumn(schema, pos) {
|
|
90
|
-
return tr => {
|
|
91
|
-
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
95
|
-
return tr => {
|
|
96
|
-
if (isEmptyDocument(column)) {
|
|
97
|
-
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(insideRightEdgePos), Slice.empty);
|
|
98
|
-
} else {
|
|
99
|
-
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), Slice.empty);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const fromTwoColsToThree = addColumn;
|
|
104
|
-
const fromOneColToTwo = addColumn;
|
|
105
|
-
const fromTwoColsToOne = removeLastColumnInLayout;
|
|
106
|
-
const fromThreeColsToTwo = removeLastColumnInLayout;
|
|
107
|
-
const fromOneColToThree = (schema, pos) => {
|
|
108
|
-
return tr => {
|
|
109
|
-
addColumn(schema, pos)(tr);
|
|
110
|
-
addColumn(schema, pos)(tr);
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
const fromThreeColstoOne = (node, tr, insideRightEdgePos) => {
|
|
114
|
-
const thirdColumn = node.content.child(2);
|
|
115
|
-
fromThreeColsToTwo(thirdColumn, insideRightEdgePos - thirdColumn.nodeSize, insideRightEdgePos)(tr);
|
|
116
|
-
const secondColumn = node.content.child(1);
|
|
117
|
-
fromTwoColsToOne(secondColumn, insideRightEdgePos - thirdColumn.nodeSize - secondColumn.nodeSize, insideRightEdgePos)(tr);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Handles switching from 2 -> 3 cols, or 3 -> 2 cols
|
|
122
|
-
* Switching from 2 -> 3 just adds a new one at the end
|
|
123
|
-
* Switching from 3 -> 2 moves all the content of the third col inside the second before
|
|
124
|
-
* removing it
|
|
125
|
-
*/
|
|
126
|
-
function forceColumnStructure(state, node, pos, presetLayout) {
|
|
127
|
-
const tr = state.tr;
|
|
128
|
-
const insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
129
|
-
const numCols = node.childCount;
|
|
130
|
-
|
|
131
|
-
// 3 columns -> 2 columns
|
|
132
|
-
if (TWO_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 3) {
|
|
133
|
-
const thirdColumn = node.content.child(2);
|
|
134
|
-
const columnPos = insideRightEdgeOfLayoutSection - thirdColumn.nodeSize;
|
|
135
|
-
fromThreeColsToTwo(thirdColumn, columnPos, insideRightEdgeOfLayoutSection)(tr);
|
|
136
|
-
|
|
137
|
-
// 2 columns -> 3 columns
|
|
138
|
-
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
139
|
-
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
140
|
-
|
|
141
|
-
// 2 columns -> 1 column
|
|
142
|
-
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
143
|
-
const secondColumn = node.content.child(1);
|
|
144
|
-
const columnPos = insideRightEdgeOfLayoutSection - secondColumn.nodeSize;
|
|
145
|
-
fromTwoColsToOne(secondColumn, columnPos, insideRightEdgeOfLayoutSection)(tr);
|
|
146
|
-
|
|
147
|
-
// 3 columns -> 1 column
|
|
148
|
-
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 3) {
|
|
149
|
-
fromThreeColstoOne(node, tr, insideRightEdgeOfLayoutSection);
|
|
150
|
-
|
|
151
|
-
// 1 column -> 2 columns
|
|
152
|
-
} else if (TWO_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 1) {
|
|
153
|
-
fromOneColToTwo(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
154
|
-
// 1 column -> 3 columns
|
|
155
|
-
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 1) {
|
|
156
|
-
fromOneColToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
157
|
-
}
|
|
158
|
-
return tr;
|
|
159
|
-
}
|
|
160
|
-
function columnWidth(node, schema, widths) {
|
|
161
|
-
const {
|
|
162
|
-
layoutColumn
|
|
163
|
-
} = schema.nodes;
|
|
164
|
-
const truncatedWidths = widths.map(w => Number(w.toFixed(2)));
|
|
165
|
-
return flatmap(node.content, (column, idx) => {
|
|
166
|
-
if (column.type === layoutColumn) {
|
|
167
|
-
return layoutColumn.create({
|
|
168
|
-
...column.attrs,
|
|
169
|
-
width: truncatedWidths[idx]
|
|
170
|
-
}, column.content, column.marks);
|
|
171
|
-
} else {
|
|
172
|
-
return column;
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
177
|
-
const node = tr.doc.nodeAt(pos);
|
|
178
|
-
if (!node) {
|
|
179
|
-
return tr;
|
|
180
|
-
}
|
|
181
|
-
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
182
|
-
}
|
|
183
|
-
export function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
184
|
-
let tr = forceColumnStructure(state, node, pos, presetLayout);
|
|
185
|
-
|
|
186
|
-
// save the selection here, since forcing column widths causes a change over the
|
|
187
|
-
// entire layoutSection, which remaps selection to the end. not remapping here
|
|
188
|
-
// is safe because the structure is no longer changing.
|
|
189
|
-
const selection = tr.selection;
|
|
190
|
-
tr = forceColumnWidths(state, tr, pos, presetLayout);
|
|
191
|
-
const selectionPos$ = tr.doc.resolve(selection.$from.pos);
|
|
192
|
-
return tr.setSelection(state.selection instanceof NodeSelection ? new NodeSelection(selectionPos$) : new TextSelection(selectionPos$));
|
|
193
|
-
}
|
|
194
|
-
export const setPresetLayout = editorAnalyticsAPI => layout => (state, dispatch) => {
|
|
195
|
-
const {
|
|
196
|
-
pos,
|
|
197
|
-
selectedLayout
|
|
198
|
-
} = pluginKey.getState(state);
|
|
199
|
-
if (selectedLayout === layout || pos === null) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
const node = state.doc.nodeAt(pos);
|
|
203
|
-
if (!node) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
let tr = forceSectionToPresetLayout(state, node, pos, layout);
|
|
207
|
-
if (tr) {
|
|
208
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
209
|
-
action: ACTION.CHANGED_LAYOUT,
|
|
210
|
-
actionSubject: ACTION_SUBJECT.LAYOUT,
|
|
211
|
-
attributes: {
|
|
212
|
-
previousLayout: formatLayoutName(selectedLayout),
|
|
213
|
-
newLayout: formatLayoutName(layout)
|
|
214
|
-
},
|
|
215
|
-
eventType: EVENT_TYPE.TRACK
|
|
216
|
-
})(tr);
|
|
217
|
-
tr.setMeta('scrollIntoView', false);
|
|
218
|
-
if (dispatch) {
|
|
219
|
-
dispatch(tr);
|
|
220
|
-
}
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
return false;
|
|
224
|
-
};
|
|
225
|
-
function layoutNeedChanges(node) {
|
|
226
|
-
return !getPresetLayout(node);
|
|
227
|
-
}
|
|
228
|
-
function getLayoutChange(node, pos, schema) {
|
|
229
|
-
if (node.type === schema.nodes.layoutSection) {
|
|
230
|
-
if (!layoutNeedChanges(node)) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const presetLayout = node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
234
|
-
const fixedColumns = columnWidth(node, schema, getWidthsForPreset(presetLayout));
|
|
235
|
-
return {
|
|
236
|
-
from: pos + 1,
|
|
237
|
-
to: pos + node.nodeSize - 1,
|
|
238
|
-
slice: new Slice(fixedColumns, 0, 0)
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
export const fixColumnSizes = (changedTr, state) => {
|
|
243
|
-
const {
|
|
244
|
-
layoutSection
|
|
245
|
-
} = state.schema.nodes;
|
|
246
|
-
let change;
|
|
247
|
-
const range = getStepRange(changedTr);
|
|
248
|
-
if (!range) {
|
|
249
|
-
return undefined;
|
|
250
|
-
}
|
|
251
|
-
changedTr.doc.nodesBetween(range.from, range.to, (node, pos) => {
|
|
252
|
-
if (node.type !== layoutSection) {
|
|
253
|
-
return true; // Check all internal nodes expect for layout section
|
|
254
|
-
}
|
|
255
|
-
// Node is a section
|
|
256
|
-
if (layoutNeedChanges(node)) {
|
|
257
|
-
change = getLayoutChange(node, pos, state.schema);
|
|
258
|
-
}
|
|
259
|
-
return false; // We dont go deep, We dont accept nested layouts
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
// Hack to prevent: https://product-fabric.atlassian.net/browse/ED-7523
|
|
263
|
-
// By default prosemirror try to recreate the node with the default attributes
|
|
264
|
-
// The default attribute is invalid adf though. when this happen the node after
|
|
265
|
-
// current position is a layout section
|
|
266
|
-
const $pos = changedTr.doc.resolve(range.to);
|
|
267
|
-
if ($pos.depth > 0) {
|
|
268
|
-
// 'range.to' position could resolve to doc, in this ResolvedPos.after will throws
|
|
269
|
-
const pos = $pos.after();
|
|
270
|
-
const node = changedTr.doc.nodeAt(pos);
|
|
271
|
-
if (node && node.type === layoutSection && layoutNeedChanges(node)) {
|
|
272
|
-
change = getLayoutChange(node, pos, state.schema);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return change;
|
|
276
|
-
};
|
|
277
|
-
export const fixColumnStructure = state => {
|
|
278
|
-
const {
|
|
279
|
-
pos,
|
|
280
|
-
selectedLayout
|
|
281
|
-
} = pluginKey.getState(state);
|
|
282
|
-
if (pos !== null && selectedLayout) {
|
|
283
|
-
const node = state.doc.nodeAt(pos);
|
|
284
|
-
if (node && node.childCount !== getWidthsForPreset(selectedLayout).length) {
|
|
285
|
-
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return;
|
|
289
|
-
};
|
|
290
|
-
export const deleteActiveLayoutNode = editorAnalyticsAPI => (state, dispatch) => {
|
|
291
|
-
const {
|
|
292
|
-
pos,
|
|
293
|
-
selectedLayout
|
|
294
|
-
} = pluginKey.getState(state);
|
|
295
|
-
if (pos !== null) {
|
|
296
|
-
const node = state.doc.nodeAt(pos);
|
|
297
|
-
if (dispatch) {
|
|
298
|
-
let tr = state.tr.delete(pos, pos + node.nodeSize);
|
|
299
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
300
|
-
action: ACTION.DELETED,
|
|
301
|
-
actionSubject: ACTION_SUBJECT.LAYOUT,
|
|
302
|
-
attributes: {
|
|
303
|
-
layout: formatLayoutName(selectedLayout)
|
|
304
|
-
},
|
|
305
|
-
eventType: EVENT_TYPE.TRACK
|
|
306
|
-
})(tr);
|
|
307
|
-
dispatch(tr);
|
|
308
|
-
}
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
return false;
|
|
312
|
-
};
|
|
313
|
-
const formatLayoutName = layout => {
|
|
314
|
-
switch (layout) {
|
|
315
|
-
case 'single':
|
|
316
|
-
return LAYOUT_TYPE.SINGLE_COL;
|
|
317
|
-
case 'two_equal':
|
|
318
|
-
return LAYOUT_TYPE.TWO_COLS_EQUAL;
|
|
319
|
-
case 'three_equal':
|
|
320
|
-
return LAYOUT_TYPE.THREE_COLS_EQUAL;
|
|
321
|
-
case 'two_left_sidebar':
|
|
322
|
-
return LAYOUT_TYPE.LEFT_SIDEBAR;
|
|
323
|
-
case 'two_right_sidebar':
|
|
324
|
-
return LAYOUT_TYPE.RIGHT_SIDEBAR;
|
|
325
|
-
case 'three_with_sidebars':
|
|
326
|
-
return LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
327
|
-
}
|
|
328
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { layoutColumn, layoutSection } from '@atlaskit/adf-schema';
|
|
3
|
-
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
4
|
-
import { buildToolbar } from './toolbar';
|
|
5
|
-
import { createDefaultLayoutSection, insertLayoutColumnsWithAnalytics } from './actions';
|
|
6
|
-
import { IconLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
|
-
export { pluginKey };
|
|
11
|
-
export const layoutPlugin = ({
|
|
12
|
-
config: options = {},
|
|
13
|
-
api
|
|
14
|
-
}) => {
|
|
15
|
-
var _api$analytics;
|
|
16
|
-
return {
|
|
17
|
-
name: 'layout',
|
|
18
|
-
nodes() {
|
|
19
|
-
return [{
|
|
20
|
-
name: 'layoutSection',
|
|
21
|
-
node: layoutSection
|
|
22
|
-
}, {
|
|
23
|
-
name: 'layoutColumn',
|
|
24
|
-
node: layoutColumn
|
|
25
|
-
}];
|
|
26
|
-
},
|
|
27
|
-
pmPlugins() {
|
|
28
|
-
return [{
|
|
29
|
-
name: 'layout',
|
|
30
|
-
plugin: () => createLayoutPlugin(options)
|
|
31
|
-
}];
|
|
32
|
-
},
|
|
33
|
-
actions: {
|
|
34
|
-
insertLayoutColumns: insertLayoutColumnsWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
35
|
-
},
|
|
36
|
-
pluginsOptions: {
|
|
37
|
-
floatingToolbar(state, intl) {
|
|
38
|
-
const {
|
|
39
|
-
pos,
|
|
40
|
-
allowBreakout,
|
|
41
|
-
addSidebarLayouts,
|
|
42
|
-
allowSingleColumnLayout
|
|
43
|
-
} = pluginKey.getState(state);
|
|
44
|
-
if (pos !== null) {
|
|
45
|
-
return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api);
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
},
|
|
49
|
-
quickInsert: ({
|
|
50
|
-
formatMessage
|
|
51
|
-
}) => [{
|
|
52
|
-
id: 'layout',
|
|
53
|
-
title: formatMessage(messages.columns),
|
|
54
|
-
description: formatMessage(messages.columnsDescription),
|
|
55
|
-
keywords: ['column', 'section'],
|
|
56
|
-
priority: 1100,
|
|
57
|
-
icon: () => /*#__PURE__*/React.createElement(IconLayout, null),
|
|
58
|
-
action(insert, state) {
|
|
59
|
-
var _api$analytics2, _api$analytics2$actio;
|
|
60
|
-
const tr = insert(createDefaultLayoutSection(state));
|
|
61
|
-
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.attachAnalyticsEvent({
|
|
62
|
-
action: ACTION.INSERTED,
|
|
63
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
64
|
-
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
|
|
65
|
-
attributes: {
|
|
66
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
67
|
-
},
|
|
68
|
-
eventType: EVENT_TYPE.TRACK
|
|
69
|
-
})(tr);
|
|
70
|
-
return tr;
|
|
71
|
-
}
|
|
72
|
-
}]
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|