@atlaskit/editor-plugin-base 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.eslintrc.js +14 -0
  2. package/CHANGELOG.md +11 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +33 -0
  5. package/dist/cjs/commands.js +20 -0
  6. package/dist/cjs/index.js +33 -0
  7. package/dist/cjs/plugin.js +143 -0
  8. package/dist/cjs/pm-plugins/context-identifier.js +58 -0
  9. package/dist/cjs/pm-plugins/disable-spell-checking.js +63 -0
  10. package/dist/cjs/pm-plugins/filter-steps.js +34 -0
  11. package/dist/cjs/pm-plugins/fix-chrome-88-selection.js +34 -0
  12. package/dist/cjs/pm-plugins/frozen-editor.js +265 -0
  13. package/dist/cjs/pm-plugins/inline-cursor-target.js +184 -0
  14. package/dist/cjs/pm-plugins/newline-preserve-marks.js +34 -0
  15. package/dist/cjs/pm-plugins/scroll-gutter/index.js +264 -0
  16. package/dist/cjs/pm-plugins/scroll-gutter/plugin-key.js +15 -0
  17. package/dist/cjs/types.js +5 -0
  18. package/dist/cjs/utils/frozen-editor.js +11 -0
  19. package/dist/cjs/utils/input-latency-tracking.js +134 -0
  20. package/dist/es2019/commands.js +13 -0
  21. package/dist/es2019/index.js +4 -0
  22. package/dist/es2019/plugin.js +113 -0
  23. package/dist/es2019/pm-plugins/context-identifier.js +43 -0
  24. package/dist/es2019/pm-plugins/disable-spell-checking.js +54 -0
  25. package/dist/es2019/pm-plugins/filter-steps.js +23 -0
  26. package/dist/es2019/pm-plugins/fix-chrome-88-selection.js +24 -0
  27. package/dist/es2019/pm-plugins/frozen-editor.js +258 -0
  28. package/dist/es2019/pm-plugins/inline-cursor-target.js +187 -0
  29. package/dist/es2019/pm-plugins/newline-preserve-marks.js +20 -0
  30. package/dist/es2019/pm-plugins/scroll-gutter/index.js +244 -0
  31. package/dist/es2019/pm-plugins/scroll-gutter/plugin-key.js +7 -0
  32. package/dist/es2019/types.js +1 -0
  33. package/dist/es2019/utils/frozen-editor.js +2 -0
  34. package/dist/es2019/utils/input-latency-tracking.js +103 -0
  35. package/dist/esm/commands.js +13 -0
  36. package/dist/esm/index.js +4 -0
  37. package/dist/esm/plugin.js +131 -0
  38. package/dist/esm/pm-plugins/context-identifier.js +48 -0
  39. package/dist/esm/pm-plugins/disable-spell-checking.js +56 -0
  40. package/dist/esm/pm-plugins/filter-steps.js +27 -0
  41. package/dist/esm/pm-plugins/fix-chrome-88-selection.js +26 -0
  42. package/dist/esm/pm-plugins/frozen-editor.js +251 -0
  43. package/dist/esm/pm-plugins/inline-cursor-target.js +175 -0
  44. package/dist/esm/pm-plugins/newline-preserve-marks.js +26 -0
  45. package/dist/esm/pm-plugins/scroll-gutter/index.js +256 -0
  46. package/dist/esm/pm-plugins/scroll-gutter/plugin-key.js +7 -0
  47. package/dist/esm/types.js +1 -0
  48. package/dist/esm/utils/frozen-editor.js +4 -0
  49. package/dist/esm/utils/input-latency-tracking.js +127 -0
  50. package/dist/types/commands.d.ts +2 -0
  51. package/dist/types/index.d.ts +7 -0
  52. package/dist/types/plugin.d.ts +24 -0
  53. package/dist/types/pm-plugins/context-identifier.d.ts +12 -0
  54. package/dist/types/pm-plugins/disable-spell-checking.d.ts +4 -0
  55. package/dist/types/pm-plugins/filter-steps.d.ts +4 -0
  56. package/dist/types/pm-plugins/fix-chrome-88-selection.d.ts +5 -0
  57. package/dist/types/pm-plugins/frozen-editor.d.ts +12 -0
  58. package/dist/types/pm-plugins/inline-cursor-target.d.ts +17 -0
  59. package/dist/types/pm-plugins/newline-preserve-marks.d.ts +5 -0
  60. package/dist/types/pm-plugins/scroll-gutter/index.d.ts +22 -0
  61. package/dist/types/pm-plugins/scroll-gutter/plugin-key.d.ts +7 -0
  62. package/dist/types/types.d.ts +4 -0
  63. package/dist/types/utils/frozen-editor.d.ts +2 -0
  64. package/dist/types/utils/input-latency-tracking.d.ts +42 -0
  65. package/dist/types-ts4.5/commands.d.ts +2 -0
  66. package/dist/types-ts4.5/index.d.ts +7 -0
  67. package/dist/types-ts4.5/plugin.d.ts +26 -0
  68. package/dist/types-ts4.5/pm-plugins/context-identifier.d.ts +12 -0
  69. package/dist/types-ts4.5/pm-plugins/disable-spell-checking.d.ts +4 -0
  70. package/dist/types-ts4.5/pm-plugins/filter-steps.d.ts +4 -0
  71. package/dist/types-ts4.5/pm-plugins/fix-chrome-88-selection.d.ts +5 -0
  72. package/dist/types-ts4.5/pm-plugins/frozen-editor.d.ts +12 -0
  73. package/dist/types-ts4.5/pm-plugins/inline-cursor-target.d.ts +17 -0
  74. package/dist/types-ts4.5/pm-plugins/newline-preserve-marks.d.ts +5 -0
  75. package/dist/types-ts4.5/pm-plugins/scroll-gutter/index.d.ts +22 -0
  76. package/dist/types-ts4.5/pm-plugins/scroll-gutter/plugin-key.d.ts +7 -0
  77. package/dist/types-ts4.5/types.d.ts +4 -0
  78. package/dist/types-ts4.5/utils/frozen-editor.d.ts +2 -0
  79. package/dist/types-ts4.5/utils/input-latency-tracking.d.ts +42 -0
  80. package/package.json +92 -0
  81. package/report.api.md +89 -0
  82. package/tmp/api-report-tmp.d.ts +64 -0
  83. package/tsconfig.app.json +45 -0
  84. package/tsconfig.dev.json +81 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ rules: {
3
+ '@typescript-eslint/no-duplicate-imports': 'error',
4
+ '@typescript-eslint/no-explicit-any': 'error',
5
+ },
6
+ overrides: [
7
+ {
8
+ files: ['**/__tests__/**/*.{js,ts,tsx}', '**/examples/**/*.{js,ts,tsx}'],
9
+ rules: {
10
+ '@typescript-eslint/no-explicit-any': 'off',
11
+ },
12
+ },
13
+ ],
14
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # @atlaskit/editor-plugin-base
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`f8e7203eec6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f8e7203eec6) - ED-19618 Extract base plugin from editor-core
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
package/LICENSE.md ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Editor Base Plugin
2
+
3
+ Base plugin for @atlaskit/editor-core
4
+
5
+ **Note:** This component is designed for internal Atlassian development.
6
+ External contributors will be able to use this component but will not be able to submit issues.
7
+
8
+ ## Install
9
+ ---
10
+ - **Install** - *yarn add @atlaskit/editor-plugin-base*
11
+ - **npm** - [@atlaskit/editor-plugin-base](https://www.npmjs.com/package/@atlaskit/editor-plugin-base)
12
+ - **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-base)
13
+ - **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-base/dist/)
14
+
15
+ ## Usage
16
+ ---
17
+
18
+ **Internal use only**
19
+
20
+ @atlaskit/editor-plugin-base is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
21
+
22
+ Direct use of this component is not supported.
23
+
24
+ Please see [Atlaskit - Editor plugin base](https://atlaskit.atlassian.com/packages/editor/editor-plugin-base) for documentation and examples for this package.
25
+
26
+ ## Support
27
+ ---
28
+
29
+ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
30
+
31
+ ## License
32
+ ---
33
+ Please see [Atlassian Frontend - License](https://developer.atlassian.com/cloud/framework/atlassian-frontend/#license) for more licensing information.
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setKeyboardHeight = void 0;
7
+ var _pluginKey = require("./pm-plugins/scroll-gutter/plugin-key");
8
+ var setKeyboardHeight = function setKeyboardHeight(keyboardHeight) {
9
+ return function (state, dispatch) {
10
+ var tr = state.tr;
11
+ tr.setMeta(_pluginKey.scrollGutterPluginKey, {
12
+ keyboardHeight: keyboardHeight
13
+ });
14
+ if (dispatch) {
15
+ dispatch(tr);
16
+ }
17
+ return true;
18
+ };
19
+ };
20
+ exports.setKeyboardHeight = setKeyboardHeight;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "DEGRADED_SEVERITY_THRESHOLD", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _frozenEditor.DEGRADED_SEVERITY_THRESHOLD;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "NORMAL_SEVERITY_THRESHOLD", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _frozenEditor.NORMAL_SEVERITY_THRESHOLD;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "basePlugin", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _plugin.default;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "setKeyboardHeight", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _commands.setKeyboardHeight;
29
+ }
30
+ });
31
+ var _plugin = _interopRequireDefault(require("./plugin"));
32
+ var _frozenEditor = require("./pm-plugins/frozen-editor");
33
+ var _commands = require("./commands");
@@ -0,0 +1,143 @@
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.isChromeWithSelectionBug = exports.default = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _adfSchema = require("@atlaskit/adf-schema");
11
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
12
+ var _utils = require("@atlaskit/editor-common/utils");
13
+ var _commands = require("@atlaskit/editor-prosemirror/commands");
14
+ var _history = require("@atlaskit/editor-prosemirror/history");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _contextIdentifier = _interopRequireWildcard(require("./pm-plugins/context-identifier"));
17
+ var _disableSpellChecking = _interopRequireDefault(require("./pm-plugins/disable-spell-checking"));
18
+ var _filterSteps = _interopRequireDefault(require("./pm-plugins/filter-steps"));
19
+ var _fixChrome88Selection = _interopRequireDefault(require("./pm-plugins/fix-chrome-88-selection"));
20
+ var _frozenEditor = _interopRequireDefault(require("./pm-plugins/frozen-editor"));
21
+ var _inlineCursorTarget = _interopRequireDefault(require("./pm-plugins/inline-cursor-target"));
22
+ var _newlinePreserveMarks = _interopRequireDefault(require("./pm-plugins/newline-preserve-marks"));
23
+ var _scrollGutter = _interopRequireWildcard(require("./pm-plugins/scroll-gutter"));
24
+ 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); }
25
+ 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; }
26
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
28
+ // Chrome >= 88
29
+ var isChromeWithSelectionBug = _utils.browser.chrome && _utils.browser.chrome_version >= 88;
30
+ exports.isChromeWithSelectionBug = isChromeWithSelectionBug;
31
+ var basePlugin = function basePlugin(_ref) {
32
+ var _api$featureFlags;
33
+ var options = _ref.config,
34
+ api = _ref.api;
35
+ var featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
36
+ return {
37
+ name: 'base',
38
+ getSharedState: function getSharedState(editorState) {
39
+ return {
40
+ contextIdentifier: (0, _contextIdentifier.getContextIdentifier)(editorState),
41
+ keyboardHeight: (0, _scrollGutter.getKeyboardHeight)(editorState)
42
+ };
43
+ },
44
+ pmPlugins: function pmPlugins() {
45
+ var plugins = [{
46
+ name: 'filterStepsPlugin',
47
+ plugin: function plugin(_ref2) {
48
+ var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
49
+ return (0, _filterSteps.default)(dispatchAnalyticsEvent);
50
+ }
51
+ }];
52
+
53
+ // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
54
+ // the cursor appears at the right most point of the parent container.
55
+ // In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
56
+ // no cursor is presented to users.
57
+ // In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
58
+ // it is not possible to navigate with arrow keys.
59
+ // This plugin works around the issues by inserting decorations between
60
+ // inline nodes which are set as contenteditable, and have a zero width space.
61
+ plugins.push({
62
+ name: 'inlineCursorTargetPlugin',
63
+ plugin: function plugin() {
64
+ return options && options.allowInlineCursorTarget ? (0, _inlineCursorTarget.default)() : undefined;
65
+ }
66
+ });
67
+ plugins.push({
68
+ name: 'newlinePreserveMarksPlugin',
69
+ plugin: _newlinePreserveMarks.default
70
+ }, {
71
+ name: 'frozenEditor',
72
+ plugin: function plugin(_ref3) {
73
+ var _options$inputTrackin;
74
+ var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
75
+ return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? (0, _frozenEditor.default)(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
76
+ }
77
+ }, {
78
+ name: 'history',
79
+ plugin: function plugin() {
80
+ return (0, _history.history)();
81
+ }
82
+ },
83
+ // should be last :(
84
+ {
85
+ name: 'codeBlockIndent',
86
+ plugin: function plugin() {
87
+ return (0, _keymaps.keymap)(_objectSpread(_objectSpread({}, _commands.baseKeymap), {}, {
88
+ 'Mod-[': function Mod() {
89
+ return true;
90
+ },
91
+ 'Mod-]': function Mod() {
92
+ return true;
93
+ }
94
+ }));
95
+ }
96
+ }, {
97
+ name: 'contextIdentifier',
98
+ plugin: function plugin(_ref4) {
99
+ var dispatch = _ref4.dispatch,
100
+ providerFactory = _ref4.providerFactory;
101
+ return (0, _contextIdentifier.default)(dispatch, providerFactory);
102
+ }
103
+ });
104
+ if (options && options.allowScrollGutter) {
105
+ plugins.push({
106
+ name: 'scrollGutterPlugin',
107
+ plugin: function plugin() {
108
+ return (0, _scrollGutter.default)(options.allowScrollGutter);
109
+ }
110
+ });
111
+ }
112
+ if (isChromeWithSelectionBug && !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
113
+ plugins.push({
114
+ name: 'fixChrome88SelectionPlugin',
115
+ plugin: function plugin() {
116
+ return (0, _fixChrome88Selection.default)();
117
+ }
118
+ });
119
+ }
120
+ plugins.push({
121
+ name: 'disableSpellcheckingPlugin',
122
+ plugin: function plugin() {
123
+ return (0, _disableSpellChecking.default)(featureFlags);
124
+ }
125
+ });
126
+ return plugins;
127
+ },
128
+ nodes: function nodes() {
129
+ return [{
130
+ name: 'doc',
131
+ node: _adfSchema.doc
132
+ }, {
133
+ name: 'paragraph',
134
+ node: _adfSchema.paragraph
135
+ }, {
136
+ name: 'text',
137
+ node: _adfSchema.text
138
+ }];
139
+ }
140
+ };
141
+ };
142
+ var _default = basePlugin;
143
+ exports.default = _default;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.stateKey = exports.getContextIdentifier = exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ var stateKey = new _state.PluginKey('contextIdentiferPlugin');
14
+ exports.stateKey = stateKey;
15
+ var getContextIdentifier = function getContextIdentifier(state) {
16
+ if (state) {
17
+ var _stateKey$getState;
18
+ return (_stateKey$getState = stateKey.getState(state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.contextIdentifierProvider;
19
+ }
20
+ };
21
+ exports.getContextIdentifier = getContextIdentifier;
22
+ var _default = function _default(dispatch, providerFactory) {
23
+ return new _safePlugin.SafePlugin({
24
+ key: stateKey,
25
+ state: {
26
+ init: function init() {
27
+ return {};
28
+ },
29
+ apply: function apply(tr, pluginState) {
30
+ if (tr.getMeta(stateKey)) {
31
+ return tr.getMeta(stateKey);
32
+ }
33
+ return pluginState;
34
+ }
35
+ },
36
+ view: function view(_view) {
37
+ var providerPromiseHandler = function providerPromiseHandler(name, providerPromise) {
38
+ if (providerPromise && name === 'contextIdentifierProvider') {
39
+ providerPromise.then(function (provider) {
40
+ var tr = _view.state.tr.setMeta(stateKey, {
41
+ contextIdentifierProvider: _objectSpread({}, provider)
42
+ });
43
+ _view.dispatch(tr);
44
+ });
45
+ }
46
+ };
47
+ if (providerFactory) {
48
+ providerFactory.subscribe('contextIdentifierProvider', providerPromiseHandler);
49
+ }
50
+ return {
51
+ destroy: function destroy() {
52
+ providerFactory && providerFactory.unsubscribe('contextIdentifierProvider', providerPromiseHandler);
53
+ }
54
+ };
55
+ }
56
+ });
57
+ };
58
+ exports.default = _default;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _utils = require("@atlaskit/editor-common/utils");
9
+ var _state = require("@atlaskit/editor-prosemirror/state");
10
+ function getCurrentBrowserAndVersion() {
11
+ switch (true) {
12
+ case _utils.browser.chrome === true:
13
+ return {
14
+ browser: 'chrome',
15
+ version: _utils.browser.chrome_version
16
+ };
17
+ case _utils.browser.ie === true:
18
+ return {
19
+ browser: 'ie',
20
+ version: _utils.browser.ie_version
21
+ };
22
+ case _utils.browser.gecko === true:
23
+ return {
24
+ browser: 'gecko',
25
+ version: _utils.browser.gecko_version
26
+ };
27
+ case _utils.browser.safari === true:
28
+ return {
29
+ browser: 'safari',
30
+ version: _utils.browser.safari_version
31
+ };
32
+ }
33
+ return undefined;
34
+ }
35
+ var _default = function _default(featureFlags) {
36
+ return new _safePlugin.SafePlugin({
37
+ key: new _state.PluginKey('disableSpellchecking'),
38
+ props: {
39
+ attributes: function attributes(editorState) {
40
+ if (!featureFlags) {
41
+ return {};
42
+ }
43
+ var browserConfigFeatureFlag = featureFlags.disableSpellcheckByBrowser;
44
+ var userCurrentBrowserAndVersion = getCurrentBrowserAndVersion();
45
+ if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
46
+ return {};
47
+ }
48
+ var browserVersionDisableRange = browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
49
+ if (!browserVersionDisableRange || !_utils.browser[userCurrentBrowserAndVersion.browser]) {
50
+ return {};
51
+ }
52
+ var shouldDisableSpellcheck = !!browserVersionDisableRange.maximum ? userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum && userCurrentBrowserAndVersion.version <= browserVersionDisableRange.maximum : _utils.browser[userCurrentBrowserAndVersion.browser] && userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum;
53
+ if (shouldDisableSpellcheck) {
54
+ return {
55
+ spellcheck: 'false'
56
+ };
57
+ }
58
+ return {};
59
+ }
60
+ }
61
+ });
62
+ };
63
+ exports.default = _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
9
+ var hasInvalidSteps = function hasInvalidSteps(tr) {
10
+ return (tr.steps || []).some(function (step) {
11
+ return step.from > step.to;
12
+ });
13
+ };
14
+ var _default = function _default(dispatchAnalyticsEvent) {
15
+ return new _safePlugin.SafePlugin({
16
+ filterTransaction: function filterTransaction(transaction) {
17
+ if (hasInvalidSteps(transaction)) {
18
+ // eslint-disable-next-line no-console
19
+ console.warn('The transaction was blocked because it contains invalid steps', transaction.steps);
20
+ dispatchAnalyticsEvent({
21
+ action: _analytics.ACTION.DISCARDED_INVALID_STEPS_FROM_TRANSACTION,
22
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
23
+ attributes: {
24
+ analyticsEventPayloads: (0, _analytics.getAnalyticsEventsFromTransaction)(transaction)
25
+ },
26
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
27
+ });
28
+ return false;
29
+ }
30
+ return true;
31
+ }
32
+ });
33
+ };
34
+ exports.default = _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fixChromeSelectionKey = exports.default = void 0;
7
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _state = require("@atlaskit/editor-prosemirror/state");
9
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
10
+ function isDivHTMLElement(elm) {
11
+ return elm.tagName.toLowerCase() === 'div';
12
+ }
13
+ var fixChromeSelectionKey = new _state.PluginKey('fixChromeSelectionPlugin');
14
+ exports.fixChromeSelectionKey = fixChromeSelectionKey;
15
+ var _default = function _default() {
16
+ return new _safePlugin.SafePlugin({
17
+ key: fixChromeSelectionKey,
18
+ props: {
19
+ handleDOMEvents: {
20
+ focus: function focus(view) {
21
+ // We don't need to reset when there's a NodeSelection
22
+ // It creates other problem. @see HOT-94478
23
+ if (isDivHTMLElement(view.dom) && !(0, _utils.isNodeSelection)(view.state.selection)) {
24
+ view.dom.style.display = 'inline-block';
25
+ view.dom.offsetHeight;
26
+ view.dom.style.display = 'block';
27
+ }
28
+ return false;
29
+ }
30
+ }
31
+ }
32
+ });
33
+ };
34
+ exports.default = _default;