@atlaskit/editor-core 187.38.2 → 187.38.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 (62) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -2
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/plugins/media/index.js +2 -2
  5. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -3
  6. package/dist/cjs/plugins/media/pm-plugins/main.js +11 -12
  7. package/dist/cjs/plugins/media/toolbar/linking.js +4 -2
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/labs/next/presets/default.js +1 -1
  10. package/dist/es2019/plugins/index.js +0 -1
  11. package/dist/es2019/plugins/media/index.js +2 -2
  12. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  13. package/dist/es2019/plugins/media/pm-plugins/main.js +11 -12
  14. package/dist/es2019/plugins/media/toolbar/linking.js +4 -2
  15. package/dist/es2019/version-wrapper.js +1 -1
  16. package/dist/esm/labs/next/presets/default.js +1 -1
  17. package/dist/esm/plugins/index.js +0 -1
  18. package/dist/esm/plugins/media/index.js +2 -2
  19. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +2 -3
  20. package/dist/esm/plugins/media/pm-plugins/main.js +11 -12
  21. package/dist/esm/plugins/media/toolbar/linking.js +4 -2
  22. package/dist/esm/version-wrapper.js +1 -1
  23. package/dist/types/labs/next/presets/default.d.ts +1 -1
  24. package/dist/types/plugins/index.d.ts +0 -1
  25. package/dist/types/plugins/media/commands/linking.d.ts +2 -2
  26. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
  27. package/dist/types/plugins/media/picker-facade.d.ts +4 -4
  28. package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +1 -1
  29. package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +1 -1
  30. package/dist/types/plugins/media/pm-plugins/keymap.d.ts +1 -1
  31. package/dist/types/plugins/media/pm-plugins/main.d.ts +4 -4
  32. package/dist/types/plugins/media/toolbar/alt-text.d.ts +1 -1
  33. package/dist/types/plugins/media/toolbar/commands.d.ts +4 -4
  34. package/dist/types/plugins/media/ui/MediaPicker/BrowserWrapper.d.ts +2 -2
  35. package/dist/types/plugins/media/ui/MediaPicker/DropzoneWrapper.d.ts +3 -3
  36. package/dist/types/plugins/media/ui/MediaPicker/PickerFacadeProvider.d.ts +3 -3
  37. package/dist/types/plugins/media/utils/media-files.d.ts +2 -2
  38. package/dist/types/plugins/media/utils/media-single.d.ts +1 -1
  39. package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
  40. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  41. package/dist/types-ts4.5/plugins/media/commands/linking.d.ts +2 -2
  42. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
  43. package/dist/types-ts4.5/plugins/media/picker-facade.d.ts +4 -4
  44. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +1 -1
  45. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +1 -1
  46. package/dist/types-ts4.5/plugins/media/pm-plugins/keymap.d.ts +1 -1
  47. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +4 -4
  48. package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +1 -1
  49. package/dist/types-ts4.5/plugins/media/toolbar/commands.d.ts +4 -4
  50. package/dist/types-ts4.5/plugins/media/ui/MediaPicker/BrowserWrapper.d.ts +2 -2
  51. package/dist/types-ts4.5/plugins/media/ui/MediaPicker/DropzoneWrapper.d.ts +3 -3
  52. package/dist/types-ts4.5/plugins/media/ui/MediaPicker/PickerFacadeProvider.d.ts +3 -3
  53. package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +2 -2
  54. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +1 -1
  55. package/package.json +3 -2
  56. package/report.api.md +7 -14
  57. package/tmp/api-report-tmp.d.ts +7 -14
  58. package/dist/cjs/plugins/placeholder/index.js +0 -135
  59. package/dist/es2019/plugins/placeholder/index.js +0 -123
  60. package/dist/esm/plugins/placeholder/index.js +0 -124
  61. package/dist/types/plugins/placeholder/index.d.ts +0 -22
  62. package/dist/types-ts4.5/plugins/placeholder/index.d.ts +0 -26
@@ -1,123 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { browser, isEmptyDocument, bracketTyped } from '@atlaskit/editor-common/utils';
3
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
5
- export const pluginKey = new PluginKey('placeholderPlugin');
6
- function getPlaceholderState(editorState) {
7
- return pluginKey.getState(editorState);
8
- }
9
- export const placeholderTestId = 'placeholder-test-id';
10
- export function createPlaceholderDecoration(editorState, placeholderText, pos = 1) {
11
- const placeholderDecoration = document.createElement('span');
12
- let placeholderNodeWithText = placeholderDecoration;
13
- placeholderDecoration.setAttribute('data-testid', placeholderTestId);
14
- placeholderDecoration.className = 'placeholder-decoration';
15
-
16
- // PM sets contenteditable to false on Decorations so Firefox doesn't display the flashing cursor
17
- // So adding an extra span which will contain the placeholder text
18
- if (browser.gecko) {
19
- const placeholderNode = document.createElement('span');
20
- placeholderNode.setAttribute('contenteditable', 'true'); // explicitly overriding the default Decoration behaviour
21
- placeholderDecoration.appendChild(placeholderNode);
22
- placeholderNodeWithText = placeholderNode;
23
- }
24
- placeholderNodeWithText.textContent = placeholderText || ' ';
25
-
26
- // ME-2289 Tapping on backspace in empty editor hides and displays the keyboard
27
- // Add a editable buff node as the cursor moving forward is inevitable
28
- // when backspace in GBoard composition
29
- if (browser.android && browser.chrome) {
30
- const buffNode = document.createElement('span');
31
- buffNode.setAttribute('class', 'placeholder-android');
32
- buffNode.setAttribute('contenteditable', 'true');
33
- buffNode.textContent = ' ';
34
- placeholderDecoration.appendChild(buffNode);
35
- }
36
- return DecorationSet.create(editorState.doc, [Decoration.widget(pos, placeholderDecoration, {
37
- side: 0,
38
- key: 'placeholder'
39
- })]);
40
- }
41
- function setPlaceHolderState(placeholderText, pos) {
42
- return {
43
- hasPlaceholder: true,
44
- placeholderText,
45
- pos: pos ? pos : 1
46
- };
47
- }
48
- const emptyPlaceholder = {
49
- hasPlaceholder: false
50
- };
51
- function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText) {
52
- if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
53
- return emptyPlaceholder;
54
- }
55
- if (defaultPlaceholderText && isEmptyDocument(editorState.doc)) {
56
- return setPlaceHolderState(defaultPlaceholderText);
57
- }
58
- if (bracketPlaceholderText && bracketTyped(editorState) && isEditorFocused) {
59
- const {
60
- $from
61
- } = editorState.selection;
62
- // Space is to account for positioning of the bracket
63
- const bracketHint = ' ' + bracketPlaceholderText;
64
- return setPlaceHolderState(bracketHint, $from.pos - 1);
65
- }
66
- return emptyPlaceholder;
67
- }
68
- export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
69
- if (!defaultPlaceholderText && !bracketPlaceholderText) {
70
- return;
71
- }
72
- return new SafePlugin({
73
- key: pluginKey,
74
- state: {
75
- init: (_, state) => {
76
- var _api$focus, _api$focus$sharedStat;
77
- return createPlaceHolderStateFrom(Boolean(api === null || api === void 0 ? void 0 : (_api$focus = api.focus) === null || _api$focus === void 0 ? void 0 : (_api$focus$sharedStat = _api$focus.sharedState.currentState()) === null || _api$focus$sharedStat === void 0 ? void 0 : _api$focus$sharedStat.hasFocus), state, api === null || api === void 0 ? void 0 : api.typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
78
- },
79
- apply: (tr, _oldPluginState, _oldEditorState, newEditorState) => {
80
- var _api$focus2, _api$focus2$sharedSta;
81
- const meta = tr.getMeta(pluginKey);
82
- const isEditorFocused = Boolean(api === null || api === void 0 ? void 0 : (_api$focus2 = api.focus) === null || _api$focus2 === void 0 ? void 0 : (_api$focus2$sharedSta = _api$focus2.sharedState.currentState()) === null || _api$focus2$sharedSta === void 0 ? void 0 : _api$focus2$sharedSta.hasFocus);
83
- if (meta) {
84
- if (meta.removePlaceholder) {
85
- return emptyPlaceholder;
86
- }
87
- if (meta.applyPlaceholderIfEmpty) {
88
- return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : api.typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
89
- }
90
- }
91
- return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : api.typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
92
- }
93
- },
94
- props: {
95
- decorations(editorState) {
96
- var _api$composition;
97
- const {
98
- hasPlaceholder,
99
- placeholderText,
100
- pos
101
- } = getPlaceholderState(editorState);
102
- const compositionPluginState = api === null || api === void 0 ? void 0 : (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
103
- if (hasPlaceholder && placeholderText && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
104
- return createPlaceholderDecoration(editorState, placeholderText, pos);
105
- }
106
- return;
107
- }
108
- }
109
- });
110
- }
111
- const placeholderPlugin = ({
112
- config: options,
113
- api
114
- }) => ({
115
- name: 'placeholder',
116
- pmPlugins() {
117
- return [{
118
- name: 'placeholder',
119
- plugin: () => createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api)
120
- }];
121
- }
122
- });
123
- export default placeholderPlugin;
@@ -1,124 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { browser, isEmptyDocument, bracketTyped } from '@atlaskit/editor-common/utils';
3
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
5
- export var pluginKey = new PluginKey('placeholderPlugin');
6
- function getPlaceholderState(editorState) {
7
- return pluginKey.getState(editorState);
8
- }
9
- export var placeholderTestId = 'placeholder-test-id';
10
- export function createPlaceholderDecoration(editorState, placeholderText) {
11
- var pos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
12
- var placeholderDecoration = document.createElement('span');
13
- var placeholderNodeWithText = placeholderDecoration;
14
- placeholderDecoration.setAttribute('data-testid', placeholderTestId);
15
- placeholderDecoration.className = 'placeholder-decoration';
16
-
17
- // PM sets contenteditable to false on Decorations so Firefox doesn't display the flashing cursor
18
- // So adding an extra span which will contain the placeholder text
19
- if (browser.gecko) {
20
- var placeholderNode = document.createElement('span');
21
- placeholderNode.setAttribute('contenteditable', 'true'); // explicitly overriding the default Decoration behaviour
22
- placeholderDecoration.appendChild(placeholderNode);
23
- placeholderNodeWithText = placeholderNode;
24
- }
25
- placeholderNodeWithText.textContent = placeholderText || ' ';
26
-
27
- // ME-2289 Tapping on backspace in empty editor hides and displays the keyboard
28
- // Add a editable buff node as the cursor moving forward is inevitable
29
- // when backspace in GBoard composition
30
- if (browser.android && browser.chrome) {
31
- var buffNode = document.createElement('span');
32
- buffNode.setAttribute('class', 'placeholder-android');
33
- buffNode.setAttribute('contenteditable', 'true');
34
- buffNode.textContent = ' ';
35
- placeholderDecoration.appendChild(buffNode);
36
- }
37
- return DecorationSet.create(editorState.doc, [Decoration.widget(pos, placeholderDecoration, {
38
- side: 0,
39
- key: 'placeholder'
40
- })]);
41
- }
42
- function setPlaceHolderState(placeholderText, pos) {
43
- return {
44
- hasPlaceholder: true,
45
- placeholderText: placeholderText,
46
- pos: pos ? pos : 1
47
- };
48
- }
49
- var emptyPlaceholder = {
50
- hasPlaceholder: false
51
- };
52
- function createPlaceHolderStateFrom(isEditorFocused, editorState, isTypeAheadOpen, defaultPlaceholderText, bracketPlaceholderText) {
53
- if (isTypeAheadOpen !== null && isTypeAheadOpen !== void 0 && isTypeAheadOpen(editorState)) {
54
- return emptyPlaceholder;
55
- }
56
- if (defaultPlaceholderText && isEmptyDocument(editorState.doc)) {
57
- return setPlaceHolderState(defaultPlaceholderText);
58
- }
59
- if (bracketPlaceholderText && bracketTyped(editorState) && isEditorFocused) {
60
- var $from = editorState.selection.$from;
61
- // Space is to account for positioning of the bracket
62
- var bracketHint = ' ' + bracketPlaceholderText;
63
- return setPlaceHolderState(bracketHint, $from.pos - 1);
64
- }
65
- return emptyPlaceholder;
66
- }
67
- export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
68
- if (!defaultPlaceholderText && !bracketPlaceholderText) {
69
- return;
70
- }
71
- return new SafePlugin({
72
- key: pluginKey,
73
- state: {
74
- init: function init(_, state) {
75
- var _api$focus, _api$focus$sharedStat;
76
- return createPlaceHolderStateFrom(Boolean(api === null || api === void 0 ? void 0 : (_api$focus = api.focus) === null || _api$focus === void 0 ? void 0 : (_api$focus$sharedStat = _api$focus.sharedState.currentState()) === null || _api$focus$sharedStat === void 0 ? void 0 : _api$focus$sharedStat.hasFocus), state, api === null || api === void 0 ? void 0 : api.typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
77
- },
78
- apply: function apply(tr, _oldPluginState, _oldEditorState, newEditorState) {
79
- var _api$focus2, _api$focus2$sharedSta;
80
- var meta = tr.getMeta(pluginKey);
81
- var isEditorFocused = Boolean(api === null || api === void 0 ? void 0 : (_api$focus2 = api.focus) === null || _api$focus2 === void 0 ? void 0 : (_api$focus2$sharedSta = _api$focus2.sharedState.currentState()) === null || _api$focus2$sharedSta === void 0 ? void 0 : _api$focus2$sharedSta.hasFocus);
82
- if (meta) {
83
- if (meta.removePlaceholder) {
84
- return emptyPlaceholder;
85
- }
86
- if (meta.applyPlaceholderIfEmpty) {
87
- return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : api.typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
88
- }
89
- }
90
- return createPlaceHolderStateFrom(isEditorFocused, newEditorState, api === null || api === void 0 ? void 0 : api.typeAhead.actions.isOpen, defaultPlaceholderText, bracketPlaceholderText);
91
- }
92
- },
93
- props: {
94
- decorations: function decorations(editorState) {
95
- var _api$composition;
96
- var _getPlaceholderState = getPlaceholderState(editorState),
97
- hasPlaceholder = _getPlaceholderState.hasPlaceholder,
98
- placeholderText = _getPlaceholderState.placeholderText,
99
- pos = _getPlaceholderState.pos;
100
- var compositionPluginState = api === null || api === void 0 ? void 0 : (_api$composition = api.composition) === null || _api$composition === void 0 ? void 0 : _api$composition.sharedState.currentState();
101
- if (hasPlaceholder && placeholderText && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
102
- return createPlaceholderDecoration(editorState, placeholderText, pos);
103
- }
104
- return;
105
- }
106
- }
107
- });
108
- }
109
- var placeholderPlugin = function placeholderPlugin(_ref) {
110
- var options = _ref.config,
111
- api = _ref.api;
112
- return {
113
- name: 'placeholder',
114
- pmPlugins: function pmPlugins() {
115
- return [{
116
- name: 'placeholder',
117
- plugin: function plugin() {
118
- return createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api);
119
- }
120
- }];
121
- }
122
- };
123
- };
124
- export default placeholderPlugin;
@@ -1,22 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
- import type { NextEditorPlugin, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
- import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
7
- import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
8
- export declare const pluginKey: PluginKey<any>;
9
- import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
10
- export declare const placeholderTestId = "placeholder-test-id";
11
- export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, pos?: number): DecorationSet;
12
- export declare function createPlugin(defaultPlaceholderText?: string, bracketPlaceholderText?: string, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
13
- export interface PlaceholderPluginOptions {
14
- placeholder?: string;
15
- placeholderBracketHint?: string;
16
- }
17
- type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
18
- pluginConfiguration: PlaceholderPluginOptions | undefined;
19
- dependencies: [FocusPlugin, CompositionPlugin, TypeAheadPlugin];
20
- }>;
21
- declare const placeholderPlugin: PlaceholderPlugin;
22
- export default placeholderPlugin;
@@ -1,26 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
- import type { NextEditorPlugin, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
- import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
7
- import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
8
- export declare const pluginKey: PluginKey<any>;
9
- import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
10
- export declare const placeholderTestId = "placeholder-test-id";
11
- export declare function createPlaceholderDecoration(editorState: EditorState, placeholderText: string, pos?: number): DecorationSet;
12
- export declare function createPlugin(defaultPlaceholderText?: string, bracketPlaceholderText?: string, api?: ExtractInjectionAPI<PlaceholderPlugin>): SafePlugin | undefined;
13
- export interface PlaceholderPluginOptions {
14
- placeholder?: string;
15
- placeholderBracketHint?: string;
16
- }
17
- type PlaceholderPlugin = NextEditorPlugin<'placeholder', {
18
- pluginConfiguration: PlaceholderPluginOptions | undefined;
19
- dependencies: [
20
- FocusPlugin,
21
- CompositionPlugin,
22
- TypeAheadPlugin
23
- ];
24
- }>;
25
- declare const placeholderPlugin: PlaceholderPlugin;
26
- export default placeholderPlugin;