@atlaskit/editor-plugin-paste 19.0.4 → 19.0.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 +16 -0
- package/dist/cjs/pm-plugins/util/edge-cases/index.js +5 -7
- package/dist/cjs/pm-plugins/util/handlers.js +13 -13
- package/dist/es2019/pm-plugins/util/edge-cases/index.js +5 -7
- package/dist/es2019/pm-plugins/util/handlers.js +13 -13
- package/dist/esm/pm-plugins/util/edge-cases/index.js +5 -7
- package/dist/esm/pm-plugins/util/handlers.js +13 -13
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 19.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9e6211ceb4ceb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9e6211ceb4ceb) -
|
|
8
|
+
Clean up the fully rolled-out `platform_editor_small_font_size` experiment and make its permanent
|
|
9
|
+
`true` behavior unconditional across editor formatting, task and list handling, paste behavior,
|
|
10
|
+
controls, and rendering.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 19.0.5
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 19.0.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -79,7 +79,7 @@ var stripFontSizeInsideBlockquoteLists = function stripFontSizeInsideBlockquoteL
|
|
|
79
79
|
taskItem = _tr$doc$type$schema$n.taskItem,
|
|
80
80
|
blockTaskItem = _tr$doc$type$schema$n.blockTaskItem;
|
|
81
81
|
var listItemParentNodeTypes = [listItem, taskItem, blockTaskItem];
|
|
82
|
-
if (!fontSize
|
|
82
|
+
if (!fontSize) {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
var containingBlockquote = tr.doc.nodeAt(blockquotePos);
|
|
@@ -106,13 +106,11 @@ function insertSliceInsideBlockquote(_ref3) {
|
|
|
106
106
|
tr: tr
|
|
107
107
|
});
|
|
108
108
|
tr.replaceSelection(slice);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
|
|
109
|
+
var insertedBlockquotePos = (0, _utils2.findParentNodeOfType)(schema.nodes.blockquote)(tr.selection);
|
|
110
|
+
if (!insertedBlockquotePos) {
|
|
111
|
+
return;
|
|
115
112
|
}
|
|
113
|
+
stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
|
|
116
114
|
}
|
|
117
115
|
function updateSelectionAfterReplace(_ref4) {
|
|
118
116
|
var tr = _ref4.tr;
|
|
@@ -1241,19 +1241,19 @@ function handleParagraphBlockMarks(state, slice) {
|
|
|
1241
1241
|
paragraph = _schema$nodes3.paragraph,
|
|
1242
1242
|
heading = _schema$nodes3.heading;
|
|
1243
1243
|
var fontSize = schema.marks.fontSize;
|
|
1244
|
-
var
|
|
1244
|
+
var hasFontSize = !!fontSize;
|
|
1245
1245
|
|
|
1246
1246
|
// When copying from inside a container (e.g. panel, expand), ProseMirror wraps the
|
|
1247
1247
|
// content back in the container via addContext(), increasing openStart/openEnd. Unwrap
|
|
1248
1248
|
// so the paragraph (with its fontSize mark) becomes top-level.
|
|
1249
|
-
if (
|
|
1249
|
+
if (hasFontSize) {
|
|
1250
1250
|
slice = unwrapContainerNodesWithBlockMarks(slice, schema, fontSize);
|
|
1251
1251
|
}
|
|
1252
1252
|
var destinationListNode = (_findParentNodeOfType2 = (0, _utils2.findParentNodeOfType)([bulletList, orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
|
|
1253
1253
|
var currentNode = typeof $from.node === 'function' ? $from.node() : undefined;
|
|
1254
1254
|
var isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === taskItem || $from.parent.type === taskItem;
|
|
1255
1255
|
var isInSmallTaskContext = !!blockTaskItem && ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === blockTaskItem || $from.parent.type === blockTaskItem || $from.parent.type === paragraph && $from.depth > 0 && $from.node($from.depth - 1).type === blockTaskItem);
|
|
1256
|
-
var destinationBlockMarkAttrs =
|
|
1256
|
+
var destinationBlockMarkAttrs = hasFontSize ? getDestinationFontSizeAttrs(destinationListNode, isInSmallTaskContext, $from, currentNode, fontSize) : false;
|
|
1257
1257
|
var isInHeadingContext = $from.parent.type === heading;
|
|
1258
1258
|
|
|
1259
1259
|
// If no paragraph in the slice contains marks, there's no need for special handling
|
|
@@ -1262,7 +1262,7 @@ function handleParagraphBlockMarks(state, slice) {
|
|
|
1262
1262
|
if (!sliceHasTopLevelMarks(slice) && !destinationBlockMarkAttrs) {
|
|
1263
1263
|
return slice;
|
|
1264
1264
|
}
|
|
1265
|
-
var shouldNormalizeFontSizeForTarget =
|
|
1265
|
+
var shouldNormalizeFontSizeForTarget = hasFontSize && (!!destinationListNode || isInNormalTaskContext || isInSmallTaskContext || isInHeadingContext);
|
|
1266
1266
|
|
|
1267
1267
|
// If pasting a single paragraph into pre-existing content, match destination formatting.
|
|
1268
1268
|
// For bullet/ordered lists under small-text, we still need to normalize the paragraph block mark
|
|
@@ -1395,9 +1395,9 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1395
1395
|
var firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
|
|
1396
1396
|
var lastChildOfSlice = (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.lastChild;
|
|
1397
1397
|
var listContainerNodeTypes = [bulletList, orderedList];
|
|
1398
|
-
var
|
|
1399
|
-
var destinationListNode =
|
|
1400
|
-
var destinationListFontSizeAttrs =
|
|
1398
|
+
var hasFontSize = !!fontSize;
|
|
1399
|
+
var destinationListNode = hasFontSize ? (_findParentNodeOfType3 = (0, _utils2.findParentNodeOfType)(listContainerNodeTypes)(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node : undefined;
|
|
1400
|
+
var destinationListFontSizeAttrs = hasFontSize ? (0, _lists.getFirstParagraphBlockMarkAttrs)(destinationListNode, fontSize) : false;
|
|
1401
1401
|
|
|
1402
1402
|
// In case user is pasting inline code,
|
|
1403
1403
|
// any backtick ` immediately preceding it should be removed.
|
|
@@ -1418,13 +1418,13 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1418
1418
|
var sliceContentBlockquoteListNodes = doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes);
|
|
1419
1419
|
|
|
1420
1420
|
// Compute once and reuse below to avoid traversing the slice twice.
|
|
1421
|
-
var sliceMarkTypes =
|
|
1422
|
-
var destinationIsEmpty =
|
|
1421
|
+
var sliceMarkTypes = hasFontSize ? getTopLevelMarkTypesInSlice(slice) : new Set();
|
|
1422
|
+
var destinationIsEmpty = hasFontSize && selection.$from.parent.type === paragraph && selection.$from.parent.textContent.length === 0;
|
|
1423
1423
|
|
|
1424
1424
|
// Capture the destination paragraph's non-fontSize block marks (e.g. alignment, indentation)
|
|
1425
1425
|
// before the paste so they can be restored if the paste replaces the paragraph entirely
|
|
1426
1426
|
// (which happens when small text is pasted with openStart=0).
|
|
1427
|
-
var destinationNonFontSizeBlockMarks =
|
|
1427
|
+
var destinationNonFontSizeBlockMarks = hasFontSize && selection.$from.parent.type === paragraph && sliceMarkTypes.has(fontSize) ? selection.$from.parent.marks.filter(function (m) {
|
|
1428
1428
|
return m.type !== fontSize;
|
|
1429
1429
|
}) : [];
|
|
1430
1430
|
|
|
@@ -1506,7 +1506,7 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
|
|
1508
1508
|
// font size handling for pasting into lists or blockquotes
|
|
1509
|
-
if (
|
|
1509
|
+
if (hasFontSize && (isSliceContentListNodes || sliceContentBlockquoteListNodes)) {
|
|
1510
1510
|
var containingList = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.selection.$from, listContainerNodeTypes);
|
|
1511
1511
|
if (containingList) {
|
|
1512
1512
|
(0, _lists.reconcileBlockMarkForContainerAtPos)(tr, containingList.pos, fontSize, isSliceContentListNodes ? destinationListFontSizeAttrs : false);
|
|
@@ -1514,13 +1514,13 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
|
|
1516
1516
|
// font size handling for pasting into paragraphs (normal text) - preserve source style
|
|
1517
|
-
if (
|
|
1517
|
+
if (hasFontSize && destinationIsEmpty && !sliceMarkTypes.has(fontSize) && !destinationListNode && selection.$from.parent.type === paragraph && (0, _lists.getBlockMarkAttrs)(selection.$from.parent, fontSize)) {
|
|
1518
1518
|
(0, _lists.reconcileBlockMarkForParagraphAtPos)(tr, tr.mapping.map(selection.$from.pos), fontSize, false);
|
|
1519
1519
|
}
|
|
1520
1520
|
|
|
1521
1521
|
// Restore destination block marks (e.g. alignment) that were lost when pasting small text
|
|
1522
1522
|
// replaced the paragraph entirely (openStart=0 from container unwrap).
|
|
1523
|
-
if (
|
|
1523
|
+
if (hasFontSize && destinationNonFontSizeBlockMarks.length > 0) {
|
|
1524
1524
|
var pastedFrom = tr.mapping.map(selection.from, -1);
|
|
1525
1525
|
var pastedTo = tr.mapping.map(selection.to, 1);
|
|
1526
1526
|
var _iterator2 = _createForOfIteratorHelper(destinationNonFontSizeBlockMarks),
|
|
@@ -79,7 +79,7 @@ const stripFontSizeInsideBlockquoteLists = (tr, blockquotePos) => {
|
|
|
79
79
|
}
|
|
80
80
|
} = tr.doc.type.schema;
|
|
81
81
|
const listItemParentNodeTypes = [listItem, taskItem, blockTaskItem];
|
|
82
|
-
if (!fontSize
|
|
82
|
+
if (!fontSize) {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
const containingBlockquote = tr.doc.nodeAt(blockquotePos);
|
|
@@ -103,13 +103,11 @@ export function insertSliceInsideBlockquote({
|
|
|
103
103
|
tr
|
|
104
104
|
});
|
|
105
105
|
tr.replaceSelection(slice);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
|
|
106
|
+
const insertedBlockquotePos = findParentNodeOfType(schema.nodes.blockquote)(tr.selection);
|
|
107
|
+
if (!insertedBlockquotePos) {
|
|
108
|
+
return;
|
|
112
109
|
}
|
|
110
|
+
stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
|
|
113
111
|
}
|
|
114
112
|
export function updateSelectionAfterReplace({
|
|
115
113
|
tr
|
|
@@ -1233,19 +1233,19 @@ export function handleParagraphBlockMarks(state, slice) {
|
|
|
1233
1233
|
const {
|
|
1234
1234
|
fontSize
|
|
1235
1235
|
} = schema.marks;
|
|
1236
|
-
const
|
|
1236
|
+
const hasFontSize = !!fontSize;
|
|
1237
1237
|
|
|
1238
1238
|
// When copying from inside a container (e.g. panel, expand), ProseMirror wraps the
|
|
1239
1239
|
// content back in the container via addContext(), increasing openStart/openEnd. Unwrap
|
|
1240
1240
|
// so the paragraph (with its fontSize mark) becomes top-level.
|
|
1241
|
-
if (
|
|
1241
|
+
if (hasFontSize) {
|
|
1242
1242
|
slice = unwrapContainerNodesWithBlockMarks(slice, schema, fontSize);
|
|
1243
1243
|
}
|
|
1244
1244
|
const destinationListNode = (_findParentNodeOfType2 = findParentNodeOfType([bulletList, orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
|
|
1245
1245
|
const currentNode = typeof $from.node === 'function' ? $from.node() : undefined;
|
|
1246
1246
|
const isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === taskItem || $from.parent.type === taskItem;
|
|
1247
1247
|
const isInSmallTaskContext = !!blockTaskItem && ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === blockTaskItem || $from.parent.type === blockTaskItem || $from.parent.type === paragraph && $from.depth > 0 && $from.node($from.depth - 1).type === blockTaskItem);
|
|
1248
|
-
const destinationBlockMarkAttrs =
|
|
1248
|
+
const destinationBlockMarkAttrs = hasFontSize ? getDestinationFontSizeAttrs(destinationListNode, isInSmallTaskContext, $from, currentNode, fontSize) : false;
|
|
1249
1249
|
const isInHeadingContext = $from.parent.type === heading;
|
|
1250
1250
|
|
|
1251
1251
|
// If no paragraph in the slice contains marks, there's no need for special handling
|
|
@@ -1254,7 +1254,7 @@ export function handleParagraphBlockMarks(state, slice) {
|
|
|
1254
1254
|
if (!sliceHasTopLevelMarks(slice) && !destinationBlockMarkAttrs) {
|
|
1255
1255
|
return slice;
|
|
1256
1256
|
}
|
|
1257
|
-
const shouldNormalizeFontSizeForTarget =
|
|
1257
|
+
const shouldNormalizeFontSizeForTarget = hasFontSize && (!!destinationListNode || isInNormalTaskContext || isInSmallTaskContext || isInHeadingContext);
|
|
1258
1258
|
|
|
1259
1259
|
// If pasting a single paragraph into pre-existing content, match destination formatting.
|
|
1260
1260
|
// For bullet/ordered lists under small-text, we still need to normalize the paragraph block mark
|
|
@@ -1379,9 +1379,9 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1379
1379
|
const firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
|
|
1380
1380
|
const lastChildOfSlice = (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.lastChild;
|
|
1381
1381
|
const listContainerNodeTypes = [bulletList, orderedList];
|
|
1382
|
-
const
|
|
1383
|
-
const destinationListNode =
|
|
1384
|
-
const destinationListFontSizeAttrs =
|
|
1382
|
+
const hasFontSize = !!fontSize;
|
|
1383
|
+
const destinationListNode = hasFontSize ? (_findParentNodeOfType3 = findParentNodeOfType(listContainerNodeTypes)(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node : undefined;
|
|
1384
|
+
const destinationListFontSizeAttrs = hasFontSize ? getFirstParagraphBlockMarkAttrs(destinationListNode, fontSize) : false;
|
|
1385
1385
|
|
|
1386
1386
|
// In case user is pasting inline code,
|
|
1387
1387
|
// any backtick ` immediately preceding it should be removed.
|
|
@@ -1402,13 +1402,13 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1402
1402
|
const sliceContentBlockquoteListNodes = doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes);
|
|
1403
1403
|
|
|
1404
1404
|
// Compute once and reuse below to avoid traversing the slice twice.
|
|
1405
|
-
const sliceMarkTypes =
|
|
1406
|
-
const destinationIsEmpty =
|
|
1405
|
+
const sliceMarkTypes = hasFontSize ? getTopLevelMarkTypesInSlice(slice) : new Set();
|
|
1406
|
+
const destinationIsEmpty = hasFontSize && selection.$from.parent.type === paragraph && selection.$from.parent.textContent.length === 0;
|
|
1407
1407
|
|
|
1408
1408
|
// Capture the destination paragraph's non-fontSize block marks (e.g. alignment, indentation)
|
|
1409
1409
|
// before the paste so they can be restored if the paste replaces the paragraph entirely
|
|
1410
1410
|
// (which happens when small text is pasted with openStart=0).
|
|
1411
|
-
const destinationNonFontSizeBlockMarks =
|
|
1411
|
+
const destinationNonFontSizeBlockMarks = hasFontSize && selection.$from.parent.type === paragraph && sliceMarkTypes.has(fontSize) ? selection.$from.parent.marks.filter(m => m.type !== fontSize) : [];
|
|
1412
1412
|
|
|
1413
1413
|
// We want to use safeInsert to insert invalid content, as it inserts at the closest non schema violating position
|
|
1414
1414
|
// rather than spliting the selection parent node in half (which is what replaceSelection does)
|
|
@@ -1488,7 +1488,7 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
|
|
1490
1490
|
// font size handling for pasting into lists or blockquotes
|
|
1491
|
-
if (
|
|
1491
|
+
if (hasFontSize && (isSliceContentListNodes || sliceContentBlockquoteListNodes)) {
|
|
1492
1492
|
const containingList = findParentNodeOfTypeClosestToPos(tr.selection.$from, listContainerNodeTypes);
|
|
1493
1493
|
if (containingList) {
|
|
1494
1494
|
reconcileBlockMarkForContainerAtPos(tr, containingList.pos, fontSize, isSliceContentListNodes ? destinationListFontSizeAttrs : false);
|
|
@@ -1496,13 +1496,13 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
|
|
1498
1498
|
// font size handling for pasting into paragraphs (normal text) - preserve source style
|
|
1499
|
-
if (
|
|
1499
|
+
if (hasFontSize && destinationIsEmpty && !sliceMarkTypes.has(fontSize) && !destinationListNode && selection.$from.parent.type === paragraph && getBlockMarkAttrs(selection.$from.parent, fontSize)) {
|
|
1500
1500
|
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(selection.$from.pos), fontSize, false);
|
|
1501
1501
|
}
|
|
1502
1502
|
|
|
1503
1503
|
// Restore destination block marks (e.g. alignment) that were lost when pasting small text
|
|
1504
1504
|
// replaced the paragraph entirely (openStart=0 from container unwrap).
|
|
1505
|
-
if (
|
|
1505
|
+
if (hasFontSize && destinationNonFontSizeBlockMarks.length > 0) {
|
|
1506
1506
|
const pastedFrom = tr.mapping.map(selection.from, -1);
|
|
1507
1507
|
const pastedTo = tr.mapping.map(selection.to, 1);
|
|
1508
1508
|
for (const mark of destinationNonFontSizeBlockMarks) {
|
|
@@ -70,7 +70,7 @@ var stripFontSizeInsideBlockquoteLists = function stripFontSizeInsideBlockquoteL
|
|
|
70
70
|
taskItem = _tr$doc$type$schema$n.taskItem,
|
|
71
71
|
blockTaskItem = _tr$doc$type$schema$n.blockTaskItem;
|
|
72
72
|
var listItemParentNodeTypes = [listItem, taskItem, blockTaskItem];
|
|
73
|
-
if (!fontSize
|
|
73
|
+
if (!fontSize) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
var containingBlockquote = tr.doc.nodeAt(blockquotePos);
|
|
@@ -97,13 +97,11 @@ export function insertSliceInsideBlockquote(_ref3) {
|
|
|
97
97
|
tr: tr
|
|
98
98
|
});
|
|
99
99
|
tr.replaceSelection(slice);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
|
|
100
|
+
var insertedBlockquotePos = findParentNodeOfType(schema.nodes.blockquote)(tr.selection);
|
|
101
|
+
if (!insertedBlockquotePos) {
|
|
102
|
+
return;
|
|
106
103
|
}
|
|
104
|
+
stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
|
|
107
105
|
}
|
|
108
106
|
export function updateSelectionAfterReplace(_ref4) {
|
|
109
107
|
var tr = _ref4.tr;
|
|
@@ -1212,19 +1212,19 @@ export function handleParagraphBlockMarks(state, slice) {
|
|
|
1212
1212
|
paragraph = _schema$nodes3.paragraph,
|
|
1213
1213
|
heading = _schema$nodes3.heading;
|
|
1214
1214
|
var fontSize = schema.marks.fontSize;
|
|
1215
|
-
var
|
|
1215
|
+
var hasFontSize = !!fontSize;
|
|
1216
1216
|
|
|
1217
1217
|
// When copying from inside a container (e.g. panel, expand), ProseMirror wraps the
|
|
1218
1218
|
// content back in the container via addContext(), increasing openStart/openEnd. Unwrap
|
|
1219
1219
|
// so the paragraph (with its fontSize mark) becomes top-level.
|
|
1220
|
-
if (
|
|
1220
|
+
if (hasFontSize) {
|
|
1221
1221
|
slice = unwrapContainerNodesWithBlockMarks(slice, schema, fontSize);
|
|
1222
1222
|
}
|
|
1223
1223
|
var destinationListNode = (_findParentNodeOfType2 = findParentNodeOfType([bulletList, orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
|
|
1224
1224
|
var currentNode = typeof $from.node === 'function' ? $from.node() : undefined;
|
|
1225
1225
|
var isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === taskItem || $from.parent.type === taskItem;
|
|
1226
1226
|
var isInSmallTaskContext = !!blockTaskItem && ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === blockTaskItem || $from.parent.type === blockTaskItem || $from.parent.type === paragraph && $from.depth > 0 && $from.node($from.depth - 1).type === blockTaskItem);
|
|
1227
|
-
var destinationBlockMarkAttrs =
|
|
1227
|
+
var destinationBlockMarkAttrs = hasFontSize ? getDestinationFontSizeAttrs(destinationListNode, isInSmallTaskContext, $from, currentNode, fontSize) : false;
|
|
1228
1228
|
var isInHeadingContext = $from.parent.type === heading;
|
|
1229
1229
|
|
|
1230
1230
|
// If no paragraph in the slice contains marks, there's no need for special handling
|
|
@@ -1233,7 +1233,7 @@ export function handleParagraphBlockMarks(state, slice) {
|
|
|
1233
1233
|
if (!sliceHasTopLevelMarks(slice) && !destinationBlockMarkAttrs) {
|
|
1234
1234
|
return slice;
|
|
1235
1235
|
}
|
|
1236
|
-
var shouldNormalizeFontSizeForTarget =
|
|
1236
|
+
var shouldNormalizeFontSizeForTarget = hasFontSize && (!!destinationListNode || isInNormalTaskContext || isInSmallTaskContext || isInHeadingContext);
|
|
1237
1237
|
|
|
1238
1238
|
// If pasting a single paragraph into pre-existing content, match destination formatting.
|
|
1239
1239
|
// For bullet/ordered lists under small-text, we still need to normalize the paragraph block mark
|
|
@@ -1366,9 +1366,9 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1366
1366
|
var firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
|
|
1367
1367
|
var lastChildOfSlice = (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.lastChild;
|
|
1368
1368
|
var listContainerNodeTypes = [bulletList, orderedList];
|
|
1369
|
-
var
|
|
1370
|
-
var destinationListNode =
|
|
1371
|
-
var destinationListFontSizeAttrs =
|
|
1369
|
+
var hasFontSize = !!fontSize;
|
|
1370
|
+
var destinationListNode = hasFontSize ? (_findParentNodeOfType3 = findParentNodeOfType(listContainerNodeTypes)(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node : undefined;
|
|
1371
|
+
var destinationListFontSizeAttrs = hasFontSize ? getFirstParagraphBlockMarkAttrs(destinationListNode, fontSize) : false;
|
|
1372
1372
|
|
|
1373
1373
|
// In case user is pasting inline code,
|
|
1374
1374
|
// any backtick ` immediately preceding it should be removed.
|
|
@@ -1389,13 +1389,13 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1389
1389
|
var sliceContentBlockquoteListNodes = doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes);
|
|
1390
1390
|
|
|
1391
1391
|
// Compute once and reuse below to avoid traversing the slice twice.
|
|
1392
|
-
var sliceMarkTypes =
|
|
1393
|
-
var destinationIsEmpty =
|
|
1392
|
+
var sliceMarkTypes = hasFontSize ? getTopLevelMarkTypesInSlice(slice) : new Set();
|
|
1393
|
+
var destinationIsEmpty = hasFontSize && selection.$from.parent.type === paragraph && selection.$from.parent.textContent.length === 0;
|
|
1394
1394
|
|
|
1395
1395
|
// Capture the destination paragraph's non-fontSize block marks (e.g. alignment, indentation)
|
|
1396
1396
|
// before the paste so they can be restored if the paste replaces the paragraph entirely
|
|
1397
1397
|
// (which happens when small text is pasted with openStart=0).
|
|
1398
|
-
var destinationNonFontSizeBlockMarks =
|
|
1398
|
+
var destinationNonFontSizeBlockMarks = hasFontSize && selection.$from.parent.type === paragraph && sliceMarkTypes.has(fontSize) ? selection.$from.parent.marks.filter(function (m) {
|
|
1399
1399
|
return m.type !== fontSize;
|
|
1400
1400
|
}) : [];
|
|
1401
1401
|
|
|
@@ -1477,7 +1477,7 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1477
1477
|
}
|
|
1478
1478
|
|
|
1479
1479
|
// font size handling for pasting into lists or blockquotes
|
|
1480
|
-
if (
|
|
1480
|
+
if (hasFontSize && (isSliceContentListNodes || sliceContentBlockquoteListNodes)) {
|
|
1481
1481
|
var containingList = findParentNodeOfTypeClosestToPos(tr.selection.$from, listContainerNodeTypes);
|
|
1482
1482
|
if (containingList) {
|
|
1483
1483
|
reconcileBlockMarkForContainerAtPos(tr, containingList.pos, fontSize, isSliceContentListNodes ? destinationListFontSizeAttrs : false);
|
|
@@ -1485,13 +1485,13 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1485
1485
|
}
|
|
1486
1486
|
|
|
1487
1487
|
// font size handling for pasting into paragraphs (normal text) - preserve source style
|
|
1488
|
-
if (
|
|
1488
|
+
if (hasFontSize && destinationIsEmpty && !sliceMarkTypes.has(fontSize) && !destinationListNode && selection.$from.parent.type === paragraph && getBlockMarkAttrs(selection.$from.parent, fontSize)) {
|
|
1489
1489
|
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(selection.$from.pos), fontSize, false);
|
|
1490
1490
|
}
|
|
1491
1491
|
|
|
1492
1492
|
// Restore destination block marks (e.g. alignment) that were lost when pasting small text
|
|
1493
1493
|
// replaced the paragraph entirely (openStart=0 from container unwrap).
|
|
1494
|
-
if (
|
|
1494
|
+
if (hasFontSize && destinationNonFontSizeBlockMarks.length > 0) {
|
|
1495
1495
|
var pastedFrom = tr.mapping.map(selection.from, -1);
|
|
1496
1496
|
var pastedTo = tr.mapping.map(selection.to, 1);
|
|
1497
1497
|
var _iterator2 = _createForOfIteratorHelper(destinationNonFontSizeBlockMarks),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.6",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,30 +28,30 @@
|
|
|
28
28
|
"@atlaskit/editor-plugin-better-type-history": "^18.0.0",
|
|
29
29
|
"@atlaskit/editor-plugin-card": "^24.0.0",
|
|
30
30
|
"@atlaskit/editor-plugin-expand": "^19.0.0",
|
|
31
|
-
"@atlaskit/editor-plugin-extension": "^21.
|
|
31
|
+
"@atlaskit/editor-plugin-extension": "^21.1.0",
|
|
32
32
|
"@atlaskit/editor-plugin-feature-flags": "^17.0.0",
|
|
33
33
|
"@atlaskit/editor-plugin-list": "^20.0.0",
|
|
34
|
-
"@atlaskit/editor-plugin-media": "^20.
|
|
35
|
-
"@atlaskit/editor-plugin-mentions": "^20.
|
|
34
|
+
"@atlaskit/editor-plugin-media": "^20.1.0",
|
|
35
|
+
"@atlaskit/editor-plugin-mentions": "^20.1.0",
|
|
36
36
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
37
37
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
38
38
|
"@atlaskit/flag": "^18.5.0",
|
|
39
|
-
"@atlaskit/icon": "^37.
|
|
39
|
+
"@atlaskit/icon": "^37.7.0",
|
|
40
40
|
"@atlaskit/insm": "^3.0.0",
|
|
41
|
-
"@atlaskit/linking-common": "^12.
|
|
41
|
+
"@atlaskit/linking-common": "^12.2.0",
|
|
42
42
|
"@atlaskit/media-client": "^38.1.0",
|
|
43
43
|
"@atlaskit/media-common": "^14.6.0",
|
|
44
44
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
46
46
|
"@atlaskit/prosemirror-history": "^1.2.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^194.0.0",
|
|
48
48
|
"@atlaskit/tokens": "^16.12.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"lodash": "^4.17.21",
|
|
51
51
|
"uuid": "^11.1.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@atlaskit/editor-common": "^122.
|
|
54
|
+
"@atlaskit/editor-common": "^122.6.0",
|
|
55
55
|
"react": "^18.2.0 || ^19.2.0",
|
|
56
56
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
57
57
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|