@atlaskit/editor-plugin-code-block 3.5.12 → 3.5.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 +6 -0
- package/dist/cjs/nodeviews/code-block.js +23 -1
- package/dist/cjs/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
- package/dist/cjs/pm-plugins/ide-ux/bracket-handling.js +4 -0
- package/dist/cjs/pm-plugins/ide-ux/line-handling.js +13 -0
- package/dist/cjs/pm-plugins/ide-ux/quote-handling.js +8 -0
- package/dist/cjs/pm-plugins/ide-ux.js +4 -0
- package/dist/cjs/pm-plugins/input-rule.js +16 -1
- package/dist/cjs/pm-plugins/main.js +4 -0
- package/dist/cjs/pm-plugins/toolbar.js +4 -0
- package/dist/cjs/pm-plugins/transform-to-code-block.js +6 -1
- package/dist/cjs/pm-plugins/utils.js +3 -0
- package/dist/es2019/editor-commands/index.js +3 -3
- package/dist/es2019/nodeviews/code-block.js +24 -1
- package/dist/es2019/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
- package/dist/es2019/pm-plugins/ide-ux/bracket-handling.js +4 -0
- package/dist/es2019/pm-plugins/ide-ux/line-handling.js +13 -0
- package/dist/es2019/pm-plugins/ide-ux/quote-handling.js +8 -0
- package/dist/es2019/pm-plugins/ide-ux.js +6 -2
- package/dist/es2019/pm-plugins/input-rule.js +16 -1
- package/dist/es2019/pm-plugins/main.js +4 -0
- package/dist/es2019/pm-plugins/toolbar.js +4 -0
- package/dist/es2019/pm-plugins/transform-to-code-block.js +7 -1
- package/dist/es2019/pm-plugins/utils.js +3 -0
- package/dist/esm/nodeviews/code-block.js +24 -1
- package/dist/esm/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
- package/dist/esm/pm-plugins/ide-ux/bracket-handling.js +4 -0
- package/dist/esm/pm-plugins/ide-ux/line-handling.js +13 -0
- package/dist/esm/pm-plugins/ide-ux/quote-handling.js +8 -0
- package/dist/esm/pm-plugins/ide-ux.js +4 -0
- package/dist/esm/pm-plugins/input-rule.js +16 -1
- package/dist/esm/pm-plugins/main.js +4 -0
- package/dist/esm/pm-plugins/toolbar.js +4 -0
- package/dist/esm/pm-plugins/transform-to-code-block.js +7 -1
- package/dist/esm/pm-plugins/utils.js +3 -0
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
15
15
|
var _editorCommands = require("../editor-commands");
|
|
16
16
|
var _mainState = require("../pm-plugins/main-state");
|
|
17
17
|
var _classNames = require("../ui/class-names");
|
|
18
|
+
// Ignored via go/ees005
|
|
19
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
18
20
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
19
21
|
var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
20
22
|
return ['div', {
|
|
@@ -41,6 +43,8 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
|
41
43
|
}]];
|
|
42
44
|
};
|
|
43
45
|
var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
46
|
+
// Ignored via go/ees005
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
44
48
|
function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
|
|
45
49
|
var _this = this,
|
|
46
50
|
_api$editorDisabled;
|
|
@@ -54,6 +58,8 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
54
58
|
_this.node.forEach(function (node) {
|
|
55
59
|
var text = node.text;
|
|
56
60
|
if (text) {
|
|
61
|
+
// Ignored via go/ees005
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
57
63
|
totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
|
|
58
64
|
}
|
|
59
65
|
});
|
|
@@ -67,8 +73,14 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
67
73
|
this.getPos = getPos;
|
|
68
74
|
this.view = view;
|
|
69
75
|
this.node = _node;
|
|
76
|
+
// Ignored via go/ees005
|
|
77
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
70
78
|
this.dom = dom;
|
|
79
|
+
// Ignored via go/ees005
|
|
80
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
71
81
|
this.contentDOM = contentDOM;
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
72
84
|
this.lineNumberGutter = this.dom.querySelector(".".concat(_classNames.codeBlockClassNames.gutter));
|
|
73
85
|
this.api = api;
|
|
74
86
|
this.maintainDynamicGutterSize();
|
|
@@ -102,6 +114,8 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
102
114
|
var contentWrapper = this.dom.childNodes[1];
|
|
103
115
|
var contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
|
|
104
116
|
if ((contentView === null || contentView === void 0 || (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
|
|
117
|
+
// Ignored via go/ees005
|
|
118
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
105
119
|
var codeElement = contentView.firstChild;
|
|
106
120
|
codeElement.innerHTML = savedInnerHTML;
|
|
107
121
|
|
|
@@ -128,10 +142,15 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
128
142
|
if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
|
|
129
143
|
var savedInnerHTML = '';
|
|
130
144
|
while (contentView.childNodes.length > 1) {
|
|
145
|
+
// Ignored via go/ees005
|
|
146
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
131
147
|
var lastChild = contentView.lastChild;
|
|
132
148
|
savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
|
|
133
149
|
contentView.removeChild(lastChild);
|
|
134
150
|
}
|
|
151
|
+
|
|
152
|
+
// Ignored via go/ees005
|
|
153
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
135
154
|
var firstChild = contentView.firstChild;
|
|
136
155
|
savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
|
|
137
156
|
var newCursorPosition = firstChild.innerHTML.length + 1;
|
|
@@ -182,6 +201,9 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
|
|
|
182
201
|
}
|
|
183
202
|
}]);
|
|
184
203
|
}();
|
|
185
|
-
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
|
|
204
|
+
var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
|
|
205
|
+
// Ignored via go/ees005
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
207
|
+
) {
|
|
186
208
|
return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
187
209
|
};
|
|
@@ -40,6 +40,8 @@ function codeBlockCopySelectionPlugin() {
|
|
|
40
40
|
decorationStartAndEnd: undefined
|
|
41
41
|
};
|
|
42
42
|
},
|
|
43
|
+
// Ignored via go/ees005
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
43
45
|
apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
44
46
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
45
47
|
case 'show-selection':
|
|
@@ -11,11 +11,15 @@ var BRACKET_MAP = exports.BRACKET_MAP = {
|
|
|
11
11
|
};
|
|
12
12
|
var shouldAutoCloseBracket = exports.shouldAutoCloseBracket = function shouldAutoCloseBracket(before, after) {
|
|
13
13
|
// when directly before a closing bracket
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
14
16
|
if (/^[}\])]/.test(after)) {
|
|
15
17
|
return true;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
// exclusion: when directly before a non-whitespace character
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
19
23
|
if (/^[^\s]/.test(after)) {
|
|
20
24
|
return false;
|
|
21
25
|
}
|
|
@@ -16,8 +16,12 @@ var isCursorInsideCodeBlock = exports.isCursorInsideCodeBlock = function isCurso
|
|
|
16
16
|
var getStartOfCurrentLine = exports.getStartOfCurrentLine = function getStartOfCurrentLine(state) {
|
|
17
17
|
var $from = state.selection.$from;
|
|
18
18
|
if ($from.nodeBefore && $from.nodeBefore.isText) {
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
21
|
var prevNewLineIndex = $from.nodeBefore.text.lastIndexOf('\n');
|
|
20
22
|
return {
|
|
23
|
+
// Ignored via go/ees005
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
21
25
|
text: $from.nodeBefore.text.substring(prevNewLineIndex + 1),
|
|
22
26
|
pos: $from.start() + prevNewLineIndex + 1
|
|
23
27
|
};
|
|
@@ -30,8 +34,12 @@ var getStartOfCurrentLine = exports.getStartOfCurrentLine = function getStartOfC
|
|
|
30
34
|
var getEndOfCurrentLine = exports.getEndOfCurrentLine = function getEndOfCurrentLine(state) {
|
|
31
35
|
var $to = state.selection.$to;
|
|
32
36
|
if ($to.nodeAfter && $to.nodeAfter.isText) {
|
|
37
|
+
// Ignored via go/ees005
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
39
|
var nextNewLineIndex = $to.nodeAfter.text.indexOf('\n');
|
|
34
40
|
return {
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
35
43
|
text: $to.nodeAfter.text.substring(0, nextNewLineIndex >= 0 ? nextNewLineIndex : undefined),
|
|
36
44
|
pos: nextNewLineIndex >= 0 ? $to.pos + nextNewLineIndex : $to.end()
|
|
37
45
|
};
|
|
@@ -60,11 +68,16 @@ var forEachLine = exports.forEachLine = function forEachLine(text, callback) {
|
|
|
60
68
|
offset += line.length + 1;
|
|
61
69
|
});
|
|
62
70
|
};
|
|
71
|
+
|
|
72
|
+
// Ignored via go/ees005
|
|
73
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
63
74
|
var SPACE = {
|
|
64
75
|
token: ' ',
|
|
65
76
|
size: 2,
|
|
66
77
|
regex: /[^ ]/
|
|
67
78
|
};
|
|
79
|
+
// Ignored via go/ees005
|
|
80
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
68
81
|
var TAB = {
|
|
69
82
|
token: '\t',
|
|
70
83
|
size: 1,
|
|
@@ -11,16 +11,24 @@ var QUOTE_MAP = exports.QUOTE_MAP = {
|
|
|
11
11
|
};
|
|
12
12
|
var shouldAutoCloseQuote = exports.shouldAutoCloseQuote = function shouldAutoCloseQuote(before, after) {
|
|
13
13
|
// when directly before a closing bracket
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
14
16
|
if (/^[}\])]/.test(after)) {
|
|
15
17
|
return true;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
// exclusion: when directly before a non-whitespace character
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
19
23
|
if (/^[^\s]/.test(after)) {
|
|
20
24
|
return false;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
// exclusion: when directly after a letter or quote
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
30
|
+
// Ignored via go/ees005
|
|
31
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
24
32
|
if (/[A-Za-z0-9]$/.test(before) || /[\'\"\`]$/.test(before)) {
|
|
25
33
|
return false;
|
|
26
34
|
}
|
|
@@ -20,6 +20,8 @@ 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
|
|
23
25
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
24
26
|
var _pluginInjectionApi$c;
|
|
25
27
|
var state = view.state,
|
|
@@ -66,6 +68,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
|
|
|
66
68
|
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
67
69
|
Backspace: function Backspace(state, dispatch) {
|
|
68
70
|
if ((0, _lineHandling.isCursorInsideCodeBlock)(state)) {
|
|
71
|
+
// Ignored via go/ees005
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
73
|
var $cursor = (0, _utils3.getCursor)(state.selection);
|
|
70
74
|
var beforeText = (0, _lineHandling.getStartOfCurrentLine)(state).text;
|
|
71
75
|
var afterText = (0, _lineHandling.getEndOfCurrentLine)(state).text;
|
|
@@ -37,10 +37,16 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
37
37
|
var validMatchLength = function validMatchLength(match) {
|
|
38
38
|
return match.length > 0 && match[0].length === 3;
|
|
39
39
|
};
|
|
40
|
+
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
40
43
|
var threeTildeRule = (0, _utils.createRule)(/(?!\s)(`{3,})$/, function (state, match, start, end) {
|
|
41
44
|
if (!validMatchLength(match)) {
|
|
42
45
|
return null;
|
|
43
46
|
}
|
|
47
|
+
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
50
|
var attributes = {};
|
|
45
51
|
if (match[4]) {
|
|
46
52
|
attributes.language = match[4];
|
|
@@ -54,10 +60,19 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
54
60
|
(0, _utils2.safeInsert)(codeBlock)(tr);
|
|
55
61
|
return tr;
|
|
56
62
|
});
|
|
57
|
-
var leftNodeReplacementThreeTildeRule = (0, _utils.createRule)(
|
|
63
|
+
var leftNodeReplacementThreeTildeRule = (0, _utils.createRule)(
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// 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) {
|
|
58
70
|
if (!validMatchLength(match)) {
|
|
59
71
|
return null;
|
|
60
72
|
}
|
|
73
|
+
|
|
74
|
+
// Ignored via go/ees005
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
76
|
var attributes = {};
|
|
62
77
|
if (match[4]) {
|
|
63
78
|
attributes.language = match[4];
|
|
@@ -46,6 +46,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
46
46
|
event.preventDefault();
|
|
47
47
|
return true;
|
|
48
48
|
} else if (_browser.browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && (0, _transforms.findCodeBlock)(view.state, view.state.selection)) {
|
|
49
|
+
// Ignored via go/ees005
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
51
|
var resultingText = event.target.outerText + '\n';
|
|
50
52
|
if (resultingText.endsWith(eventText)) {
|
|
51
53
|
// End of paragraph
|
|
@@ -84,6 +86,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
84
86
|
decorations: _view.DecorationSet.create(state.doc, initialDecorations)
|
|
85
87
|
};
|
|
86
88
|
},
|
|
89
|
+
// Ignored via go/ees005
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
87
91
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
88
92
|
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
89
93
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === _actions.ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -118,6 +118,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
118
118
|
};
|
|
119
119
|
return {
|
|
120
120
|
title: 'CodeBlock floating controls',
|
|
121
|
+
// Ignored via go/ees005
|
|
122
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
121
123
|
getDomRef: function getDomRef(view) {
|
|
122
124
|
return (0, _utils.findDomRefAtPos)(pos, view.domAtPos.bind(view));
|
|
123
125
|
},
|
|
@@ -132,6 +134,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
132
134
|
* Filters language list based on both name and alias properties.
|
|
133
135
|
*/
|
|
134
136
|
var languageListFilter = exports.languageListFilter = function languageListFilter(option, rawInput) {
|
|
137
|
+
// Ignored via go/ees005
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
139
|
var _ref3 = option,
|
|
136
140
|
data = _ref3.data;
|
|
137
141
|
var searchString = rawInput.toLowerCase();
|
|
@@ -10,7 +10,12 @@ 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
|
-
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
15
|
+
function transformToCodeBlockAction(state, start,
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
attrs, isNestingInQuoteSupported) {
|
|
14
19
|
var startOfCodeBlockText = state.selection.$from;
|
|
15
20
|
var endPosition = state.selection.empty && !(state.selection instanceof _selection.GapCursorSelection) ? startOfCodeBlockText.end() : state.selection.$to.pos;
|
|
16
21
|
var startLinePosition = startOfCodeBlockText.start();
|
|
@@ -30,6 +30,9 @@ 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
|
|
33
36
|
mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
34
37
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
|
|
35
38
|
if (node.type.name === 'codeBlock') {
|
|
@@ -66,7 +66,7 @@ export const copyContentToClipboard = (state, dispatch) => {
|
|
|
66
66
|
const textContent = codeBlock && codeBlock.node.textContent;
|
|
67
67
|
if (textContent) {
|
|
68
68
|
copyToClipboard(textContent);
|
|
69
|
-
|
|
69
|
+
const copyToClipboardTr = tr;
|
|
70
70
|
copyToClipboardTr.setMeta(pluginKey, {
|
|
71
71
|
type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
|
|
72
72
|
data: true
|
|
@@ -83,7 +83,7 @@ export const resetCopiedState = (state, dispatch) => {
|
|
|
83
83
|
tr
|
|
84
84
|
} = state;
|
|
85
85
|
const codeBlockState = pluginKey.getState(state);
|
|
86
|
-
|
|
86
|
+
const resetCopiedStateTr = tr;
|
|
87
87
|
if (codeBlockState && codeBlockState.contentCopied) {
|
|
88
88
|
resetCopiedStateTr.setMeta(pluginKey, {
|
|
89
89
|
type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
|
|
@@ -188,7 +188,7 @@ export function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI, isNestin
|
|
|
188
188
|
},
|
|
189
189
|
eventType: EVENT_TYPE.TRACK
|
|
190
190
|
})(function (state, dispatch) {
|
|
191
|
-
|
|
191
|
+
const tr = createInsertCodeBlockTransaction({
|
|
192
192
|
state,
|
|
193
193
|
isNestingInQuoteSupported
|
|
194
194
|
});
|
|
@@ -6,6 +6,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
6
6
|
import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
|
|
7
7
|
import { getPluginState } from '../pm-plugins/main-state';
|
|
8
8
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
9
|
+
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
9
12
|
const MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
10
13
|
const toDOM = (node, contentEditable, formattedAriaLabel) => ['div', {
|
|
11
14
|
class: codeBlockClassNames.container
|
|
@@ -30,6 +33,8 @@ const toDOM = (node, contentEditable, formattedAriaLabel) => ['div', {
|
|
|
30
33
|
contenteditable: 'false'
|
|
31
34
|
}]];
|
|
32
35
|
export class CodeBlockView {
|
|
36
|
+
// Ignored via go/ees005
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
33
38
|
constructor(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
|
|
34
39
|
var _api$editorDisabled, _api$editorDisabled$s;
|
|
35
40
|
_defineProperty(this, "formattedAriaLabel", '');
|
|
@@ -41,6 +46,8 @@ export class CodeBlockView {
|
|
|
41
46
|
this.node.forEach(node => {
|
|
42
47
|
const text = node.text;
|
|
43
48
|
if (text) {
|
|
49
|
+
// Ignored via go/ees005
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
51
|
totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
|
|
45
52
|
}
|
|
46
53
|
});
|
|
@@ -55,8 +62,14 @@ export class CodeBlockView {
|
|
|
55
62
|
this.getPos = getPos;
|
|
56
63
|
this.view = view;
|
|
57
64
|
this.node = _node;
|
|
65
|
+
// Ignored via go/ees005
|
|
66
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
58
67
|
this.dom = dom;
|
|
68
|
+
// Ignored via go/ees005
|
|
69
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
59
70
|
this.contentDOM = contentDOM;
|
|
71
|
+
// Ignored via go/ees005
|
|
72
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
60
73
|
this.lineNumberGutter = this.dom.querySelector(`.${codeBlockClassNames.gutter}`);
|
|
61
74
|
this.api = api;
|
|
62
75
|
this.maintainDynamicGutterSize();
|
|
@@ -85,6 +98,8 @@ export class CodeBlockView {
|
|
|
85
98
|
const contentWrapper = this.dom.childNodes[1];
|
|
86
99
|
const contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
|
|
87
100
|
if ((contentView === null || contentView === void 0 ? void 0 : (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
|
|
101
|
+
// Ignored via go/ees005
|
|
102
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
88
103
|
const codeElement = contentView.firstChild;
|
|
89
104
|
codeElement.innerHTML = savedInnerHTML;
|
|
90
105
|
|
|
@@ -107,10 +122,15 @@ export class CodeBlockView {
|
|
|
107
122
|
if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
|
|
108
123
|
let savedInnerHTML = '';
|
|
109
124
|
while (contentView.childNodes.length > 1) {
|
|
125
|
+
// Ignored via go/ees005
|
|
126
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
110
127
|
const lastChild = contentView.lastChild;
|
|
111
128
|
savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
|
|
112
129
|
contentView.removeChild(lastChild);
|
|
113
130
|
}
|
|
131
|
+
|
|
132
|
+
// Ignored via go/ees005
|
|
133
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
114
134
|
const firstChild = contentView.firstChild;
|
|
115
135
|
savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
|
|
116
136
|
const newCursorPosition = firstChild.innerHTML.length + 1;
|
|
@@ -154,4 +174,7 @@ export class CodeBlockView {
|
|
|
154
174
|
this.cleanupEditorDisabledListener = undefined;
|
|
155
175
|
}
|
|
156
176
|
}
|
|
157
|
-
export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api
|
|
177
|
+
export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api
|
|
178
|
+
// Ignored via go/ees005
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
180
|
+
) => new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
@@ -30,6 +30,8 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
30
30
|
decorationStartAndEnd: undefined
|
|
31
31
|
};
|
|
32
32
|
},
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
33
35
|
apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
34
36
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
35
37
|
case 'show-selection':
|
|
@@ -5,11 +5,15 @@ export const BRACKET_MAP = {
|
|
|
5
5
|
};
|
|
6
6
|
export const shouldAutoCloseBracket = (before, after) => {
|
|
7
7
|
// when directly before a closing bracket
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
if (/^[}\])]/.test(after)) {
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
// exclusion: when directly before a non-whitespace character
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
13
17
|
if (/^[^\s]/.test(after)) {
|
|
14
18
|
return false;
|
|
15
19
|
}
|
|
@@ -6,8 +6,12 @@ export const getStartOfCurrentLine = state => {
|
|
|
6
6
|
$from
|
|
7
7
|
} = state.selection;
|
|
8
8
|
if ($from.nodeBefore && $from.nodeBefore.isText) {
|
|
9
|
+
// Ignored via go/ees005
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
11
|
const prevNewLineIndex = $from.nodeBefore.text.lastIndexOf('\n');
|
|
10
12
|
return {
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11
15
|
text: $from.nodeBefore.text.substring(prevNewLineIndex + 1),
|
|
12
16
|
pos: $from.start() + prevNewLineIndex + 1
|
|
13
17
|
};
|
|
@@ -22,8 +26,12 @@ export const getEndOfCurrentLine = state => {
|
|
|
22
26
|
$to
|
|
23
27
|
} = state.selection;
|
|
24
28
|
if ($to.nodeAfter && $to.nodeAfter.isText) {
|
|
29
|
+
// Ignored via go/ees005
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
25
31
|
const nextNewLineIndex = $to.nodeAfter.text.indexOf('\n');
|
|
26
32
|
return {
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
35
|
text: $to.nodeAfter.text.substring(0, nextNewLineIndex >= 0 ? nextNewLineIndex : undefined),
|
|
28
36
|
pos: nextNewLineIndex >= 0 ? $to.pos + nextNewLineIndex : $to.end()
|
|
29
37
|
};
|
|
@@ -54,11 +62,16 @@ export const forEachLine = (text, callback) => {
|
|
|
54
62
|
offset += line.length + 1;
|
|
55
63
|
});
|
|
56
64
|
};
|
|
65
|
+
|
|
66
|
+
// Ignored via go/ees005
|
|
67
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
57
68
|
const SPACE = {
|
|
58
69
|
token: ' ',
|
|
59
70
|
size: 2,
|
|
60
71
|
regex: /[^ ]/
|
|
61
72
|
};
|
|
73
|
+
// Ignored via go/ees005
|
|
74
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
62
75
|
const TAB = {
|
|
63
76
|
token: '\t',
|
|
64
77
|
size: 1,
|
|
@@ -5,16 +5,24 @@ export const QUOTE_MAP = {
|
|
|
5
5
|
};
|
|
6
6
|
export const shouldAutoCloseQuote = (before, after) => {
|
|
7
7
|
// when directly before a closing bracket
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
if (/^[}\])]/.test(after)) {
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
// exclusion: when directly before a non-whitespace character
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
13
17
|
if (/^[^\s]/.test(after)) {
|
|
14
18
|
return false;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
// exclusion: when directly after a letter or quote
|
|
22
|
+
// Ignored via go/ees005
|
|
23
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
18
26
|
if (/[A-Za-z0-9]$/.test(before) || /[\'\"\`]$/.test(before)) {
|
|
19
27
|
return false;
|
|
20
28
|
}
|
|
@@ -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
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
17
19
|
handleTextInput(view, from, to, text) {
|
|
18
20
|
var _pluginInjectionApi$c;
|
|
19
21
|
const {
|
|
@@ -39,7 +41,7 @@ const ideUX = pluginInjectionApi => {
|
|
|
39
41
|
} = getAutoClosingBracketInfo(beforeText + text, afterText);
|
|
40
42
|
if (left && right) {
|
|
41
43
|
const bracketPair = state.schema.text(text + right);
|
|
42
|
-
|
|
44
|
+
const tr = state.tr.replaceWith(from, to, bracketPair);
|
|
43
45
|
dispatch(setTextSelection(from + text.length)(tr));
|
|
44
46
|
return true;
|
|
45
47
|
}
|
|
@@ -53,7 +55,7 @@ const ideUX = pluginInjectionApi => {
|
|
|
53
55
|
} = getAutoClosingQuoteInfo(beforeText + text, afterText);
|
|
54
56
|
if (leftQuote && rightQuote) {
|
|
55
57
|
const quotePair = state.schema.text(text + rightQuote);
|
|
56
|
-
|
|
58
|
+
const tr = state.tr.replaceWith(from, to, quotePair);
|
|
57
59
|
dispatch(setTextSelection(from + text.length)(tr));
|
|
58
60
|
return true;
|
|
59
61
|
}
|
|
@@ -64,6 +66,8 @@ const ideUX = pluginInjectionApi => {
|
|
|
64
66
|
handleKeyDown: keydownHandler({
|
|
65
67
|
Backspace: (state, dispatch) => {
|
|
66
68
|
if (isCursorInsideCodeBlock(state)) {
|
|
69
|
+
// Ignored via go/ees005
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
67
71
|
const $cursor = getCursor(state.selection);
|
|
68
72
|
const beforeText = getStartOfCurrentLine(state).text;
|
|
69
73
|
const afterText = getEndOfCurrentLine(state).text;
|
|
@@ -29,10 +29,16 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
29
29
|
eventType: EVENT_TYPE.TRACK
|
|
30
30
|
}, editorAnalyticsAPI);
|
|
31
31
|
const validMatchLength = match => match.length > 0 && match[0].length === 3;
|
|
32
|
+
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
32
35
|
const threeTildeRule = createRule(/(?!\s)(`{3,})$/, (state, match, start, end) => {
|
|
33
36
|
if (!validMatchLength(match)) {
|
|
34
37
|
return null;
|
|
35
38
|
}
|
|
39
|
+
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
42
|
const attributes = {};
|
|
37
43
|
if (match[4]) {
|
|
38
44
|
attributes.language = match[4];
|
|
@@ -46,10 +52,19 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
46
52
|
safeInsert(codeBlock)(tr);
|
|
47
53
|
return tr;
|
|
48
54
|
});
|
|
49
|
-
const leftNodeReplacementThreeTildeRule = createRule(
|
|
55
|
+
const leftNodeReplacementThreeTildeRule = createRule(
|
|
56
|
+
// Ignored via go/ees005
|
|
57
|
+
// 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) => {
|
|
50
62
|
if (!validMatchLength(match)) {
|
|
51
63
|
return null;
|
|
52
64
|
}
|
|
65
|
+
|
|
66
|
+
// Ignored via go/ees005
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
68
|
const attributes = {};
|
|
54
69
|
if (match[4]) {
|
|
55
70
|
attributes.language = match[4];
|
|
@@ -37,6 +37,8 @@ export const createPlugin = ({
|
|
|
37
37
|
event.preventDefault();
|
|
38
38
|
return true;
|
|
39
39
|
} else if (browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && findCodeBlock(view.state, view.state.selection)) {
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
42
|
const resultingText = event.target.outerText + '\n';
|
|
41
43
|
if (resultingText.endsWith(eventText)) {
|
|
42
44
|
// End of paragraph
|
|
@@ -73,6 +75,8 @@ export const createPlugin = ({
|
|
|
73
75
|
decorations: DecorationSet.create(state.doc, initialDecorations)
|
|
74
76
|
};
|
|
75
77
|
},
|
|
78
|
+
// Ignored via go/ees005
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
76
80
|
apply(tr, pluginState, _oldState, newState) {
|
|
77
81
|
const meta = tr.getMeta(pluginKey);
|
|
78
82
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -99,6 +99,8 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
|
|
|
99
99
|
};
|
|
100
100
|
return {
|
|
101
101
|
title: 'CodeBlock floating controls',
|
|
102
|
+
// Ignored via go/ees005
|
|
103
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
102
104
|
getDomRef: view => findDomRefAtPos(pos, view.domAtPos.bind(view)),
|
|
103
105
|
nodeType,
|
|
104
106
|
items: [languageSelect, separator, codeBlockWrapButton, separator, ...copyToClipboardItems, deleteButton],
|
|
@@ -110,6 +112,8 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
|
|
|
110
112
|
* Filters language list based on both name and alias properties.
|
|
111
113
|
*/
|
|
112
114
|
export const languageListFilter = (option, rawInput) => {
|
|
115
|
+
// Ignored via go/ees005
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
117
|
const {
|
|
114
118
|
data
|
|
115
119
|
} = option;
|
|
@@ -3,7 +3,13 @@ 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
|
-
|
|
6
|
+
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
9
|
+
export function transformToCodeBlockAction(state, start,
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
attrs, isNestingInQuoteSupported) {
|
|
7
13
|
const startOfCodeBlockText = state.selection.$from;
|
|
8
14
|
const endPosition = state.selection.empty && !(state.selection instanceof GapCursorSelection) ? startOfCodeBlockText.end() : state.selection.$to.pos;
|
|
9
15
|
const startLinePosition = startOfCodeBlockText.start();
|
|
@@ -22,6 +22,9 @@ 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
|
|
25
28
|
mapResult.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
26
29
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), (node, pos) => {
|
|
27
30
|
if (node.type.name === 'codeBlock') {
|
|
@@ -8,6 +8,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
8
8
|
import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
|
|
9
9
|
import { getPluginState } from '../pm-plugins/main-state';
|
|
10
10
|
import { codeBlockClassNames } from '../ui/class-names';
|
|
11
|
+
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
11
14
|
var MATCH_NEWLINES = new RegExp('\n', 'g');
|
|
12
15
|
var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
13
16
|
return ['div', {
|
|
@@ -34,6 +37,8 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
|
|
|
34
37
|
}]];
|
|
35
38
|
};
|
|
36
39
|
export var CodeBlockView = /*#__PURE__*/function () {
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
37
42
|
function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
|
|
38
43
|
var _this = this,
|
|
39
44
|
_api$editorDisabled;
|
|
@@ -47,6 +52,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
47
52
|
_this.node.forEach(function (node) {
|
|
48
53
|
var text = node.text;
|
|
49
54
|
if (text) {
|
|
55
|
+
// Ignored via go/ees005
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
57
|
totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
|
|
51
58
|
}
|
|
52
59
|
});
|
|
@@ -60,8 +67,14 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
60
67
|
this.getPos = getPos;
|
|
61
68
|
this.view = view;
|
|
62
69
|
this.node = _node;
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
63
72
|
this.dom = dom;
|
|
73
|
+
// Ignored via go/ees005
|
|
74
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
64
75
|
this.contentDOM = contentDOM;
|
|
76
|
+
// Ignored via go/ees005
|
|
77
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
65
78
|
this.lineNumberGutter = this.dom.querySelector(".".concat(codeBlockClassNames.gutter));
|
|
66
79
|
this.api = api;
|
|
67
80
|
this.maintainDynamicGutterSize();
|
|
@@ -95,6 +108,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
95
108
|
var contentWrapper = this.dom.childNodes[1];
|
|
96
109
|
var contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
|
|
97
110
|
if ((contentView === null || contentView === void 0 || (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
|
|
111
|
+
// Ignored via go/ees005
|
|
112
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
98
113
|
var codeElement = contentView.firstChild;
|
|
99
114
|
codeElement.innerHTML = savedInnerHTML;
|
|
100
115
|
|
|
@@ -121,10 +136,15 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
121
136
|
if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
|
|
122
137
|
var savedInnerHTML = '';
|
|
123
138
|
while (contentView.childNodes.length > 1) {
|
|
139
|
+
// Ignored via go/ees005
|
|
140
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
124
141
|
var lastChild = contentView.lastChild;
|
|
125
142
|
savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
|
|
126
143
|
contentView.removeChild(lastChild);
|
|
127
144
|
}
|
|
145
|
+
|
|
146
|
+
// Ignored via go/ees005
|
|
147
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
128
148
|
var firstChild = contentView.firstChild;
|
|
129
149
|
savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
|
|
130
150
|
var newCursorPosition = firstChild.innerHTML.length + 1;
|
|
@@ -175,6 +195,9 @@ export var CodeBlockView = /*#__PURE__*/function () {
|
|
|
175
195
|
}
|
|
176
196
|
}]);
|
|
177
197
|
}();
|
|
178
|
-
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
|
|
198
|
+
export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
|
|
199
|
+
// Ignored via go/ees005
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
201
|
+
) {
|
|
179
202
|
return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
|
|
180
203
|
};
|
|
@@ -30,6 +30,8 @@ export function codeBlockCopySelectionPlugin() {
|
|
|
30
30
|
decorationStartAndEnd: undefined
|
|
31
31
|
};
|
|
32
32
|
},
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
33
35
|
apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
|
|
34
36
|
switch (transaction.getMeta(copySelectionPluginKey)) {
|
|
35
37
|
case 'show-selection':
|
|
@@ -5,11 +5,15 @@ export var BRACKET_MAP = {
|
|
|
5
5
|
};
|
|
6
6
|
export var shouldAutoCloseBracket = function shouldAutoCloseBracket(before, after) {
|
|
7
7
|
// when directly before a closing bracket
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
if (/^[}\])]/.test(after)) {
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
// exclusion: when directly before a non-whitespace character
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
13
17
|
if (/^[^\s]/.test(after)) {
|
|
14
18
|
return false;
|
|
15
19
|
}
|
|
@@ -8,8 +8,12 @@ export var isCursorInsideCodeBlock = function isCursorInsideCodeBlock(state) {
|
|
|
8
8
|
export var getStartOfCurrentLine = function getStartOfCurrentLine(state) {
|
|
9
9
|
var $from = state.selection.$from;
|
|
10
10
|
if ($from.nodeBefore && $from.nodeBefore.isText) {
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11
13
|
var prevNewLineIndex = $from.nodeBefore.text.lastIndexOf('\n');
|
|
12
14
|
return {
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13
17
|
text: $from.nodeBefore.text.substring(prevNewLineIndex + 1),
|
|
14
18
|
pos: $from.start() + prevNewLineIndex + 1
|
|
15
19
|
};
|
|
@@ -22,8 +26,12 @@ export var getStartOfCurrentLine = function getStartOfCurrentLine(state) {
|
|
|
22
26
|
export var getEndOfCurrentLine = function getEndOfCurrentLine(state) {
|
|
23
27
|
var $to = state.selection.$to;
|
|
24
28
|
if ($to.nodeAfter && $to.nodeAfter.isText) {
|
|
29
|
+
// Ignored via go/ees005
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
25
31
|
var nextNewLineIndex = $to.nodeAfter.text.indexOf('\n');
|
|
26
32
|
return {
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
35
|
text: $to.nodeAfter.text.substring(0, nextNewLineIndex >= 0 ? nextNewLineIndex : undefined),
|
|
28
36
|
pos: nextNewLineIndex >= 0 ? $to.pos + nextNewLineIndex : $to.end()
|
|
29
37
|
};
|
|
@@ -52,11 +60,16 @@ export var forEachLine = function forEachLine(text, callback) {
|
|
|
52
60
|
offset += line.length + 1;
|
|
53
61
|
});
|
|
54
62
|
};
|
|
63
|
+
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
55
66
|
var SPACE = {
|
|
56
67
|
token: ' ',
|
|
57
68
|
size: 2,
|
|
58
69
|
regex: /[^ ]/
|
|
59
70
|
};
|
|
71
|
+
// Ignored via go/ees005
|
|
72
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
60
73
|
var TAB = {
|
|
61
74
|
token: '\t',
|
|
62
75
|
size: 1,
|
|
@@ -5,16 +5,24 @@ export var QUOTE_MAP = {
|
|
|
5
5
|
};
|
|
6
6
|
export var shouldAutoCloseQuote = function shouldAutoCloseQuote(before, after) {
|
|
7
7
|
// when directly before a closing bracket
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
if (/^[}\])]/.test(after)) {
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
// exclusion: when directly before a non-whitespace character
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
13
17
|
if (/^[^\s]/.test(after)) {
|
|
14
18
|
return false;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
// exclusion: when directly after a letter or quote
|
|
22
|
+
// Ignored via go/ees005
|
|
23
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
18
26
|
if (/[A-Za-z0-9]$/.test(before) || /[\'\"\`]$/.test(before)) {
|
|
19
27
|
return false;
|
|
20
28
|
}
|
|
@@ -14,6 +14,8 @@ 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
|
|
17
19
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
18
20
|
var _pluginInjectionApi$c;
|
|
19
21
|
var state = view.state,
|
|
@@ -60,6 +62,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
|
|
|
60
62
|
handleKeyDown: keydownHandler({
|
|
61
63
|
Backspace: function Backspace(state, dispatch) {
|
|
62
64
|
if (isCursorInsideCodeBlock(state)) {
|
|
65
|
+
// Ignored via go/ees005
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
67
|
var $cursor = getCursor(state.selection);
|
|
64
68
|
var beforeText = getStartOfCurrentLine(state).text;
|
|
65
69
|
var afterText = getEndOfCurrentLine(state).text;
|
|
@@ -31,10 +31,16 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
31
31
|
var validMatchLength = function validMatchLength(match) {
|
|
32
32
|
return match.length > 0 && match[0].length === 3;
|
|
33
33
|
};
|
|
34
|
+
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
34
37
|
var threeTildeRule = createRule(/(?!\s)(`{3,})$/, function (state, match, start, end) {
|
|
35
38
|
if (!validMatchLength(match)) {
|
|
36
39
|
return null;
|
|
37
40
|
}
|
|
41
|
+
|
|
42
|
+
// Ignored via go/ees005
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
44
|
var attributes = {};
|
|
39
45
|
if (match[4]) {
|
|
40
46
|
attributes.language = match[4];
|
|
@@ -48,10 +54,19 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
|
|
|
48
54
|
safeInsert(codeBlock)(tr);
|
|
49
55
|
return tr;
|
|
50
56
|
});
|
|
51
|
-
var leftNodeReplacementThreeTildeRule = createRule(
|
|
57
|
+
var leftNodeReplacementThreeTildeRule = createRule(
|
|
58
|
+
// Ignored via go/ees005
|
|
59
|
+
// 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) {
|
|
52
64
|
if (!validMatchLength(match)) {
|
|
53
65
|
return null;
|
|
54
66
|
}
|
|
67
|
+
|
|
68
|
+
// Ignored via go/ees005
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
70
|
var attributes = {};
|
|
56
71
|
if (match[4]) {
|
|
57
72
|
attributes.language = match[4];
|
|
@@ -41,6 +41,8 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
41
41
|
event.preventDefault();
|
|
42
42
|
return true;
|
|
43
43
|
} else if (browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && findCodeBlock(view.state, view.state.selection)) {
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
46
|
var resultingText = event.target.outerText + '\n';
|
|
45
47
|
if (resultingText.endsWith(eventText)) {
|
|
46
48
|
// End of paragraph
|
|
@@ -79,6 +81,8 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
79
81
|
decorations: DecorationSet.create(state.doc, initialDecorations)
|
|
80
82
|
};
|
|
81
83
|
},
|
|
84
|
+
// Ignored via go/ees005
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
82
86
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
83
87
|
var meta = tr.getMeta(pluginKey);
|
|
84
88
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
|
|
@@ -108,6 +108,8 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
108
108
|
};
|
|
109
109
|
return {
|
|
110
110
|
title: 'CodeBlock floating controls',
|
|
111
|
+
// Ignored via go/ees005
|
|
112
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
111
113
|
getDomRef: function getDomRef(view) {
|
|
112
114
|
return findDomRefAtPos(pos, view.domAtPos.bind(view));
|
|
113
115
|
},
|
|
@@ -122,6 +124,8 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
122
124
|
* Filters language list based on both name and alias properties.
|
|
123
125
|
*/
|
|
124
126
|
export var languageListFilter = function languageListFilter(option, rawInput) {
|
|
127
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
129
|
var _ref3 = option,
|
|
126
130
|
data = _ref3.data;
|
|
127
131
|
var searchString = rawInput.toLowerCase();
|
|
@@ -3,7 +3,13 @@ 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
|
-
|
|
6
|
+
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
9
|
+
export function transformToCodeBlockAction(state, start,
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
attrs, isNestingInQuoteSupported) {
|
|
7
13
|
var startOfCodeBlockText = state.selection.$from;
|
|
8
14
|
var endPosition = state.selection.empty && !(state.selection instanceof GapCursorSelection) ? startOfCodeBlockText.end() : state.selection.$to.pos;
|
|
9
15
|
var startLinePosition = startOfCodeBlockText.start();
|
|
@@ -22,6 +22,9 @@ 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
|
|
25
28
|
mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
26
29
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
|
|
27
30
|
if (node.type.name === 'codeBlock') {
|
|
@@ -21,7 +21,7 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
21
21
|
}, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
22
22
|
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
23
23
|
sharedState: {
|
|
24
|
-
createAnalyticsEvent: import("
|
|
24
|
+
createAnalyticsEvent: import("packages/analytics/analytics-next/dist/types").CreateUIAnalyticsEvent | null;
|
|
25
25
|
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
26
26
|
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
27
27
|
};
|
|
@@ -24,7 +24,7 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
24
24
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
25
25
|
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
26
26
|
sharedState: {
|
|
27
|
-
createAnalyticsEvent: import("
|
|
27
|
+
createAnalyticsEvent: import("packages/analytics/analytics-next/dist/types").CreateUIAnalyticsEvent | null;
|
|
28
28
|
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
29
29
|
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
30
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.13",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
35
|
"@atlaskit/code": "^15.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^
|
|
36
|
+
"@atlaskit/editor-common": "^98.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
38
38
|
"@atlaskit/editor-plugin-composition": "^1.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|