@atlaskit/editor-plugin-code-block 4.2.6 → 4.2.8
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
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 4.2.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.2.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#137043](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/137043)
|
|
14
|
+
[`616c9cd4a2c60`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/616c9cd4a2c60) -
|
|
15
|
+
Fix line wrapping and decorations being lost on breakout in advanced codeblocks
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 4.2.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
9
9
|
var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _classNames = require("../ui/class-names");
|
|
13
14
|
var _utils = require("./utils");
|
|
14
15
|
/* eslint-disable @atlaskit/platform/ensure-feature-flag-prefix */
|
|
@@ -163,14 +164,27 @@ var updateDecorationSetWithWordWrappedDecorator = exports.updateDecorationSetWit
|
|
|
163
164
|
if (!isNodeWrapped) {
|
|
164
165
|
var currentWrappedBlockDecorationSet = getWordWrapDecoratorsFromNodePos(pos, updatedDecorationSet);
|
|
165
166
|
updatedDecorationSet = updatedDecorationSet.remove(currentWrappedBlockDecorationSet);
|
|
167
|
+
|
|
168
|
+
// In code block advanced we don't use the node decoration - however a change in decorations
|
|
169
|
+
// is how we detect updates to the word wrap. If we have no decorations attached we've
|
|
170
|
+
// likely changed the breakout width with the toggle ON - we add an empty decoration to force
|
|
171
|
+
// prosemirror to recognise the change so we can update in our node view. This gets filtered
|
|
172
|
+
// out on the next toggle.
|
|
173
|
+
if (currentWrappedBlockDecorationSet.length === 0 && (0, _experiments.editorExperiment)('platform_editor_advanced_code_blocks', true)) {
|
|
174
|
+
var wrappedBlock = _view.Decoration.node(pos, pos + innerNode.nodeSize, {}, {
|
|
175
|
+
type: DECORATION_WRAPPED_BLOCK_NODE_TYPE
|
|
176
|
+
} // Allows for quick filtering of decorations while using `find`
|
|
177
|
+
);
|
|
178
|
+
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [wrappedBlock]);
|
|
179
|
+
}
|
|
166
180
|
} else {
|
|
167
|
-
var
|
|
181
|
+
var _wrappedBlock = _view.Decoration.node(pos, pos + innerNode.nodeSize, {
|
|
168
182
|
class: _classNames.codeBlockClassNames.contentWrapped
|
|
169
183
|
}, {
|
|
170
184
|
type: DECORATION_WRAPPED_BLOCK_NODE_TYPE
|
|
171
185
|
} // Allows for quick filtering of decorations while using `find`
|
|
172
186
|
);
|
|
173
|
-
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [
|
|
187
|
+
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [_wrappedBlock]);
|
|
174
188
|
}
|
|
175
189
|
return updatedDecorationSet;
|
|
176
190
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
7
8
|
import { getAllCodeBlockNodesInDoc } from './utils';
|
|
8
9
|
export const DECORATION_WIDGET_TYPE = 'decorationWidgetType';
|
|
@@ -155,6 +156,19 @@ export const updateDecorationSetWithWordWrappedDecorator = (decorationSet, tr, n
|
|
|
155
156
|
if (!isNodeWrapped) {
|
|
156
157
|
const currentWrappedBlockDecorationSet = getWordWrapDecoratorsFromNodePos(pos, updatedDecorationSet);
|
|
157
158
|
updatedDecorationSet = updatedDecorationSet.remove(currentWrappedBlockDecorationSet);
|
|
159
|
+
|
|
160
|
+
// In code block advanced we don't use the node decoration - however a change in decorations
|
|
161
|
+
// is how we detect updates to the word wrap. If we have no decorations attached we've
|
|
162
|
+
// likely changed the breakout width with the toggle ON - we add an empty decoration to force
|
|
163
|
+
// prosemirror to recognise the change so we can update in our node view. This gets filtered
|
|
164
|
+
// out on the next toggle.
|
|
165
|
+
if (currentWrappedBlockDecorationSet.length === 0 && editorExperiment('platform_editor_advanced_code_blocks', true)) {
|
|
166
|
+
const wrappedBlock = Decoration.node(pos, pos + innerNode.nodeSize, {}, {
|
|
167
|
+
type: DECORATION_WRAPPED_BLOCK_NODE_TYPE
|
|
168
|
+
} // Allows for quick filtering of decorations while using `find`
|
|
169
|
+
);
|
|
170
|
+
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [wrappedBlock]);
|
|
171
|
+
}
|
|
158
172
|
} else {
|
|
159
173
|
const wrappedBlock = Decoration.node(pos, pos + innerNode.nodeSize, {
|
|
160
174
|
class: codeBlockClassNames.contentWrapped
|
|
@@ -4,6 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
4
4
|
import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
5
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
8
9
|
import { getAllCodeBlockNodesInDoc } from './utils';
|
|
9
10
|
export var DECORATION_WIDGET_TYPE = 'decorationWidgetType';
|
|
@@ -156,14 +157,27 @@ export var updateDecorationSetWithWordWrappedDecorator = function updateDecorati
|
|
|
156
157
|
if (!isNodeWrapped) {
|
|
157
158
|
var currentWrappedBlockDecorationSet = getWordWrapDecoratorsFromNodePos(pos, updatedDecorationSet);
|
|
158
159
|
updatedDecorationSet = updatedDecorationSet.remove(currentWrappedBlockDecorationSet);
|
|
160
|
+
|
|
161
|
+
// In code block advanced we don't use the node decoration - however a change in decorations
|
|
162
|
+
// is how we detect updates to the word wrap. If we have no decorations attached we've
|
|
163
|
+
// likely changed the breakout width with the toggle ON - we add an empty decoration to force
|
|
164
|
+
// prosemirror to recognise the change so we can update in our node view. This gets filtered
|
|
165
|
+
// out on the next toggle.
|
|
166
|
+
if (currentWrappedBlockDecorationSet.length === 0 && editorExperiment('platform_editor_advanced_code_blocks', true)) {
|
|
167
|
+
var wrappedBlock = Decoration.node(pos, pos + innerNode.nodeSize, {}, {
|
|
168
|
+
type: DECORATION_WRAPPED_BLOCK_NODE_TYPE
|
|
169
|
+
} // Allows for quick filtering of decorations while using `find`
|
|
170
|
+
);
|
|
171
|
+
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [wrappedBlock]);
|
|
172
|
+
}
|
|
159
173
|
} else {
|
|
160
|
-
var
|
|
174
|
+
var _wrappedBlock = Decoration.node(pos, pos + innerNode.nodeSize, {
|
|
161
175
|
class: codeBlockClassNames.contentWrapped
|
|
162
176
|
}, {
|
|
163
177
|
type: DECORATION_WRAPPED_BLOCK_NODE_TYPE
|
|
164
178
|
} // Allows for quick filtering of decorations while using `find`
|
|
165
179
|
);
|
|
166
|
-
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [
|
|
180
|
+
updatedDecorationSet = updatedDecorationSet.add(tr.doc, [_wrappedBlock]);
|
|
167
181
|
}
|
|
168
182
|
return updatedDecorationSet;
|
|
169
183
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.8",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
35
|
"@atlaskit/code": "^17.0.0",
|
|
36
|
-
"@atlaskit/editor-common": "^
|
|
36
|
+
"@atlaskit/editor-common": "^103.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
38
38
|
"@atlaskit/editor-plugin-composition": "^1.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|