@atlaskit/editor-plugin-paste-options-toolbar 1.4.4 → 1.4.6
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 +14 -0
- package/dist/cjs/pm-plugins/util/format-handlers.js +5 -0
- package/dist/cjs/pm-plugins/util/index.js +4 -0
- package/dist/cjs/ui/paste-icon.js +5 -0
- package/dist/cjs/ui/toolbar.js +10 -1
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/pm-plugins/util/format-handlers.js +10 -5
- package/dist/es2019/pm-plugins/util/index.js +4 -0
- package/dist/es2019/ui/paste-icon.js +5 -0
- package/dist/es2019/ui/toolbar.js +10 -1
- package/dist/esm/pm-plugins/util/format-handlers.js +5 -0
- package/dist/esm/pm-plugins/util/index.js +4 -0
- package/dist/esm/ui/paste-icon.js +5 -0
- package/dist/esm/ui/toolbar.js +10 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 1.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 1.4.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#99019](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99019)
|
|
14
|
+
[`40d07b40b2031`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/40d07b40b2031) -
|
|
15
|
+
ED-25888: Add lint rule to enforce editor plugin structure
|
|
16
|
+
|
|
3
17
|
## 1.4.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -150,9 +150,14 @@ function getMarkdownSlice(text, schema, selection) {
|
|
|
150
150
|
try {
|
|
151
151
|
var _doc$content$firstChi, _doc$content$lastChil;
|
|
152
152
|
var textInput = text;
|
|
153
|
+
|
|
154
|
+
// Ignored via go/ees005
|
|
155
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
153
156
|
var textSplitByCodeBlock = textInput.split(/```/);
|
|
154
157
|
for (var i = 0; i < textSplitByCodeBlock.length; i++) {
|
|
155
158
|
if (i % 2 === 0) {
|
|
159
|
+
// Ignored via go/ees005
|
|
160
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
156
161
|
textSplitByCodeBlock[i] = textSplitByCodeBlock[i].replace(/\\/g, '\\\\');
|
|
157
162
|
}
|
|
158
163
|
}
|
|
@@ -13,7 +13,11 @@ function isPastedFromFabricEditor(pastedFrom) {
|
|
|
13
13
|
// @see https://product-fabric.atlassian.net/browse/ED-3159
|
|
14
14
|
// @see https://github.com/markdown-it/markdown-it/issues/38
|
|
15
15
|
function escapeLinks(text) {
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
16
18
|
return text.replace(/(\[([^\]]+)\]\()?((https?|ftp|jamfselfservice):\/\/[^\s"'>]+)/g, function (str) {
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
17
21
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s"'>]+$/) ? "<".concat(str, ">") : str;
|
|
18
22
|
});
|
|
19
23
|
}
|
|
@@ -17,6 +17,8 @@ var CustomGlyph = function CustomGlyph(props) {
|
|
|
17
17
|
viewBox: "0 0 24 24",
|
|
18
18
|
fill: "none",
|
|
19
19
|
xmlns: "http://www.w3.org/2000/svg"
|
|
20
|
+
// Ignored via go/ees005
|
|
21
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
20
22
|
}, props), /*#__PURE__*/_react.default.createElement("path", {
|
|
21
23
|
fillRule: "evenodd",
|
|
22
24
|
clipRule: "evenodd",
|
|
@@ -38,6 +40,9 @@ var CustomGlyph = function CustomGlyph(props) {
|
|
|
38
40
|
fill: "currentColor"
|
|
39
41
|
}));
|
|
40
42
|
};
|
|
43
|
+
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
41
46
|
var EditorPasteIcon = function EditorPasteIcon(props) {
|
|
42
47
|
return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({}, props, {
|
|
43
48
|
glyph: CustomGlyph
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -81,6 +81,9 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, edi
|
|
|
81
81
|
var onPositionCalculated = function onPositionCalculated(editorView, nextPos) {
|
|
82
82
|
var from = editorView.state.selection.from;
|
|
83
83
|
var fromCoords = editorView.coordsAtPos(from);
|
|
84
|
+
|
|
85
|
+
// Ignored via go/ees005
|
|
86
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
84
87
|
var toolbar = document.querySelector("div[aria-label=\"".concat(_messages.pasteOptionsToolbarMessages.pasteOptions.defaultMessage, "\"]"));
|
|
85
88
|
var offsetParent = (toolbar === null || toolbar === void 0 ? void 0 : toolbar.offsetParent) || editorView.dom;
|
|
86
89
|
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
@@ -95,6 +98,12 @@ var onPositionCalculated = function onPositionCalculated(editorView, nextPos) {
|
|
|
95
98
|
};
|
|
96
99
|
var getCursorHeight = function getCursorHeight(editorView, from) {
|
|
97
100
|
var nodeAtFrom = editorView.domAtPos(from).node;
|
|
98
|
-
var nearestNonTextNode = (nodeAtFrom === null || nodeAtFrom === void 0 ? void 0 : nodeAtFrom.nodeType) === Node.TEXT_NODE ?
|
|
101
|
+
var nearestNonTextNode = (nodeAtFrom === null || nodeAtFrom === void 0 ? void 0 : nodeAtFrom.nodeType) === Node.TEXT_NODE ?
|
|
102
|
+
// Ignored via go/ees005
|
|
103
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
104
|
+
nodeAtFrom.parentNode :
|
|
105
|
+
// Ignored via go/ees005
|
|
106
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
107
|
+
nodeAtFrom;
|
|
99
108
|
return parseFloat(window.getComputedStyle(nearestNonTextNode, undefined).lineHeight || '');
|
|
100
109
|
};
|
|
@@ -43,7 +43,7 @@ export function createPlugin(dispatch) {
|
|
|
43
43
|
highlightContent,
|
|
44
44
|
pasteStartPos
|
|
45
45
|
} = pasteOptionsPluginKey.getState(state) || {};
|
|
46
|
-
|
|
46
|
+
const decorationSet = (_pasteOptionsPluginKe = (_pasteOptionsPluginKe2 = pasteOptionsPluginKey.getState(state)) === null || _pasteOptionsPluginKe2 === void 0 ? void 0 : _pasteOptionsPluginKe2.highlightDecorationSet) !== null && _pasteOptionsPluginKe !== void 0 ? _pasteOptionsPluginKe : DecorationSet.empty;
|
|
47
47
|
if (!highlightContent) {
|
|
48
48
|
return decorationSet;
|
|
49
49
|
}
|
|
@@ -7,8 +7,8 @@ import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
|
7
7
|
import { escapeLinks } from './index';
|
|
8
8
|
export const formatMarkdown = (tr, pluginState) => {
|
|
9
9
|
let pasteStartPos = pluginState.pasteStartPos;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const pasteEndPos = pluginState.pasteEndPos;
|
|
11
|
+
const plaintext = pluginState.plaintext;
|
|
12
12
|
if (pasteStartPos < 0) {
|
|
13
13
|
return tr;
|
|
14
14
|
}
|
|
@@ -31,7 +31,7 @@ export const formatMarkdown = (tr, pluginState) => {
|
|
|
31
31
|
};
|
|
32
32
|
export const formatRichText = (tr, pluginState) => {
|
|
33
33
|
let pasteStartPos = pluginState.pasteStartPos;
|
|
34
|
-
|
|
34
|
+
const pasteEndPos = pluginState.pasteEndPos;
|
|
35
35
|
const richTextSlice = pluginState.richTextSlice;
|
|
36
36
|
if (pasteStartPos < 0) {
|
|
37
37
|
return tr;
|
|
@@ -54,8 +54,8 @@ export const formatRichText = (tr, pluginState) => {
|
|
|
54
54
|
};
|
|
55
55
|
export const formatPlainText = (tr, pluginState) => {
|
|
56
56
|
let pasteStartPos = pluginState.pasteStartPos;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const pasteEndPos = pluginState.pasteEndPos;
|
|
58
|
+
const plaintext = pluginState.plaintext;
|
|
59
59
|
|
|
60
60
|
//not possible to create plain text slice with empty string
|
|
61
61
|
if (pasteStartPos < 0 || plaintext === '') {
|
|
@@ -145,9 +145,14 @@ export function getMarkdownSlice(text, schema, selection) {
|
|
|
145
145
|
try {
|
|
146
146
|
var _doc$content$firstChi, _doc$content$lastChil;
|
|
147
147
|
let textInput = text;
|
|
148
|
+
|
|
149
|
+
// Ignored via go/ees005
|
|
150
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
148
151
|
const textSplitByCodeBlock = textInput.split(/```/);
|
|
149
152
|
for (let i = 0; i < textSplitByCodeBlock.length; i++) {
|
|
150
153
|
if (i % 2 === 0) {
|
|
154
|
+
// Ignored via go/ees005
|
|
155
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
151
156
|
textSplitByCodeBlock[i] = textSplitByCodeBlock[i].replace(/\\/g, '\\\\');
|
|
152
157
|
}
|
|
153
158
|
}
|
|
@@ -5,7 +5,11 @@ export function isPastedFromFabricEditor(pastedFrom) {
|
|
|
5
5
|
// @see https://product-fabric.atlassian.net/browse/ED-3159
|
|
6
6
|
// @see https://github.com/markdown-it/markdown-it/issues/38
|
|
7
7
|
export function escapeLinks(text) {
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
return text.replace(/(\[([^\]]+)\]\()?((https?|ftp|jamfselfservice):\/\/[^\s"'>]+)/g, str => {
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
9
13
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s"'>]+$/) ? `<${str}>` : str;
|
|
10
14
|
});
|
|
11
15
|
}
|
|
@@ -9,6 +9,8 @@ const CustomGlyph = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
|
9
9
|
viewBox: "0 0 24 24",
|
|
10
10
|
fill: "none",
|
|
11
11
|
xmlns: "http://www.w3.org/2000/svg"
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
12
14
|
}, props), /*#__PURE__*/React.createElement("path", {
|
|
13
15
|
fillRule: "evenodd",
|
|
14
16
|
clipRule: "evenodd",
|
|
@@ -29,6 +31,9 @@ const CustomGlyph = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
|
29
31
|
rx: "1",
|
|
30
32
|
fill: "currentColor"
|
|
31
33
|
}));
|
|
34
|
+
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
32
37
|
const EditorPasteIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({}, props, {
|
|
33
38
|
glyph: CustomGlyph
|
|
34
39
|
}));
|
|
@@ -78,6 +78,9 @@ const onPositionCalculated = (editorView, nextPos) => {
|
|
|
78
78
|
from
|
|
79
79
|
} = editorView.state.selection;
|
|
80
80
|
const fromCoords = editorView.coordsAtPos(from);
|
|
81
|
+
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
81
84
|
const toolbar = document.querySelector(`div[aria-label="${messages.pasteOptions.defaultMessage}"]`);
|
|
82
85
|
const offsetParent = (toolbar === null || toolbar === void 0 ? void 0 : toolbar.offsetParent) || editorView.dom;
|
|
83
86
|
const offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
@@ -92,6 +95,12 @@ const onPositionCalculated = (editorView, nextPos) => {
|
|
|
92
95
|
};
|
|
93
96
|
const getCursorHeight = (editorView, from) => {
|
|
94
97
|
const nodeAtFrom = editorView.domAtPos(from).node;
|
|
95
|
-
const nearestNonTextNode = (nodeAtFrom === null || nodeAtFrom === void 0 ? void 0 : nodeAtFrom.nodeType) === Node.TEXT_NODE ?
|
|
98
|
+
const nearestNonTextNode = (nodeAtFrom === null || nodeAtFrom === void 0 ? void 0 : nodeAtFrom.nodeType) === Node.TEXT_NODE ?
|
|
99
|
+
// Ignored via go/ees005
|
|
100
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
101
|
+
nodeAtFrom.parentNode :
|
|
102
|
+
// Ignored via go/ees005
|
|
103
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
104
|
+
nodeAtFrom;
|
|
96
105
|
return parseFloat(window.getComputedStyle(nearestNonTextNode, undefined).lineHeight || '');
|
|
97
106
|
};
|
|
@@ -143,9 +143,14 @@ export function getMarkdownSlice(text, schema, selection) {
|
|
|
143
143
|
try {
|
|
144
144
|
var _doc$content$firstChi, _doc$content$lastChil;
|
|
145
145
|
var textInput = text;
|
|
146
|
+
|
|
147
|
+
// Ignored via go/ees005
|
|
148
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
146
149
|
var textSplitByCodeBlock = textInput.split(/```/);
|
|
147
150
|
for (var i = 0; i < textSplitByCodeBlock.length; i++) {
|
|
148
151
|
if (i % 2 === 0) {
|
|
152
|
+
// Ignored via go/ees005
|
|
153
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
149
154
|
textSplitByCodeBlock[i] = textSplitByCodeBlock[i].replace(/\\/g, '\\\\');
|
|
150
155
|
}
|
|
151
156
|
}
|
|
@@ -5,7 +5,11 @@ export function isPastedFromFabricEditor(pastedFrom) {
|
|
|
5
5
|
// @see https://product-fabric.atlassian.net/browse/ED-3159
|
|
6
6
|
// @see https://github.com/markdown-it/markdown-it/issues/38
|
|
7
7
|
export function escapeLinks(text) {
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
return text.replace(/(\[([^\]]+)\]\()?((https?|ftp|jamfselfservice):\/\/[^\s"'>]+)/g, function (str) {
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
9
13
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s"'>]+$/) ? "<".concat(str, ">") : str;
|
|
10
14
|
});
|
|
11
15
|
}
|
|
@@ -10,6 +10,8 @@ var CustomGlyph = function CustomGlyph(props) {
|
|
|
10
10
|
viewBox: "0 0 24 24",
|
|
11
11
|
fill: "none",
|
|
12
12
|
xmlns: "http://www.w3.org/2000/svg"
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
13
15
|
}, props), /*#__PURE__*/React.createElement("path", {
|
|
14
16
|
fillRule: "evenodd",
|
|
15
17
|
clipRule: "evenodd",
|
|
@@ -31,6 +33,9 @@ var CustomGlyph = function CustomGlyph(props) {
|
|
|
31
33
|
fill: "currentColor"
|
|
32
34
|
}));
|
|
33
35
|
};
|
|
36
|
+
|
|
37
|
+
// Ignored via go/ees005
|
|
38
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
34
39
|
var EditorPasteIcon = function EditorPasteIcon(props) {
|
|
35
40
|
return /*#__PURE__*/React.createElement(Icon, _extends({}, props, {
|
|
36
41
|
glyph: CustomGlyph
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -74,6 +74,9 @@ export var buildToolbar = function buildToolbar(state, intl, editorAnalyticsAPI)
|
|
|
74
74
|
var onPositionCalculated = function onPositionCalculated(editorView, nextPos) {
|
|
75
75
|
var from = editorView.state.selection.from;
|
|
76
76
|
var fromCoords = editorView.coordsAtPos(from);
|
|
77
|
+
|
|
78
|
+
// Ignored via go/ees005
|
|
79
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
77
80
|
var toolbar = document.querySelector("div[aria-label=\"".concat(messages.pasteOptions.defaultMessage, "\"]"));
|
|
78
81
|
var offsetParent = (toolbar === null || toolbar === void 0 ? void 0 : toolbar.offsetParent) || editorView.dom;
|
|
79
82
|
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
@@ -88,6 +91,12 @@ var onPositionCalculated = function onPositionCalculated(editorView, nextPos) {
|
|
|
88
91
|
};
|
|
89
92
|
var getCursorHeight = function getCursorHeight(editorView, from) {
|
|
90
93
|
var nodeAtFrom = editorView.domAtPos(from).node;
|
|
91
|
-
var nearestNonTextNode = (nodeAtFrom === null || nodeAtFrom === void 0 ? void 0 : nodeAtFrom.nodeType) === Node.TEXT_NODE ?
|
|
94
|
+
var nearestNonTextNode = (nodeAtFrom === null || nodeAtFrom === void 0 ? void 0 : nodeAtFrom.nodeType) === Node.TEXT_NODE ?
|
|
95
|
+
// Ignored via go/ees005
|
|
96
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
97
|
+
nodeAtFrom.parentNode :
|
|
98
|
+
// Ignored via go/ees005
|
|
99
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
100
|
+
nodeAtFrom;
|
|
92
101
|
return parseFloat(window.getComputedStyle(nearestNonTextNode, undefined).lineHeight || '');
|
|
93
102
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"./styles": "./src/ui/styles.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^98.0.0",
|
|
36
36
|
"@atlaskit/editor-markdown-transformer": "^5.13.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
38
38
|
"@atlaskit/editor-plugin-paste": "^2.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"techstack": {
|
|
60
60
|
"@atlassian/frontend": {
|
|
61
61
|
"code-structure": [
|
|
62
|
-
"
|
|
62
|
+
"editor-plugin"
|
|
63
63
|
],
|
|
64
64
|
"import-structure": [
|
|
65
65
|
"atlassian-conventions"
|