@atlaskit/editor-plugin-code-bidi-warning 1.2.10 → 1.2.11
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 +9 -0
- package/dist/cjs/pm-plugins/main.js +9 -4
- package/dist/cjs/pm-plugins/plugin-factory.js +43 -18
- package/dist/es2019/pm-plugins/main.js +9 -3
- package/dist/es2019/pm-plugins/plugin-factory.js +38 -18
- package/dist/esm/pm-plugins/main.js +8 -3
- package/dist/esm/pm-plugins/plugin-factory.js +42 -18
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/plugin-factory.d.ts +8 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +8 -2
- package/package.json +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-bidi-warning
|
|
2
2
|
|
|
3
|
+
## 1.2.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#161849](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/161849)
|
|
8
|
+
[`3f274c6c27b24`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f274c6c27b24) -
|
|
9
|
+
ED-25608: removes reactdom.render from code-bidi-warning
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 1.2.10
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -10,18 +10,23 @@ var _pluginKey = require("../plugin-key");
|
|
|
10
10
|
var _pluginFactory = require("./plugin-factory");
|
|
11
11
|
var createPlugin = exports.createPlugin = function createPlugin(_ref, _ref2) {
|
|
12
12
|
var dispatch = _ref.dispatch,
|
|
13
|
-
getIntl = _ref.getIntl
|
|
13
|
+
getIntl = _ref.getIntl,
|
|
14
|
+
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI;
|
|
14
15
|
var appearance = _ref2.appearance;
|
|
15
16
|
var intl = getIntl();
|
|
16
17
|
var codeBidiWarningLabel = intl.formatMessage(_messages.codeBidiWarningMessages.label);
|
|
18
|
+
var _pluginFactoryCreator = (0, _pluginFactory.pluginFactoryCreator)(nodeViewPortalProviderAPI),
|
|
19
|
+
createPluginState = _pluginFactoryCreator.createPluginState,
|
|
20
|
+
getPluginState = _pluginFactoryCreator.getPluginState;
|
|
17
21
|
return new _safePlugin.SafePlugin({
|
|
18
22
|
key: _pluginKey.codeBidiWarningPluginKey,
|
|
19
|
-
state:
|
|
23
|
+
state: createPluginState(dispatch, function (state) {
|
|
20
24
|
return {
|
|
21
25
|
decorationSet: (0, _pluginFactory.createBidiWarningsDecorationSetFromDoc)({
|
|
22
26
|
doc: state.doc,
|
|
23
27
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
24
|
-
tooltipEnabled: true
|
|
28
|
+
tooltipEnabled: true,
|
|
29
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI
|
|
25
30
|
}),
|
|
26
31
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
27
32
|
tooltipEnabled: true
|
|
@@ -29,7 +34,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref, _ref2) {
|
|
|
29
34
|
}),
|
|
30
35
|
props: {
|
|
31
36
|
decorations: function decorations(state) {
|
|
32
|
-
var _getPluginState =
|
|
37
|
+
var _getPluginState = getPluginState(state),
|
|
33
38
|
decorationSet = _getPluginState.decorationSet;
|
|
34
39
|
return decorationSet;
|
|
35
40
|
}
|
|
@@ -5,19 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createBidiWarningsDecorationSetFromDoc = createBidiWarningsDecorationSetFromDoc;
|
|
8
|
-
exports.
|
|
8
|
+
exports.pluginFactoryCreator = void 0;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
12
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
12
13
|
var _bidiWarning = _interopRequireDefault(require("@atlaskit/code/bidi-warning"));
|
|
13
14
|
var _bidiWarningDecorator = _interopRequireDefault(require("@atlaskit/code/bidi-warning-decorator"));
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
16
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
18
|
var _pluginKey = require("../plugin-key");
|
|
17
19
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
18
20
|
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; }
|
|
19
21
|
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; }
|
|
20
|
-
var
|
|
22
|
+
var pluginFactoryCreator = exports.pluginFactoryCreator = function pluginFactoryCreator(nodeViewPortalProviderAPI) {
|
|
23
|
+
return (0, _utils.pluginFactory)(_pluginKey.codeBidiWarningPluginKey, _reducer.default, {
|
|
21
24
|
onDocChanged: function onDocChanged(tr, pluginState) {
|
|
22
25
|
if (!tr.steps.find(_utils.stepHasSlice)) {
|
|
23
26
|
return pluginState;
|
|
@@ -25,19 +28,20 @@ var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.codeBidiWarningPluginK
|
|
|
25
28
|
var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
|
|
26
29
|
doc: tr.doc,
|
|
27
30
|
codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
|
|
28
|
-
tooltipEnabled: pluginState.tooltipEnabled
|
|
31
|
+
tooltipEnabled: pluginState.tooltipEnabled,
|
|
32
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI
|
|
29
33
|
});
|
|
30
34
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
31
35
|
decorationSet: newBidiWarningsDecorationSet
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
getPluginState = exports.getPluginState = _pluginFactory.getPluginState;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
37
40
|
function createBidiWarningsDecorationSetFromDoc(_ref) {
|
|
38
41
|
var doc = _ref.doc,
|
|
39
42
|
codeBidiWarningLabel = _ref.codeBidiWarningLabel,
|
|
40
|
-
tooltipEnabled = _ref.tooltipEnabled
|
|
43
|
+
tooltipEnabled = _ref.tooltipEnabled,
|
|
44
|
+
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI;
|
|
41
45
|
var bidiCharactersAndTheirPositions = [];
|
|
42
46
|
doc.descendants(function (node, pos) {
|
|
43
47
|
var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
|
|
@@ -76,12 +80,21 @@ function createBidiWarningsDecorationSetFromDoc(_ref) {
|
|
|
76
80
|
var newBidiWarningsDecorationSet = _view.DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(function (_ref4) {
|
|
77
81
|
var position = _ref4.position,
|
|
78
82
|
bidiCharacter = _ref4.bidiCharacter;
|
|
83
|
+
var renderKey = (0, _v.default)();
|
|
79
84
|
return _view.Decoration.widget(position, function () {
|
|
80
85
|
return renderDOM({
|
|
81
86
|
bidiCharacter: bidiCharacter,
|
|
82
87
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
83
|
-
tooltipEnabled: tooltipEnabled
|
|
88
|
+
tooltipEnabled: tooltipEnabled,
|
|
89
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
|
|
90
|
+
renderKey: renderKey
|
|
84
91
|
});
|
|
92
|
+
}, {
|
|
93
|
+
destroy: function destroy() {
|
|
94
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
95
|
+
nodeViewPortalProviderAPI.remove(renderKey);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
85
98
|
});
|
|
86
99
|
}));
|
|
87
100
|
return newBidiWarningsDecorationSet;
|
|
@@ -89,16 +102,28 @@ function createBidiWarningsDecorationSetFromDoc(_ref) {
|
|
|
89
102
|
function renderDOM(_ref5) {
|
|
90
103
|
var bidiCharacter = _ref5.bidiCharacter,
|
|
91
104
|
codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
|
|
92
|
-
tooltipEnabled = _ref5.tooltipEnabled
|
|
105
|
+
tooltipEnabled = _ref5.tooltipEnabled,
|
|
106
|
+
nodeViewPortalProviderAPI = _ref5.nodeViewPortalProviderAPI,
|
|
107
|
+
renderKey = _ref5.renderKey;
|
|
93
108
|
var element = document.createElement('span');
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
110
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
|
|
112
|
+
bidiCharacter: bidiCharacter,
|
|
113
|
+
skipChildren: true,
|
|
114
|
+
label: codeBidiWarningLabel,
|
|
115
|
+
tooltipEnabled: tooltipEnabled
|
|
116
|
+
});
|
|
117
|
+
}, element, renderKey);
|
|
118
|
+
} else {
|
|
119
|
+
// Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
|
|
120
|
+
// we should investigate if there is a memory leak with such usage.
|
|
121
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
|
|
122
|
+
bidiCharacter: bidiCharacter,
|
|
123
|
+
skipChildren: true,
|
|
124
|
+
label: codeBidiWarningLabel,
|
|
125
|
+
tooltipEnabled: tooltipEnabled
|
|
126
|
+
}), element);
|
|
127
|
+
}
|
|
103
128
|
return element;
|
|
104
129
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { codeBidiWarningPluginKey } from '../plugin-key';
|
|
4
|
-
import { createBidiWarningsDecorationSetFromDoc,
|
|
4
|
+
import { createBidiWarningsDecorationSetFromDoc, pluginFactoryCreator } from './plugin-factory';
|
|
5
5
|
export const createPlugin = ({
|
|
6
6
|
dispatch,
|
|
7
|
-
getIntl
|
|
7
|
+
getIntl,
|
|
8
|
+
nodeViewPortalProviderAPI
|
|
8
9
|
}, {
|
|
9
10
|
appearance
|
|
10
11
|
}) => {
|
|
11
12
|
const intl = getIntl();
|
|
12
13
|
const codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
|
|
14
|
+
const {
|
|
15
|
+
createPluginState,
|
|
16
|
+
getPluginState
|
|
17
|
+
} = pluginFactoryCreator(nodeViewPortalProviderAPI);
|
|
13
18
|
return new SafePlugin({
|
|
14
19
|
key: codeBidiWarningPluginKey,
|
|
15
20
|
state: createPluginState(dispatch, state => {
|
|
@@ -17,7 +22,8 @@ export const createPlugin = ({
|
|
|
17
22
|
decorationSet: createBidiWarningsDecorationSetFromDoc({
|
|
18
23
|
doc: state.doc,
|
|
19
24
|
codeBidiWarningLabel,
|
|
20
|
-
tooltipEnabled: true
|
|
25
|
+
tooltipEnabled: true,
|
|
26
|
+
nodeViewPortalProviderAPI
|
|
21
27
|
}),
|
|
22
28
|
codeBidiWarningLabel,
|
|
23
29
|
tooltipEnabled: true
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
|
+
import uuid from 'uuid/v4';
|
|
3
4
|
import CodeBidiWarning from '@atlaskit/code/bidi-warning';
|
|
4
5
|
import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
|
|
5
6
|
import { pluginFactory, stepHasSlice } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
import { codeBidiWarningPluginKey } from '../plugin-key';
|
|
8
10
|
import reducer from './reducer';
|
|
9
|
-
export const {
|
|
10
|
-
createPluginState,
|
|
11
|
-
getPluginState
|
|
12
|
-
} = pluginFactory(codeBidiWarningPluginKey, reducer, {
|
|
11
|
+
export const pluginFactoryCreator = nodeViewPortalProviderAPI => pluginFactory(codeBidiWarningPluginKey, reducer, {
|
|
13
12
|
onDocChanged: (tr, pluginState) => {
|
|
14
13
|
if (!tr.steps.find(stepHasSlice)) {
|
|
15
14
|
return pluginState;
|
|
@@ -17,7 +16,8 @@ export const {
|
|
|
17
16
|
const newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
|
|
18
17
|
doc: tr.doc,
|
|
19
18
|
codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
|
|
20
|
-
tooltipEnabled: pluginState.tooltipEnabled
|
|
19
|
+
tooltipEnabled: pluginState.tooltipEnabled,
|
|
20
|
+
nodeViewPortalProviderAPI
|
|
21
21
|
});
|
|
22
22
|
return {
|
|
23
23
|
...pluginState,
|
|
@@ -28,7 +28,8 @@ export const {
|
|
|
28
28
|
export function createBidiWarningsDecorationSetFromDoc({
|
|
29
29
|
doc,
|
|
30
30
|
codeBidiWarningLabel,
|
|
31
|
-
tooltipEnabled
|
|
31
|
+
tooltipEnabled,
|
|
32
|
+
nodeViewPortalProviderAPI
|
|
32
33
|
}) {
|
|
33
34
|
const bidiCharactersAndTheirPositions = [];
|
|
34
35
|
doc.descendants((node, pos) => {
|
|
@@ -69,28 +70,47 @@ export function createBidiWarningsDecorationSetFromDoc({
|
|
|
69
70
|
position,
|
|
70
71
|
bidiCharacter
|
|
71
72
|
}) => {
|
|
73
|
+
const renderKey = uuid();
|
|
72
74
|
return Decoration.widget(position, () => renderDOM({
|
|
73
75
|
bidiCharacter,
|
|
74
76
|
codeBidiWarningLabel,
|
|
75
|
-
tooltipEnabled
|
|
76
|
-
|
|
77
|
+
tooltipEnabled,
|
|
78
|
+
nodeViewPortalProviderAPI,
|
|
79
|
+
renderKey
|
|
80
|
+
}), {
|
|
81
|
+
destroy: () => {
|
|
82
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
83
|
+
nodeViewPortalProviderAPI.remove(renderKey);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
77
87
|
}));
|
|
78
88
|
return newBidiWarningsDecorationSet;
|
|
79
89
|
}
|
|
80
90
|
function renderDOM({
|
|
81
91
|
bidiCharacter,
|
|
82
92
|
codeBidiWarningLabel,
|
|
83
|
-
tooltipEnabled
|
|
93
|
+
tooltipEnabled,
|
|
94
|
+
nodeViewPortalProviderAPI,
|
|
95
|
+
renderKey
|
|
84
96
|
}) {
|
|
85
97
|
const element = document.createElement('span');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
99
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
100
|
+
bidiCharacter: bidiCharacter,
|
|
101
|
+
skipChildren: true,
|
|
102
|
+
label: codeBidiWarningLabel,
|
|
103
|
+
tooltipEnabled: tooltipEnabled
|
|
104
|
+
}), element, renderKey);
|
|
105
|
+
} else {
|
|
106
|
+
// Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
|
|
107
|
+
// we should investigate if there is a memory leak with such usage.
|
|
108
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
109
|
+
bidiCharacter: bidiCharacter,
|
|
110
|
+
skipChildren: true,
|
|
111
|
+
label: codeBidiWarningLabel,
|
|
112
|
+
tooltipEnabled: tooltipEnabled
|
|
113
|
+
}), element);
|
|
114
|
+
}
|
|
95
115
|
return element;
|
|
96
116
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { codeBidiWarningPluginKey } from '../plugin-key';
|
|
4
|
-
import { createBidiWarningsDecorationSetFromDoc,
|
|
4
|
+
import { createBidiWarningsDecorationSetFromDoc, pluginFactoryCreator } from './plugin-factory';
|
|
5
5
|
export var createPlugin = function createPlugin(_ref, _ref2) {
|
|
6
6
|
var dispatch = _ref.dispatch,
|
|
7
|
-
getIntl = _ref.getIntl
|
|
7
|
+
getIntl = _ref.getIntl,
|
|
8
|
+
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI;
|
|
8
9
|
var appearance = _ref2.appearance;
|
|
9
10
|
var intl = getIntl();
|
|
10
11
|
var codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
|
|
12
|
+
var _pluginFactoryCreator = pluginFactoryCreator(nodeViewPortalProviderAPI),
|
|
13
|
+
createPluginState = _pluginFactoryCreator.createPluginState,
|
|
14
|
+
getPluginState = _pluginFactoryCreator.getPluginState;
|
|
11
15
|
return new SafePlugin({
|
|
12
16
|
key: codeBidiWarningPluginKey,
|
|
13
17
|
state: createPluginState(dispatch, function (state) {
|
|
@@ -15,7 +19,8 @@ export var createPlugin = function createPlugin(_ref, _ref2) {
|
|
|
15
19
|
decorationSet: createBidiWarningsDecorationSetFromDoc({
|
|
16
20
|
doc: state.doc,
|
|
17
21
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
18
|
-
tooltipEnabled: true
|
|
22
|
+
tooltipEnabled: true,
|
|
23
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI
|
|
19
24
|
}),
|
|
20
25
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
21
26
|
tooltipEnabled: true
|
|
@@ -3,13 +3,16 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
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
4
|
import React from 'react';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
+
import uuid from 'uuid/v4';
|
|
6
7
|
import CodeBidiWarning from '@atlaskit/code/bidi-warning';
|
|
7
8
|
import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
|
|
8
9
|
import { pluginFactory, stepHasSlice } from '@atlaskit/editor-common/utils';
|
|
9
10
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
12
|
import { codeBidiWarningPluginKey } from '../plugin-key';
|
|
11
13
|
import reducer from './reducer';
|
|
12
|
-
var
|
|
14
|
+
export var pluginFactoryCreator = function pluginFactoryCreator(nodeViewPortalProviderAPI) {
|
|
15
|
+
return pluginFactory(codeBidiWarningPluginKey, reducer, {
|
|
13
16
|
onDocChanged: function onDocChanged(tr, pluginState) {
|
|
14
17
|
if (!tr.steps.find(stepHasSlice)) {
|
|
15
18
|
return pluginState;
|
|
@@ -17,20 +20,20 @@ var _pluginFactory = pluginFactory(codeBidiWarningPluginKey, reducer, {
|
|
|
17
20
|
var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
|
|
18
21
|
doc: tr.doc,
|
|
19
22
|
codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
|
|
20
|
-
tooltipEnabled: pluginState.tooltipEnabled
|
|
23
|
+
tooltipEnabled: pluginState.tooltipEnabled,
|
|
24
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI
|
|
21
25
|
});
|
|
22
26
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
23
27
|
decorationSet: newBidiWarningsDecorationSet
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
getPluginState = _pluginFactory.getPluginState;
|
|
29
|
-
export { createPluginState, getPluginState };
|
|
30
|
+
});
|
|
31
|
+
};
|
|
30
32
|
export function createBidiWarningsDecorationSetFromDoc(_ref) {
|
|
31
33
|
var doc = _ref.doc,
|
|
32
34
|
codeBidiWarningLabel = _ref.codeBidiWarningLabel,
|
|
33
|
-
tooltipEnabled = _ref.tooltipEnabled
|
|
35
|
+
tooltipEnabled = _ref.tooltipEnabled,
|
|
36
|
+
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI;
|
|
34
37
|
var bidiCharactersAndTheirPositions = [];
|
|
35
38
|
doc.descendants(function (node, pos) {
|
|
36
39
|
var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
|
|
@@ -69,12 +72,21 @@ export function createBidiWarningsDecorationSetFromDoc(_ref) {
|
|
|
69
72
|
var newBidiWarningsDecorationSet = DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(function (_ref4) {
|
|
70
73
|
var position = _ref4.position,
|
|
71
74
|
bidiCharacter = _ref4.bidiCharacter;
|
|
75
|
+
var renderKey = uuid();
|
|
72
76
|
return Decoration.widget(position, function () {
|
|
73
77
|
return renderDOM({
|
|
74
78
|
bidiCharacter: bidiCharacter,
|
|
75
79
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
76
|
-
tooltipEnabled: tooltipEnabled
|
|
80
|
+
tooltipEnabled: tooltipEnabled,
|
|
81
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
|
|
82
|
+
renderKey: renderKey
|
|
77
83
|
});
|
|
84
|
+
}, {
|
|
85
|
+
destroy: function destroy() {
|
|
86
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
87
|
+
nodeViewPortalProviderAPI.remove(renderKey);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
78
90
|
});
|
|
79
91
|
}));
|
|
80
92
|
return newBidiWarningsDecorationSet;
|
|
@@ -82,16 +94,28 @@ export function createBidiWarningsDecorationSetFromDoc(_ref) {
|
|
|
82
94
|
function renderDOM(_ref5) {
|
|
83
95
|
var bidiCharacter = _ref5.bidiCharacter,
|
|
84
96
|
codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
|
|
85
|
-
tooltipEnabled = _ref5.tooltipEnabled
|
|
97
|
+
tooltipEnabled = _ref5.tooltipEnabled,
|
|
98
|
+
nodeViewPortalProviderAPI = _ref5.nodeViewPortalProviderAPI,
|
|
99
|
+
renderKey = _ref5.renderKey;
|
|
86
100
|
var element = document.createElement('span');
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
102
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
103
|
+
return /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
104
|
+
bidiCharacter: bidiCharacter,
|
|
105
|
+
skipChildren: true,
|
|
106
|
+
label: codeBidiWarningLabel,
|
|
107
|
+
tooltipEnabled: tooltipEnabled
|
|
108
|
+
});
|
|
109
|
+
}, element, renderKey);
|
|
110
|
+
} else {
|
|
111
|
+
// Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
|
|
112
|
+
// we should investigate if there is a memory leak with such usage.
|
|
113
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
114
|
+
bidiCharacter: bidiCharacter,
|
|
115
|
+
skipChildren: true,
|
|
116
|
+
label: codeBidiWarningLabel,
|
|
117
|
+
tooltipEnabled: tooltipEnabled
|
|
118
|
+
}), element);
|
|
119
|
+
}
|
|
96
120
|
return element;
|
|
97
121
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import type { EditorAppearance, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
-
export declare const createPlugin: ({ dispatch, getIntl }: PMPluginFactoryParams, { appearance }: {
|
|
3
|
+
export declare const createPlugin: ({ dispatch, getIntl, nodeViewPortalProviderAPI }: PMPluginFactoryParams, { appearance }: {
|
|
4
4
|
appearance?: EditorAppearance | undefined;
|
|
5
5
|
}) => SafePlugin<import("./types").CodeBidiWarningPluginState>;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
1
2
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
4
|
+
export declare const pluginFactoryCreator: (nodeViewPortalProviderAPI: PortalProviderAPI) => {
|
|
5
|
+
createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("./types").CodeBidiWarningPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState)) => import("prosemirror-state").SafeStateField<import("./types").CodeBidiWarningPluginState>;
|
|
6
|
+
createCommand: <A = unknown>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
7
|
+
getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState;
|
|
8
|
+
};
|
|
9
|
+
export declare function createBidiWarningsDecorationSetFromDoc({ doc, codeBidiWarningLabel, tooltipEnabled, nodeViewPortalProviderAPI, }: {
|
|
5
10
|
doc: PmNode;
|
|
6
11
|
codeBidiWarningLabel: string;
|
|
7
12
|
tooltipEnabled: boolean;
|
|
13
|
+
nodeViewPortalProviderAPI: PortalProviderAPI;
|
|
8
14
|
}): DecorationSet;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import type { EditorAppearance, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
-
export declare const createPlugin: ({ dispatch, getIntl }: PMPluginFactoryParams, { appearance }: {
|
|
3
|
+
export declare const createPlugin: ({ dispatch, getIntl, nodeViewPortalProviderAPI }: PMPluginFactoryParams, { appearance }: {
|
|
4
4
|
appearance?: EditorAppearance | undefined;
|
|
5
5
|
}) => SafePlugin<import("./types").CodeBidiWarningPluginState>;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
1
2
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
4
|
+
export declare const pluginFactoryCreator: (nodeViewPortalProviderAPI: PortalProviderAPI) => {
|
|
5
|
+
createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("./types").CodeBidiWarningPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState)) => import("prosemirror-state").SafeStateField<import("./types").CodeBidiWarningPluginState>;
|
|
6
|
+
createCommand: <A = unknown>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
7
|
+
getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState;
|
|
8
|
+
};
|
|
9
|
+
export declare function createBidiWarningsDecorationSetFromDoc({ doc, codeBidiWarningLabel, tooltipEnabled, nodeViewPortalProviderAPI, }: {
|
|
5
10
|
doc: PmNode;
|
|
6
11
|
codeBidiWarningLabel: string;
|
|
7
12
|
tooltipEnabled: boolean;
|
|
13
|
+
nodeViewPortalProviderAPI: PortalProviderAPI;
|
|
8
14
|
}): DecorationSet;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-bidi-warning",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Code bidi warning plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/code": "^15.6.0",
|
|
35
|
-
"@atlaskit/editor-common": "^94.
|
|
35
|
+
"@atlaskit/editor-common": "^94.19.0",
|
|
36
36
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
37
|
-
"@
|
|
37
|
+
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
38
|
+
"@babel/runtime": "^7.0.0",
|
|
39
|
+
"uuid": "^3.1.0"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
40
42
|
"react": "^16.8.0 || ^17.0.0 || ~18.2.0",
|
|
@@ -81,5 +83,10 @@
|
|
|
81
83
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
82
84
|
]
|
|
83
85
|
}
|
|
86
|
+
},
|
|
87
|
+
"platform-feature-flags": {
|
|
88
|
+
"platform_editor_react18_plugin_portalprovider": {
|
|
89
|
+
"type": "boolean"
|
|
90
|
+
}
|
|
84
91
|
}
|
|
85
92
|
}
|