@atlaskit/editor-plugin-code-block 3.2.1 → 3.2.2
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 +8 -0
- package/dist/cjs/nodeviews/code-block.js +11 -8
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/ui/class-names.js +2 -1
- package/dist/es2019/nodeviews/code-block.js +11 -8
- package/dist/es2019/pm-plugins/main.js +3 -2
- package/dist/es2019/ui/class-names.js +2 -1
- package/dist/esm/nodeviews/code-block.js +12 -9
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/ui/class-names.js +2 -1
- package/dist/types/nodeviews/code-block.d.ts +3 -2
- package/dist/types/pm-plugins/main.d.ts +2 -1
- package/dist/types/ui/class-names.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/code-block.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/ui/class-names.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#124302](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124302)
|
|
8
|
+
[`45dc9b6543007`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/45dc9b6543007) -
|
|
9
|
+
[ux] ED-24228 adding wrap content functionality with feature gate
|
|
10
|
+
|
|
3
11
|
## 3.2.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ var _actions = require("../actions");
|
|
|
16
16
|
var _mainState = require("../pm-plugins/main-state");
|
|
17
17
|
var _classNames = require("../ui/class-names");
|
|
18
18
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
19
|
-
var toDOM = function toDOM(node, contentEditable) {
|
|
19
|
+
var toDOM = function toDOM(node, contentEditable, isWrapped) {
|
|
20
20
|
return ['div', {
|
|
21
21
|
class: 'code-block'
|
|
22
22
|
}, ['div', {
|
|
@@ -27,12 +27,14 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
27
27
|
}, ['div', {
|
|
28
28
|
class: _classNames.codeBlockClassNames.gutter,
|
|
29
29
|
contenteditable: 'false'
|
|
30
|
-
}], ['div', {
|
|
30
|
+
}], ['div', isWrapped && (0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping') ? {
|
|
31
|
+
class: "".concat(_classNames.codeBlockClassNames.content, " ").concat(_classNames.codeBlockClassNames.contentWrapped)
|
|
32
|
+
} : {
|
|
31
33
|
class: _classNames.codeBlockClassNames.content
|
|
32
34
|
}, ['code', {
|
|
33
35
|
'data-language': node.attrs.language || '',
|
|
34
36
|
spellcheck: 'false',
|
|
35
|
-
contenteditable: (0, _platformFeatureFlags.
|
|
37
|
+
contenteditable: (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
|
|
36
38
|
'data-testid': 'code-block--code'
|
|
37
39
|
}, 0]]], ['div', {
|
|
38
40
|
class: _classNames.codeBlockClassNames.end,
|
|
@@ -40,7 +42,7 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
40
42
|
}]];
|
|
41
43
|
};
|
|
42
44
|
var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
43
|
-
function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
|
|
45
|
+
function CodeBlockView(_node, view, getPos, api, isWrapped, cleanupEditorDisabledListener) {
|
|
44
46
|
var _this = this,
|
|
45
47
|
_api$editorDisabled;
|
|
46
48
|
(0, _classCallCheck2.default)(this, CodeBlockView);
|
|
@@ -60,7 +62,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
60
62
|
}
|
|
61
63
|
}));
|
|
62
64
|
this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
|
|
63
|
-
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled))),
|
|
65
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled), isWrapped)),
|
|
64
66
|
dom = _DOMSerializer$render.dom,
|
|
65
67
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
66
68
|
this.getPos = getPos;
|
|
@@ -70,6 +72,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
70
72
|
this.contentDOM = contentDOM;
|
|
71
73
|
this.lineNumberGutter = this.dom.querySelector(".".concat(_classNames.codeBlockClassNames.gutter));
|
|
72
74
|
this.api = api;
|
|
75
|
+
this.isWrapped = isWrapped;
|
|
73
76
|
this.ensureLineNumbers();
|
|
74
77
|
this.handleEditorDisabledChanged();
|
|
75
78
|
}
|
|
@@ -78,7 +81,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
78
81
|
value: function handleEditorDisabledChanged() {
|
|
79
82
|
var _this$api,
|
|
80
83
|
_this2 = this;
|
|
81
|
-
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && (0, _platformFeatureFlags.
|
|
84
|
+
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
82
85
|
this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
83
86
|
if (_this2.contentDOM) {
|
|
84
87
|
_this2.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
|
|
@@ -173,6 +176,6 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
173
176
|
}]);
|
|
174
177
|
return CodeBlockView;
|
|
175
178
|
}();
|
|
176
|
-
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
|
|
177
|
-
return new CodeBlockView(node, view, getPos, api);
|
|
179
|
+
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api, isWrapped) {
|
|
180
|
+
return new CodeBlockView(node, view, getPos, api, isWrapped);
|
|
178
181
|
};
|
|
@@ -24,7 +24,9 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
24
24
|
getIntl = _ref.getIntl,
|
|
25
25
|
_ref$allowComposition = _ref.allowCompositionInputOverride,
|
|
26
26
|
allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition,
|
|
27
|
-
api = _ref.api
|
|
27
|
+
api = _ref.api,
|
|
28
|
+
_ref$isWrapped = _ref.isWrapped,
|
|
29
|
+
isWrapped = _ref$isWrapped === void 0 ? false : _ref$isWrapped;
|
|
28
30
|
var handleDOMEvents = {};
|
|
29
31
|
|
|
30
32
|
// ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
|
|
@@ -102,7 +104,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
102
104
|
props: {
|
|
103
105
|
nodeViews: {
|
|
104
106
|
codeBlock: function codeBlock(node, view, getPos) {
|
|
105
|
-
return (0, _codeBlock.codeBlockNodeView)(node, view, getPos, api);
|
|
107
|
+
return (0, _codeBlock.codeBlockNodeView)(node, view, getPos, api, isWrapped);
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
handleClickOn: (0, _selection.createSelectionClickHandler)(['codeBlock'], function (target) {
|
|
@@ -11,5 +11,6 @@ var codeBlockClassNames = exports.codeBlockClassNames = {
|
|
|
11
11
|
end: _styles.CodeBlockSharedCssClassName.CODEBLOCK_END,
|
|
12
12
|
contentWrapper: _styles.CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER,
|
|
13
13
|
gutter: _styles.CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER,
|
|
14
|
-
content: _styles.CodeBlockSharedCssClassName.CODEBLOCK_CONTENT
|
|
14
|
+
content: _styles.CodeBlockSharedCssClassName.CODEBLOCK_CONTENT,
|
|
15
|
+
contentWrapped: _styles.CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPED
|
|
15
16
|
};
|
|
@@ -2,12 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import rafSchedule from 'raf-schd';
|
|
3
3
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { resetShouldIgnoreFollowingMutations } from '../actions';
|
|
7
7
|
import { getPluginState } from '../pm-plugins/main-state';
|
|
8
8
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
9
9
|
const MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
10
|
-
const toDOM = (node, contentEditable) => ['div', {
|
|
10
|
+
const toDOM = (node, contentEditable, isWrapped) => ['div', {
|
|
11
11
|
class: 'code-block'
|
|
12
12
|
}, ['div', {
|
|
13
13
|
class: codeBlockClassNames.start,
|
|
@@ -17,19 +17,21 @@ const toDOM = (node, contentEditable) => ['div', {
|
|
|
17
17
|
}, ['div', {
|
|
18
18
|
class: codeBlockClassNames.gutter,
|
|
19
19
|
contenteditable: 'false'
|
|
20
|
-
}], ['div', {
|
|
20
|
+
}], ['div', isWrapped && fg('editor_support_code_block_wrapping') ? {
|
|
21
|
+
class: `${codeBlockClassNames.content} ${codeBlockClassNames.contentWrapped}`
|
|
22
|
+
} : {
|
|
21
23
|
class: codeBlockClassNames.content
|
|
22
24
|
}, ['code', {
|
|
23
25
|
'data-language': node.attrs.language || '',
|
|
24
26
|
spellcheck: 'false',
|
|
25
|
-
contenteditable:
|
|
27
|
+
contenteditable: fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
|
|
26
28
|
'data-testid': 'code-block--code'
|
|
27
29
|
}, 0]]], ['div', {
|
|
28
30
|
class: codeBlockClassNames.end,
|
|
29
31
|
contenteditable: 'false'
|
|
30
32
|
}]];
|
|
31
33
|
export class CodeBlockView {
|
|
32
|
-
constructor(_node, view, getPos, api, cleanupEditorDisabledListener) {
|
|
34
|
+
constructor(_node, view, getPos, api, isWrapped, cleanupEditorDisabledListener) {
|
|
33
35
|
var _api$editorDisabled, _api$editorDisabled$s;
|
|
34
36
|
_defineProperty(this, "ensureLineNumbers", rafSchedule(() => {
|
|
35
37
|
let lines = 1;
|
|
@@ -50,7 +52,7 @@ export class CodeBlockView {
|
|
|
50
52
|
const {
|
|
51
53
|
dom,
|
|
52
54
|
contentDOM
|
|
53
|
-
} = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled$s !== void 0 && _api$editorDisabled$s.editorDisabled)));
|
|
55
|
+
} = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled$s !== void 0 && _api$editorDisabled$s.editorDisabled), isWrapped));
|
|
54
56
|
this.getPos = getPos;
|
|
55
57
|
this.view = view;
|
|
56
58
|
this.node = _node;
|
|
@@ -58,12 +60,13 @@ export class CodeBlockView {
|
|
|
58
60
|
this.contentDOM = contentDOM;
|
|
59
61
|
this.lineNumberGutter = this.dom.querySelector(`.${codeBlockClassNames.gutter}`);
|
|
60
62
|
this.api = api;
|
|
63
|
+
this.isWrapped = isWrapped;
|
|
61
64
|
this.ensureLineNumbers();
|
|
62
65
|
this.handleEditorDisabledChanged();
|
|
63
66
|
}
|
|
64
67
|
handleEditorDisabledChanged() {
|
|
65
68
|
var _this$api;
|
|
66
|
-
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled &&
|
|
69
|
+
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
67
70
|
this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(sharedState => {
|
|
68
71
|
if (this.contentDOM) {
|
|
69
72
|
this.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
|
|
@@ -144,4 +147,4 @@ export class CodeBlockView {
|
|
|
144
147
|
this.cleanupEditorDisabledListener = undefined;
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
|
-
export const codeBlockNodeView = (node, view, getPos, api) => new CodeBlockView(node, view, getPos, api);
|
|
150
|
+
export const codeBlockNodeView = (node, view, getPos, api, isWrapped) => new CodeBlockView(node, view, getPos, api, isWrapped);
|
|
@@ -12,7 +12,8 @@ export const createPlugin = ({
|
|
|
12
12
|
useLongPressSelection = false,
|
|
13
13
|
getIntl,
|
|
14
14
|
allowCompositionInputOverride = false,
|
|
15
|
-
api
|
|
15
|
+
api,
|
|
16
|
+
isWrapped = false
|
|
16
17
|
}) => {
|
|
17
18
|
const handleDOMEvents = {};
|
|
18
19
|
|
|
@@ -91,7 +92,7 @@ export const createPlugin = ({
|
|
|
91
92
|
key: pluginKey,
|
|
92
93
|
props: {
|
|
93
94
|
nodeViews: {
|
|
94
|
-
codeBlock: (node, view, getPos) => codeBlockNodeView(node, view, getPos, api)
|
|
95
|
+
codeBlock: (node, view, getPos) => codeBlockNodeView(node, view, getPos, api, isWrapped)
|
|
95
96
|
},
|
|
96
97
|
handleClickOn: createSelectionClickHandler(['codeBlock'], target => !!(target.closest(`.${codeBlockClassNames.gutter}`) || target.classList.contains(codeBlockClassNames.content)), {
|
|
97
98
|
useLongPressSelection
|
|
@@ -5,5 +5,6 @@ export const codeBlockClassNames = {
|
|
|
5
5
|
end: CodeBlockSharedCssClassName.CODEBLOCK_END,
|
|
6
6
|
contentWrapper: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER,
|
|
7
7
|
gutter: CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER,
|
|
8
|
-
content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT
|
|
8
|
+
content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT,
|
|
9
|
+
contentWrapped: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPED
|
|
9
10
|
};
|
|
@@ -4,12 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
5
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
-
import {
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { resetShouldIgnoreFollowingMutations } from '../actions';
|
|
9
9
|
import { getPluginState } from '../pm-plugins/main-state';
|
|
10
10
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
11
11
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
12
|
-
var toDOM = function toDOM(node, contentEditable) {
|
|
12
|
+
var toDOM = function toDOM(node, contentEditable, isWrapped) {
|
|
13
13
|
return ['div', {
|
|
14
14
|
class: 'code-block'
|
|
15
15
|
}, ['div', {
|
|
@@ -20,12 +20,14 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
20
20
|
}, ['div', {
|
|
21
21
|
class: codeBlockClassNames.gutter,
|
|
22
22
|
contenteditable: 'false'
|
|
23
|
-
}], ['div', {
|
|
23
|
+
}], ['div', isWrapped && fg('editor_support_code_block_wrapping') ? {
|
|
24
|
+
class: "".concat(codeBlockClassNames.content, " ").concat(codeBlockClassNames.contentWrapped)
|
|
25
|
+
} : {
|
|
24
26
|
class: codeBlockClassNames.content
|
|
25
27
|
}, ['code', {
|
|
26
28
|
'data-language': node.attrs.language || '',
|
|
27
29
|
spellcheck: 'false',
|
|
28
|
-
contenteditable:
|
|
30
|
+
contenteditable: fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
|
|
29
31
|
'data-testid': 'code-block--code'
|
|
30
32
|
}, 0]]], ['div', {
|
|
31
33
|
class: codeBlockClassNames.end,
|
|
@@ -33,7 +35,7 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
33
35
|
}]];
|
|
34
36
|
};
|
|
35
37
|
export var CodeBlockView = /*#__PURE__*/function () {
|
|
36
|
-
function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
|
|
38
|
+
function CodeBlockView(_node, view, getPos, api, isWrapped, cleanupEditorDisabledListener) {
|
|
37
39
|
var _this = this,
|
|
38
40
|
_api$editorDisabled;
|
|
39
41
|
_classCallCheck(this, CodeBlockView);
|
|
@@ -53,7 +55,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
53
55
|
}
|
|
54
56
|
}));
|
|
55
57
|
this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
|
|
56
|
-
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled))),
|
|
58
|
+
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled), isWrapped)),
|
|
57
59
|
dom = _DOMSerializer$render.dom,
|
|
58
60
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
59
61
|
this.getPos = getPos;
|
|
@@ -63,6 +65,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
63
65
|
this.contentDOM = contentDOM;
|
|
64
66
|
this.lineNumberGutter = this.dom.querySelector(".".concat(codeBlockClassNames.gutter));
|
|
65
67
|
this.api = api;
|
|
68
|
+
this.isWrapped = isWrapped;
|
|
66
69
|
this.ensureLineNumbers();
|
|
67
70
|
this.handleEditorDisabledChanged();
|
|
68
71
|
}
|
|
@@ -71,7 +74,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
71
74
|
value: function handleEditorDisabledChanged() {
|
|
72
75
|
var _this$api,
|
|
73
76
|
_this2 = this;
|
|
74
|
-
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled &&
|
|
77
|
+
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
75
78
|
this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
76
79
|
if (_this2.contentDOM) {
|
|
77
80
|
_this2.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
|
|
@@ -166,6 +169,6 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
166
169
|
}]);
|
|
167
170
|
return CodeBlockView;
|
|
168
171
|
}();
|
|
169
|
-
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
|
|
170
|
-
return new CodeBlockView(node, view, getPos, api);
|
|
172
|
+
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api, isWrapped) {
|
|
173
|
+
return new CodeBlockView(node, view, getPos, api, isWrapped);
|
|
171
174
|
};
|
|
@@ -17,7 +17,9 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
17
17
|
getIntl = _ref.getIntl,
|
|
18
18
|
_ref$allowComposition = _ref.allowCompositionInputOverride,
|
|
19
19
|
allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition,
|
|
20
|
-
api = _ref.api
|
|
20
|
+
api = _ref.api,
|
|
21
|
+
_ref$isWrapped = _ref.isWrapped,
|
|
22
|
+
isWrapped = _ref$isWrapped === void 0 ? false : _ref$isWrapped;
|
|
21
23
|
var handleDOMEvents = {};
|
|
22
24
|
|
|
23
25
|
// ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
|
|
@@ -95,7 +97,7 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
95
97
|
props: {
|
|
96
98
|
nodeViews: {
|
|
97
99
|
codeBlock: function codeBlock(node, view, getPos) {
|
|
98
|
-
return codeBlockNodeView(node, view, getPos, api);
|
|
100
|
+
return codeBlockNodeView(node, view, getPos, api, isWrapped);
|
|
99
101
|
}
|
|
100
102
|
},
|
|
101
103
|
handleClickOn: createSelectionClickHandler(['codeBlock'], function (target) {
|
|
@@ -5,5 +5,6 @@ export var codeBlockClassNames = {
|
|
|
5
5
|
end: CodeBlockSharedCssClassName.CODEBLOCK_END,
|
|
6
6
|
contentWrapper: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER,
|
|
7
7
|
gutter: CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER,
|
|
8
|
-
content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT
|
|
8
|
+
content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT,
|
|
9
|
+
contentWrapped: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPED
|
|
9
10
|
};
|
|
@@ -11,7 +11,8 @@ export declare class CodeBlockView {
|
|
|
11
11
|
getPos: getPosHandlerNode;
|
|
12
12
|
view: EditorView;
|
|
13
13
|
api?: ExtractInjectionAPI<CodeBlockPlugin>;
|
|
14
|
-
|
|
14
|
+
isWrapped?: boolean;
|
|
15
|
+
constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, api?: ExtractInjectionAPI<CodeBlockPlugin>, isWrapped?: boolean, cleanupEditorDisabledListener?: (() => void) | undefined);
|
|
15
16
|
handleEditorDisabledChanged(): void;
|
|
16
17
|
updateDOMAndSelection(savedInnerHTML: string, newCursorPosition: number): void;
|
|
17
18
|
coalesceDOMElements(): void;
|
|
@@ -23,4 +24,4 @@ export declare class CodeBlockView {
|
|
|
23
24
|
}): boolean;
|
|
24
25
|
destroy(): void;
|
|
25
26
|
}
|
|
26
|
-
export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
|
|
27
|
+
export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined, isWrapped: boolean | undefined) => CodeBlockView;
|
|
@@ -3,7 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { CodeBlockPlugin } from '../index';
|
|
5
5
|
import type { CodeBlockState } from './main-state';
|
|
6
|
-
export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, }: {
|
|
6
|
+
export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, isWrapped, }: {
|
|
7
7
|
useLongPressSelection?: boolean | undefined;
|
|
8
8
|
getIntl: () => IntlShape;
|
|
9
9
|
allowCompositionInputOverride?: boolean | undefined;
|
|
@@ -36,4 +36,5 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
36
36
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
37
37
|
};
|
|
38
38
|
}> | undefined;
|
|
39
|
+
isWrapped?: boolean | undefined;
|
|
39
40
|
}) => SafePlugin<CodeBlockState>;
|
|
@@ -11,7 +11,8 @@ export declare class CodeBlockView {
|
|
|
11
11
|
getPos: getPosHandlerNode;
|
|
12
12
|
view: EditorView;
|
|
13
13
|
api?: ExtractInjectionAPI<CodeBlockPlugin>;
|
|
14
|
-
|
|
14
|
+
isWrapped?: boolean;
|
|
15
|
+
constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, api?: ExtractInjectionAPI<CodeBlockPlugin>, isWrapped?: boolean, cleanupEditorDisabledListener?: (() => void) | undefined);
|
|
15
16
|
handleEditorDisabledChanged(): void;
|
|
16
17
|
updateDOMAndSelection(savedInnerHTML: string, newCursorPosition: number): void;
|
|
17
18
|
coalesceDOMElements(): void;
|
|
@@ -23,4 +24,4 @@ export declare class CodeBlockView {
|
|
|
23
24
|
}): boolean;
|
|
24
25
|
destroy(): void;
|
|
25
26
|
}
|
|
26
|
-
export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
|
|
27
|
+
export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined, isWrapped: boolean | undefined) => CodeBlockView;
|
|
@@ -3,7 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { CodeBlockPlugin } from '../index';
|
|
5
5
|
import type { CodeBlockState } from './main-state';
|
|
6
|
-
export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, }: {
|
|
6
|
+
export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, isWrapped, }: {
|
|
7
7
|
useLongPressSelection?: boolean | undefined;
|
|
8
8
|
getIntl: () => IntlShape;
|
|
9
9
|
allowCompositionInputOverride?: boolean | undefined;
|
|
@@ -43,4 +43,5 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
43
43
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
44
44
|
};
|
|
45
45
|
}> | undefined;
|
|
46
|
+
isWrapped?: boolean | undefined;
|
|
46
47
|
}) => SafePlugin<CodeBlockState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/editor-plugin-decorations": "^1.2.0",
|
|
42
42
|
"@atlaskit/editor-plugin-editor-disabled": "^1.2.0",
|
|
43
43
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
44
|
-
"@atlaskit/icon": "^22.
|
|
44
|
+
"@atlaskit/icon": "^22.8.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
46
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|