@atlaskit/editor-plugin-code-block 4.2.5 → 4.2.7
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 +15 -0
- package/dist/cjs/pm-plugins/decorators.js +16 -2
- package/dist/es2019/pm-plugins/decorators.js +14 -0
- package/dist/esm/pm-plugins/decorators.js +16 -2
- package/dist/types/pm-plugins/language-list.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/language-list.d.ts +21 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 4.2.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#137043](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/137043)
|
|
8
|
+
[`616c9cd4a2c60`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/616c9cd4a2c60) -
|
|
9
|
+
Fix line wrapping and decorations being lost on breakout in advanced codeblocks
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 4.2.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 4.2.5
|
|
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
|
};
|
|
@@ -318,6 +318,10 @@ export declare const DEFAULT_LANGUAGES: ({
|
|
|
318
318
|
readonly name: "Protocol Buffers";
|
|
319
319
|
readonly alias: readonly ["protobuf", "proto"];
|
|
320
320
|
readonly value: "protobuf";
|
|
321
|
+
} | {
|
|
322
|
+
readonly name: "Handlebars";
|
|
323
|
+
readonly alias: readonly ["handlebars", "mustache"];
|
|
324
|
+
readonly value: "handlebars";
|
|
321
325
|
} | {
|
|
322
326
|
readonly name: "ABAP";
|
|
323
327
|
readonly alias: readonly ["abap"];
|
|
@@ -648,6 +652,10 @@ export declare function findMatchedLanguage(supportedLanguages: Language[], lang
|
|
|
648
652
|
readonly name: "Protocol Buffers";
|
|
649
653
|
readonly alias: readonly ["protobuf", "proto"];
|
|
650
654
|
readonly value: "protobuf";
|
|
655
|
+
} | {
|
|
656
|
+
readonly name: "Handlebars";
|
|
657
|
+
readonly alias: readonly ["handlebars", "mustache"];
|
|
658
|
+
readonly value: "handlebars";
|
|
651
659
|
} | {
|
|
652
660
|
readonly name: "ABAP";
|
|
653
661
|
readonly alias: readonly ["abap"];
|
|
@@ -979,6 +987,10 @@ export declare function createLanguageList(supportedLanguages: Language[]): ({
|
|
|
979
987
|
readonly name: "Protocol Buffers";
|
|
980
988
|
readonly alias: readonly ["protobuf", "proto"];
|
|
981
989
|
readonly value: "protobuf";
|
|
990
|
+
} | {
|
|
991
|
+
readonly name: "Handlebars";
|
|
992
|
+
readonly alias: readonly ["handlebars", "mustache"];
|
|
993
|
+
readonly value: "handlebars";
|
|
982
994
|
} | {
|
|
983
995
|
readonly name: "ABAP";
|
|
984
996
|
readonly alias: readonly ["abap"];
|
|
@@ -560,6 +560,13 @@ export declare const DEFAULT_LANGUAGES: ({
|
|
|
560
560
|
"proto"
|
|
561
561
|
];
|
|
562
562
|
readonly value: "protobuf";
|
|
563
|
+
} | {
|
|
564
|
+
readonly name: "Handlebars";
|
|
565
|
+
readonly alias: readonly [
|
|
566
|
+
"handlebars",
|
|
567
|
+
"mustache"
|
|
568
|
+
];
|
|
569
|
+
readonly value: "handlebars";
|
|
563
570
|
} | {
|
|
564
571
|
readonly name: "ABAP";
|
|
565
572
|
readonly alias: readonly [
|
|
@@ -1134,6 +1141,13 @@ export declare function findMatchedLanguage(supportedLanguages: Language[], lang
|
|
|
1134
1141
|
"proto"
|
|
1135
1142
|
];
|
|
1136
1143
|
readonly value: "protobuf";
|
|
1144
|
+
} | {
|
|
1145
|
+
readonly name: "Handlebars";
|
|
1146
|
+
readonly alias: readonly [
|
|
1147
|
+
"handlebars",
|
|
1148
|
+
"mustache"
|
|
1149
|
+
];
|
|
1150
|
+
readonly value: "handlebars";
|
|
1137
1151
|
} | {
|
|
1138
1152
|
readonly name: "ABAP";
|
|
1139
1153
|
readonly alias: readonly [
|
|
@@ -1709,6 +1723,13 @@ export declare function createLanguageList(supportedLanguages: Language[]): ({
|
|
|
1709
1723
|
"proto"
|
|
1710
1724
|
];
|
|
1711
1725
|
readonly value: "protobuf";
|
|
1726
|
+
} | {
|
|
1727
|
+
readonly name: "Handlebars";
|
|
1728
|
+
readonly alias: readonly [
|
|
1729
|
+
"handlebars",
|
|
1730
|
+
"mustache"
|
|
1731
|
+
];
|
|
1732
|
+
readonly value: "handlebars";
|
|
1712
1733
|
} | {
|
|
1713
1734
|
readonly name: "ABAP";
|
|
1714
1735
|
readonly alias: readonly [
|
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.7",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
|
-
"@atlaskit/code": "^
|
|
36
|
-
"@atlaskit/editor-common": "^102.
|
|
35
|
+
"@atlaskit/code": "^17.0.0",
|
|
36
|
+
"@atlaskit/editor-common": "^102.19.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",
|