@atlaskit/editor-plugin-block-controls 2.13.12 → 2.13.14
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 +21 -0
- package/dist/cjs/plugin.js +5 -16
- package/dist/cjs/pm-plugins/decorations-anchor.js +4 -3
- package/dist/cjs/pm-plugins/decorations-drop-target.js +3 -0
- package/dist/cjs/ui/drop-target-layout.js +7 -4
- package/dist/cjs/ui/drop-target-v2.js +4 -5
- package/dist/cjs/ui/global-styles.js +86 -122
- package/dist/cjs/utils/inline-drop-target.js +4 -0
- package/dist/es2019/plugin.js +1 -10
- package/dist/es2019/pm-plugins/decorations-anchor.js +4 -3
- package/dist/es2019/pm-plugins/decorations-drop-target.js +3 -0
- package/dist/es2019/ui/drop-target-layout.js +8 -5
- package/dist/es2019/ui/drop-target-v2.js +5 -5
- package/dist/es2019/ui/global-styles.js +23 -20
- package/dist/es2019/utils/inline-drop-target.js +4 -1
- package/dist/esm/plugin.js +5 -16
- package/dist/esm/pm-plugins/decorations-anchor.js +4 -3
- package/dist/esm/pm-plugins/decorations-drop-target.js +3 -0
- package/dist/esm/ui/drop-target-layout.js +7 -4
- package/dist/esm/ui/drop-target-v2.js +4 -5
- package/dist/esm/ui/global-styles.js +87 -122
- package/dist/esm/utils/inline-drop-target.js +4 -0
- package/dist/types/ui/drop-target-layout.d.ts +1 -1
- package/dist/types/utils/inline-drop-target.d.ts +2 -1
- package/dist/types-ts4.5/ui/drop-target-layout.d.ts +1 -1
- package/dist/types-ts4.5/utils/inline-drop-target.d.ts +2 -1
- package/package.json +4 -7
- package/dist/cjs/pm-plugins/empty-block-experiment.js +0 -46
- package/dist/cjs/ui/empty-block-experiment/global-styles.js +0 -66
- package/dist/cjs/ui/empty-block-experiment/widget.js +0 -144
- package/dist/es2019/pm-plugins/empty-block-experiment.js +0 -38
- package/dist/es2019/ui/empty-block-experiment/global-styles.js +0 -77
- package/dist/es2019/ui/empty-block-experiment/widget.js +0 -138
- package/dist/esm/pm-plugins/empty-block-experiment.js +0 -40
- package/dist/esm/ui/empty-block-experiment/global-styles.js +0 -58
- package/dist/esm/ui/empty-block-experiment/widget.js +0 -133
- package/dist/types/pm-plugins/empty-block-experiment.d.ts +0 -13
- package/dist/types/ui/empty-block-experiment/global-styles.d.ts +0 -4
- package/dist/types/ui/empty-block-experiment/widget.d.ts +0 -13
- package/dist/types-ts4.5/pm-plugins/empty-block-experiment.d.ts +0 -13
- package/dist/types-ts4.5/ui/empty-block-experiment/global-styles.d.ts +0 -4
- package/dist/types-ts4.5/ui/empty-block-experiment/widget.d.ts +0 -13
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
/* eslint-disable @atlaskit/ui-styling-standard/use-compiled */
|
|
3
|
-
import React, { createElement } from 'react';
|
|
4
|
-
import { keyframes } from '@emotion/react';
|
|
5
|
-
import ReactDOM from 'react-dom';
|
|
6
|
-
import { injectIntl, RawIntlProvider } from 'react-intl-next';
|
|
7
|
-
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
8
|
-
import { blockControlsMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
10
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
12
|
-
import EditorAddIcon from '@atlaskit/icon/glyph/editor/add';
|
|
13
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
|
-
import { Box, Pressable, xcss } from '@atlaskit/primitives';
|
|
15
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
16
|
-
var wrapperStyles = xcss({
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
top: "calc('50%' - ".concat("var(--ds-space-150, 12px)", ")"),
|
|
19
|
-
left: "calc(".concat("var(--ds-space-negative-300, -24px)", " + ", "var(--ds-space-negative-100, -8px)", ")")
|
|
20
|
-
});
|
|
21
|
-
var appear = keyframes({
|
|
22
|
-
from: {
|
|
23
|
-
visibility: 'hidden'
|
|
24
|
-
},
|
|
25
|
-
to: {
|
|
26
|
-
visibility: 'visible'
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
var delayedAppearance = xcss({
|
|
30
|
-
visibility: 'hidden',
|
|
31
|
-
animation: "".concat(appear, " 0.1s"),
|
|
32
|
-
animationDelay: '2s',
|
|
33
|
-
animationFillMode: 'forwards'
|
|
34
|
-
});
|
|
35
|
-
var buttonStyles = xcss({
|
|
36
|
-
boxSizing: 'border-box',
|
|
37
|
-
display: 'flex',
|
|
38
|
-
flexDirection: 'column',
|
|
39
|
-
justifyContent: 'center',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
height: "var(--ds-space-300, 24px)",
|
|
42
|
-
width: "var(--ds-space-300, 24px)",
|
|
43
|
-
border: 'none',
|
|
44
|
-
backgroundColor: 'color.background.neutral',
|
|
45
|
-
borderRadius: '50%',
|
|
46
|
-
color: 'color.text.accent.gray',
|
|
47
|
-
zIndex: 'card',
|
|
48
|
-
outline: 'none',
|
|
49
|
-
':hover': {
|
|
50
|
-
backgroundColor: 'color.background.neutral.hovered'
|
|
51
|
-
},
|
|
52
|
-
':active': {
|
|
53
|
-
backgroundColor: 'color.background.neutral.pressed'
|
|
54
|
-
},
|
|
55
|
-
':focus': {
|
|
56
|
-
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
60
|
-
var api = _ref.api,
|
|
61
|
-
getPos = _ref.getPos,
|
|
62
|
-
formatMessage = _ref.intl.formatMessage;
|
|
63
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
64
|
-
xcss: [wrapperStyles],
|
|
65
|
-
testId: "editor-empty-line-prompt-experiment"
|
|
66
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
67
|
-
content: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
68
|
-
description: formatMessage(messages.insert),
|
|
69
|
-
shortcutOverride: "/"
|
|
70
|
-
})
|
|
71
|
-
}, /*#__PURE__*/React.createElement(Pressable, {
|
|
72
|
-
type: "button",
|
|
73
|
-
"aria-label": formatMessage(messages.insert),
|
|
74
|
-
xcss: [buttonStyles].concat(_toConsumableArray(fg('platform_editor_empty_line_prompt_delay') ? [delayedAppearance] : [])),
|
|
75
|
-
onClick: function onClick() {
|
|
76
|
-
var _api$core, _api$quickInsert;
|
|
77
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
78
|
-
var tr = _ref2.tr;
|
|
79
|
-
var start = getPos();
|
|
80
|
-
if (!start) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
return tr.setSelection(TextSelection.create(tr.doc, start));
|
|
84
|
-
});
|
|
85
|
-
api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
|
|
86
|
-
}
|
|
87
|
-
}, /*#__PURE__*/React.createElement(EditorAddIcon, {
|
|
88
|
-
label: "add",
|
|
89
|
-
size: "medium"
|
|
90
|
-
}))));
|
|
91
|
-
};
|
|
92
|
-
var TypeAheadControlWithIntl = injectIntl(TypeAheadControl);
|
|
93
|
-
var toDOM = function toDOM(api, getPos, getIntl) {
|
|
94
|
-
var wrapper = document.createElement('span');
|
|
95
|
-
wrapper.contentEditable = 'false';
|
|
96
|
-
wrapper.setAttribute('data-empty-block-experiment', 'true');
|
|
97
|
-
wrapper.setAttribute('class', 'empty-block-experiment');
|
|
98
|
-
var element = document.createElement('span');
|
|
99
|
-
element.contentEditable = 'false';
|
|
100
|
-
element.setAttribute('style', 'position: absolute;');
|
|
101
|
-
wrapper.appendChild(element);
|
|
102
|
-
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
103
|
-
value: getIntl()
|
|
104
|
-
}, /*#__PURE__*/createElement(TypeAheadControlWithIntl, {
|
|
105
|
-
api: api,
|
|
106
|
-
getPos: getPos
|
|
107
|
-
})), element);
|
|
108
|
-
|
|
109
|
-
// // This is a hack to ensure that the cursor in Chrome does not take on the height of the widget button.
|
|
110
|
-
// // Cursor height cannot be controlled via CSS and is handled by the browser.
|
|
111
|
-
// // see Prosemirror forum: https://discuss.prosemirror.net/t/chrome-caret-cursor-larger-than-the-text-with-inlined-items/5946
|
|
112
|
-
var cursorHack = document.createTextNode(ZERO_WIDTH_SPACE);
|
|
113
|
-
wrapper.appendChild(cursorHack);
|
|
114
|
-
return wrapper;
|
|
115
|
-
};
|
|
116
|
-
export var createEmptyBlockWidgetDecoration = function createEmptyBlockWidgetDecoration(selection, api, getIntl) {
|
|
117
|
-
if (selection instanceof TextSelection && selection.$cursor) {
|
|
118
|
-
var _$cursor$parent, _$cursor$parent2;
|
|
119
|
-
var $cursor = selection.$cursor;
|
|
120
|
-
var depth = $cursor.depth;
|
|
121
|
-
var cursorAtRoot = depth === 1;
|
|
122
|
-
var nodeIsEmpty = ((_$cursor$parent = $cursor.parent) === null || _$cursor$parent === void 0 ? void 0 : _$cursor$parent.nodeSize) === 2;
|
|
123
|
-
var supportedNodeTypes = ['paragraph', 'heading'];
|
|
124
|
-
if (cursorAtRoot && nodeIsEmpty && supportedNodeTypes.includes((_$cursor$parent2 = $cursor.parent) === null || _$cursor$parent2 === void 0 ? void 0 : _$cursor$parent2.type.name)) {
|
|
125
|
-
return Decoration.widget(selection.$cursor.posAtIndex($cursor.depth - 1), function (_view, getPos) {
|
|
126
|
-
return toDOM(api, getPos, getIntl);
|
|
127
|
-
}, {
|
|
128
|
-
key: 'emptyBlockWidgetDecoration',
|
|
129
|
-
side: -1
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type IntlShape } from 'react-intl-next';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { type BlockControlsPlugin } from '../types';
|
|
7
|
-
export declare const emptyBlockExperimentPluginKey: PluginKey<EmptyBlockExperimentState>;
|
|
8
|
-
export type EmptyBlockExperimentState = {
|
|
9
|
-
decorations: DecorationSet;
|
|
10
|
-
};
|
|
11
|
-
export declare const createEmptyBlockExperimentPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape) => SafePlugin<{
|
|
12
|
-
decorations: DecorationSet;
|
|
13
|
-
}>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { type IntlShape, type WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { type Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { type BlockControlsPlugin } from '../../types';
|
|
7
|
-
type Props = {
|
|
8
|
-
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
9
|
-
getPos: () => number | undefined;
|
|
10
|
-
};
|
|
11
|
-
export declare const TypeAheadControl: ({ api, getPos, intl: { formatMessage }, }: Props & WrappedComponentProps) => JSX.Element;
|
|
12
|
-
export declare const createEmptyBlockWidgetDecoration: (selection: Selection, api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape) => Decoration | undefined;
|
|
13
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type IntlShape } from 'react-intl-next';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { type BlockControlsPlugin } from '../types';
|
|
7
|
-
export declare const emptyBlockExperimentPluginKey: PluginKey<EmptyBlockExperimentState>;
|
|
8
|
-
export type EmptyBlockExperimentState = {
|
|
9
|
-
decorations: DecorationSet;
|
|
10
|
-
};
|
|
11
|
-
export declare const createEmptyBlockExperimentPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape) => SafePlugin<{
|
|
12
|
-
decorations: DecorationSet;
|
|
13
|
-
}>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { type IntlShape, type WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { type Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { type BlockControlsPlugin } from '../../types';
|
|
7
|
-
type Props = {
|
|
8
|
-
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
9
|
-
getPos: () => number | undefined;
|
|
10
|
-
};
|
|
11
|
-
export declare const TypeAheadControl: ({ api, getPos, intl: { formatMessage }, }: Props & WrappedComponentProps) => JSX.Element;
|
|
12
|
-
export declare const createEmptyBlockWidgetDecoration: (selection: Selection, api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape) => Decoration | undefined;
|
|
13
|
-
export {};
|