@atlaskit/editor-core 189.0.1 → 189.0.4
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 +12 -0
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/cjs/plugins/placeholder-text/index.js +6 -240
- package/dist/cjs/plugins/placeholder-text/plugin.js +266 -0
- package/dist/cjs/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.js +1 -1
- package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +1 -1
- package/dist/es2019/plugins/placeholder-text/index.js +1 -224
- package/dist/es2019/plugins/placeholder-text/plugin.js +246 -0
- package/dist/es2019/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.js +1 -1
- package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +1 -1
- package/dist/esm/plugins/placeholder-text/index.js +1 -239
- package/dist/esm/plugins/placeholder-text/plugin.js +258 -0
- package/dist/esm/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.js +1 -1
- package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +1 -1
- package/dist/types/plugins/placeholder-text/index.d.ts +2 -16
- package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +1 -1
- package/dist/types/plugins/placeholder-text/plugin-key.d.ts +2 -2
- package/dist/types/plugins/placeholder-text/plugin.d.ts +7 -0
- package/dist/types/plugins/placeholder-text/types.d.ts +9 -1
- package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +2 -22
- package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +1 -1
- package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +2 -2
- package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +7 -0
- package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +12 -1
- package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/package.json +7 -3
- /package/dist/cjs/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.js +0 -0
- /package/dist/cjs/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.js +0 -0
- /package/dist/es2019/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.js +0 -0
- /package/dist/es2019/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.js +0 -0
- /package/dist/esm/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.js +0 -0
- /package/dist/esm/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.js +0 -0
- /package/dist/types/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.d.ts +0 -0
- /package/dist/types/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.d.ts +0 -0
- /package/dist/types/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.d.ts +0 -0
- /package/dist/types-ts4.5/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.d.ts +0 -0
- /package/dist/types-ts4.5/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.d.ts +0 -0
- /package/dist/types-ts4.5/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 189.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41991](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41991) [`28a7171e7e3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/28a7171e7e3) - [ux] add shift click select backward feature to expand selection
|
|
8
|
+
|
|
9
|
+
## 189.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#41773](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41773) [`2ad7c026f79`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2ad7c026f79) - ED-20478: partially decouples placeholdertext editor plugin for future package extraction, migrates associated failing integration tests to libra
|
|
14
|
+
|
|
3
15
|
## 189.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -182,7 +182,7 @@ Object.defineProperty(exports, "pastePlugin", {
|
|
|
182
182
|
Object.defineProperty(exports, "placeholderTextPlugin", {
|
|
183
183
|
enumerable: true,
|
|
184
184
|
get: function get() {
|
|
185
|
-
return _placeholderText.
|
|
185
|
+
return _placeholderText.placeholderTextPlugin;
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
Object.defineProperty(exports, "tasksAndDecisionsPlugin", {
|
|
@@ -228,7 +228,7 @@ var _macro = _interopRequireDefault(require("./macro"));
|
|
|
228
228
|
var _maxContentSize = _interopRequireDefault(require("./max-content-size"));
|
|
229
229
|
var _panel = _interopRequireDefault(require("./panel"));
|
|
230
230
|
var _paste = _interopRequireDefault(require("./paste"));
|
|
231
|
-
var _placeholderText =
|
|
231
|
+
var _placeholderText = require("./placeholder-text");
|
|
232
232
|
var _tasksAndDecisions = _interopRequireDefault(require("./tasks-and-decisions"));
|
|
233
233
|
var _textColor = _interopRequireDefault(require("./text-color"));
|
|
234
234
|
var _breakout = _interopRequireDefault(require("./breakout"));
|
|
@@ -4,244 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
|
-
var _text = _interopRequireDefault(require("@atlaskit/icon/glyph/media-services/text"));
|
|
14
|
-
var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
|
|
15
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
-
var _cursor = require("../fake-text-cursor/cursor");
|
|
17
|
-
var _PlaceholderFloatingToolbar = _interopRequireDefault(require("./ui/PlaceholderFloatingToolbar"));
|
|
18
|
-
var _actions = require("./actions");
|
|
19
|
-
var _placeholderTextNodeview = require("./placeholder-text-nodeview");
|
|
20
|
-
var _pluginKey = require("./plugin-key");
|
|
21
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
22
|
-
var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
|
|
23
|
-
var _selectionUtils = require("./selection-utils");
|
|
24
|
-
var getOpenTypeAhead = function getOpenTypeAhead(trigger, api) {
|
|
25
|
-
var _api$typeAhead, _api$typeAhead2;
|
|
26
|
-
var typeAheadHandler = api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.findHandlerByTrigger(trigger);
|
|
27
|
-
if (!typeAheadHandler || !typeAheadHandler.id) {
|
|
28
|
-
return null;
|
|
7
|
+
Object.defineProperty(exports, "placeholderTextPlugin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _plugin.default;
|
|
29
11
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
inputMethod: _analytics.INPUT_METHOD.KEYBOARD
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
function createPlugin(dispatch, options, api) {
|
|
36
|
-
var allowInserting = !!options.allowInserting;
|
|
37
|
-
return new _safePlugin.SafePlugin({
|
|
38
|
-
key: _pluginKey.pluginKey,
|
|
39
|
-
state: {
|
|
40
|
-
init: function init() {
|
|
41
|
-
return {
|
|
42
|
-
showInsertPanelAt: null,
|
|
43
|
-
allowInserting: allowInserting
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
apply: function apply(tr, state) {
|
|
47
|
-
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
48
|
-
if (meta && meta.showInsertPanelAt !== undefined) {
|
|
49
|
-
var newState = {
|
|
50
|
-
showInsertPanelAt: meta.showInsertPanelAt,
|
|
51
|
-
allowInserting: allowInserting
|
|
52
|
-
};
|
|
53
|
-
dispatch(_pluginKey.pluginKey, newState);
|
|
54
|
-
return newState;
|
|
55
|
-
} else if (state.showInsertPanelAt) {
|
|
56
|
-
var _newState = {
|
|
57
|
-
showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
|
|
58
|
-
allowInserting: allowInserting
|
|
59
|
-
};
|
|
60
|
-
dispatch(_pluginKey.pluginKey, _newState);
|
|
61
|
-
return _newState;
|
|
62
|
-
}
|
|
63
|
-
return state;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
67
|
-
if (transactions.some(function (txn) {
|
|
68
|
-
return txn.docChanged;
|
|
69
|
-
})) {
|
|
70
|
-
var didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
|
|
71
|
-
var adjacentNode = newState.selection.$head.nodeAfter;
|
|
72
|
-
var adjacentNodePos = newState.selection.$head.pos;
|
|
73
|
-
var placeholderNodeType = newState.schema.nodes.placeholder;
|
|
74
|
-
if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
|
|
75
|
-
var _$newHead$nodeBefore;
|
|
76
|
-
var $newHead = newState.selection.$head;
|
|
77
|
-
var $oldHead = oldState.selection.$head;
|
|
78
|
-
// Check that cursor has moved forward in the document **and** that there is content before the cursor
|
|
79
|
-
var cursorMoved = $oldHead.pos < $newHead.pos;
|
|
80
|
-
var nodeBeforeHasContent = !(0, _utils.isNodeEmpty)($newHead.nodeBefore);
|
|
81
|
-
var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
|
|
82
|
-
if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
|
|
83
|
-
var _NodeSelection$create = _state.NodeSelection.create(newState.doc, adjacentNodePos),
|
|
84
|
-
$from = _NodeSelection$create.$from,
|
|
85
|
-
$to = _NodeSelection$create.$to;
|
|
86
|
-
return newState.tr.deleteRange($from.pos, $to.pos);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Handle Fake Text Cursor for Floating Toolbar
|
|
92
|
-
if (!_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && _pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
|
|
93
|
-
return newState.tr.setSelection(new _cursor.FakeTextCursorSelection(newState.selection.$from));
|
|
94
|
-
}
|
|
95
|
-
if (_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && !_pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
|
|
96
|
-
if (newState.selection instanceof _cursor.FakeTextCursorSelection) {
|
|
97
|
-
return newState.tr.setSelection(new _state.TextSelection(newState.selection.$from));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return;
|
|
101
|
-
},
|
|
102
|
-
props: {
|
|
103
|
-
handleDOMEvents: {
|
|
104
|
-
beforeinput: function beforeinput(view, event) {
|
|
105
|
-
var state = view.state;
|
|
106
|
-
if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && (0, _selectionUtils.isSelectionAtPlaceholder)(view.state.selection)) {
|
|
107
|
-
event.stopPropagation();
|
|
108
|
-
event.preventDefault();
|
|
109
|
-
var startNodePosition = state.selection.from;
|
|
110
|
-
var content = event.data || '';
|
|
111
|
-
var tr = view.state.tr;
|
|
112
|
-
tr.delete(startNodePosition, startNodePosition + 1);
|
|
113
|
-
var openTypeAhead = getOpenTypeAhead(content, api);
|
|
114
|
-
if (openTypeAhead) {
|
|
115
|
-
openTypeAhead(tr);
|
|
116
|
-
} else {
|
|
117
|
-
tr.insertText(content);
|
|
118
|
-
}
|
|
119
|
-
view.dispatch(tr);
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
nodeViews: {
|
|
126
|
-
placeholder: function placeholder(node, view, getPos) {
|
|
127
|
-
return new _placeholderTextNodeview.PlaceholderTextNodeView(node, view, getPos);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref) {
|
|
134
|
-
var api = _ref.api,
|
|
135
|
-
options = _ref.config;
|
|
136
|
-
return {
|
|
137
|
-
name: 'placeholderText',
|
|
138
|
-
nodes: function nodes() {
|
|
139
|
-
return [{
|
|
140
|
-
name: 'placeholder',
|
|
141
|
-
node: _adfSchema.placeholder
|
|
142
|
-
}];
|
|
143
|
-
},
|
|
144
|
-
pmPlugins: function pmPlugins() {
|
|
145
|
-
return [{
|
|
146
|
-
name: 'placeholderText',
|
|
147
|
-
plugin: function plugin(_ref2) {
|
|
148
|
-
var dispatch = _ref2.dispatch;
|
|
149
|
-
return createPlugin(dispatch, options, api);
|
|
150
|
-
}
|
|
151
|
-
}];
|
|
152
|
-
},
|
|
153
|
-
contentComponent: function contentComponent(_ref3) {
|
|
154
|
-
var editorView = _ref3.editorView,
|
|
155
|
-
popupsMountPoint = _ref3.popupsMountPoint,
|
|
156
|
-
popupsBoundariesElement = _ref3.popupsBoundariesElement;
|
|
157
|
-
var insertPlaceholderText = function insertPlaceholderText(value) {
|
|
158
|
-
return (0, _actions.insertPlaceholderTextAtSelection)(value)(editorView.state, editorView.dispatch);
|
|
159
|
-
};
|
|
160
|
-
var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
|
|
161
|
-
return (0, _actions.hidePlaceholderFloatingToolbar)(editorView.state, editorView.dispatch);
|
|
162
|
-
};
|
|
163
|
-
var getNodeFromPos = function getNodeFromPos(pos) {
|
|
164
|
-
return editorView.domAtPos(pos).node;
|
|
165
|
-
};
|
|
166
|
-
var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
|
|
167
|
-
return editorView.coordsAtPos(pos);
|
|
168
|
-
};
|
|
169
|
-
var setFocusInEditor = function setFocusInEditor() {
|
|
170
|
-
return editorView.focus();
|
|
171
|
-
};
|
|
172
|
-
return /*#__PURE__*/_react.default.createElement(_WithPluginState.default, {
|
|
173
|
-
plugins: {
|
|
174
|
-
placeholderTextState: _pluginKey.pluginKey
|
|
175
|
-
},
|
|
176
|
-
render: function render(_ref4) {
|
|
177
|
-
var _ref4$placeholderText = _ref4.placeholderTextState,
|
|
178
|
-
placeholderTextState = _ref4$placeholderText === void 0 ? {} : _ref4$placeholderText;
|
|
179
|
-
if (placeholderTextState.showInsertPanelAt) {
|
|
180
|
-
return /*#__PURE__*/_react.default.createElement(_PlaceholderFloatingToolbar.default, {
|
|
181
|
-
editorViewDOM: editorView.dom,
|
|
182
|
-
popupsMountPoint: popupsMountPoint,
|
|
183
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
184
|
-
getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
|
|
185
|
-
getNodeFromPos: getNodeFromPos,
|
|
186
|
-
hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
|
|
187
|
-
showInsertPanelAt: placeholderTextState.showInsertPanelAt,
|
|
188
|
-
insertPlaceholder: insertPlaceholderText,
|
|
189
|
-
setFocusInEditor: setFocusInEditor
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
199
|
-
if (!options.allowInserting) {
|
|
200
|
-
return plugin;
|
|
201
|
-
}
|
|
202
|
-
plugin.pluginsOptions = {
|
|
203
|
-
quickInsert: function quickInsert(_ref5) {
|
|
204
|
-
var formatMessage = _ref5.formatMessage;
|
|
205
|
-
return [{
|
|
206
|
-
id: 'placeholderText',
|
|
207
|
-
title: formatMessage(_messages.messages.placeholderText),
|
|
208
|
-
description: formatMessage(_messages.messages.placeholderTextDescription),
|
|
209
|
-
priority: 1400,
|
|
210
|
-
keywords: ['placeholder'],
|
|
211
|
-
icon: function icon() {
|
|
212
|
-
return /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
213
|
-
label: ""
|
|
214
|
-
});
|
|
215
|
-
},
|
|
216
|
-
action: function action(insert, state) {
|
|
217
|
-
var _api$analytics;
|
|
218
|
-
var tr = state.tr;
|
|
219
|
-
tr.setMeta(_pluginKey.pluginKey, {
|
|
220
|
-
showInsertPanelAt: tr.selection.anchor
|
|
221
|
-
});
|
|
222
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
223
|
-
action: _analytics.ACTION.INSERTED,
|
|
224
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
225
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
|
|
226
|
-
attributes: {
|
|
227
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
228
|
-
},
|
|
229
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
230
|
-
})(tr);
|
|
231
|
-
return tr;
|
|
232
|
-
}
|
|
233
|
-
}];
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
return plugin;
|
|
237
|
-
};
|
|
238
|
-
var placeholderTextPlugin = function placeholderTextPlugin(_ref6) {
|
|
239
|
-
var _ref6$config = _ref6.config,
|
|
240
|
-
options = _ref6$config === void 0 ? {} : _ref6$config,
|
|
241
|
-
api = _ref6.api;
|
|
242
|
-
return decorateWithPluginOptions(basePlaceholderTextPlugin({
|
|
243
|
-
config: options,
|
|
244
|
-
api: api
|
|
245
|
-
}), options, api);
|
|
246
|
-
};
|
|
247
|
-
var _default = exports.default = placeholderTextPlugin;
|
|
12
|
+
});
|
|
13
|
+
var _plugin = _interopRequireDefault(require("./plugin"));
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createPlugin = createPlugin;
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
|
+
var _text = _interopRequireDefault(require("@atlaskit/icon/glyph/media-services/text"));
|
|
14
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
+
var _cursor = require("../fake-text-cursor/cursor");
|
|
17
|
+
var _PlaceholderFloatingToolbar = _interopRequireDefault(require("./ui/PlaceholderFloatingToolbar"));
|
|
18
|
+
var _actions = require("./actions");
|
|
19
|
+
var _placeholderTextNodeview = require("./placeholder-text-nodeview");
|
|
20
|
+
var _pluginKey = require("./plugin-key");
|
|
21
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
22
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
23
|
+
var _selectionUtils = require("./selection-utils");
|
|
24
|
+
var getOpenTypeAhead = function getOpenTypeAhead(trigger, api) {
|
|
25
|
+
var _api$typeAhead, _api$typeAhead2;
|
|
26
|
+
var typeAheadHandler = api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.findHandlerByTrigger(trigger);
|
|
27
|
+
if (!typeAheadHandler || !typeAheadHandler.id) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.openAtTransaction({
|
|
31
|
+
triggerHandler: typeAheadHandler,
|
|
32
|
+
inputMethod: _analytics.INPUT_METHOD.KEYBOARD
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
function createPlugin(dispatch, options, api) {
|
|
36
|
+
var allowInserting = !!options.allowInserting;
|
|
37
|
+
return new _safePlugin.SafePlugin({
|
|
38
|
+
key: _pluginKey.pluginKey,
|
|
39
|
+
state: {
|
|
40
|
+
init: function init() {
|
|
41
|
+
return {
|
|
42
|
+
showInsertPanelAt: null,
|
|
43
|
+
allowInserting: allowInserting
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
apply: function apply(tr, state) {
|
|
47
|
+
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
48
|
+
if (meta && meta.showInsertPanelAt !== undefined) {
|
|
49
|
+
var newState = {
|
|
50
|
+
showInsertPanelAt: meta.showInsertPanelAt,
|
|
51
|
+
allowInserting: allowInserting
|
|
52
|
+
};
|
|
53
|
+
dispatch(_pluginKey.pluginKey, newState);
|
|
54
|
+
return newState;
|
|
55
|
+
} else if (state.showInsertPanelAt) {
|
|
56
|
+
var _newState = {
|
|
57
|
+
showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
|
|
58
|
+
allowInserting: allowInserting
|
|
59
|
+
};
|
|
60
|
+
dispatch(_pluginKey.pluginKey, _newState);
|
|
61
|
+
return _newState;
|
|
62
|
+
}
|
|
63
|
+
return state;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
67
|
+
if (transactions.some(function (txn) {
|
|
68
|
+
return txn.docChanged;
|
|
69
|
+
})) {
|
|
70
|
+
var didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
|
|
71
|
+
var adjacentNode = newState.selection.$head.nodeAfter;
|
|
72
|
+
var adjacentNodePos = newState.selection.$head.pos;
|
|
73
|
+
var placeholderNodeType = newState.schema.nodes.placeholder;
|
|
74
|
+
if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
|
|
75
|
+
var _$newHead$nodeBefore;
|
|
76
|
+
var $newHead = newState.selection.$head;
|
|
77
|
+
var $oldHead = oldState.selection.$head;
|
|
78
|
+
// Check that cursor has moved forward in the document **and** that there is content before the cursor
|
|
79
|
+
var cursorMoved = $oldHead.pos < $newHead.pos;
|
|
80
|
+
var nodeBeforeHasContent = !(0, _utils.isNodeEmpty)($newHead.nodeBefore);
|
|
81
|
+
var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
|
|
82
|
+
if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
|
|
83
|
+
var _NodeSelection$create = _state.NodeSelection.create(newState.doc, adjacentNodePos),
|
|
84
|
+
$from = _NodeSelection$create.$from,
|
|
85
|
+
$to = _NodeSelection$create.$to;
|
|
86
|
+
return newState.tr.deleteRange($from.pos, $to.pos);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Handle Fake Text Cursor for Floating Toolbar
|
|
92
|
+
if (!_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && _pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
|
|
93
|
+
return newState.tr.setSelection(new _cursor.FakeTextCursorSelection(newState.selection.$from));
|
|
94
|
+
}
|
|
95
|
+
if (_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && !_pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
|
|
96
|
+
if (newState.selection instanceof _cursor.FakeTextCursorSelection) {
|
|
97
|
+
return newState.tr.setSelection(new _state.TextSelection(newState.selection.$from));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
},
|
|
102
|
+
props: {
|
|
103
|
+
handleDOMEvents: {
|
|
104
|
+
beforeinput: function beforeinput(view, event) {
|
|
105
|
+
var state = view.state;
|
|
106
|
+
if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && (0, _selectionUtils.isSelectionAtPlaceholder)(view.state.selection)) {
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
var startNodePosition = state.selection.from;
|
|
110
|
+
var content = event.data || '';
|
|
111
|
+
var tr = view.state.tr;
|
|
112
|
+
tr.delete(startNodePosition, startNodePosition + 1);
|
|
113
|
+
var openTypeAhead = getOpenTypeAhead(content, api);
|
|
114
|
+
if (openTypeAhead) {
|
|
115
|
+
openTypeAhead(tr);
|
|
116
|
+
} else {
|
|
117
|
+
tr.insertText(content);
|
|
118
|
+
}
|
|
119
|
+
view.dispatch(tr);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
nodeViews: {
|
|
126
|
+
placeholder: function placeholder(node, view, getPos) {
|
|
127
|
+
return new _placeholderTextNodeview.PlaceholderTextNodeView(node, view, getPos);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function ContentComponent(_ref) {
|
|
134
|
+
var editorView = _ref.editorView,
|
|
135
|
+
dependencyApi = _ref.dependencyApi,
|
|
136
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
137
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement;
|
|
138
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(dependencyApi, ['placeholderText']),
|
|
139
|
+
placeholderTextState = _useSharedPluginState.placeholderTextState;
|
|
140
|
+
var insertPlaceholderText = function insertPlaceholderText(value) {
|
|
141
|
+
return (0, _actions.insertPlaceholderTextAtSelection)(value)(editorView.state, editorView.dispatch);
|
|
142
|
+
};
|
|
143
|
+
var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
|
|
144
|
+
return (0, _actions.hidePlaceholderFloatingToolbar)(editorView.state, editorView.dispatch);
|
|
145
|
+
};
|
|
146
|
+
var getNodeFromPos = function getNodeFromPos(pos) {
|
|
147
|
+
return editorView.domAtPos(pos).node;
|
|
148
|
+
};
|
|
149
|
+
var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
|
|
150
|
+
return editorView.coordsAtPos(pos);
|
|
151
|
+
};
|
|
152
|
+
var setFocusInEditor = function setFocusInEditor() {
|
|
153
|
+
return editorView.focus();
|
|
154
|
+
};
|
|
155
|
+
if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
|
|
156
|
+
return /*#__PURE__*/_react.default.createElement(_PlaceholderFloatingToolbar.default, {
|
|
157
|
+
editorViewDOM: editorView.dom,
|
|
158
|
+
popupsMountPoint: popupsMountPoint,
|
|
159
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
160
|
+
getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
|
|
161
|
+
getNodeFromPos: getNodeFromPos,
|
|
162
|
+
hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
|
|
163
|
+
showInsertPanelAt: placeholderTextState.showInsertPanelAt,
|
|
164
|
+
insertPlaceholder: insertPlaceholderText,
|
|
165
|
+
setFocusInEditor: setFocusInEditor
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref2) {
|
|
171
|
+
var api = _ref2.api,
|
|
172
|
+
options = _ref2.config;
|
|
173
|
+
return {
|
|
174
|
+
name: 'placeholderText',
|
|
175
|
+
nodes: function nodes() {
|
|
176
|
+
return [{
|
|
177
|
+
name: 'placeholder',
|
|
178
|
+
node: _adfSchema.placeholder
|
|
179
|
+
}];
|
|
180
|
+
},
|
|
181
|
+
pmPlugins: function pmPlugins() {
|
|
182
|
+
return [{
|
|
183
|
+
name: 'placeholderText',
|
|
184
|
+
plugin: function plugin(_ref3) {
|
|
185
|
+
var dispatch = _ref3.dispatch;
|
|
186
|
+
return createPlugin(dispatch, options, api);
|
|
187
|
+
}
|
|
188
|
+
}];
|
|
189
|
+
},
|
|
190
|
+
getSharedState: function getSharedState(editorState) {
|
|
191
|
+
if (!editorState) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
var _ref4 = _pluginKey.pluginKey.getState(editorState) || {
|
|
195
|
+
showInsertPanelAt: null
|
|
196
|
+
},
|
|
197
|
+
showInsertPanelAt = _ref4.showInsertPanelAt,
|
|
198
|
+
allowInserting = _ref4.allowInserting;
|
|
199
|
+
return {
|
|
200
|
+
showInsertPanelAt: showInsertPanelAt,
|
|
201
|
+
allowInserting: !!allowInserting
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
contentComponent: function contentComponent(_ref5) {
|
|
205
|
+
var editorView = _ref5.editorView,
|
|
206
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
207
|
+
popupsBoundariesElement = _ref5.popupsBoundariesElement;
|
|
208
|
+
return /*#__PURE__*/_react.default.createElement(ContentComponent, {
|
|
209
|
+
editorView: editorView,
|
|
210
|
+
popupsMountPoint: popupsMountPoint,
|
|
211
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
212
|
+
dependencyApi: api
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
218
|
+
if (!options.allowInserting) {
|
|
219
|
+
return plugin;
|
|
220
|
+
}
|
|
221
|
+
plugin.pluginsOptions = {
|
|
222
|
+
quickInsert: function quickInsert(_ref6) {
|
|
223
|
+
var formatMessage = _ref6.formatMessage;
|
|
224
|
+
return [{
|
|
225
|
+
id: 'placeholderText',
|
|
226
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.placeholderText),
|
|
227
|
+
description: formatMessage(_messages.toolbarInsertBlockMessages.placeholderTextDescription),
|
|
228
|
+
priority: 1400,
|
|
229
|
+
keywords: ['placeholder'],
|
|
230
|
+
icon: function icon() {
|
|
231
|
+
return /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
232
|
+
label: ""
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
action: function action(insert, state) {
|
|
236
|
+
var _api$analytics;
|
|
237
|
+
var tr = state.tr;
|
|
238
|
+
tr.setMeta(_pluginKey.pluginKey, {
|
|
239
|
+
showInsertPanelAt: tr.selection.anchor
|
|
240
|
+
});
|
|
241
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
242
|
+
action: _analytics.ACTION.INSERTED,
|
|
243
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
244
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
|
|
245
|
+
attributes: {
|
|
246
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
247
|
+
},
|
|
248
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
249
|
+
})(tr);
|
|
250
|
+
return tr;
|
|
251
|
+
}
|
|
252
|
+
}];
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return plugin;
|
|
256
|
+
};
|
|
257
|
+
var placeholderTextPlugin = function placeholderTextPlugin(_ref7) {
|
|
258
|
+
var _ref7$config = _ref7.config,
|
|
259
|
+
options = _ref7$config === void 0 ? {} : _ref7$config,
|
|
260
|
+
api = _ref7.api;
|
|
261
|
+
return decorateWithPluginOptions(basePlaceholderTextPlugin({
|
|
262
|
+
config: options,
|
|
263
|
+
api: api
|
|
264
|
+
}), options, api);
|
|
265
|
+
};
|
|
266
|
+
var _default = exports.default = placeholderTextPlugin;
|
|
@@ -11,5 +11,5 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
11
11
|
var _colors = require("@atlaskit/theme/colors");
|
|
12
12
|
var _templateObject, _templateObject2;
|
|
13
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:
|
|
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
15
|
};
|
|
@@ -16,7 +16,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
17
|
var _reactIntlNext = require("react-intl-next");
|
|
18
18
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
|
-
var _FloatingToolbar = _interopRequireWildcard(require("
|
|
19
|
+
var _FloatingToolbar = _interopRequireWildcard(require("../FloatingToolbar"));
|
|
20
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
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
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); }; }
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
|
-
var version = exports.version = "189.0.
|
|
8
|
+
var version = exports.version = "189.0.4";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -11,7 +11,7 @@ export { default as macroPlugin } from './macro';
|
|
|
11
11
|
export { default as maxContentSizePlugin } from './max-content-size';
|
|
12
12
|
export { default as panelPlugin } from './panel';
|
|
13
13
|
export { default as pastePlugin } from './paste';
|
|
14
|
-
export {
|
|
14
|
+
export { placeholderTextPlugin } from './placeholder-text';
|
|
15
15
|
export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
|
|
16
16
|
export { default as textColorPlugin } from './text-color';
|
|
17
17
|
export { default as breakoutPlugin } from './breakout';
|