@atlaskit/editor-plugin-hyperlink 4.4.1 → 4.4.3

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,22 @@
1
1
  # @atlaskit/editor-plugin-hyperlink
2
2
 
3
+ ## 4.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#148126](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/148126)
8
+ [`2839a051cf613`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2839a051cf613) -
9
+ Migrate to useSharedPluginStateSelector for grid, guideline, help-dialog, highlight and hyperlink
10
+ plugins
11
+
12
+ ## 4.4.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [#150122](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/150122)
17
+ [`92cc72b849cd4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/92cc72b849cd4) -
18
+ EDITOR-705 - cleanup FG platform_editor_update_insert_link_mark_end_pos
19
+
3
20
  ## 4.4.1
4
21
 
5
22
  ### Patch Changes
@@ -23,7 +23,6 @@ var _link = require("@atlaskit/editor-common/link");
23
23
  var _preset = require("@atlaskit/editor-common/preset");
24
24
  var _utils = require("@atlaskit/editor-common/utils");
25
25
  var _state = require("@atlaskit/editor-prosemirror/state");
26
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
27
26
  var _main = require("../pm-plugins/main");
28
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -113,20 +112,12 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
113
112
  var _text = displayText || incomingTitle || incomingHref;
114
113
  if (!displayText || displayText !== currentText) {
115
114
  tr.insertText(_text, from, to);
116
- if ((0, _platformFeatureFlags.fg)('platform_editor_update_insert_link_mark_end_pos')) {
117
- // new block created to wrap the link
118
- if (tr.mapping.map(from) === from + _text.length + 2) {
119
- // +1 is for the block's opening tag
120
- markEnd = from + _text.length + 1;
121
- } else {
122
- markEnd = from + _text.length;
123
- }
115
+ // new block created to wrap the link
116
+ if (tr.mapping.map(from) === from + _text.length + 2) {
117
+ // +1 is for the block's opening tag
118
+ markEnd = from + _text.length + 1;
124
119
  } else {
125
- if (!(0, _link.isTextAtPos)(from)(state)) {
126
- markEnd = from + _text.length + 1;
127
- } else {
128
- markEnd = from + _text.length;
129
- }
120
+ markEnd = from + _text.length;
130
121
  }
131
122
  }
132
123
  tr.addMark(from, markEnd, link.create({
@@ -17,6 +17,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
17
17
  var _link2 = require("@atlaskit/editor-common/link");
18
18
  var _messages = require("@atlaskit/editor-common/messages");
19
19
  var _ui = require("@atlaskit/editor-common/ui");
20
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
20
21
  var _utils = require("@atlaskit/editor-common/utils");
21
22
  var _state = require("@atlaskit/editor-prosemirror/state");
22
23
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
@@ -63,6 +64,24 @@ function getLinkText(activeLinkMark, state) {
63
64
  }
64
65
  return activeLinkMark.node.text;
65
66
  }
67
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
68
+ var timesViewed = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'hyperlink.timesViewed');
69
+ var inputMethod = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'hyperlink.inputMethod');
70
+ var searchSessionId = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'hyperlink.searchSessionId');
71
+ return {
72
+ timesViewed: timesViewed,
73
+ inputMethod: inputMethod,
74
+ searchSessionId: searchSessionId
75
+ };
76
+ }, function (api) {
77
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['hyperlink']),
78
+ hyperlinkState = _useSharedPluginState.hyperlinkState;
79
+ return {
80
+ timesViewed: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.timesViewed,
81
+ inputMethod: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.inputMethod,
82
+ searchSessionId: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.searchSessionId
83
+ };
84
+ });
66
85
  function HyperlinkAddToolbarWithState(_ref) {
67
86
  var _pluginInjectionApi$c;
68
87
  var _ref$linkPickerOption = _ref.linkPickerOptions,
@@ -79,8 +98,11 @@ function HyperlinkAddToolbarWithState(_ref) {
79
98
  onEscapeCallback = _ref.onEscapeCallback,
80
99
  onClickAwayCallback = _ref.onClickAwayCallback,
81
100
  pluginInjectionApi = _ref.pluginInjectionApi;
82
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink']),
83
- hyperlinkState = _useSharedPluginState.hyperlinkState;
101
+ var _useSharedState = useSharedState(pluginInjectionApi),
102
+ timesViewed = _useSharedState.timesViewed,
103
+ inputMethod = _useSharedState.inputMethod,
104
+ searchSessionId = _useSharedState.searchSessionId;
105
+
84
106
  // This is constant rather than dynamic - because if someone's already got a hyperlink toolbar open,
85
107
  // we don't want to dynamically change it on them as this would cause data loss if they've already
86
108
  // started typing in the fields.
@@ -98,9 +120,9 @@ function HyperlinkAddToolbarWithState(_ref) {
98
120
  onClose: onClose,
99
121
  onEscapeCallback: onEscapeCallback,
100
122
  onClickAwayCallback: onClickAwayCallback,
101
- timesViewed: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.timesViewed,
102
- inputMethod: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.inputMethod,
103
- searchSessionId: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.searchSessionId,
123
+ timesViewed: timesViewed,
124
+ inputMethod: inputMethod,
125
+ searchSessionId: searchSessionId,
104
126
  isOffline: isOffline.current
105
127
  });
106
128
  }
@@ -5,7 +5,6 @@ import { isTextAtPos, LinkAction } from '@atlaskit/editor-common/link';
5
5
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
6
6
  import { getLinkCreationAnalyticsEvent, normalizeUrl } from '@atlaskit/editor-common/utils';
7
7
  import { Selection } from '@atlaskit/editor-prosemirror/state';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { stateKey } from '../pm-plugins/main';
10
9
  function setLinkHrefEditorCommand(href, pos, editorAnalyticsApi, to, isTabPressed) {
11
10
  return ({
@@ -97,20 +96,12 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
97
96
  const text = displayText || incomingTitle || incomingHref;
98
97
  if (!displayText || displayText !== currentText) {
99
98
  tr.insertText(text, from, to);
100
- if (fg('platform_editor_update_insert_link_mark_end_pos')) {
101
- // new block created to wrap the link
102
- if (tr.mapping.map(from) === from + text.length + 2) {
103
- // +1 is for the block's opening tag
104
- markEnd = from + text.length + 1;
105
- } else {
106
- markEnd = from + text.length;
107
- }
99
+ // new block created to wrap the link
100
+ if (tr.mapping.map(from) === from + text.length + 2) {
101
+ // +1 is for the block's opening tag
102
+ markEnd = from + text.length + 1;
108
103
  } else {
109
- if (!isTextAtPos(from)(state)) {
110
- markEnd = from + text.length + 1;
111
- } else {
112
- markEnd = from + text.length;
113
- }
104
+ markEnd = from + text.length;
114
105
  }
115
106
  }
116
107
  tr.addMark(from, markEnd, link.create({
@@ -2,10 +2,11 @@ import React, { useRef } from 'react';
2
2
  import { isSafeUrl } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT_ID, INPUT_METHOD, buildVisitedLinkPayload } from '@atlaskit/editor-common/analytics';
4
4
  import { commandWithMetadata } from '@atlaskit/editor-common/card';
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
+ import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
6
6
  import { HyperlinkAddToolbar } from '@atlaskit/editor-common/link';
7
7
  import { linkMessages, linkToolbarMessages as linkToolbarCommonMessages } from '@atlaskit/editor-common/messages';
8
8
  import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
9
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
10
  import { normalizeUrl } from '@atlaskit/editor-common/utils';
10
11
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
11
12
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
@@ -47,6 +48,25 @@ function getLinkText(activeLinkMark, state) {
47
48
  }
48
49
  return activeLinkMark.node.text;
49
50
  }
51
+ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
52
+ const timesViewed = useSharedPluginStateSelector(api, 'hyperlink.timesViewed');
53
+ const inputMethod = useSharedPluginStateSelector(api, 'hyperlink.inputMethod');
54
+ const searchSessionId = useSharedPluginStateSelector(api, 'hyperlink.searchSessionId');
55
+ return {
56
+ timesViewed,
57
+ inputMethod,
58
+ searchSessionId
59
+ };
60
+ }, api => {
61
+ const {
62
+ hyperlinkState
63
+ } = useSharedPluginState(api, ['hyperlink']);
64
+ return {
65
+ timesViewed: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.timesViewed,
66
+ inputMethod: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.inputMethod,
67
+ searchSessionId: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.searchSessionId
68
+ };
69
+ });
50
70
  export function HyperlinkAddToolbarWithState({
51
71
  linkPickerOptions = {},
52
72
  onSubmit,
@@ -64,8 +84,11 @@ export function HyperlinkAddToolbarWithState({
64
84
  }) {
65
85
  var _pluginInjectionApi$c, _pluginInjectionApi$c2;
66
86
  const {
67
- hyperlinkState
68
- } = useSharedPluginState(pluginInjectionApi, ['hyperlink']);
87
+ timesViewed,
88
+ inputMethod,
89
+ searchSessionId
90
+ } = useSharedState(pluginInjectionApi);
91
+
69
92
  // This is constant rather than dynamic - because if someone's already got a hyperlink toolbar open,
70
93
  // we don't want to dynamically change it on them as this would cause data loss if they've already
71
94
  // started typing in the fields.
@@ -83,9 +106,9 @@ export function HyperlinkAddToolbarWithState({
83
106
  onClose: onClose,
84
107
  onEscapeCallback: onEscapeCallback,
85
108
  onClickAwayCallback: onClickAwayCallback,
86
- timesViewed: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.timesViewed,
87
- inputMethod: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.inputMethod,
88
- searchSessionId: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.searchSessionId,
109
+ timesViewed: timesViewed,
110
+ inputMethod: inputMethod,
111
+ searchSessionId: searchSessionId,
89
112
  isOffline: isOffline.current
90
113
  });
91
114
  }
@@ -8,7 +8,6 @@ import { isTextAtPos, LinkAction } from '@atlaskit/editor-common/link';
8
8
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
9
9
  import { getLinkCreationAnalyticsEvent, normalizeUrl } from '@atlaskit/editor-common/utils';
10
10
  import { Selection } from '@atlaskit/editor-prosemirror/state';
11
- import { fg } from '@atlaskit/platform-feature-flags';
12
11
  import { stateKey } from '../pm-plugins/main';
13
12
  function setLinkHrefEditorCommand(href, pos, editorAnalyticsApi, to, isTabPressed) {
14
13
  return function (_ref) {
@@ -96,20 +95,12 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
96
95
  var _text = displayText || incomingTitle || incomingHref;
97
96
  if (!displayText || displayText !== currentText) {
98
97
  tr.insertText(_text, from, to);
99
- if (fg('platform_editor_update_insert_link_mark_end_pos')) {
100
- // new block created to wrap the link
101
- if (tr.mapping.map(from) === from + _text.length + 2) {
102
- // +1 is for the block's opening tag
103
- markEnd = from + _text.length + 1;
104
- } else {
105
- markEnd = from + _text.length;
106
- }
98
+ // new block created to wrap the link
99
+ if (tr.mapping.map(from) === from + _text.length + 2) {
100
+ // +1 is for the block's opening tag
101
+ markEnd = from + _text.length + 1;
107
102
  } else {
108
- if (!isTextAtPos(from)(state)) {
109
- markEnd = from + _text.length + 1;
110
- } else {
111
- markEnd = from + _text.length;
112
- }
103
+ markEnd = from + _text.length;
113
104
  }
114
105
  }
115
106
  tr.addMark(from, markEnd, link.create({
@@ -6,10 +6,11 @@ import React, { useRef } from 'react';
6
6
  import { isSafeUrl } from '@atlaskit/adf-schema';
7
7
  import { ACTION, ACTION_SUBJECT_ID, INPUT_METHOD, buildVisitedLinkPayload } from '@atlaskit/editor-common/analytics';
8
8
  import { commandWithMetadata } from '@atlaskit/editor-common/card';
9
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
+ import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
10
10
  import { HyperlinkAddToolbar } from '@atlaskit/editor-common/link';
11
11
  import { linkMessages, linkToolbarMessages as linkToolbarCommonMessages } from '@atlaskit/editor-common/messages';
12
12
  import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
13
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
13
14
  import { normalizeUrl } from '@atlaskit/editor-common/utils';
14
15
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
15
16
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
@@ -53,6 +54,24 @@ function getLinkText(activeLinkMark, state) {
53
54
  }
54
55
  return activeLinkMark.node.text;
55
56
  }
57
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
58
+ var timesViewed = useSharedPluginStateSelector(api, 'hyperlink.timesViewed');
59
+ var inputMethod = useSharedPluginStateSelector(api, 'hyperlink.inputMethod');
60
+ var searchSessionId = useSharedPluginStateSelector(api, 'hyperlink.searchSessionId');
61
+ return {
62
+ timesViewed: timesViewed,
63
+ inputMethod: inputMethod,
64
+ searchSessionId: searchSessionId
65
+ };
66
+ }, function (api) {
67
+ var _useSharedPluginState = useSharedPluginState(api, ['hyperlink']),
68
+ hyperlinkState = _useSharedPluginState.hyperlinkState;
69
+ return {
70
+ timesViewed: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.timesViewed,
71
+ inputMethod: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.inputMethod,
72
+ searchSessionId: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.searchSessionId
73
+ };
74
+ });
56
75
  export function HyperlinkAddToolbarWithState(_ref) {
57
76
  var _pluginInjectionApi$c;
58
77
  var _ref$linkPickerOption = _ref.linkPickerOptions,
@@ -69,8 +88,11 @@ export function HyperlinkAddToolbarWithState(_ref) {
69
88
  onEscapeCallback = _ref.onEscapeCallback,
70
89
  onClickAwayCallback = _ref.onClickAwayCallback,
71
90
  pluginInjectionApi = _ref.pluginInjectionApi;
72
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink']),
73
- hyperlinkState = _useSharedPluginState.hyperlinkState;
91
+ var _useSharedState = useSharedState(pluginInjectionApi),
92
+ timesViewed = _useSharedState.timesViewed,
93
+ inputMethod = _useSharedState.inputMethod,
94
+ searchSessionId = _useSharedState.searchSessionId;
95
+
74
96
  // This is constant rather than dynamic - because if someone's already got a hyperlink toolbar open,
75
97
  // we don't want to dynamically change it on them as this would cause data loss if they've already
76
98
  // started typing in the fields.
@@ -88,9 +110,9 @@ export function HyperlinkAddToolbarWithState(_ref) {
88
110
  onClose: onClose,
89
111
  onEscapeCallback: onEscapeCallback,
90
112
  onClickAwayCallback: onClickAwayCallback,
91
- timesViewed: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.timesViewed,
92
- inputMethod: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.inputMethod,
93
- searchSessionId: hyperlinkState === null || hyperlinkState === void 0 ? void 0 : hyperlinkState.searchSessionId,
113
+ timesViewed: timesViewed,
114
+ inputMethod: inputMethod,
115
+ searchSessionId: searchSessionId,
94
116
  isOffline: isOffline.current
95
117
  });
96
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-hyperlink",
3
- "version": "4.4.1",
3
+ "version": "4.4.3",
4
4
  "description": "Hyperlink plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,18 +35,18 @@
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
37
  "@atlaskit/analytics-next": "^11.0.0",
38
- "@atlaskit/editor-common": "^104.0.0",
38
+ "@atlaskit/editor-common": "^104.1.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
40
40
  "@atlaskit/editor-plugin-card": "^5.4.0",
41
41
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
42
42
  "@atlaskit/editor-plugin-editor-viewmode": "^3.1.0",
43
43
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
44
- "@atlaskit/editor-plugin-selection-toolbar": "^3.5.0",
44
+ "@atlaskit/editor-plugin-selection-toolbar": "^3.6.0",
45
45
  "@atlaskit/editor-prosemirror": "7.0.0",
46
- "@atlaskit/icon": "^25.6.0",
46
+ "@atlaskit/icon": "^25.8.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
48
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
49
- "@atlaskit/tmp-editor-statsig": "^4.16.0",
49
+ "@atlaskit/tmp-editor-statsig": "^4.19.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
52
52
  "uuid": "^3.1.0"
@@ -102,9 +102,6 @@
102
102
  }
103
103
  },
104
104
  "platform-feature-flags": {
105
- "platform_editor_update_insert_link_mark_end_pos": {
106
- "type": "boolean"
107
- },
108
105
  "linking_platform_smart_links_in_live_pages": {
109
106
  "type": "boolean"
110
107
  },