@atlaskit/editor-plugin-paste 7.4.13 → 7.4.15
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 +13 -0
- package/dist/cjs/pm-plugins/util/index.js +31 -59
- package/dist/es2019/pm-plugins/util/index.js +31 -59
- package/dist/esm/pm-plugins/util/index.js +31 -59
- package/package.json +9 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 7.4.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`d23b93a4296a9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d23b93a4296a9) -
|
|
8
|
+
[ux] Clean FG for platform_editor_paste_code_fence_spaces
|
|
9
|
+
|
|
10
|
+
## 7.4.14
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 7.4.13
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -28,7 +28,6 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
28
28
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
29
29
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
30
30
|
var _mediaClient = require("@atlaskit/media-client");
|
|
31
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
32
31
|
function isPastedFromWord(html) {
|
|
33
32
|
return !!html && html.indexOf('urn:schemas-microsoft-com:office:word') >= 0;
|
|
34
33
|
}
|
|
@@ -121,66 +120,39 @@ function escapeLinks(text) {
|
|
|
121
120
|
* const output = escapeBackslashAndLinksExceptCodeBlock(input); // 'This is a link: <https://example.com> and a backslash: \\\\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```'
|
|
122
121
|
*/
|
|
123
122
|
function escapeBackslashAndLinksExceptCodeBlock(textInput) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
123
|
+
// ref: https://spec.commonmark.org/0.31.2/#fenced-code-blocks
|
|
124
|
+
// Allows up to 3 leading spaces before ``` and optional trailing characters
|
|
125
|
+
// Ignored via go/ees005
|
|
126
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
127
|
+
var openingCodeFenceRegex = /^( {0,3})```.*$/;
|
|
128
|
+
// Allows up to 3 leading spaces before ``` and optional trailing spaces or tabs
|
|
129
|
+
// Ignored via go/ees005
|
|
130
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
131
|
+
var closingCodeFenceRegex = /^( {0,3})```[ \t]*$/;
|
|
132
|
+
var isInsideCodeBlock = false;
|
|
133
|
+
var lines = textInput.split('\n');
|
|
134
|
+
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
135
|
+
return lines.map(function (line) {
|
|
136
|
+
if (!isInsideCodeBlock && openingCodeFenceRegex.test(line)) {
|
|
137
|
+
isInsideCodeBlock = true;
|
|
138
|
+
return line;
|
|
139
|
+
}
|
|
140
|
+
if (isInsideCodeBlock && closingCodeFenceRegex.test(line)) {
|
|
141
|
+
isInsideCodeBlock = false;
|
|
142
|
+
return line;
|
|
143
|
+
}
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return line;
|
|
150
|
-
} else {
|
|
151
|
-
// Ignored via go/ees005
|
|
152
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
153
|
-
var escaped = line.replace(/\\/g, '\\\\');
|
|
154
|
-
escaped = escapeLinks(escaped);
|
|
155
|
-
return escaped;
|
|
156
|
-
}
|
|
157
|
-
}).join('\n');
|
|
158
|
-
} else {
|
|
159
|
-
var codeToken = '```';
|
|
160
|
-
var _isInsideCodeBlock = false;
|
|
161
|
-
var _lines = textInput.split('\n');
|
|
162
|
-
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
163
|
-
return _lines.map(function (line) {
|
|
164
|
-
if (line === codeToken) {
|
|
165
|
-
// Toggle code block state
|
|
166
|
-
_isInsideCodeBlock = !_isInsideCodeBlock;
|
|
167
|
-
return line;
|
|
168
|
-
} else if (line.startsWith(codeToken) && !_isInsideCodeBlock) {
|
|
169
|
-
// if there is some text after the ``` mark , it gets counted as language attribute only at the start of codeblock
|
|
170
|
-
_isInsideCodeBlock = true;
|
|
171
|
-
return line;
|
|
172
|
-
}
|
|
173
|
-
if (!_isInsideCodeBlock) {
|
|
174
|
-
// Only escape outside code blocks
|
|
175
|
-
// Ignored via go/ees005
|
|
176
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
177
|
-
var escaped = line.replace(/\\/g, '\\\\');
|
|
178
|
-
escaped = escapeLinks(escaped);
|
|
179
|
-
return escaped;
|
|
180
|
-
}
|
|
145
|
+
// not code fence, don't escape anything inside code block
|
|
146
|
+
if (isInsideCodeBlock) {
|
|
181
147
|
return line;
|
|
182
|
-
}
|
|
183
|
-
|
|
148
|
+
} else {
|
|
149
|
+
// Ignored via go/ees005
|
|
150
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
151
|
+
var escaped = line.replace(/\\/g, '\\\\');
|
|
152
|
+
escaped = escapeLinks(escaped);
|
|
153
|
+
return escaped;
|
|
154
|
+
}
|
|
155
|
+
}).join('\n');
|
|
184
156
|
}
|
|
185
157
|
function hasOnlyNodesOfType() {
|
|
186
158
|
for (var _len = arguments.length, nodeTypes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -6,7 +6,6 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
6
6
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { getSelectedTableInfo, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
8
8
|
import { isMediaBlobUrl } from '@atlaskit/media-client';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
export function isPastedFromWord(html) {
|
|
11
10
|
return !!html && html.indexOf('urn:schemas-microsoft-com:office:word') >= 0;
|
|
12
11
|
}
|
|
@@ -99,66 +98,39 @@ export function escapeLinks(text) {
|
|
|
99
98
|
* const output = escapeBackslashAndLinksExceptCodeBlock(input); // 'This is a link: <https://example.com> and a backslash: \\\\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```'
|
|
100
99
|
*/
|
|
101
100
|
export function escapeBackslashAndLinksExceptCodeBlock(textInput) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
101
|
+
// ref: https://spec.commonmark.org/0.31.2/#fenced-code-blocks
|
|
102
|
+
// Allows up to 3 leading spaces before ``` and optional trailing characters
|
|
103
|
+
// Ignored via go/ees005
|
|
104
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
105
|
+
const openingCodeFenceRegex = /^( {0,3})```.*$/;
|
|
106
|
+
// Allows up to 3 leading spaces before ``` and optional trailing spaces or tabs
|
|
107
|
+
// Ignored via go/ees005
|
|
108
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
109
|
+
const closingCodeFenceRegex = /^( {0,3})```[ \t]*$/;
|
|
110
|
+
let isInsideCodeBlock = false;
|
|
111
|
+
const lines = textInput.split('\n');
|
|
112
|
+
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
113
|
+
return lines.map(line => {
|
|
114
|
+
if (!isInsideCodeBlock && openingCodeFenceRegex.test(line)) {
|
|
115
|
+
isInsideCodeBlock = true;
|
|
116
|
+
return line;
|
|
117
|
+
}
|
|
118
|
+
if (isInsideCodeBlock && closingCodeFenceRegex.test(line)) {
|
|
119
|
+
isInsideCodeBlock = false;
|
|
120
|
+
return line;
|
|
121
|
+
}
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return line;
|
|
128
|
-
} else {
|
|
129
|
-
// Ignored via go/ees005
|
|
130
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
131
|
-
let escaped = line.replace(/\\/g, '\\\\');
|
|
132
|
-
escaped = escapeLinks(escaped);
|
|
133
|
-
return escaped;
|
|
134
|
-
}
|
|
135
|
-
}).join('\n');
|
|
136
|
-
} else {
|
|
137
|
-
const codeToken = '```';
|
|
138
|
-
let isInsideCodeBlock = false;
|
|
139
|
-
const lines = textInput.split('\n');
|
|
140
|
-
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
141
|
-
return lines.map(line => {
|
|
142
|
-
if (line === codeToken) {
|
|
143
|
-
// Toggle code block state
|
|
144
|
-
isInsideCodeBlock = !isInsideCodeBlock;
|
|
145
|
-
return line;
|
|
146
|
-
} else if (line.startsWith(codeToken) && !isInsideCodeBlock) {
|
|
147
|
-
// if there is some text after the ``` mark , it gets counted as language attribute only at the start of codeblock
|
|
148
|
-
isInsideCodeBlock = true;
|
|
149
|
-
return line;
|
|
150
|
-
}
|
|
151
|
-
if (!isInsideCodeBlock) {
|
|
152
|
-
// Only escape outside code blocks
|
|
153
|
-
// Ignored via go/ees005
|
|
154
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
155
|
-
let escaped = line.replace(/\\/g, '\\\\');
|
|
156
|
-
escaped = escapeLinks(escaped);
|
|
157
|
-
return escaped;
|
|
158
|
-
}
|
|
123
|
+
// not code fence, don't escape anything inside code block
|
|
124
|
+
if (isInsideCodeBlock) {
|
|
159
125
|
return line;
|
|
160
|
-
}
|
|
161
|
-
|
|
126
|
+
} else {
|
|
127
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
129
|
+
let escaped = line.replace(/\\/g, '\\\\');
|
|
130
|
+
escaped = escapeLinks(escaped);
|
|
131
|
+
return escaped;
|
|
132
|
+
}
|
|
133
|
+
}).join('\n');
|
|
162
134
|
}
|
|
163
135
|
export function hasOnlyNodesOfType(...nodeTypes) {
|
|
164
136
|
return slice => {
|
|
@@ -7,7 +7,6 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
7
7
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
8
8
|
import { getSelectedTableInfo, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
9
9
|
import { isMediaBlobUrl } from '@atlaskit/media-client';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
export function isPastedFromWord(html) {
|
|
12
11
|
return !!html && html.indexOf('urn:schemas-microsoft-com:office:word') >= 0;
|
|
13
12
|
}
|
|
@@ -100,66 +99,39 @@ export function escapeLinks(text) {
|
|
|
100
99
|
* const output = escapeBackslashAndLinksExceptCodeBlock(input); // 'This is a link: <https://example.com> and a backslash: \\\\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```'
|
|
101
100
|
*/
|
|
102
101
|
export function escapeBackslashAndLinksExceptCodeBlock(textInput) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
102
|
+
// ref: https://spec.commonmark.org/0.31.2/#fenced-code-blocks
|
|
103
|
+
// Allows up to 3 leading spaces before ``` and optional trailing characters
|
|
104
|
+
// Ignored via go/ees005
|
|
105
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
106
|
+
var openingCodeFenceRegex = /^( {0,3})```.*$/;
|
|
107
|
+
// Allows up to 3 leading spaces before ``` and optional trailing spaces or tabs
|
|
108
|
+
// Ignored via go/ees005
|
|
109
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
110
|
+
var closingCodeFenceRegex = /^( {0,3})```[ \t]*$/;
|
|
111
|
+
var isInsideCodeBlock = false;
|
|
112
|
+
var lines = textInput.split('\n');
|
|
113
|
+
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
114
|
+
return lines.map(function (line) {
|
|
115
|
+
if (!isInsideCodeBlock && openingCodeFenceRegex.test(line)) {
|
|
116
|
+
isInsideCodeBlock = true;
|
|
117
|
+
return line;
|
|
118
|
+
}
|
|
119
|
+
if (isInsideCodeBlock && closingCodeFenceRegex.test(line)) {
|
|
120
|
+
isInsideCodeBlock = false;
|
|
121
|
+
return line;
|
|
122
|
+
}
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return line;
|
|
129
|
-
} else {
|
|
130
|
-
// Ignored via go/ees005
|
|
131
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
132
|
-
var escaped = line.replace(/\\/g, '\\\\');
|
|
133
|
-
escaped = escapeLinks(escaped);
|
|
134
|
-
return escaped;
|
|
135
|
-
}
|
|
136
|
-
}).join('\n');
|
|
137
|
-
} else {
|
|
138
|
-
var codeToken = '```';
|
|
139
|
-
var _isInsideCodeBlock = false;
|
|
140
|
-
var _lines = textInput.split('\n');
|
|
141
|
-
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
142
|
-
return _lines.map(function (line) {
|
|
143
|
-
if (line === codeToken) {
|
|
144
|
-
// Toggle code block state
|
|
145
|
-
_isInsideCodeBlock = !_isInsideCodeBlock;
|
|
146
|
-
return line;
|
|
147
|
-
} else if (line.startsWith(codeToken) && !_isInsideCodeBlock) {
|
|
148
|
-
// if there is some text after the ``` mark , it gets counted as language attribute only at the start of codeblock
|
|
149
|
-
_isInsideCodeBlock = true;
|
|
150
|
-
return line;
|
|
151
|
-
}
|
|
152
|
-
if (!_isInsideCodeBlock) {
|
|
153
|
-
// Only escape outside code blocks
|
|
154
|
-
// Ignored via go/ees005
|
|
155
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
156
|
-
var escaped = line.replace(/\\/g, '\\\\');
|
|
157
|
-
escaped = escapeLinks(escaped);
|
|
158
|
-
return escaped;
|
|
159
|
-
}
|
|
124
|
+
// not code fence, don't escape anything inside code block
|
|
125
|
+
if (isInsideCodeBlock) {
|
|
160
126
|
return line;
|
|
161
|
-
}
|
|
162
|
-
|
|
127
|
+
} else {
|
|
128
|
+
// Ignored via go/ees005
|
|
129
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
130
|
+
var escaped = line.replace(/\\/g, '\\\\');
|
|
131
|
+
escaped = escapeLinks(escaped);
|
|
132
|
+
return escaped;
|
|
133
|
+
}
|
|
134
|
+
}).join('\n');
|
|
163
135
|
}
|
|
164
136
|
export function hasOnlyNodesOfType() {
|
|
165
137
|
for (var _len = arguments.length, nodeTypes = new Array(_len), _key = 0; _key < _len; _key++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.15",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,36 +28,36 @@
|
|
|
28
28
|
"atlaskit:src": "src/index.ts",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^51.5.1",
|
|
31
|
-
"@atlaskit/code": "^17.
|
|
31
|
+
"@atlaskit/code": "^17.4.0",
|
|
32
32
|
"@atlaskit/editor-markdown-transformer": "^5.20.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
34
|
-
"@atlaskit/editor-plugin-annotation": "^6.
|
|
34
|
+
"@atlaskit/editor-plugin-annotation": "^6.3.0",
|
|
35
35
|
"@atlaskit/editor-plugin-better-type-history": "^6.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-card": "^11.5.0",
|
|
37
37
|
"@atlaskit/editor-plugin-feature-flags": "^5.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-list": "^8.2.0",
|
|
39
|
-
"@atlaskit/editor-plugin-media": "^8.
|
|
39
|
+
"@atlaskit/editor-plugin-media": "^8.5.0",
|
|
40
40
|
"@atlaskit/editor-plugin-mentions": "^8.2.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
43
43
|
"@atlaskit/insm": "^0.2.0",
|
|
44
|
-
"@atlaskit/media-client": "^35.
|
|
44
|
+
"@atlaskit/media-client": "^35.7.0",
|
|
45
45
|
"@atlaskit/media-common": "^12.3.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
|
-
"@atlaskit/
|
|
47
|
+
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^15.7.0",
|
|
48
49
|
"@babel/runtime": "^7.0.0",
|
|
49
50
|
"lodash": "^4.17.21",
|
|
50
51
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
51
52
|
"uuid": "^3.1.0"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
|
-
"@atlaskit/editor-common": "^110.
|
|
55
|
+
"@atlaskit/editor-common": "^110.41.0",
|
|
55
56
|
"react": "^18.2.0",
|
|
56
57
|
"react-dom": "^18.2.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@testing-library/react": "^13.4.0",
|
|
60
|
+
"@testing-library/react": "^16.3.0",
|
|
61
61
|
"wait-for-expect": "^1.2.0"
|
|
62
62
|
},
|
|
63
63
|
"techstack": {
|
|
@@ -118,9 +118,6 @@
|
|
|
118
118
|
"platform_editor_link_paste_select_all": {
|
|
119
119
|
"type": "boolean"
|
|
120
120
|
},
|
|
121
|
-
"platform_editor_paste_code_fence_spaces": {
|
|
122
|
-
"type": "boolean"
|
|
123
|
-
},
|
|
124
121
|
"platform_editor_date_to_text": {
|
|
125
122
|
"type": "boolean"
|
|
126
123
|
}
|