@atlaskit/editor-core 189.0.1 → 189.0.3

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/index.js +2 -2
  3. package/dist/cjs/plugins/placeholder-text/index.js +6 -240
  4. package/dist/cjs/plugins/placeholder-text/plugin.js +266 -0
  5. package/dist/cjs/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.js +1 -1
  6. package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +1 -1
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/plugins/index.js +1 -1
  9. package/dist/es2019/plugins/placeholder-text/index.js +1 -224
  10. package/dist/es2019/plugins/placeholder-text/plugin.js +246 -0
  11. package/dist/es2019/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.js +1 -1
  12. package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +1 -1
  13. package/dist/es2019/version-wrapper.js +1 -1
  14. package/dist/esm/plugins/index.js +1 -1
  15. package/dist/esm/plugins/placeholder-text/index.js +1 -239
  16. package/dist/esm/plugins/placeholder-text/plugin.js +258 -0
  17. package/dist/esm/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.js +1 -1
  18. package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +1 -1
  19. package/dist/esm/version-wrapper.js +1 -1
  20. package/dist/types/plugins/index.d.ts +1 -1
  21. package/dist/types/plugins/placeholder-text/index.d.ts +2 -16
  22. package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +1 -1
  23. package/dist/types/plugins/placeholder-text/plugin-key.d.ts +2 -2
  24. package/dist/types/plugins/placeholder-text/plugin.d.ts +7 -0
  25. package/dist/types/plugins/placeholder-text/types.d.ts +9 -1
  26. package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +2 -2
  27. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  28. package/dist/types-ts4.5/plugins/index.d.ts +1 -1
  29. package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +2 -22
  30. package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +1 -1
  31. package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +2 -2
  32. package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +7 -0
  33. package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +12 -1
  34. package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +2 -2
  35. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  36. package/package.json +2 -2
  37. /package/dist/cjs/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.js +0 -0
  38. /package/dist/cjs/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.js +0 -0
  39. /package/dist/es2019/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.js +0 -0
  40. /package/dist/es2019/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.js +0 -0
  41. /package/dist/esm/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.js +0 -0
  42. /package/dist/esm/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.js +0 -0
  43. /package/dist/types/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.d.ts +0 -0
  44. /package/dist/types/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.d.ts +0 -0
  45. /package/dist/types/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.d.ts +0 -0
  46. /package/dist/types-ts4.5/{ui → plugins/placeholder-text/ui}/FloatingToolbar/index.d.ts +0 -0
  47. /package/dist/types-ts4.5/{ui → plugins/placeholder-text/ui}/FloatingToolbar/styles.d.ts +0 -0
  48. /package/dist/types-ts4.5/{ui → plugins/placeholder-text/ui}/FloatingToolbar/utils.d.ts +0 -0
@@ -1,239 +1 @@
1
- import React from 'react';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
- import { placeholder } from '@atlaskit/adf-schema';
5
- import MediaServicesTextIcon from '@atlaskit/icon/glyph/media-services/text';
6
- import WithPluginState from '../../ui/WithPluginState';
7
- import { isNodeEmpty } from '@atlaskit/editor-common/utils';
8
- import { FakeTextCursorSelection } from '../fake-text-cursor/cursor';
9
- import PlaceholderFloatingToolbar from './ui/PlaceholderFloatingToolbar';
10
- import { hidePlaceholderFloatingToolbar, insertPlaceholderTextAtSelection } from './actions';
11
- import { PlaceholderTextNodeView } from './placeholder-text-nodeview';
12
- import { pluginKey } from './plugin-key';
13
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
14
- import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
15
- import { isSelectionAtPlaceholder } from './selection-utils';
16
- var getOpenTypeAhead = function getOpenTypeAhead(trigger, api) {
17
- var _api$typeAhead, _api$typeAhead2;
18
- 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);
19
- if (!typeAheadHandler || !typeAheadHandler.id) {
20
- return null;
21
- }
22
- 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({
23
- triggerHandler: typeAheadHandler,
24
- inputMethod: INPUT_METHOD.KEYBOARD
25
- });
26
- };
27
- export function createPlugin(dispatch, options, api) {
28
- var allowInserting = !!options.allowInserting;
29
- return new SafePlugin({
30
- key: pluginKey,
31
- state: {
32
- init: function init() {
33
- return {
34
- showInsertPanelAt: null,
35
- allowInserting: allowInserting
36
- };
37
- },
38
- apply: function apply(tr, state) {
39
- var meta = tr.getMeta(pluginKey);
40
- if (meta && meta.showInsertPanelAt !== undefined) {
41
- var newState = {
42
- showInsertPanelAt: meta.showInsertPanelAt,
43
- allowInserting: allowInserting
44
- };
45
- dispatch(pluginKey, newState);
46
- return newState;
47
- } else if (state.showInsertPanelAt) {
48
- var _newState = {
49
- showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
50
- allowInserting: allowInserting
51
- };
52
- dispatch(pluginKey, _newState);
53
- return _newState;
54
- }
55
- return state;
56
- }
57
- },
58
- appendTransaction: function appendTransaction(transactions, oldState, newState) {
59
- if (transactions.some(function (txn) {
60
- return txn.docChanged;
61
- })) {
62
- var didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
63
- var adjacentNode = newState.selection.$head.nodeAfter;
64
- var adjacentNodePos = newState.selection.$head.pos;
65
- var placeholderNodeType = newState.schema.nodes.placeholder;
66
- if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
67
- var _$newHead$nodeBefore;
68
- var $newHead = newState.selection.$head;
69
- var $oldHead = oldState.selection.$head;
70
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
71
- var cursorMoved = $oldHead.pos < $newHead.pos;
72
- var nodeBeforeHasContent = !isNodeEmpty($newHead.nodeBefore);
73
- var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
74
- if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
75
- var _NodeSelection$create = NodeSelection.create(newState.doc, adjacentNodePos),
76
- $from = _NodeSelection$create.$from,
77
- $to = _NodeSelection$create.$to;
78
- return newState.tr.deleteRange($from.pos, $to.pos);
79
- }
80
- }
81
- }
82
-
83
- // Handle Fake Text Cursor for Floating Toolbar
84
- if (!pluginKey.getState(oldState).showInsertPanelAt && pluginKey.getState(newState).showInsertPanelAt) {
85
- return newState.tr.setSelection(new FakeTextCursorSelection(newState.selection.$from));
86
- }
87
- if (pluginKey.getState(oldState).showInsertPanelAt && !pluginKey.getState(newState).showInsertPanelAt) {
88
- if (newState.selection instanceof FakeTextCursorSelection) {
89
- return newState.tr.setSelection(new TextSelection(newState.selection.$from));
90
- }
91
- }
92
- return;
93
- },
94
- props: {
95
- handleDOMEvents: {
96
- beforeinput: function beforeinput(view, event) {
97
- var state = view.state;
98
- if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && isSelectionAtPlaceholder(view.state.selection)) {
99
- event.stopPropagation();
100
- event.preventDefault();
101
- var startNodePosition = state.selection.from;
102
- var content = event.data || '';
103
- var tr = view.state.tr;
104
- tr.delete(startNodePosition, startNodePosition + 1);
105
- var openTypeAhead = getOpenTypeAhead(content, api);
106
- if (openTypeAhead) {
107
- openTypeAhead(tr);
108
- } else {
109
- tr.insertText(content);
110
- }
111
- view.dispatch(tr);
112
- return true;
113
- }
114
- return false;
115
- }
116
- },
117
- nodeViews: {
118
- placeholder: function placeholder(node, view, getPos) {
119
- return new PlaceholderTextNodeView(node, view, getPos);
120
- }
121
- }
122
- }
123
- });
124
- }
125
- var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref) {
126
- var api = _ref.api,
127
- options = _ref.config;
128
- return {
129
- name: 'placeholderText',
130
- nodes: function nodes() {
131
- return [{
132
- name: 'placeholder',
133
- node: placeholder
134
- }];
135
- },
136
- pmPlugins: function pmPlugins() {
137
- return [{
138
- name: 'placeholderText',
139
- plugin: function plugin(_ref2) {
140
- var dispatch = _ref2.dispatch;
141
- return createPlugin(dispatch, options, api);
142
- }
143
- }];
144
- },
145
- contentComponent: function contentComponent(_ref3) {
146
- var editorView = _ref3.editorView,
147
- popupsMountPoint = _ref3.popupsMountPoint,
148
- popupsBoundariesElement = _ref3.popupsBoundariesElement;
149
- var insertPlaceholderText = function insertPlaceholderText(value) {
150
- return insertPlaceholderTextAtSelection(value)(editorView.state, editorView.dispatch);
151
- };
152
- var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
153
- return hidePlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
154
- };
155
- var getNodeFromPos = function getNodeFromPos(pos) {
156
- return editorView.domAtPos(pos).node;
157
- };
158
- var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
159
- return editorView.coordsAtPos(pos);
160
- };
161
- var setFocusInEditor = function setFocusInEditor() {
162
- return editorView.focus();
163
- };
164
- return /*#__PURE__*/React.createElement(WithPluginState, {
165
- plugins: {
166
- placeholderTextState: pluginKey
167
- },
168
- render: function render(_ref4) {
169
- var _ref4$placeholderText = _ref4.placeholderTextState,
170
- placeholderTextState = _ref4$placeholderText === void 0 ? {} : _ref4$placeholderText;
171
- if (placeholderTextState.showInsertPanelAt) {
172
- return /*#__PURE__*/React.createElement(PlaceholderFloatingToolbar, {
173
- editorViewDOM: editorView.dom,
174
- popupsMountPoint: popupsMountPoint,
175
- popupsBoundariesElement: popupsBoundariesElement,
176
- getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
177
- getNodeFromPos: getNodeFromPos,
178
- hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
179
- showInsertPanelAt: placeholderTextState.showInsertPanelAt,
180
- insertPlaceholder: insertPlaceholderText,
181
- setFocusInEditor: setFocusInEditor
182
- });
183
- }
184
- return null;
185
- }
186
- });
187
- }
188
- };
189
- };
190
- var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
191
- if (!options.allowInserting) {
192
- return plugin;
193
- }
194
- plugin.pluginsOptions = {
195
- quickInsert: function quickInsert(_ref5) {
196
- var formatMessage = _ref5.formatMessage;
197
- return [{
198
- id: 'placeholderText',
199
- title: formatMessage(messages.placeholderText),
200
- description: formatMessage(messages.placeholderTextDescription),
201
- priority: 1400,
202
- keywords: ['placeholder'],
203
- icon: function icon() {
204
- return /*#__PURE__*/React.createElement(MediaServicesTextIcon, {
205
- label: ""
206
- });
207
- },
208
- action: function action(insert, state) {
209
- var _api$analytics;
210
- var tr = state.tr;
211
- tr.setMeta(pluginKey, {
212
- showInsertPanelAt: tr.selection.anchor
213
- });
214
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
215
- action: ACTION.INSERTED,
216
- actionSubject: ACTION_SUBJECT.DOCUMENT,
217
- actionSubjectId: ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
218
- attributes: {
219
- inputMethod: INPUT_METHOD.QUICK_INSERT
220
- },
221
- eventType: EVENT_TYPE.TRACK
222
- })(tr);
223
- return tr;
224
- }
225
- }];
226
- }
227
- };
228
- return plugin;
229
- };
230
- var placeholderTextPlugin = function placeholderTextPlugin(_ref6) {
231
- var _ref6$config = _ref6.config,
232
- options = _ref6$config === void 0 ? {} : _ref6$config,
233
- api = _ref6.api;
234
- return decorateWithPluginOptions(basePlaceholderTextPlugin({
235
- config: options,
236
- api: api
237
- }), options, api);
238
- };
239
- export default placeholderTextPlugin;
1
+ export { default as placeholderTextPlugin } from './plugin';
@@ -0,0 +1,258 @@
1
+ import React from 'react';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { placeholder } from '@atlaskit/adf-schema';
5
+ import MediaServicesTextIcon from '@atlaskit/icon/glyph/media-services/text';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { isNodeEmpty } from '@atlaskit/editor-common/utils';
8
+ import { FakeTextCursorSelection } from '../fake-text-cursor/cursor';
9
+ import PlaceholderFloatingToolbar from './ui/PlaceholderFloatingToolbar';
10
+ import { hidePlaceholderFloatingToolbar, insertPlaceholderTextAtSelection } from './actions';
11
+ import { PlaceholderTextNodeView } from './placeholder-text-nodeview';
12
+ import { pluginKey } from './plugin-key';
13
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
14
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
15
+ import { isSelectionAtPlaceholder } from './selection-utils';
16
+ var getOpenTypeAhead = function getOpenTypeAhead(trigger, api) {
17
+ var _api$typeAhead, _api$typeAhead2;
18
+ 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);
19
+ if (!typeAheadHandler || !typeAheadHandler.id) {
20
+ return null;
21
+ }
22
+ 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({
23
+ triggerHandler: typeAheadHandler,
24
+ inputMethod: INPUT_METHOD.KEYBOARD
25
+ });
26
+ };
27
+ export function createPlugin(dispatch, options, api) {
28
+ var allowInserting = !!options.allowInserting;
29
+ return new SafePlugin({
30
+ key: pluginKey,
31
+ state: {
32
+ init: function init() {
33
+ return {
34
+ showInsertPanelAt: null,
35
+ allowInserting: allowInserting
36
+ };
37
+ },
38
+ apply: function apply(tr, state) {
39
+ var meta = tr.getMeta(pluginKey);
40
+ if (meta && meta.showInsertPanelAt !== undefined) {
41
+ var newState = {
42
+ showInsertPanelAt: meta.showInsertPanelAt,
43
+ allowInserting: allowInserting
44
+ };
45
+ dispatch(pluginKey, newState);
46
+ return newState;
47
+ } else if (state.showInsertPanelAt) {
48
+ var _newState = {
49
+ showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
50
+ allowInserting: allowInserting
51
+ };
52
+ dispatch(pluginKey, _newState);
53
+ return _newState;
54
+ }
55
+ return state;
56
+ }
57
+ },
58
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
59
+ if (transactions.some(function (txn) {
60
+ return txn.docChanged;
61
+ })) {
62
+ var didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
63
+ var adjacentNode = newState.selection.$head.nodeAfter;
64
+ var adjacentNodePos = newState.selection.$head.pos;
65
+ var placeholderNodeType = newState.schema.nodes.placeholder;
66
+ if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
67
+ var _$newHead$nodeBefore;
68
+ var $newHead = newState.selection.$head;
69
+ var $oldHead = oldState.selection.$head;
70
+ // Check that cursor has moved forward in the document **and** that there is content before the cursor
71
+ var cursorMoved = $oldHead.pos < $newHead.pos;
72
+ var nodeBeforeHasContent = !isNodeEmpty($newHead.nodeBefore);
73
+ var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
74
+ if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
75
+ var _NodeSelection$create = NodeSelection.create(newState.doc, adjacentNodePos),
76
+ $from = _NodeSelection$create.$from,
77
+ $to = _NodeSelection$create.$to;
78
+ return newState.tr.deleteRange($from.pos, $to.pos);
79
+ }
80
+ }
81
+ }
82
+
83
+ // Handle Fake Text Cursor for Floating Toolbar
84
+ if (!pluginKey.getState(oldState).showInsertPanelAt && pluginKey.getState(newState).showInsertPanelAt) {
85
+ return newState.tr.setSelection(new FakeTextCursorSelection(newState.selection.$from));
86
+ }
87
+ if (pluginKey.getState(oldState).showInsertPanelAt && !pluginKey.getState(newState).showInsertPanelAt) {
88
+ if (newState.selection instanceof FakeTextCursorSelection) {
89
+ return newState.tr.setSelection(new TextSelection(newState.selection.$from));
90
+ }
91
+ }
92
+ return;
93
+ },
94
+ props: {
95
+ handleDOMEvents: {
96
+ beforeinput: function beforeinput(view, event) {
97
+ var state = view.state;
98
+ if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && isSelectionAtPlaceholder(view.state.selection)) {
99
+ event.stopPropagation();
100
+ event.preventDefault();
101
+ var startNodePosition = state.selection.from;
102
+ var content = event.data || '';
103
+ var tr = view.state.tr;
104
+ tr.delete(startNodePosition, startNodePosition + 1);
105
+ var openTypeAhead = getOpenTypeAhead(content, api);
106
+ if (openTypeAhead) {
107
+ openTypeAhead(tr);
108
+ } else {
109
+ tr.insertText(content);
110
+ }
111
+ view.dispatch(tr);
112
+ return true;
113
+ }
114
+ return false;
115
+ }
116
+ },
117
+ nodeViews: {
118
+ placeholder: function placeholder(node, view, getPos) {
119
+ return new PlaceholderTextNodeView(node, view, getPos);
120
+ }
121
+ }
122
+ }
123
+ });
124
+ }
125
+ function ContentComponent(_ref) {
126
+ var editorView = _ref.editorView,
127
+ dependencyApi = _ref.dependencyApi,
128
+ popupsMountPoint = _ref.popupsMountPoint,
129
+ popupsBoundariesElement = _ref.popupsBoundariesElement;
130
+ var _useSharedPluginState = useSharedPluginState(dependencyApi, ['placeholderText']),
131
+ placeholderTextState = _useSharedPluginState.placeholderTextState;
132
+ var insertPlaceholderText = function insertPlaceholderText(value) {
133
+ return insertPlaceholderTextAtSelection(value)(editorView.state, editorView.dispatch);
134
+ };
135
+ var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
136
+ return hidePlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
137
+ };
138
+ var getNodeFromPos = function getNodeFromPos(pos) {
139
+ return editorView.domAtPos(pos).node;
140
+ };
141
+ var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
142
+ return editorView.coordsAtPos(pos);
143
+ };
144
+ var setFocusInEditor = function setFocusInEditor() {
145
+ return editorView.focus();
146
+ };
147
+ if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
148
+ return /*#__PURE__*/React.createElement(PlaceholderFloatingToolbar, {
149
+ editorViewDOM: editorView.dom,
150
+ popupsMountPoint: popupsMountPoint,
151
+ popupsBoundariesElement: popupsBoundariesElement,
152
+ getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
153
+ getNodeFromPos: getNodeFromPos,
154
+ hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
155
+ showInsertPanelAt: placeholderTextState.showInsertPanelAt,
156
+ insertPlaceholder: insertPlaceholderText,
157
+ setFocusInEditor: setFocusInEditor
158
+ });
159
+ }
160
+ return null;
161
+ }
162
+ var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref2) {
163
+ var api = _ref2.api,
164
+ options = _ref2.config;
165
+ return {
166
+ name: 'placeholderText',
167
+ nodes: function nodes() {
168
+ return [{
169
+ name: 'placeholder',
170
+ node: placeholder
171
+ }];
172
+ },
173
+ pmPlugins: function pmPlugins() {
174
+ return [{
175
+ name: 'placeholderText',
176
+ plugin: function plugin(_ref3) {
177
+ var dispatch = _ref3.dispatch;
178
+ return createPlugin(dispatch, options, api);
179
+ }
180
+ }];
181
+ },
182
+ getSharedState: function getSharedState(editorState) {
183
+ if (!editorState) {
184
+ return undefined;
185
+ }
186
+ var _ref4 = pluginKey.getState(editorState) || {
187
+ showInsertPanelAt: null
188
+ },
189
+ showInsertPanelAt = _ref4.showInsertPanelAt,
190
+ allowInserting = _ref4.allowInserting;
191
+ return {
192
+ showInsertPanelAt: showInsertPanelAt,
193
+ allowInserting: !!allowInserting
194
+ };
195
+ },
196
+ contentComponent: function contentComponent(_ref5) {
197
+ var editorView = _ref5.editorView,
198
+ popupsMountPoint = _ref5.popupsMountPoint,
199
+ popupsBoundariesElement = _ref5.popupsBoundariesElement;
200
+ return /*#__PURE__*/React.createElement(ContentComponent, {
201
+ editorView: editorView,
202
+ popupsMountPoint: popupsMountPoint,
203
+ popupsBoundariesElement: popupsBoundariesElement,
204
+ dependencyApi: api
205
+ });
206
+ }
207
+ };
208
+ };
209
+ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
210
+ if (!options.allowInserting) {
211
+ return plugin;
212
+ }
213
+ plugin.pluginsOptions = {
214
+ quickInsert: function quickInsert(_ref6) {
215
+ var formatMessage = _ref6.formatMessage;
216
+ return [{
217
+ id: 'placeholderText',
218
+ title: formatMessage(messages.placeholderText),
219
+ description: formatMessage(messages.placeholderTextDescription),
220
+ priority: 1400,
221
+ keywords: ['placeholder'],
222
+ icon: function icon() {
223
+ return /*#__PURE__*/React.createElement(MediaServicesTextIcon, {
224
+ label: ""
225
+ });
226
+ },
227
+ action: function action(insert, state) {
228
+ var _api$analytics;
229
+ var tr = state.tr;
230
+ tr.setMeta(pluginKey, {
231
+ showInsertPanelAt: tr.selection.anchor
232
+ });
233
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
234
+ action: ACTION.INSERTED,
235
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
236
+ actionSubjectId: ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
237
+ attributes: {
238
+ inputMethod: INPUT_METHOD.QUICK_INSERT
239
+ },
240
+ eventType: EVENT_TYPE.TRACK
241
+ })(tr);
242
+ return tr;
243
+ }
244
+ }];
245
+ }
246
+ };
247
+ return plugin;
248
+ };
249
+ var placeholderTextPlugin = function placeholderTextPlugin(_ref7) {
250
+ var _ref7$config = _ref7.config,
251
+ options = _ref7$config === void 0 ? {} : _ref7$config,
252
+ api = _ref7.api;
253
+ return decorateWithPluginOptions(basePlaceholderTextPlugin({
254
+ config: options,
255
+ api: api
256
+ }), options, api);
257
+ };
258
+ export default placeholderTextPlugin;
@@ -4,5 +4,5 @@ import { css } from '@emotion/react';
4
4
  import { borderRadius } from '@atlaskit/theme/constants';
5
5
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
6
6
  export var container = function container(height) {
7
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-radius: ", "px;\n box-shadow: ", ";\n display: flex;\n align-items: center;\n box-sizing: border-box;\n padding: 4px 8px;\n background-color: ", ";\n ", ";\n"])), borderRadius(), "var(--ds-shadow-overlay, ".concat("0 12px 24px -6px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"), "var(--ds-background-input, ".concat(N0, ")"), height ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: ", "px;\n "])), height) : '');
7
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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"])), borderRadius(), "var(--ds-shadow-overlay, ".concat("0 12px 24px -6px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"), "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)", "var(--ds-background-input, ".concat(N0, ")"), height ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: ", "px;\n "])), height) : '');
8
8
  };
@@ -10,7 +10,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
10
10
  import React from 'react';
11
11
  import { defineMessages, injectIntl } from 'react-intl-next';
12
12
  import { PanelTextInput } from '@atlaskit/editor-common/ui';
13
- import FloatingToolbar, { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from '../../../../ui/FloatingToolbar';
13
+ import FloatingToolbar, { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from '../FloatingToolbar';
14
14
  export var messages = defineMessages({
15
15
  placeholderTextPlaceholder: {
16
16
  id: 'fabric.editor.placeholderTextPlaceholder',
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "189.0.1";
2
+ export var version = "189.0.3";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -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 { default as placeholderTextPlugin } from './placeholder-text';
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';
@@ -1,16 +1,2 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { ExtractInjectionAPI, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { Dispatch } from '../../event-dispatcher';
4
- import type { PlaceholderTextOptions, PluginState } from './types';
5
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
- import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
7
- export declare function createPlugin(dispatch: Dispatch<PluginState>, options: PlaceholderTextOptions, api: ExtractInjectionAPI<PlaceholderTextPlugin> | undefined): SafePlugin | undefined;
8
- type PlaceholderTextPlugin = NextEditorPlugin<'placeholderText', {
9
- dependencies: [OptionalPlugin<typeof analyticsPlugin>, TypeAheadPlugin];
10
- pluginConfiguration: PlaceholderTextOptions;
11
- }>;
12
- declare const placeholderTextPlugin: NextEditorPlugin<'placeholderText', {
13
- dependencies: [OptionalPlugin<typeof analyticsPlugin>, TypeAheadPlugin];
14
- pluginConfiguration: PlaceholderTextOptions;
15
- }>;
16
- export default placeholderTextPlugin;
1
+ export { default as placeholderTextPlugin } from './plugin';
2
+ export type { PlaceholderTextPlugin, PlaceholderTextPluginState, PlaceholderTextOptions, } from './types';
@@ -1,6 +1,6 @@
1
1
  import type { NodeView, EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { getPosHandler } from '../../nodeviews';
3
+ import type { getPosHandler } from '@atlaskit/editor-common/react-node-view';
4
4
  type PmMutationRecord = MutationRecord | {
5
5
  type: 'selection';
6
6
  target: Element;
@@ -1,3 +1,3 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- import type { PluginState } from './types';
3
- export declare const pluginKey: PluginKey<PluginState>;
2
+ import type { PlaceholderTextPluginState } from './types';
3
+ export declare const pluginKey: PluginKey<PlaceholderTextPluginState>;
@@ -0,0 +1,7 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
4
+ import type { PlaceholderTextOptions, PlaceholderTextPlugin, PlaceholderTextPluginState } from './types';
5
+ export declare function createPlugin(dispatch: Dispatch<PlaceholderTextPluginState>, options: PlaceholderTextOptions, api: ExtractInjectionAPI<PlaceholderTextPlugin> | undefined): SafePlugin | undefined;
6
+ declare const placeholderTextPlugin: PlaceholderTextPlugin;
7
+ export default placeholderTextPlugin;
@@ -1,7 +1,15 @@
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
3
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
1
4
  export interface PlaceholderTextOptions {
2
5
  allowInserting?: boolean;
3
6
  }
4
- export interface PluginState {
7
+ export interface PlaceholderTextPluginState {
5
8
  showInsertPanelAt: number | null;
6
9
  allowInserting: boolean;
7
10
  }
11
+ export type PlaceholderTextPlugin = NextEditorPlugin<'placeholderText', {
12
+ dependencies: [OptionalPlugin<typeof analyticsPlugin>, TypeAheadPlugin];
13
+ pluginConfiguration: PlaceholderTextOptions;
14
+ sharedState: PlaceholderTextPluginState | undefined;
15
+ }>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { WrappedComponentProps } from 'react-intl-next';
3
- import { Coordinates } from '../../../../ui/FloatingToolbar';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { Coordinates } from '../FloatingToolbar';
4
4
  export declare const messages: {
5
5
  placeholderTextPlaceholder: {
6
6
  id: string;
@@ -18,5 +18,5 @@ type Props = {
18
18
  isLoading?: boolean;
19
19
  featureFlags?: FeatureFlags;
20
20
  } & WithAnalyticsEventsProps;
21
- declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "key" | "autoSaveReject" | "onChange" | "isLoading" | "fields" | "parameters" | "onCancel" | "featureFlags" | "autoSave" | "analyticsContext" | "errorMessage" | "extensionManifest" | "autoSaveTrigger" | "showHeader" | "closeOnEsc"> & React.RefAttributes<any>>;
21
+ declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "key" | "autoSaveReject" | "onChange" | "isLoading" | "fields" | "parameters" | "featureFlags" | "onCancel" | "autoSave" | "analyticsContext" | "errorMessage" | "extensionManifest" | "autoSaveTrigger" | "showHeader" | "closeOnEsc"> & React.RefAttributes<any>>;
22
22
  export default _default;
@@ -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 { default as placeholderTextPlugin } from './placeholder-text';
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';
@@ -1,22 +1,2 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { ExtractInjectionAPI, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { Dispatch } from '../../event-dispatcher';
4
- import type { PlaceholderTextOptions, PluginState } from './types';
5
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
- import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
7
- export declare function createPlugin(dispatch: Dispatch<PluginState>, options: PlaceholderTextOptions, api: ExtractInjectionAPI<PlaceholderTextPlugin> | undefined): SafePlugin | undefined;
8
- type PlaceholderTextPlugin = NextEditorPlugin<'placeholderText', {
9
- dependencies: [
10
- OptionalPlugin<typeof analyticsPlugin>,
11
- TypeAheadPlugin
12
- ];
13
- pluginConfiguration: PlaceholderTextOptions;
14
- }>;
15
- declare const placeholderTextPlugin: NextEditorPlugin<'placeholderText', {
16
- dependencies: [
17
- OptionalPlugin<typeof analyticsPlugin>,
18
- TypeAheadPlugin
19
- ];
20
- pluginConfiguration: PlaceholderTextOptions;
21
- }>;
22
- export default placeholderTextPlugin;
1
+ export { default as placeholderTextPlugin } from './plugin';
2
+ export type { PlaceholderTextPlugin, PlaceholderTextPluginState, PlaceholderTextOptions, } from './types';
@@ -1,6 +1,6 @@
1
1
  import type { NodeView, EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { getPosHandler } from '../../nodeviews';
3
+ import type { getPosHandler } from '@atlaskit/editor-common/react-node-view';
4
4
  type PmMutationRecord = MutationRecord | {
5
5
  type: 'selection';
6
6
  target: Element;