@atlaskit/editor-plugin-paste 4.1.3 → 4.1.5
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 +16 -0
- package/dist/cjs/pm-plugins/analytics.js +1 -0
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/util/index.js +37 -0
- package/dist/es2019/pm-plugins/analytics.js +1 -0
- package/dist/es2019/pm-plugins/main.js +3 -3
- package/dist/es2019/pm-plugins/util/index.js +36 -0
- package/dist/esm/pm-plugins/analytics.js +1 -0
- package/dist/esm/pm-plugins/main.js +3 -3
- package/dist/esm/pm-plugins/util/index.js +36 -0
- package/dist/types/editor-commands/commands.d.ts +1 -1
- package/dist/types/pm-plugins/move-analytics/commands.d.ts +1 -1
- package/dist/types/pm-plugins/move-analytics/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/util/edge-cases/lists.d.ts +1 -1
- package/dist/types/pm-plugins/util/index.d.ts +10 -0
- package/dist/types-ts4.5/editor-commands/commands.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/move-analytics/commands.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/move-analytics/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/edge-cases/lists.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/index.d.ts +10 -0
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 4.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.1.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#200144](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/200144)
|
|
14
|
+
[`05db69e3fb6a2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05db69e3fb6a2) -
|
|
15
|
+
[ux] Fixes an issue where content inside code blocks was being unnecessarily escaped during
|
|
16
|
+
copy/paste operations. With this change, code block content will be copied as-is, preserving the
|
|
17
|
+
original formatting and characters.
|
|
18
|
+
|
|
3
19
|
## 4.1.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -94,6 +94,7 @@ function getContent(_ref) {
|
|
|
94
94
|
return _analytics.PasteContents.uncategorized;
|
|
95
95
|
}
|
|
96
96
|
var type = nodeOrMarkName.values().next().value;
|
|
97
|
+
// @ts-ignore - TS2538 TypeScript 5.9.2 upgrade
|
|
97
98
|
var pasteContent = contentToPasteContent[type];
|
|
98
99
|
return pasteContent ? pasteContent : _analytics.PasteContents.uncategorized;
|
|
99
100
|
}
|
|
@@ -48,8 +48,8 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
48
48
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
49
49
|
var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema, _paste.md);
|
|
50
50
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
51
|
-
var
|
|
52
|
-
var doc = atlassianMarkDownParser.parse(
|
|
51
|
+
var escapedTextInput = (0, _platformFeatureFlags.fg)('platform_editor_paste_code_block_do_not_escape') ? (0, _util.escapeBackslashAndLinksExceptCodeBlock)(text) : (0, _util.escapeLinks)(escapeBackslashExceptCodeblock(text));
|
|
52
|
+
var doc = atlassianMarkDownParser.parse(escapedTextInput);
|
|
53
53
|
if (doc && doc.content) {
|
|
54
54
|
return new _model.Slice(doc.content, openStart, openEnd);
|
|
55
55
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.addReplaceSelectedTableAnalytics = void 0;
|
|
8
8
|
exports.applyTextMarksToSlice = applyTextMarksToSlice;
|
|
9
|
+
exports.escapeBackslashAndLinksExceptCodeBlock = escapeBackslashAndLinksExceptCodeBlock;
|
|
9
10
|
exports.escapeLinks = escapeLinks;
|
|
10
11
|
exports.getPasteSource = getPasteSource;
|
|
11
12
|
exports.hasOnlyNodesOfType = hasOnlyNodesOfType;
|
|
@@ -109,6 +110,42 @@ function escapeLinks(text) {
|
|
|
109
110
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s>"]+$/) ? "<".concat(str, ">") : str;
|
|
110
111
|
});
|
|
111
112
|
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Escapes backslashes and links outside code blocks.
|
|
116
|
+
*
|
|
117
|
+
* @param textInput - The input string to process, possibly containing code blocks and links.
|
|
118
|
+
* @returns The processed string with backslashes and links escaped outside code blocks.
|
|
119
|
+
* @example
|
|
120
|
+
* const input = 'This is a link: https://example.com and a backslash: \\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```';
|
|
121
|
+
* 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
|
+
*/
|
|
123
|
+
function escapeBackslashAndLinksExceptCodeBlock(textInput) {
|
|
124
|
+
var codeToken = '```';
|
|
125
|
+
var isInsideCodeBlock = false;
|
|
126
|
+
var lines = textInput.split('\n');
|
|
127
|
+
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
128
|
+
return lines.map(function (line) {
|
|
129
|
+
if (line === codeToken) {
|
|
130
|
+
// Toggle code block state
|
|
131
|
+
isInsideCodeBlock = !isInsideCodeBlock;
|
|
132
|
+
return line;
|
|
133
|
+
} else if (line.startsWith(codeToken) && !isInsideCodeBlock) {
|
|
134
|
+
// if there is some text after the ``` mark , it gets counted as language attribute only at the start of codeblock
|
|
135
|
+
isInsideCodeBlock = true;
|
|
136
|
+
return line;
|
|
137
|
+
}
|
|
138
|
+
if (!isInsideCodeBlock) {
|
|
139
|
+
// Only escape outside code blocks
|
|
140
|
+
// Ignored via go/ees005
|
|
141
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
142
|
+
var escaped = line.replace(/\\/g, '\\\\');
|
|
143
|
+
escaped = escapeLinks(escaped);
|
|
144
|
+
return escaped;
|
|
145
|
+
}
|
|
146
|
+
return line;
|
|
147
|
+
}).join('\n');
|
|
148
|
+
}
|
|
112
149
|
function hasOnlyNodesOfType() {
|
|
113
150
|
for (var _len = arguments.length, nodeTypes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
114
151
|
nodeTypes[_key] = arguments[_key];
|
|
@@ -85,6 +85,7 @@ export function getContent({
|
|
|
85
85
|
return PasteContents.uncategorized;
|
|
86
86
|
}
|
|
87
87
|
const type = nodeOrMarkName.values().next().value;
|
|
88
|
+
// @ts-ignore - TS2538 TypeScript 5.9.2 upgrade
|
|
88
89
|
const pasteContent = contentToPasteContent[type];
|
|
89
90
|
return pasteContent ? pasteContent : PasteContents.uncategorized;
|
|
90
91
|
}
|
|
@@ -21,7 +21,7 @@ import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformS
|
|
|
21
21
|
import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnalytics, handleExpandWithAnalytics, handleMarkdownWithAnalytics, handleMediaSingleWithAnalytics, handleNestedTablePasteWithAnalytics, handlePasteAsPlainTextWithAnalytics, handlePasteIntoCaptionWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePastePreservingMarksWithAnalytics, handleRichTextWithAnalytics, handleSelectedTableWithAnalytics, sendPasteAnalyticsEvent } from './analytics';
|
|
22
22
|
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
23
23
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
24
|
-
import { escapeLinks, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
24
|
+
import { escapeBackslashAndLinksExceptCodeBlock, escapeLinks, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
25
25
|
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
26
26
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from './util/handlers';
|
|
27
27
|
import { htmlHasIncompleteTable, isPastedFromTinyMCEConfluence, tryRebuildCompleteTableHtml } from './util/tinyMCE';
|
|
@@ -37,8 +37,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
37
37
|
const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
38
38
|
const atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
39
39
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
40
|
-
const
|
|
41
|
-
const doc = atlassianMarkDownParser.parse(
|
|
40
|
+
const escapedTextInput = fg('platform_editor_paste_code_block_do_not_escape') ? escapeBackslashAndLinksExceptCodeBlock(text) : escapeLinks(escapeBackslashExceptCodeblock(text));
|
|
41
|
+
const doc = atlassianMarkDownParser.parse(escapedTextInput);
|
|
42
42
|
if (doc && doc.content) {
|
|
43
43
|
return new Slice(doc.content, openStart, openEnd);
|
|
44
44
|
}
|
|
@@ -88,6 +88,42 @@ export function escapeLinks(text) {
|
|
|
88
88
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s>"]+$/) ? `<${str}>` : str;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Escapes backslashes and links outside code blocks.
|
|
94
|
+
*
|
|
95
|
+
* @param textInput - The input string to process, possibly containing code blocks and links.
|
|
96
|
+
* @returns The processed string with backslashes and links escaped outside code blocks.
|
|
97
|
+
* @example
|
|
98
|
+
* const input = 'This is a link: https://example.com and a backslash: \\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```';
|
|
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```'
|
|
100
|
+
*/
|
|
101
|
+
export function escapeBackslashAndLinksExceptCodeBlock(textInput) {
|
|
102
|
+
const codeToken = '```';
|
|
103
|
+
let isInsideCodeBlock = false;
|
|
104
|
+
const lines = textInput.split('\n');
|
|
105
|
+
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
106
|
+
return lines.map(line => {
|
|
107
|
+
if (line === codeToken) {
|
|
108
|
+
// Toggle code block state
|
|
109
|
+
isInsideCodeBlock = !isInsideCodeBlock;
|
|
110
|
+
return line;
|
|
111
|
+
} else if (line.startsWith(codeToken) && !isInsideCodeBlock) {
|
|
112
|
+
// if there is some text after the ``` mark , it gets counted as language attribute only at the start of codeblock
|
|
113
|
+
isInsideCodeBlock = true;
|
|
114
|
+
return line;
|
|
115
|
+
}
|
|
116
|
+
if (!isInsideCodeBlock) {
|
|
117
|
+
// Only escape outside code blocks
|
|
118
|
+
// Ignored via go/ees005
|
|
119
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
120
|
+
let escaped = line.replace(/\\/g, '\\\\');
|
|
121
|
+
escaped = escapeLinks(escaped);
|
|
122
|
+
return escaped;
|
|
123
|
+
}
|
|
124
|
+
return line;
|
|
125
|
+
}).join('\n');
|
|
126
|
+
}
|
|
91
127
|
export function hasOnlyNodesOfType(...nodeTypes) {
|
|
92
128
|
return slice => {
|
|
93
129
|
let hasOnlyNodesOfType = true;
|
|
@@ -82,6 +82,7 @@ export function getContent(_ref) {
|
|
|
82
82
|
return PasteContents.uncategorized;
|
|
83
83
|
}
|
|
84
84
|
var type = nodeOrMarkName.values().next().value;
|
|
85
|
+
// @ts-ignore - TS2538 TypeScript 5.9.2 upgrade
|
|
85
86
|
var pasteContent = contentToPasteContent[type];
|
|
86
87
|
return pasteContent ? pasteContent : PasteContents.uncategorized;
|
|
87
88
|
}
|
|
@@ -26,7 +26,7 @@ import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformS
|
|
|
26
26
|
import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnalytics, handleExpandWithAnalytics, handleMarkdownWithAnalytics, handleMediaSingleWithAnalytics, handleNestedTablePasteWithAnalytics, handlePasteAsPlainTextWithAnalytics, handlePasteIntoCaptionWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePastePreservingMarksWithAnalytics, handleRichTextWithAnalytics, handleSelectedTableWithAnalytics, sendPasteAnalyticsEvent } from './analytics';
|
|
27
27
|
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
28
28
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
29
|
-
import { escapeLinks, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
29
|
+
import { escapeBackslashAndLinksExceptCodeBlock, escapeLinks, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
30
30
|
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
31
31
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from './util/handlers';
|
|
32
32
|
import { htmlHasIncompleteTable, isPastedFromTinyMCEConfluence, tryRebuildCompleteTableHtml } from './util/tinyMCE';
|
|
@@ -40,8 +40,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
40
40
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
41
41
|
var atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
42
42
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
43
|
-
var
|
|
44
|
-
var doc = atlassianMarkDownParser.parse(
|
|
43
|
+
var escapedTextInput = fg('platform_editor_paste_code_block_do_not_escape') ? escapeBackslashAndLinksExceptCodeBlock(text) : escapeLinks(escapeBackslashExceptCodeblock(text));
|
|
44
|
+
var doc = atlassianMarkDownParser.parse(escapedTextInput);
|
|
45
45
|
if (doc && doc.content) {
|
|
46
46
|
return new Slice(doc.content, openStart, openEnd);
|
|
47
47
|
}
|
|
@@ -89,6 +89,42 @@ export function escapeLinks(text) {
|
|
|
89
89
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s>"]+$/) ? "<".concat(str, ">") : str;
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Escapes backslashes and links outside code blocks.
|
|
95
|
+
*
|
|
96
|
+
* @param textInput - The input string to process, possibly containing code blocks and links.
|
|
97
|
+
* @returns The processed string with backslashes and links escaped outside code blocks.
|
|
98
|
+
* @example
|
|
99
|
+
* const 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
|
+
* 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
|
+
*/
|
|
102
|
+
export function escapeBackslashAndLinksExceptCodeBlock(textInput) {
|
|
103
|
+
var codeToken = '```';
|
|
104
|
+
var isInsideCodeBlock = false;
|
|
105
|
+
var lines = textInput.split('\n');
|
|
106
|
+
// In the splitted array, we traverse through every line and check if it will be parsed as a codeblock.
|
|
107
|
+
return lines.map(function (line) {
|
|
108
|
+
if (line === codeToken) {
|
|
109
|
+
// Toggle code block state
|
|
110
|
+
isInsideCodeBlock = !isInsideCodeBlock;
|
|
111
|
+
return line;
|
|
112
|
+
} else if (line.startsWith(codeToken) && !isInsideCodeBlock) {
|
|
113
|
+
// if there is some text after the ``` mark , it gets counted as language attribute only at the start of codeblock
|
|
114
|
+
isInsideCodeBlock = true;
|
|
115
|
+
return line;
|
|
116
|
+
}
|
|
117
|
+
if (!isInsideCodeBlock) {
|
|
118
|
+
// Only escape outside code blocks
|
|
119
|
+
// Ignored via go/ees005
|
|
120
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
121
|
+
var escaped = line.replace(/\\/g, '\\\\');
|
|
122
|
+
escaped = escapeLinks(escaped);
|
|
123
|
+
return escaped;
|
|
124
|
+
}
|
|
125
|
+
return line;
|
|
126
|
+
}).join('\n');
|
|
127
|
+
}
|
|
92
128
|
export function hasOnlyNodesOfType() {
|
|
93
129
|
for (var _len = arguments.length, nodeTypes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
94
130
|
nodeTypes[_key] = arguments[_key];
|
|
@@ -26,6 +26,6 @@ export declare const splitParagraphs: (slice: Slice, schema: Schema) => Slice;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const splitIntoParagraphs: ({ fragment, blockMarks, schema, }: {
|
|
28
28
|
fragment: Fragment;
|
|
29
|
-
blockMarks?: readonly Mark[]
|
|
29
|
+
blockMarks?: readonly Mark[];
|
|
30
30
|
schema: Schema;
|
|
31
31
|
}) => Fragment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { ActionType, ContentMoved } from './types';
|
|
3
|
-
export declare const updateContentMoved: (nextState: Omit<ContentMoved,
|
|
3
|
+
export declare const updateContentMoved: (nextState: Omit<ContentMoved, "currentActions">, nextAction: ActionType) => import("@atlaskit/editor-common/types").Command;
|
|
4
4
|
export declare const resetContentMoved: () => import("@atlaskit/editor-common/types").Command;
|
|
5
5
|
export declare const resetContentMovedTransform: () => (tr: Transaction) => Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("./types").MoveAnalyticsPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").MoveAnalyticsPluginState)) => import("prosemirror-state").SafeStateField<import("./types").MoveAnalyticsPluginState>, createCommand: <A = import("./actions").MoveAnalyticsPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (
|
|
1
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("./types").MoveAnalyticsPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").MoveAnalyticsPluginState)) => import("prosemirror-state").SafeStateField<import("./types").MoveAnalyticsPluginState>, createCommand: <A = import("./actions").MoveAnalyticsPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").MoveAnalyticsPluginState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const pluginKey: PluginKey<any>;
|
|
3
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("..").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("..").PastePluginState)) => import("prosemirror-state").SafeStateField<import("..").PastePluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (
|
|
3
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("..").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("..").PastePluginState)) => import("prosemirror-state").SafeStateField<import("..").PastePluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("..").PastePluginState;
|
|
@@ -15,5 +15,5 @@ export declare function insertSliceIntoRangeSelectionInsideList({ tr, slice, }:
|
|
|
15
15
|
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice, schema }: {
|
|
16
16
|
tr: Transaction;
|
|
17
17
|
slice: Slice;
|
|
18
|
-
schema?: Schema
|
|
18
|
+
schema?: Schema;
|
|
19
19
|
}) => void;
|
|
@@ -24,6 +24,16 @@ export declare function getPasteSource(event: ClipboardEvent): PasteSource;
|
|
|
24
24
|
* check behaviour of double quotes in url strings
|
|
25
25
|
*/
|
|
26
26
|
export declare function escapeLinks(text: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Escapes backslashes and links outside code blocks.
|
|
29
|
+
*
|
|
30
|
+
* @param textInput - The input string to process, possibly containing code blocks and links.
|
|
31
|
+
* @returns The processed string with backslashes and links escaped outside code blocks.
|
|
32
|
+
* @example
|
|
33
|
+
* const input = 'This is a link: https://example.com and a backslash: \\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```';
|
|
34
|
+
* 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```'
|
|
35
|
+
*/
|
|
36
|
+
export declare function escapeBackslashAndLinksExceptCodeBlock(textInput: string): string;
|
|
27
37
|
export declare function hasOnlyNodesOfType(...nodeTypes: NodeType[]): (slice: Slice) => boolean;
|
|
28
38
|
export declare function applyTextMarksToSlice(schema: Schema, marks?: readonly Mark[]): (slice: Slice) => Slice;
|
|
29
39
|
export declare function isEmptyNode(node: PMNode | null | undefined): boolean | null;
|
|
@@ -26,6 +26,6 @@ export declare const splitParagraphs: (slice: Slice, schema: Schema) => Slice;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const splitIntoParagraphs: ({ fragment, blockMarks, schema, }: {
|
|
28
28
|
fragment: Fragment;
|
|
29
|
-
blockMarks?: readonly Mark[]
|
|
29
|
+
blockMarks?: readonly Mark[];
|
|
30
30
|
schema: Schema;
|
|
31
31
|
}) => Fragment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { ActionType, ContentMoved } from './types';
|
|
3
|
-
export declare const updateContentMoved: (nextState: Omit<ContentMoved,
|
|
3
|
+
export declare const updateContentMoved: (nextState: Omit<ContentMoved, "currentActions">, nextAction: ActionType) => import("@atlaskit/editor-common/types").Command;
|
|
4
4
|
export declare const resetContentMoved: () => import("@atlaskit/editor-common/types").Command;
|
|
5
5
|
export declare const resetContentMovedTransform: () => (tr: Transaction) => Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("./types").MoveAnalyticsPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").MoveAnalyticsPluginState)) => import("prosemirror-state").SafeStateField<import("./types").MoveAnalyticsPluginState>, createCommand: <A = import("./actions").MoveAnalyticsPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (
|
|
1
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("./types").MoveAnalyticsPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").MoveAnalyticsPluginState)) => import("prosemirror-state").SafeStateField<import("./types").MoveAnalyticsPluginState>, createCommand: <A = import("./actions").MoveAnalyticsPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").MoveAnalyticsPluginState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const pluginKey: PluginKey<any>;
|
|
3
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("..").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("..").PastePluginState)) => import("prosemirror-state").SafeStateField<import("..").PastePluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (
|
|
3
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: import("..").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("..").PastePluginState)) => import("prosemirror-state").SafeStateField<import("..").PastePluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("..").PastePluginState;
|
|
@@ -15,5 +15,5 @@ export declare function insertSliceIntoRangeSelectionInsideList({ tr, slice, }:
|
|
|
15
15
|
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice, schema }: {
|
|
16
16
|
tr: Transaction;
|
|
17
17
|
slice: Slice;
|
|
18
|
-
schema?: Schema
|
|
18
|
+
schema?: Schema;
|
|
19
19
|
}) => void;
|
|
@@ -24,6 +24,16 @@ export declare function getPasteSource(event: ClipboardEvent): PasteSource;
|
|
|
24
24
|
* check behaviour of double quotes in url strings
|
|
25
25
|
*/
|
|
26
26
|
export declare function escapeLinks(text: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Escapes backslashes and links outside code blocks.
|
|
29
|
+
*
|
|
30
|
+
* @param textInput - The input string to process, possibly containing code blocks and links.
|
|
31
|
+
* @returns The processed string with backslashes and links escaped outside code blocks.
|
|
32
|
+
* @example
|
|
33
|
+
* const input = 'This is a link: https://example.com and a backslash: \\\n```\ncode block https://example.com not escaped\ncode block \\ not escaped\n```';
|
|
34
|
+
* 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```'
|
|
35
|
+
*/
|
|
36
|
+
export declare function escapeBackslashAndLinksExceptCodeBlock(textInput: string): string;
|
|
27
37
|
export declare function hasOnlyNodesOfType(...nodeTypes: NodeType[]): (slice: Slice) => boolean;
|
|
28
38
|
export declare function applyTextMarksToSlice(schema: Schema, marks?: readonly Mark[]): (slice: Slice) => Slice;
|
|
29
39
|
export declare function isEmptyNode(node: PMNode | null | undefined): boolean | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,37 +34,36 @@
|
|
|
34
34
|
"@atlaskit/code": "^17.2.0",
|
|
35
35
|
"@atlaskit/editor-markdown-transformer": "^5.16.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
37
|
-
"@atlaskit/editor-plugin-annotation": "^3.
|
|
37
|
+
"@atlaskit/editor-plugin-annotation": "^3.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-better-type-history": "^3.0.0",
|
|
39
|
-
"@atlaskit/editor-plugin-card": "^7.
|
|
39
|
+
"@atlaskit/editor-plugin-card": "^7.4.0",
|
|
40
40
|
"@atlaskit/editor-plugin-feature-flags": "^2.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-list": "^5.1.0",
|
|
42
42
|
"@atlaskit/editor-plugin-media": "^5.2.0",
|
|
43
43
|
"@atlaskit/editor-plugin-mentions": "^5.2.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
46
|
-
"@atlaskit/media-client": "^35.
|
|
46
|
+
"@atlaskit/media-client": "^35.3.0",
|
|
47
47
|
"@atlaskit/media-common": "^12.3.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^10.0.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
52
52
|
"uuid": "^3.1.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@atlaskit/editor-common": "^107.
|
|
55
|
+
"@atlaskit/editor-common": "^107.25.0",
|
|
56
56
|
"react": "^18.2.0",
|
|
57
57
|
"react-dom": "^18.2.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@af/visual-regression": "workspace:^",
|
|
61
|
-
"@atlaskit/editor-plugin-block-type": "^6.
|
|
61
|
+
"@atlaskit/editor-plugin-block-type": "^6.2.0",
|
|
62
62
|
"@atlaskit/editor-plugin-history": "^3.1.0",
|
|
63
63
|
"@atlaskit/editor-plugin-type-ahead": "^3.1.0",
|
|
64
64
|
"@atlaskit/ssr": "workspace:^",
|
|
65
65
|
"@atlaskit/visual-regression": "workspace:^",
|
|
66
66
|
"@testing-library/react": "^13.4.0",
|
|
67
|
-
"typescript": "~5.4.2",
|
|
68
67
|
"wait-for-expect": "^1.2.0"
|
|
69
68
|
},
|
|
70
69
|
"techstack": {
|
|
@@ -118,6 +117,9 @@
|
|
|
118
117
|
},
|
|
119
118
|
"platform_editor_track_node_types": {
|
|
120
119
|
"type": "boolean"
|
|
120
|
+
},
|
|
121
|
+
"platform_editor_paste_code_block_do_not_escape": {
|
|
122
|
+
"type": "boolean"
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
}
|