@atlaskit/editor-plugin-code-block 3.5.16 → 3.6.1
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 +20 -0
- package/dist/cjs/codeBlockPlugin.js +8 -0
- package/dist/cjs/nodeviews/code-block.js +1 -6
- package/dist/cjs/pm-plugins/codeBlockCopySelectionPlugin.js +4 -4
- package/dist/cjs/pm-plugins/ide-ux.js +0 -2
- package/dist/cjs/pm-plugins/input-rule.js +2 -6
- package/dist/cjs/pm-plugins/main.js +0 -2
- package/dist/cjs/pm-plugins/transform-to-code-block.js +0 -2
- package/dist/cjs/pm-plugins/utils.js +0 -3
- package/dist/es2019/codeBlockPlugin.js +9 -1
- package/dist/es2019/nodeviews/code-block.js +1 -6
- package/dist/es2019/pm-plugins/codeBlockCopySelectionPlugin.js +4 -4
- package/dist/es2019/pm-plugins/ide-ux.js +0 -2
- package/dist/es2019/pm-plugins/input-rule.js +2 -6
- package/dist/es2019/pm-plugins/main.js +0 -2
- package/dist/es2019/pm-plugins/transform-to-code-block.js +0 -3
- package/dist/es2019/pm-plugins/utils.js +0 -3
- package/dist/esm/codeBlockPlugin.js +9 -1
- package/dist/esm/nodeviews/code-block.js +1 -6
- package/dist/esm/pm-plugins/codeBlockCopySelectionPlugin.js +4 -4
- package/dist/esm/pm-plugins/ide-ux.js +0 -2
- package/dist/esm/pm-plugins/input-rule.js +2 -6
- package/dist/esm/pm-plugins/main.js +0 -2
- package/dist/esm/pm-plugins/transform-to-code-block.js +0 -3
- package/dist/esm/pm-plugins/utils.js +0 -3
- package/dist/types/codeBlockPluginType.d.ts +4 -0
- package/dist/types/pm-plugins/codeBlockCopySelectionPlugin.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +4 -0
- package/dist/types-ts4.5/codeBlockPluginType.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/codeBlockCopySelectionPlugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#103918](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103918)
|
|
14
|
+
[`29844093c6ab4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/29844093c6ab4) -
|
|
15
|
+
Expose new shared state for code block plugin which indicates the current node that the copy text
|
|
16
|
+
button is hovered for. Display highlight decorations for the copy text button in the advanced code
|
|
17
|
+
block plugin.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 3.5.16
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -36,6 +36,14 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
36
36
|
node: _adfSchema.codeBlock
|
|
37
37
|
}];
|
|
38
38
|
},
|
|
39
|
+
getSharedState: function getSharedState(state) {
|
|
40
|
+
if (!state) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
copyButtonHoverNode: _codeBlockCopySelectionPlugin.copySelectionPluginKey.getState(state).codeBlockNode
|
|
45
|
+
};
|
|
46
|
+
},
|
|
39
47
|
pmPlugins: function pmPlugins() {
|
|
40
48
|
return [{
|
|
41
49
|
name: 'codeBlock',
|
|
@@ -42,8 +42,6 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
|
42
42
|
}]];
|
|
43
43
|
};
|
|
44
44
|
var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
45
|
-
// Ignored via go/ees005
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
47
45
|
function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
|
|
48
46
|
var _this = this,
|
|
49
47
|
_api$editorDisabled;
|
|
@@ -197,9 +195,6 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
197
195
|
}
|
|
198
196
|
}]);
|
|
199
197
|
}();
|
|
200
|
-
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
|
|
201
|
-
// Ignored via go/ees005
|
|
202
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
203
|
-
) {
|
|
198
|
+
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
|
|
204
199
|
return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
205
200
|
};
|
|
@@ -23,12 +23,14 @@ function getSelectionDecorationStartAndEnd(_ref) {
|
|
|
23
23
|
});
|
|
24
24
|
if (!codeBlockNode) {
|
|
25
25
|
return {
|
|
26
|
-
decorationStartAndEnd: undefined
|
|
26
|
+
decorationStartAndEnd: undefined,
|
|
27
|
+
codeBlockNode: undefined
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
var decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
30
31
|
return {
|
|
31
|
-
decorationStartAndEnd: decorationStartAndEnd
|
|
32
|
+
decorationStartAndEnd: decorationStartAndEnd,
|
|
33
|
+
codeBlockNode: codeBlockNode.node
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
function codeBlockCopySelectionPlugin() {
|
|
@@ -40,8 +42,6 @@ function codeBlockCopySelectionPlugin() {
|
|
|
40
42
|
decorationStartAndEnd: undefined
|
|
41
43
|
};
|
|
42
44
|
},
|
|
43
|
-
// Ignored via go/ees005
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
45
45
|
apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
46
46
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
47
47
|
case 'show-selection':
|
|
@@ -20,8 +20,6 @@ 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
|
-
// Ignored via go/ees005
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
25
23
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
26
24
|
var _pluginInjectionApi$c;
|
|
27
25
|
var state = view.state,
|
|
@@ -38,8 +38,7 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
38
38
|
return match.length > 0 && match[0].length === 3;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
41
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
43
42
|
var threeTildeRule = (0, _utils.createRule)(/(?!\s)(`{3,})$/, function (state, match, start, end) {
|
|
44
43
|
if (!validMatchLength(match)) {
|
|
45
44
|
return null;
|
|
@@ -63,10 +62,7 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
63
62
|
var leftNodeReplacementThreeTildeRule = (0, _utils.createRule)(
|
|
64
63
|
// Ignored via go/ees005
|
|
65
64
|
// eslint-disable-next-line require-unicode-regexp
|
|
66
|
-
new RegExp("((".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")),
|
|
67
|
-
// Ignored via go/ees005
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
69
|
-
function (state, match, start, end) {
|
|
65
|
+
new RegExp("((".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")), function (state, match, start, end) {
|
|
70
66
|
if (!validMatchLength(match)) {
|
|
71
67
|
return null;
|
|
72
68
|
}
|
|
@@ -86,8 +86,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
86
86
|
decorations: _view.DecorationSet.create(state.doc, initialDecorations)
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
|
-
// Ignored via go/ees005
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
91
89
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
92
90
|
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
93
91
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === _actions.ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -10,8 +10,6 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
10
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
-
// Ignored via go/ees005
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
15
13
|
function transformToCodeBlockAction(state, start,
|
|
16
14
|
// Ignored via go/ees005
|
|
17
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -30,9 +30,6 @@ function getAllChangedCodeBlocksInTransaction(tr) {
|
|
|
30
30
|
var nodePositions = new Set();
|
|
31
31
|
tr.steps.forEach(function (step) {
|
|
32
32
|
var mapResult = step.getMap();
|
|
33
|
-
|
|
34
|
-
// Ignored via go/ees005
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
36
33
|
mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
37
34
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
|
|
38
35
|
if (node.type.name === 'codeBlock') {
|
|
@@ -6,7 +6,7 @@ import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
|
|
8
8
|
import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
|
|
9
|
-
import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
9
|
+
import { codeBlockCopySelectionPlugin, copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
10
10
|
import ideUX from './pm-plugins/ide-ux';
|
|
11
11
|
import { createCodeBlockInputRule } from './pm-plugins/input-rule';
|
|
12
12
|
import keymap from './pm-plugins/keymaps';
|
|
@@ -27,6 +27,14 @@ const codeBlockPlugin = ({
|
|
|
27
27
|
node: codeBlock
|
|
28
28
|
}];
|
|
29
29
|
},
|
|
30
|
+
getSharedState(state) {
|
|
31
|
+
if (!state) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
copyButtonHoverNode: copySelectionPluginKey.getState(state).codeBlockNode
|
|
36
|
+
};
|
|
37
|
+
},
|
|
30
38
|
pmPlugins() {
|
|
31
39
|
return [{
|
|
32
40
|
name: 'codeBlock',
|
|
@@ -32,8 +32,6 @@ const toDOM = (node, contentEditable, formattedAriaLabel) => ['div', {
|
|
|
32
32
|
contenteditable: 'false'
|
|
33
33
|
}]];
|
|
34
34
|
export class CodeBlockView {
|
|
35
|
-
// Ignored via go/ees005
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
37
35
|
constructor(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
|
|
38
36
|
var _api$editorDisabled, _api$editorDisabled$s;
|
|
39
37
|
_defineProperty(this, "formattedAriaLabel", '');
|
|
@@ -170,7 +168,4 @@ export class CodeBlockView {
|
|
|
170
168
|
this.cleanupEditorDisabledListener = undefined;
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
|
-
export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api
|
|
174
|
-
// Ignored via go/ees005
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
176
|
-
) => new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
171
|
+
export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api) => new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
@@ -13,12 +13,14 @@ function getSelectionDecorationStartAndEnd({
|
|
|
13
13
|
});
|
|
14
14
|
if (!codeBlockNode) {
|
|
15
15
|
return {
|
|
16
|
-
decorationStartAndEnd: undefined
|
|
16
|
+
decorationStartAndEnd: undefined,
|
|
17
|
+
codeBlockNode: undefined
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
const decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
20
21
|
return {
|
|
21
|
-
decorationStartAndEnd
|
|
22
|
+
decorationStartAndEnd,
|
|
23
|
+
codeBlockNode: codeBlockNode.node
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
export function codeBlockCopySelectionPlugin() {
|
|
@@ -30,8 +32,6 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
30
32
|
decorationStartAndEnd: undefined
|
|
31
33
|
};
|
|
32
34
|
},
|
|
33
|
-
// Ignored via go/ees005
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
35
35
|
apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
36
36
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
37
37
|
case 'show-selection':
|
|
@@ -14,8 +14,6 @@ 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
|
-
// Ignored via go/ees005
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
17
|
handleTextInput(view, from, to, text) {
|
|
20
18
|
var _pluginInjectionApi$c;
|
|
21
19
|
const {
|
|
@@ -30,8 +30,7 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
30
30
|
}, editorAnalyticsAPI);
|
|
31
31
|
const validMatchLength = match => match.length > 0 && match[0].length === 3;
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
33
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
35
34
|
const threeTildeRule = createRule(/(?!\s)(`{3,})$/, (state, match, start, end) => {
|
|
36
35
|
if (!validMatchLength(match)) {
|
|
37
36
|
return null;
|
|
@@ -55,10 +54,7 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
55
54
|
const leftNodeReplacementThreeTildeRule = createRule(
|
|
56
55
|
// Ignored via go/ees005
|
|
57
56
|
// eslint-disable-next-line require-unicode-regexp
|
|
58
|
-
new RegExp(`((${leafNodeReplacementCharacter}\`{3,})|^\\s(\`{3,}))(\\S*)$`),
|
|
59
|
-
// Ignored via go/ees005
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
61
|
-
(state, match, start, end) => {
|
|
57
|
+
new RegExp(`((${leafNodeReplacementCharacter}\`{3,})|^\\s(\`{3,}))(\\S*)$`), (state, match, start, end) => {
|
|
62
58
|
if (!validMatchLength(match)) {
|
|
63
59
|
return null;
|
|
64
60
|
}
|
|
@@ -75,8 +75,6 @@ export const createPlugin = ({
|
|
|
75
75
|
decorations: DecorationSet.create(state.doc, initialDecorations)
|
|
76
76
|
};
|
|
77
77
|
},
|
|
78
|
-
// Ignored via go/ees005
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
80
78
|
apply(tr, pluginState, _oldState, newState) {
|
|
81
79
|
const meta = tr.getMeta(pluginKey);
|
|
82
80
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -3,9 +3,6 @@ import { mapSlice, timestampToString } from '@atlaskit/editor-common/utils';
|
|
|
3
3
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
|
|
7
|
-
// Ignored via go/ees005
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
9
6
|
export function transformToCodeBlockAction(state, start,
|
|
10
7
|
// Ignored via go/ees005
|
|
11
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -22,9 +22,6 @@ export function getAllChangedCodeBlocksInTransaction(tr) {
|
|
|
22
22
|
const nodePositions = new Set();
|
|
23
23
|
tr.steps.forEach(step => {
|
|
24
24
|
const mapResult = step.getMap();
|
|
25
|
-
|
|
26
|
-
// Ignored via go/ees005
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
28
25
|
mapResult.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
29
26
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), (node, pos) => {
|
|
30
27
|
if (node.type.name === 'codeBlock') {
|
|
@@ -9,7 +9,7 @@ import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
|
|
11
11
|
import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
|
|
12
|
-
import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
12
|
+
import { codeBlockCopySelectionPlugin, copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
13
13
|
import ideUX from './pm-plugins/ide-ux';
|
|
14
14
|
import { createCodeBlockInputRule } from './pm-plugins/input-rule';
|
|
15
15
|
import keymap from './pm-plugins/keymaps';
|
|
@@ -29,6 +29,14 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
29
29
|
node: codeBlock
|
|
30
30
|
}];
|
|
31
31
|
},
|
|
32
|
+
getSharedState: function getSharedState(state) {
|
|
33
|
+
if (!state) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
copyButtonHoverNode: copySelectionPluginKey.getState(state).codeBlockNode
|
|
38
|
+
};
|
|
39
|
+
},
|
|
32
40
|
pmPlugins: function pmPlugins() {
|
|
33
41
|
return [{
|
|
34
42
|
name: 'codeBlock',
|
|
@@ -36,8 +36,6 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
|
36
36
|
}]];
|
|
37
37
|
};
|
|
38
38
|
export var CodeBlockView = /*#__PURE__*/function () {
|
|
39
|
-
// Ignored via go/ees005
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
41
39
|
function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
|
|
42
40
|
var _this = this,
|
|
43
41
|
_api$editorDisabled;
|
|
@@ -191,9 +189,6 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
191
189
|
}
|
|
192
190
|
}]);
|
|
193
191
|
}();
|
|
194
|
-
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
|
|
195
|
-
// Ignored via go/ees005
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
197
|
-
) {
|
|
192
|
+
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
|
|
198
193
|
return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
199
194
|
};
|
|
@@ -13,12 +13,14 @@ function getSelectionDecorationStartAndEnd(_ref) {
|
|
|
13
13
|
});
|
|
14
14
|
if (!codeBlockNode) {
|
|
15
15
|
return {
|
|
16
|
-
decorationStartAndEnd: undefined
|
|
16
|
+
decorationStartAndEnd: undefined,
|
|
17
|
+
codeBlockNode: undefined
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
var decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
20
21
|
return {
|
|
21
|
-
decorationStartAndEnd: decorationStartAndEnd
|
|
22
|
+
decorationStartAndEnd: decorationStartAndEnd,
|
|
23
|
+
codeBlockNode: codeBlockNode.node
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
export function codeBlockCopySelectionPlugin() {
|
|
@@ -30,8 +32,6 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
30
32
|
decorationStartAndEnd: undefined
|
|
31
33
|
};
|
|
32
34
|
},
|
|
33
|
-
// Ignored via go/ees005
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
35
35
|
apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
36
36
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
37
37
|
case 'show-selection':
|
|
@@ -14,8 +14,6 @@ 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
|
-
// Ignored via go/ees005
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
17
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
20
18
|
var _pluginInjectionApi$c;
|
|
21
19
|
var state = view.state,
|
|
@@ -32,8 +32,7 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
32
32
|
return match.length > 0 && match[0].length === 3;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
35
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
37
36
|
var threeTildeRule = createRule(/(?!\s)(`{3,})$/, function (state, match, start, end) {
|
|
38
37
|
if (!validMatchLength(match)) {
|
|
39
38
|
return null;
|
|
@@ -57,10 +56,7 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
57
56
|
var leftNodeReplacementThreeTildeRule = createRule(
|
|
58
57
|
// Ignored via go/ees005
|
|
59
58
|
// eslint-disable-next-line require-unicode-regexp
|
|
60
|
-
new RegExp("((".concat(leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")),
|
|
61
|
-
// Ignored via go/ees005
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
63
|
-
function (state, match, start, end) {
|
|
59
|
+
new RegExp("((".concat(leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")), function (state, match, start, end) {
|
|
64
60
|
if (!validMatchLength(match)) {
|
|
65
61
|
return null;
|
|
66
62
|
}
|
|
@@ -81,8 +81,6 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
81
81
|
decorations: DecorationSet.create(state.doc, initialDecorations)
|
|
82
82
|
};
|
|
83
83
|
},
|
|
84
|
-
// Ignored via go/ees005
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
86
84
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
87
85
|
var meta = tr.getMeta(pluginKey);
|
|
88
86
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -3,9 +3,6 @@ import { mapSlice, timestampToString } from '@atlaskit/editor-common/utils';
|
|
|
3
3
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
|
|
7
|
-
// Ignored via go/ees005
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
9
6
|
export function transformToCodeBlockAction(state, start,
|
|
10
7
|
// Ignored via go/ees005
|
|
11
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -22,9 +22,6 @@ export function getAllChangedCodeBlocksInTransaction(tr) {
|
|
|
22
22
|
var nodePositions = new Set();
|
|
23
23
|
tr.steps.forEach(function (step) {
|
|
24
24
|
var mapResult = step.getMap();
|
|
25
|
-
|
|
26
|
-
// Ignored via go/ees005
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
28
25
|
mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
29
26
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
|
|
30
27
|
if (node.type.name === 'codeBlock') {
|
|
@@ -5,6 +5,7 @@ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
|
5
5
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import type { CodeBlockOptions } from './types';
|
|
9
10
|
type CodeBlockDependencies = [
|
|
10
11
|
DecorationsPlugin,
|
|
@@ -16,6 +17,9 @@ type CodeBlockDependencies = [
|
|
|
16
17
|
export type CodeBlockPlugin = NextEditorPlugin<'codeBlock', {
|
|
17
18
|
pluginConfiguration: CodeBlockOptions | undefined;
|
|
18
19
|
dependencies: CodeBlockDependencies;
|
|
20
|
+
sharedState: {
|
|
21
|
+
copyButtonHoverNode: PMNode;
|
|
22
|
+
} | undefined;
|
|
19
23
|
actions: {
|
|
20
24
|
insertCodeBlock: (inputMethod: INPUT_METHOD) => Command;
|
|
21
25
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
export declare const copySelectionPluginKey: PluginKey<any>;
|
|
5
6
|
type CodeBlockCopySelectionPluginState = {
|
|
6
7
|
decorationStartAndEnd?: [start: number, end: number];
|
|
8
|
+
codeBlockNode?: PMNode;
|
|
7
9
|
};
|
|
8
10
|
export declare function codeBlockCopySelectionPlugin(): SafePlugin<CodeBlockCopySelectionPluginState>;
|
|
9
11
|
export declare function provideVisualFeedbackForCopyButton(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { CodeBlockPlugin } from '../index';
|
|
6
7
|
import { type CodeBlockState } from './main-state';
|
|
@@ -36,6 +37,9 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
36
37
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
37
38
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
38
39
|
}, import("@atlaskit/editor-common/types").FeatureFlags>>];
|
|
40
|
+
sharedState: {
|
|
41
|
+
copyButtonHoverNode: PMNode;
|
|
42
|
+
} | undefined;
|
|
39
43
|
actions: {
|
|
40
44
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
41
45
|
};
|
|
@@ -5,6 +5,7 @@ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
|
5
5
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import type { CodeBlockOptions } from './types';
|
|
9
10
|
type CodeBlockDependencies = [
|
|
10
11
|
DecorationsPlugin,
|
|
@@ -16,6 +17,9 @@ type CodeBlockDependencies = [
|
|
|
16
17
|
export type CodeBlockPlugin = NextEditorPlugin<'codeBlock', {
|
|
17
18
|
pluginConfiguration: CodeBlockOptions | undefined;
|
|
18
19
|
dependencies: CodeBlockDependencies;
|
|
20
|
+
sharedState: {
|
|
21
|
+
copyButtonHoverNode: PMNode;
|
|
22
|
+
} | undefined;
|
|
19
23
|
actions: {
|
|
20
24
|
insertCodeBlock: (inputMethod: INPUT_METHOD) => Command;
|
|
21
25
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
export declare const copySelectionPluginKey: PluginKey<any>;
|
|
@@ -7,6 +8,7 @@ type CodeBlockCopySelectionPluginState = {
|
|
|
7
8
|
start: number,
|
|
8
9
|
end: number
|
|
9
10
|
];
|
|
11
|
+
codeBlockNode?: PMNode;
|
|
10
12
|
};
|
|
11
13
|
export declare function codeBlockCopySelectionPlugin(): SafePlugin<CodeBlockCopySelectionPluginState>;
|
|
12
14
|
export declare function provideVisualFeedbackForCopyButton(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { CodeBlockPlugin } from '../index';
|
|
6
7
|
import { type CodeBlockState } from './main-state';
|
|
@@ -44,6 +45,9 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
44
45
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
45
46
|
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
46
47
|
];
|
|
48
|
+
sharedState: {
|
|
49
|
+
copyButtonHoverNode: PMNode;
|
|
50
|
+
} | undefined;
|
|
47
51
|
actions: {
|
|
48
52
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
49
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/code": "^15.
|
|
36
|
-
"@atlaskit/editor-common": "^99.
|
|
37
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
35
|
+
"@atlaskit/code": "^15.7.0",
|
|
36
|
+
"@atlaskit/editor-common": "^99.7.0",
|
|
37
|
+
"@atlaskit/editor-plugin-analytics": "^1.11.0",
|
|
38
38
|
"@atlaskit/editor-plugin-composition": "^1.2.0",
|
|
39
|
-
"@atlaskit/editor-plugin-decorations": "^1.
|
|
40
|
-
"@atlaskit/editor-plugin-editor-disabled": "^1.
|
|
39
|
+
"@atlaskit/editor-plugin-decorations": "^1.4.0",
|
|
40
|
+
"@atlaskit/editor-plugin-editor-disabled": "^1.4.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
42
|
-
"@atlaskit/icon": "^23.
|
|
43
|
-
"@atlaskit/platform-feature-flags": "^0.
|
|
42
|
+
"@atlaskit/icon": "^23.6.0",
|
|
43
|
+
"@atlaskit/platform-feature-flags": "^1.0.0",
|
|
44
44
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0"
|
|
46
46
|
},
|