@atlaskit/editor-core 189.1.11 → 189.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/plugins/index.js +0 -14
  3. package/dist/cjs/plugins/insert-block/index.js +6 -10
  4. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
  5. package/dist/cjs/presets/universal.js +4 -2
  6. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/plugins/index.js +0 -2
  9. package/dist/es2019/plugins/insert-block/index.js +5 -9
  10. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  11. package/dist/es2019/presets/universal.js +3 -1
  12. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  13. package/dist/es2019/version-wrapper.js +1 -1
  14. package/dist/esm/plugins/index.js +0 -2
  15. package/dist/esm/plugins/insert-block/index.js +5 -9
  16. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
  17. package/dist/esm/presets/universal.js +3 -1
  18. package/dist/esm/ui/ContentStyles/index.js +1 -1
  19. package/dist/esm/version-wrapper.js +1 -1
  20. package/dist/types/plugins/index.d.ts +0 -2
  21. package/dist/types/plugins/insert-block/types.d.ts +4 -2
  22. package/dist/types/types/editor-props.d.ts +2 -2
  23. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  24. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  25. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
  26. package/dist/types-ts4.5/types/editor-props.d.ts +2 -2
  27. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  28. package/package.json +4 -2
  29. package/report.api.md +2 -16
  30. package/tmp/api-report-tmp.d.ts +2 -16
  31. package/dist/cjs/plugins/layout/actions.js +0 -345
  32. package/dist/cjs/plugins/layout/index.js +0 -91
  33. package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
  34. package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
  35. package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
  36. package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
  37. package/dist/cjs/plugins/layout/toolbar.js +0 -116
  38. package/dist/cjs/plugins/layout/types.js +0 -5
  39. package/dist/cjs/plugins/placeholder-text/actions.js +0 -35
  40. package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
  41. package/dist/cjs/plugins/placeholder-text/index.js +0 -20
  42. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
  43. package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
  44. package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
  45. package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
  46. package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
  47. package/dist/cjs/plugins/placeholder-text/types.js +0 -5
  48. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
  49. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
  50. package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
  51. package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
  52. package/dist/es2019/plugins/layout/actions.js +0 -328
  53. package/dist/es2019/plugins/layout/index.js +0 -75
  54. package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
  55. package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
  56. package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
  57. package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
  58. package/dist/es2019/plugins/layout/toolbar.js +0 -101
  59. package/dist/es2019/plugins/layout/types.js +0 -1
  60. package/dist/es2019/plugins/placeholder-text/actions.js +0 -27
  61. package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
  62. package/dist/es2019/plugins/placeholder-text/index.js +0 -2
  63. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
  64. package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
  65. package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
  66. package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
  67. package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
  68. package/dist/es2019/plugins/placeholder-text/types.js +0 -1
  69. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
  70. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
  71. package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
  72. package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
  73. package/dist/esm/plugins/layout/actions.js +0 -336
  74. package/dist/esm/plugins/layout/index.js +0 -79
  75. package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
  76. package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
  77. package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
  78. package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
  79. package/dist/esm/plugins/layout/toolbar.js +0 -109
  80. package/dist/esm/plugins/layout/types.js +0 -1
  81. package/dist/esm/plugins/placeholder-text/actions.js +0 -29
  82. package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
  83. package/dist/esm/plugins/placeholder-text/index.js +0 -2
  84. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
  85. package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
  86. package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
  87. package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
  88. package/dist/esm/plugins/placeholder-text/styles.js +0 -6
  89. package/dist/esm/plugins/placeholder-text/types.js +0 -1
  90. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
  91. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
  92. package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
  93. package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
  94. package/dist/types/plugins/layout/actions.d.ts +0 -22
  95. package/dist/types/plugins/layout/index.d.ts +0 -15
  96. package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
  97. package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
  98. package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
  99. package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
  100. package/dist/types/plugins/layout/toolbar.d.ts +0 -6
  101. package/dist/types/plugins/layout/types.d.ts +0 -13
  102. package/dist/types/plugins/placeholder-text/actions.d.ts +0 -4
  103. package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
  104. package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
  105. package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
  106. package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
  107. package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
  108. package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
  109. package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
  110. package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
  111. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
  112. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
  113. package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
  114. package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
  115. package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
  116. package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
  117. package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
  118. package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
  119. package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
  120. package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
  121. package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
  122. package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
  123. package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
  124. package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
  125. package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
  126. package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
  127. package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
  128. package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
  129. package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
  130. package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
  131. package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
  132. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
  133. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
  134. package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
  135. package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
@@ -1,247 +0,0 @@
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 { drawFakeTextCursor, 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
- const getOpenTypeAhead = (trigger, api) => {
17
- var _api$typeAhead, _api$typeAhead$action, _api$typeAhead2, _api$typeAhead2$actio;
18
- const typeAheadHandler = api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : (_api$typeAhead$action = _api$typeAhead.actions) === null || _api$typeAhead$action === void 0 ? void 0 : _api$typeAhead$action.findHandlerByTrigger(trigger);
19
- if (!typeAheadHandler || !typeAheadHandler.id) {
20
- return null;
21
- }
22
- return api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : _api$typeAhead2$actio.openAtTransaction({
23
- triggerHandler: typeAheadHandler,
24
- inputMethod: INPUT_METHOD.KEYBOARD
25
- });
26
- };
27
- export function createPlugin(dispatch, options, api) {
28
- const allowInserting = !!options.allowInserting;
29
- return new SafePlugin({
30
- key: pluginKey,
31
- state: {
32
- init: () => ({
33
- showInsertPanelAt: null,
34
- allowInserting
35
- }),
36
- apply: (tr, state) => {
37
- const meta = tr.getMeta(pluginKey);
38
- if (meta && meta.showInsertPanelAt !== undefined) {
39
- const newState = {
40
- showInsertPanelAt: meta.showInsertPanelAt,
41
- allowInserting
42
- };
43
- dispatch(pluginKey, newState);
44
- return newState;
45
- } else if (state.showInsertPanelAt) {
46
- const newState = {
47
- showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
48
- allowInserting
49
- };
50
- dispatch(pluginKey, newState);
51
- return newState;
52
- }
53
- return state;
54
- }
55
- },
56
- appendTransaction(transactions, oldState, newState) {
57
- if (transactions.some(txn => txn.docChanged)) {
58
- const didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
59
- const adjacentNode = newState.selection.$head.nodeAfter;
60
- const adjacentNodePos = newState.selection.$head.pos;
61
- const placeholderNodeType = newState.schema.nodes.placeholder;
62
- if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
63
- var _$newHead$nodeBefore;
64
- const {
65
- $head: $newHead
66
- } = newState.selection;
67
- const {
68
- $head: $oldHead
69
- } = oldState.selection;
70
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
71
- const cursorMoved = $oldHead.pos < $newHead.pos;
72
- const nodeBeforeHasContent = !isNodeEmpty($newHead.nodeBefore);
73
- const nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
74
- if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
75
- const {
76
- $from,
77
- $to
78
- } = NodeSelection.create(newState.doc, adjacentNodePos);
79
- return newState.tr.deleteRange($from.pos, $to.pos);
80
- }
81
- }
82
- }
83
-
84
- // Handle Fake Text Cursor for Floating Toolbar
85
- if (!pluginKey.getState(oldState).showInsertPanelAt && pluginKey.getState(newState).showInsertPanelAt) {
86
- return newState.tr.setSelection(new FakeTextCursorSelection(newState.selection.$from));
87
- }
88
- if (pluginKey.getState(oldState).showInsertPanelAt && !pluginKey.getState(newState).showInsertPanelAt) {
89
- if (newState.selection instanceof FakeTextCursorSelection) {
90
- return newState.tr.setSelection(new TextSelection(newState.selection.$from));
91
- }
92
- }
93
- return;
94
- },
95
- props: {
96
- decorations: drawFakeTextCursor,
97
- handleDOMEvents: {
98
- beforeinput: (view, event) => {
99
- const {
100
- state
101
- } = view;
102
- if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && isSelectionAtPlaceholder(view.state.selection)) {
103
- event.stopPropagation();
104
- event.preventDefault();
105
- const startNodePosition = state.selection.from;
106
- const content = event.data || '';
107
- const tr = view.state.tr;
108
- tr.delete(startNodePosition, startNodePosition + 1);
109
- const openTypeAhead = getOpenTypeAhead(content, api);
110
- if (openTypeAhead) {
111
- openTypeAhead(tr);
112
- } else {
113
- tr.insertText(content);
114
- }
115
- view.dispatch(tr);
116
- return true;
117
- }
118
- return false;
119
- }
120
- },
121
- nodeViews: {
122
- placeholder: (node, view, getPos) => new PlaceholderTextNodeView(node, view, getPos)
123
- }
124
- }
125
- });
126
- }
127
- function ContentComponent({
128
- editorView,
129
- dependencyApi,
130
- popupsMountPoint,
131
- popupsBoundariesElement
132
- }) {
133
- const {
134
- placeholderTextState
135
- } = useSharedPluginState(dependencyApi, ['placeholderText']);
136
- const insertPlaceholderText = value => insertPlaceholderTextAtSelection(value)(editorView.state, editorView.dispatch);
137
- const hidePlaceholderToolbar = () => hidePlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
138
- const getNodeFromPos = pos => editorView.domAtPos(pos).node;
139
- const getFixedCoordinatesFromPos = pos => editorView.coordsAtPos(pos);
140
- const setFocusInEditor = () => editorView.focus();
141
- if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
142
- return /*#__PURE__*/React.createElement(PlaceholderFloatingToolbar, {
143
- editorViewDOM: editorView.dom,
144
- popupsMountPoint: popupsMountPoint,
145
- popupsBoundariesElement: popupsBoundariesElement,
146
- getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
147
- getNodeFromPos: getNodeFromPos,
148
- hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
149
- showInsertPanelAt: placeholderTextState.showInsertPanelAt,
150
- insertPlaceholder: insertPlaceholderText,
151
- setFocusInEditor: setFocusInEditor
152
- });
153
- }
154
- return null;
155
- }
156
- const basePlaceholderTextPlugin = ({
157
- api,
158
- config: options
159
- }) => ({
160
- name: 'placeholderText',
161
- nodes() {
162
- return [{
163
- name: 'placeholder',
164
- node: placeholder
165
- }];
166
- },
167
- pmPlugins() {
168
- return [{
169
- name: 'placeholderText',
170
- plugin: ({
171
- dispatch
172
- }) => createPlugin(dispatch, options, api)
173
- }];
174
- },
175
- getSharedState(editorState) {
176
- if (!editorState) {
177
- return undefined;
178
- }
179
- const {
180
- showInsertPanelAt,
181
- allowInserting
182
- } = pluginKey.getState(editorState) || {
183
- showInsertPanelAt: null
184
- };
185
- return {
186
- showInsertPanelAt,
187
- allowInserting: !!allowInserting
188
- };
189
- },
190
- contentComponent({
191
- editorView,
192
- popupsMountPoint,
193
- popupsBoundariesElement
194
- }) {
195
- return /*#__PURE__*/React.createElement(ContentComponent, {
196
- editorView: editorView,
197
- popupsMountPoint: popupsMountPoint,
198
- popupsBoundariesElement: popupsBoundariesElement,
199
- dependencyApi: api
200
- });
201
- }
202
- });
203
- const decorateWithPluginOptions = (plugin, options, api) => {
204
- if (!options.allowInserting) {
205
- return plugin;
206
- }
207
- plugin.pluginsOptions = {
208
- quickInsert: ({
209
- formatMessage
210
- }) => [{
211
- id: 'placeholderText',
212
- title: formatMessage(messages.placeholderText),
213
- description: formatMessage(messages.placeholderTextDescription),
214
- priority: 1400,
215
- keywords: ['placeholder'],
216
- icon: () => /*#__PURE__*/React.createElement(MediaServicesTextIcon, {
217
- label: ""
218
- }),
219
- action(insert, state) {
220
- var _api$analytics;
221
- const tr = state.tr;
222
- tr.setMeta(pluginKey, {
223
- showInsertPanelAt: tr.selection.anchor
224
- });
225
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
226
- action: ACTION.INSERTED,
227
- actionSubject: ACTION_SUBJECT.DOCUMENT,
228
- actionSubjectId: ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
229
- attributes: {
230
- inputMethod: INPUT_METHOD.QUICK_INSERT
231
- },
232
- eventType: EVENT_TYPE.TRACK
233
- })(tr);
234
- return tr;
235
- }
236
- }]
237
- };
238
- return plugin;
239
- };
240
- const placeholderTextPlugin = ({
241
- config: options = {},
242
- api
243
- }) => decorateWithPluginOptions(basePlaceholderTextPlugin({
244
- config: options,
245
- api
246
- }), options, api);
247
- export default placeholderTextPlugin;
@@ -1,8 +0,0 @@
1
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- export const isSelectionAtPlaceholder = selection => {
3
- if (!(selection instanceof TextSelection) || !selection.$cursor) {
4
- return false;
5
- }
6
- const node = selection.$cursor.doc.nodeAt(selection.$cursor.pos);
7
- return (node === null || node === void 0 ? void 0 : node.type.name) === 'placeholder';
8
- };
@@ -1,52 +0,0 @@
1
- import { css } from '@emotion/react';
2
- import { B75, N200 } from '@atlaskit/theme/colors';
3
- import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
- export const placeholderTextStyles = css`
5
- .ProseMirror span[data-placeholder] {
6
- color: ${`var(--ds-text-subtlest, ${N200})`};
7
- display: inline;
8
- }
9
-
10
- .ProseMirror span.pm-placeholder {
11
- display: inline;
12
- color: ${`var(--ds-text-subtlest, ${N200})`};
13
- }
14
- .ProseMirror span.pm-placeholder__text {
15
- display: inline;
16
- color: ${`var(--ds-text-subtlest, ${N200})`};
17
- }
18
-
19
- .ProseMirror span.pm-placeholder.${akEditorSelectedNodeClassName} {
20
- ${getSelectionStyles([SelectionStyle.Background])}
21
- }
22
-
23
- .ProseMirror span.pm-placeholder__text[data-placeholder]::after {
24
- color: ${`var(--ds-text-subtlest, ${N200})`};
25
- cursor: text;
26
- content: attr(data-placeholder);
27
- display: inline;
28
- }
29
-
30
- .ProseMirror {
31
- .ProseMirror-fake-text-cursor {
32
- display: inline;
33
- pointer-events: none;
34
- position: relative;
35
- }
36
-
37
- .ProseMirror-fake-text-cursor::after {
38
- content: '';
39
- display: inline;
40
- top: 0;
41
- position: absolute;
42
- border-right: 1px solid ${"var(--ds-border, rgba(0, 0, 0, 0.4))"};
43
- }
44
-
45
- .ProseMirror-fake-text-selection {
46
- display: inline;
47
- pointer-events: none;
48
- position: relative;
49
- background-color: ${`var(--ds-background-selected, ${B75})`};
50
- }
51
- }
52
- `;
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { PureComponent } from 'react';
4
- import { Popup } from '@atlaskit/editor-common/ui';
5
- import { container } from './styles';
6
- export { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from './utils';
7
- export default class FloatingToolbar extends PureComponent {
8
- render() {
9
- const {
10
- children,
11
- target,
12
- offset,
13
- fitWidth,
14
- fitHeight = 40,
15
- onPositionCalculated,
16
- popupsMountPoint,
17
- popupsBoundariesElement,
18
- className,
19
- absoluteOffset,
20
- alignX,
21
- alignY,
22
- zIndex
23
- } = this.props;
24
- if (!target) {
25
- return null;
26
- }
27
- return jsx(Popup, {
28
- absoluteOffset: absoluteOffset,
29
- alignX: alignX,
30
- alignY: alignY,
31
- target: target,
32
- zIndex: zIndex,
33
- mountTo: popupsMountPoint,
34
- boundariesElement: popupsBoundariesElement,
35
- offset: offset,
36
- fitWidth: fitWidth,
37
- fitHeight: fitHeight,
38
- onPositionCalculated: onPositionCalculated
39
- }, jsx("div", {
40
- css: container(fitHeight),
41
- "data-testid": "popup-container",
42
- className: className
43
- }, children));
44
- }
45
- }
@@ -1,15 +0,0 @@
1
- import { css } from '@emotion/react';
2
- import { borderRadius } from '@atlaskit/theme/constants';
3
- import { N0, N50A, N60A } from '@atlaskit/theme/colors';
4
- export const container = height => css`
5
- border-radius: ${borderRadius()}px;
6
- box-shadow: ${`var(--ds-shadow-overlay, ${`0 12px 24px -6px ${N50A}, 0 0 1px ${N60A}`})`};
7
- display: flex;
8
- align-items: center;
9
- box-sizing: border-box;
10
- padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"};
11
- background-color: ${`var(--ds-background-input, ${N0})`};
12
- ${height ? css`
13
- height: ${height}px;
14
- ` : ''};
15
- `;
@@ -1,41 +0,0 @@
1
- const getCursorHeightFrom = node => parseFloat(window.getComputedStyle(node, undefined).lineHeight || '');
2
- export const getOffsetParent = (editorViewDom, popupsMountPoint) => popupsMountPoint ? popupsMountPoint.offsetParent : editorViewDom.offsetParent;
3
- export const getNearestNonTextNode = node => node.nodeType === Node.TEXT_NODE ? node.parentNode : node;
4
-
5
- /**
6
- * We need to translate the co-ordinates because `coordsAtPos` returns co-ordinates
7
- * relative to `window`. And, also need to adjust the cursor container height.
8
- * (0, 0)
9
- * +--------------------- [window] ---------------------+
10
- * | (left, top) +-------- [Offset Parent] --------+ |
11
- * | {coordsAtPos} | [Cursor] <- cursorHeight | |
12
- * | | [FloatingToolbar] | |
13
- */
14
- const convertFixedCoordinatesToAbsolutePositioning = (coordinates, offsetParent, cursorHeight) => {
15
- const {
16
- left: offsetParentLeft,
17
- top: offsetParentTop,
18
- height: offsetParentHeight
19
- } = offsetParent.getBoundingClientRect();
20
- return {
21
- left: coordinates.left - offsetParentLeft,
22
- right: coordinates.right - offsetParentLeft,
23
- top: coordinates.top - (offsetParentTop - cursorHeight) + offsetParent.scrollTop,
24
- bottom: offsetParentHeight - (coordinates.top - (offsetParentTop - cursorHeight) - offsetParent.scrollTop)
25
- };
26
- };
27
- export const handlePositionCalculatedWith = (offsetParent, node, getCurrentFixedCoordinates) => position => {
28
- if (!offsetParent) {
29
- return position;
30
- }
31
- const target = getNearestNonTextNode(node);
32
- const cursorHeight = getCursorHeightFrom(target);
33
- const fixedCoordinates = getCurrentFixedCoordinates();
34
- const absoluteCoordinates = convertFixedCoordinatesToAbsolutePositioning(fixedCoordinates, offsetParent, cursorHeight);
35
- return {
36
- left: position.left ? absoluteCoordinates.left : undefined,
37
- right: position.right ? absoluteCoordinates.right : undefined,
38
- top: position.top ? absoluteCoordinates.top : undefined,
39
- bottom: position.bottom ? absoluteCoordinates.bottom : undefined
40
- };
41
- };
@@ -1,60 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import { defineMessages, injectIntl } from 'react-intl-next';
4
- import { PanelTextInput } from '@atlaskit/editor-common/ui';
5
- import FloatingToolbar, { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from '../FloatingToolbar';
6
- export const messages = defineMessages({
7
- placeholderTextPlaceholder: {
8
- id: 'fabric.editor.placeholderTextPlaceholder',
9
- defaultMessage: 'Add placeholder text',
10
- description: ''
11
- }
12
- });
13
- class PlaceholderFloatingToolbar extends React.Component {
14
- constructor(...args) {
15
- super(...args);
16
- _defineProperty(this, "handleSubmit", value => {
17
- if (value) {
18
- this.props.insertPlaceholder(value);
19
- this.props.setFocusInEditor();
20
- } else {
21
- this.props.hidePlaceholderFloatingToolbar();
22
- }
23
- });
24
- _defineProperty(this, "handleBlur", () => {
25
- this.props.hidePlaceholderFloatingToolbar();
26
- });
27
- }
28
- render() {
29
- const {
30
- getNodeFromPos,
31
- showInsertPanelAt,
32
- editorViewDOM,
33
- popupsMountPoint,
34
- getFixedCoordinatesFromPos,
35
- popupsBoundariesElement,
36
- intl: {
37
- formatMessage
38
- }
39
- } = this.props;
40
- const target = getNodeFromPos(showInsertPanelAt);
41
- const offsetParent = getOffsetParent(editorViewDOM, popupsMountPoint);
42
- const getFixedCoordinates = () => getFixedCoordinatesFromPos(showInsertPanelAt);
43
- const handlePositionCalculated = handlePositionCalculatedWith(offsetParent, target, getFixedCoordinates);
44
- return /*#__PURE__*/React.createElement(FloatingToolbar, {
45
- target: getNearestNonTextNode(target),
46
- onPositionCalculated: handlePositionCalculated,
47
- popupsMountPoint: popupsMountPoint,
48
- popupsBoundariesElement: popupsBoundariesElement,
49
- fitHeight: 32,
50
- offset: [0, 12]
51
- }, /*#__PURE__*/React.createElement(PanelTextInput, {
52
- placeholder: formatMessage(messages.placeholderTextPlaceholder),
53
- onSubmit: this.handleSubmit,
54
- onBlur: this.handleBlur,
55
- autoFocus: true,
56
- width: 300
57
- }));
58
- }
59
- }
60
- export default injectIntl(PlaceholderFloatingToolbar);