@atlaskit/editor-plugin-code-block 3.3.12 → 3.3.14
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 +21 -0
- package/dist/cjs/nodeviews/code-block.js +5 -1
- package/dist/cjs/pm-plugins/decorators.js +12 -4
- package/dist/cjs/pm-plugins/main.js +9 -4
- package/dist/es2019/nodeviews/code-block.js +4 -1
- package/dist/es2019/pm-plugins/decorators.js +11 -4
- package/dist/es2019/pm-plugins/main.js +9 -2
- package/dist/esm/nodeviews/code-block.js +4 -1
- package/dist/esm/pm-plugins/decorators.js +11 -4
- package/dist/esm/pm-plugins/main.js +9 -2
- package/dist/types/pm-plugins/decorators.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/decorators.d.ts +1 -1
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.3.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#138118](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138118)
|
|
8
|
+
[`5e4d9eb1aefe4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5e4d9eb1aefe4) -
|
|
9
|
+
NOISSUE: Upgrades editor React peer dependencies to v18
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.3.13
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#136871](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136871)
|
|
17
|
+
[`87a30d5cb3ffb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/87a30d5cb3ffb) -
|
|
18
|
+
ED-24814 - Addressing a bug where changing the language on a wrapped code block caused the wrapped
|
|
19
|
+
decorator to disappear. Required changing the sequence in which we update the keys on the wrapped
|
|
20
|
+
states WeakMap. Due to the amount of changes, it has all be placed behind a bug fix feature gate
|
|
21
|
+
(editor_code_block_wrapping_language_change_bug) and the original feature gate
|
|
22
|
+
(editor_support_code_block_wrapping).
|
|
23
|
+
|
|
3
24
|
## 3.3.12
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -16,6 +16,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
16
16
|
var _actions = require("../actions");
|
|
17
17
|
var _mainState = require("../pm-plugins/main-state");
|
|
18
18
|
var _classNames = require("../ui/class-names");
|
|
19
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
20
|
+
|
|
19
21
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
20
22
|
var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
21
23
|
return ['div', {
|
|
@@ -167,7 +169,9 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
167
169
|
}
|
|
168
170
|
if (node !== this.node) {
|
|
169
171
|
if ((0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping')) {
|
|
170
|
-
(0,
|
|
172
|
+
if (!(0, _platformFeatureFlags.fg)('editor_code_block_wrapping_language_change_bug')) {
|
|
173
|
+
(0, _codeBlock.transferCodeBlockWrappedValue)(this.node, node);
|
|
174
|
+
}
|
|
171
175
|
}
|
|
172
176
|
if (node.attrs.language !== this.node.attrs.language) {
|
|
173
177
|
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
@@ -8,8 +8,11 @@ exports.validateWordWrappedDecorators = exports.updateDecorationSetWithWordWrapp
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _classNames = require("../ui/class-names");
|
|
12
13
|
var _utils = require("../utils");
|
|
14
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
15
|
+
|
|
13
16
|
var DECORATION_WIDGET_TYPE = exports.DECORATION_WIDGET_TYPE = 'decorationWidgetType';
|
|
14
17
|
var DECORATION_WRAPPED_BLOCK_NODE_TYPE = exports.DECORATION_WRAPPED_BLOCK_NODE_TYPE = 'decorationNodeType';
|
|
15
18
|
|
|
@@ -26,9 +29,8 @@ var generateInitialDecorations = exports.generateInitialDecorations = function g
|
|
|
26
29
|
/**
|
|
27
30
|
* Update all the decorations used by the code block.
|
|
28
31
|
*/
|
|
29
|
-
var updateCodeBlockDecorations = exports.updateCodeBlockDecorations = function updateCodeBlockDecorations(tr,
|
|
32
|
+
var updateCodeBlockDecorations = exports.updateCodeBlockDecorations = function updateCodeBlockDecorations(tr, codeBlockNodes, decorationSet) {
|
|
30
33
|
var updatedDecorationSet = decorationSet;
|
|
31
|
-
var codeBlockNodes = (0, _utils.getAllCodeBlockNodesInDoc)(state);
|
|
32
34
|
|
|
33
35
|
// All the line numbers decorators are refreshed on doc change.
|
|
34
36
|
updatedDecorationSet = updateDecorationSetWithLineNumberDecorators(tr, codeBlockNodes, updatedDecorationSet);
|
|
@@ -129,8 +131,14 @@ var validateWordWrappedDecorators = exports.validateWordWrappedDecorators = func
|
|
|
129
131
|
codeBlockNodes.forEach(function (node) {
|
|
130
132
|
var isCodeBlockWrappedInState = (0, _codeBlock.isCodeBlockWordWrapEnabled)(node.node);
|
|
131
133
|
var isCodeBlockWrappedByDecorator = getWordWrapDecoratorsFromNodePos(node.pos, decorationSet).length !== 0;
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
+
if ((0, _platformFeatureFlags.fg)('editor_code_block_wrapping_language_change_bug')) {
|
|
135
|
+
if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
|
|
136
|
+
updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
if (isCodeBlockWrappedInState && !isCodeBlockWrappedByDecorator) {
|
|
140
|
+
updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
});
|
|
136
144
|
return updatedDecorationSet;
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
10
|
+
var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
10
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
13
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
@@ -14,14 +15,14 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
14
15
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
15
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _actions = require("../actions");
|
|
17
|
-
var
|
|
18
|
+
var _codeBlock2 = require("../nodeviews/code-block");
|
|
18
19
|
var _pluginKey = require("../plugin-key");
|
|
19
20
|
var _classNames = require("../ui/class-names");
|
|
20
21
|
var _utils = require("../utils");
|
|
21
22
|
var _actions2 = require("./actions");
|
|
22
23
|
var _decorators = require("./decorators");
|
|
23
24
|
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; }
|
|
24
|
-
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; }
|
|
25
|
+
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; } /* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
25
26
|
var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
26
27
|
var _ref$useLongPressSele = _ref.useLongPressSelection,
|
|
27
28
|
useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele,
|
|
@@ -97,7 +98,11 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
97
98
|
// specifically used for updating word wrap node decorators (does not cover drag & drop, validateWordWrappedDecorators does).
|
|
98
99
|
var updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
|
|
99
100
|
if ((0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping')) {
|
|
100
|
-
|
|
101
|
+
var codeBlockNodes = (0, _utils.getAllCodeBlockNodesInDoc)(newState);
|
|
102
|
+
if ((0, _platformFeatureFlags.fg)('editor_code_block_wrapping_language_change_bug')) {
|
|
103
|
+
(0, _codeBlock.updateCodeBlockWrappedStateNodeKeys)(codeBlockNodes, _oldState);
|
|
104
|
+
}
|
|
105
|
+
updatedDecorationSet = (0, _decorators.updateCodeBlockDecorations)(tr, codeBlockNodes, updatedDecorationSet);
|
|
101
106
|
}
|
|
102
107
|
var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
103
108
|
pos: _node ? _node.pos : null,
|
|
@@ -139,7 +144,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
139
144
|
var _getIntl = getIntl(),
|
|
140
145
|
formatMessage = _getIntl.formatMessage;
|
|
141
146
|
var formattedAriaLabel = formatMessage(_messages.blockTypeMessages.codeblock);
|
|
142
|
-
return (0,
|
|
147
|
+
return (0, _codeBlock2.codeBlockNodeView)(node, view, getPos, formattedAriaLabel, api);
|
|
143
148
|
}
|
|
144
149
|
},
|
|
145
150
|
handleClickOn: (0, _selection.createSelectionClickHandler)(['codeBlock'], function (target) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
2
3
|
import rafSchedule from 'raf-schd';
|
|
3
4
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
4
5
|
import { codeBlockWrappedStates, defaultWordWrapState, transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
|
|
@@ -144,7 +145,9 @@ export class CodeBlockView {
|
|
|
144
145
|
}
|
|
145
146
|
if (node !== this.node) {
|
|
146
147
|
if (fg('editor_support_code_block_wrapping')) {
|
|
147
|
-
|
|
148
|
+
if (!fg('editor_code_block_wrapping_language_change_bug')) {
|
|
149
|
+
transferCodeBlockWrappedValue(this.node, node);
|
|
150
|
+
}
|
|
148
151
|
}
|
|
149
152
|
if (node.attrs.language !== this.node.attrs.language) {
|
|
150
153
|
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
1
2
|
import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
2
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
5
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
4
6
|
import { getAllCodeBlockNodesInDoc } from '../utils';
|
|
5
7
|
export const DECORATION_WIDGET_TYPE = 'decorationWidgetType';
|
|
@@ -16,9 +18,8 @@ export const generateInitialDecorations = state => {
|
|
|
16
18
|
/**
|
|
17
19
|
* Update all the decorations used by the code block.
|
|
18
20
|
*/
|
|
19
|
-
export const updateCodeBlockDecorations = (tr,
|
|
21
|
+
export const updateCodeBlockDecorations = (tr, codeBlockNodes, decorationSet) => {
|
|
20
22
|
let updatedDecorationSet = decorationSet;
|
|
21
|
-
const codeBlockNodes = getAllCodeBlockNodesInDoc(state);
|
|
22
23
|
|
|
23
24
|
// All the line numbers decorators are refreshed on doc change.
|
|
24
25
|
updatedDecorationSet = updateDecorationSetWithLineNumberDecorators(tr, codeBlockNodes, updatedDecorationSet);
|
|
@@ -119,8 +120,14 @@ export const validateWordWrappedDecorators = (tr, codeBlockNodes, decorationSet)
|
|
|
119
120
|
codeBlockNodes.forEach(node => {
|
|
120
121
|
const isCodeBlockWrappedInState = isCodeBlockWordWrapEnabled(node.node);
|
|
121
122
|
const isCodeBlockWrappedByDecorator = getWordWrapDecoratorsFromNodePos(node.pos, decorationSet).length !== 0;
|
|
122
|
-
if (
|
|
123
|
-
|
|
123
|
+
if (fg('editor_code_block_wrapping_language_change_bug')) {
|
|
124
|
+
if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
|
|
125
|
+
updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
if (isCodeBlockWrappedInState && !isCodeBlockWrappedByDecorator) {
|
|
129
|
+
updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
|
|
130
|
+
}
|
|
124
131
|
}
|
|
125
132
|
});
|
|
126
133
|
return updatedDecorationSet;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
2
|
+
|
|
1
3
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
4
|
+
import { updateCodeBlockWrappedStateNodeKeys } from '@atlaskit/editor-common/code-block';
|
|
2
5
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
3
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
7
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
@@ -9,7 +12,7 @@ import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '.
|
|
|
9
12
|
import { codeBlockNodeView } from '../nodeviews/code-block';
|
|
10
13
|
import { pluginKey } from '../plugin-key';
|
|
11
14
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
12
|
-
import { findCodeBlock } from '../utils';
|
|
15
|
+
import { findCodeBlock, getAllCodeBlockNodesInDoc } from '../utils';
|
|
13
16
|
import { ACTIONS } from './actions';
|
|
14
17
|
import { generateInitialDecorations, updateCodeBlockDecorations, updateDecorationSetWithWordWrappedDecorator } from './decorators';
|
|
15
18
|
export const createPlugin = ({
|
|
@@ -85,7 +88,11 @@ export const createPlugin = ({
|
|
|
85
88
|
// specifically used for updating word wrap node decorators (does not cover drag & drop, validateWordWrappedDecorators does).
|
|
86
89
|
let updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
|
|
87
90
|
if (fg('editor_support_code_block_wrapping')) {
|
|
88
|
-
|
|
91
|
+
const codeBlockNodes = getAllCodeBlockNodesInDoc(newState);
|
|
92
|
+
if (fg('editor_code_block_wrapping_language_change_bug')) {
|
|
93
|
+
updateCodeBlockWrappedStateNodeKeys(codeBlockNodes, _oldState);
|
|
94
|
+
}
|
|
95
|
+
updatedDecorationSet = updateCodeBlockDecorations(tr, codeBlockNodes, updatedDecorationSet);
|
|
89
96
|
}
|
|
90
97
|
const newPluginState = {
|
|
91
98
|
...pluginState,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
4
5
|
import rafSchedule from 'raf-schd';
|
|
5
6
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
6
7
|
import { codeBlockWrappedStates, defaultWordWrapState, transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
|
|
@@ -160,7 +161,9 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
160
161
|
}
|
|
161
162
|
if (node !== this.node) {
|
|
162
163
|
if (fg('editor_support_code_block_wrapping')) {
|
|
163
|
-
|
|
164
|
+
if (!fg('editor_code_block_wrapping_language_change_bug')) {
|
|
165
|
+
transferCodeBlockWrappedValue(this.node, node);
|
|
166
|
+
}
|
|
164
167
|
}
|
|
165
168
|
if (node.attrs.language !== this.node.attrs.language) {
|
|
166
169
|
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
2
3
|
import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
3
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
6
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
5
7
|
import { getAllCodeBlockNodesInDoc } from '../utils';
|
|
6
8
|
export var DECORATION_WIDGET_TYPE = 'decorationWidgetType';
|
|
@@ -19,9 +21,8 @@ export var generateInitialDecorations = function generateInitialDecorations(stat
|
|
|
19
21
|
/**
|
|
20
22
|
* Update all the decorations used by the code block.
|
|
21
23
|
*/
|
|
22
|
-
export var updateCodeBlockDecorations = function updateCodeBlockDecorations(tr,
|
|
24
|
+
export var updateCodeBlockDecorations = function updateCodeBlockDecorations(tr, codeBlockNodes, decorationSet) {
|
|
23
25
|
var updatedDecorationSet = decorationSet;
|
|
24
|
-
var codeBlockNodes = getAllCodeBlockNodesInDoc(state);
|
|
25
26
|
|
|
26
27
|
// All the line numbers decorators are refreshed on doc change.
|
|
27
28
|
updatedDecorationSet = updateDecorationSetWithLineNumberDecorators(tr, codeBlockNodes, updatedDecorationSet);
|
|
@@ -122,8 +123,14 @@ export var validateWordWrappedDecorators = function validateWordWrappedDecorator
|
|
|
122
123
|
codeBlockNodes.forEach(function (node) {
|
|
123
124
|
var isCodeBlockWrappedInState = isCodeBlockWordWrapEnabled(node.node);
|
|
124
125
|
var isCodeBlockWrappedByDecorator = getWordWrapDecoratorsFromNodePos(node.pos, decorationSet).length !== 0;
|
|
125
|
-
if (
|
|
126
|
-
|
|
126
|
+
if (fg('editor_code_block_wrapping_language_change_bug')) {
|
|
127
|
+
if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
|
|
128
|
+
updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
if (isCodeBlockWrappedInState && !isCodeBlockWrappedByDecorator) {
|
|
132
|
+
updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
|
|
133
|
+
}
|
|
127
134
|
}
|
|
128
135
|
});
|
|
129
136
|
return updatedDecorationSet;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
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
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
|
+
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
5
|
+
|
|
4
6
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
7
|
+
import { updateCodeBlockWrappedStateNodeKeys } from '@atlaskit/editor-common/code-block';
|
|
5
8
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
9
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
10
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
@@ -12,7 +15,7 @@ import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '.
|
|
|
12
15
|
import { codeBlockNodeView } from '../nodeviews/code-block';
|
|
13
16
|
import { pluginKey } from '../plugin-key';
|
|
14
17
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
15
|
-
import { findCodeBlock } from '../utils';
|
|
18
|
+
import { findCodeBlock, getAllCodeBlockNodesInDoc } from '../utils';
|
|
16
19
|
import { ACTIONS } from './actions';
|
|
17
20
|
import { generateInitialDecorations, updateCodeBlockDecorations, updateDecorationSetWithWordWrappedDecorator } from './decorators';
|
|
18
21
|
export var createPlugin = function createPlugin(_ref) {
|
|
@@ -90,7 +93,11 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
90
93
|
// specifically used for updating word wrap node decorators (does not cover drag & drop, validateWordWrappedDecorators does).
|
|
91
94
|
var updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
|
|
92
95
|
if (fg('editor_support_code_block_wrapping')) {
|
|
93
|
-
|
|
96
|
+
var codeBlockNodes = getAllCodeBlockNodesInDoc(newState);
|
|
97
|
+
if (fg('editor_code_block_wrapping_language_change_bug')) {
|
|
98
|
+
updateCodeBlockWrappedStateNodeKeys(codeBlockNodes, _oldState);
|
|
99
|
+
}
|
|
100
|
+
updatedDecorationSet = updateCodeBlockDecorations(tr, codeBlockNodes, updatedDecorationSet);
|
|
94
101
|
}
|
|
95
102
|
var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
96
103
|
pos: _node ? _node.pos : null,
|
|
@@ -11,7 +11,7 @@ export declare const generateInitialDecorations: (state: EditorState) => Decorat
|
|
|
11
11
|
/**
|
|
12
12
|
* Update all the decorations used by the code block.
|
|
13
13
|
*/
|
|
14
|
-
export declare const updateCodeBlockDecorations: (tr: ReadonlyTransaction,
|
|
14
|
+
export declare const updateCodeBlockDecorations: (tr: ReadonlyTransaction, codeBlockNodes: NodeWithPos[], decorationSet: DecorationSet) => DecorationSet;
|
|
15
15
|
/**
|
|
16
16
|
* Update the decorations set with the line number decorators.
|
|
17
17
|
*/
|
|
@@ -11,7 +11,7 @@ export declare const generateInitialDecorations: (state: EditorState) => Decorat
|
|
|
11
11
|
/**
|
|
12
12
|
* Update all the decorations used by the code block.
|
|
13
13
|
*/
|
|
14
|
-
export declare const updateCodeBlockDecorations: (tr: ReadonlyTransaction,
|
|
14
|
+
export declare const updateCodeBlockDecorations: (tr: ReadonlyTransaction, codeBlockNodes: NodeWithPos[], decorationSet: DecorationSet) => DecorationSet;
|
|
15
15
|
/**
|
|
16
16
|
* Update the decorations set with the line number decorators.
|
|
17
17
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.14",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor: Core Experiences",
|
|
12
12
|
"singleton": true,
|
|
13
|
-
"runReact18":
|
|
13
|
+
"runReact18": true
|
|
14
14
|
},
|
|
15
15
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
16
16
|
"main": "dist/cjs/index.js",
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
35
35
|
"@atlaskit/code": "^15.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^88.
|
|
36
|
+
"@atlaskit/editor-common": "^88.12.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
38
38
|
"@atlaskit/editor-plugin-composition": "^1.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
42
|
-
"@atlaskit/icon": "^22.
|
|
42
|
+
"@atlaskit/icon": "^22.16.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
44
44
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"raf-schd": "^4.0.3"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"react": "^16.8.0",
|
|
49
|
+
"react": "^16.8.0 || ^17.0.0 || ~18.2.0",
|
|
50
50
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -97,6 +97,9 @@
|
|
|
97
97
|
"code_block_auto_insertion_bug_fix": {
|
|
98
98
|
"type": "boolean"
|
|
99
99
|
},
|
|
100
|
+
"editor_code_block_wrapping_language_change_bug": {
|
|
101
|
+
"type": "boolean"
|
|
102
|
+
},
|
|
100
103
|
"platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
|
|
101
104
|
"type": "boolean"
|
|
102
105
|
}
|