@atlaskit/editor-plugin-code-block 3.2.3 → 3.2.4
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 +9 -0
- package/dist/cjs/actions.js +34 -15
- package/dist/cjs/toolbar.js +1 -1
- package/dist/es2019/actions.js +24 -5
- package/dist/es2019/toolbar.js +1 -1
- package/dist/esm/actions.js +35 -16
- package/dist/esm/toolbar.js +1 -1
- package/dist/types/actions.d.ts +1 -1
- package/dist/types-ts4.5/actions.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#126818](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/126818)
|
|
8
|
+
[`197b047fbe6e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/197b047fbe6e6) -
|
|
9
|
+
ED-24245 - Adding analytics TRACK event that is triggered when the user clicks the toggle word
|
|
10
|
+
wrap button on the code block floating toolbar.
|
|
11
|
+
|
|
3
12
|
## 3.2.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -206,20 +206,39 @@ function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
206
206
|
/**
|
|
207
207
|
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
208
208
|
*/
|
|
209
|
-
var toggleWordWrapStateForCodeBlockNode = exports.toggleWordWrapStateForCodeBlockNode = function toggleWordWrapStateForCodeBlockNode(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
209
|
+
var toggleWordWrapStateForCodeBlockNode = exports.toggleWordWrapStateForCodeBlockNode = function toggleWordWrapStateForCodeBlockNode(editorAnalyticsAPI) {
|
|
210
|
+
return function (state, dispatch) {
|
|
211
|
+
var _findCodeBlock;
|
|
212
|
+
if (!(0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping')) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
var codeBlockNode = (_findCodeBlock = (0, _utils2.findCodeBlock)(state)) === null || _findCodeBlock === void 0 ? void 0 : _findCodeBlock.node;
|
|
216
|
+
var tr = state.tr;
|
|
217
|
+
if (!_codeBlock.codeBlockWrappedStates || !codeBlockNode) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
var updatedToggleState = !(0, _codeBlock.isCodeBlockWordWrapEnabled)(codeBlockNode);
|
|
221
|
+
_codeBlock.codeBlockWrappedStates.set(codeBlockNode, updatedToggleState);
|
|
220
222
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
// TODO: Remove in ED-24222. Leaving here for demo purposes.
|
|
224
|
+
// eslint-disable-next-line no-console
|
|
225
|
+
console.log("Code Block Word Wrap: Updating codeBlockWrappedStates with: ".concat(updatedToggleState));
|
|
226
|
+
if (dispatch) {
|
|
227
|
+
var payload = {
|
|
228
|
+
action: _analytics.ACTION.TOGGLE_CODE_BLOCK_WRAP,
|
|
229
|
+
actionSubject: _analytics.ACTION_SUBJECT.CODE_BLOCK,
|
|
230
|
+
attributes: {
|
|
231
|
+
platform: _analytics.PLATFORMS.WEB,
|
|
232
|
+
mode: _analytics.MODE.EDITOR,
|
|
233
|
+
wordWrapEnabled: updatedToggleState
|
|
234
|
+
},
|
|
235
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// TODO: ED-24320 should convert this to attachAnalyticsEvent if it is dispatching a transaction here.
|
|
239
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent(payload);
|
|
240
|
+
dispatch(tr);
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
};
|
|
225
244
|
};
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -105,7 +105,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
105
105
|
id: 'editor.codeBlock.wrap',
|
|
106
106
|
type: 'button',
|
|
107
107
|
icon: _WrapIcon.WrapIcon,
|
|
108
|
-
onClick: _actions.toggleWordWrapStateForCodeBlockNode,
|
|
108
|
+
onClick: (0, _actions.toggleWordWrapStateForCodeBlockNode)(editorAnalyticsAPI),
|
|
109
109
|
// Hooking up here for demo purposes. To be revisited with ED-24222.
|
|
110
110
|
title: formatMessage(_messages.codeBlockButtonMessages.wrapCode),
|
|
111
111
|
tabIndex: null
|
package/dist/es2019/actions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
3
3
|
import { codeBlockWrappedStates, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
4
4
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
@@ -216,20 +216,39 @@ export function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
216
216
|
/**
|
|
217
217
|
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
218
218
|
*/
|
|
219
|
-
export const toggleWordWrapStateForCodeBlockNode = state => {
|
|
219
|
+
export const toggleWordWrapStateForCodeBlockNode = editorAnalyticsAPI => (state, dispatch) => {
|
|
220
220
|
var _findCodeBlock;
|
|
221
221
|
if (!fg('editor_support_code_block_wrapping')) {
|
|
222
222
|
return false;
|
|
223
223
|
}
|
|
224
224
|
const codeBlockNode = (_findCodeBlock = findCodeBlock(state)) === null || _findCodeBlock === void 0 ? void 0 : _findCodeBlock.node;
|
|
225
|
+
const {
|
|
226
|
+
tr
|
|
227
|
+
} = state;
|
|
225
228
|
if (!codeBlockWrappedStates || !codeBlockNode) {
|
|
226
229
|
return false;
|
|
227
230
|
}
|
|
228
|
-
const
|
|
229
|
-
codeBlockWrappedStates.set(codeBlockNode,
|
|
231
|
+
const updatedToggleState = !isCodeBlockWordWrapEnabled(codeBlockNode);
|
|
232
|
+
codeBlockWrappedStates.set(codeBlockNode, updatedToggleState);
|
|
230
233
|
|
|
231
234
|
// TODO: Remove in ED-24222. Leaving here for demo purposes.
|
|
232
235
|
// eslint-disable-next-line no-console
|
|
233
|
-
console.log(`Code Block Word Wrap: Updating codeBlockWrappedStates with: ${
|
|
236
|
+
console.log(`Code Block Word Wrap: Updating codeBlockWrappedStates with: ${updatedToggleState}`);
|
|
237
|
+
if (dispatch) {
|
|
238
|
+
const payload = {
|
|
239
|
+
action: ACTION.TOGGLE_CODE_BLOCK_WRAP,
|
|
240
|
+
actionSubject: ACTION_SUBJECT.CODE_BLOCK,
|
|
241
|
+
attributes: {
|
|
242
|
+
platform: PLATFORMS.WEB,
|
|
243
|
+
mode: MODE.EDITOR,
|
|
244
|
+
wordWrapEnabled: updatedToggleState
|
|
245
|
+
},
|
|
246
|
+
eventType: EVENT_TYPE.TRACK
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// TODO: ED-24320 should convert this to attachAnalyticsEvent if it is dispatching a transaction here.
|
|
250
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.fireAnalyticsEvent(payload);
|
|
251
|
+
dispatch(tr);
|
|
252
|
+
}
|
|
234
253
|
return true;
|
|
235
254
|
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -86,7 +86,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
|
|
|
86
86
|
id: 'editor.codeBlock.wrap',
|
|
87
87
|
type: 'button',
|
|
88
88
|
icon: WrapIcon,
|
|
89
|
-
onClick: toggleWordWrapStateForCodeBlockNode,
|
|
89
|
+
onClick: toggleWordWrapStateForCodeBlockNode(editorAnalyticsAPI),
|
|
90
90
|
// Hooking up here for demo purposes. To be revisited with ED-24222.
|
|
91
91
|
title: formatMessage(codeBlockButtonMessages.wrapCode),
|
|
92
92
|
tabIndex: null
|
package/dist/esm/actions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
3
3
|
import { codeBlockWrappedStates, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
4
4
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
@@ -196,20 +196,39 @@ export function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
196
196
|
/**
|
|
197
197
|
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
198
198
|
*/
|
|
199
|
-
export var toggleWordWrapStateForCodeBlockNode = function toggleWordWrapStateForCodeBlockNode(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
export var toggleWordWrapStateForCodeBlockNode = function toggleWordWrapStateForCodeBlockNode(editorAnalyticsAPI) {
|
|
200
|
+
return function (state, dispatch) {
|
|
201
|
+
var _findCodeBlock;
|
|
202
|
+
if (!fg('editor_support_code_block_wrapping')) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
var codeBlockNode = (_findCodeBlock = findCodeBlock(state)) === null || _findCodeBlock === void 0 ? void 0 : _findCodeBlock.node;
|
|
206
|
+
var tr = state.tr;
|
|
207
|
+
if (!codeBlockWrappedStates || !codeBlockNode) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
var updatedToggleState = !isCodeBlockWordWrapEnabled(codeBlockNode);
|
|
211
|
+
codeBlockWrappedStates.set(codeBlockNode, updatedToggleState);
|
|
210
212
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
// TODO: Remove in ED-24222. Leaving here for demo purposes.
|
|
214
|
+
// eslint-disable-next-line no-console
|
|
215
|
+
console.log("Code Block Word Wrap: Updating codeBlockWrappedStates with: ".concat(updatedToggleState));
|
|
216
|
+
if (dispatch) {
|
|
217
|
+
var payload = {
|
|
218
|
+
action: ACTION.TOGGLE_CODE_BLOCK_WRAP,
|
|
219
|
+
actionSubject: ACTION_SUBJECT.CODE_BLOCK,
|
|
220
|
+
attributes: {
|
|
221
|
+
platform: PLATFORMS.WEB,
|
|
222
|
+
mode: MODE.EDITOR,
|
|
223
|
+
wordWrapEnabled: updatedToggleState
|
|
224
|
+
},
|
|
225
|
+
eventType: EVENT_TYPE.TRACK
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// TODO: ED-24320 should convert this to attachAnalyticsEvent if it is dispatching a transaction here.
|
|
229
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent(payload);
|
|
230
|
+
dispatch(tr);
|
|
231
|
+
}
|
|
232
|
+
return true;
|
|
233
|
+
};
|
|
215
234
|
};
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -95,7 +95,7 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
95
95
|
id: 'editor.codeBlock.wrap',
|
|
96
96
|
type: 'button',
|
|
97
97
|
icon: WrapIcon,
|
|
98
|
-
onClick: toggleWordWrapStateForCodeBlockNode,
|
|
98
|
+
onClick: toggleWordWrapStateForCodeBlockNode(editorAnalyticsAPI),
|
|
99
99
|
// Hooking up here for demo purposes. To be revisited with ED-24222.
|
|
100
100
|
title: formatMessage(codeBlockButtonMessages.wrapCode),
|
|
101
101
|
tabIndex: null
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD,
|
|
|
19
19
|
/**
|
|
20
20
|
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
21
21
|
*/
|
|
22
|
-
export declare const toggleWordWrapStateForCodeBlockNode: Command;
|
|
22
|
+
export declare const toggleWordWrapStateForCodeBlockNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -19,4 +19,4 @@ export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD,
|
|
|
19
19
|
/**
|
|
20
20
|
* Add the given node to the codeBlockWrappedStates WeakMap with the toggle boolean value.
|
|
21
21
|
*/
|
|
22
|
-
export declare const toggleWordWrapStateForCodeBlockNode: Command;
|
|
22
|
+
export declare const toggleWordWrapStateForCodeBlockNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
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.4",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^40.3.0",
|
|
37
37
|
"@atlaskit/code": "^15.4.0",
|
|
38
|
-
"@atlaskit/editor-common": "^87.
|
|
38
|
+
"@atlaskit/editor-common": "^87.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.6.0",
|
|
40
40
|
"@atlaskit/editor-plugin-composition": "^1.2.0",
|
|
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.10.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",
|