@atlaskit/editor-plugin-code-block 8.1.11 → 8.1.13
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 +17 -0
- package/dist/cjs/codeBlockPlugin.js +1 -1
- package/dist/cjs/pm-plugins/codeBlockCopySelectionPlugin.js +11 -1
- package/dist/cjs/pm-plugins/ide-ux.js +3 -0
- package/dist/cjs/pm-plugins/main.js +9 -0
- package/dist/cjs/pm-plugins/utils.js +9 -0
- package/dist/es2019/codeBlockPlugin.js +2 -2
- package/dist/es2019/pm-plugins/codeBlockCopySelectionPlugin.js +14 -1
- package/dist/es2019/pm-plugins/ide-ux.js +4 -0
- package/dist/es2019/pm-plugins/main.js +12 -0
- package/dist/es2019/pm-plugins/utils.js +9 -0
- package/dist/esm/codeBlockPlugin.js +2 -2
- package/dist/esm/pm-plugins/codeBlockCopySelectionPlugin.js +11 -1
- package/dist/esm/pm-plugins/ide-ux.js +3 -0
- package/dist/esm/pm-plugins/main.js +9 -0
- package/dist/esm/pm-plugins/utils.js +9 -0
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 8.1.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`43d1dfc88c1de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/43d1dfc88c1de) -
|
|
8
|
+
Clean up platform_editor_block_menu_format_rank_revised
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 8.1.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`4d676bbdb3ce6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4d676bbdb3ce6) -
|
|
16
|
+
ts-ignore added temporarily to unblock local consumption for help-center, will be removed once
|
|
17
|
+
project refs are setup
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 8.1.11
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -37,7 +37,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
37
37
|
parent: {
|
|
38
38
|
type: 'block-menu-section',
|
|
39
39
|
key: _blockMenu.FORMAT_MENU_ITEM.key,
|
|
40
|
-
rank:
|
|
40
|
+
rank: _blockMenu.FORMAT_NESTED_MENU_RANK[_blockMenu.FORMAT_CODE_BLOCK_MENU_ITEM.key]
|
|
41
41
|
},
|
|
42
42
|
component: (0, _CodeBlockMenuItem.createCodeBlockMenuItem)(api)
|
|
43
43
|
}]);
|
|
@@ -37,12 +37,21 @@ function codeBlockCopySelectionPlugin() {
|
|
|
37
37
|
return new _safePlugin.SafePlugin({
|
|
38
38
|
key: copySelectionPluginKey,
|
|
39
39
|
state: {
|
|
40
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
40
41
|
init: function init() {
|
|
41
42
|
return {
|
|
42
43
|
decorationStartAndEnd: undefined
|
|
43
44
|
};
|
|
44
45
|
},
|
|
45
|
-
|
|
46
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
47
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
48
|
+
apply: function apply(
|
|
49
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
50
|
+
transaction, currentCodeBlockCopySelectionPluginState,
|
|
51
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
52
|
+
_oldState,
|
|
53
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
54
|
+
newState) {
|
|
46
55
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
47
56
|
case 'show-selection':
|
|
48
57
|
{
|
|
@@ -71,6 +80,7 @@ function codeBlockCopySelectionPlugin() {
|
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
82
|
props: {
|
|
83
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
74
84
|
decorations: function decorations(state) {
|
|
75
85
|
if (copySelectionPluginKey.getState(state).decorationStartAndEnd) {
|
|
76
86
|
var _copySelectionPluginK = (0, _slicedToArray2.default)(copySelectionPluginKey.getState(state).decorationStartAndEnd, 2),
|
|
@@ -20,6 +20,7 @@ var ideUX = function ideUX(pluginInjectionApi) {
|
|
|
20
20
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
21
21
|
return new _safePlugin.SafePlugin({
|
|
22
22
|
props: {
|
|
23
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
23
24
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
24
25
|
var _pluginInjectionApi$c;
|
|
25
26
|
var state = view.state,
|
|
@@ -63,6 +64,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
|
|
|
63
64
|
}
|
|
64
65
|
return false;
|
|
65
66
|
},
|
|
67
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
68
|
+
|
|
66
69
|
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
67
70
|
Backspace: function Backspace(state, dispatch) {
|
|
68
71
|
if ((0, _lineHandling.isCursorInsideCodeBlock)(state)) {
|
|
@@ -32,6 +32,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
32
32
|
allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition,
|
|
33
33
|
api = _ref.api;
|
|
34
34
|
var handleDOMEvents = {
|
|
35
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
36
|
+
|
|
35
37
|
click: function click() {
|
|
36
38
|
var _api$core, _api$interaction;
|
|
37
39
|
// Set hasHadInteraction to true on any click of code blocks, as clicks
|
|
@@ -83,6 +85,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
83
85
|
}
|
|
84
86
|
return new _safePlugin.SafePlugin({
|
|
85
87
|
state: {
|
|
88
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
86
89
|
init: function init(_, state) {
|
|
87
90
|
var node = (0, _transforms.findCodeBlock)(state, state.selection);
|
|
88
91
|
var initialDecorations =
|
|
@@ -99,6 +102,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
99
102
|
decorations: _view.DecorationSet.create(state.doc, initialDecorations)
|
|
100
103
|
};
|
|
101
104
|
},
|
|
105
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
102
106
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
103
107
|
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
104
108
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === _actions.ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -112,6 +116,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
112
116
|
|
|
113
117
|
// Updates mapping position of all existing decorations to new positions
|
|
114
118
|
// specifically used for updating word wrap node decorators (does not cover drag & drop, validateWordWrappedDecorators does).
|
|
119
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
120
|
+
|
|
115
121
|
var updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
|
|
116
122
|
var codeBlockNodes = (0, _utils.getAllChangedCodeBlocksInTransaction)(tr);
|
|
117
123
|
if (codeBlockNodes) {
|
|
@@ -151,9 +157,12 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
151
157
|
},
|
|
152
158
|
key: _pluginKey.pluginKey,
|
|
153
159
|
props: {
|
|
160
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
154
161
|
decorations: function decorations(state) {
|
|
155
162
|
return _pluginKey.pluginKey.getState(state).decorations || _view.DecorationSet.empty;
|
|
156
163
|
},
|
|
164
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
165
|
+
|
|
157
166
|
nodeViews: {
|
|
158
167
|
codeBlock: function codeBlock(node, view, getPos) {
|
|
159
168
|
var _getIntl = getIntl(),
|
|
@@ -11,6 +11,8 @@ function getCursor(selection) {
|
|
|
11
11
|
}
|
|
12
12
|
function getAllCodeBlockNodesInDoc(state) {
|
|
13
13
|
var codeBlockNodes = [];
|
|
14
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
15
|
+
|
|
14
16
|
state.doc.descendants(function (node, pos) {
|
|
15
17
|
if (node.type === state.schema.nodes.codeBlock) {
|
|
16
18
|
codeBlockNodes.push({
|
|
@@ -26,9 +28,16 @@ function getAllCodeBlockNodesInDoc(state) {
|
|
|
26
28
|
function getAllChangedCodeBlocksInTransaction(tr) {
|
|
27
29
|
var changedCodeBlocks = [];
|
|
28
30
|
var nodePositions = new Set();
|
|
31
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
32
|
+
|
|
29
33
|
tr.steps.forEach(function (step) {
|
|
30
34
|
var mapResult = step.getMap();
|
|
35
|
+
|
|
36
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
37
|
+
|
|
31
38
|
mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
39
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
40
|
+
|
|
32
41
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
|
|
33
42
|
if (node.type.name === 'codeBlock') {
|
|
34
43
|
if (!nodePositions.has(pos)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { codeBlock, codeBlockWithLocalId } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK
|
|
4
|
+
import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
|
|
5
5
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -28,7 +28,7 @@ const codeBlockPlugin = ({
|
|
|
28
28
|
parent: {
|
|
29
29
|
type: 'block-menu-section',
|
|
30
30
|
key: FORMAT_MENU_ITEM.key,
|
|
31
|
-
rank:
|
|
31
|
+
rank: FORMAT_NESTED_MENU_RANK[FORMAT_CODE_BLOCK_MENU_ITEM.key]
|
|
32
32
|
},
|
|
33
33
|
component: createCodeBlockMenuItem(api)
|
|
34
34
|
}]);
|
|
@@ -27,12 +27,23 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
27
27
|
return new SafePlugin({
|
|
28
28
|
key: copySelectionPluginKey,
|
|
29
29
|
state: {
|
|
30
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
31
|
+
|
|
30
32
|
init() {
|
|
31
33
|
return {
|
|
32
34
|
decorationStartAndEnd: undefined
|
|
33
35
|
};
|
|
34
36
|
},
|
|
35
|
-
|
|
37
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
38
|
+
|
|
39
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
40
|
+
apply(
|
|
41
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
42
|
+
transaction, currentCodeBlockCopySelectionPluginState,
|
|
43
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
44
|
+
_oldState,
|
|
45
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
46
|
+
newState) {
|
|
36
47
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
37
48
|
case 'show-selection':
|
|
38
49
|
{
|
|
@@ -61,6 +72,8 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
61
72
|
}
|
|
62
73
|
},
|
|
63
74
|
props: {
|
|
75
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
76
|
+
|
|
64
77
|
decorations(state) {
|
|
65
78
|
if (copySelectionPluginKey.getState(state).decorationStartAndEnd) {
|
|
66
79
|
const [start, end] = copySelectionPluginKey.getState(state).decorationStartAndEnd;
|
|
@@ -14,6 +14,8 @@ const ideUX = pluginInjectionApi => {
|
|
|
14
14
|
const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
15
15
|
return new SafePlugin({
|
|
16
16
|
props: {
|
|
17
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
18
|
+
|
|
17
19
|
handleTextInput(view, from, to, text) {
|
|
18
20
|
var _pluginInjectionApi$c;
|
|
19
21
|
const {
|
|
@@ -61,6 +63,8 @@ const ideUX = pluginInjectionApi => {
|
|
|
61
63
|
}
|
|
62
64
|
return false;
|
|
63
65
|
},
|
|
66
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
67
|
+
|
|
64
68
|
handleKeyDown: keydownHandler({
|
|
65
69
|
Backspace: (state, dispatch) => {
|
|
66
70
|
if (isCursorInsideCodeBlock(state)) {
|
|
@@ -21,6 +21,8 @@ export const createPlugin = ({
|
|
|
21
21
|
api
|
|
22
22
|
}) => {
|
|
23
23
|
const handleDOMEvents = {
|
|
24
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
25
|
+
|
|
24
26
|
click: () => {
|
|
25
27
|
var _api$core, _api$interaction;
|
|
26
28
|
// Set hasHadInteraction to true on any click of code blocks, as clicks
|
|
@@ -70,6 +72,8 @@ export const createPlugin = ({
|
|
|
70
72
|
}
|
|
71
73
|
return new SafePlugin({
|
|
72
74
|
state: {
|
|
75
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
76
|
+
|
|
73
77
|
init(_, state) {
|
|
74
78
|
const node = findCodeBlock(state, state.selection);
|
|
75
79
|
const initialDecorations =
|
|
@@ -86,6 +90,8 @@ export const createPlugin = ({
|
|
|
86
90
|
decorations: DecorationSet.create(state.doc, initialDecorations)
|
|
87
91
|
};
|
|
88
92
|
},
|
|
93
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
94
|
+
|
|
89
95
|
apply(tr, pluginState, _oldState, newState) {
|
|
90
96
|
const meta = tr.getMeta(pluginKey);
|
|
91
97
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -100,6 +106,8 @@ export const createPlugin = ({
|
|
|
100
106
|
|
|
101
107
|
// Updates mapping position of all existing decorations to new positions
|
|
102
108
|
// specifically used for updating word wrap node decorators (does not cover drag & drop, validateWordWrappedDecorators does).
|
|
109
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
110
|
+
|
|
103
111
|
let updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
|
|
104
112
|
const codeBlockNodes = getAllChangedCodeBlocksInTransaction(tr);
|
|
105
113
|
if (codeBlockNodes) {
|
|
@@ -143,9 +151,13 @@ export const createPlugin = ({
|
|
|
143
151
|
},
|
|
144
152
|
key: pluginKey,
|
|
145
153
|
props: {
|
|
154
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
155
|
+
|
|
146
156
|
decorations(state) {
|
|
147
157
|
return pluginKey.getState(state).decorations || DecorationSet.empty;
|
|
148
158
|
},
|
|
159
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
160
|
+
|
|
149
161
|
nodeViews: {
|
|
150
162
|
codeBlock: (node, view, getPos) => {
|
|
151
163
|
const {
|
|
@@ -3,6 +3,8 @@ export function getCursor(selection) {
|
|
|
3
3
|
}
|
|
4
4
|
export function getAllCodeBlockNodesInDoc(state) {
|
|
5
5
|
const codeBlockNodes = [];
|
|
6
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
7
|
+
|
|
6
8
|
state.doc.descendants((node, pos) => {
|
|
7
9
|
if (node.type === state.schema.nodes.codeBlock) {
|
|
8
10
|
codeBlockNodes.push({
|
|
@@ -18,9 +20,16 @@ export function getAllCodeBlockNodesInDoc(state) {
|
|
|
18
20
|
export function getAllChangedCodeBlocksInTransaction(tr) {
|
|
19
21
|
const changedCodeBlocks = [];
|
|
20
22
|
const nodePositions = new Set();
|
|
23
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
24
|
+
|
|
21
25
|
tr.steps.forEach(step => {
|
|
22
26
|
const mapResult = step.getMap();
|
|
27
|
+
|
|
28
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
29
|
+
|
|
23
30
|
mapResult.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
31
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
32
|
+
|
|
24
33
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), (node, pos) => {
|
|
25
34
|
if (node.type.name === 'codeBlock') {
|
|
26
35
|
if (!nodePositions.has(pos)) {
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { codeBlock, codeBlockWithLocalId } from '@atlaskit/adf-schema';
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
-
import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK
|
|
7
|
+
import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
|
|
8
8
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
9
9
|
import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -30,7 +30,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
30
30
|
parent: {
|
|
31
31
|
type: 'block-menu-section',
|
|
32
32
|
key: FORMAT_MENU_ITEM.key,
|
|
33
|
-
rank:
|
|
33
|
+
rank: FORMAT_NESTED_MENU_RANK[FORMAT_CODE_BLOCK_MENU_ITEM.key]
|
|
34
34
|
},
|
|
35
35
|
component: createCodeBlockMenuItem(api)
|
|
36
36
|
}]);
|
|
@@ -27,12 +27,21 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
27
27
|
return new SafePlugin({
|
|
28
28
|
key: copySelectionPluginKey,
|
|
29
29
|
state: {
|
|
30
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
30
31
|
init: function init() {
|
|
31
32
|
return {
|
|
32
33
|
decorationStartAndEnd: undefined
|
|
33
34
|
};
|
|
34
35
|
},
|
|
35
|
-
|
|
36
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
37
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
38
|
+
apply: function apply(
|
|
39
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
40
|
+
transaction, currentCodeBlockCopySelectionPluginState,
|
|
41
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
42
|
+
_oldState,
|
|
43
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
44
|
+
newState) {
|
|
36
45
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
37
46
|
case 'show-selection':
|
|
38
47
|
{
|
|
@@ -61,6 +70,7 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
61
70
|
}
|
|
62
71
|
},
|
|
63
72
|
props: {
|
|
73
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
64
74
|
decorations: function decorations(state) {
|
|
65
75
|
if (copySelectionPluginKey.getState(state).decorationStartAndEnd) {
|
|
66
76
|
var _copySelectionPluginK = _slicedToArray(copySelectionPluginKey.getState(state).decorationStartAndEnd, 2),
|
|
@@ -14,6 +14,7 @@ var ideUX = function ideUX(pluginInjectionApi) {
|
|
|
14
14
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
15
15
|
return new SafePlugin({
|
|
16
16
|
props: {
|
|
17
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
17
18
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
18
19
|
var _pluginInjectionApi$c;
|
|
19
20
|
var state = view.state,
|
|
@@ -57,6 +58,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
|
|
|
57
58
|
}
|
|
58
59
|
return false;
|
|
59
60
|
},
|
|
61
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
62
|
+
|
|
60
63
|
handleKeyDown: keydownHandler({
|
|
61
64
|
Backspace: function Backspace(state, dispatch) {
|
|
62
65
|
if (isCursorInsideCodeBlock(state)) {
|
|
@@ -25,6 +25,8 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
25
25
|
allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition,
|
|
26
26
|
api = _ref.api;
|
|
27
27
|
var handleDOMEvents = {
|
|
28
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
29
|
+
|
|
28
30
|
click: function click() {
|
|
29
31
|
var _api$core, _api$interaction;
|
|
30
32
|
// Set hasHadInteraction to true on any click of code blocks, as clicks
|
|
@@ -76,6 +78,7 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
76
78
|
}
|
|
77
79
|
return new SafePlugin({
|
|
78
80
|
state: {
|
|
81
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
79
82
|
init: function init(_, state) {
|
|
80
83
|
var node = findCodeBlock(state, state.selection);
|
|
81
84
|
var initialDecorations =
|
|
@@ -92,6 +95,7 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
92
95
|
decorations: DecorationSet.create(state.doc, initialDecorations)
|
|
93
96
|
};
|
|
94
97
|
},
|
|
98
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
95
99
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
96
100
|
var meta = tr.getMeta(pluginKey);
|
|
97
101
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -105,6 +109,8 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
105
109
|
|
|
106
110
|
// Updates mapping position of all existing decorations to new positions
|
|
107
111
|
// specifically used for updating word wrap node decorators (does not cover drag & drop, validateWordWrappedDecorators does).
|
|
112
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
113
|
+
|
|
108
114
|
var updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
|
|
109
115
|
var codeBlockNodes = getAllChangedCodeBlocksInTransaction(tr);
|
|
110
116
|
if (codeBlockNodes) {
|
|
@@ -144,9 +150,12 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
144
150
|
},
|
|
145
151
|
key: pluginKey,
|
|
146
152
|
props: {
|
|
153
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
147
154
|
decorations: function decorations(state) {
|
|
148
155
|
return pluginKey.getState(state).decorations || DecorationSet.empty;
|
|
149
156
|
},
|
|
157
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
158
|
+
|
|
150
159
|
nodeViews: {
|
|
151
160
|
codeBlock: function codeBlock(node, view, getPos) {
|
|
152
161
|
var _getIntl = getIntl(),
|
|
@@ -3,6 +3,8 @@ export function getCursor(selection) {
|
|
|
3
3
|
}
|
|
4
4
|
export function getAllCodeBlockNodesInDoc(state) {
|
|
5
5
|
var codeBlockNodes = [];
|
|
6
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
7
|
+
|
|
6
8
|
state.doc.descendants(function (node, pos) {
|
|
7
9
|
if (node.type === state.schema.nodes.codeBlock) {
|
|
8
10
|
codeBlockNodes.push({
|
|
@@ -18,9 +20,16 @@ export function getAllCodeBlockNodesInDoc(state) {
|
|
|
18
20
|
export function getAllChangedCodeBlocksInTransaction(tr) {
|
|
19
21
|
var changedCodeBlocks = [];
|
|
20
22
|
var nodePositions = new Set();
|
|
23
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
24
|
+
|
|
21
25
|
tr.steps.forEach(function (step) {
|
|
22
26
|
var mapResult = step.getMap();
|
|
27
|
+
|
|
28
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
29
|
+
|
|
23
30
|
mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
31
|
+
// @ts-ignore - Workaround for help-center local consumption
|
|
32
|
+
|
|
24
33
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
|
|
25
34
|
if (node.type.name === 'codeBlock') {
|
|
26
35
|
if (!nodePositions.has(pos)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.13",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@atlaskit/icon": "^29.0.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^13.43.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^110.
|
|
50
|
+
"@atlaskit/editor-common": "^110.34.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
53
53
|
},
|
|
@@ -104,9 +104,6 @@
|
|
|
104
104
|
},
|
|
105
105
|
"platform_editor_adf_with_localid": {
|
|
106
106
|
"type": "boolean"
|
|
107
|
-
},
|
|
108
|
-
"platform_editor_block_menu_format_rank_revised": {
|
|
109
|
-
"type": "boolean"
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
109
|
}
|