@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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/plugins/insert-block/index.js +6 -10
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/cjs/presets/universal.js +4 -2
- package/dist/cjs/ui/ContentStyles/index.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/plugins/insert-block/index.js +5 -9
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/es2019/presets/universal.js +3 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/plugins/insert-block/index.js +5 -9
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/esm/presets/universal.js +3 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +4 -2
- package/dist/types/types/editor-props.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
- package/dist/types-ts4.5/types/editor-props.d.ts +2 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/package.json +4 -2
- package/report.api.md +2 -16
- package/tmp/api-report-tmp.d.ts +2 -16
- package/dist/cjs/plugins/layout/actions.js +0 -345
- package/dist/cjs/plugins/layout/index.js +0 -91
- package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
- package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
- package/dist/cjs/plugins/layout/toolbar.js +0 -116
- package/dist/cjs/plugins/layout/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/actions.js +0 -35
- package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
- package/dist/cjs/plugins/placeholder-text/index.js +0 -20
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
- package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
- package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
- package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
- package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
- package/dist/cjs/plugins/placeholder-text/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
- package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
- package/dist/es2019/plugins/layout/actions.js +0 -328
- package/dist/es2019/plugins/layout/index.js +0 -75
- package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
- package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
- package/dist/es2019/plugins/layout/toolbar.js +0 -101
- package/dist/es2019/plugins/layout/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/actions.js +0 -27
- package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
- package/dist/es2019/plugins/placeholder-text/index.js +0 -2
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
- package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
- package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
- package/dist/es2019/plugins/placeholder-text/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
- package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
- package/dist/esm/plugins/layout/actions.js +0 -336
- package/dist/esm/plugins/layout/index.js +0 -79
- package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
- package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
- package/dist/esm/plugins/layout/toolbar.js +0 -109
- package/dist/esm/plugins/layout/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/actions.js +0 -29
- package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
- package/dist/esm/plugins/placeholder-text/index.js +0 -2
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
- package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
- package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/esm/plugins/placeholder-text/styles.js +0 -6
- package/dist/esm/plugins/placeholder-text/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
- package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
- package/dist/types/plugins/layout/actions.d.ts +0 -22
- package/dist/types/plugins/layout/index.d.ts +0 -15
- package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types/plugins/layout/types.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
- package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
- package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
- package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import EditorLayoutSingleIcon from '@atlaskit/icon/glyph/editor/layout-single';
|
|
4
|
-
import LayoutTwoEqualIcon from '@atlaskit/icon/glyph/editor/layout-two-equal';
|
|
5
|
-
import LayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
6
|
-
import LayoutTwoLeftSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-left-sidebar';
|
|
7
|
-
import LayoutTwoRightSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-right-sidebar';
|
|
8
|
-
import LayoutThreeWithSidebarsIcon from '@atlaskit/icon/glyph/editor/layout-three-with-sidebars';
|
|
9
|
-
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
10
|
-
import { toolbarMessages } from './toolbar-messages';
|
|
11
|
-
import commonMessages from '@atlaskit/editor-common/messages';
|
|
12
|
-
import { setPresetLayout, deleteActiveLayoutNode, getPresetLayout } from './actions';
|
|
13
|
-
var LAYOUT_TYPES = [{
|
|
14
|
-
id: 'editor.layout.twoEquals',
|
|
15
|
-
type: 'two_equal',
|
|
16
|
-
title: toolbarMessages.twoColumns,
|
|
17
|
-
icon: LayoutTwoEqualIcon
|
|
18
|
-
}, {
|
|
19
|
-
id: 'editor.layout.threeEquals',
|
|
20
|
-
type: 'three_equal',
|
|
21
|
-
title: toolbarMessages.threeColumns,
|
|
22
|
-
icon: LayoutThreeEqualIcon
|
|
23
|
-
}];
|
|
24
|
-
var LAYOUT_TYPES_WITH_SINGLE_COL = [{
|
|
25
|
-
id: 'editor.layout.singeLayout',
|
|
26
|
-
type: 'single',
|
|
27
|
-
title: toolbarMessages.singleColumn,
|
|
28
|
-
icon: EditorLayoutSingleIcon
|
|
29
|
-
}].concat(LAYOUT_TYPES);
|
|
30
|
-
var SIDEBAR_LAYOUT_TYPES = [{
|
|
31
|
-
id: 'editor.layout.twoRightSidebar',
|
|
32
|
-
type: 'two_right_sidebar',
|
|
33
|
-
title: toolbarMessages.rightSidebar,
|
|
34
|
-
icon: LayoutTwoRightSidebarIcon
|
|
35
|
-
}, {
|
|
36
|
-
id: 'editor.layout.twoLeftSidebar',
|
|
37
|
-
type: 'two_left_sidebar',
|
|
38
|
-
title: toolbarMessages.leftSidebar,
|
|
39
|
-
icon: LayoutTwoLeftSidebarIcon
|
|
40
|
-
}, {
|
|
41
|
-
id: 'editor.layout.threeWithSidebars',
|
|
42
|
-
type: 'three_with_sidebars',
|
|
43
|
-
title: toolbarMessages.threeColumnsWithSidebars,
|
|
44
|
-
icon: LayoutThreeWithSidebarsIcon
|
|
45
|
-
}];
|
|
46
|
-
var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, editorAnalyticsAPI) {
|
|
47
|
-
return {
|
|
48
|
-
id: item.id,
|
|
49
|
-
type: 'button',
|
|
50
|
-
icon: item.icon,
|
|
51
|
-
testId: item.title.id ? "".concat(item.title.id) : undefined,
|
|
52
|
-
title: intl.formatMessage(item.title),
|
|
53
|
-
onClick: setPresetLayout(editorAnalyticsAPI)(item.type),
|
|
54
|
-
selected: !!currentLayout && currentLayout === item.type,
|
|
55
|
-
tabIndex: null
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export var layoutToolbarTitle = 'Layout floating controls';
|
|
59
|
-
export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) {
|
|
60
|
-
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
61
|
-
var _ref = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
|
|
62
|
-
hoverDecoration = _ref.hoverDecoration;
|
|
63
|
-
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
64
|
-
var node = state.doc.nodeAt(pos);
|
|
65
|
-
if (node) {
|
|
66
|
-
var currentLayout = getPresetLayout(node);
|
|
67
|
-
var separator = {
|
|
68
|
-
type: 'separator'
|
|
69
|
-
};
|
|
70
|
-
var nodeType = state.schema.nodes.layoutSection;
|
|
71
|
-
var deleteButton = {
|
|
72
|
-
id: 'editor.layout.delete',
|
|
73
|
-
type: 'button',
|
|
74
|
-
appearance: 'danger',
|
|
75
|
-
focusEditoronEnter: true,
|
|
76
|
-
icon: RemoveIcon,
|
|
77
|
-
testId: commonMessages.remove.id,
|
|
78
|
-
title: intl.formatMessage(commonMessages.remove),
|
|
79
|
-
onClick: deleteActiveLayoutNode(editorAnalyticsAPI),
|
|
80
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
81
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
82
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
83
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
84
|
-
tabIndex: null
|
|
85
|
-
};
|
|
86
|
-
var layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
|
|
87
|
-
return {
|
|
88
|
-
title: layoutToolbarTitle,
|
|
89
|
-
getDomRef: function getDomRef(view) {
|
|
90
|
-
return findDomRefAtPos(pos, view.domAtPos.bind(view));
|
|
91
|
-
},
|
|
92
|
-
nodeType: nodeType,
|
|
93
|
-
items: [].concat(_toConsumableArray(layoutTypes.map(function (i) {
|
|
94
|
-
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
95
|
-
})), _toConsumableArray(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(function (i) {
|
|
96
|
-
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
97
|
-
}) : []), [{
|
|
98
|
-
type: 'copy-button',
|
|
99
|
-
items: [separator, {
|
|
100
|
-
state: state,
|
|
101
|
-
formatMessage: intl.formatMessage,
|
|
102
|
-
nodeType: nodeType
|
|
103
|
-
}]
|
|
104
|
-
}, separator, deleteButton]),
|
|
105
|
-
scrollable: true
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return;
|
|
109
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { pluginKey } from './plugin-key';
|
|
2
|
-
export var showPlaceholderFloatingToolbar = function showPlaceholderFloatingToolbar(state, dispatch) {
|
|
3
|
-
var tr = state.tr;
|
|
4
|
-
if (!state.selection.empty) {
|
|
5
|
-
tr.deleteSelection();
|
|
6
|
-
}
|
|
7
|
-
tr.setMeta(pluginKey, {
|
|
8
|
-
showInsertPanelAt: tr.selection.anchor
|
|
9
|
-
});
|
|
10
|
-
tr.scrollIntoView();
|
|
11
|
-
dispatch(tr);
|
|
12
|
-
return true;
|
|
13
|
-
};
|
|
14
|
-
export var insertPlaceholderTextAtSelection = function insertPlaceholderTextAtSelection(value) {
|
|
15
|
-
return function (state, dispatch) {
|
|
16
|
-
dispatch(state.tr.replaceSelectionWith(state.schema.nodes.placeholder.createChecked({
|
|
17
|
-
text: value
|
|
18
|
-
})).setMeta(pluginKey, {
|
|
19
|
-
showInsertPanelAt: null
|
|
20
|
-
}).scrollIntoView());
|
|
21
|
-
return true;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export var hidePlaceholderFloatingToolbar = function hidePlaceholderFloatingToolbar(state, dispatch) {
|
|
25
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
26
|
-
showInsertPanelAt: null
|
|
27
|
-
}));
|
|
28
|
-
return true;
|
|
29
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
2
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
3
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
9
|
-
import { TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
-
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
12
|
-
export var FakeTextCursorBookmark = /*#__PURE__*/function () {
|
|
13
|
-
function FakeTextCursorBookmark(pos) {
|
|
14
|
-
_classCallCheck(this, FakeTextCursorBookmark);
|
|
15
|
-
_defineProperty(this, "pos", undefined);
|
|
16
|
-
_defineProperty(this, "visible", false);
|
|
17
|
-
this.pos = pos;
|
|
18
|
-
}
|
|
19
|
-
_createClass(FakeTextCursorBookmark, [{
|
|
20
|
-
key: "map",
|
|
21
|
-
value: function map(mapping) {
|
|
22
|
-
return new FakeTextCursorBookmark(mapping.map(this.pos));
|
|
23
|
-
}
|
|
24
|
-
}, {
|
|
25
|
-
key: "resolve",
|
|
26
|
-
value: function resolve(doc) {
|
|
27
|
-
var $pos = doc.resolve(this.pos);
|
|
28
|
-
return Selection.near($pos);
|
|
29
|
-
}
|
|
30
|
-
}]);
|
|
31
|
-
return FakeTextCursorBookmark;
|
|
32
|
-
}();
|
|
33
|
-
export var FakeTextCursorSelection = /*#__PURE__*/function (_Selection) {
|
|
34
|
-
_inherits(FakeTextCursorSelection, _Selection);
|
|
35
|
-
var _super = _createSuper(FakeTextCursorSelection);
|
|
36
|
-
function FakeTextCursorSelection($pos) {
|
|
37
|
-
_classCallCheck(this, FakeTextCursorSelection);
|
|
38
|
-
return _super.call(this, $pos, $pos);
|
|
39
|
-
}
|
|
40
|
-
_createClass(FakeTextCursorSelection, [{
|
|
41
|
-
key: "map",
|
|
42
|
-
value: function map(doc, mapping) {
|
|
43
|
-
var $pos = doc.resolve(mapping.map(this.$head.pos));
|
|
44
|
-
return new FakeTextCursorSelection($pos);
|
|
45
|
-
}
|
|
46
|
-
}, {
|
|
47
|
-
key: "eq",
|
|
48
|
-
value: function eq(other) {
|
|
49
|
-
return other instanceof FakeTextCursorSelection && other.head === this.head;
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: "toJSON",
|
|
53
|
-
value: function toJSON() {
|
|
54
|
-
return {
|
|
55
|
-
type: 'Cursor',
|
|
56
|
-
pos: this.head
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "getBookmark",
|
|
61
|
-
value: function getBookmark() {
|
|
62
|
-
return new FakeTextCursorBookmark(this.anchor);
|
|
63
|
-
}
|
|
64
|
-
}], [{
|
|
65
|
-
key: "content",
|
|
66
|
-
value: function content() {
|
|
67
|
-
return Slice.empty;
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "fromJSON",
|
|
71
|
-
value: function fromJSON(doc, json) {
|
|
72
|
-
return new FakeTextCursorSelection(doc.resolve(json.pos));
|
|
73
|
-
}
|
|
74
|
-
}]);
|
|
75
|
-
return FakeTextCursorSelection;
|
|
76
|
-
}(Selection);
|
|
77
|
-
Selection.jsonID('fake-text-cursor', FakeTextCursorSelection);
|
|
78
|
-
export var addFakeTextCursor = function addFakeTextCursor(state, dispatch) {
|
|
79
|
-
var selection = state.selection;
|
|
80
|
-
if (selection.empty) {
|
|
81
|
-
var $from = state.selection.$from;
|
|
82
|
-
dispatch(state.tr.setSelection(new FakeTextCursorSelection($from)));
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
export var removeFakeTextCursor = function removeFakeTextCursor(state, dispatch) {
|
|
86
|
-
if (state.selection instanceof FakeTextCursorSelection) {
|
|
87
|
-
var $from = state.selection.$from;
|
|
88
|
-
dispatch(state.tr.setSelection(new TextSelection($from)));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
export var drawFakeTextCursor = function drawFakeTextCursor(state) {
|
|
92
|
-
if (!(state.selection instanceof FakeTextCursorSelection)) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
var node = document.createElement('div');
|
|
96
|
-
node.className = 'ProseMirror-fake-text-cursor';
|
|
97
|
-
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, {
|
|
98
|
-
key: 'Cursor'
|
|
99
|
-
})]);
|
|
100
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
5
|
-
var serializePlaceholderNode = function serializePlaceholderNode(node) {
|
|
6
|
-
var element = document.createElement('span');
|
|
7
|
-
element.classList.add('pm-placeholder');
|
|
8
|
-
|
|
9
|
-
// the inline node api test suite requires the following class name
|
|
10
|
-
element.classList.add('placeholderView-content-wrap');
|
|
11
|
-
element.innerText = ZERO_WIDTH_SPACE;
|
|
12
|
-
var elementChildren = document.createElement('span');
|
|
13
|
-
elementChildren.classList.add('pm-placeholder__text');
|
|
14
|
-
elementChildren.dataset.placeholder = node.attrs.text;
|
|
15
|
-
elementChildren.setAttribute('contenteditable', 'false');
|
|
16
|
-
element.appendChild(elementChildren);
|
|
17
|
-
if (browser.safari) {
|
|
18
|
-
element.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
|
|
19
|
-
} else {
|
|
20
|
-
element.appendChild(document.createElement('wbr'));
|
|
21
|
-
}
|
|
22
|
-
return element;
|
|
23
|
-
};
|
|
24
|
-
export var PlaceholderTextNodeView = /*#__PURE__*/function () {
|
|
25
|
-
function PlaceholderTextNodeView(node, view, getPos) {
|
|
26
|
-
_classCallCheck(this, PlaceholderTextNodeView);
|
|
27
|
-
this.node = node;
|
|
28
|
-
this.view = view;
|
|
29
|
-
this.getPos = getPos;
|
|
30
|
-
this.dom = serializePlaceholderNode(this.node);
|
|
31
|
-
this.getPos = getPos;
|
|
32
|
-
}
|
|
33
|
-
_createClass(PlaceholderTextNodeView, [{
|
|
34
|
-
key: "stopEvent",
|
|
35
|
-
value: function stopEvent(e) {
|
|
36
|
-
if (e.type === 'mousedown' && typeof this.getPos === 'function') {
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
var _view = this.view;
|
|
39
|
-
var startNodePosition = this.getPos();
|
|
40
|
-
if (typeof startNodePosition !== 'number') {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
var tr = _view.state.tr;
|
|
44
|
-
tr.setSelection(Selection.near(tr.doc.resolve(startNodePosition)));
|
|
45
|
-
_view.dispatch(tr);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}, {
|
|
51
|
-
key: "ignoreMutation",
|
|
52
|
-
value: function ignoreMutation(record) {
|
|
53
|
-
if (typeof this.getPos !== 'function' || record.type !== 'selection') {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
var view = this.view,
|
|
57
|
-
node = this.node;
|
|
58
|
-
var placeholderStartPosition = this.getPos();
|
|
59
|
-
if (typeof placeholderStartPosition !== 'number') {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
var placeholderEndPosition = placeholderStartPosition + node.nodeSize;
|
|
63
|
-
var selection = view.state.selection;
|
|
64
|
-
|
|
65
|
-
// when the selection is set right after the placeholder.
|
|
66
|
-
// we should let ProseMirror deal with this edge-case
|
|
67
|
-
if (selection.from === placeholderEndPosition) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
var isSelectionAtPlaceholder = selection.from === placeholderStartPosition;
|
|
71
|
-
var isSelectionAfterlaceholder = selection.from > placeholderEndPosition;
|
|
72
|
-
if (isSelectionAtPlaceholder || isSelectionAfterlaceholder) {
|
|
73
|
-
var tr = view.state.tr;
|
|
74
|
-
tr.setSelection(Selection.near(tr.doc.resolve(placeholderEndPosition)));
|
|
75
|
-
view.dispatch(tr);
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
}]);
|
|
81
|
-
return PlaceholderTextNodeView;
|
|
82
|
-
}();
|
|
@@ -1,259 +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
|
-
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
|
-
decorations: drawFakeTextCursor,
|
|
96
|
-
handleDOMEvents: {
|
|
97
|
-
beforeinput: function beforeinput(view, event) {
|
|
98
|
-
var state = view.state;
|
|
99
|
-
if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && isSelectionAtPlaceholder(view.state.selection)) {
|
|
100
|
-
event.stopPropagation();
|
|
101
|
-
event.preventDefault();
|
|
102
|
-
var startNodePosition = state.selection.from;
|
|
103
|
-
var content = event.data || '';
|
|
104
|
-
var tr = view.state.tr;
|
|
105
|
-
tr.delete(startNodePosition, startNodePosition + 1);
|
|
106
|
-
var openTypeAhead = getOpenTypeAhead(content, api);
|
|
107
|
-
if (openTypeAhead) {
|
|
108
|
-
openTypeAhead(tr);
|
|
109
|
-
} else {
|
|
110
|
-
tr.insertText(content);
|
|
111
|
-
}
|
|
112
|
-
view.dispatch(tr);
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
nodeViews: {
|
|
119
|
-
placeholder: function placeholder(node, view, getPos) {
|
|
120
|
-
return new PlaceholderTextNodeView(node, view, getPos);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function ContentComponent(_ref) {
|
|
127
|
-
var editorView = _ref.editorView,
|
|
128
|
-
dependencyApi = _ref.dependencyApi,
|
|
129
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
130
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement;
|
|
131
|
-
var _useSharedPluginState = useSharedPluginState(dependencyApi, ['placeholderText']),
|
|
132
|
-
placeholderTextState = _useSharedPluginState.placeholderTextState;
|
|
133
|
-
var insertPlaceholderText = function insertPlaceholderText(value) {
|
|
134
|
-
return insertPlaceholderTextAtSelection(value)(editorView.state, editorView.dispatch);
|
|
135
|
-
};
|
|
136
|
-
var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
|
|
137
|
-
return hidePlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
|
|
138
|
-
};
|
|
139
|
-
var getNodeFromPos = function getNodeFromPos(pos) {
|
|
140
|
-
return editorView.domAtPos(pos).node;
|
|
141
|
-
};
|
|
142
|
-
var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
|
|
143
|
-
return editorView.coordsAtPos(pos);
|
|
144
|
-
};
|
|
145
|
-
var setFocusInEditor = function setFocusInEditor() {
|
|
146
|
-
return editorView.focus();
|
|
147
|
-
};
|
|
148
|
-
if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
|
|
149
|
-
return /*#__PURE__*/React.createElement(PlaceholderFloatingToolbar, {
|
|
150
|
-
editorViewDOM: editorView.dom,
|
|
151
|
-
popupsMountPoint: popupsMountPoint,
|
|
152
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
153
|
-
getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
|
|
154
|
-
getNodeFromPos: getNodeFromPos,
|
|
155
|
-
hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
|
|
156
|
-
showInsertPanelAt: placeholderTextState.showInsertPanelAt,
|
|
157
|
-
insertPlaceholder: insertPlaceholderText,
|
|
158
|
-
setFocusInEditor: setFocusInEditor
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref2) {
|
|
164
|
-
var api = _ref2.api,
|
|
165
|
-
options = _ref2.config;
|
|
166
|
-
return {
|
|
167
|
-
name: 'placeholderText',
|
|
168
|
-
nodes: function nodes() {
|
|
169
|
-
return [{
|
|
170
|
-
name: 'placeholder',
|
|
171
|
-
node: placeholder
|
|
172
|
-
}];
|
|
173
|
-
},
|
|
174
|
-
pmPlugins: function pmPlugins() {
|
|
175
|
-
return [{
|
|
176
|
-
name: 'placeholderText',
|
|
177
|
-
plugin: function plugin(_ref3) {
|
|
178
|
-
var dispatch = _ref3.dispatch;
|
|
179
|
-
return createPlugin(dispatch, options, api);
|
|
180
|
-
}
|
|
181
|
-
}];
|
|
182
|
-
},
|
|
183
|
-
getSharedState: function getSharedState(editorState) {
|
|
184
|
-
if (!editorState) {
|
|
185
|
-
return undefined;
|
|
186
|
-
}
|
|
187
|
-
var _ref4 = pluginKey.getState(editorState) || {
|
|
188
|
-
showInsertPanelAt: null
|
|
189
|
-
},
|
|
190
|
-
showInsertPanelAt = _ref4.showInsertPanelAt,
|
|
191
|
-
allowInserting = _ref4.allowInserting;
|
|
192
|
-
return {
|
|
193
|
-
showInsertPanelAt: showInsertPanelAt,
|
|
194
|
-
allowInserting: !!allowInserting
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
contentComponent: function contentComponent(_ref5) {
|
|
198
|
-
var editorView = _ref5.editorView,
|
|
199
|
-
popupsMountPoint = _ref5.popupsMountPoint,
|
|
200
|
-
popupsBoundariesElement = _ref5.popupsBoundariesElement;
|
|
201
|
-
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
202
|
-
editorView: editorView,
|
|
203
|
-
popupsMountPoint: popupsMountPoint,
|
|
204
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
205
|
-
dependencyApi: api
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
211
|
-
if (!options.allowInserting) {
|
|
212
|
-
return plugin;
|
|
213
|
-
}
|
|
214
|
-
plugin.pluginsOptions = {
|
|
215
|
-
quickInsert: function quickInsert(_ref6) {
|
|
216
|
-
var formatMessage = _ref6.formatMessage;
|
|
217
|
-
return [{
|
|
218
|
-
id: 'placeholderText',
|
|
219
|
-
title: formatMessage(messages.placeholderText),
|
|
220
|
-
description: formatMessage(messages.placeholderTextDescription),
|
|
221
|
-
priority: 1400,
|
|
222
|
-
keywords: ['placeholder'],
|
|
223
|
-
icon: function icon() {
|
|
224
|
-
return /*#__PURE__*/React.createElement(MediaServicesTextIcon, {
|
|
225
|
-
label: ""
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
action: function action(insert, state) {
|
|
229
|
-
var _api$analytics;
|
|
230
|
-
var tr = state.tr;
|
|
231
|
-
tr.setMeta(pluginKey, {
|
|
232
|
-
showInsertPanelAt: tr.selection.anchor
|
|
233
|
-
});
|
|
234
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
235
|
-
action: ACTION.INSERTED,
|
|
236
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
237
|
-
actionSubjectId: ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
|
|
238
|
-
attributes: {
|
|
239
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
240
|
-
},
|
|
241
|
-
eventType: EVENT_TYPE.TRACK
|
|
242
|
-
})(tr);
|
|
243
|
-
return tr;
|
|
244
|
-
}
|
|
245
|
-
}];
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
return plugin;
|
|
249
|
-
};
|
|
250
|
-
var placeholderTextPlugin = function placeholderTextPlugin(_ref7) {
|
|
251
|
-
var _ref7$config = _ref7.config,
|
|
252
|
-
options = _ref7$config === void 0 ? {} : _ref7$config,
|
|
253
|
-
api = _ref7.api;
|
|
254
|
-
return decorateWithPluginOptions(basePlaceholderTextPlugin({
|
|
255
|
-
config: options,
|
|
256
|
-
api: api
|
|
257
|
-
}), options, api);
|
|
258
|
-
};
|
|
259
|
-
export default placeholderTextPlugin;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export var isSelectionAtPlaceholder = function isSelectionAtPlaceholder(selection) {
|
|
3
|
-
if (!(selection instanceof TextSelection) || !selection.$cursor) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
var node = selection.$cursor.doc.nodeAt(selection.$cursor.pos);
|
|
7
|
-
return (node === null || node === void 0 ? void 0 : node.type.name) === 'placeholder';
|
|
8
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject;
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { B75, N200 } from '@atlaskit/theme/colors';
|
|
5
|
-
import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
6
|
-
export var placeholderTextStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror span[data-placeholder] {\n color: ", ";\n display: inline;\n }\n\n .ProseMirror span.pm-placeholder {\n display: inline;\n color: ", ";\n }\n .ProseMirror span.pm-placeholder__text {\n display: inline;\n color: ", ";\n }\n\n .ProseMirror span.pm-placeholder.", " {\n ", "\n }\n\n .ProseMirror span.pm-placeholder__text[data-placeholder]::after {\n color: ", ";\n cursor: text;\n content: attr(data-placeholder);\n display: inline;\n }\n\n .ProseMirror {\n .ProseMirror-fake-text-cursor {\n display: inline;\n pointer-events: none;\n position: relative;\n }\n\n .ProseMirror-fake-text-cursor::after {\n content: '';\n display: inline;\n top: 0;\n position: absolute;\n border-right: 1px solid ", ";\n }\n\n .ProseMirror-fake-text-selection {\n display: inline;\n pointer-events: none;\n position: relative;\n background-color: ", ";\n }\n }\n"])), "var(--ds-text-subtlest, ".concat(N200, ")"), "var(--ds-text-subtlest, ".concat(N200, ")"), "var(--ds-text-subtlest, ".concat(N200, ")"), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.Background]), "var(--ds-text-subtlest, ".concat(N200, ")"), "var(--ds-border, rgba(0, 0, 0, 0.4))", "var(--ds-background-selected, ".concat(B75, ")"));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8
|
-
/** @jsx jsx */
|
|
9
|
-
import { jsx } from '@emotion/react';
|
|
10
|
-
import { PureComponent } from 'react';
|
|
11
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { container } from './styles';
|
|
13
|
-
export { handlePositionCalculatedWith, getOffsetParent, getNearestNonTextNode } from './utils';
|
|
14
|
-
var FloatingToolbar = /*#__PURE__*/function (_PureComponent) {
|
|
15
|
-
_inherits(FloatingToolbar, _PureComponent);
|
|
16
|
-
var _super = _createSuper(FloatingToolbar);
|
|
17
|
-
function FloatingToolbar() {
|
|
18
|
-
_classCallCheck(this, FloatingToolbar);
|
|
19
|
-
return _super.apply(this, arguments);
|
|
20
|
-
}
|
|
21
|
-
_createClass(FloatingToolbar, [{
|
|
22
|
-
key: "render",
|
|
23
|
-
value: function render() {
|
|
24
|
-
var _this$props = this.props,
|
|
25
|
-
children = _this$props.children,
|
|
26
|
-
target = _this$props.target,
|
|
27
|
-
offset = _this$props.offset,
|
|
28
|
-
fitWidth = _this$props.fitWidth,
|
|
29
|
-
_this$props$fitHeight = _this$props.fitHeight,
|
|
30
|
-
fitHeight = _this$props$fitHeight === void 0 ? 40 : _this$props$fitHeight,
|
|
31
|
-
onPositionCalculated = _this$props.onPositionCalculated,
|
|
32
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
33
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
34
|
-
className = _this$props.className,
|
|
35
|
-
absoluteOffset = _this$props.absoluteOffset,
|
|
36
|
-
alignX = _this$props.alignX,
|
|
37
|
-
alignY = _this$props.alignY,
|
|
38
|
-
zIndex = _this$props.zIndex;
|
|
39
|
-
if (!target) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return jsx(Popup, {
|
|
43
|
-
absoluteOffset: absoluteOffset,
|
|
44
|
-
alignX: alignX,
|
|
45
|
-
alignY: alignY,
|
|
46
|
-
target: target,
|
|
47
|
-
zIndex: zIndex,
|
|
48
|
-
mountTo: popupsMountPoint,
|
|
49
|
-
boundariesElement: popupsBoundariesElement,
|
|
50
|
-
offset: offset,
|
|
51
|
-
fitWidth: fitWidth,
|
|
52
|
-
fitHeight: fitHeight,
|
|
53
|
-
onPositionCalculated: onPositionCalculated
|
|
54
|
-
}, jsx("div", {
|
|
55
|
-
css: container(fitHeight),
|
|
56
|
-
"data-testid": "popup-container",
|
|
57
|
-
className: className
|
|
58
|
-
}, children));
|
|
59
|
-
}
|
|
60
|
-
}]);
|
|
61
|
-
return FloatingToolbar;
|
|
62
|
-
}(PureComponent);
|
|
63
|
-
export { FloatingToolbar as default };
|