@atlaskit/editor-core 187.38.2 → 187.38.5
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 +16 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/media/index.js +2 -2
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -3
- package/dist/cjs/plugins/media/pm-plugins/main.js +11 -12
- package/dist/cjs/plugins/media/toolbar/linking.js +4 -2
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +5 -40
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +28 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/media/index.js +2 -2
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +11 -12
- package/dist/es2019/plugins/media/toolbar/linking.js +4 -2
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +6 -39
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +28 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/media/index.js +2 -2
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +2 -3
- package/dist/esm/plugins/media/pm-plugins/main.js +11 -12
- package/dist/esm/plugins/media/toolbar/linking.js +4 -2
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +6 -41
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +28 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/media/commands/linking.d.ts +2 -2
- package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
- package/dist/types/plugins/media/picker-facade.d.ts +4 -4
- package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +1 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +1 -1
- package/dist/types/plugins/media/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +4 -4
- package/dist/types/plugins/media/toolbar/alt-text.d.ts +1 -1
- package/dist/types/plugins/media/toolbar/commands.d.ts +4 -4
- package/dist/types/plugins/media/ui/MediaPicker/BrowserWrapper.d.ts +2 -2
- package/dist/types/plugins/media/ui/MediaPicker/DropzoneWrapper.d.ts +3 -3
- package/dist/types/plugins/media/ui/MediaPicker/PickerFacadeProvider.d.ts +3 -3
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -4
- package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +2 -2
- package/dist/types/plugins/media/utils/media-single.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/commands/linking.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/picker-facade.d.ts +4 -4
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +4 -4
- package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/toolbar/commands.d.ts +4 -4
- package/dist/types-ts4.5/plugins/media/ui/MediaPicker/BrowserWrapper.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/ui/MediaPicker/DropzoneWrapper.d.ts +3 -3
- package/dist/types-ts4.5/plugins/media/ui/MediaPicker/PickerFacadeProvider.d.ts +3 -3
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -4
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +1 -1
- package/package.json +7 -6
- package/report.api.md +7 -14
- package/tmp/api-report-tmp.d.ts +7 -14
- package/dist/cjs/plugins/placeholder/index.js +0 -135
- package/dist/es2019/plugins/placeholder/index.js +0 -123
- package/dist/esm/plugins/placeholder/index.js +0 -124
- package/dist/types/plugins/placeholder/index.d.ts +0 -22
- package/dist/types-ts4.5/plugins/placeholder/index.d.ts +0 -26
|
@@ -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;
|