@atlaskit/editor-plugin-code-block 3.2.1 → 3.2.3
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 +19 -0
- package/dist/cjs/actions.js +26 -7
- package/dist/cjs/nodeviews/code-block.js +15 -8
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/toolbar.js +2 -1
- package/dist/cjs/ui/class-names.js +2 -1
- package/dist/es2019/actions.js +25 -6
- package/dist/es2019/nodeviews/code-block.js +15 -8
- package/dist/es2019/pm-plugins/main.js +3 -2
- package/dist/es2019/toolbar.js +3 -2
- package/dist/es2019/ui/class-names.js +2 -1
- package/dist/esm/actions.js +25 -6
- package/dist/esm/nodeviews/code-block.js +16 -9
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/toolbar.js +3 -2
- package/dist/esm/ui/class-names.js +2 -1
- package/dist/types/actions.d.ts +4 -1
- package/dist/types/nodeviews/code-block.d.ts +3 -2
- package/dist/types/pm-plugins/main.d.ts +3 -2
- package/dist/types/ui/class-names.d.ts +1 -0
- package/dist/types-ts4.5/actions.d.ts +4 -1
- package/dist/types-ts4.5/nodeviews/code-block.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -2
- package/dist/types-ts4.5/ui/class-names.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#125133](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125133)
|
|
8
|
+
[`d804e5dd3216b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d804e5dd3216b) -
|
|
9
|
+
ED-24226 - Add state to manage the toggle word wrap state of code blocks. New WeakMap added in
|
|
10
|
+
editor-common/src/code-block, as word wrap state is shared throughout the editor. Covers regular
|
|
11
|
+
changes to code block by the user via the node view update function. Covers breakout of code block
|
|
12
|
+
node. Does not cover drag&drop & cut&paste edge cases.
|
|
13
|
+
|
|
14
|
+
## 3.2.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#124302](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124302)
|
|
19
|
+
[`45dc9b6543007`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/45dc9b6543007) -
|
|
20
|
+
[ux] ED-24228 adding wrap content functionality with feature gate
|
|
21
|
+
|
|
3
22
|
## 3.2.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -7,17 +7,20 @@ exports.copyContentToClipboard = exports.changeLanguage = void 0;
|
|
|
7
7
|
exports.createInsertCodeBlockTransaction = createInsertCodeBlockTransaction;
|
|
8
8
|
exports.ignoreFollowingMutations = void 0;
|
|
9
9
|
exports.insertCodeBlockWithAnalytics = insertCodeBlockWithAnalytics;
|
|
10
|
-
exports.
|
|
10
|
+
exports.toggleWordWrapStateForCodeBlockNode = exports.resetShouldIgnoreFollowingMutations = exports.resetCopiedState = exports.removeCodeBlock = void 0;
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
13
|
+
var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
13
14
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
14
15
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
15
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
17
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
19
|
var _pluginKey = require("./plugin-key");
|
|
18
20
|
var _actions = require("./pm-plugins/actions");
|
|
19
21
|
var _codeBlockCopySelectionPlugin = require("./pm-plugins/codeBlockCopySelectionPlugin");
|
|
20
22
|
var _transformToCodeBlock = require("./transform-to-code-block");
|
|
23
|
+
var _utils2 = require("./utils");
|
|
21
24
|
var removeCodeBlock = exports.removeCodeBlock = function removeCodeBlock(state, dispatch) {
|
|
22
25
|
var nodes = state.schema.nodes,
|
|
23
26
|
tr = state.tr;
|
|
@@ -32,11 +35,6 @@ var removeCodeBlock = exports.removeCodeBlock = function removeCodeBlock(state,
|
|
|
32
35
|
}
|
|
33
36
|
return true;
|
|
34
37
|
};
|
|
35
|
-
|
|
36
|
-
// we will be hooking the button up in this follow up card ED-24222
|
|
37
|
-
var wrapCodeBlock = exports.wrapCodeBlock = function wrapCodeBlock(state, dispatch) {
|
|
38
|
-
return false;
|
|
39
|
-
};
|
|
40
38
|
var changeLanguage = exports.changeLanguage = function changeLanguage(editorAnalyticsAPI) {
|
|
41
39
|
return function (language) {
|
|
42
40
|
return function (state, dispatch) {
|
|
@@ -203,4 +201,25 @@ function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
203
201
|
}
|
|
204
202
|
return true;
|
|
205
203
|
});
|
|
206
|
-
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
208
|
+
*/
|
|
209
|
+
var toggleWordWrapStateForCodeBlockNode = exports.toggleWordWrapStateForCodeBlockNode = function toggleWordWrapStateForCodeBlockNode(state) {
|
|
210
|
+
var _findCodeBlock;
|
|
211
|
+
if (!(0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping')) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
var codeBlockNode = (_findCodeBlock = (0, _utils2.findCodeBlock)(state)) === null || _findCodeBlock === void 0 ? void 0 : _findCodeBlock.node;
|
|
215
|
+
if (!_codeBlock.codeBlockWrappedStates || !codeBlockNode) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
var currentValue = (0, _codeBlock.isCodeBlockWordWrapEnabled)(codeBlockNode);
|
|
219
|
+
_codeBlock.codeBlockWrappedStates.set(codeBlockNode, !currentValue);
|
|
220
|
+
|
|
221
|
+
// TODO: Remove in ED-24222. Leaving here for demo purposes.
|
|
222
|
+
// eslint-disable-next-line no-console
|
|
223
|
+
console.log("Code Block Word Wrap: Updating codeBlockWrappedStates with: ".concat(_codeBlock.codeBlockWrappedStates.get(codeBlockNode)));
|
|
224
|
+
return true;
|
|
225
|
+
};
|
|
@@ -9,6 +9,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
|
+
var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
12
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
14
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -16,7 +17,7 @@ var _actions = require("../actions");
|
|
|
16
17
|
var _mainState = require("../pm-plugins/main-state");
|
|
17
18
|
var _classNames = require("../ui/class-names");
|
|
18
19
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
19
|
-
var toDOM = function toDOM(node, contentEditable) {
|
|
20
|
+
var toDOM = function toDOM(node, contentEditable, isWrapped) {
|
|
20
21
|
return ['div', {
|
|
21
22
|
class: 'code-block'
|
|
22
23
|
}, ['div', {
|
|
@@ -27,12 +28,14 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
27
28
|
}, ['div', {
|
|
28
29
|
class: _classNames.codeBlockClassNames.gutter,
|
|
29
30
|
contenteditable: 'false'
|
|
30
|
-
}], ['div', {
|
|
31
|
+
}], ['div', isWrapped && (0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping') ? {
|
|
32
|
+
class: "".concat(_classNames.codeBlockClassNames.content, " ").concat(_classNames.codeBlockClassNames.contentWrapped)
|
|
33
|
+
} : {
|
|
31
34
|
class: _classNames.codeBlockClassNames.content
|
|
32
35
|
}, ['code', {
|
|
33
36
|
'data-language': node.attrs.language || '',
|
|
34
37
|
spellcheck: 'false',
|
|
35
|
-
contenteditable: (0, _platformFeatureFlags.
|
|
38
|
+
contenteditable: (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
|
|
36
39
|
'data-testid': 'code-block--code'
|
|
37
40
|
}, 0]]], ['div', {
|
|
38
41
|
class: _classNames.codeBlockClassNames.end,
|
|
@@ -40,7 +43,7 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
40
43
|
}]];
|
|
41
44
|
};
|
|
42
45
|
var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
43
|
-
function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
|
|
46
|
+
function CodeBlockView(_node, view, getPos, api, isWrapped, cleanupEditorDisabledListener) {
|
|
44
47
|
var _this = this,
|
|
45
48
|
_api$editorDisabled;
|
|
46
49
|
(0, _classCallCheck2.default)(this, CodeBlockView);
|
|
@@ -60,7 +63,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
60
63
|
}
|
|
61
64
|
}));
|
|
62
65
|
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))),
|
|
66
|
+
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
67
|
dom = _DOMSerializer$render.dom,
|
|
65
68
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
66
69
|
this.getPos = getPos;
|
|
@@ -70,6 +73,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
70
73
|
this.contentDOM = contentDOM;
|
|
71
74
|
this.lineNumberGutter = this.dom.querySelector(".".concat(_classNames.codeBlockClassNames.gutter));
|
|
72
75
|
this.api = api;
|
|
76
|
+
this.isWrapped = isWrapped;
|
|
73
77
|
this.ensureLineNumbers();
|
|
74
78
|
this.handleEditorDisabledChanged();
|
|
75
79
|
}
|
|
@@ -78,7 +82,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
78
82
|
value: function handleEditorDisabledChanged() {
|
|
79
83
|
var _this$api,
|
|
80
84
|
_this2 = this;
|
|
81
|
-
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && (0, _platformFeatureFlags.
|
|
85
|
+
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
86
|
this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
83
87
|
if (_this2.contentDOM) {
|
|
84
88
|
_this2.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
|
|
@@ -139,6 +143,9 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
139
143
|
return false;
|
|
140
144
|
}
|
|
141
145
|
if (node !== this.node) {
|
|
146
|
+
if ((0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping')) {
|
|
147
|
+
(0, _codeBlock.transferCodeBlockWrappedValue)(this.node, node);
|
|
148
|
+
}
|
|
142
149
|
if (node.attrs.language !== this.node.attrs.language) {
|
|
143
150
|
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
144
151
|
}
|
|
@@ -173,6 +180,6 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
173
180
|
}]);
|
|
174
181
|
return CodeBlockView;
|
|
175
182
|
}();
|
|
176
|
-
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
|
|
177
|
-
return new CodeBlockView(node, view, getPos, api);
|
|
183
|
+
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api, isWrapped) {
|
|
184
|
+
return new CodeBlockView(node, view, getPos, api, isWrapped);
|
|
178
185
|
};
|
|
@@ -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) {
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -105,7 +105,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
105
105
|
id: 'editor.codeBlock.wrap',
|
|
106
106
|
type: 'button',
|
|
107
107
|
icon: _WrapIcon.WrapIcon,
|
|
108
|
-
onClick: _actions.
|
|
108
|
+
onClick: _actions.toggleWordWrapStateForCodeBlockNode,
|
|
109
|
+
// Hooking up here for demo purposes. To be revisited with ED-24222.
|
|
109
110
|
title: formatMessage(_messages.codeBlockButtonMessages.wrapCode),
|
|
110
111
|
tabIndex: null
|
|
111
112
|
};
|
|
@@ -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
|
};
|
package/dist/es2019/actions.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
3
|
+
import { codeBlockWrappedStates, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
3
4
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
5
|
import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
5
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
import { pluginKey } from './plugin-key';
|
|
8
10
|
import { ACTIONS } from './pm-plugins/actions';
|
|
9
11
|
import { copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
10
12
|
import { transformToCodeBlockAction } from './transform-to-code-block';
|
|
13
|
+
import { findCodeBlock } from './utils';
|
|
11
14
|
export const removeCodeBlock = (state, dispatch) => {
|
|
12
15
|
const {
|
|
13
16
|
schema: {
|
|
@@ -26,11 +29,6 @@ export const removeCodeBlock = (state, dispatch) => {
|
|
|
26
29
|
}
|
|
27
30
|
return true;
|
|
28
31
|
};
|
|
29
|
-
|
|
30
|
-
// we will be hooking the button up in this follow up card ED-24222
|
|
31
|
-
export const wrapCodeBlock = (state, dispatch) => {
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
34
32
|
export const changeLanguage = editorAnalyticsAPI => language => (state, dispatch) => {
|
|
35
33
|
var _pluginKey$getState;
|
|
36
34
|
const {
|
|
@@ -213,4 +211,25 @@ export function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
213
211
|
}
|
|
214
212
|
return true;
|
|
215
213
|
});
|
|
216
|
-
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
218
|
+
*/
|
|
219
|
+
export const toggleWordWrapStateForCodeBlockNode = state => {
|
|
220
|
+
var _findCodeBlock;
|
|
221
|
+
if (!fg('editor_support_code_block_wrapping')) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
const codeBlockNode = (_findCodeBlock = findCodeBlock(state)) === null || _findCodeBlock === void 0 ? void 0 : _findCodeBlock.node;
|
|
225
|
+
if (!codeBlockWrappedStates || !codeBlockNode) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
const currentValue = isCodeBlockWordWrapEnabled(codeBlockNode);
|
|
229
|
+
codeBlockWrappedStates.set(codeBlockNode, !currentValue);
|
|
230
|
+
|
|
231
|
+
// TODO: Remove in ED-24222. Leaving here for demo purposes.
|
|
232
|
+
// eslint-disable-next-line no-console
|
|
233
|
+
console.log(`Code Block Word Wrap: Updating codeBlockWrappedStates with: ${codeBlockWrappedStates.get(codeBlockNode)}`);
|
|
234
|
+
return true;
|
|
235
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import rafSchedule from 'raf-schd';
|
|
3
|
+
import { transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
|
|
3
4
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import {
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { resetShouldIgnoreFollowingMutations } from '../actions';
|
|
7
8
|
import { getPluginState } from '../pm-plugins/main-state';
|
|
8
9
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
9
10
|
const MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
10
|
-
const toDOM = (node, contentEditable) => ['div', {
|
|
11
|
+
const toDOM = (node, contentEditable, isWrapped) => ['div', {
|
|
11
12
|
class: 'code-block'
|
|
12
13
|
}, ['div', {
|
|
13
14
|
class: codeBlockClassNames.start,
|
|
@@ -17,19 +18,21 @@ const toDOM = (node, contentEditable) => ['div', {
|
|
|
17
18
|
}, ['div', {
|
|
18
19
|
class: codeBlockClassNames.gutter,
|
|
19
20
|
contenteditable: 'false'
|
|
20
|
-
}], ['div', {
|
|
21
|
+
}], ['div', isWrapped && fg('editor_support_code_block_wrapping') ? {
|
|
22
|
+
class: `${codeBlockClassNames.content} ${codeBlockClassNames.contentWrapped}`
|
|
23
|
+
} : {
|
|
21
24
|
class: codeBlockClassNames.content
|
|
22
25
|
}, ['code', {
|
|
23
26
|
'data-language': node.attrs.language || '',
|
|
24
27
|
spellcheck: 'false',
|
|
25
|
-
contenteditable:
|
|
28
|
+
contenteditable: fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
|
|
26
29
|
'data-testid': 'code-block--code'
|
|
27
30
|
}, 0]]], ['div', {
|
|
28
31
|
class: codeBlockClassNames.end,
|
|
29
32
|
contenteditable: 'false'
|
|
30
33
|
}]];
|
|
31
34
|
export class CodeBlockView {
|
|
32
|
-
constructor(_node, view, getPos, api, cleanupEditorDisabledListener) {
|
|
35
|
+
constructor(_node, view, getPos, api, isWrapped, cleanupEditorDisabledListener) {
|
|
33
36
|
var _api$editorDisabled, _api$editorDisabled$s;
|
|
34
37
|
_defineProperty(this, "ensureLineNumbers", rafSchedule(() => {
|
|
35
38
|
let lines = 1;
|
|
@@ -50,7 +53,7 @@ export class CodeBlockView {
|
|
|
50
53
|
const {
|
|
51
54
|
dom,
|
|
52
55
|
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)));
|
|
56
|
+
} = 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
57
|
this.getPos = getPos;
|
|
55
58
|
this.view = view;
|
|
56
59
|
this.node = _node;
|
|
@@ -58,12 +61,13 @@ export class CodeBlockView {
|
|
|
58
61
|
this.contentDOM = contentDOM;
|
|
59
62
|
this.lineNumberGutter = this.dom.querySelector(`.${codeBlockClassNames.gutter}`);
|
|
60
63
|
this.api = api;
|
|
64
|
+
this.isWrapped = isWrapped;
|
|
61
65
|
this.ensureLineNumbers();
|
|
62
66
|
this.handleEditorDisabledChanged();
|
|
63
67
|
}
|
|
64
68
|
handleEditorDisabledChanged() {
|
|
65
69
|
var _this$api;
|
|
66
|
-
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled &&
|
|
70
|
+
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
71
|
this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(sharedState => {
|
|
68
72
|
if (this.contentDOM) {
|
|
69
73
|
this.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
|
|
@@ -116,6 +120,9 @@ export class CodeBlockView {
|
|
|
116
120
|
return false;
|
|
117
121
|
}
|
|
118
122
|
if (node !== this.node) {
|
|
123
|
+
if (fg('editor_support_code_block_wrapping')) {
|
|
124
|
+
transferCodeBlockWrappedValue(this.node, node);
|
|
125
|
+
}
|
|
119
126
|
if (node.attrs.language !== this.node.attrs.language) {
|
|
120
127
|
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
121
128
|
}
|
|
@@ -144,4 +151,4 @@ export class CodeBlockView {
|
|
|
144
151
|
this.cleanupEditorDisabledListener = undefined;
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
|
-
export const codeBlockNodeView = (node, view, getPos, api) => new CodeBlockView(node, view, getPos, api);
|
|
154
|
+
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
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -3,7 +3,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
3
3
|
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
4
4
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState,
|
|
6
|
+
import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState, toggleWordWrapStateForCodeBlockNode } from './actions';
|
|
7
7
|
import { createLanguageList, DEFAULT_LANGUAGES, getLanguageIdentifier } from './language-list';
|
|
8
8
|
import { pluginKey } from './plugin-key';
|
|
9
9
|
import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
@@ -86,7 +86,8 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
|
|
|
86
86
|
id: 'editor.codeBlock.wrap',
|
|
87
87
|
type: 'button',
|
|
88
88
|
icon: WrapIcon,
|
|
89
|
-
onClick:
|
|
89
|
+
onClick: toggleWordWrapStateForCodeBlockNode,
|
|
90
|
+
// Hooking up here for demo purposes. To be revisited with ED-24222.
|
|
90
91
|
title: formatMessage(codeBlockButtonMessages.wrapCode),
|
|
91
92
|
tabIndex: null
|
|
92
93
|
};
|
|
@@ -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
|
};
|
package/dist/esm/actions.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
3
|
+
import { codeBlockWrappedStates, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
3
4
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
5
|
import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
5
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
import { pluginKey } from './plugin-key';
|
|
8
10
|
import { ACTIONS } from './pm-plugins/actions';
|
|
9
11
|
import { copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
10
12
|
import { transformToCodeBlockAction } from './transform-to-code-block';
|
|
13
|
+
import { findCodeBlock } from './utils';
|
|
11
14
|
export var removeCodeBlock = function removeCodeBlock(state, dispatch) {
|
|
12
15
|
var nodes = state.schema.nodes,
|
|
13
16
|
tr = state.tr;
|
|
@@ -22,11 +25,6 @@ export var removeCodeBlock = function removeCodeBlock(state, dispatch) {
|
|
|
22
25
|
}
|
|
23
26
|
return true;
|
|
24
27
|
};
|
|
25
|
-
|
|
26
|
-
// we will be hooking the button up in this follow up card ED-24222
|
|
27
|
-
export var wrapCodeBlock = function wrapCodeBlock(state, dispatch) {
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
30
28
|
export var changeLanguage = function changeLanguage(editorAnalyticsAPI) {
|
|
31
29
|
return function (language) {
|
|
32
30
|
return function (state, dispatch) {
|
|
@@ -193,4 +191,25 @@ export function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
193
191
|
}
|
|
194
192
|
return true;
|
|
195
193
|
});
|
|
196
|
-
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
198
|
+
*/
|
|
199
|
+
export var toggleWordWrapStateForCodeBlockNode = function toggleWordWrapStateForCodeBlockNode(state) {
|
|
200
|
+
var _findCodeBlock;
|
|
201
|
+
if (!fg('editor_support_code_block_wrapping')) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
var codeBlockNode = (_findCodeBlock = findCodeBlock(state)) === null || _findCodeBlock === void 0 ? void 0 : _findCodeBlock.node;
|
|
205
|
+
if (!codeBlockWrappedStates || !codeBlockNode) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
var currentValue = isCodeBlockWordWrapEnabled(codeBlockNode);
|
|
209
|
+
codeBlockWrappedStates.set(codeBlockNode, !currentValue);
|
|
210
|
+
|
|
211
|
+
// TODO: Remove in ED-24222. Leaving here for demo purposes.
|
|
212
|
+
// eslint-disable-next-line no-console
|
|
213
|
+
console.log("Code Block Word Wrap: Updating codeBlockWrappedStates with: ".concat(codeBlockWrappedStates.get(codeBlockNode)));
|
|
214
|
+
return true;
|
|
215
|
+
};
|
|
@@ -2,14 +2,15 @@ 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
4
|
import rafSchedule from 'raf-schd';
|
|
5
|
+
import { transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
|
|
5
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
-
import {
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { resetShouldIgnoreFollowingMutations } from '../actions';
|
|
9
10
|
import { getPluginState } from '../pm-plugins/main-state';
|
|
10
11
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
11
12
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
12
|
-
var toDOM = function toDOM(node, contentEditable) {
|
|
13
|
+
var toDOM = function toDOM(node, contentEditable, isWrapped) {
|
|
13
14
|
return ['div', {
|
|
14
15
|
class: 'code-block'
|
|
15
16
|
}, ['div', {
|
|
@@ -20,12 +21,14 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
20
21
|
}, ['div', {
|
|
21
22
|
class: codeBlockClassNames.gutter,
|
|
22
23
|
contenteditable: 'false'
|
|
23
|
-
}], ['div', {
|
|
24
|
+
}], ['div', isWrapped && fg('editor_support_code_block_wrapping') ? {
|
|
25
|
+
class: "".concat(codeBlockClassNames.content, " ").concat(codeBlockClassNames.contentWrapped)
|
|
26
|
+
} : {
|
|
24
27
|
class: codeBlockClassNames.content
|
|
25
28
|
}, ['code', {
|
|
26
29
|
'data-language': node.attrs.language || '',
|
|
27
30
|
spellcheck: 'false',
|
|
28
|
-
contenteditable:
|
|
31
|
+
contenteditable: fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
|
|
29
32
|
'data-testid': 'code-block--code'
|
|
30
33
|
}, 0]]], ['div', {
|
|
31
34
|
class: codeBlockClassNames.end,
|
|
@@ -33,7 +36,7 @@ var toDOM = function toDOM(node, contentEditable) {
|
|
|
33
36
|
}]];
|
|
34
37
|
};
|
|
35
38
|
export var CodeBlockView = /*#__PURE__*/function () {
|
|
36
|
-
function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
|
|
39
|
+
function CodeBlockView(_node, view, getPos, api, isWrapped, cleanupEditorDisabledListener) {
|
|
37
40
|
var _this = this,
|
|
38
41
|
_api$editorDisabled;
|
|
39
42
|
_classCallCheck(this, CodeBlockView);
|
|
@@ -53,7 +56,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
53
56
|
}
|
|
54
57
|
}));
|
|
55
58
|
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))),
|
|
59
|
+
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
60
|
dom = _DOMSerializer$render.dom,
|
|
58
61
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
59
62
|
this.getPos = getPos;
|
|
@@ -63,6 +66,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
63
66
|
this.contentDOM = contentDOM;
|
|
64
67
|
this.lineNumberGutter = this.dom.querySelector(".".concat(codeBlockClassNames.gutter));
|
|
65
68
|
this.api = api;
|
|
69
|
+
this.isWrapped = isWrapped;
|
|
66
70
|
this.ensureLineNumbers();
|
|
67
71
|
this.handleEditorDisabledChanged();
|
|
68
72
|
}
|
|
@@ -71,7 +75,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
71
75
|
value: function handleEditorDisabledChanged() {
|
|
72
76
|
var _this$api,
|
|
73
77
|
_this2 = this;
|
|
74
|
-
if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled &&
|
|
78
|
+
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
79
|
this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
76
80
|
if (_this2.contentDOM) {
|
|
77
81
|
_this2.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
|
|
@@ -132,6 +136,9 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
132
136
|
return false;
|
|
133
137
|
}
|
|
134
138
|
if (node !== this.node) {
|
|
139
|
+
if (fg('editor_support_code_block_wrapping')) {
|
|
140
|
+
transferCodeBlockWrappedValue(this.node, node);
|
|
141
|
+
}
|
|
135
142
|
if (node.attrs.language !== this.node.attrs.language) {
|
|
136
143
|
this.contentDOM.setAttribute('data-language', node.attrs.language || '');
|
|
137
144
|
}
|
|
@@ -166,6 +173,6 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
166
173
|
}]);
|
|
167
174
|
return CodeBlockView;
|
|
168
175
|
}();
|
|
169
|
-
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
|
|
170
|
-
return new CodeBlockView(node, view, getPos, api);
|
|
176
|
+
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api, isWrapped) {
|
|
177
|
+
return new CodeBlockView(node, view, getPos, api, isWrapped);
|
|
171
178
|
};
|
|
@@ -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) {
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -3,7 +3,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
3
3
|
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
4
4
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState,
|
|
6
|
+
import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState, toggleWordWrapStateForCodeBlockNode } from './actions';
|
|
7
7
|
import { createLanguageList, DEFAULT_LANGUAGES, getLanguageIdentifier } from './language-list';
|
|
8
8
|
import { pluginKey } from './plugin-key';
|
|
9
9
|
import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
@@ -95,7 +95,8 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
95
95
|
id: 'editor.codeBlock.wrap',
|
|
96
96
|
type: 'button',
|
|
97
97
|
icon: WrapIcon,
|
|
98
|
-
onClick:
|
|
98
|
+
onClick: toggleWordWrapStateForCodeBlockNode,
|
|
99
|
+
// Hooking up here for demo purposes. To be revisited with ED-24222.
|
|
99
100
|
title: formatMessage(codeBlockButtonMessages.wrapCode),
|
|
100
101
|
tabIndex: null
|
|
101
102
|
};
|
|
@@ -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
|
};
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/a
|
|
|
2
2
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
export declare const removeCodeBlock: Command;
|
|
5
|
-
export declare const wrapCodeBlock: Command;
|
|
6
5
|
export declare const changeLanguage: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (language: string) => Command;
|
|
7
6
|
export declare const copyContentToClipboard: Command;
|
|
8
7
|
export declare const resetCopiedState: Command;
|
|
@@ -17,3 +16,7 @@ export declare function createInsertCodeBlockTransaction({ state }: {
|
|
|
17
16
|
state: EditorState;
|
|
18
17
|
}): import("prosemirror-state").Transaction;
|
|
19
18
|
export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
|
|
19
|
+
/**
|
|
20
|
+
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
21
|
+
*/
|
|
22
|
+
export declare const toggleWordWrapStateForCodeBlockNode: Command;
|
|
@@ -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;
|
|
@@ -2,8 +2,8 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
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
|
-
import type
|
|
6
|
-
export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, }: {
|
|
5
|
+
import { type CodeBlockState } from './main-state';
|
|
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>;
|
|
@@ -2,7 +2,6 @@ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/a
|
|
|
2
2
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
export declare const removeCodeBlock: Command;
|
|
5
|
-
export declare const wrapCodeBlock: Command;
|
|
6
5
|
export declare const changeLanguage: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (language: string) => Command;
|
|
7
6
|
export declare const copyContentToClipboard: Command;
|
|
8
7
|
export declare const resetCopiedState: Command;
|
|
@@ -17,3 +16,7 @@ export declare function createInsertCodeBlockTransaction({ state }: {
|
|
|
17
16
|
state: EditorState;
|
|
18
17
|
}): import("prosemirror-state").Transaction;
|
|
19
18
|
export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
|
|
19
|
+
/**
|
|
20
|
+
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
21
|
+
*/
|
|
22
|
+
export declare const toggleWordWrapStateForCodeBlockNode: Command;
|
|
@@ -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;
|
|
@@ -2,8 +2,8 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
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
|
-
import type
|
|
6
|
-
export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, }: {
|
|
5
|
+
import { type CodeBlockState } from './main-state';
|
|
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.3",
|
|
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",
|