@atlaskit/editor-plugin-paste 9.1.3 → 9.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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 9.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 9.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`1c4534dc921e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1c4534dc921e6) -
14
+ Preserve small text formatting when converting selections to task lists across block menu, block
15
+ type, and paste flows
16
+ - Updated dependencies
17
+
3
18
  ## 9.1.3
4
19
 
5
20
  ### Patch Changes
@@ -7,11 +7,13 @@ exports.insertSliceForLists = insertSliceForLists;
7
7
  exports.insertSliceForTaskInsideList = insertSliceForTaskInsideList;
8
8
  exports.insertSliceInsideBlockquote = insertSliceInsideBlockquote;
9
9
  exports.updateSelectionAfterReplace = updateSelectionAfterReplace;
10
+ var _commands = require("@atlaskit/editor-common/commands");
10
11
  var _utils = require("@atlaskit/editor-common/utils");
11
12
  var _model = require("@atlaskit/editor-prosemirror/model");
12
13
  var _state = require("@atlaskit/editor-prosemirror/state");
13
14
  var _transform = require("@atlaskit/editor-prosemirror/transform");
14
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
16
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
17
  var _index = require("../index");
16
18
  var _lists = require("./lists");
17
19
  function insertSliceForLists(_ref) {
@@ -67,6 +69,32 @@ function insertSliceForLists(_ref) {
67
69
  }
68
70
  tr.replaceSelection(slice);
69
71
  }
72
+ var stripFontSizeInsideBlockquoteLists = function stripFontSizeInsideBlockquoteLists(tr, blockquotePos) {
73
+ var _tr$doc$type$schema = tr.doc.type.schema,
74
+ fontSize = _tr$doc$type$schema.marks.fontSize,
75
+ _tr$doc$type$schema$n = _tr$doc$type$schema.nodes,
76
+ paragraph = _tr$doc$type$schema$n.paragraph,
77
+ listItem = _tr$doc$type$schema$n.listItem,
78
+ taskItem = _tr$doc$type$schema$n.taskItem,
79
+ blockTaskItem = _tr$doc$type$schema$n.blockTaskItem;
80
+ var listItemParentNodeTypes = [listItem, taskItem, blockTaskItem];
81
+ if (!fontSize || !(0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
82
+ return;
83
+ }
84
+ var containingBlockquote = tr.doc.nodeAt(blockquotePos);
85
+ if (!containingBlockquote) {
86
+ return;
87
+ }
88
+ var from = blockquotePos + 1;
89
+ var to = blockquotePos + containingBlockquote.nodeSize - 1;
90
+ (0, _commands.createToggleBlockMarkOnRangeNext)(fontSize, function () {
91
+ return false;
92
+ }, function (_schema, node, parent) {
93
+ return node.type === paragraph && !!parent && listItemParentNodeTypes.some(function (nodeType) {
94
+ return nodeType === parent.type;
95
+ });
96
+ })(from, to, tr);
97
+ };
70
98
  function insertSliceInsideBlockquote(_ref3) {
71
99
  var tr = _ref3.tr,
72
100
  slice = _ref3.slice;
@@ -77,6 +105,13 @@ function insertSliceInsideBlockquote(_ref3) {
77
105
  tr: tr
78
106
  });
79
107
  tr.replaceSelection(slice);
108
+ if ((0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
109
+ var insertedBlockquotePos = (0, _utils2.findParentNodeOfType)(schema.nodes.blockquote)(tr.selection);
110
+ if (!insertedBlockquotePos) {
111
+ return;
112
+ }
113
+ stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
114
+ }
80
115
  }
81
116
  function updateSelectionAfterReplace(_ref4) {
82
117
  var tr = _ref4.tr;
@@ -920,11 +920,20 @@ function handleParagraphBlockMarks(state, slice) {
920
920
  var schema = state.schema,
921
921
  selection = state.selection,
922
922
  $from = state.selection.$from;
923
- var destinationListNode = (_findParentNodeOfType2 = (0, _utils2.findParentNodeOfType)([schema.nodes.bulletList, schema.nodes.orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
923
+ var _schema$nodes3 = schema.nodes,
924
+ bulletList = _schema$nodes3.bulletList,
925
+ orderedList = _schema$nodes3.orderedList,
926
+ blockTaskItem = _schema$nodes3.blockTaskItem,
927
+ taskItem = _schema$nodes3.taskItem,
928
+ paragraph = _schema$nodes3.paragraph,
929
+ heading = _schema$nodes3.heading;
930
+ var fontSize = schema.marks.fontSize;
931
+ var destinationListNode = (_findParentNodeOfType2 = (0, _utils2.findParentNodeOfType)([bulletList, orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
924
932
  var currentNode = typeof $from.node === 'function' ? $from.node() : undefined;
925
- var isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === schema.nodes.taskItem || $from.parent.type === schema.nodes.taskItem;
926
- var isInSmallTaskContext = schema.nodes.blockTaskItem && (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === schema.nodes.blockTaskItem || schema.nodes.blockTaskItem && $from.parent.type === schema.nodes.blockTaskItem || schema.nodes.blockTaskItem && $from.parent.type === schema.nodes.paragraph && $from.depth > 0 && $from.node($from.depth - 1).type === schema.nodes.blockTaskItem;
927
- var destinationBlockMarkAttrs = (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) && schema.marks.fontSize ? destinationListNode ? (0, _lists.getFirstParagraphBlockMarkAttrs)(destinationListNode, schema.marks.fontSize) : isInSmallTaskContext ? (0, _lists.getBlockMarkAttrs)($from.parent, schema.marks.fontSize) || (0, _lists.getFirstParagraphBlockMarkAttrs)(currentNode, schema.marks.fontSize) : false : false;
933
+ var isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === taskItem || $from.parent.type === taskItem;
934
+ 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);
935
+ var isSmallFontSizeEnabled = (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) && !!fontSize;
936
+ var destinationBlockMarkAttrs = isSmallFontSizeEnabled ? destinationListNode ? (0, _lists.getFirstParagraphBlockMarkAttrs)(destinationListNode, fontSize) : isInSmallTaskContext ? (0, _lists.getBlockMarkAttrs)($from.parent, fontSize) || (0, _lists.getFirstParagraphBlockMarkAttrs)(currentNode, fontSize) : false : false;
928
937
 
929
938
  // If no paragraph in the slice contains marks, there's no need for special handling
930
939
  // unless we're pasting into a small-text list and need to add the destination block mark.
@@ -932,7 +941,7 @@ function handleParagraphBlockMarks(state, slice) {
932
941
  if (!sliceHasTopLevelMarks(slice) && !destinationBlockMarkAttrs) {
933
942
  return slice;
934
943
  }
935
- var shouldNormalizeFontSizeForTarget = (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) && !!schema.marks.fontSize && (!!destinationListNode || isInNormalTaskContext || !!isInSmallTaskContext);
944
+ var shouldNormalizeFontSizeForTarget = isSmallFontSizeEnabled && (!!destinationListNode || isInNormalTaskContext || isInSmallTaskContext);
936
945
 
937
946
  // If pasting a single paragraph into pre-existing content, match destination formatting.
938
947
  // For bullet/ordered lists under small-text, we still need to normalize the paragraph block mark
@@ -961,19 +970,19 @@ function handleParagraphBlockMarks(state, slice) {
961
970
  } finally {
962
971
  _iterator.f();
963
972
  }
964
- var fontSizeMarkType = shouldNormalizeFontSizeForTarget ? schema.marks.fontSize : undefined;
965
973
  var normalizedContent = (0, _utils.mapSlice)(slice, function (node) {
966
- if (node.type === schema.nodes.paragraph) {
974
+ if (node.type === paragraph) {
967
975
  var paragraphMarks = node.marks.filter(function (mark) {
968
976
  return !forbiddenMarkTypes.includes(mark.type);
969
977
  });
970
- var normalizedMarks = fontSizeMarkType ? paragraphMarks.filter(function (mark) {
971
- return mark.type !== fontSizeMarkType;
972
- }) : paragraphMarks;
973
- return schema.nodes.paragraph.createChecked(undefined, node.content, destinationBlockMarkAttrs && fontSizeMarkType ? normalizedMarks.concat(fontSizeMarkType.create(destinationBlockMarkAttrs)) : normalizedMarks);
974
- } else if (node.type === schema.nodes.heading) {
978
+ return paragraph.createChecked(undefined, node.content, destinationBlockMarkAttrs ? paragraphMarks.filter(function (mark) {
979
+ return mark.type !== fontSize;
980
+ }).concat(fontSize.create(destinationBlockMarkAttrs)) : shouldNormalizeFontSizeForTarget ? paragraphMarks.filter(function (mark) {
981
+ return mark.type !== fontSize;
982
+ }) : paragraphMarks);
983
+ } else if (node.type === heading) {
975
984
  // Preserve heading attributes to keep formatting
976
- return schema.nodes.heading.createChecked(node.attrs, node.content, node.marks.filter(function (mark) {
985
+ return heading.createChecked(node.attrs, node.content, node.marks.filter(function (mark) {
977
986
  return !forbiddenMarkTypes.includes(mark.type);
978
987
  }));
979
988
  }
@@ -1036,19 +1045,37 @@ function flattenNestedListInSlice(slice) {
1036
1045
  var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
1037
1046
  return new _model.Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
1038
1047
  }
1048
+ var doesSliceContainBlockquoteListNodes = function doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes) {
1049
+ var _firstChildOfSlice$ty, _lastChildOfSlice$typ;
1050
+ var firstChildOfSlice = slice.content.firstChild;
1051
+ var lastChildOfSlice = slice.content.lastChild;
1052
+ var isFirstChildBlockquoteListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'blockquote' && listContainerNodeTypes.some(function (nodeType) {
1053
+ var _firstChildOfSlice$co;
1054
+ return nodeType === (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co === void 0 ? void 0 : _firstChildOfSlice$co.type);
1055
+ });
1056
+ var isLastChildBlockquoteListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'blockquote' && listContainerNodeTypes.some(function (nodeType) {
1057
+ var _lastChildOfSlice$con;
1058
+ return nodeType === (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$con = lastChildOfSlice.content.firstChild) === null || _lastChildOfSlice$con === void 0 ? void 0 : _lastChildOfSlice$con.type);
1059
+ });
1060
+ return isFirstChildBlockquoteListNode || isLastChildBlockquoteListNode;
1061
+ };
1039
1062
  function handleRichText(slice, queueCardsFromChangedTr) {
1040
1063
  return function (state, dispatch) {
1041
- var _slice$content, _slice$content2, _findParentNodeOfType3, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
1064
+ var _slice$content, _slice$content2, _findParentNodeOfType3, _firstChildOfSlice$ty2, _lastChildOfSlice$typ2, _panelParentOverCurre;
1042
1065
  var _state$schema$nodes4 = state.schema.nodes,
1043
1066
  codeBlock = _state$schema$nodes4.codeBlock,
1044
1067
  heading = _state$schema$nodes4.heading,
1045
1068
  paragraph = _state$schema$nodes4.paragraph,
1046
- panel = _state$schema$nodes4.panel;
1069
+ panel = _state$schema$nodes4.panel,
1070
+ bulletList = _state$schema$nodes4.bulletList,
1071
+ orderedList = _state$schema$nodes4.orderedList;
1072
+ var fontSize = state.schema.marks.fontSize;
1047
1073
  var selection = state.selection,
1048
1074
  schema = state.schema;
1049
1075
  var firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
1050
1076
  var lastChildOfSlice = (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.lastChild;
1051
- var destinationListFontSizeAttrs = (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? (0, _lists.getFirstParagraphBlockMarkAttrs)((_findParentNodeOfType3 = (0, _utils2.findParentNodeOfType)([schema.nodes.bulletList, schema.nodes.orderedList])(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node, schema.marks.fontSize) : false;
1077
+ var listContainerNodeTypes = [bulletList, orderedList];
1078
+ var destinationListFontSizeAttrs = (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? (0, _lists.getFirstParagraphBlockMarkAttrs)((_findParentNodeOfType3 = (0, _utils2.findParentNodeOfType)(listContainerNodeTypes)(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node, fontSize) : false;
1052
1079
 
1053
1080
  // In case user is pasting inline code,
1054
1081
  // any backtick ` immediately preceding it should be removed.
@@ -1063,9 +1090,10 @@ function handleRichText(slice, queueCardsFromChangedTr) {
1063
1090
  var isFirstChildListNode = (0, _utils.isListNode)(firstChildOfSlice);
1064
1091
  var isLastChildListNode = (0, _utils.isListNode)(lastChildOfSlice);
1065
1092
  var isSliceContentListNodes = isFirstChildListNode || isLastChildListNode;
1066
- var isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'taskList';
1067
- var isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'taskList';
1093
+ var isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'taskList';
1094
+ var isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ2 = lastChildOfSlice.type) === null || _lastChildOfSlice$typ2 === void 0 ? void 0 : _lastChildOfSlice$typ2.name) === 'taskList';
1068
1095
  var isSliceContentTaskListNodes = isFirstChildTaskListNode || isLastChildTaskListNode;
1096
+ var sliceContentBlockquoteListNodes = doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes);
1069
1097
 
1070
1098
  // We want to use safeInsert to insert invalid content, as it inserts at the closest non schema violating position
1071
1099
  // rather than spliting the selection parent node in half (which is what replaceSelection does)
@@ -1082,8 +1110,8 @@ function handleRichText(slice, queueCardsFromChangedTr) {
1082
1110
  schema: schema
1083
1111
  });
1084
1112
  } else if (noNeedForSafeInsert && !((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_flexible_list_indentation', 'isEnabled', true) && checkTaskListInList(state, slice))) {
1085
- var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
1086
- if ((firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co !== void 0 && _firstChildOfSlice$co.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co2 === void 0 ? void 0 : _firstChildOfSlice$co2.type.name)) {
1113
+ var _firstChildOfSlice$ty3, _firstChildOfSlice$co2, _firstChildOfSlice$co3;
1114
+ if ((firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty3 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty3 === void 0 ? void 0 : _firstChildOfSlice$ty3.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co2 !== void 0 && _firstChildOfSlice$co2.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co3 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co3 === void 0 ? void 0 : _firstChildOfSlice$co3.type.name)) {
1087
1115
  // checks if parent node is a blockquote and child node is either a bulletlist or orderedlist or mediaSingle
1088
1116
  (0, _edgeCases.insertSliceInsideBlockquote)({
1089
1117
  tr: tr,
@@ -1133,10 +1161,10 @@ function handleRichText(slice, queueCardsFromChangedTr) {
1133
1161
  }
1134
1162
  }
1135
1163
  }
1136
- if ((0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) && isSliceContentListNodes) {
1137
- var containingList = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(tr.mapping.map(selection.from)), [schema.nodes.bulletList, schema.nodes.orderedList]);
1164
+ if ((isSliceContentListNodes || sliceContentBlockquoteListNodes) && fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
1165
+ var containingList = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.selection.$from, listContainerNodeTypes);
1138
1166
  if (containingList) {
1139
- (0, _lists.reconcileBlockMarkForContainerAtPos)(tr, containingList.pos, schema.marks.fontSize, destinationListFontSizeAttrs);
1167
+ (0, _lists.reconcileBlockMarkForContainerAtPos)(tr, containingList.pos, fontSize, isSliceContentListNodes ? destinationListFontSizeAttrs : false);
1140
1168
  }
1141
1169
  }
1142
1170
  tr.setStoredMarks([]);
@@ -1,8 +1,10 @@
1
+ import { createToggleBlockMarkOnRangeNext } from '@atlaskit/editor-common/commands';
1
2
  import { isListNode } from '@atlaskit/editor-common/utils';
2
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
5
6
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
8
  import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
7
9
  import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
8
10
  export function insertSliceForLists({
@@ -63,6 +65,30 @@ export function insertSliceForLists({
63
65
  }
64
66
  tr.replaceSelection(slice);
65
67
  }
68
+ const stripFontSizeInsideBlockquoteLists = (tr, blockquotePos) => {
69
+ const {
70
+ marks: {
71
+ fontSize
72
+ },
73
+ nodes: {
74
+ paragraph,
75
+ listItem,
76
+ taskItem,
77
+ blockTaskItem
78
+ }
79
+ } = tr.doc.type.schema;
80
+ const listItemParentNodeTypes = [listItem, taskItem, blockTaskItem];
81
+ if (!fontSize || !expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
82
+ return;
83
+ }
84
+ const containingBlockquote = tr.doc.nodeAt(blockquotePos);
85
+ if (!containingBlockquote) {
86
+ return;
87
+ }
88
+ const from = blockquotePos + 1;
89
+ const to = blockquotePos + containingBlockquote.nodeSize - 1;
90
+ createToggleBlockMarkOnRangeNext(fontSize, () => false, (_schema, node, parent) => node.type === paragraph && !!parent && listItemParentNodeTypes.some(nodeType => nodeType === parent.type))(from, to, tr);
91
+ };
66
92
  export function insertSliceInsideBlockquote({
67
93
  tr,
68
94
  slice
@@ -76,6 +102,13 @@ export function insertSliceInsideBlockquote({
76
102
  tr
77
103
  });
78
104
  tr.replaceSelection(slice);
105
+ if (expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
106
+ const insertedBlockquotePos = findParentNodeOfType(schema.nodes.blockquote)(tr.selection);
107
+ if (!insertedBlockquotePos) {
108
+ return;
109
+ }
110
+ stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
111
+ }
79
112
  }
80
113
  export function updateSelectionAfterReplace({
81
114
  tr
@@ -910,11 +910,23 @@ export function handleParagraphBlockMarks(state, slice) {
910
910
  $from
911
911
  }
912
912
  } = state;
913
- const destinationListNode = (_findParentNodeOfType2 = findParentNodeOfType([schema.nodes.bulletList, schema.nodes.orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
913
+ const {
914
+ bulletList,
915
+ orderedList,
916
+ blockTaskItem,
917
+ taskItem,
918
+ paragraph,
919
+ heading
920
+ } = schema.nodes;
921
+ const {
922
+ fontSize
923
+ } = schema.marks;
924
+ const destinationListNode = (_findParentNodeOfType2 = findParentNodeOfType([bulletList, orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
914
925
  const currentNode = typeof $from.node === 'function' ? $from.node() : undefined;
915
- const isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === schema.nodes.taskItem || $from.parent.type === schema.nodes.taskItem;
916
- const isInSmallTaskContext = schema.nodes.blockTaskItem && (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === schema.nodes.blockTaskItem || schema.nodes.blockTaskItem && $from.parent.type === schema.nodes.blockTaskItem || schema.nodes.blockTaskItem && $from.parent.type === schema.nodes.paragraph && $from.depth > 0 && $from.node($from.depth - 1).type === schema.nodes.blockTaskItem;
917
- const destinationBlockMarkAttrs = expValEquals('platform_editor_small_font_size', 'isEnabled', true) && schema.marks.fontSize ? destinationListNode ? getFirstParagraphBlockMarkAttrs(destinationListNode, schema.marks.fontSize) : isInSmallTaskContext ? getBlockMarkAttrs($from.parent, schema.marks.fontSize) || getFirstParagraphBlockMarkAttrs(currentNode, schema.marks.fontSize) : false : false;
926
+ const isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === taskItem || $from.parent.type === taskItem;
927
+ 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);
928
+ const isSmallFontSizeEnabled = expValEquals('platform_editor_small_font_size', 'isEnabled', true) && !!fontSize;
929
+ const destinationBlockMarkAttrs = isSmallFontSizeEnabled ? destinationListNode ? getFirstParagraphBlockMarkAttrs(destinationListNode, fontSize) : isInSmallTaskContext ? getBlockMarkAttrs($from.parent, fontSize) || getFirstParagraphBlockMarkAttrs(currentNode, fontSize) : false : false;
918
930
 
919
931
  // If no paragraph in the slice contains marks, there's no need for special handling
920
932
  // unless we're pasting into a small-text list and need to add the destination block mark.
@@ -922,7 +934,7 @@ export function handleParagraphBlockMarks(state, slice) {
922
934
  if (!sliceHasTopLevelMarks(slice) && !destinationBlockMarkAttrs) {
923
935
  return slice;
924
936
  }
925
- const shouldNormalizeFontSizeForTarget = expValEquals('platform_editor_small_font_size', 'isEnabled', true) && !!schema.marks.fontSize && (!!destinationListNode || isInNormalTaskContext || !!isInSmallTaskContext);
937
+ const shouldNormalizeFontSizeForTarget = isSmallFontSizeEnabled && (!!destinationListNode || isInNormalTaskContext || isInSmallTaskContext);
926
938
 
927
939
  // If pasting a single paragraph into pre-existing content, match destination formatting.
928
940
  // For bullet/ordered lists under small-text, we still need to normalize the paragraph block mark
@@ -942,15 +954,13 @@ export function handleParagraphBlockMarks(state, slice) {
942
954
  forbiddenMarkTypes.push(markType);
943
955
  }
944
956
  }
945
- const fontSizeMarkType = shouldNormalizeFontSizeForTarget ? schema.marks.fontSize : undefined;
946
957
  const normalizedContent = mapSlice(slice, node => {
947
- if (node.type === schema.nodes.paragraph) {
958
+ if (node.type === paragraph) {
948
959
  const paragraphMarks = node.marks.filter(mark => !forbiddenMarkTypes.includes(mark.type));
949
- const normalizedMarks = fontSizeMarkType ? paragraphMarks.filter(mark => mark.type !== fontSizeMarkType) : paragraphMarks;
950
- return schema.nodes.paragraph.createChecked(undefined, node.content, destinationBlockMarkAttrs && fontSizeMarkType ? normalizedMarks.concat(fontSizeMarkType.create(destinationBlockMarkAttrs)) : normalizedMarks);
951
- } else if (node.type === schema.nodes.heading) {
960
+ return paragraph.createChecked(undefined, node.content, destinationBlockMarkAttrs ? paragraphMarks.filter(mark => mark.type !== fontSize).concat(fontSize.create(destinationBlockMarkAttrs)) : shouldNormalizeFontSizeForTarget ? paragraphMarks.filter(mark => mark.type !== fontSize) : paragraphMarks);
961
+ } else if (node.type === heading) {
952
962
  // Preserve heading attributes to keep formatting
953
- return schema.nodes.heading.createChecked(node.attrs, node.content, node.marks.filter(mark => !forbiddenMarkTypes.includes(mark.type)));
963
+ return heading.createChecked(node.attrs, node.content, node.marks.filter(mark => !forbiddenMarkTypes.includes(mark.type)));
954
964
  }
955
965
  return node;
956
966
  });
@@ -1011,22 +1021,42 @@ export function flattenNestedListInSlice(slice) {
1011
1021
  const contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
1012
1022
  return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
1013
1023
  }
1024
+ const doesSliceContainBlockquoteListNodes = (slice, listContainerNodeTypes) => {
1025
+ var _firstChildOfSlice$ty, _lastChildOfSlice$typ;
1026
+ const firstChildOfSlice = slice.content.firstChild;
1027
+ const lastChildOfSlice = slice.content.lastChild;
1028
+ const isFirstChildBlockquoteListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'blockquote' && listContainerNodeTypes.some(nodeType => {
1029
+ var _firstChildOfSlice$co;
1030
+ return nodeType === (firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co === void 0 ? void 0 : _firstChildOfSlice$co.type);
1031
+ });
1032
+ const isLastChildBlockquoteListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 ? void 0 : (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'blockquote' && listContainerNodeTypes.some(nodeType => {
1033
+ var _lastChildOfSlice$con;
1034
+ return nodeType === (lastChildOfSlice === null || lastChildOfSlice === void 0 ? void 0 : (_lastChildOfSlice$con = lastChildOfSlice.content.firstChild) === null || _lastChildOfSlice$con === void 0 ? void 0 : _lastChildOfSlice$con.type);
1035
+ });
1036
+ return isFirstChildBlockquoteListNode || isLastChildBlockquoteListNode;
1037
+ };
1014
1038
  export function handleRichText(slice, queueCardsFromChangedTr) {
1015
1039
  return (state, dispatch) => {
1016
- var _slice$content, _slice$content2, _findParentNodeOfType3, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
1040
+ var _slice$content, _slice$content2, _findParentNodeOfType3, _firstChildOfSlice$ty2, _lastChildOfSlice$typ2, _panelParentOverCurre;
1017
1041
  const {
1018
1042
  codeBlock,
1019
1043
  heading,
1020
1044
  paragraph,
1021
- panel
1045
+ panel,
1046
+ bulletList,
1047
+ orderedList
1022
1048
  } = state.schema.nodes;
1049
+ const {
1050
+ fontSize
1051
+ } = state.schema.marks;
1023
1052
  const {
1024
1053
  selection,
1025
1054
  schema
1026
1055
  } = state;
1027
1056
  const firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
1028
1057
  const lastChildOfSlice = (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.lastChild;
1029
- const destinationListFontSizeAttrs = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getFirstParagraphBlockMarkAttrs((_findParentNodeOfType3 = findParentNodeOfType([schema.nodes.bulletList, schema.nodes.orderedList])(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node, schema.marks.fontSize) : false;
1058
+ const listContainerNodeTypes = [bulletList, orderedList];
1059
+ const destinationListFontSizeAttrs = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getFirstParagraphBlockMarkAttrs((_findParentNodeOfType3 = findParentNodeOfType(listContainerNodeTypes)(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node, fontSize) : false;
1030
1060
 
1031
1061
  // In case user is pasting inline code,
1032
1062
  // any backtick ` immediately preceding it should be removed.
@@ -1041,9 +1071,10 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1041
1071
  const isFirstChildListNode = isListNode(firstChildOfSlice);
1042
1072
  const isLastChildListNode = isListNode(lastChildOfSlice);
1043
1073
  const isSliceContentListNodes = isFirstChildListNode || isLastChildListNode;
1044
- const isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'taskList';
1045
- const isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 ? void 0 : (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'taskList';
1074
+ const isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'taskList';
1075
+ const isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 ? void 0 : (_lastChildOfSlice$typ2 = lastChildOfSlice.type) === null || _lastChildOfSlice$typ2 === void 0 ? void 0 : _lastChildOfSlice$typ2.name) === 'taskList';
1046
1076
  const isSliceContentTaskListNodes = isFirstChildTaskListNode || isLastChildTaskListNode;
1077
+ const sliceContentBlockquoteListNodes = doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes);
1047
1078
 
1048
1079
  // We want to use safeInsert to insert invalid content, as it inserts at the closest non schema violating position
1049
1080
  // rather than spliting the selection parent node in half (which is what replaceSelection does)
@@ -1060,8 +1091,8 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1060
1091
  schema
1061
1092
  });
1062
1093
  } else if (noNeedForSafeInsert && !(expValEqualsNoExposure('platform_editor_flexible_list_indentation', 'isEnabled', true) && checkTaskListInList(state, slice))) {
1063
- var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
1064
- if ((firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co !== void 0 && _firstChildOfSlice$co.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co2 === void 0 ? void 0 : _firstChildOfSlice$co2.type.name)) {
1094
+ var _firstChildOfSlice$ty3, _firstChildOfSlice$co2, _firstChildOfSlice$co3;
1095
+ if ((firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$ty3 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty3 === void 0 ? void 0 : _firstChildOfSlice$ty3.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co2 !== void 0 && _firstChildOfSlice$co2.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$co3 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co3 === void 0 ? void 0 : _firstChildOfSlice$co3.type.name)) {
1065
1096
  // checks if parent node is a blockquote and child node is either a bulletlist or orderedlist or mediaSingle
1066
1097
  insertSliceInsideBlockquote({
1067
1098
  tr,
@@ -1111,10 +1142,10 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1111
1142
  }
1112
1143
  }
1113
1144
  }
1114
- if (expValEquals('platform_editor_small_font_size', 'isEnabled', true) && isSliceContentListNodes) {
1115
- const containingList = findParentNodeOfTypeClosestToPos(tr.doc.resolve(tr.mapping.map(selection.from)), [schema.nodes.bulletList, schema.nodes.orderedList]);
1145
+ if ((isSliceContentListNodes || sliceContentBlockquoteListNodes) && fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
1146
+ const containingList = findParentNodeOfTypeClosestToPos(tr.selection.$from, listContainerNodeTypes);
1116
1147
  if (containingList) {
1117
- reconcileBlockMarkForContainerAtPos(tr, containingList.pos, schema.marks.fontSize, destinationListFontSizeAttrs);
1148
+ reconcileBlockMarkForContainerAtPos(tr, containingList.pos, fontSize, isSliceContentListNodes ? destinationListFontSizeAttrs : false);
1118
1149
  }
1119
1150
  }
1120
1151
  tr.setStoredMarks([]);
@@ -1,8 +1,10 @@
1
+ import { createToggleBlockMarkOnRangeNext } from '@atlaskit/editor-common/commands';
1
2
  import { isListNode } from '@atlaskit/editor-common/utils';
2
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
5
6
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
8
  import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
7
9
  import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
8
10
  export function insertSliceForLists(_ref) {
@@ -58,6 +60,32 @@ export function insertSliceForLists(_ref) {
58
60
  }
59
61
  tr.replaceSelection(slice);
60
62
  }
63
+ var stripFontSizeInsideBlockquoteLists = function stripFontSizeInsideBlockquoteLists(tr, blockquotePos) {
64
+ var _tr$doc$type$schema = tr.doc.type.schema,
65
+ fontSize = _tr$doc$type$schema.marks.fontSize,
66
+ _tr$doc$type$schema$n = _tr$doc$type$schema.nodes,
67
+ paragraph = _tr$doc$type$schema$n.paragraph,
68
+ listItem = _tr$doc$type$schema$n.listItem,
69
+ taskItem = _tr$doc$type$schema$n.taskItem,
70
+ blockTaskItem = _tr$doc$type$schema$n.blockTaskItem;
71
+ var listItemParentNodeTypes = [listItem, taskItem, blockTaskItem];
72
+ if (!fontSize || !expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
73
+ return;
74
+ }
75
+ var containingBlockquote = tr.doc.nodeAt(blockquotePos);
76
+ if (!containingBlockquote) {
77
+ return;
78
+ }
79
+ var from = blockquotePos + 1;
80
+ var to = blockquotePos + containingBlockquote.nodeSize - 1;
81
+ createToggleBlockMarkOnRangeNext(fontSize, function () {
82
+ return false;
83
+ }, function (_schema, node, parent) {
84
+ return node.type === paragraph && !!parent && listItemParentNodeTypes.some(function (nodeType) {
85
+ return nodeType === parent.type;
86
+ });
87
+ })(from, to, tr);
88
+ };
61
89
  export function insertSliceInsideBlockquote(_ref3) {
62
90
  var tr = _ref3.tr,
63
91
  slice = _ref3.slice;
@@ -68,6 +96,13 @@ export function insertSliceInsideBlockquote(_ref3) {
68
96
  tr: tr
69
97
  });
70
98
  tr.replaceSelection(slice);
99
+ if (expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
100
+ var insertedBlockquotePos = findParentNodeOfType(schema.nodes.blockquote)(tr.selection);
101
+ if (!insertedBlockquotePos) {
102
+ return;
103
+ }
104
+ stripFontSizeInsideBlockquoteLists(tr, insertedBlockquotePos.pos);
105
+ }
71
106
  }
72
107
  export function updateSelectionAfterReplace(_ref4) {
73
108
  var tr = _ref4.tr;
@@ -893,11 +893,20 @@ export function handleParagraphBlockMarks(state, slice) {
893
893
  var schema = state.schema,
894
894
  selection = state.selection,
895
895
  $from = state.selection.$from;
896
- var destinationListNode = (_findParentNodeOfType2 = findParentNodeOfType([schema.nodes.bulletList, schema.nodes.orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
896
+ var _schema$nodes3 = schema.nodes,
897
+ bulletList = _schema$nodes3.bulletList,
898
+ orderedList = _schema$nodes3.orderedList,
899
+ blockTaskItem = _schema$nodes3.blockTaskItem,
900
+ taskItem = _schema$nodes3.taskItem,
901
+ paragraph = _schema$nodes3.paragraph,
902
+ heading = _schema$nodes3.heading;
903
+ var fontSize = schema.marks.fontSize;
904
+ var destinationListNode = (_findParentNodeOfType2 = findParentNodeOfType([bulletList, orderedList])(selection)) === null || _findParentNodeOfType2 === void 0 ? void 0 : _findParentNodeOfType2.node;
897
905
  var currentNode = typeof $from.node === 'function' ? $from.node() : undefined;
898
- var isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === schema.nodes.taskItem || $from.parent.type === schema.nodes.taskItem;
899
- var isInSmallTaskContext = schema.nodes.blockTaskItem && (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === schema.nodes.blockTaskItem || schema.nodes.blockTaskItem && $from.parent.type === schema.nodes.blockTaskItem || schema.nodes.blockTaskItem && $from.parent.type === schema.nodes.paragraph && $from.depth > 0 && $from.node($from.depth - 1).type === schema.nodes.blockTaskItem;
900
- var destinationBlockMarkAttrs = expValEquals('platform_editor_small_font_size', 'isEnabled', true) && schema.marks.fontSize ? destinationListNode ? getFirstParagraphBlockMarkAttrs(destinationListNode, schema.marks.fontSize) : isInSmallTaskContext ? getBlockMarkAttrs($from.parent, schema.marks.fontSize) || getFirstParagraphBlockMarkAttrs(currentNode, schema.marks.fontSize) : false : false;
906
+ var isInNormalTaskContext = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === taskItem || $from.parent.type === taskItem;
907
+ 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);
908
+ var isSmallFontSizeEnabled = expValEquals('platform_editor_small_font_size', 'isEnabled', true) && !!fontSize;
909
+ var destinationBlockMarkAttrs = isSmallFontSizeEnabled ? destinationListNode ? getFirstParagraphBlockMarkAttrs(destinationListNode, fontSize) : isInSmallTaskContext ? getBlockMarkAttrs($from.parent, fontSize) || getFirstParagraphBlockMarkAttrs(currentNode, fontSize) : false : false;
901
910
 
902
911
  // If no paragraph in the slice contains marks, there's no need for special handling
903
912
  // unless we're pasting into a small-text list and need to add the destination block mark.
@@ -905,7 +914,7 @@ export function handleParagraphBlockMarks(state, slice) {
905
914
  if (!sliceHasTopLevelMarks(slice) && !destinationBlockMarkAttrs) {
906
915
  return slice;
907
916
  }
908
- var shouldNormalizeFontSizeForTarget = expValEquals('platform_editor_small_font_size', 'isEnabled', true) && !!schema.marks.fontSize && (!!destinationListNode || isInNormalTaskContext || !!isInSmallTaskContext);
917
+ var shouldNormalizeFontSizeForTarget = isSmallFontSizeEnabled && (!!destinationListNode || isInNormalTaskContext || isInSmallTaskContext);
909
918
 
910
919
  // If pasting a single paragraph into pre-existing content, match destination formatting.
911
920
  // For bullet/ordered lists under small-text, we still need to normalize the paragraph block mark
@@ -934,19 +943,19 @@ export function handleParagraphBlockMarks(state, slice) {
934
943
  } finally {
935
944
  _iterator.f();
936
945
  }
937
- var fontSizeMarkType = shouldNormalizeFontSizeForTarget ? schema.marks.fontSize : undefined;
938
946
  var normalizedContent = mapSlice(slice, function (node) {
939
- if (node.type === schema.nodes.paragraph) {
947
+ if (node.type === paragraph) {
940
948
  var paragraphMarks = node.marks.filter(function (mark) {
941
949
  return !forbiddenMarkTypes.includes(mark.type);
942
950
  });
943
- var normalizedMarks = fontSizeMarkType ? paragraphMarks.filter(function (mark) {
944
- return mark.type !== fontSizeMarkType;
945
- }) : paragraphMarks;
946
- return schema.nodes.paragraph.createChecked(undefined, node.content, destinationBlockMarkAttrs && fontSizeMarkType ? normalizedMarks.concat(fontSizeMarkType.create(destinationBlockMarkAttrs)) : normalizedMarks);
947
- } else if (node.type === schema.nodes.heading) {
951
+ return paragraph.createChecked(undefined, node.content, destinationBlockMarkAttrs ? paragraphMarks.filter(function (mark) {
952
+ return mark.type !== fontSize;
953
+ }).concat(fontSize.create(destinationBlockMarkAttrs)) : shouldNormalizeFontSizeForTarget ? paragraphMarks.filter(function (mark) {
954
+ return mark.type !== fontSize;
955
+ }) : paragraphMarks);
956
+ } else if (node.type === heading) {
948
957
  // Preserve heading attributes to keep formatting
949
- return schema.nodes.heading.createChecked(node.attrs, node.content, node.marks.filter(function (mark) {
958
+ return heading.createChecked(node.attrs, node.content, node.marks.filter(function (mark) {
950
959
  return !forbiddenMarkTypes.includes(mark.type);
951
960
  }));
952
961
  }
@@ -1009,19 +1018,37 @@ export function flattenNestedListInSlice(slice) {
1009
1018
  var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
1010
1019
  return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
1011
1020
  }
1021
+ var doesSliceContainBlockquoteListNodes = function doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes) {
1022
+ var _firstChildOfSlice$ty, _lastChildOfSlice$typ;
1023
+ var firstChildOfSlice = slice.content.firstChild;
1024
+ var lastChildOfSlice = slice.content.lastChild;
1025
+ var isFirstChildBlockquoteListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'blockquote' && listContainerNodeTypes.some(function (nodeType) {
1026
+ var _firstChildOfSlice$co;
1027
+ return nodeType === (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co === void 0 ? void 0 : _firstChildOfSlice$co.type);
1028
+ });
1029
+ var isLastChildBlockquoteListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'blockquote' && listContainerNodeTypes.some(function (nodeType) {
1030
+ var _lastChildOfSlice$con;
1031
+ return nodeType === (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$con = lastChildOfSlice.content.firstChild) === null || _lastChildOfSlice$con === void 0 ? void 0 : _lastChildOfSlice$con.type);
1032
+ });
1033
+ return isFirstChildBlockquoteListNode || isLastChildBlockquoteListNode;
1034
+ };
1012
1035
  export function handleRichText(slice, queueCardsFromChangedTr) {
1013
1036
  return function (state, dispatch) {
1014
- var _slice$content, _slice$content2, _findParentNodeOfType3, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
1037
+ var _slice$content, _slice$content2, _findParentNodeOfType3, _firstChildOfSlice$ty2, _lastChildOfSlice$typ2, _panelParentOverCurre;
1015
1038
  var _state$schema$nodes4 = state.schema.nodes,
1016
1039
  codeBlock = _state$schema$nodes4.codeBlock,
1017
1040
  heading = _state$schema$nodes4.heading,
1018
1041
  paragraph = _state$schema$nodes4.paragraph,
1019
- panel = _state$schema$nodes4.panel;
1042
+ panel = _state$schema$nodes4.panel,
1043
+ bulletList = _state$schema$nodes4.bulletList,
1044
+ orderedList = _state$schema$nodes4.orderedList;
1045
+ var fontSize = state.schema.marks.fontSize;
1020
1046
  var selection = state.selection,
1021
1047
  schema = state.schema;
1022
1048
  var firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
1023
1049
  var lastChildOfSlice = (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.lastChild;
1024
- var destinationListFontSizeAttrs = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getFirstParagraphBlockMarkAttrs((_findParentNodeOfType3 = findParentNodeOfType([schema.nodes.bulletList, schema.nodes.orderedList])(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node, schema.marks.fontSize) : false;
1050
+ var listContainerNodeTypes = [bulletList, orderedList];
1051
+ var destinationListFontSizeAttrs = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getFirstParagraphBlockMarkAttrs((_findParentNodeOfType3 = findParentNodeOfType(listContainerNodeTypes)(selection)) === null || _findParentNodeOfType3 === void 0 ? void 0 : _findParentNodeOfType3.node, fontSize) : false;
1025
1052
 
1026
1053
  // In case user is pasting inline code,
1027
1054
  // any backtick ` immediately preceding it should be removed.
@@ -1036,9 +1063,10 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1036
1063
  var isFirstChildListNode = isListNode(firstChildOfSlice);
1037
1064
  var isLastChildListNode = isListNode(lastChildOfSlice);
1038
1065
  var isSliceContentListNodes = isFirstChildListNode || isLastChildListNode;
1039
- var isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'taskList';
1040
- var isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'taskList';
1066
+ var isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'taskList';
1067
+ var isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ2 = lastChildOfSlice.type) === null || _lastChildOfSlice$typ2 === void 0 ? void 0 : _lastChildOfSlice$typ2.name) === 'taskList';
1041
1068
  var isSliceContentTaskListNodes = isFirstChildTaskListNode || isLastChildTaskListNode;
1069
+ var sliceContentBlockquoteListNodes = doesSliceContainBlockquoteListNodes(slice, listContainerNodeTypes);
1042
1070
 
1043
1071
  // We want to use safeInsert to insert invalid content, as it inserts at the closest non schema violating position
1044
1072
  // rather than spliting the selection parent node in half (which is what replaceSelection does)
@@ -1055,8 +1083,8 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1055
1083
  schema: schema
1056
1084
  });
1057
1085
  } else if (noNeedForSafeInsert && !(expValEqualsNoExposure('platform_editor_flexible_list_indentation', 'isEnabled', true) && checkTaskListInList(state, slice))) {
1058
- var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
1059
- if ((firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co !== void 0 && _firstChildOfSlice$co.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co2 === void 0 ? void 0 : _firstChildOfSlice$co2.type.name)) {
1086
+ var _firstChildOfSlice$ty3, _firstChildOfSlice$co2, _firstChildOfSlice$co3;
1087
+ if ((firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty3 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty3 === void 0 ? void 0 : _firstChildOfSlice$ty3.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co2 !== void 0 && _firstChildOfSlice$co2.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co3 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co3 === void 0 ? void 0 : _firstChildOfSlice$co3.type.name)) {
1060
1088
  // checks if parent node is a blockquote and child node is either a bulletlist or orderedlist or mediaSingle
1061
1089
  insertSliceInsideBlockquote({
1062
1090
  tr: tr,
@@ -1106,10 +1134,10 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1106
1134
  }
1107
1135
  }
1108
1136
  }
1109
- if (expValEquals('platform_editor_small_font_size', 'isEnabled', true) && isSliceContentListNodes) {
1110
- var containingList = findParentNodeOfTypeClosestToPos(tr.doc.resolve(tr.mapping.map(selection.from)), [schema.nodes.bulletList, schema.nodes.orderedList]);
1137
+ if ((isSliceContentListNodes || sliceContentBlockquoteListNodes) && fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
1138
+ var containingList = findParentNodeOfTypeClosestToPos(tr.selection.$from, listContainerNodeTypes);
1111
1139
  if (containingList) {
1112
- reconcileBlockMarkForContainerAtPos(tr, containingList.pos, schema.marks.fontSize, destinationListFontSizeAttrs);
1140
+ reconcileBlockMarkForContainerAtPos(tr, containingList.pos, fontSize, isSliceContentListNodes ? destinationListFontSizeAttrs : false);
1113
1141
  }
1114
1142
  }
1115
1143
  tr.setStoredMarks([]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "9.1.3",
3
+ "version": "9.1.5",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,13 +42,13 @@
42
42
  "@atlaskit/editor-prosemirror": "^7.3.0",
43
43
  "@atlaskit/editor-tables": "^2.9.0",
44
44
  "@atlaskit/flag": "^17.9.0",
45
- "@atlaskit/icon": "^33.1.0",
45
+ "@atlaskit/icon": "^34.0.0",
46
46
  "@atlaskit/insm": "^0.4.0",
47
47
  "@atlaskit/media-client": "^36.0.0",
48
48
  "@atlaskit/media-common": "^13.0.0",
49
49
  "@atlaskit/platform-feature-flags": "^1.1.0",
50
50
  "@atlaskit/prosemirror-history": "^0.2.0",
51
- "@atlaskit/tmp-editor-statsig": "^52.0.0",
51
+ "@atlaskit/tmp-editor-statsig": "^53.0.0",
52
52
  "@atlaskit/tokens": "^11.4.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "lodash": "^4.17.21",
@@ -56,7 +56,7 @@
56
56
  "uuid": "^3.1.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^112.13.0",
59
+ "@atlaskit/editor-common": "^112.15.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0"
62
62
  },