@atlaskit/editor-plugin-hyperlink 4.2.3 → 4.2.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,24 @@
1
1
  # @atlaskit/editor-plugin-hyperlink
2
2
 
3
+ ## 4.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#125391](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/125391)
8
+ [`ead20443d03e8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ead20443d03e8) -
9
+ [ux] When Editor Controls enabled, we show Text Formatting toolbar on range selection inside of a
10
+ hyperlink.
11
+ - Updated dependencies
12
+
13
+ ## 4.2.4
14
+
15
+ ### Patch Changes
16
+
17
+ - [#121182](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121182)
18
+ [`224d725203e16`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/224d725203e16) -
19
+ [ux] EDF-2445 - Link added via cmd-k above a inline comment will be decorated by the inline
20
+ comment under FG platform_editor_update_insert_link_mark_end_pos
21
+
3
22
  ## 4.2.3
4
23
 
5
24
  ### Patch Changes
@@ -23,6 +23,7 @@ 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");
26
27
  var _main = require("../pm-plugins/main");
27
28
  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; }
28
29
  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; }
@@ -112,10 +113,20 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
112
113
  var _text = displayText || incomingTitle || incomingHref;
113
114
  if (!displayText || displayText !== currentText) {
114
115
  tr.insertText(_text, from, to);
115
- if (!(0, _link.isTextAtPos)(from)(state)) {
116
- markEnd = from + _text.length + 1;
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
+ }
117
124
  } else {
118
- markEnd = from + _text.length;
125
+ if (!(0, _link.isTextAtPos)(from)(state)) {
126
+ markEnd = from + _text.length + 1;
127
+ } else {
128
+ markEnd = from + _text.length;
129
+ }
119
130
  }
120
131
  }
121
132
  tr.addMark(from, markEnd, link.create({
@@ -18,6 +18,7 @@ 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
20
  var _utils = require("@atlaskit/editor-common/utils");
21
+ var _state = require("@atlaskit/editor-prosemirror/state");
21
22
  var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
22
23
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
23
24
  var _unlink = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/unlink"));
@@ -108,6 +109,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(opti
108
109
  if (options.disableFloatingToolbar) {
109
110
  return;
110
111
  }
112
+
113
+ // If range selection, we don't show hyperlink floating toolbar.
114
+ // Text Formattting toolbar is shown instaed.
115
+ if (state.selection instanceof _state.TextSelection && state.selection.to !== state.selection.from && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
116
+ return;
117
+ }
111
118
  var formatMessage = intl.formatMessage;
112
119
  var linkState = _main.stateKey.getState(state);
113
120
  var editorCardActions = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions;
@@ -136,7 +143,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(opti
136
143
  var link = linkMark[0] && linkMark[0].attrs.href;
137
144
  var isValidUrl = (0, _adfSchema.isSafeUrl)(link);
138
145
  var labelOpenLink = formatMessage(isValidUrl ? _messages.linkMessages.openLink : _messages.linkToolbarMessages.unableToOpenLink);
139
- // TODO: ED-14403 investigate why these are not translating?
146
+ // TODO: ED-14403 - investigate why these are not translating?
140
147
  var labelUnlink = formatMessage(_messages.linkToolbarMessages.unlink);
141
148
  var editLink = formatMessage(_messages.linkToolbarMessages.editLink);
142
149
  var metadata = {
@@ -5,6 +5,7 @@ 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';
8
9
  import { stateKey } from '../pm-plugins/main';
9
10
  function setLinkHrefEditorCommand(href, pos, editorAnalyticsApi, to, isTabPressed) {
10
11
  return ({
@@ -96,10 +97,20 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
96
97
  const text = displayText || incomingTitle || incomingHref;
97
98
  if (!displayText || displayText !== currentText) {
98
99
  tr.insertText(text, from, to);
99
- if (!isTextAtPos(from)(state)) {
100
- markEnd = from + text.length + 1;
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
+ }
101
108
  } else {
102
- markEnd = from + text.length;
109
+ if (!isTextAtPos(from)(state)) {
110
+ markEnd = from + text.length + 1;
111
+ } else {
112
+ markEnd = from + text.length;
113
+ }
103
114
  }
104
115
  }
105
116
  tr.addMark(from, markEnd, link.create({
@@ -15,7 +15,7 @@ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
15
15
  import LinkIcon from '@atlaskit/icon/core/link';
16
16
  const PrimaryToolbarComponentWithIntl = ({
17
17
  api,
18
- // TODO - Analytics
18
+ // TODO: ED-26959 - Analytics
19
19
  // editorAnalyticsAPI,
20
20
  intl
21
21
  }) => {
@@ -7,6 +7,7 @@ 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
9
  import { normalizeUrl } from '@atlaskit/editor-common/utils';
10
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
10
11
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
11
12
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
12
13
  import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
@@ -92,6 +93,12 @@ export const getToolbarConfig = (options, pluginInjectionApi) => (state, intl, p
92
93
  if (options.disableFloatingToolbar) {
93
94
  return;
94
95
  }
96
+
97
+ // If range selection, we don't show hyperlink floating toolbar.
98
+ // Text Formattting toolbar is shown instaed.
99
+ if (state.selection instanceof TextSelection && state.selection.to !== state.selection.from && editorExperiment('platform_editor_controls', 'variant1')) {
100
+ return;
101
+ }
95
102
  const {
96
103
  formatMessage
97
104
  } = intl;
@@ -122,7 +129,7 @@ export const getToolbarConfig = (options, pluginInjectionApi) => (state, intl, p
122
129
  const link = linkMark[0] && linkMark[0].attrs.href;
123
130
  const isValidUrl = isSafeUrl(link);
124
131
  const labelOpenLink = formatMessage(isValidUrl ? linkMessages.openLink : linkToolbarCommonMessages.unableToOpenLink);
125
- // TODO: ED-14403 investigate why these are not translating?
132
+ // TODO: ED-14403 - investigate why these are not translating?
126
133
  const labelUnlink = formatMessage(linkToolbarCommonMessages.unlink);
127
134
  const editLink = formatMessage(linkToolbarCommonMessages.editLink);
128
135
  const metadata = {
@@ -8,6 +8,7 @@ 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';
11
12
  import { stateKey } from '../pm-plugins/main';
12
13
  function setLinkHrefEditorCommand(href, pos, editorAnalyticsApi, to, isTabPressed) {
13
14
  return function (_ref) {
@@ -95,10 +96,20 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
95
96
  var _text = displayText || incomingTitle || incomingHref;
96
97
  if (!displayText || displayText !== currentText) {
97
98
  tr.insertText(_text, from, to);
98
- if (!isTextAtPos(from)(state)) {
99
- markEnd = from + _text.length + 1;
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
+ }
100
107
  } else {
101
- markEnd = from + _text.length;
108
+ if (!isTextAtPos(from)(state)) {
109
+ markEnd = from + _text.length + 1;
110
+ } else {
111
+ markEnd = from + _text.length;
112
+ }
102
113
  }
103
114
  }
104
115
  tr.addMark(from, markEnd, link.create({
@@ -11,6 +11,7 @@ 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
13
  import { normalizeUrl } from '@atlaskit/editor-common/utils';
14
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
14
15
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
15
16
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
16
17
  import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
@@ -98,6 +99,12 @@ export var getToolbarConfig = function getToolbarConfig(options, pluginInjection
98
99
  if (options.disableFloatingToolbar) {
99
100
  return;
100
101
  }
102
+
103
+ // If range selection, we don't show hyperlink floating toolbar.
104
+ // Text Formattting toolbar is shown instaed.
105
+ if (state.selection instanceof TextSelection && state.selection.to !== state.selection.from && editorExperiment('platform_editor_controls', 'variant1')) {
106
+ return;
107
+ }
101
108
  var formatMessage = intl.formatMessage;
102
109
  var linkState = stateKey.getState(state);
103
110
  var editorCardActions = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions;
@@ -126,7 +133,7 @@ export var getToolbarConfig = function getToolbarConfig(options, pluginInjection
126
133
  var link = linkMark[0] && linkMark[0].attrs.href;
127
134
  var isValidUrl = isSafeUrl(link);
128
135
  var labelOpenLink = formatMessage(isValidUrl ? linkMessages.openLink : linkToolbarCommonMessages.unableToOpenLink);
129
- // TODO: ED-14403 investigate why these are not translating?
136
+ // TODO: ED-14403 - investigate why these are not translating?
130
137
  var labelUnlink = formatMessage(linkToolbarCommonMessages.unlink);
131
138
  var editLink = formatMessage(linkToolbarCommonMessages.editLink);
132
139
  var metadata = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-hyperlink",
3
- "version": "4.2.3",
3
+ "version": "4.2.5",
4
4
  "description": "Hyperlink plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
37
  "@atlaskit/analytics-next": "^11.0.0",
38
- "@atlaskit/editor-common": "^102.0.0",
38
+ "@atlaskit/editor-common": "^102.3.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-card": "^5.2.0",
41
41
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
@@ -46,7 +46,7 @@
46
46
  "@atlaskit/icon": "^24.1.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
48
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
49
- "@atlaskit/tmp-editor-statsig": "^3.4.0",
49
+ "@atlaskit/tmp-editor-statsig": "^3.5.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
52
52
  "uuid": "^3.1.0"
@@ -102,6 +102,9 @@
102
102
  }
103
103
  },
104
104
  "platform-feature-flags": {
105
+ "platform_editor_update_insert_link_mark_end_pos": {
106
+ "type": "boolean"
107
+ },
105
108
  "linking_platform_smart_links_in_live_pages": {
106
109
  "type": "boolean"
107
110
  }