@atlaskit/editor-plugin-code-block-advanced 8.0.20 → 8.0.22
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 +18 -0
- package/dist/cjs/nodeviews/extensions/lineSeparator.js +1 -5
- package/dist/cjs/nodeviews/extensions/prosemirrorDecorations.js +10 -2
- package/dist/es2019/nodeviews/extensions/lineSeparator.js +1 -6
- package/dist/es2019/nodeviews/extensions/prosemirrorDecorations.js +7 -1
- package/dist/esm/nodeviews/extensions/lineSeparator.js +1 -6
- package/dist/esm/nodeviews/extensions/prosemirrorDecorations.js +9 -1
- package/dist/types/nodeviews/extensions/prosemirrorDecorations.d.ts +11 -0
- package/dist/types-ts4.5/nodeviews/extensions/prosemirrorDecorations.d.ts +11 -0
- package/package.json +6 -3
- package/src/nodeviews/extensions/lineSeparator.ts +1 -6
- package/src/nodeviews/extensions/prosemirrorDecorations.ts +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block-advanced
|
|
2
2
|
|
|
3
|
+
## 8.0.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`cdf5e30bb1541`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cdf5e30bb1541) -
|
|
8
|
+
Fix for edge case in firefox with prosemirror decorations being unsorted, ensures they are sorted
|
|
9
|
+
for diff decorations.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 8.0.21
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`65e300b324e87`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65e300b324e87) -
|
|
17
|
+
Remove feature flag platform_editor_fix_advanced_codeblocks_crlf - CRLF line separator fix is now
|
|
18
|
+
always enabled
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 8.0.20
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -5,14 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.lineSeparatorExtension = void 0;
|
|
7
7
|
var _state = require("@codemirror/state");
|
|
8
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
8
|
/**
|
|
10
9
|
* To avoid issues with CRLF (\r\n) syncing with ProseMirror,
|
|
11
10
|
* we only consider \n for line separators.
|
|
12
11
|
*/
|
|
13
12
|
var lineSeparatorExtension = exports.lineSeparatorExtension = function lineSeparatorExtension() {
|
|
14
|
-
|
|
15
|
-
return _state.EditorState.lineSeparator.of('\n');
|
|
16
|
-
}
|
|
17
|
-
return [];
|
|
13
|
+
return _state.EditorState.lineSeparator.of('\n');
|
|
18
14
|
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.prosemirrorDecorationPlugin = void 0;
|
|
7
|
+
exports.sortDecorationsByPositionAndSide = exports.prosemirrorDecorationPlugin = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -12,6 +12,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
12
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
14
|
var _view = require("@codemirror/view");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
17
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
18
|
var PMWidget = /*#__PURE__*/function (_WidgetType) {
|
|
@@ -76,6 +77,9 @@ var mapPMDecorationToCMDecoration = function mapPMDecorationToCMDecoration(decor
|
|
|
76
77
|
function isDefined(value) {
|
|
77
78
|
return value !== undefined;
|
|
78
79
|
}
|
|
80
|
+
var sortDecorationsByPositionAndSide = exports.sortDecorationsByPositionAndSide = function sortDecorationsByPositionAndSide(a, b) {
|
|
81
|
+
return a.from - b.from || a.value.startSide - b.value.startSide;
|
|
82
|
+
};
|
|
79
83
|
|
|
80
84
|
/**
|
|
81
85
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
@@ -118,7 +122,11 @@ var prosemirrorDecorationPlugin = exports.prosemirrorDecorationPlugin = function
|
|
|
118
122
|
}).map(function (decoration) {
|
|
119
123
|
return mapPMDecorationToCMDecoration(decoration, editorView, getPos);
|
|
120
124
|
}).filter(isDefined);
|
|
121
|
-
|
|
125
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_decoration_edge_case')) {
|
|
126
|
+
return _view.Decoration.set(cmDecorations.sort(sortDecorationsByPositionAndSide));
|
|
127
|
+
} else {
|
|
128
|
+
return _view.Decoration.set(cmDecorations);
|
|
129
|
+
}
|
|
122
130
|
}
|
|
123
131
|
}, {
|
|
124
132
|
key: "update",
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { EditorState as CodeMirrorState } from '@codemirror/state';
|
|
2
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
-
|
|
4
2
|
/**
|
|
5
3
|
* To avoid issues with CRLF (\r\n) syncing with ProseMirror,
|
|
6
4
|
* we only consider \n for line separators.
|
|
7
5
|
*/
|
|
8
6
|
export const lineSeparatorExtension = () => {
|
|
9
|
-
|
|
10
|
-
return CodeMirrorState.lineSeparator.of('\n');
|
|
11
|
-
}
|
|
12
|
-
return [];
|
|
7
|
+
return CodeMirrorState.lineSeparator.of('\n');
|
|
13
8
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ViewPlugin, WidgetType, Decoration as CodeMirrorDecoration } from '@codemirror/view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
class PMWidget extends WidgetType {
|
|
3
4
|
constructor(toDOMElement) {
|
|
4
5
|
super();
|
|
@@ -56,6 +57,7 @@ const mapPMDecorationToCMDecoration = (decoration, view, getPos) => {
|
|
|
56
57
|
function isDefined(value) {
|
|
57
58
|
return value !== undefined;
|
|
58
59
|
}
|
|
60
|
+
export const sortDecorationsByPositionAndSide = (a, b) => a.from - b.from || a.value.startSide - b.value.startSide;
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
63
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
@@ -89,7 +91,11 @@ export const prosemirrorDecorationPlugin = (updateDecorationsEffect, editorView,
|
|
|
89
91
|
});
|
|
90
92
|
});
|
|
91
93
|
const cmDecorations = allDecorations.sort((a, b) => a.from < b.from ? -1 : 1).map(decoration => mapPMDecorationToCMDecoration(decoration, editorView, getPos)).filter(isDefined);
|
|
92
|
-
|
|
94
|
+
if (fg('platform_editor_fix_decoration_edge_case')) {
|
|
95
|
+
return CodeMirrorDecoration.set(cmDecorations.sort(sortDecorationsByPositionAndSide));
|
|
96
|
+
} else {
|
|
97
|
+
return CodeMirrorDecoration.set(cmDecorations);
|
|
98
|
+
}
|
|
93
99
|
}
|
|
94
100
|
update(update) {
|
|
95
101
|
this.decorations = this.updateDecorations(update.view);
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { EditorState as CodeMirrorState } from '@codemirror/state';
|
|
2
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
-
|
|
4
2
|
/**
|
|
5
3
|
* To avoid issues with CRLF (\r\n) syncing with ProseMirror,
|
|
6
4
|
* we only consider \n for line separators.
|
|
7
5
|
*/
|
|
8
6
|
export var lineSeparatorExtension = function lineSeparatorExtension() {
|
|
9
|
-
|
|
10
|
-
return CodeMirrorState.lineSeparator.of('\n');
|
|
11
|
-
}
|
|
12
|
-
return [];
|
|
7
|
+
return CodeMirrorState.lineSeparator.of('\n');
|
|
13
8
|
};
|
|
@@ -7,6 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
7
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
import { ViewPlugin, WidgetType, Decoration as CodeMirrorDecoration } from '@codemirror/view';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
var PMWidget = /*#__PURE__*/function (_WidgetType) {
|
|
11
12
|
function PMWidget(toDOMElement) {
|
|
12
13
|
var _this;
|
|
@@ -69,6 +70,9 @@ var mapPMDecorationToCMDecoration = function mapPMDecorationToCMDecoration(decor
|
|
|
69
70
|
function isDefined(value) {
|
|
70
71
|
return value !== undefined;
|
|
71
72
|
}
|
|
73
|
+
export var sortDecorationsByPositionAndSide = function sortDecorationsByPositionAndSide(a, b) {
|
|
74
|
+
return a.from - b.from || a.value.startSide - b.value.startSide;
|
|
75
|
+
};
|
|
72
76
|
|
|
73
77
|
/**
|
|
74
78
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
@@ -111,7 +115,11 @@ export var prosemirrorDecorationPlugin = function prosemirrorDecorationPlugin(up
|
|
|
111
115
|
}).map(function (decoration) {
|
|
112
116
|
return mapPMDecorationToCMDecoration(decoration, editorView, getPos);
|
|
113
117
|
}).filter(isDefined);
|
|
114
|
-
|
|
118
|
+
if (fg('platform_editor_fix_decoration_edge_case')) {
|
|
119
|
+
return CodeMirrorDecoration.set(cmDecorations.sort(sortDecorationsByPositionAndSide));
|
|
120
|
+
} else {
|
|
121
|
+
return CodeMirrorDecoration.set(cmDecorations);
|
|
122
|
+
}
|
|
115
123
|
}
|
|
116
124
|
}, {
|
|
117
125
|
key: "update",
|
|
@@ -2,6 +2,17 @@ import type { Facet } from '@codemirror/state';
|
|
|
2
2
|
import { ViewPlugin } from '@codemirror/view';
|
|
3
3
|
import type { EditorView as CodeMirror, DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
export declare const sortDecorationsByPositionAndSide: (a: {
|
|
6
|
+
from: number;
|
|
7
|
+
value: {
|
|
8
|
+
startSide: number;
|
|
9
|
+
};
|
|
10
|
+
}, b: {
|
|
11
|
+
from: number;
|
|
12
|
+
value: {
|
|
13
|
+
startSide: number;
|
|
14
|
+
};
|
|
15
|
+
}) => number;
|
|
5
16
|
/**
|
|
6
17
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
7
18
|
*
|
|
@@ -2,6 +2,17 @@ import type { Facet } from '@codemirror/state';
|
|
|
2
2
|
import { ViewPlugin } from '@codemirror/view';
|
|
3
3
|
import type { EditorView as CodeMirror, DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
export declare const sortDecorationsByPositionAndSide: (a: {
|
|
6
|
+
from: number;
|
|
7
|
+
value: {
|
|
8
|
+
startSide: number;
|
|
9
|
+
};
|
|
10
|
+
}, b: {
|
|
11
|
+
from: number;
|
|
12
|
+
value: {
|
|
13
|
+
startSide: number;
|
|
14
|
+
};
|
|
15
|
+
}) => number;
|
|
5
16
|
/**
|
|
6
17
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
7
18
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block-advanced",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.22",
|
|
4
4
|
"description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^54.4.0",
|
|
42
42
|
"@atlaskit/tokens": "^11.4.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@codemirror/autocomplete": "6.18.4",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"codemirror-lang-elixir": "4.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@atlaskit/editor-common": "^112.
|
|
58
|
+
"@atlaskit/editor-common": "^112.18.0",
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
61
61
|
},
|
|
@@ -99,6 +99,9 @@
|
|
|
99
99
|
"platform_editor_adf_with_localid": {
|
|
100
100
|
"type": "boolean"
|
|
101
101
|
},
|
|
102
|
+
"platform_editor_fix_decoration_edge_case": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
},
|
|
102
105
|
"platform_editor_content_mode_button_mvp": {
|
|
103
106
|
"type": "boolean"
|
|
104
107
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { EditorState as CodeMirrorState } from '@codemirror/state';
|
|
2
2
|
import type { Extension } from '@codemirror/state';
|
|
3
3
|
|
|
4
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* To avoid issues with CRLF (\r\n) syncing with ProseMirror,
|
|
8
6
|
* we only consider \n for line separators.
|
|
9
7
|
*/
|
|
10
8
|
export const lineSeparatorExtension = (): Extension => {
|
|
11
|
-
|
|
12
|
-
return CodeMirrorState.lineSeparator.of('\n');
|
|
13
|
-
}
|
|
14
|
-
return [];
|
|
9
|
+
return CodeMirrorState.lineSeparator.of('\n');
|
|
15
10
|
};
|
|
@@ -3,6 +3,7 @@ import { ViewPlugin, WidgetType, Decoration as CodeMirrorDecoration } from '@cod
|
|
|
3
3
|
import type { EditorView as CodeMirror, DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
|
|
5
5
|
import type { EditorView, Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
|
|
7
8
|
class PMWidget extends WidgetType {
|
|
8
9
|
constructor(readonly toDOMElement: HTMLElement) {
|
|
@@ -86,6 +87,11 @@ function isDefined<TValue>(value: TValue | undefined): value is TValue {
|
|
|
86
87
|
return value !== undefined;
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
export const sortDecorationsByPositionAndSide = (
|
|
91
|
+
a: { from: number; value: { startSide: number } },
|
|
92
|
+
b: { from: number; value: { startSide: number } },
|
|
93
|
+
) => a.from - b.from || a.value.startSide - b.value.startSide;
|
|
94
|
+
|
|
89
95
|
/**
|
|
90
96
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
91
97
|
*
|
|
@@ -134,7 +140,13 @@ export const prosemirrorDecorationPlugin = (
|
|
|
134
140
|
.map((decoration) => mapPMDecorationToCMDecoration(decoration, editorView, getPos))
|
|
135
141
|
.filter(isDefined);
|
|
136
142
|
|
|
137
|
-
|
|
143
|
+
if (fg('platform_editor_fix_decoration_edge_case')) {
|
|
144
|
+
return CodeMirrorDecoration.set(
|
|
145
|
+
cmDecorations.sort(sortDecorationsByPositionAndSide),
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
return CodeMirrorDecoration.set(cmDecorations);
|
|
149
|
+
}
|
|
138
150
|
}
|
|
139
151
|
update(update: ViewUpdate) {
|
|
140
152
|
this.decorations = this.updateDecorations(update.view);
|