@atlaskit/editor-plugin-paste 4.1.8 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.1.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [`a2cd8c46a3e94`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a2cd8c46a3e94) -
14
+ EDITOR-1442 Bump adf-schema
15
+ - Updated dependencies
16
+
3
17
  ## 4.1.8
4
18
 
5
19
  ### Patch Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.createPlugin = createPlugin;
8
8
  exports.isInsideBlockQuote = void 0;
9
+ exports.isSharePointUrl = isSharePointUrl;
9
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _uuid = _interopRequireDefault(require("uuid"));
@@ -43,6 +44,27 @@ var isInsideBlockQuote = exports.isInsideBlockQuote = function isInsideBlockQuot
43
44
  return (0, _utils2.hasParentNodeOfType)(blockquote)(state.selection);
44
45
  };
45
46
  var PASTE = 'Editor Paste Plugin Paste Duration';
47
+ function isSharePointUrl(url) {
48
+ if (!url) {
49
+ return false;
50
+ }
51
+ try {
52
+ var urlObj = new URL(url);
53
+ var hostname = urlObj.hostname.toLowerCase();
54
+ var protocol = urlObj.protocol.toLowerCase();
55
+
56
+ // Only accept HTTPS URLs for security
57
+ if (protocol !== 'https:') {
58
+ return false;
59
+ }
60
+
61
+ // Check if hostname ends with the trusted domains (not just contains them)
62
+ return hostname.endsWith('sharepoint.com') || hostname.endsWith('onedrive.com') || hostname.endsWith('onedrive.live.com');
63
+ } catch (_unused) {
64
+ // If URL parsing fails, return false for safety
65
+ return false;
66
+ }
67
+ }
46
68
  function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
47
69
  var _pluginInjectionApi$a;
48
70
  var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
@@ -478,6 +500,20 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
478
500
  return true;
479
501
  }
480
502
 
503
+ // Special handling for SharePoint URLs generated from Share button
504
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
505
+ if ((0, _platformFeatureFlags.fg)('platform_editor_sharepoint_url_smart_card_fallback') && isSharePointUrl(text)) {
506
+ // Create an inline card directly for SharePoint URLs to show the "Connect" button
507
+ var inlineCardNode = schema.nodes.inlineCard.create({
508
+ url: text
509
+ });
510
+ var cardSlice = new _model.Slice(_model.Fragment.from(inlineCardNode), 0, 0);
511
+ if (dispatch) {
512
+ dispatch(state.tr.replaceSelection(cardSlice));
513
+ }
514
+ return true;
515
+ }
516
+
481
517
  // handle the case when copy content from a table cell inside bodied extension
482
518
  if ((0, _handlers.handleTableContentPasteInBodiedExtension)(slice)(state, dispatch)) {
483
519
  return true;
@@ -32,6 +32,27 @@ export const isInsideBlockQuote = state => {
32
32
  return hasParentNodeOfType(blockquote)(state.selection);
33
33
  };
34
34
  const PASTE = 'Editor Paste Plugin Paste Duration';
35
+ export function isSharePointUrl(url) {
36
+ if (!url) {
37
+ return false;
38
+ }
39
+ try {
40
+ const urlObj = new URL(url);
41
+ const hostname = urlObj.hostname.toLowerCase();
42
+ const protocol = urlObj.protocol.toLowerCase();
43
+
44
+ // Only accept HTTPS URLs for security
45
+ if (protocol !== 'https:') {
46
+ return false;
47
+ }
48
+
49
+ // Check if hostname ends with the trusted domains (not just contains them)
50
+ return hostname.endsWith('sharepoint.com') || hostname.endsWith('onedrive.com') || hostname.endsWith('onedrive.live.com');
51
+ } catch {
52
+ // If URL parsing fails, return false for safety
53
+ return false;
54
+ }
55
+ }
35
56
  export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
36
57
  var _pluginInjectionApi$a;
37
58
  const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
@@ -442,6 +463,20 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
442
463
  return true;
443
464
  }
444
465
 
466
+ // Special handling for SharePoint URLs generated from Share button
467
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
468
+ if (fg('platform_editor_sharepoint_url_smart_card_fallback') && isSharePointUrl(text)) {
469
+ // Create an inline card directly for SharePoint URLs to show the "Connect" button
470
+ const inlineCardNode = schema.nodes.inlineCard.create({
471
+ url: text
472
+ });
473
+ const cardSlice = new Slice(Fragment.from(inlineCardNode), 0, 0);
474
+ if (dispatch) {
475
+ dispatch(state.tr.replaceSelection(cardSlice));
476
+ }
477
+ return true;
478
+ }
479
+
445
480
  // handle the case when copy content from a table cell inside bodied extension
446
481
  if (handleTableContentPasteInBodiedExtension(slice)(state, dispatch)) {
447
482
  return true;
@@ -35,6 +35,27 @@ export var isInsideBlockQuote = function isInsideBlockQuote(state) {
35
35
  return hasParentNodeOfType(blockquote)(state.selection);
36
36
  };
37
37
  var PASTE = 'Editor Paste Plugin Paste Duration';
38
+ export function isSharePointUrl(url) {
39
+ if (!url) {
40
+ return false;
41
+ }
42
+ try {
43
+ var urlObj = new URL(url);
44
+ var hostname = urlObj.hostname.toLowerCase();
45
+ var protocol = urlObj.protocol.toLowerCase();
46
+
47
+ // Only accept HTTPS URLs for security
48
+ if (protocol !== 'https:') {
49
+ return false;
50
+ }
51
+
52
+ // Check if hostname ends with the trusted domains (not just contains them)
53
+ return hostname.endsWith('sharepoint.com') || hostname.endsWith('onedrive.com') || hostname.endsWith('onedrive.live.com');
54
+ } catch (_unused) {
55
+ // If URL parsing fails, return false for safety
56
+ return false;
57
+ }
58
+ }
38
59
  export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
39
60
  var _pluginInjectionApi$a;
40
61
  var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
@@ -470,6 +491,20 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
470
491
  return true;
471
492
  }
472
493
 
494
+ // Special handling for SharePoint URLs generated from Share button
495
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
496
+ if (fg('platform_editor_sharepoint_url_smart_card_fallback') && isSharePointUrl(text)) {
497
+ // Create an inline card directly for SharePoint URLs to show the "Connect" button
498
+ var inlineCardNode = schema.nodes.inlineCard.create({
499
+ url: text
500
+ });
501
+ var cardSlice = new Slice(Fragment.from(inlineCardNode), 0, 0);
502
+ if (dispatch) {
503
+ dispatch(state.tr.replaceSelection(cardSlice));
504
+ }
505
+ return true;
506
+ }
507
+
473
508
  // handle the case when copy content from a table cell inside bodied extension
474
509
  if (handleTableContentPasteInBodiedExtension(slice)(state, dispatch)) {
475
510
  return true;
@@ -8,4 +8,5 @@ import type { Schema } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { PastePlugin } from '../index';
10
10
  export declare const isInsideBlockQuote: (state: EditorState) => boolean;
11
+ export declare function isSharePointUrl(url: string | undefined): boolean;
11
12
  export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../pastePluginType").PastePluginState>;
@@ -8,4 +8,5 @@ import type { Schema } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { PastePlugin } from '../index';
10
10
  export declare const isInsideBlockQuote: (state: EditorState) => boolean;
11
+ export declare function isSharePointUrl(url: string | undefined): boolean;
11
12
  export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../pastePluginType").PastePluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "4.1.8",
3
+ "version": "5.0.0",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,41 +26,38 @@
26
26
  },
27
27
  "sideEffects": false,
28
28
  "atlaskit:src": "src/index.ts",
29
- "af:exports": {
30
- ".": "./src/index.ts"
31
- },
32
29
  "dependencies": {
33
- "@atlaskit/adf-schema": "^50.2.1",
30
+ "@atlaskit/adf-schema": "^50.2.3",
34
31
  "@atlaskit/code": "^17.2.0",
35
32
  "@atlaskit/editor-markdown-transformer": "^5.16.0",
36
- "@atlaskit/editor-plugin-analytics": "^3.0.0",
37
- "@atlaskit/editor-plugin-annotation": "^3.3.0",
38
- "@atlaskit/editor-plugin-better-type-history": "^3.0.0",
39
- "@atlaskit/editor-plugin-card": "^7.4.0",
40
- "@atlaskit/editor-plugin-feature-flags": "^2.0.0",
41
- "@atlaskit/editor-plugin-list": "^5.1.0",
42
- "@atlaskit/editor-plugin-media": "^5.2.0",
43
- "@atlaskit/editor-plugin-mentions": "^5.2.0",
33
+ "@atlaskit/editor-plugin-analytics": "^4.0.0",
34
+ "@atlaskit/editor-plugin-annotation": "^4.0.0",
35
+ "@atlaskit/editor-plugin-better-type-history": "^4.0.0",
36
+ "@atlaskit/editor-plugin-card": "^8.0.0",
37
+ "@atlaskit/editor-plugin-feature-flags": "^3.0.0",
38
+ "@atlaskit/editor-plugin-list": "^6.0.0",
39
+ "@atlaskit/editor-plugin-media": "^6.0.0",
40
+ "@atlaskit/editor-plugin-mentions": "^6.0.0",
44
41
  "@atlaskit/editor-prosemirror": "7.0.0",
45
42
  "@atlaskit/editor-tables": "^2.9.0",
46
43
  "@atlaskit/media-client": "^35.3.0",
47
44
  "@atlaskit/media-common": "^12.3.0",
48
45
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
- "@atlaskit/tmp-editor-statsig": "^11.5.0",
46
+ "@atlaskit/tmp-editor-statsig": "^12.0.0",
50
47
  "@babel/runtime": "^7.0.0",
51
48
  "lodash": "^4.17.21",
52
49
  "uuid": "^3.1.0"
53
50
  },
54
51
  "peerDependencies": {
55
- "@atlaskit/editor-common": "^107.28.0",
52
+ "@atlaskit/editor-common": "^108.0.0",
56
53
  "react": "^18.2.0",
57
54
  "react-dom": "^18.2.0"
58
55
  },
59
56
  "devDependencies": {
60
57
  "@af/visual-regression": "workspace:^",
61
- "@atlaskit/editor-plugin-block-type": "^6.2.0",
62
- "@atlaskit/editor-plugin-history": "^3.1.0",
63
- "@atlaskit/editor-plugin-type-ahead": "^3.1.0",
58
+ "@atlaskit/editor-plugin-block-type": "^7.0.0",
59
+ "@atlaskit/editor-plugin-history": "^4.0.0",
60
+ "@atlaskit/editor-plugin-type-ahead": "^4.0.0",
64
61
  "@atlaskit/ssr": "workspace:^",
65
62
  "@testing-library/react": "^13.4.0",
66
63
  "wait-for-expect": "^1.2.0"
@@ -119,6 +116,9 @@
119
116
  },
120
117
  "platform_editor_paste_code_block_do_not_escape": {
121
118
  "type": "boolean"
119
+ },
120
+ "platform_editor_sharepoint_url_smart_card_fallback": {
121
+ "type": "boolean"
122
122
  }
123
123
  }
124
124
  }