@atlaskit/editor-core 189.1.12 → 189.1.15
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 +13 -0
- package/dist/cjs/i18n/cs.js +0 -1
- package/dist/cjs/i18n/da.js +0 -1
- package/dist/cjs/i18n/de.js +0 -1
- package/dist/cjs/i18n/en.js +0 -1
- package/dist/cjs/i18n/en_GB.js +0 -1
- package/dist/cjs/i18n/en_ZZ.js +0 -1
- package/dist/cjs/i18n/es.js +0 -1
- package/dist/cjs/i18n/fi.js +0 -1
- package/dist/cjs/i18n/fr.js +0 -1
- package/dist/cjs/i18n/hu.js +0 -1
- package/dist/cjs/i18n/it.js +0 -1
- package/dist/cjs/i18n/ja.js +0 -1
- package/dist/cjs/i18n/ko.js +0 -1
- package/dist/cjs/i18n/nb.js +0 -1
- package/dist/cjs/i18n/nl.js +0 -1
- package/dist/cjs/i18n/pl.js +0 -1
- package/dist/cjs/i18n/pt_BR.js +0 -1
- package/dist/cjs/i18n/ru.js +0 -1
- package/dist/cjs/i18n/sv.js +0 -1
- package/dist/cjs/i18n/th.js +0 -1
- package/dist/cjs/i18n/tr.js +0 -1
- package/dist/cjs/i18n/uk.js +0 -1
- package/dist/cjs/i18n/vi.js +0 -1
- package/dist/cjs/i18n/zh.js +0 -1
- package/dist/cjs/i18n/zh_TW.js +0 -1
- package/dist/cjs/plugins/index.js +0 -7
- 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/plugins/panel/actions.js +11 -11
- package/dist/cjs/plugins/panel/index.js +4 -4
- package/dist/cjs/plugins/panel/nodeviews/panel.js +5 -5
- package/dist/cjs/plugins/panel/pm-plugins/keymaps.js +7 -7
- package/dist/cjs/plugins/panel/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/panel/toolbar.js +16 -16
- package/dist/cjs/plugins/panel/utils.js +1 -1
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/ui/ContentStyles/index.js +7 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/i18n/cs.js +0 -1
- package/dist/es2019/i18n/da.js +0 -1
- package/dist/es2019/i18n/de.js +0 -1
- package/dist/es2019/i18n/en.js +0 -1
- package/dist/es2019/i18n/en_GB.js +0 -1
- package/dist/es2019/i18n/en_ZZ.js +0 -1
- package/dist/es2019/i18n/es.js +0 -1
- package/dist/es2019/i18n/fi.js +0 -1
- package/dist/es2019/i18n/fr.js +0 -1
- package/dist/es2019/i18n/hu.js +0 -1
- package/dist/es2019/i18n/it.js +0 -1
- package/dist/es2019/i18n/ja.js +0 -1
- package/dist/es2019/i18n/ko.js +0 -1
- package/dist/es2019/i18n/nb.js +0 -1
- package/dist/es2019/i18n/nl.js +0 -1
- package/dist/es2019/i18n/pl.js +0 -1
- package/dist/es2019/i18n/pt_BR.js +0 -1
- package/dist/es2019/i18n/ru.js +0 -1
- package/dist/es2019/i18n/sv.js +0 -1
- package/dist/es2019/i18n/th.js +0 -1
- package/dist/es2019/i18n/tr.js +0 -1
- package/dist/es2019/i18n/uk.js +0 -1
- package/dist/es2019/i18n/vi.js +0 -1
- package/dist/es2019/i18n/zh.js +0 -1
- package/dist/es2019/i18n/zh_TW.js +0 -1
- package/dist/es2019/plugins/index.js +0 -1
- 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/plugins/panel/actions.js +5 -5
- package/dist/es2019/plugins/panel/index.js +6 -6
- package/dist/es2019/plugins/panel/nodeviews/panel.js +5 -5
- package/dist/es2019/plugins/panel/pm-plugins/keymaps.js +2 -2
- package/dist/es2019/plugins/panel/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/panel/toolbar.js +12 -13
- package/dist/es2019/plugins/panel/utils.js +1 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/ui/ContentStyles/index.js +2 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/i18n/cs.js +0 -1
- package/dist/esm/i18n/da.js +0 -1
- package/dist/esm/i18n/de.js +0 -1
- package/dist/esm/i18n/en.js +0 -1
- package/dist/esm/i18n/en_GB.js +0 -1
- package/dist/esm/i18n/en_ZZ.js +0 -1
- package/dist/esm/i18n/es.js +0 -1
- package/dist/esm/i18n/fi.js +0 -1
- package/dist/esm/i18n/fr.js +0 -1
- package/dist/esm/i18n/hu.js +0 -1
- package/dist/esm/i18n/it.js +0 -1
- package/dist/esm/i18n/ja.js +0 -1
- package/dist/esm/i18n/ko.js +0 -1
- package/dist/esm/i18n/nb.js +0 -1
- package/dist/esm/i18n/nl.js +0 -1
- package/dist/esm/i18n/pl.js +0 -1
- package/dist/esm/i18n/pt_BR.js +0 -1
- package/dist/esm/i18n/ru.js +0 -1
- package/dist/esm/i18n/sv.js +0 -1
- package/dist/esm/i18n/th.js +0 -1
- package/dist/esm/i18n/tr.js +0 -1
- package/dist/esm/i18n/uk.js +0 -1
- package/dist/esm/i18n/vi.js +0 -1
- package/dist/esm/i18n/zh.js +0 -1
- package/dist/esm/i18n/zh_TW.js +0 -1
- package/dist/esm/plugins/index.js +0 -1
- 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/plugins/panel/actions.js +5 -5
- package/dist/esm/plugins/panel/index.js +6 -6
- package/dist/esm/plugins/panel/nodeviews/panel.js +5 -5
- package/dist/esm/plugins/panel/pm-plugins/keymaps.js +2 -2
- package/dist/esm/plugins/panel/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/panel/toolbar.js +12 -13
- package/dist/esm/plugins/panel/utils.js +1 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/ui/ContentStyles/index.js +2 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/i18n/cs.d.ts +0 -1
- package/dist/types/i18n/da.d.ts +0 -1
- package/dist/types/i18n/de.d.ts +0 -1
- package/dist/types/i18n/en.d.ts +0 -1
- package/dist/types/i18n/en_GB.d.ts +0 -1
- package/dist/types/i18n/en_ZZ.d.ts +0 -1
- package/dist/types/i18n/es.d.ts +0 -1
- package/dist/types/i18n/fi.d.ts +0 -1
- package/dist/types/i18n/fr.d.ts +0 -1
- package/dist/types/i18n/hu.d.ts +0 -1
- package/dist/types/i18n/it.d.ts +0 -1
- package/dist/types/i18n/ja.d.ts +0 -1
- package/dist/types/i18n/ko.d.ts +0 -1
- package/dist/types/i18n/nb.d.ts +0 -1
- package/dist/types/i18n/nl.d.ts +0 -1
- package/dist/types/i18n/pl.d.ts +0 -1
- package/dist/types/i18n/pt_BR.d.ts +0 -1
- package/dist/types/i18n/ru.d.ts +0 -1
- package/dist/types/i18n/sv.d.ts +0 -1
- package/dist/types/i18n/th.d.ts +0 -1
- package/dist/types/i18n/tr.d.ts +0 -1
- package/dist/types/i18n/uk.d.ts +0 -1
- package/dist/types/i18n/vi.d.ts +0 -1
- package/dist/types/i18n/zh.d.ts +0 -1
- package/dist/types/i18n/zh_TW.d.ts +0 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +3 -1
- package/dist/types/plugins/panel/actions.d.ts +2 -2
- package/dist/types/plugins/panel/index.d.ts +3 -3
- package/dist/types/plugins/panel/nodeviews/panel.d.ts +3 -3
- package/dist/types/plugins/panel/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/panel/toolbar.d.ts +6 -7
- package/dist/types/plugins/panel/types.d.ts +1 -1
- package/dist/types/plugins/panel/utils.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types/{plugins/panel/styles.d.ts → ui/ContentStyles/panel.d.ts} +1 -1
- package/dist/types-ts4.5/i18n/cs.d.ts +0 -1
- package/dist/types-ts4.5/i18n/da.d.ts +0 -1
- package/dist/types-ts4.5/i18n/de.d.ts +0 -1
- package/dist/types-ts4.5/i18n/en.d.ts +0 -1
- package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -1
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -1
- package/dist/types-ts4.5/i18n/es.d.ts +0 -1
- package/dist/types-ts4.5/i18n/fi.d.ts +0 -1
- package/dist/types-ts4.5/i18n/fr.d.ts +0 -1
- package/dist/types-ts4.5/i18n/hu.d.ts +0 -1
- package/dist/types-ts4.5/i18n/it.d.ts +0 -1
- package/dist/types-ts4.5/i18n/ja.d.ts +0 -1
- package/dist/types-ts4.5/i18n/ko.d.ts +0 -1
- package/dist/types-ts4.5/i18n/nb.d.ts +0 -1
- package/dist/types-ts4.5/i18n/nl.d.ts +0 -1
- package/dist/types-ts4.5/i18n/pl.d.ts +0 -1
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -1
- package/dist/types-ts4.5/i18n/ru.d.ts +0 -1
- package/dist/types-ts4.5/i18n/sv.d.ts +0 -1
- package/dist/types-ts4.5/i18n/th.d.ts +0 -1
- package/dist/types-ts4.5/i18n/tr.d.ts +0 -1
- package/dist/types-ts4.5/i18n/uk.d.ts +0 -1
- package/dist/types-ts4.5/i18n/vi.d.ts +0 -1
- package/dist/types-ts4.5/i18n/zh.d.ts +0 -1
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
- package/dist/types-ts4.5/plugins/panel/actions.d.ts +2 -2
- package/dist/types-ts4.5/plugins/panel/index.d.ts +3 -3
- package/dist/types-ts4.5/plugins/panel/nodeviews/panel.d.ts +3 -3
- package/dist/types-ts4.5/plugins/panel/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +6 -7
- package/dist/types-ts4.5/plugins/panel/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/panel/utils.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types-ts4.5/{plugins/panel/styles.d.ts → ui/ContentStyles/panel.d.ts} +1 -1
- package/package.json +4 -3
- package/report.api.md +1 -6
- package/tmp/api-report-tmp.d.ts +1 -6
- 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/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/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/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/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
- /package/dist/cjs/{plugins/panel/styles.js → ui/ContentStyles/panel.js} +0 -0
- /package/dist/es2019/{plugins/panel/styles.js → ui/ContentStyles/panel.js} +0 -0
- /package/dist/esm/{plugins/panel/styles.js → ui/ContentStyles/panel.js} +0 -0
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createPlugin = createPlugin;
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
|
-
var _text = _interopRequireDefault(require("@atlaskit/icon/glyph/media-services/text"));
|
|
14
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
-
var _cursor = require("./fake-text-cursor/cursor");
|
|
17
|
-
var _PlaceholderFloatingToolbar = _interopRequireDefault(require("./ui/PlaceholderFloatingToolbar"));
|
|
18
|
-
var _actions = require("./actions");
|
|
19
|
-
var _placeholderTextNodeview = require("./placeholder-text-nodeview");
|
|
20
|
-
var _pluginKey = require("./plugin-key");
|
|
21
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
22
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
23
|
-
var _selectionUtils = require("./selection-utils");
|
|
24
|
-
var getOpenTypeAhead = function getOpenTypeAhead(trigger, api) {
|
|
25
|
-
var _api$typeAhead, _api$typeAhead2;
|
|
26
|
-
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);
|
|
27
|
-
if (!typeAheadHandler || !typeAheadHandler.id) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
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({
|
|
31
|
-
triggerHandler: typeAheadHandler,
|
|
32
|
-
inputMethod: _analytics.INPUT_METHOD.KEYBOARD
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
function createPlugin(dispatch, options, api) {
|
|
36
|
-
var allowInserting = !!options.allowInserting;
|
|
37
|
-
return new _safePlugin.SafePlugin({
|
|
38
|
-
key: _pluginKey.pluginKey,
|
|
39
|
-
state: {
|
|
40
|
-
init: function init() {
|
|
41
|
-
return {
|
|
42
|
-
showInsertPanelAt: null,
|
|
43
|
-
allowInserting: allowInserting
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
apply: function apply(tr, state) {
|
|
47
|
-
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
48
|
-
if (meta && meta.showInsertPanelAt !== undefined) {
|
|
49
|
-
var newState = {
|
|
50
|
-
showInsertPanelAt: meta.showInsertPanelAt,
|
|
51
|
-
allowInserting: allowInserting
|
|
52
|
-
};
|
|
53
|
-
dispatch(_pluginKey.pluginKey, newState);
|
|
54
|
-
return newState;
|
|
55
|
-
} else if (state.showInsertPanelAt) {
|
|
56
|
-
var _newState = {
|
|
57
|
-
showInsertPanelAt: tr.mapping.map(state.showInsertPanelAt),
|
|
58
|
-
allowInserting: allowInserting
|
|
59
|
-
};
|
|
60
|
-
dispatch(_pluginKey.pluginKey, _newState);
|
|
61
|
-
return _newState;
|
|
62
|
-
}
|
|
63
|
-
return state;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
67
|
-
if (transactions.some(function (txn) {
|
|
68
|
-
return txn.docChanged;
|
|
69
|
-
})) {
|
|
70
|
-
var didPlaceholderExistBeforeTxn = oldState.selection.$head.nodeAfter === newState.selection.$head.nodeAfter;
|
|
71
|
-
var adjacentNode = newState.selection.$head.nodeAfter;
|
|
72
|
-
var adjacentNodePos = newState.selection.$head.pos;
|
|
73
|
-
var placeholderNodeType = newState.schema.nodes.placeholder;
|
|
74
|
-
if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
|
|
75
|
-
var _$newHead$nodeBefore;
|
|
76
|
-
var $newHead = newState.selection.$head;
|
|
77
|
-
var $oldHead = oldState.selection.$head;
|
|
78
|
-
// Check that cursor has moved forward in the document **and** that there is content before the cursor
|
|
79
|
-
var cursorMoved = $oldHead.pos < $newHead.pos;
|
|
80
|
-
var nodeBeforeHasContent = !(0, _utils.isNodeEmpty)($newHead.nodeBefore);
|
|
81
|
-
var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
|
|
82
|
-
if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
|
|
83
|
-
var _NodeSelection$create = _state.NodeSelection.create(newState.doc, adjacentNodePos),
|
|
84
|
-
$from = _NodeSelection$create.$from,
|
|
85
|
-
$to = _NodeSelection$create.$to;
|
|
86
|
-
return newState.tr.deleteRange($from.pos, $to.pos);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Handle Fake Text Cursor for Floating Toolbar
|
|
92
|
-
if (!_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && _pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
|
|
93
|
-
return newState.tr.setSelection(new _cursor.FakeTextCursorSelection(newState.selection.$from));
|
|
94
|
-
}
|
|
95
|
-
if (_pluginKey.pluginKey.getState(oldState).showInsertPanelAt && !_pluginKey.pluginKey.getState(newState).showInsertPanelAt) {
|
|
96
|
-
if (newState.selection instanceof _cursor.FakeTextCursorSelection) {
|
|
97
|
-
return newState.tr.setSelection(new _state.TextSelection(newState.selection.$from));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return;
|
|
101
|
-
},
|
|
102
|
-
props: {
|
|
103
|
-
decorations: _cursor.drawFakeTextCursor,
|
|
104
|
-
handleDOMEvents: {
|
|
105
|
-
beforeinput: function beforeinput(view, event) {
|
|
106
|
-
var state = view.state;
|
|
107
|
-
if (event instanceof InputEvent && !event.isComposing && event.inputType === 'insertText' && (0, _selectionUtils.isSelectionAtPlaceholder)(view.state.selection)) {
|
|
108
|
-
event.stopPropagation();
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
var startNodePosition = state.selection.from;
|
|
111
|
-
var content = event.data || '';
|
|
112
|
-
var tr = view.state.tr;
|
|
113
|
-
tr.delete(startNodePosition, startNodePosition + 1);
|
|
114
|
-
var openTypeAhead = getOpenTypeAhead(content, api);
|
|
115
|
-
if (openTypeAhead) {
|
|
116
|
-
openTypeAhead(tr);
|
|
117
|
-
} else {
|
|
118
|
-
tr.insertText(content);
|
|
119
|
-
}
|
|
120
|
-
view.dispatch(tr);
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
nodeViews: {
|
|
127
|
-
placeholder: function placeholder(node, view, getPos) {
|
|
128
|
-
return new _placeholderTextNodeview.PlaceholderTextNodeView(node, view, getPos);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function ContentComponent(_ref) {
|
|
135
|
-
var editorView = _ref.editorView,
|
|
136
|
-
dependencyApi = _ref.dependencyApi,
|
|
137
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
138
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement;
|
|
139
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(dependencyApi, ['placeholderText']),
|
|
140
|
-
placeholderTextState = _useSharedPluginState.placeholderTextState;
|
|
141
|
-
var insertPlaceholderText = function insertPlaceholderText(value) {
|
|
142
|
-
return (0, _actions.insertPlaceholderTextAtSelection)(value)(editorView.state, editorView.dispatch);
|
|
143
|
-
};
|
|
144
|
-
var hidePlaceholderToolbar = function hidePlaceholderToolbar() {
|
|
145
|
-
return (0, _actions.hidePlaceholderFloatingToolbar)(editorView.state, editorView.dispatch);
|
|
146
|
-
};
|
|
147
|
-
var getNodeFromPos = function getNodeFromPos(pos) {
|
|
148
|
-
return editorView.domAtPos(pos).node;
|
|
149
|
-
};
|
|
150
|
-
var getFixedCoordinatesFromPos = function getFixedCoordinatesFromPos(pos) {
|
|
151
|
-
return editorView.coordsAtPos(pos);
|
|
152
|
-
};
|
|
153
|
-
var setFocusInEditor = function setFocusInEditor() {
|
|
154
|
-
return editorView.focus();
|
|
155
|
-
};
|
|
156
|
-
if (placeholderTextState !== null && placeholderTextState !== void 0 && placeholderTextState.showInsertPanelAt) {
|
|
157
|
-
return /*#__PURE__*/_react.default.createElement(_PlaceholderFloatingToolbar.default, {
|
|
158
|
-
editorViewDOM: editorView.dom,
|
|
159
|
-
popupsMountPoint: popupsMountPoint,
|
|
160
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
161
|
-
getFixedCoordinatesFromPos: getFixedCoordinatesFromPos,
|
|
162
|
-
getNodeFromPos: getNodeFromPos,
|
|
163
|
-
hidePlaceholderFloatingToolbar: hidePlaceholderToolbar,
|
|
164
|
-
showInsertPanelAt: placeholderTextState.showInsertPanelAt,
|
|
165
|
-
insertPlaceholder: insertPlaceholderText,
|
|
166
|
-
setFocusInEditor: setFocusInEditor
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
var basePlaceholderTextPlugin = function basePlaceholderTextPlugin(_ref2) {
|
|
172
|
-
var api = _ref2.api,
|
|
173
|
-
options = _ref2.config;
|
|
174
|
-
return {
|
|
175
|
-
name: 'placeholderText',
|
|
176
|
-
nodes: function nodes() {
|
|
177
|
-
return [{
|
|
178
|
-
name: 'placeholder',
|
|
179
|
-
node: _adfSchema.placeholder
|
|
180
|
-
}];
|
|
181
|
-
},
|
|
182
|
-
pmPlugins: function pmPlugins() {
|
|
183
|
-
return [{
|
|
184
|
-
name: 'placeholderText',
|
|
185
|
-
plugin: function plugin(_ref3) {
|
|
186
|
-
var dispatch = _ref3.dispatch;
|
|
187
|
-
return createPlugin(dispatch, options, api);
|
|
188
|
-
}
|
|
189
|
-
}];
|
|
190
|
-
},
|
|
191
|
-
getSharedState: function getSharedState(editorState) {
|
|
192
|
-
if (!editorState) {
|
|
193
|
-
return undefined;
|
|
194
|
-
}
|
|
195
|
-
var _ref4 = _pluginKey.pluginKey.getState(editorState) || {
|
|
196
|
-
showInsertPanelAt: null
|
|
197
|
-
},
|
|
198
|
-
showInsertPanelAt = _ref4.showInsertPanelAt,
|
|
199
|
-
allowInserting = _ref4.allowInserting;
|
|
200
|
-
return {
|
|
201
|
-
showInsertPanelAt: showInsertPanelAt,
|
|
202
|
-
allowInserting: !!allowInserting
|
|
203
|
-
};
|
|
204
|
-
},
|
|
205
|
-
contentComponent: function contentComponent(_ref5) {
|
|
206
|
-
var editorView = _ref5.editorView,
|
|
207
|
-
popupsMountPoint = _ref5.popupsMountPoint,
|
|
208
|
-
popupsBoundariesElement = _ref5.popupsBoundariesElement;
|
|
209
|
-
return /*#__PURE__*/_react.default.createElement(ContentComponent, {
|
|
210
|
-
editorView: editorView,
|
|
211
|
-
popupsMountPoint: popupsMountPoint,
|
|
212
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
213
|
-
dependencyApi: api
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
219
|
-
if (!options.allowInserting) {
|
|
220
|
-
return plugin;
|
|
221
|
-
}
|
|
222
|
-
plugin.pluginsOptions = {
|
|
223
|
-
quickInsert: function quickInsert(_ref6) {
|
|
224
|
-
var formatMessage = _ref6.formatMessage;
|
|
225
|
-
return [{
|
|
226
|
-
id: 'placeholderText',
|
|
227
|
-
title: formatMessage(_messages.toolbarInsertBlockMessages.placeholderText),
|
|
228
|
-
description: formatMessage(_messages.toolbarInsertBlockMessages.placeholderTextDescription),
|
|
229
|
-
priority: 1400,
|
|
230
|
-
keywords: ['placeholder'],
|
|
231
|
-
icon: function icon() {
|
|
232
|
-
return /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
233
|
-
label: ""
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
action: function action(insert, state) {
|
|
237
|
-
var _api$analytics;
|
|
238
|
-
var tr = state.tr;
|
|
239
|
-
tr.setMeta(_pluginKey.pluginKey, {
|
|
240
|
-
showInsertPanelAt: tr.selection.anchor
|
|
241
|
-
});
|
|
242
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
243
|
-
action: _analytics.ACTION.INSERTED,
|
|
244
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
245
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PLACEHOLDER_TEXT,
|
|
246
|
-
attributes: {
|
|
247
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
248
|
-
},
|
|
249
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
250
|
-
})(tr);
|
|
251
|
-
return tr;
|
|
252
|
-
}
|
|
253
|
-
}];
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
return plugin;
|
|
257
|
-
};
|
|
258
|
-
var placeholderTextPlugin = function placeholderTextPlugin(_ref7) {
|
|
259
|
-
var _ref7$config = _ref7.config,
|
|
260
|
-
options = _ref7$config === void 0 ? {} : _ref7$config,
|
|
261
|
-
api = _ref7.api;
|
|
262
|
-
return decorateWithPluginOptions(basePlaceholderTextPlugin({
|
|
263
|
-
config: options,
|
|
264
|
-
api: api
|
|
265
|
-
}), options, api);
|
|
266
|
-
};
|
|
267
|
-
var _default = exports.default = placeholderTextPlugin;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSelectionAtPlaceholder = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var isSelectionAtPlaceholder = exports.isSelectionAtPlaceholder = function isSelectionAtPlaceholder(selection) {
|
|
9
|
-
if (!(selection instanceof _state.TextSelection) || !selection.$cursor) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
var node = selection.$cursor.doc.nodeAt(selection.$cursor.pos);
|
|
13
|
-
return (node === null || node === void 0 ? void 0 : node.type.name) === 'placeholder';
|
|
14
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.placeholderTextStyles = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
11
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
-
var _templateObject;
|
|
13
|
-
var placeholderTextStyles = exports.placeholderTextStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\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(_colors.N200, ")"), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), _editorSharedStyles.akEditorSelectedNodeClassName, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.Background]), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), "var(--ds-border, rgba(0, 0, 0, 0.4))", "var(--ds-background-selected, ".concat(_colors.B75, ")"));
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
Object.defineProperty(exports, "getNearestNonTextNode", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _utils.getNearestNonTextNode;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "getOffsetParent", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function get() {
|
|
17
|
-
return _utils.getOffsetParent;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "handlePositionCalculatedWith", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function get() {
|
|
23
|
-
return _utils.handlePositionCalculatedWith;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
27
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
28
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
29
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
30
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
31
|
-
var _react = require("@emotion/react");
|
|
32
|
-
var _react2 = require("react");
|
|
33
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
34
|
-
var _styles = require("./styles");
|
|
35
|
-
var _utils = require("./utils");
|
|
36
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
37
|
-
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; } } /** @jsx jsx */
|
|
38
|
-
var FloatingToolbar = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
39
|
-
(0, _inherits2.default)(FloatingToolbar, _PureComponent);
|
|
40
|
-
var _super = _createSuper(FloatingToolbar);
|
|
41
|
-
function FloatingToolbar() {
|
|
42
|
-
(0, _classCallCheck2.default)(this, FloatingToolbar);
|
|
43
|
-
return _super.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
(0, _createClass2.default)(FloatingToolbar, [{
|
|
46
|
-
key: "render",
|
|
47
|
-
value: function render() {
|
|
48
|
-
var _this$props = this.props,
|
|
49
|
-
children = _this$props.children,
|
|
50
|
-
target = _this$props.target,
|
|
51
|
-
offset = _this$props.offset,
|
|
52
|
-
fitWidth = _this$props.fitWidth,
|
|
53
|
-
_this$props$fitHeight = _this$props.fitHeight,
|
|
54
|
-
fitHeight = _this$props$fitHeight === void 0 ? 40 : _this$props$fitHeight,
|
|
55
|
-
onPositionCalculated = _this$props.onPositionCalculated,
|
|
56
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
57
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
58
|
-
className = _this$props.className,
|
|
59
|
-
absoluteOffset = _this$props.absoluteOffset,
|
|
60
|
-
alignX = _this$props.alignX,
|
|
61
|
-
alignY = _this$props.alignY,
|
|
62
|
-
zIndex = _this$props.zIndex;
|
|
63
|
-
if (!target) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return (0, _react.jsx)(_ui.Popup, {
|
|
67
|
-
absoluteOffset: absoluteOffset,
|
|
68
|
-
alignX: alignX,
|
|
69
|
-
alignY: alignY,
|
|
70
|
-
target: target,
|
|
71
|
-
zIndex: zIndex,
|
|
72
|
-
mountTo: popupsMountPoint,
|
|
73
|
-
boundariesElement: popupsBoundariesElement,
|
|
74
|
-
offset: offset,
|
|
75
|
-
fitWidth: fitWidth,
|
|
76
|
-
fitHeight: fitHeight,
|
|
77
|
-
onPositionCalculated: onPositionCalculated
|
|
78
|
-
}, (0, _react.jsx)("div", {
|
|
79
|
-
css: (0, _styles.container)(fitHeight),
|
|
80
|
-
"data-testid": "popup-container",
|
|
81
|
-
className: className
|
|
82
|
-
}, children));
|
|
83
|
-
}
|
|
84
|
-
}]);
|
|
85
|
-
return FloatingToolbar;
|
|
86
|
-
}(_react2.PureComponent);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.container = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
11
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
12
|
-
var _templateObject, _templateObject2;
|
|
13
|
-
var container = exports.container = function container(height) {
|
|
14
|
-
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n border-radius: ", "px;\n box-shadow: ", ";\n display: flex;\n align-items: center;\n box-sizing: border-box;\n padding: ", " ", ";\n background-color: ", ";\n ", ";\n"])), (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 12px 24px -6px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"), "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)", "var(--ds-background-input, ".concat(_colors.N0, ")"), height ? (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n height: ", "px;\n "])), height) : '');
|
|
15
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handlePositionCalculatedWith = exports.getOffsetParent = exports.getNearestNonTextNode = void 0;
|
|
7
|
-
var getCursorHeightFrom = function getCursorHeightFrom(node) {
|
|
8
|
-
return parseFloat(window.getComputedStyle(node, undefined).lineHeight || '');
|
|
9
|
-
};
|
|
10
|
-
var getOffsetParent = exports.getOffsetParent = function getOffsetParent(editorViewDom, popupsMountPoint) {
|
|
11
|
-
return popupsMountPoint ? popupsMountPoint.offsetParent : editorViewDom.offsetParent;
|
|
12
|
-
};
|
|
13
|
-
var getNearestNonTextNode = exports.getNearestNonTextNode = function getNearestNonTextNode(node) {
|
|
14
|
-
return node.nodeType === Node.TEXT_NODE ? node.parentNode : node;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* We need to translate the co-ordinates because `coordsAtPos` returns co-ordinates
|
|
19
|
-
* relative to `window`. And, also need to adjust the cursor container height.
|
|
20
|
-
* (0, 0)
|
|
21
|
-
* +--------------------- [window] ---------------------+
|
|
22
|
-
* | (left, top) +-------- [Offset Parent] --------+ |
|
|
23
|
-
* | {coordsAtPos} | [Cursor] <- cursorHeight | |
|
|
24
|
-
* | | [FloatingToolbar] | |
|
|
25
|
-
*/
|
|
26
|
-
var convertFixedCoordinatesToAbsolutePositioning = function convertFixedCoordinatesToAbsolutePositioning(coordinates, offsetParent, cursorHeight) {
|
|
27
|
-
var _offsetParent$getBoun = offsetParent.getBoundingClientRect(),
|
|
28
|
-
offsetParentLeft = _offsetParent$getBoun.left,
|
|
29
|
-
offsetParentTop = _offsetParent$getBoun.top,
|
|
30
|
-
offsetParentHeight = _offsetParent$getBoun.height;
|
|
31
|
-
return {
|
|
32
|
-
left: coordinates.left - offsetParentLeft,
|
|
33
|
-
right: coordinates.right - offsetParentLeft,
|
|
34
|
-
top: coordinates.top - (offsetParentTop - cursorHeight) + offsetParent.scrollTop,
|
|
35
|
-
bottom: offsetParentHeight - (coordinates.top - (offsetParentTop - cursorHeight) - offsetParent.scrollTop)
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
var handlePositionCalculatedWith = exports.handlePositionCalculatedWith = function handlePositionCalculatedWith(offsetParent, node, getCurrentFixedCoordinates) {
|
|
39
|
-
return function (position) {
|
|
40
|
-
if (!offsetParent) {
|
|
41
|
-
return position;
|
|
42
|
-
}
|
|
43
|
-
var target = getNearestNonTextNode(node);
|
|
44
|
-
var cursorHeight = getCursorHeightFrom(target);
|
|
45
|
-
var fixedCoordinates = getCurrentFixedCoordinates();
|
|
46
|
-
var absoluteCoordinates = convertFixedCoordinatesToAbsolutePositioning(fixedCoordinates, offsetParent, cursorHeight);
|
|
47
|
-
return {
|
|
48
|
-
left: position.left ? absoluteCoordinates.left : undefined,
|
|
49
|
-
right: position.right ? absoluteCoordinates.right : undefined,
|
|
50
|
-
top: position.top ? absoluteCoordinates.top : undefined,
|
|
51
|
-
bottom: position.bottom ? absoluteCoordinates.bottom : undefined
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.messages = exports.default = void 0;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _reactIntlNext = require("react-intl-next");
|
|
18
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
|
-
var _FloatingToolbar = _interopRequireWildcard(require("../FloatingToolbar"));
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
23
|
-
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; } }
|
|
24
|
-
var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
|
|
25
|
-
placeholderTextPlaceholder: {
|
|
26
|
-
id: 'fabric.editor.placeholderTextPlaceholder',
|
|
27
|
-
defaultMessage: 'Add placeholder text',
|
|
28
|
-
description: ''
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
var PlaceholderFloatingToolbar = /*#__PURE__*/function (_React$Component) {
|
|
32
|
-
(0, _inherits2.default)(PlaceholderFloatingToolbar, _React$Component);
|
|
33
|
-
var _super = _createSuper(PlaceholderFloatingToolbar);
|
|
34
|
-
function PlaceholderFloatingToolbar() {
|
|
35
|
-
var _this;
|
|
36
|
-
(0, _classCallCheck2.default)(this, PlaceholderFloatingToolbar);
|
|
37
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
-
args[_key] = arguments[_key];
|
|
39
|
-
}
|
|
40
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSubmit", function (value) {
|
|
42
|
-
if (value) {
|
|
43
|
-
_this.props.insertPlaceholder(value);
|
|
44
|
-
_this.props.setFocusInEditor();
|
|
45
|
-
} else {
|
|
46
|
-
_this.props.hidePlaceholderFloatingToolbar();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleBlur", function () {
|
|
50
|
-
_this.props.hidePlaceholderFloatingToolbar();
|
|
51
|
-
});
|
|
52
|
-
return _this;
|
|
53
|
-
}
|
|
54
|
-
(0, _createClass2.default)(PlaceholderFloatingToolbar, [{
|
|
55
|
-
key: "render",
|
|
56
|
-
value: function render() {
|
|
57
|
-
var _this$props = this.props,
|
|
58
|
-
getNodeFromPos = _this$props.getNodeFromPos,
|
|
59
|
-
showInsertPanelAt = _this$props.showInsertPanelAt,
|
|
60
|
-
editorViewDOM = _this$props.editorViewDOM,
|
|
61
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
62
|
-
getFixedCoordinatesFromPos = _this$props.getFixedCoordinatesFromPos,
|
|
63
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
64
|
-
formatMessage = _this$props.intl.formatMessage;
|
|
65
|
-
var target = getNodeFromPos(showInsertPanelAt);
|
|
66
|
-
var offsetParent = (0, _FloatingToolbar.getOffsetParent)(editorViewDOM, popupsMountPoint);
|
|
67
|
-
var getFixedCoordinates = function getFixedCoordinates() {
|
|
68
|
-
return getFixedCoordinatesFromPos(showInsertPanelAt);
|
|
69
|
-
};
|
|
70
|
-
var handlePositionCalculated = (0, _FloatingToolbar.handlePositionCalculatedWith)(offsetParent, target, getFixedCoordinates);
|
|
71
|
-
return /*#__PURE__*/_react.default.createElement(_FloatingToolbar.default, {
|
|
72
|
-
target: (0, _FloatingToolbar.getNearestNonTextNode)(target),
|
|
73
|
-
onPositionCalculated: handlePositionCalculated,
|
|
74
|
-
popupsMountPoint: popupsMountPoint,
|
|
75
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
76
|
-
fitHeight: 32,
|
|
77
|
-
offset: [0, 12]
|
|
78
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.PanelTextInput, {
|
|
79
|
-
placeholder: formatMessage(messages.placeholderTextPlaceholder),
|
|
80
|
-
onSubmit: this.handleSubmit,
|
|
81
|
-
onBlur: this.handleBlur,
|
|
82
|
-
autoFocus: true,
|
|
83
|
-
width: 300
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
}]);
|
|
87
|
-
return PlaceholderFloatingToolbar;
|
|
88
|
-
}(_react.default.Component);
|
|
89
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(PlaceholderFloatingToolbar);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { pluginKey } from './plugin-key';
|
|
2
|
-
export const showPlaceholderFloatingToolbar = (state, dispatch) => {
|
|
3
|
-
const 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 const insertPlaceholderTextAtSelection = value => (state, dispatch) => {
|
|
15
|
-
dispatch(state.tr.replaceSelectionWith(state.schema.nodes.placeholder.createChecked({
|
|
16
|
-
text: value
|
|
17
|
-
})).setMeta(pluginKey, {
|
|
18
|
-
showInsertPanelAt: null
|
|
19
|
-
}).scrollIntoView());
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
export const hidePlaceholderFloatingToolbar = (state, dispatch) => {
|
|
23
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
24
|
-
showInsertPanelAt: null
|
|
25
|
-
}));
|
|
26
|
-
return true;
|
|
27
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
export class FakeTextCursorBookmark {
|
|
6
|
-
constructor(pos) {
|
|
7
|
-
_defineProperty(this, "pos", undefined);
|
|
8
|
-
_defineProperty(this, "visible", false);
|
|
9
|
-
this.pos = pos;
|
|
10
|
-
}
|
|
11
|
-
map(mapping) {
|
|
12
|
-
return new FakeTextCursorBookmark(mapping.map(this.pos));
|
|
13
|
-
}
|
|
14
|
-
resolve(doc) {
|
|
15
|
-
const $pos = doc.resolve(this.pos);
|
|
16
|
-
return Selection.near($pos);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export class FakeTextCursorSelection extends Selection {
|
|
20
|
-
constructor($pos) {
|
|
21
|
-
super($pos, $pos);
|
|
22
|
-
}
|
|
23
|
-
map(doc, mapping) {
|
|
24
|
-
const $pos = doc.resolve(mapping.map(this.$head.pos));
|
|
25
|
-
return new FakeTextCursorSelection($pos);
|
|
26
|
-
}
|
|
27
|
-
static content() {
|
|
28
|
-
return Slice.empty;
|
|
29
|
-
}
|
|
30
|
-
eq(other) {
|
|
31
|
-
return other instanceof FakeTextCursorSelection && other.head === this.head;
|
|
32
|
-
}
|
|
33
|
-
toJSON() {
|
|
34
|
-
return {
|
|
35
|
-
type: 'Cursor',
|
|
36
|
-
pos: this.head
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
static fromJSON(doc, json) {
|
|
40
|
-
return new FakeTextCursorSelection(doc.resolve(json.pos));
|
|
41
|
-
}
|
|
42
|
-
getBookmark() {
|
|
43
|
-
return new FakeTextCursorBookmark(this.anchor);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
Selection.jsonID('fake-text-cursor', FakeTextCursorSelection);
|
|
47
|
-
export const addFakeTextCursor = (state, dispatch) => {
|
|
48
|
-
const {
|
|
49
|
-
selection
|
|
50
|
-
} = state;
|
|
51
|
-
if (selection.empty) {
|
|
52
|
-
const {
|
|
53
|
-
selection: {
|
|
54
|
-
$from
|
|
55
|
-
}
|
|
56
|
-
} = state;
|
|
57
|
-
dispatch(state.tr.setSelection(new FakeTextCursorSelection($from)));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
export const removeFakeTextCursor = (state, dispatch) => {
|
|
61
|
-
if (state.selection instanceof FakeTextCursorSelection) {
|
|
62
|
-
const {
|
|
63
|
-
$from
|
|
64
|
-
} = state.selection;
|
|
65
|
-
dispatch(state.tr.setSelection(new TextSelection($from)));
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
export const drawFakeTextCursor = state => {
|
|
69
|
-
if (!(state.selection instanceof FakeTextCursorSelection)) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
const node = document.createElement('div');
|
|
73
|
-
node.className = 'ProseMirror-fake-text-cursor';
|
|
74
|
-
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, {
|
|
75
|
-
key: 'Cursor'
|
|
76
|
-
})]);
|
|
77
|
-
};
|