@atlaskit/editor-core 187.41.7 → 187.42.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 +17 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/code-block/index.js +1 -1
- package/dist/cjs/plugins/help-dialog/ui/index.js +1 -1
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/insert-block/index.js +11 -11
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
- package/dist/cjs/plugins/panel/index.js +1 -1
- package/dist/cjs/ui/ContentStyles/index.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/index.js +0 -6
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/code-block/index.js +1 -1
- package/dist/es2019/plugins/help-dialog/ui/index.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +1 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
- package/dist/es2019/plugins/panel/index.js +1 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/code-block/index.js +1 -1
- package/dist/esm/plugins/help-dialog/ui/index.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +1 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
- package/dist/esm/plugins/panel/index.js +1 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/labs/next/presets/default.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -2
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +0 -7
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +7 -4
- package/report.api.md +1 -62
- package/tmp/api-report-tmp.d.ts +1 -51
- package/dist/cjs/plugins/block-type/commands/block-type.js +0 -202
- package/dist/cjs/plugins/block-type/commands/delete-and-move-cursor.js +0 -56
- package/dist/cjs/plugins/block-type/commands/delete-block-content.js +0 -45
- package/dist/cjs/plugins/block-type/commands/index.js +0 -68
- package/dist/cjs/plugins/block-type/consts.js +0 -15
- package/dist/cjs/plugins/block-type/index.js +0 -215
- package/dist/cjs/plugins/block-type/messages.js +0 -160
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +0 -104
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +0 -34
- package/dist/cjs/plugins/block-type/pm-plugins/main.js +0 -151
- package/dist/cjs/plugins/block-type/styles.js +0 -15
- package/dist/cjs/plugins/block-type/types.js +0 -115
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -54
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +0 -193
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -34
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -15
- package/dist/cjs/plugins/block-type/utils.js +0 -87
- package/dist/es2019/plugins/block-type/commands/block-type.js +0 -191
- package/dist/es2019/plugins/block-type/commands/delete-and-move-cursor.js +0 -54
- package/dist/es2019/plugins/block-type/commands/delete-block-content.js +0 -42
- package/dist/es2019/plugins/block-type/commands/index.js +0 -3
- package/dist/es2019/plugins/block-type/consts.js +0 -8
- package/dist/es2019/plugins/block-type/index.js +0 -201
- package/dist/es2019/plugins/block-type/messages.js +0 -153
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +0 -93
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +0 -25
- package/dist/es2019/plugins/block-type/pm-plugins/main.js +0 -137
- package/dist/es2019/plugins/block-type/styles.js +0 -8
- package/dist/es2019/plugins/block-type/types.js +0 -93
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -44
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +0 -170
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -49
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -8
- package/dist/es2019/plugins/block-type/utils.js +0 -76
- package/dist/esm/plugins/block-type/commands/block-type.js +0 -187
- package/dist/esm/plugins/block-type/commands/delete-and-move-cursor.js +0 -49
- package/dist/esm/plugins/block-type/commands/delete-block-content.js +0 -39
- package/dist/esm/plugins/block-type/commands/index.js +0 -3
- package/dist/esm/plugins/block-type/consts.js +0 -8
- package/dist/esm/plugins/block-type/index.js +0 -202
- package/dist/esm/plugins/block-type/messages.js +0 -153
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +0 -96
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +0 -25
- package/dist/esm/plugins/block-type/pm-plugins/main.js +0 -142
- package/dist/esm/plugins/block-type/styles.js +0 -7
- package/dist/esm/plugins/block-type/types.js +0 -93
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -44
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +0 -186
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -20
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -8
- package/dist/esm/plugins/block-type/utils.js +0 -77
- package/dist/types/plugins/block-type/commands/block-type.d.ts +0 -19
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +0 -12
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +0 -10
- package/dist/types/plugins/block-type/commands/index.d.ts +0 -4
- package/dist/types/plugins/block-type/consts.d.ts +0 -1
- package/dist/types/plugins/block-type/index.d.ts +0 -18
- package/dist/types/plugins/block-type/messages.d.ts +0 -152
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +0 -6
- package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +0 -5
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +0 -17
- package/dist/types/plugins/block-type/styles.d.ts +0 -2
- package/dist/types/plugins/block-type/types.d.ts +0 -40
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +0 -22
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +0 -29
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +0 -8
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
- package/dist/types/plugins/block-type/utils.d.ts +0 -16
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +0 -19
- package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +0 -12
- package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +0 -10
- package/dist/types-ts4.5/plugins/block-type/commands/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/block-type/consts.d.ts +0 -1
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +0 -20
- package/dist/types-ts4.5/plugins/block-type/messages.d.ts +0 -152
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +0 -6
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +0 -5
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +0 -17
- package/dist/types-ts4.5/plugins/block-type/styles.d.ts +0 -2
- package/dist/types-ts4.5/plugins/block-type/types.d.ts +0 -40
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +0 -22
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +0 -29
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +0 -8
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
- package/dist/types-ts4.5/plugins/block-type/utils.d.ts +0 -16
|
@@ -1,193 +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 _react = _interopRequireDefault(require("react"));
|
|
16
|
-
var _react2 = require("@emotion/react");
|
|
17
|
-
var _reactIntlNext = require("react-intl-next");
|
|
18
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
|
-
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
20
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
21
|
-
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
22
|
-
var _styled = require("./styled");
|
|
23
|
-
var _blocktypeButton = require("./blocktype-button");
|
|
24
|
-
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; }
|
|
25
|
-
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; }
|
|
26
|
-
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); }; }
|
|
27
|
-
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 */
|
|
28
|
-
var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
29
|
-
(0, _inherits2.default)(ToolbarBlockType, _React$PureComponent);
|
|
30
|
-
var _super = _createSuper(ToolbarBlockType);
|
|
31
|
-
function ToolbarBlockType() {
|
|
32
|
-
var _this;
|
|
33
|
-
(0, _classCallCheck2.default)(this, ToolbarBlockType);
|
|
34
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
|
-
args[_key] = arguments[_key];
|
|
36
|
-
}
|
|
37
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
38
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
39
|
-
active: false,
|
|
40
|
-
isOpenedByKeyboard: false
|
|
41
|
-
});
|
|
42
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onOpenChange", function (attrs) {
|
|
43
|
-
_this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
|
|
44
|
-
active: attrs.isOpen,
|
|
45
|
-
isOpenedByKeyboard: attrs.isOpenedByKeyboard
|
|
46
|
-
}));
|
|
47
|
-
});
|
|
48
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTriggerClick", function () {
|
|
49
|
-
_this.onOpenChange({
|
|
50
|
-
isOpen: !_this.state.active,
|
|
51
|
-
isOpenedByKeyboard: false
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTriggerByKeyboard", function (event) {
|
|
55
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
_this.onOpenChange({
|
|
58
|
-
isOpen: !_this.state.active,
|
|
59
|
-
isOpenedByKeyboard: true
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createItems", function () {
|
|
64
|
-
var formatMessage = _this.props.intl.formatMessage;
|
|
65
|
-
var _this$props$pluginSta = _this.props.pluginState,
|
|
66
|
-
currentBlockType = _this$props$pluginSta.currentBlockType,
|
|
67
|
-
availableBlockTypes = _this$props$pluginSta.availableBlockTypes;
|
|
68
|
-
var items = availableBlockTypes.map(function (blockType, index) {
|
|
69
|
-
var isActive = currentBlockType === blockType;
|
|
70
|
-
var tagName = blockType.tagName || 'p';
|
|
71
|
-
var Tag = tagName;
|
|
72
|
-
var keyMap = (0, _keymaps.findKeymapByDescription)(blockType.title.defaultMessage);
|
|
73
|
-
return {
|
|
74
|
-
content: (0, _react2.jsx)("div", {
|
|
75
|
-
css: (0, _styled.blockTypeMenuItemStyle)(tagName, isActive)
|
|
76
|
-
}, (0, _react2.jsx)(Tag, null, formatMessage(blockType.title))),
|
|
77
|
-
value: blockType,
|
|
78
|
-
label: formatMessage(blockType.title),
|
|
79
|
-
'aria-label': (0, _keymaps.tooltip)(keyMap, formatMessage(blockType.title)),
|
|
80
|
-
keyShortcuts: (0, _keymaps.getAriaKeyshortcuts)(keyMap),
|
|
81
|
-
key: "".concat(blockType.name, "-").concat(index),
|
|
82
|
-
elemAfter: (0, _react2.jsx)("div", {
|
|
83
|
-
css: [_styled.keyboardShortcut, isActive && _styled.keyboardShortcutSelect]
|
|
84
|
-
}, (0, _keymaps.tooltip)(keyMap)),
|
|
85
|
-
isActive: isActive
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
return [{
|
|
89
|
-
items: items
|
|
90
|
-
}];
|
|
91
|
-
});
|
|
92
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSelectBlockType", function (_ref) {
|
|
93
|
-
var item = _ref.item,
|
|
94
|
-
_ref$shouldCloseMenu = _ref.shouldCloseMenu,
|
|
95
|
-
shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
|
|
96
|
-
var blockType = item.value;
|
|
97
|
-
_this.props.setBlockType(blockType.name);
|
|
98
|
-
if (shouldCloseMenu) {
|
|
99
|
-
_this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
|
|
100
|
-
active: false
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
return _this;
|
|
105
|
-
}
|
|
106
|
-
(0, _createClass2.default)(ToolbarBlockType, [{
|
|
107
|
-
key: "render",
|
|
108
|
-
value: function render() {
|
|
109
|
-
var _this2 = this;
|
|
110
|
-
var _this$state = this.state,
|
|
111
|
-
active = _this$state.active,
|
|
112
|
-
isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
|
|
113
|
-
var _this$props = this.props,
|
|
114
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
115
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
116
|
-
popupsScrollableElement = _this$props.popupsScrollableElement,
|
|
117
|
-
isSmall = _this$props.isSmall,
|
|
118
|
-
isReducedSpacing = _this$props.isReducedSpacing,
|
|
119
|
-
_this$props$pluginSta2 = _this$props.pluginState,
|
|
120
|
-
currentBlockType = _this$props$pluginSta2.currentBlockType,
|
|
121
|
-
blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
|
|
122
|
-
availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
|
|
123
|
-
formatMessage = _this$props.intl.formatMessage;
|
|
124
|
-
var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
|
|
125
|
-
return blockType.nodeName === 'heading';
|
|
126
|
-
});
|
|
127
|
-
if (isHeadingDisabled) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
var blockTypeTitles = availableBlockTypes.filter(function (blockType) {
|
|
131
|
-
return blockType.name === currentBlockType.name;
|
|
132
|
-
}).map(function (blockType) {
|
|
133
|
-
return blockType.title;
|
|
134
|
-
});
|
|
135
|
-
if (!this.props.isDisabled && !blockTypesDisabled) {
|
|
136
|
-
var items = this.createItems();
|
|
137
|
-
return (0, _react2.jsx)("span", {
|
|
138
|
-
css: _styles.wrapperStyle
|
|
139
|
-
}, (0, _react2.jsx)(_uiMenu.DropdownMenuWithKeyboardNavigation, {
|
|
140
|
-
items: items,
|
|
141
|
-
onOpenChange: this.onOpenChange,
|
|
142
|
-
onItemActivated: this.handleSelectBlockType,
|
|
143
|
-
isOpen: active,
|
|
144
|
-
mountTo: popupsMountPoint,
|
|
145
|
-
boundariesElement: popupsBoundariesElement,
|
|
146
|
-
scrollableElement: popupsScrollableElement,
|
|
147
|
-
zIndex: _editorSharedStyles.akEditorMenuZIndex,
|
|
148
|
-
fitHeight: 360,
|
|
149
|
-
fitWidth: 106,
|
|
150
|
-
shouldUseDefaultRole: true,
|
|
151
|
-
shouldFocusFirstItem: function shouldFocusFirstItem() {
|
|
152
|
-
if (isOpenedByKeyboard) {
|
|
153
|
-
_this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {
|
|
154
|
-
isOpenedByKeyboard: false
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
return isOpenedByKeyboard;
|
|
158
|
-
}
|
|
159
|
-
}, (0, _react2.jsx)(_blocktypeButton.BlockTypeButton, {
|
|
160
|
-
isSmall: isSmall,
|
|
161
|
-
isReducedSpacing: isReducedSpacing,
|
|
162
|
-
selected: active,
|
|
163
|
-
disabled: false,
|
|
164
|
-
title: blockTypeTitles[0],
|
|
165
|
-
onClick: this.handleTriggerClick,
|
|
166
|
-
onKeyDown: this.handleTriggerByKeyboard,
|
|
167
|
-
formatMessage: formatMessage,
|
|
168
|
-
"aria-expanded": active
|
|
169
|
-
})), (0, _react2.jsx)("span", {
|
|
170
|
-
css: _styles.separatorStyles
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
return (0, _react2.jsx)("span", {
|
|
174
|
-
css: _styles.wrapperStyle
|
|
175
|
-
}, (0, _react2.jsx)(_blocktypeButton.BlockTypeButton, {
|
|
176
|
-
isSmall: isSmall,
|
|
177
|
-
isReducedSpacing: isReducedSpacing,
|
|
178
|
-
selected: active,
|
|
179
|
-
disabled: true,
|
|
180
|
-
title: blockTypeTitles[0],
|
|
181
|
-
onClick: this.handleTriggerClick,
|
|
182
|
-
onKeyDown: this.handleTriggerByKeyboard,
|
|
183
|
-
formatMessage: formatMessage,
|
|
184
|
-
"aria-expanded": active
|
|
185
|
-
}), (0, _react2.jsx)("span", {
|
|
186
|
-
css: _styles.separatorStyles
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
}]);
|
|
190
|
-
return ToolbarBlockType;
|
|
191
|
-
}(_react.default.PureComponent);
|
|
192
|
-
var _default = (0, _reactIntlNext.injectIntl)(ToolbarBlockType);
|
|
193
|
-
exports.default = _default;
|
|
@@ -1,34 +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.wrapperSmallStyle = exports.keyboardShortcutSelect = exports.keyboardShortcut = exports.expandIconWrapperStyle = exports.buttonContentStyle = exports.buttonContentReducedSpacingStyle = exports.blockTypeMenuItemStyle = 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 _styles = require("@atlaskit/editor-common/styles");
|
|
12
|
-
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
13
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
14
|
-
/** @jsx jsx */
|
|
15
|
-
var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, selected) {
|
|
16
|
-
// TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
|
|
17
|
-
var selectedStyle = selected ? "".concat(tagName, " { color: ", "var(--ds-text, white)", " !important; }") : '';
|
|
18
|
-
return function (themeProps) {
|
|
19
|
-
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n > {\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n }\n }\n ", ";\n "])), (0, _styles.headingsSharedStyles)(themeProps), selectedStyle);
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.blockTypeMenuItemStyle = blockTypeMenuItemStyle;
|
|
23
|
-
var keyboardShortcut = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n margin-left: ", ";\n"])), _shortcut.shortcutStyle, "var(--ds-space-200, 16px)");
|
|
24
|
-
exports.keyboardShortcut = keyboardShortcut;
|
|
25
|
-
var keyboardShortcutSelect = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(_colors.N400, ")"));
|
|
26
|
-
exports.keyboardShortcutSelect = keyboardShortcutSelect;
|
|
27
|
-
var buttonContentStyle = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n min-width: 80px;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n flex-direction: column;\n padding: ", ";\n"])), "var(--ds-space-075, 6px)");
|
|
28
|
-
exports.buttonContentStyle = buttonContentStyle;
|
|
29
|
-
var buttonContentReducedSpacingStyle = (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
30
|
-
exports.buttonContentReducedSpacingStyle = buttonContentReducedSpacingStyle;
|
|
31
|
-
var wrapperSmallStyle = (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: ", ";\n min-width: 40px;\n"])), "var(--ds-space-050, 4px)");
|
|
32
|
-
exports.wrapperSmallStyle = wrapperSmallStyle;
|
|
33
|
-
var expandIconWrapperStyle = (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: -8px;\n"])));
|
|
34
|
-
exports.expandIconWrapperStyle = expandIconWrapperStyle;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toolbarMessages = void 0;
|
|
7
|
-
var _reactIntlNext = require("react-intl-next");
|
|
8
|
-
var toolbarMessages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
-
textStyles: {
|
|
10
|
-
id: 'fabric.editor.textStyles',
|
|
11
|
-
defaultMessage: 'Text styles',
|
|
12
|
-
description: 'Menu provides access to various heading styles or normal text'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
exports.toolbarMessages = toolbarMessages;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.areBlockTypesDisabled = areBlockTypesDisabled;
|
|
7
|
-
exports.isNodeAWrappingBlockNode = exports.createWrappingTextBlockRule = exports.createJoinNodesRule = void 0;
|
|
8
|
-
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
9
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
|
-
var _types = require("./types");
|
|
11
|
-
var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
12
|
-
if (!node) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return _types.WRAPPER_BLOCK_TYPES.some(function (blockNode) {
|
|
16
|
-
return blockNode.name === node.type.name;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
exports.isNodeAWrappingBlockNode = isNodeAWrappingBlockNode;
|
|
20
|
-
var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
21
|
-
return (0, _utils.createWrappingJoinRule)({
|
|
22
|
-
nodeType: nodeType,
|
|
23
|
-
match: match,
|
|
24
|
-
getAttrs: {},
|
|
25
|
-
joinPredicate: function joinPredicate(_, node) {
|
|
26
|
-
return node.type === nodeType;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
exports.createJoinNodesRule = createJoinNodesRule;
|
|
31
|
-
var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
32
|
-
var match = _ref.match,
|
|
33
|
-
nodeType = _ref.nodeType,
|
|
34
|
-
getAttrs = _ref.getAttrs;
|
|
35
|
-
var handler = function handler(state, match, start, end) {
|
|
36
|
-
var fixedStart = Math.max(start, 1);
|
|
37
|
-
var $start = state.doc.resolve(fixedStart);
|
|
38
|
-
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
39
|
-
var nodeBefore = $start.node(-1);
|
|
40
|
-
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
44
|
-
};
|
|
45
|
-
return (0, _prosemirrorInputRules.createRule)(match, handler);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Function will create a list of wrapper blocks present in a selection.
|
|
50
|
-
*/
|
|
51
|
-
exports.createWrappingTextBlockRule = createWrappingTextBlockRule;
|
|
52
|
-
function getSelectedWrapperNodes(state) {
|
|
53
|
-
var nodes = [];
|
|
54
|
-
if (state.selection) {
|
|
55
|
-
var _state$selection = state.selection,
|
|
56
|
-
$from = _state$selection.$from,
|
|
57
|
-
$to = _state$selection.$to;
|
|
58
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
59
|
-
blockquote = _state$schema$nodes.blockquote,
|
|
60
|
-
panel = _state$schema$nodes.panel,
|
|
61
|
-
orderedList = _state$schema$nodes.orderedList,
|
|
62
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
63
|
-
listItem = _state$schema$nodes.listItem,
|
|
64
|
-
codeBlock = _state$schema$nodes.codeBlock,
|
|
65
|
-
decisionItem = _state$schema$nodes.decisionItem,
|
|
66
|
-
decisionList = _state$schema$nodes.decisionList,
|
|
67
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
68
|
-
taskList = _state$schema$nodes.taskList;
|
|
69
|
-
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
70
|
-
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
71
|
-
nodes.push(node.type);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return nodes;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
80
|
-
*/
|
|
81
|
-
function areBlockTypesDisabled(state) {
|
|
82
|
-
var nodesTypes = getSelectedWrapperNodes(state);
|
|
83
|
-
var panel = state.schema.nodes.panel;
|
|
84
|
-
return nodesTypes.filter(function (type) {
|
|
85
|
-
return type !== panel;
|
|
86
|
-
}).length > 0;
|
|
87
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
|
-
import { filterChildrenBetween, wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { HEADINGS_BY_NAME, NORMAL_TEXT } from '../types';
|
|
6
|
-
export function setBlockType(name) {
|
|
7
|
-
return (state, dispatch) => {
|
|
8
|
-
const {
|
|
9
|
-
nodes
|
|
10
|
-
} = state.schema;
|
|
11
|
-
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
12
|
-
return setNormalText()(state, dispatch);
|
|
13
|
-
}
|
|
14
|
-
const headingBlockType = HEADINGS_BY_NAME[name];
|
|
15
|
-
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
16
|
-
return setHeading(headingBlockType.level)(state, dispatch);
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
22
|
-
return (state, dispatch) => {
|
|
23
|
-
const {
|
|
24
|
-
nodes
|
|
25
|
-
} = state.schema;
|
|
26
|
-
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
27
|
-
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
28
|
-
}
|
|
29
|
-
const headingBlockType = HEADINGS_BY_NAME[name];
|
|
30
|
-
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
31
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function setNormalText() {
|
|
37
|
-
return function (state, dispatch) {
|
|
38
|
-
const {
|
|
39
|
-
selection,
|
|
40
|
-
schema,
|
|
41
|
-
tr
|
|
42
|
-
} = state;
|
|
43
|
-
const ranges = selection instanceof CellSelection ? selection.ranges : [selection];
|
|
44
|
-
ranges.forEach(({
|
|
45
|
-
$from,
|
|
46
|
-
$to
|
|
47
|
-
}) => {
|
|
48
|
-
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
49
|
-
});
|
|
50
|
-
if (dispatch) {
|
|
51
|
-
dispatch(tr);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function withCurrentHeadingLevel(fn) {
|
|
57
|
-
return (state, dispatch, view) => {
|
|
58
|
-
// Find all headings and paragraphs of text
|
|
59
|
-
const {
|
|
60
|
-
heading,
|
|
61
|
-
paragraph
|
|
62
|
-
} = state.schema.nodes;
|
|
63
|
-
const nodes = filterChildrenBetween(state.doc, state.selection.from, state.selection.to, node => {
|
|
64
|
-
return node.type === heading || node.type === paragraph;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Check each paragraph and/or heading and check for consistent level
|
|
68
|
-
let level;
|
|
69
|
-
for (let node of nodes) {
|
|
70
|
-
const nodeLevel = node.node.type === heading ? node.node.attrs.level : 0;
|
|
71
|
-
if (!level) {
|
|
72
|
-
level = nodeLevel;
|
|
73
|
-
} else if (nodeLevel !== level) {
|
|
74
|
-
// Conflict in level, therefore inconsistent and undefined
|
|
75
|
-
level = undefined;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return fn(level)(state, dispatch, view);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
83
|
-
return withCurrentHeadingLevel(previousHeadingLevel => withAnalytics(editorAnalyticsApi, {
|
|
84
|
-
action: ACTION.FORMATTED,
|
|
85
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
86
|
-
eventType: EVENT_TYPE.TRACK,
|
|
87
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
88
|
-
attributes: {
|
|
89
|
-
inputMethod,
|
|
90
|
-
newHeadingLevel: 0,
|
|
91
|
-
previousHeadingLevel
|
|
92
|
-
}
|
|
93
|
-
})(setNormalText()));
|
|
94
|
-
}
|
|
95
|
-
export function setHeading(level) {
|
|
96
|
-
return function (state, dispatch) {
|
|
97
|
-
const {
|
|
98
|
-
selection,
|
|
99
|
-
schema,
|
|
100
|
-
tr
|
|
101
|
-
} = state;
|
|
102
|
-
const ranges = selection instanceof CellSelection ? selection.ranges : [selection];
|
|
103
|
-
ranges.forEach(({
|
|
104
|
-
$from,
|
|
105
|
-
$to
|
|
106
|
-
}) => {
|
|
107
|
-
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
108
|
-
level
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
if (dispatch) {
|
|
112
|
-
dispatch(tr);
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
export const setHeadingWithAnalytics = (newHeadingLevel, inputMethod, editorAnalyticsApi) => {
|
|
118
|
-
return withCurrentHeadingLevel(previousHeadingLevel => withAnalytics(editorAnalyticsApi, {
|
|
119
|
-
action: ACTION.FORMATTED,
|
|
120
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
121
|
-
eventType: EVENT_TYPE.TRACK,
|
|
122
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
123
|
-
attributes: {
|
|
124
|
-
inputMethod,
|
|
125
|
-
newHeadingLevel,
|
|
126
|
-
previousHeadingLevel
|
|
127
|
-
}
|
|
128
|
-
})(setHeading(newHeadingLevel)));
|
|
129
|
-
};
|
|
130
|
-
function insertBlockQuote() {
|
|
131
|
-
return function (state, dispatch) {
|
|
132
|
-
const {
|
|
133
|
-
nodes
|
|
134
|
-
} = state.schema;
|
|
135
|
-
if (nodes.paragraph && nodes.blockquote) {
|
|
136
|
-
return wrapSelectionIn(nodes.blockquote)(state, dispatch);
|
|
137
|
-
}
|
|
138
|
-
return false;
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
* @param name - block type name
|
|
145
|
-
* @param inputMethod - input method
|
|
146
|
-
* @param editorAnalyticsApi - analytics api, undefined if not available either because it failed to load or wasn't added
|
|
147
|
-
* otherwise Editor becomes very sad and crashes
|
|
148
|
-
* @returns - command that inserts block type
|
|
149
|
-
*/
|
|
150
|
-
export const insertBlockQuoteWithAnalytics = (inputMethod, editorAnalyticsApi) => {
|
|
151
|
-
return withAnalytics(editorAnalyticsApi, {
|
|
152
|
-
action: ACTION.FORMATTED,
|
|
153
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
154
|
-
eventType: EVENT_TYPE.TRACK,
|
|
155
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
|
|
156
|
-
attributes: {
|
|
157
|
-
inputMethod: inputMethod
|
|
158
|
-
}
|
|
159
|
-
})(insertBlockQuote());
|
|
160
|
-
};
|
|
161
|
-
export const cleanUpAtTheStartOfDocument = (state, dispatch) => {
|
|
162
|
-
const {
|
|
163
|
-
$cursor
|
|
164
|
-
} = state.selection;
|
|
165
|
-
if ($cursor && !$cursor.nodeBefore && !$cursor.nodeAfter && $cursor.pos === 1) {
|
|
166
|
-
const {
|
|
167
|
-
tr,
|
|
168
|
-
schema
|
|
169
|
-
} = state;
|
|
170
|
-
const {
|
|
171
|
-
paragraph
|
|
172
|
-
} = schema.nodes;
|
|
173
|
-
const {
|
|
174
|
-
parent
|
|
175
|
-
} = $cursor;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Use cases:
|
|
179
|
-
* 1. Change `heading` to `paragraph`
|
|
180
|
-
* 2. Remove block marks
|
|
181
|
-
*
|
|
182
|
-
* NOTE: We already know it's an empty doc so it's safe to use 0
|
|
183
|
-
*/
|
|
184
|
-
tr.setNodeMarkup(0, paragraph, parent.attrs, []);
|
|
185
|
-
if (dispatch) {
|
|
186
|
-
dispatch(tr);
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
// We should override default behaviour when selection spans node depths or
|
|
3
|
-
// ends at a node junction
|
|
4
|
-
const shouldMoveCursorAfterDelete = state => {
|
|
5
|
-
const {
|
|
6
|
-
selection: {
|
|
7
|
-
$from,
|
|
8
|
-
$to
|
|
9
|
-
}
|
|
10
|
-
} = state;
|
|
11
|
-
const nodeRange = $from.blockRange($to);
|
|
12
|
-
if (!nodeRange) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const hasSameAncestor = $from.depth === $to.depth && $from.depth - 1 === nodeRange.depth;
|
|
16
|
-
const toPositionHasNodeAfter = !!$to.nodeAfter;
|
|
17
|
-
if (hasSameAncestor || toPositionHasNodeAfter) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Fixes cursor position after delete for list/task in panel and table
|
|
25
|
-
*
|
|
26
|
-
* ED-13873 fixes a bug where after deleting a list the cursor would move
|
|
27
|
-
* to the cell to the right. Uses setSelection to position the cursor as expected after deleting.
|
|
28
|
-
*
|
|
29
|
-
* @param state EditorState
|
|
30
|
-
* @param dispatch CommandDispatch
|
|
31
|
-
* @returns boolean
|
|
32
|
-
*/
|
|
33
|
-
export const deleteAndMoveCursor = (state, dispatch) => {
|
|
34
|
-
if (state.selection.empty || !(state.selection instanceof TextSelection)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
if (!shouldMoveCursorAfterDelete(state)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const {
|
|
41
|
-
tr
|
|
42
|
-
} = state;
|
|
43
|
-
tr.deleteSelection();
|
|
44
|
-
|
|
45
|
-
// Make sure the next position is not out of boundaries
|
|
46
|
-
const previousPosition = Math.min(Math.max(state.selection.$from.pos, 0), tr.doc.content.size);
|
|
47
|
-
// Override default delete behaviour that moves the cursor to first suitable position after selection (postive bias).
|
|
48
|
-
// See. selectionToInsertionEnd. We will override behavior with negative bias (search for suitable cursor position backwards).
|
|
49
|
-
tr.setSelection(Selection.near(tr.doc.resolve(previousPosition), -1));
|
|
50
|
-
if (dispatch) {
|
|
51
|
-
dispatch(tr.scrollIntoView());
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prevent removing the block when deleting block content
|
|
3
|
-
*
|
|
4
|
-
* @param state EditorState
|
|
5
|
-
* @param dispatch CommandDispatch
|
|
6
|
-
* @returns boolean
|
|
7
|
-
*/
|
|
8
|
-
export function deleteBlockContent(isNodeAWrappingBlockNode) {
|
|
9
|
-
return (state, dispatch) => {
|
|
10
|
-
const {
|
|
11
|
-
tr,
|
|
12
|
-
selection: {
|
|
13
|
-
$from,
|
|
14
|
-
$to
|
|
15
|
-
},
|
|
16
|
-
doc
|
|
17
|
-
} = state;
|
|
18
|
-
if ($from.pos === $to.pos) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
let selectionCrossesWrappingBlockNode = false;
|
|
22
|
-
doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
23
|
-
// Optimisation. If selection crosses wrapping block node
|
|
24
|
-
// short circuit the loop by returning false
|
|
25
|
-
if (selectionCrossesWrappingBlockNode) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if (isNodeAWrappingBlockNode(node)) {
|
|
29
|
-
selectionCrossesWrappingBlockNode = true;
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
if (!selectionCrossesWrappingBlockNode) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
tr.delete($from.pos, $to.pos);
|
|
37
|
-
if (dispatch) {
|
|
38
|
-
dispatch(tr);
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { cleanUpAtTheStartOfDocument, insertBlockQuoteWithAnalytics, setBlockType, setBlockTypeWithAnalytics, setHeading, setHeadingWithAnalytics, setNormalText, setNormalTextWithAnalytics } from './block-type';
|
|
2
|
-
export { deleteAndMoveCursor } from './delete-and-move-cursor';
|
|
3
|
-
export { deleteBlockContent } from './delete-block-content';
|