@atlaskit/editor-core 189.4.9 → 189.4.12

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 (199) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/composable-editor/editor-internal.js +3 -3
  3. package/dist/cjs/composable-editor/editor.js +202 -3
  4. package/dist/cjs/i18n/cs.js +1 -3
  5. package/dist/cjs/i18n/da.js +1 -3
  6. package/dist/cjs/i18n/de.js +1 -3
  7. package/dist/cjs/i18n/en.js +1 -3
  8. package/dist/cjs/i18n/en_GB.js +1 -3
  9. package/dist/cjs/i18n/en_ZZ.js +1 -3
  10. package/dist/cjs/i18n/es.js +1 -3
  11. package/dist/cjs/i18n/fi.js +1 -3
  12. package/dist/cjs/i18n/fr.js +1 -3
  13. package/dist/cjs/i18n/hu.js +1 -3
  14. package/dist/cjs/i18n/it.js +1 -3
  15. package/dist/cjs/i18n/ja.js +1 -3
  16. package/dist/cjs/i18n/ko.js +1 -3
  17. package/dist/cjs/i18n/nb.js +1 -3
  18. package/dist/cjs/i18n/nl.js +1 -3
  19. package/dist/cjs/i18n/pl.js +1 -3
  20. package/dist/cjs/i18n/pt_BR.js +1 -3
  21. package/dist/cjs/i18n/ru.js +1 -3
  22. package/dist/cjs/i18n/sv.js +1 -3
  23. package/dist/cjs/i18n/th.js +1 -3
  24. package/dist/cjs/i18n/tr.js +1 -3
  25. package/dist/cjs/i18n/uk.js +1 -3
  26. package/dist/cjs/i18n/vi.js +1 -3
  27. package/dist/cjs/i18n/zh.js +1 -3
  28. package/dist/cjs/i18n/zh_TW.js +1 -3
  29. package/dist/cjs/plugins/index.js +1 -15
  30. package/dist/cjs/presets/default.js +2 -2
  31. package/dist/cjs/presets/universal.js +2 -1
  32. package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +11 -3
  33. package/dist/cjs/ui/ConfigPanel/constants.js +13 -0
  34. package/dist/cjs/ui/ConfigPanel/utils.js +44 -1
  35. package/dist/cjs/version-wrapper.js +1 -1
  36. package/dist/es2019/composable-editor/editor-internal.js +4 -4
  37. package/dist/es2019/composable-editor/editor.js +208 -4
  38. package/dist/es2019/i18n/cs.js +1 -3
  39. package/dist/es2019/i18n/da.js +1 -3
  40. package/dist/es2019/i18n/de.js +1 -3
  41. package/dist/es2019/i18n/en.js +1 -3
  42. package/dist/es2019/i18n/en_GB.js +1 -3
  43. package/dist/es2019/i18n/en_ZZ.js +1 -3
  44. package/dist/es2019/i18n/es.js +1 -3
  45. package/dist/es2019/i18n/fi.js +1 -3
  46. package/dist/es2019/i18n/fr.js +1 -3
  47. package/dist/es2019/i18n/hu.js +1 -3
  48. package/dist/es2019/i18n/it.js +1 -3
  49. package/dist/es2019/i18n/ja.js +1 -3
  50. package/dist/es2019/i18n/ko.js +1 -3
  51. package/dist/es2019/i18n/nb.js +1 -3
  52. package/dist/es2019/i18n/nl.js +1 -3
  53. package/dist/es2019/i18n/pl.js +1 -3
  54. package/dist/es2019/i18n/pt_BR.js +1 -3
  55. package/dist/es2019/i18n/ru.js +1 -3
  56. package/dist/es2019/i18n/sv.js +1 -3
  57. package/dist/es2019/i18n/th.js +1 -3
  58. package/dist/es2019/i18n/tr.js +1 -3
  59. package/dist/es2019/i18n/uk.js +1 -3
  60. package/dist/es2019/i18n/vi.js +1 -3
  61. package/dist/es2019/i18n/zh.js +1 -3
  62. package/dist/es2019/i18n/zh_TW.js +1 -3
  63. package/dist/es2019/plugins/index.js +1 -3
  64. package/dist/es2019/presets/default.js +2 -2
  65. package/dist/es2019/presets/universal.js +2 -1
  66. package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +11 -2
  67. package/dist/es2019/ui/ConfigPanel/constants.js +7 -0
  68. package/dist/es2019/ui/ConfigPanel/utils.js +35 -1
  69. package/dist/es2019/version-wrapper.js +1 -1
  70. package/dist/esm/composable-editor/editor-internal.js +3 -3
  71. package/dist/esm/composable-editor/editor.js +203 -4
  72. package/dist/esm/i18n/cs.js +1 -3
  73. package/dist/esm/i18n/da.js +1 -3
  74. package/dist/esm/i18n/de.js +1 -3
  75. package/dist/esm/i18n/en.js +1 -3
  76. package/dist/esm/i18n/en_GB.js +1 -3
  77. package/dist/esm/i18n/en_ZZ.js +1 -3
  78. package/dist/esm/i18n/es.js +1 -3
  79. package/dist/esm/i18n/fi.js +1 -3
  80. package/dist/esm/i18n/fr.js +1 -3
  81. package/dist/esm/i18n/hu.js +1 -3
  82. package/dist/esm/i18n/it.js +1 -3
  83. package/dist/esm/i18n/ja.js +1 -3
  84. package/dist/esm/i18n/ko.js +1 -3
  85. package/dist/esm/i18n/nb.js +1 -3
  86. package/dist/esm/i18n/nl.js +1 -3
  87. package/dist/esm/i18n/pl.js +1 -3
  88. package/dist/esm/i18n/pt_BR.js +1 -3
  89. package/dist/esm/i18n/ru.js +1 -3
  90. package/dist/esm/i18n/sv.js +1 -3
  91. package/dist/esm/i18n/th.js +1 -3
  92. package/dist/esm/i18n/tr.js +1 -3
  93. package/dist/esm/i18n/uk.js +1 -3
  94. package/dist/esm/i18n/vi.js +1 -3
  95. package/dist/esm/i18n/zh.js +1 -3
  96. package/dist/esm/i18n/zh_TW.js +1 -3
  97. package/dist/esm/plugins/index.js +1 -3
  98. package/dist/esm/presets/default.js +2 -2
  99. package/dist/esm/presets/universal.js +2 -1
  100. package/dist/esm/ui/ConfigPanel/ConfigPanel.js +11 -3
  101. package/dist/esm/ui/ConfigPanel/constants.js +7 -0
  102. package/dist/esm/ui/ConfigPanel/utils.js +42 -0
  103. package/dist/esm/version-wrapper.js +1 -1
  104. package/dist/types/composable-editor/editor-internal.d.ts +2 -1
  105. package/dist/types/i18n/cs.d.ts +0 -2
  106. package/dist/types/i18n/da.d.ts +0 -2
  107. package/dist/types/i18n/de.d.ts +0 -2
  108. package/dist/types/i18n/en.d.ts +0 -2
  109. package/dist/types/i18n/en_GB.d.ts +0 -2
  110. package/dist/types/i18n/en_ZZ.d.ts +0 -2
  111. package/dist/types/i18n/es.d.ts +0 -2
  112. package/dist/types/i18n/fi.d.ts +0 -2
  113. package/dist/types/i18n/fr.d.ts +0 -2
  114. package/dist/types/i18n/hu.d.ts +0 -2
  115. package/dist/types/i18n/it.d.ts +0 -2
  116. package/dist/types/i18n/ja.d.ts +0 -2
  117. package/dist/types/i18n/ko.d.ts +0 -2
  118. package/dist/types/i18n/nb.d.ts +0 -2
  119. package/dist/types/i18n/nl.d.ts +0 -2
  120. package/dist/types/i18n/pl.d.ts +0 -2
  121. package/dist/types/i18n/pt_BR.d.ts +0 -2
  122. package/dist/types/i18n/ru.d.ts +0 -2
  123. package/dist/types/i18n/sv.d.ts +0 -2
  124. package/dist/types/i18n/th.d.ts +0 -2
  125. package/dist/types/i18n/tr.d.ts +0 -2
  126. package/dist/types/i18n/uk.d.ts +0 -2
  127. package/dist/types/i18n/vi.d.ts +0 -2
  128. package/dist/types/i18n/zh.d.ts +0 -2
  129. package/dist/types/i18n/zh_TW.d.ts +0 -2
  130. package/dist/types/plugins/index.d.ts +0 -2
  131. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +3 -4
  132. package/dist/types/ui/ConfigPanel/constants.d.ts +2 -0
  133. package/dist/types/ui/ConfigPanel/utils.d.ts +2 -1
  134. package/dist/types-ts4.5/composable-editor/editor-internal.d.ts +2 -1
  135. package/dist/types-ts4.5/i18n/cs.d.ts +0 -2
  136. package/dist/types-ts4.5/i18n/da.d.ts +0 -2
  137. package/dist/types-ts4.5/i18n/de.d.ts +0 -2
  138. package/dist/types-ts4.5/i18n/en.d.ts +0 -2
  139. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -2
  140. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -2
  141. package/dist/types-ts4.5/i18n/es.d.ts +0 -2
  142. package/dist/types-ts4.5/i18n/fi.d.ts +0 -2
  143. package/dist/types-ts4.5/i18n/fr.d.ts +0 -2
  144. package/dist/types-ts4.5/i18n/hu.d.ts +0 -2
  145. package/dist/types-ts4.5/i18n/it.d.ts +0 -2
  146. package/dist/types-ts4.5/i18n/ja.d.ts +0 -2
  147. package/dist/types-ts4.5/i18n/ko.d.ts +0 -2
  148. package/dist/types-ts4.5/i18n/nb.d.ts +0 -2
  149. package/dist/types-ts4.5/i18n/nl.d.ts +0 -2
  150. package/dist/types-ts4.5/i18n/pl.d.ts +0 -2
  151. package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -2
  152. package/dist/types-ts4.5/i18n/ru.d.ts +0 -2
  153. package/dist/types-ts4.5/i18n/sv.d.ts +0 -2
  154. package/dist/types-ts4.5/i18n/th.d.ts +0 -2
  155. package/dist/types-ts4.5/i18n/tr.d.ts +0 -2
  156. package/dist/types-ts4.5/i18n/uk.d.ts +0 -2
  157. package/dist/types-ts4.5/i18n/vi.d.ts +0 -2
  158. package/dist/types-ts4.5/i18n/zh.d.ts +0 -2
  159. package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -2
  160. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  161. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +3 -4
  162. package/dist/types-ts4.5/ui/ConfigPanel/constants.d.ts +2 -0
  163. package/dist/types-ts4.5/ui/ConfigPanel/utils.d.ts +2 -1
  164. package/package.json +10 -6
  165. package/dist/cjs/plugins/clear-marks-on-change-to-empty-document/index.js +0 -35
  166. package/dist/cjs/plugins/code-bidi-warning/index.js +0 -22
  167. package/dist/cjs/plugins/code-bidi-warning/plugin-key.js +0 -8
  168. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +0 -44
  169. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +0 -105
  170. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/reducer.js +0 -9
  171. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/types.js +0 -5
  172. package/dist/es2019/plugins/clear-marks-on-change-to-empty-document/index.js +0 -26
  173. package/dist/es2019/plugins/code-bidi-warning/index.js +0 -15
  174. package/dist/es2019/plugins/code-bidi-warning/plugin-key.js +0 -2
  175. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +0 -41
  176. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +0 -97
  177. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/reducer.js +0 -3
  178. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/types.js +0 -1
  179. package/dist/esm/plugins/clear-marks-on-change-to-empty-document/index.js +0 -28
  180. package/dist/esm/plugins/code-bidi-warning/index.js +0 -16
  181. package/dist/esm/plugins/code-bidi-warning/plugin-key.js +0 -2
  182. package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +0 -38
  183. package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +0 -98
  184. package/dist/esm/plugins/code-bidi-warning/pm-plugins/reducer.js +0 -3
  185. package/dist/esm/plugins/code-bidi-warning/pm-plugins/types.js +0 -1
  186. package/dist/types/plugins/clear-marks-on-change-to-empty-document/index.d.ts +0 -7
  187. package/dist/types/plugins/code-bidi-warning/index.d.ts +0 -8
  188. package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +0 -2
  189. package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +0 -5
  190. package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -8
  191. package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +0 -3
  192. package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +0 -6
  193. package/dist/types-ts4.5/plugins/clear-marks-on-change-to-empty-document/index.d.ts +0 -7
  194. package/dist/types-ts4.5/plugins/code-bidi-warning/index.d.ts +0 -8
  195. package/dist/types-ts4.5/plugins/code-bidi-warning/plugin-key.d.ts +0 -2
  196. package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/main.d.ts +0 -5
  197. package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -8
  198. package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +0 -3
  199. package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/types.d.ts +0 -6
@@ -1,105 +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.createBidiWarningsDecorationSetFromDoc = createBidiWarningsDecorationSetFromDoc;
8
- exports.getPluginState = exports.createPluginState = void 0;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _react = _interopRequireDefault(require("react"));
11
- var _reactDom = _interopRequireDefault(require("react-dom"));
12
- var _view = require("@atlaskit/editor-prosemirror/view");
13
- var _bidiWarning = _interopRequireDefault(require("@atlaskit/code/bidi-warning"));
14
- var _bidiWarningDecorator = _interopRequireDefault(require("@atlaskit/code/bidi-warning-decorator"));
15
- var _pluginStateFactory = require("../../../utils/plugin-state-factory");
16
- var _utils = require("@atlaskit/editor-common/utils");
17
- var _pluginKey = require("../plugin-key");
18
- var _reducer = _interopRequireDefault(require("./reducer"));
19
- 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; }
20
- 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; }
21
- var _pluginFactory = (0, _pluginStateFactory.pluginFactory)(_pluginKey.codeBidiWarningPluginKey, _reducer.default, {
22
- onDocChanged: function onDocChanged(tr, pluginState) {
23
- if (!tr.steps.find(_utils.stepHasSlice)) {
24
- return pluginState;
25
- }
26
- var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
27
- doc: tr.doc,
28
- codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
29
- tooltipEnabled: pluginState.tooltipEnabled
30
- });
31
- return _objectSpread(_objectSpread({}, pluginState), {}, {
32
- decorationSet: newBidiWarningsDecorationSet
33
- });
34
- }
35
- }),
36
- createPluginState = exports.createPluginState = _pluginFactory.createPluginState,
37
- getPluginState = exports.getPluginState = _pluginFactory.getPluginState;
38
- function createBidiWarningsDecorationSetFromDoc(_ref) {
39
- var doc = _ref.doc,
40
- codeBidiWarningLabel = _ref.codeBidiWarningLabel,
41
- tooltipEnabled = _ref.tooltipEnabled;
42
- var bidiCharactersAndTheirPositions = [];
43
- doc.descendants(function (node, pos) {
44
- var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
45
- return mark.type.name === 'code';
46
- });
47
- if (isTextWithCodeMark) {
48
- (0, _bidiWarningDecorator.default)(node.textContent, function (_ref2) {
49
- var bidiCharacter = _ref2.bidiCharacter,
50
- index = _ref2.index;
51
- bidiCharactersAndTheirPositions.push({
52
- position: pos + index,
53
- bidiCharacter: bidiCharacter
54
- });
55
- });
56
- return false;
57
- }
58
- var isCodeBlock = node.type.name === 'codeBlock';
59
- if (isCodeBlock) {
60
- (0, _bidiWarningDecorator.default)(node.textContent, function (_ref3) {
61
- var bidiCharacter = _ref3.bidiCharacter,
62
- index = _ref3.index;
63
- bidiCharactersAndTheirPositions.push({
64
- position: pos + index + 1,
65
- bidiCharacter: bidiCharacter
66
- });
67
- });
68
- }
69
- });
70
-
71
- // Bidi characters are not expected to commonly appear in code snippets, so recreating the decoration set
72
- // for documents rather than reusing existing decorations seems a reasonable performance/complexity tradeoff.
73
-
74
- if (bidiCharactersAndTheirPositions.length === 0) {
75
- return _view.DecorationSet.empty;
76
- }
77
- var newBidiWarningsDecorationSet = _view.DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(function (_ref4) {
78
- var position = _ref4.position,
79
- bidiCharacter = _ref4.bidiCharacter;
80
- return _view.Decoration.widget(position, function () {
81
- return renderDOM({
82
- bidiCharacter: bidiCharacter,
83
- codeBidiWarningLabel: codeBidiWarningLabel,
84
- tooltipEnabled: tooltipEnabled
85
- });
86
- });
87
- }));
88
- return newBidiWarningsDecorationSet;
89
- }
90
- function renderDOM(_ref5) {
91
- var bidiCharacter = _ref5.bidiCharacter,
92
- codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
93
- tooltipEnabled = _ref5.tooltipEnabled;
94
- var element = document.createElement('span');
95
-
96
- // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
97
- // we should investigate if there is a memory leak with such usage.
98
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
99
- bidiCharacter: bidiCharacter,
100
- skipChildren: true,
101
- label: codeBidiWarningLabel,
102
- tooltipEnabled: tooltipEnabled
103
- }), element);
104
- return element;
105
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = exports.default = function _default(pluginState, action) {
8
- return pluginState;
9
- };
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,26 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { isEmptyDocument } from '@atlaskit/editor-common/utils';
4
- export const pluginKey = new PluginKey('clearMarksOnChangeToEmptyDocumentPlugin');
5
- export function createPlugin() {
6
- return new SafePlugin({
7
- key: pluginKey,
8
- appendTransaction: (_transactions, oldState, newState) => {
9
- // ED-2973: When a user clears the editor's content, remove the current active marks
10
- if (!isEmptyDocument(oldState.doc) && isEmptyDocument(newState.doc)) {
11
- return newState.tr.setStoredMarks([]);
12
- }
13
- return;
14
- }
15
- });
16
- }
17
- const clearMarksOnChangeToEmptyDocumentPlugin = () => ({
18
- name: 'clearMarksOnEmptyDoc',
19
- pmPlugins() {
20
- return [{
21
- name: 'clearMarksOnChange',
22
- plugin: createPlugin
23
- }];
24
- }
25
- });
26
- export default clearMarksOnChangeToEmptyDocumentPlugin;
@@ -1,15 +0,0 @@
1
- import { createPlugin } from './pm-plugins/main';
2
- const codeBidiWarning = ({
3
- config
4
- }) => ({
5
- name: 'codeBidiWarning',
6
- pmPlugins() {
7
- return [{
8
- name: 'codeBidiWarning',
9
- plugin: options => {
10
- return createPlugin(options, config);
11
- }
12
- }];
13
- }
14
- });
15
- export default codeBidiWarning;
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const codeBidiWarningPluginKey = new PluginKey('codeBidiWarningPlugin');
@@ -1,41 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
3
- import { codeBidiWarningPluginKey } from '../plugin-key';
4
- import { createBidiWarningsDecorationSetFromDoc, createPluginState, getPluginState } from './plugin-factory';
5
- export const createPlugin = ({
6
- dispatch,
7
- getIntl
8
- }, {
9
- appearance
10
- }) => {
11
- const intl = getIntl();
12
- const codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
13
- return new SafePlugin({
14
- key: codeBidiWarningPluginKey,
15
- state: createPluginState(dispatch, state => {
16
- // The appearance being mobile indicates we are in an editor being
17
- // rendered by mobile bridge in a web view.
18
- // The tooltip is likely to have unexpected behaviour there, with being cut
19
- // off, so we disable it. This is also to keep the behaviour consistent with
20
- // the rendering in the mobile Native Renderer.
21
- const tooltipEnabled = appearance !== 'mobile';
22
- return {
23
- decorationSet: createBidiWarningsDecorationSetFromDoc({
24
- doc: state.doc,
25
- codeBidiWarningLabel,
26
- tooltipEnabled
27
- }),
28
- codeBidiWarningLabel,
29
- tooltipEnabled
30
- };
31
- }),
32
- props: {
33
- decorations: state => {
34
- const {
35
- decorationSet
36
- } = getPluginState(state);
37
- return decorationSet;
38
- }
39
- }
40
- });
41
- };
@@ -1,97 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import CodeBidiWarning from '@atlaskit/code/bidi-warning';
5
- import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
6
- import { pluginFactory } from '../../../utils/plugin-state-factory';
7
- import { stepHasSlice } from '@atlaskit/editor-common/utils';
8
- import { codeBidiWarningPluginKey } from '../plugin-key';
9
- import reducer from './reducer';
10
- export const {
11
- createPluginState,
12
- getPluginState
13
- } = pluginFactory(codeBidiWarningPluginKey, reducer, {
14
- onDocChanged: (tr, pluginState) => {
15
- if (!tr.steps.find(stepHasSlice)) {
16
- return pluginState;
17
- }
18
- const newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
19
- doc: tr.doc,
20
- codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
21
- tooltipEnabled: pluginState.tooltipEnabled
22
- });
23
- return {
24
- ...pluginState,
25
- decorationSet: newBidiWarningsDecorationSet
26
- };
27
- }
28
- });
29
- export function createBidiWarningsDecorationSetFromDoc({
30
- doc,
31
- codeBidiWarningLabel,
32
- tooltipEnabled
33
- }) {
34
- const bidiCharactersAndTheirPositions = [];
35
- doc.descendants((node, pos) => {
36
- const isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(mark => mark.type.name === 'code');
37
- if (isTextWithCodeMark) {
38
- codeBidiWarningDecorator(node.textContent, ({
39
- bidiCharacter,
40
- index
41
- }) => {
42
- bidiCharactersAndTheirPositions.push({
43
- position: pos + index,
44
- bidiCharacter
45
- });
46
- });
47
- return false;
48
- }
49
- const isCodeBlock = node.type.name === 'codeBlock';
50
- if (isCodeBlock) {
51
- codeBidiWarningDecorator(node.textContent, ({
52
- bidiCharacter,
53
- index
54
- }) => {
55
- bidiCharactersAndTheirPositions.push({
56
- position: pos + index + 1,
57
- bidiCharacter
58
- });
59
- });
60
- }
61
- });
62
-
63
- // Bidi characters are not expected to commonly appear in code snippets, so recreating the decoration set
64
- // for documents rather than reusing existing decorations seems a reasonable performance/complexity tradeoff.
65
-
66
- if (bidiCharactersAndTheirPositions.length === 0) {
67
- return DecorationSet.empty;
68
- }
69
- const newBidiWarningsDecorationSet = DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(({
70
- position,
71
- bidiCharacter
72
- }) => {
73
- return Decoration.widget(position, () => renderDOM({
74
- bidiCharacter,
75
- codeBidiWarningLabel,
76
- tooltipEnabled
77
- }));
78
- }));
79
- return newBidiWarningsDecorationSet;
80
- }
81
- function renderDOM({
82
- bidiCharacter,
83
- codeBidiWarningLabel,
84
- tooltipEnabled
85
- }) {
86
- const element = document.createElement('span');
87
-
88
- // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
89
- // we should investigate if there is a memory leak with such usage.
90
- ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
91
- bidiCharacter: bidiCharacter,
92
- skipChildren: true,
93
- label: codeBidiWarningLabel,
94
- tooltipEnabled: tooltipEnabled
95
- }), element);
96
- return element;
97
- }
@@ -1,3 +0,0 @@
1
- export default ((pluginState, action) => {
2
- return pluginState;
3
- });
@@ -1,28 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { isEmptyDocument } from '@atlaskit/editor-common/utils';
4
- export var pluginKey = new PluginKey('clearMarksOnChangeToEmptyDocumentPlugin');
5
- export function createPlugin() {
6
- return new SafePlugin({
7
- key: pluginKey,
8
- appendTransaction: function appendTransaction(_transactions, oldState, newState) {
9
- // ED-2973: When a user clears the editor's content, remove the current active marks
10
- if (!isEmptyDocument(oldState.doc) && isEmptyDocument(newState.doc)) {
11
- return newState.tr.setStoredMarks([]);
12
- }
13
- return;
14
- }
15
- });
16
- }
17
- var clearMarksOnChangeToEmptyDocumentPlugin = function clearMarksOnChangeToEmptyDocumentPlugin() {
18
- return {
19
- name: 'clearMarksOnEmptyDoc',
20
- pmPlugins: function pmPlugins() {
21
- return [{
22
- name: 'clearMarksOnChange',
23
- plugin: createPlugin
24
- }];
25
- }
26
- };
27
- };
28
- export default clearMarksOnChangeToEmptyDocumentPlugin;
@@ -1,16 +0,0 @@
1
- import { createPlugin } from './pm-plugins/main';
2
- var codeBidiWarning = function codeBidiWarning(_ref) {
3
- var config = _ref.config;
4
- return {
5
- name: 'codeBidiWarning',
6
- pmPlugins: function pmPlugins() {
7
- return [{
8
- name: 'codeBidiWarning',
9
- plugin: function plugin(options) {
10
- return createPlugin(options, config);
11
- }
12
- }];
13
- }
14
- };
15
- };
16
- export default codeBidiWarning;
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export var codeBidiWarningPluginKey = new PluginKey('codeBidiWarningPlugin');
@@ -1,38 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
3
- import { codeBidiWarningPluginKey } from '../plugin-key';
4
- import { createBidiWarningsDecorationSetFromDoc, createPluginState, getPluginState } from './plugin-factory';
5
- export var createPlugin = function createPlugin(_ref, _ref2) {
6
- var dispatch = _ref.dispatch,
7
- getIntl = _ref.getIntl;
8
- var appearance = _ref2.appearance;
9
- var intl = getIntl();
10
- var codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
11
- return new SafePlugin({
12
- key: codeBidiWarningPluginKey,
13
- state: createPluginState(dispatch, function (state) {
14
- // The appearance being mobile indicates we are in an editor being
15
- // rendered by mobile bridge in a web view.
16
- // The tooltip is likely to have unexpected behaviour there, with being cut
17
- // off, so we disable it. This is also to keep the behaviour consistent with
18
- // the rendering in the mobile Native Renderer.
19
- var tooltipEnabled = appearance !== 'mobile';
20
- return {
21
- decorationSet: createBidiWarningsDecorationSetFromDoc({
22
- doc: state.doc,
23
- codeBidiWarningLabel: codeBidiWarningLabel,
24
- tooltipEnabled: tooltipEnabled
25
- }),
26
- codeBidiWarningLabel: codeBidiWarningLabel,
27
- tooltipEnabled: tooltipEnabled
28
- };
29
- }),
30
- props: {
31
- decorations: function decorations(state) {
32
- var _getPluginState = getPluginState(state),
33
- decorationSet = _getPluginState.decorationSet;
34
- return decorationSet;
35
- }
36
- }
37
- });
38
- };
@@ -1,98 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- 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; }
3
- 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) { _defineProperty(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; }
4
- import React from 'react';
5
- import ReactDOM from 'react-dom';
6
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
- import CodeBidiWarning from '@atlaskit/code/bidi-warning';
8
- import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
9
- import { pluginFactory } from '../../../utils/plugin-state-factory';
10
- import { stepHasSlice } from '@atlaskit/editor-common/utils';
11
- import { codeBidiWarningPluginKey } from '../plugin-key';
12
- import reducer from './reducer';
13
- var _pluginFactory = pluginFactory(codeBidiWarningPluginKey, reducer, {
14
- onDocChanged: function onDocChanged(tr, pluginState) {
15
- if (!tr.steps.find(stepHasSlice)) {
16
- return pluginState;
17
- }
18
- var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
19
- doc: tr.doc,
20
- codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
21
- tooltipEnabled: pluginState.tooltipEnabled
22
- });
23
- return _objectSpread(_objectSpread({}, pluginState), {}, {
24
- decorationSet: newBidiWarningsDecorationSet
25
- });
26
- }
27
- }),
28
- createPluginState = _pluginFactory.createPluginState,
29
- getPluginState = _pluginFactory.getPluginState;
30
- export { createPluginState, getPluginState };
31
- export function createBidiWarningsDecorationSetFromDoc(_ref) {
32
- var doc = _ref.doc,
33
- codeBidiWarningLabel = _ref.codeBidiWarningLabel,
34
- tooltipEnabled = _ref.tooltipEnabled;
35
- var bidiCharactersAndTheirPositions = [];
36
- doc.descendants(function (node, pos) {
37
- var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
38
- return mark.type.name === 'code';
39
- });
40
- if (isTextWithCodeMark) {
41
- codeBidiWarningDecorator(node.textContent, function (_ref2) {
42
- var bidiCharacter = _ref2.bidiCharacter,
43
- index = _ref2.index;
44
- bidiCharactersAndTheirPositions.push({
45
- position: pos + index,
46
- bidiCharacter: bidiCharacter
47
- });
48
- });
49
- return false;
50
- }
51
- var isCodeBlock = node.type.name === 'codeBlock';
52
- if (isCodeBlock) {
53
- codeBidiWarningDecorator(node.textContent, function (_ref3) {
54
- var bidiCharacter = _ref3.bidiCharacter,
55
- index = _ref3.index;
56
- bidiCharactersAndTheirPositions.push({
57
- position: pos + index + 1,
58
- bidiCharacter: bidiCharacter
59
- });
60
- });
61
- }
62
- });
63
-
64
- // Bidi characters are not expected to commonly appear in code snippets, so recreating the decoration set
65
- // for documents rather than reusing existing decorations seems a reasonable performance/complexity tradeoff.
66
-
67
- if (bidiCharactersAndTheirPositions.length === 0) {
68
- return DecorationSet.empty;
69
- }
70
- var newBidiWarningsDecorationSet = DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(function (_ref4) {
71
- var position = _ref4.position,
72
- bidiCharacter = _ref4.bidiCharacter;
73
- return Decoration.widget(position, function () {
74
- return renderDOM({
75
- bidiCharacter: bidiCharacter,
76
- codeBidiWarningLabel: codeBidiWarningLabel,
77
- tooltipEnabled: tooltipEnabled
78
- });
79
- });
80
- }));
81
- return newBidiWarningsDecorationSet;
82
- }
83
- function renderDOM(_ref5) {
84
- var bidiCharacter = _ref5.bidiCharacter,
85
- codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
86
- tooltipEnabled = _ref5.tooltipEnabled;
87
- var element = document.createElement('span');
88
-
89
- // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
90
- // we should investigate if there is a memory leak with such usage.
91
- ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
92
- bidiCharacter: bidiCharacter,
93
- skipChildren: true,
94
- label: codeBidiWarningLabel,
95
- tooltipEnabled: tooltipEnabled
96
- }), element);
97
- return element;
98
- }
@@ -1,3 +0,0 @@
1
- export default (function (pluginState, action) {
2
- return pluginState;
3
- });
@@ -1,7 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
4
- export declare const pluginKey: PluginKey<any>;
5
- export declare function createPlugin(): SafePlugin;
6
- declare const clearMarksOnChangeToEmptyDocumentPlugin: NextEditorPlugin<'clearMarksOnEmptyDoc'>;
7
- export default clearMarksOnChangeToEmptyDocumentPlugin;
@@ -1,8 +0,0 @@
1
- import type { NextEditorPlugin, EditorProps } from '../../types';
2
- type Config = {
3
- appearance: EditorProps['appearance'];
4
- };
5
- declare const codeBidiWarning: NextEditorPlugin<'codeBidiWarning', {
6
- pluginConfiguration: Config;
7
- }>;
8
- export default codeBidiWarning;
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const codeBidiWarningPluginKey: PluginKey<any>;
@@ -1,5 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorProps, PMPluginFactoryParams } from '../../../types';
3
- export declare const createPlugin: ({ dispatch, getIntl }: PMPluginFactoryParams, { appearance }: {
4
- appearance: EditorProps['appearance'];
5
- }) => SafePlugin<import("./types").CodeBidiWarningPluginState>;
@@ -1,8 +0,0 @@
1
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
- export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("./types").CodeBidiWarningPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState)) => import("prosemirror-state").SafeStateField<import("./types").CodeBidiWarningPluginState>, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState;
4
- export declare function createBidiWarningsDecorationSetFromDoc({ doc, codeBidiWarningLabel, tooltipEnabled, }: {
5
- doc: PmNode;
6
- codeBidiWarningLabel: string;
7
- tooltipEnabled: boolean;
8
- }): DecorationSet;
@@ -1,3 +0,0 @@
1
- import { CodeBidiWarningPluginState } from './types';
2
- declare const _default: (pluginState: CodeBidiWarningPluginState, action: unknown) => CodeBidiWarningPluginState;
3
- export default _default;
@@ -1,6 +0,0 @@
1
- import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
- export type CodeBidiWarningPluginState = {
3
- decorationSet: DecorationSet;
4
- codeBidiWarningLabel: string;
5
- tooltipEnabled: boolean;
6
- };
@@ -1,7 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
4
- export declare const pluginKey: PluginKey<any>;
5
- export declare function createPlugin(): SafePlugin;
6
- declare const clearMarksOnChangeToEmptyDocumentPlugin: NextEditorPlugin<'clearMarksOnEmptyDoc'>;
7
- export default clearMarksOnChangeToEmptyDocumentPlugin;
@@ -1,8 +0,0 @@
1
- import type { NextEditorPlugin, EditorProps } from '../../types';
2
- type Config = {
3
- appearance: EditorProps['appearance'];
4
- };
5
- declare const codeBidiWarning: NextEditorPlugin<'codeBidiWarning', {
6
- pluginConfiguration: Config;
7
- }>;
8
- export default codeBidiWarning;
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const codeBidiWarningPluginKey: PluginKey<any>;
@@ -1,5 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorProps, PMPluginFactoryParams } from '../../../types';
3
- export declare const createPlugin: ({ dispatch, getIntl }: PMPluginFactoryParams, { appearance }: {
4
- appearance: EditorProps['appearance'];
5
- }) => SafePlugin<import("./types").CodeBidiWarningPluginState>;
@@ -1,8 +0,0 @@
1
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
- export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("./types").CodeBidiWarningPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState)) => import("prosemirror-state").SafeStateField<import("./types").CodeBidiWarningPluginState>, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState;
4
- export declare function createBidiWarningsDecorationSetFromDoc({ doc, codeBidiWarningLabel, tooltipEnabled, }: {
5
- doc: PmNode;
6
- codeBidiWarningLabel: string;
7
- tooltipEnabled: boolean;
8
- }): DecorationSet;
@@ -1,3 +0,0 @@
1
- import { CodeBidiWarningPluginState } from './types';
2
- declare const _default: (pluginState: CodeBidiWarningPluginState, action: unknown) => CodeBidiWarningPluginState;
3
- export default _default;
@@ -1,6 +0,0 @@
1
- import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
- export type CodeBidiWarningPluginState = {
3
- decorationSet: DecorationSet;
4
- codeBidiWarningLabel: string;
5
- tooltipEnabled: boolean;
6
- };