@atlaskit/editor-common 88.0.0 → 88.1.0

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/insert/index.js +23 -2
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/paste/md-plugins/linkify-md-plugin.js +3 -6
  5. package/dist/cjs/preset/core-plugin/index.js +5 -2
  6. package/dist/cjs/styles/shared/expand.js +2 -1
  7. package/dist/cjs/ui/DropList/index.js +1 -1
  8. package/dist/cjs/utils/create-wrap-selection-transaction.js +1 -0
  9. package/dist/cjs/utils/hyperlink.js +1 -64
  10. package/dist/cjs/utils/index.js +6 -0
  11. package/dist/es2019/insert/index.js +21 -1
  12. package/dist/es2019/monitoring/error.js +1 -1
  13. package/dist/es2019/paste/md-plugins/linkify-md-plugin.js +1 -4
  14. package/dist/es2019/preset/core-plugin/index.js +5 -2
  15. package/dist/es2019/styles/shared/expand.js +2 -1
  16. package/dist/es2019/ui/DropList/index.js +1 -1
  17. package/dist/es2019/utils/create-wrap-selection-transaction.js +1 -1
  18. package/dist/es2019/utils/hyperlink.js +1 -60
  19. package/dist/es2019/utils/index.js +1 -1
  20. package/dist/esm/insert/index.js +20 -1
  21. package/dist/esm/monitoring/error.js +1 -1
  22. package/dist/esm/paste/md-plugins/linkify-md-plugin.js +3 -6
  23. package/dist/esm/preset/core-plugin/index.js +5 -2
  24. package/dist/esm/styles/shared/expand.js +2 -1
  25. package/dist/esm/ui/DropList/index.js +1 -1
  26. package/dist/esm/utils/create-wrap-selection-transaction.js +1 -1
  27. package/dist/esm/utils/hyperlink.js +1 -62
  28. package/dist/esm/utils/index.js +1 -1
  29. package/dist/types/insert/index.d.ts +6 -0
  30. package/dist/types/types/next-editor-plugin.d.ts +5 -1
  31. package/dist/types/utils/create-wrap-selection-transaction.d.ts +4 -0
  32. package/dist/types/utils/hyperlink.d.ts +1 -6
  33. package/dist/types/utils/index.d.ts +1 -1
  34. package/dist/types-ts4.5/insert/index.d.ts +6 -0
  35. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +5 -1
  36. package/dist/types-ts4.5/utils/create-wrap-selection-transaction.d.ts +4 -0
  37. package/dist/types-ts4.5/utils/hyperlink.d.ts +1 -6
  38. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  39. package/package.json +1 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 88.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`193f8c85e1a39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/193f8c85e1a39) -
8
+ [ux] [ED-24635]
9
+
10
+ - Disable Turn into dropdown options when wrapping is not supported
11
+ - Update expand icon so that it can show disabled status
12
+ - Update Turn into icon to show active status when dropdown is open
13
+
14
+ - [#132259](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/132259)
15
+ [`f5e633e11af26`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f5e633e11af26) -
16
+ Expose options for the core plugin so that you can opt out of scrolling within the editor after
17
+ using the "focus" action.
18
+ - [#132800](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/132800)
19
+ [`7868d12fa96a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7868d12fa96a1) -
20
+ EDM-9074 Remove platform.linking-platform.prevent-suspicious-linkification feature flag
21
+
22
+ ### Patch Changes
23
+
24
+ - [#133191](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/133191)
25
+ [`78a1927084934`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/78a1927084934) -
26
+ [ux] Remove icon migration feature gate and migrate new icons on primary toolbar
27
+
3
28
  ## 88.0.0
4
29
 
5
30
  ### Major Changes
@@ -4,7 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.shouldSplitSelectedNodeOnNodeInsertion = exports.safeInsert = exports.normaliseNestedLayout = exports.insertSelectedItem = exports.LookDirection = void 0;
7
+ exports.LookDirection = void 0;
8
+ exports.contentAllowedInCodeBlock = contentAllowedInCodeBlock;
9
+ exports.shouldSplitSelectedNodeOnNodeInsertion = exports.safeInsert = exports.normaliseNestedLayout = exports.insertSelectedItem = void 0;
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
11
  var _model = require("@atlaskit/editor-prosemirror/model");
10
12
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -270,4 +272,23 @@ var shouldSplitSelectedNodeOnNodeInsertion = exports.shouldSplitSelectedNodeOnNo
270
272
  return true;
271
273
  }
272
274
  return false;
273
- };
275
+ };
276
+
277
+ /**
278
+ * Check if the current selection contains any nodes that are not permitted
279
+ * as codeBlock child nodes. Note that this allows paragraphs and inline nodes
280
+ * as we extract their text content.
281
+ */
282
+ function contentAllowedInCodeBlock(state) {
283
+ var _state$selection = state.selection,
284
+ $from = _state$selection.$from,
285
+ $to = _state$selection.$to;
286
+ var isAllowedChild = true;
287
+ state.doc.nodesBetween($from.pos, $to.pos, function (node) {
288
+ if (!isAllowedChild) {
289
+ return false;
290
+ }
291
+ return isAllowedChild = node.type === state.schema.nodes.listItem || node.type === state.schema.nodes.bulletList || node.type === state.schema.nodes.orderedList || node.type === state.schema.nodes.paragraph || node.isInline || node.type === state.schema.nodes.panel || node.isText;
292
+ });
293
+ return isAllowedChild;
294
+ }
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "88.0.0";
20
+ var packageVersion = "88.1.0";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // TODO: Sanitise the URL instead of just removing it
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _linkifyIt = _interopRequireDefault(require("linkify-it"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
10
  var _utils = require("../../utils");
12
11
  // File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/linkify-md-plugin.ts
13
12
  // If changes are made to this file, please make the same update in the linked file.
@@ -67,11 +66,9 @@ var linkify = function linkify(state) {
67
66
  if (!links.length) {
68
67
  links = linkify.match(text) || [];
69
68
  }
70
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.prevent-suspicious-linkification')) {
71
- links = links.filter(function (link) {
72
- return (0, _utils.shouldAutoLinkifyMatch)(link);
73
- });
74
- }
69
+ links = links.filter(function (link) {
70
+ return (0, _utils.shouldAutoLinkifyMatch)(link);
71
+ });
75
72
 
76
73
  // Now split string to nodes
77
74
  var nodes = [];
@@ -25,13 +25,16 @@ var corePlugin = exports.corePlugin = function corePlugin(_ref) {
25
25
  return (0, _editorCommands.editorCommandToPMCommand)(command)(state, dispatch);
26
26
  },
27
27
  // Code copied from `EditorActions.focus()`
28
- focus: function focus() {
28
+ focus: function focus(options) {
29
+ var _options$scrollIntoVi;
29
30
  var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
30
31
  if (!editorView || editorView.hasFocus()) {
31
32
  return false;
32
33
  }
33
34
  editorView.focus();
34
- editorView.dispatch(editorView.state.tr.scrollIntoView());
35
+ if ((_options$scrollIntoVi = options === null || options === void 0 ? void 0 : options.scrollIntoView) !== null && _options$scrollIntoVi !== void 0 ? _options$scrollIntoVi : true) {
36
+ editorView.dispatch(editorView.state.tr.scrollIntoView());
37
+ }
35
38
  return true;
36
39
  },
37
40
  // Code copied from `EditorActions.blur()`
@@ -14,7 +14,8 @@ var expandIconWrapperStyle = exports.expandIconWrapperStyle = (0, _react.css)({
14
14
 
15
15
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
16
16
  var expandIconContainerStyle = exports.expandIconContainerStyle = (0, _react.css)({
17
- padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-050, 4px)", " 0 0")
17
+ display: 'flex',
18
+ alignItems: 'center'
18
19
  });
19
20
  var prefix = 'ak-editor-expand';
20
21
  var expandClassNames = exports.expandClassNames = {
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "88.0.0";
26
+ var packageVersion = "88.1.0";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  var DropList = /*#__PURE__*/function (_Component) {
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createWrapSelectionTransaction = createWrapSelectionTransaction;
7
+ exports.getWrappingOptions = getWrappingOptions;
7
8
  var _transform = require("@atlaskit/editor-prosemirror/transform");
8
9
  var _utils = require("@atlaskit/editor-prosemirror/utils");
9
10
  var _editorCoreUtils = require("./editor-core-utils");
@@ -10,13 +10,10 @@ exports.getLinkDomain = getLinkDomain;
10
10
  exports.isFromCurrentDomain = isFromCurrentDomain;
11
11
  exports.isLinkInMatches = void 0;
12
12
  exports.linkifyContent = linkifyContent;
13
- exports.linkifyContentNew = linkifyContentNew;
14
- exports.linkifyContentOld = linkifyContentOld;
15
13
  exports.normalizeUrl = normalizeUrl;
16
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
15
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
18
16
  var _adfSchema = require("@atlaskit/adf-schema");
19
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
17
  var _types = require("../analytics/types");
21
18
  var _shouldAutoLinkifyTld = require("./should-auto-linkify-tld");
22
19
  var _slice = require("./slice");
@@ -88,56 +85,11 @@ function normalizeUrl(url) {
88
85
  }
89
86
  return (0, _adfSchema.normalizeUrl)(url);
90
87
  }
91
- function linkifyContent(schema) {
92
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.prevent-suspicious-linkification')) {
93
- return linkifyContentNew(schema);
94
- }
95
- return linkifyContentOld(schema);
96
- }
97
-
98
- /**
99
- * Linkify content in a slice (eg. after a rich text paste)
100
- */
101
- function linkifyContentOld(schema) {
102
- return function (slice) {
103
- return (0, _slice.mapSlice)(slice, function (node, parent) {
104
- var isAllowedInParent = !parent || parent.type !== schema.nodes.codeBlock;
105
- var link = node.type.schema.marks.link;
106
- if (link === undefined) {
107
- throw new Error('Link not in schema - unable to linkify content');
108
- }
109
- if (isAllowedInParent && node.isText && !link.isInSet(node.marks)) {
110
- var linkified = [];
111
- var text = node.text;
112
- var matches = findLinkMatchesOld(text);
113
- var pos = 0;
114
- var filepaths = findFilepaths(text);
115
- matches.forEach(function (match) {
116
- if (isLinkInMatches(match.start, filepaths)) {
117
- return;
118
- }
119
- if (match.start > 0) {
120
- linkified.push(node.cut(pos, match.start));
121
- }
122
- linkified.push(node.cut(match.start, match.end).mark(link.create({
123
- href: normalizeUrl(match.href)
124
- }).addToSet(node.marks)));
125
- pos = match.end;
126
- });
127
- if (pos < text.length) {
128
- linkified.push(node.cut(pos));
129
- }
130
- return linkified;
131
- }
132
- return node;
133
- });
134
- };
135
- }
136
88
 
137
89
  /**
138
90
  * Linkify content in a slice (eg. after a rich text paste)
139
91
  */
140
- function linkifyContentNew(schema) {
92
+ function linkifyContent(schema) {
141
93
  return function (slice) {
142
94
  return (0, _slice.mapSlice)(slice, function (node, parent) {
143
95
  var isAllowedInParent = !parent || parent.type !== schema.nodes.codeBlock;
@@ -200,21 +152,6 @@ function findLinkMatches(text) {
200
152
  }
201
153
  return _adfSchema.linkify.match(text) || [];
202
154
  }
203
- function findLinkMatchesOld(text) {
204
- var matches = [];
205
- var linkMatches = text && _adfSchema.linkify.match(text);
206
- if (linkMatches && linkMatches.length > 0) {
207
- linkMatches.forEach(function (match) {
208
- matches.push({
209
- start: match.index,
210
- end: match.lastIndex,
211
- title: match.raw,
212
- href: match.url
213
- });
214
- });
215
- }
216
- return matches;
217
- }
218
155
  var findFilepaths = exports.findFilepaths = function findFilepaths(text) {
219
156
  var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
220
157
  // Creation of a copy of the RegExp is necessary as lastIndex is stored on it when we run .exec()
@@ -564,6 +564,12 @@ Object.defineProperty(exports, "getUnsupportedContentLevelData", {
564
564
  return _analytics.getUnsupportedContentLevelData;
565
565
  }
566
566
  });
567
+ Object.defineProperty(exports, "getWrappingOptions", {
568
+ enumerable: true,
569
+ get: function get() {
570
+ return _createWrapSelectionTransaction.getWrappingOptions;
571
+ }
572
+ });
567
573
  Object.defineProperty(exports, "gridTypeForLayout", {
568
574
  enumerable: true,
569
575
  get: function get() {
@@ -265,4 +265,24 @@ export const shouldSplitSelectedNodeOnNodeInsertion = ({
265
265
  return true;
266
266
  }
267
267
  return false;
268
- };
268
+ };
269
+
270
+ /**
271
+ * Check if the current selection contains any nodes that are not permitted
272
+ * as codeBlock child nodes. Note that this allows paragraphs and inline nodes
273
+ * as we extract their text content.
274
+ */
275
+ export function contentAllowedInCodeBlock(state) {
276
+ const {
277
+ $from,
278
+ $to
279
+ } = state.selection;
280
+ let isAllowedChild = true;
281
+ state.doc.nodesBetween($from.pos, $to.pos, node => {
282
+ if (!isAllowedChild) {
283
+ return false;
284
+ }
285
+ return isAllowedChild = node.type === state.schema.nodes.listItem || node.type === state.schema.nodes.bulletList || node.type === state.schema.nodes.orderedList || node.type === state.schema.nodes.paragraph || node.isInline || node.type === state.schema.nodes.panel || node.isText;
286
+ });
287
+ return isAllowedChild;
288
+ }
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "88.0.0";
4
+ const packageVersion = "88.1.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -5,7 +5,6 @@
5
5
 
6
6
  import LinkifyIt from 'linkify-it';
7
7
  import { linkifyMatch } from '@atlaskit/adf-schema';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import { findFilepaths, isLinkInMatches, shouldAutoLinkifyMatch } from '../../utils';
10
9
 
11
10
  // modified version of the original markdown-it Linkify plugin
@@ -61,9 +60,7 @@ const linkify = state => {
61
60
  if (!links.length) {
62
61
  links = linkify.match(text) || [];
63
62
  }
64
- if (getBooleanFF('platform.linking-platform.prevent-suspicious-linkification')) {
65
- links = links.filter(link => shouldAutoLinkifyMatch(link));
66
- }
63
+ links = links.filter(link => shouldAutoLinkifyMatch(link));
67
64
 
68
65
  // Now split string to nodes
69
66
  const nodes = [];
@@ -23,13 +23,16 @@ export const corePlugin = ({
23
23
  return editorCommandToPMCommand(command)(state, dispatch);
24
24
  },
25
25
  // Code copied from `EditorActions.focus()`
26
- focus: () => {
26
+ focus: options => {
27
+ var _options$scrollIntoVi;
27
28
  const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
28
29
  if (!editorView || editorView.hasFocus()) {
29
30
  return false;
30
31
  }
31
32
  editorView.focus();
32
- editorView.dispatch(editorView.state.tr.scrollIntoView());
33
+ if ((_options$scrollIntoVi = options === null || options === void 0 ? void 0 : options.scrollIntoView) !== null && _options$scrollIntoVi !== void 0 ? _options$scrollIntoVi : true) {
34
+ editorView.dispatch(editorView.state.tr.scrollIntoView());
35
+ }
33
36
  return true;
34
37
  },
35
38
  // Code copied from `EditorActions.blur()`
@@ -7,7 +7,8 @@ export const expandIconWrapperStyle = css({
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
9
9
  export const expandIconContainerStyle = css({
10
- padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-050, 4px)"} 0 0`
10
+ display: 'flex',
11
+ alignItems: 'center'
11
12
  });
12
13
  const prefix = 'ak-editor-expand';
13
14
  export const expandClassNames = {
@@ -12,7 +12,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
12
12
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
13
13
  import Layer from '../Layer';
14
14
  const packageName = "@atlaskit/editor-common";
15
- const packageVersion = "88.0.0";
15
+ const packageVersion = "88.1.0";
16
16
  const halfFocusRing = 1;
17
17
  const dropOffset = '0, 8';
18
18
  class DropList extends Component {
@@ -40,7 +40,7 @@ export function createWrapSelectionTransaction({
40
40
  }
41
41
  return tr;
42
42
  }
43
- function getWrappingOptions(state, type, nodeAttributes) {
43
+ export function getWrappingOptions(state, type, nodeAttributes) {
44
44
  const {
45
45
  $from,
46
46
  $to
@@ -2,7 +2,6 @@
2
2
  // If changes are made to this file, please make the same update in the linked file.
3
3
 
4
4
  import { isSafeUrl, linkify, normalizeUrl as normaliseLinkHref } from '@atlaskit/adf-schema';
5
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics/types';
7
6
  import { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
8
7
  import { mapSlice } from './slice';
@@ -59,54 +58,11 @@ export function normalizeUrl(url) {
59
58
  }
60
59
  return normaliseLinkHref(url);
61
60
  }
62
- export function linkifyContent(schema) {
63
- if (getBooleanFF('platform.linking-platform.prevent-suspicious-linkification')) {
64
- return linkifyContentNew(schema);
65
- }
66
- return linkifyContentOld(schema);
67
- }
68
61
 
69
62
  /**
70
63
  * Linkify content in a slice (eg. after a rich text paste)
71
64
  */
72
- export function linkifyContentOld(schema) {
73
- return slice => mapSlice(slice, (node, parent) => {
74
- const isAllowedInParent = !parent || parent.type !== schema.nodes.codeBlock;
75
- const link = node.type.schema.marks.link;
76
- if (link === undefined) {
77
- throw new Error('Link not in schema - unable to linkify content');
78
- }
79
- if (isAllowedInParent && node.isText && !link.isInSet(node.marks)) {
80
- const linkified = [];
81
- const text = node.text;
82
- const matches = findLinkMatchesOld(text);
83
- let pos = 0;
84
- const filepaths = findFilepaths(text);
85
- matches.forEach(match => {
86
- if (isLinkInMatches(match.start, filepaths)) {
87
- return;
88
- }
89
- if (match.start > 0) {
90
- linkified.push(node.cut(pos, match.start));
91
- }
92
- linkified.push(node.cut(match.start, match.end).mark(link.create({
93
- href: normalizeUrl(match.href)
94
- }).addToSet(node.marks)));
95
- pos = match.end;
96
- });
97
- if (pos < text.length) {
98
- linkified.push(node.cut(pos));
99
- }
100
- return linkified;
101
- }
102
- return node;
103
- });
104
- }
105
-
106
- /**
107
- * Linkify content in a slice (eg. after a rich text paste)
108
- */
109
- export function linkifyContentNew(schema) {
65
+ export function linkifyContent(schema) {
110
66
  return slice => mapSlice(slice, (node, parent) => {
111
67
  const isAllowedInParent = !parent || parent.type !== schema.nodes.codeBlock;
112
68
  const link = node.type.schema.marks.link;
@@ -167,21 +123,6 @@ function findLinkMatches(text) {
167
123
  }
168
124
  return linkify.match(text) || [];
169
125
  }
170
- function findLinkMatchesOld(text) {
171
- const matches = [];
172
- let linkMatches = text && linkify.match(text);
173
- if (linkMatches && linkMatches.length > 0) {
174
- linkMatches.forEach(match => {
175
- matches.push({
176
- start: match.index,
177
- end: match.lastIndex,
178
- title: match.raw,
179
- href: match.url
180
- });
181
- });
182
- }
183
- return matches;
184
- }
185
126
  export const findFilepaths = (text, offset = 0) => {
186
127
  // Creation of a copy of the RegExp is necessary as lastIndex is stored on it when we run .exec()
187
128
  const localRegExp = new RegExp(FILEPATH_REGEXP);
@@ -216,7 +216,7 @@ export function isInEmptyLine(state) {
216
216
  return isEmptyParagraph(node) && hasDocAsParent($anchor);
217
217
  }
218
218
  export { dedupe } from './dedupe';
219
- export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
219
+ export { createWrapSelectionTransaction, getWrappingOptions } from './create-wrap-selection-transaction';
220
220
  export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
221
221
  export { wrapSelectionIn } from './wrap-selection-in';
222
222
  export { toJSON, nodeToJSON } from './nodes';
@@ -263,4 +263,23 @@ export var shouldSplitSelectedNodeOnNodeInsertion = function shouldSplitSelected
263
263
  return true;
264
264
  }
265
265
  return false;
266
- };
266
+ };
267
+
268
+ /**
269
+ * Check if the current selection contains any nodes that are not permitted
270
+ * as codeBlock child nodes. Note that this allows paragraphs and inline nodes
271
+ * as we extract their text content.
272
+ */
273
+ export function contentAllowedInCodeBlock(state) {
274
+ var _state$selection = state.selection,
275
+ $from = _state$selection.$from,
276
+ $to = _state$selection.$to;
277
+ var isAllowedChild = true;
278
+ state.doc.nodesBetween($from.pos, $to.pos, function (node) {
279
+ if (!isAllowedChild) {
280
+ return false;
281
+ }
282
+ return isAllowedChild = node.type === state.schema.nodes.listItem || node.type === state.schema.nodes.bulletList || node.type === state.schema.nodes.orderedList || node.type === state.schema.nodes.paragraph || node.isInline || node.type === state.schema.nodes.panel || node.isText;
283
+ });
284
+ return isAllowedChild;
285
+ }
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "88.0.0";
10
+ var packageVersion = "88.1.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -5,7 +5,6 @@
5
5
 
6
6
  import LinkifyIt from 'linkify-it';
7
7
  import { linkifyMatch } from '@atlaskit/adf-schema';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import { findFilepaths, isLinkInMatches, shouldAutoLinkifyMatch } from '../../utils';
10
9
 
11
10
  // modified version of the original markdown-it Linkify plugin
@@ -61,11 +60,9 @@ var linkify = function linkify(state) {
61
60
  if (!links.length) {
62
61
  links = linkify.match(text) || [];
63
62
  }
64
- if (getBooleanFF('platform.linking-platform.prevent-suspicious-linkification')) {
65
- links = links.filter(function (link) {
66
- return shouldAutoLinkifyMatch(link);
67
- });
68
- }
63
+ links = links.filter(function (link) {
64
+ return shouldAutoLinkifyMatch(link);
65
+ });
69
66
 
70
67
  // Now split string to nodes
71
68
  var nodes = [];
@@ -20,13 +20,16 @@ export var corePlugin = function corePlugin(_ref) {
20
20
  return editorCommandToPMCommand(command)(state, dispatch);
21
21
  },
22
22
  // Code copied from `EditorActions.focus()`
23
- focus: function focus() {
23
+ focus: function focus(options) {
24
+ var _options$scrollIntoVi;
24
25
  var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
25
26
  if (!editorView || editorView.hasFocus()) {
26
27
  return false;
27
28
  }
28
29
  editorView.focus();
29
- editorView.dispatch(editorView.state.tr.scrollIntoView());
30
+ if ((_options$scrollIntoVi = options === null || options === void 0 ? void 0 : options.scrollIntoView) !== null && _options$scrollIntoVi !== void 0 ? _options$scrollIntoVi : true) {
31
+ editorView.dispatch(editorView.state.tr.scrollIntoView());
32
+ }
30
33
  return true;
31
34
  },
32
35
  // Code copied from `EditorActions.blur()`
@@ -7,7 +7,8 @@ export var expandIconWrapperStyle = css({
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
9
9
  export var expandIconContainerStyle = css({
10
- padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-050, 4px)", " 0 0")
10
+ display: 'flex',
11
+ alignItems: 'center'
11
12
  });
12
13
  var prefix = 'ak-editor-expand';
13
14
  export var expandClassNames = {
@@ -20,7 +20,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
20
20
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "88.0.0";
23
+ var packageVersion = "88.1.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  var DropList = /*#__PURE__*/function (_Component) {
@@ -35,7 +35,7 @@ export function createWrapSelectionTransaction(_ref) {
35
35
  }
36
36
  return tr;
37
37
  }
38
- function getWrappingOptions(state, type, nodeAttributes) {
38
+ export function getWrappingOptions(state, type, nodeAttributes) {
39
39
  var _state$selection = state.selection,
40
40
  $from = _state$selection.$from,
41
41
  $to = _state$selection.$to;
@@ -4,7 +4,6 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  // If changes are made to this file, please make the same update in the linked file.
5
5
 
6
6
  import { isSafeUrl, linkify, normalizeUrl as normaliseLinkHref } from '@atlaskit/adf-schema';
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics/types';
9
8
  import { shouldAutoLinkifyMatch } from './should-auto-linkify-tld';
10
9
  import { mapSlice } from './slice';
@@ -75,56 +74,11 @@ export function normalizeUrl(url) {
75
74
  }
76
75
  return normaliseLinkHref(url);
77
76
  }
78
- export function linkifyContent(schema) {
79
- if (getBooleanFF('platform.linking-platform.prevent-suspicious-linkification')) {
80
- return linkifyContentNew(schema);
81
- }
82
- return linkifyContentOld(schema);
83
- }
84
-
85
- /**
86
- * Linkify content in a slice (eg. after a rich text paste)
87
- */
88
- export function linkifyContentOld(schema) {
89
- return function (slice) {
90
- return mapSlice(slice, function (node, parent) {
91
- var isAllowedInParent = !parent || parent.type !== schema.nodes.codeBlock;
92
- var link = node.type.schema.marks.link;
93
- if (link === undefined) {
94
- throw new Error('Link not in schema - unable to linkify content');
95
- }
96
- if (isAllowedInParent && node.isText && !link.isInSet(node.marks)) {
97
- var linkified = [];
98
- var text = node.text;
99
- var matches = findLinkMatchesOld(text);
100
- var pos = 0;
101
- var filepaths = findFilepaths(text);
102
- matches.forEach(function (match) {
103
- if (isLinkInMatches(match.start, filepaths)) {
104
- return;
105
- }
106
- if (match.start > 0) {
107
- linkified.push(node.cut(pos, match.start));
108
- }
109
- linkified.push(node.cut(match.start, match.end).mark(link.create({
110
- href: normalizeUrl(match.href)
111
- }).addToSet(node.marks)));
112
- pos = match.end;
113
- });
114
- if (pos < text.length) {
115
- linkified.push(node.cut(pos));
116
- }
117
- return linkified;
118
- }
119
- return node;
120
- });
121
- };
122
- }
123
77
 
124
78
  /**
125
79
  * Linkify content in a slice (eg. after a rich text paste)
126
80
  */
127
- export function linkifyContentNew(schema) {
81
+ export function linkifyContent(schema) {
128
82
  return function (slice) {
129
83
  return mapSlice(slice, function (node, parent) {
130
84
  var isAllowedInParent = !parent || parent.type !== schema.nodes.codeBlock;
@@ -187,21 +141,6 @@ function findLinkMatches(text) {
187
141
  }
188
142
  return linkify.match(text) || [];
189
143
  }
190
- function findLinkMatchesOld(text) {
191
- var matches = [];
192
- var linkMatches = text && linkify.match(text);
193
- if (linkMatches && linkMatches.length > 0) {
194
- linkMatches.forEach(function (match) {
195
- matches.push({
196
- start: match.index,
197
- end: match.lastIndex,
198
- title: match.raw,
199
- href: match.url
200
- });
201
- });
202
- }
203
- return matches;
204
- }
205
144
  export var findFilepaths = function findFilepaths(text) {
206
145
  var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
207
146
  // Creation of a copy of the RegExp is necessary as lastIndex is stored on it when we run .exec()
@@ -219,7 +219,7 @@ export function isInEmptyLine(state) {
219
219
  return isEmptyParagraph(node) && hasDocAsParent($anchor);
220
220
  }
221
221
  export { dedupe } from './dedupe';
222
- export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
222
+ export { createWrapSelectionTransaction, getWrappingOptions } from './create-wrap-selection-transaction';
223
223
  export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
224
224
  export { wrapSelectionIn } from './wrap-selection-in';
225
225
  export { toJSON, nodeToJSON } from './nodes';
@@ -24,3 +24,9 @@ export declare const shouldSplitSelectedNodeOnNodeInsertion: ({ parentNodeType,
24
24
  grandParentNodeType: NodeType;
25
25
  content: Node;
26
26
  }) => boolean;
27
+ /**
28
+ * Check if the current selection contains any nodes that are not permitted
29
+ * as codeBlock child nodes. Note that this allows paragraphs and inline nodes
30
+ * as we extract their text content.
31
+ */
32
+ export declare function contentAllowedInCodeBlock(state: EditorState): boolean;
@@ -33,9 +33,13 @@ export type CorePlugin = NextEditorPlugin<'core', {
33
33
  * Calls the focus method of the `EditorView` and scrolls the
34
34
  * current selection into view.
35
35
  *
36
+ * @param options
37
+ * @param options.scrollIntoView (boolean) if the view should also scroll when focusing. True by default
36
38
  * @returns (boolean) if the focus was successful
37
39
  */
38
- focus: () => boolean;
40
+ focus: (options?: {
41
+ scrollIntoView: boolean;
42
+ }) => boolean;
39
43
  /**
40
44
  * Blurs the editor.
41
45
  *
@@ -13,3 +13,7 @@ export declare function createWrapSelectionTransaction({ state, type, nodeAttrib
13
13
  type: NodeType;
14
14
  nodeAttributes?: Record<string, any>;
15
15
  }): import("prosemirror-state").Transaction;
16
+ export declare function getWrappingOptions(state: EditorState, type: NodeType, nodeAttributes?: Record<string, any>): {
17
+ range: any;
18
+ wrapping: any;
19
+ };
@@ -15,15 +15,10 @@ export declare class LinkMatcher {
15
15
  * Adds protocol to url if needed.
16
16
  */
17
17
  export declare function normalizeUrl(url?: string | null): string;
18
- export declare function linkifyContent(schema: Schema): (slice: Slice) => Slice;
19
18
  /**
20
19
  * Linkify content in a slice (eg. after a rich text paste)
21
20
  */
22
- export declare function linkifyContentOld(schema: Schema): (slice: Slice) => Slice;
23
- /**
24
- * Linkify content in a slice (eg. after a rich text paste)
25
- */
26
- export declare function linkifyContentNew(schema: Schema): (slice: Slice) => Slice;
21
+ export declare function linkifyContent(schema: Schema): (slice: Slice) => Slice;
27
22
  export declare function getLinkDomain(url: string): string;
28
23
  export declare function isFromCurrentDomain(url: string): boolean;
29
24
  interface filepathMatch {
@@ -85,7 +85,7 @@ export declare const isEmptyNode: (schema: Schema) => (node: PMNode) => boolean;
85
85
  export declare function isNodeEmpty(node?: PMNode): boolean;
86
86
  export declare function isInEmptyLine(state: EditorState): boolean;
87
87
  export { dedupe } from './dedupe';
88
- export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
88
+ export { createWrapSelectionTransaction, getWrappingOptions, } from './create-wrap-selection-transaction';
89
89
  export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
90
90
  export { wrapSelectionIn } from './wrap-selection-in';
91
91
  export { toJSON, nodeToJSON } from './nodes';
@@ -24,3 +24,9 @@ export declare const shouldSplitSelectedNodeOnNodeInsertion: ({ parentNodeType,
24
24
  grandParentNodeType: NodeType;
25
25
  content: Node;
26
26
  }) => boolean;
27
+ /**
28
+ * Check if the current selection contains any nodes that are not permitted
29
+ * as codeBlock child nodes. Note that this allows paragraphs and inline nodes
30
+ * as we extract their text content.
31
+ */
32
+ export declare function contentAllowedInCodeBlock(state: EditorState): boolean;
@@ -33,9 +33,13 @@ export type CorePlugin = NextEditorPlugin<'core', {
33
33
  * Calls the focus method of the `EditorView` and scrolls the
34
34
  * current selection into view.
35
35
  *
36
+ * @param options
37
+ * @param options.scrollIntoView (boolean) if the view should also scroll when focusing. True by default
36
38
  * @returns (boolean) if the focus was successful
37
39
  */
38
- focus: () => boolean;
40
+ focus: (options?: {
41
+ scrollIntoView: boolean;
42
+ }) => boolean;
39
43
  /**
40
44
  * Blurs the editor.
41
45
  *
@@ -13,3 +13,7 @@ export declare function createWrapSelectionTransaction({ state, type, nodeAttrib
13
13
  type: NodeType;
14
14
  nodeAttributes?: Record<string, any>;
15
15
  }): import("prosemirror-state").Transaction;
16
+ export declare function getWrappingOptions(state: EditorState, type: NodeType, nodeAttributes?: Record<string, any>): {
17
+ range: any;
18
+ wrapping: any;
19
+ };
@@ -15,15 +15,10 @@ export declare class LinkMatcher {
15
15
  * Adds protocol to url if needed.
16
16
  */
17
17
  export declare function normalizeUrl(url?: string | null): string;
18
- export declare function linkifyContent(schema: Schema): (slice: Slice) => Slice;
19
18
  /**
20
19
  * Linkify content in a slice (eg. after a rich text paste)
21
20
  */
22
- export declare function linkifyContentOld(schema: Schema): (slice: Slice) => Slice;
23
- /**
24
- * Linkify content in a slice (eg. after a rich text paste)
25
- */
26
- export declare function linkifyContentNew(schema: Schema): (slice: Slice) => Slice;
21
+ export declare function linkifyContent(schema: Schema): (slice: Slice) => Slice;
27
22
  export declare function getLinkDomain(url: string): string;
28
23
  export declare function isFromCurrentDomain(url: string): boolean;
29
24
  interface filepathMatch {
@@ -85,7 +85,7 @@ export declare const isEmptyNode: (schema: Schema) => (node: PMNode) => boolean;
85
85
  export declare function isNodeEmpty(node?: PMNode): boolean;
86
86
  export declare function isInEmptyLine(state: EditorState): boolean;
87
87
  export { dedupe } from './dedupe';
88
- export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
88
+ export { createWrapSelectionTransaction, getWrappingOptions, } from './create-wrap-selection-transaction';
89
89
  export { transformNodeIntoListItem } from './insert-node-into-ordered-list';
90
90
  export { wrapSelectionIn } from './wrap-selection-in';
91
91
  export { toJSON, nodeToJSON } from './nodes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "88.0.0",
3
+ "version": "88.1.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -218,9 +218,6 @@
218
218
  "platform.editor.media.extended-resize-experience": {
219
219
  "type": "boolean"
220
220
  },
221
- "platform.linking-platform.prevent-suspicious-linkification": {
222
- "type": "boolean"
223
- },
224
221
  "platform.editor.media.inline-image.base-support": {
225
222
  "type": "boolean"
226
223
  },