@atlaskit/editor-plugin-hyperlink 5.4.0 → 5.4.2

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,21 @@
1
1
  # @atlaskit/editor-plugin-hyperlink
2
2
 
3
+ ## 5.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 5.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#199487](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/199487)
14
+ [`54098ba4cc83c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/54098ba4cc83c) -
15
+ Add LinkSection and TextSection and add logic to hide them when toolbar is pinned. Add
16
+ UserPreferencesPlugin and EditorViewModePlugin as a dependency to editor-plugin-toolbar.
17
+ - Updated dependencies
18
+
3
19
  ## 5.4.0
4
20
 
5
21
  ### Minor Changes
@@ -25,8 +25,8 @@ var _inputRule = require("./pm-plugins/input-rule");
25
25
  var _keymap = require("./pm-plugins/keymap");
26
26
  var _main = require("./pm-plugins/main");
27
27
  var _toolbarButtons = require("./pm-plugins/toolbar-buttons");
28
+ var _toolbarComponents = require("./ui/toolbar-components");
28
29
  var _Toolbar = require("./ui/toolbar/Toolbar");
29
- var _ToolbarComponents = require("./ui/ToolbarComponents");
30
30
  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; }
31
31
  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; }
32
32
  var getPosFromActiveLinkMark = function getPosFromActiveLinkMark(state) {
@@ -54,7 +54,7 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
54
54
  var primaryToolbarComponent;
55
55
  if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true)) {
56
56
  var _api$toolbar;
57
- api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _ToolbarComponents.getToolbarComponents)(api));
57
+ api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api));
58
58
  }
59
59
  return {
60
60
  name: 'hyperlink',
@@ -37,7 +37,7 @@ var LinkButton = exports.LinkButton = function LinkButton(_ref) {
37
37
  label: formatMessage(_messages.toolbarInsertBlockMessages.link)
38
38
  }),
39
39
  onClick: onClick,
40
- testId: "editor-toolbar__link-button",
40
+ testId: 'editor-toolbar__link-button',
41
41
  isDisabled: !isEnabled
42
42
  }))
43
43
  );
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.LinkSection = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _toolbar = require("@atlaskit/editor-common/toolbar");
10
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var shouldShowLinkSection = function shouldShowLinkSection(editMode, toolbar, toolbarDocking) {
13
+ if (editMode === 'view') {
14
+ return false;
15
+ }
16
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
17
+ return true;
18
+ }
19
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
20
+ return true;
21
+ }
22
+ return false;
23
+ };
24
+ var LinkSection = exports.LinkSection = function LinkSection(_ref) {
25
+ var children = _ref.children,
26
+ parents = _ref.parents,
27
+ api = _ref.api;
28
+ var editMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
29
+ var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
30
+ var toolbar = parents.find(function (parent) {
31
+ return parent.type === 'toolbar';
32
+ });
33
+ if (!shouldShowLinkSection(editMode, toolbar, toolbarDocking)) {
34
+ return null;
35
+ }
36
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarSection, null, children);
37
+ };
@@ -8,6 +8,7 @@ exports.getToolbarComponents = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _toolbar = require("@atlaskit/editor-common/toolbar");
10
10
  var _LinkButton = require("./toolbar/LinkButton");
11
+ var _LinkSection = require("./toolbar/LinkSection");
11
12
  var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api) {
12
13
  var toolbarComponents = [{
13
14
  type: _toolbar.LINKING_SECTION.type,
@@ -16,7 +17,19 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
16
17
  type: 'toolbar',
17
18
  key: _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR,
18
19
  rank: _toolbar.TOOLBAR_RANK[_toolbar.LINKING_SECTION.key]
19
- }]
20
+ }, {
21
+ type: 'toolbar',
22
+ key: _toolbar.TOOLBARS.PRIMARY_TOOLBAR,
23
+ rank: _toolbar.TOOLBAR_RANK[_toolbar.LINKING_SECTION.key]
24
+ }],
25
+ component: function component(_ref) {
26
+ var children = _ref.children,
27
+ parents = _ref.parents;
28
+ return /*#__PURE__*/_react.default.createElement(_LinkSection.LinkSection, {
29
+ parents: parents,
30
+ api: api
31
+ }, children);
32
+ }
20
33
  }, {
21
34
  type: _toolbar.LINKING_GROUP.type,
22
35
  key: _toolbar.LINKING_GROUP.key,
@@ -17,8 +17,8 @@ import { createInputRulePlugin } from './pm-plugins/input-rule';
17
17
  import { createKeymapPlugin } from './pm-plugins/keymap';
18
18
  import { plugin, stateKey } from './pm-plugins/main';
19
19
  import { toolbarButtonsPlugin } from './pm-plugins/toolbar-buttons';
20
+ import { getToolbarComponents } from './ui/toolbar-components';
20
21
  import { getToolbarConfig } from './ui/toolbar/Toolbar';
21
- import { getToolbarComponents } from './ui/ToolbarComponents';
22
22
  const getPosFromActiveLinkMark = state => {
23
23
  if (state === undefined) {
24
24
  return undefined;
@@ -34,7 +34,7 @@ export const LinkButton = ({
34
34
  label: formatMessage(messages.link)
35
35
  }),
36
36
  onClick: onClick,
37
- testId: "editor-toolbar__link-button",
37
+ testId: 'editor-toolbar__link-button',
38
38
  isDisabled: !isEnabled
39
39
  }))
40
40
  );
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
+ import { ToolbarSection } from '@atlaskit/editor-toolbar';
5
+ const shouldShowLinkSection = (editMode, toolbar, toolbarDocking) => {
6
+ if (editMode === 'view') {
7
+ return false;
8
+ }
9
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
10
+ return true;
11
+ }
12
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
13
+ return true;
14
+ }
15
+ return false;
16
+ };
17
+ export const LinkSection = ({
18
+ children,
19
+ parents,
20
+ api
21
+ }) => {
22
+ const editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
23
+ const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
24
+ const toolbar = parents.find(parent => parent.type === 'toolbar');
25
+ if (!shouldShowLinkSection(editMode, toolbar, toolbarDocking)) {
26
+ return null;
27
+ }
28
+ return /*#__PURE__*/React.createElement(ToolbarSection, null, children);
29
+ };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { LINKING_BUTTON, LINKING_GROUP, LINKING_GROUP_RANK, LINKING_SECTION, LINKING_SECTION_RANK, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
3
  import { LinkButton } from './toolbar/LinkButton';
4
+ import { LinkSection } from './toolbar/LinkSection';
4
5
  export const getToolbarComponents = api => {
5
6
  const toolbarComponents = [{
6
7
  type: LINKING_SECTION.type,
@@ -9,7 +10,20 @@ export const getToolbarComponents = api => {
9
10
  type: 'toolbar',
10
11
  key: TOOLBARS.INLINE_TEXT_TOOLBAR,
11
12
  rank: TOOLBAR_RANK[LINKING_SECTION.key]
12
- }]
13
+ }, {
14
+ type: 'toolbar',
15
+ key: TOOLBARS.PRIMARY_TOOLBAR,
16
+ rank: TOOLBAR_RANK[LINKING_SECTION.key]
17
+ }],
18
+ component: ({
19
+ children,
20
+ parents
21
+ }) => {
22
+ return /*#__PURE__*/React.createElement(LinkSection, {
23
+ parents: parents,
24
+ api: api
25
+ }, children);
26
+ }
13
27
  }, {
14
28
  type: LINKING_GROUP.type,
15
29
  key: LINKING_GROUP.key,
@@ -20,8 +20,8 @@ import { createInputRulePlugin } from './pm-plugins/input-rule';
20
20
  import { createKeymapPlugin } from './pm-plugins/keymap';
21
21
  import { plugin as _plugin, stateKey } from './pm-plugins/main';
22
22
  import { toolbarButtonsPlugin } from './pm-plugins/toolbar-buttons';
23
+ import { getToolbarComponents } from './ui/toolbar-components';
23
24
  import { getToolbarConfig } from './ui/toolbar/Toolbar';
24
- import { getToolbarComponents } from './ui/ToolbarComponents';
25
25
  var getPosFromActiveLinkMark = function getPosFromActiveLinkMark(state) {
26
26
  if (state === undefined) {
27
27
  return undefined;
@@ -30,7 +30,7 @@ export var LinkButton = function LinkButton(_ref) {
30
30
  label: formatMessage(messages.link)
31
31
  }),
32
32
  onClick: onClick,
33
- testId: "editor-toolbar__link-button",
33
+ testId: 'editor-toolbar__link-button',
34
34
  isDisabled: !isEnabled
35
35
  }))
36
36
  );
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
+ import { ToolbarSection } from '@atlaskit/editor-toolbar';
5
+ var shouldShowLinkSection = function shouldShowLinkSection(editMode, toolbar, toolbarDocking) {
6
+ if (editMode === 'view') {
7
+ return false;
8
+ }
9
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
10
+ return true;
11
+ }
12
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
13
+ return true;
14
+ }
15
+ return false;
16
+ };
17
+ export var LinkSection = function LinkSection(_ref) {
18
+ var children = _ref.children,
19
+ parents = _ref.parents,
20
+ api = _ref.api;
21
+ var editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
22
+ var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
23
+ var toolbar = parents.find(function (parent) {
24
+ return parent.type === 'toolbar';
25
+ });
26
+ if (!shouldShowLinkSection(editMode, toolbar, toolbarDocking)) {
27
+ return null;
28
+ }
29
+ return /*#__PURE__*/React.createElement(ToolbarSection, null, children);
30
+ };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { LINKING_BUTTON, LINKING_GROUP, LINKING_GROUP_RANK, LINKING_SECTION, LINKING_SECTION_RANK, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
3
  import { LinkButton } from './toolbar/LinkButton';
4
+ import { LinkSection } from './toolbar/LinkSection';
4
5
  export var getToolbarComponents = function getToolbarComponents(api) {
5
6
  var toolbarComponents = [{
6
7
  type: LINKING_SECTION.type,
@@ -9,7 +10,19 @@ export var getToolbarComponents = function getToolbarComponents(api) {
9
10
  type: 'toolbar',
10
11
  key: TOOLBARS.INLINE_TEXT_TOOLBAR,
11
12
  rank: TOOLBAR_RANK[LINKING_SECTION.key]
12
- }]
13
+ }, {
14
+ type: 'toolbar',
15
+ key: TOOLBARS.PRIMARY_TOOLBAR,
16
+ rank: TOOLBAR_RANK[LINKING_SECTION.key]
17
+ }],
18
+ component: function component(_ref) {
19
+ var children = _ref.children,
20
+ parents = _ref.parents;
21
+ return /*#__PURE__*/React.createElement(LinkSection, {
22
+ parents: parents,
23
+ api: api
24
+ }, children);
25
+ }
13
26
  }, {
14
27
  type: LINKING_GROUP.type,
15
28
  key: LINKING_GROUP.key,
@@ -5,7 +5,7 @@ import { type PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { type EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  export declare const ButtonWrapper: ({ editorView, pos, stateKey, intl, onOpenLinkClick, }: {
7
7
  editorView: EditorView;
8
- pos?: number | undefined;
8
+ pos?: number;
9
9
  stateKey: PluginKey<HyperlinkState>;
10
10
  intl: IntlShape;
11
11
  /** Callback fired when the Open Link dropdown item is clicked */
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { WrappedComponentProps } from 'react-intl-next';
3
2
  import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import type { ExtractInjectionAPI } from "@atlaskit/editor-common/types";
3
- import type { HyperlinkPlugin } from "../../hyperlinkPluginType";
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
4
4
  type LinkButtonProps = {
5
5
  api?: ExtractInjectionAPI<HyperlinkPlugin>;
6
6
  };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
+ import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
5
+ type LinkSectionProps = {
6
+ children: React.ReactNode;
7
+ parents: ToolbarComponentTypes;
8
+ api?: ExtractInjectionAPI<HyperlinkPlugin>;
9
+ };
10
+ export declare const LinkSection: ({ children, parents, api }: LinkSectionProps) => React.JSX.Element | null;
11
+ export {};
@@ -5,7 +5,7 @@ import { type PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { type EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  export declare const ButtonWrapper: ({ editorView, pos, stateKey, intl, onOpenLinkClick, }: {
7
7
  editorView: EditorView;
8
- pos?: number | undefined;
8
+ pos?: number;
9
9
  stateKey: PluginKey<HyperlinkState>;
10
10
  intl: IntlShape;
11
11
  /** Callback fired when the Open Link dropdown item is clicked */
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { WrappedComponentProps } from 'react-intl-next';
3
2
  import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import type { ExtractInjectionAPI } from "@atlaskit/editor-common/types";
3
- import type { HyperlinkPlugin } from "../../hyperlinkPluginType";
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
4
4
  type LinkButtonProps = {
5
5
  api?: ExtractInjectionAPI<HyperlinkPlugin>;
6
6
  };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
+ import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
5
+ type LinkSectionProps = {
6
+ children: React.ReactNode;
7
+ parents: ToolbarComponentTypes;
8
+ api?: ExtractInjectionAPI<HyperlinkPlugin>;
9
+ };
10
+ export declare const LinkSection: ({ children, parents, api }: LinkSectionProps) => React.JSX.Element | null;
11
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-hyperlink",
3
- "version": "5.4.0",
3
+ "version": "5.4.2",
4
4
  "description": "Hyperlink plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,25 +35,25 @@
35
35
  "@atlaskit/adf-schema": "^50.2.0",
36
36
  "@atlaskit/analytics-next": "^11.1.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
38
- "@atlaskit/editor-plugin-card": "^7.2.0",
38
+ "@atlaskit/editor-plugin-card": "^7.4.0",
39
39
  "@atlaskit/editor-plugin-connectivity": "^3.1.0",
40
40
  "@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
41
41
  "@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
42
42
  "@atlaskit/editor-plugin-selection-toolbar": "^4.3.0",
43
- "@atlaskit/editor-plugin-toolbar": "^0.1.0",
43
+ "@atlaskit/editor-plugin-toolbar": "^0.2.0",
44
44
  "@atlaskit/editor-prosemirror": "7.0.0",
45
- "@atlaskit/editor-toolbar": "^0.1.0",
46
- "@atlaskit/editor-toolbar-model": "^0.0.4",
47
- "@atlaskit/icon": "^27.10.0",
45
+ "@atlaskit/editor-toolbar": "^0.3.0",
46
+ "@atlaskit/editor-toolbar-model": "^0.1.0",
47
+ "@atlaskit/icon": "^27.12.0",
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/prosemirror-input-rules": "^3.4.0",
50
- "@atlaskit/tmp-editor-statsig": "^9.25.0",
50
+ "@atlaskit/tmp-editor-statsig": "^9.28.0",
51
51
  "@babel/runtime": "^7.0.0",
52
52
  "@emotion/react": "^11.7.1",
53
53
  "uuid": "^3.1.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^107.19.0",
56
+ "@atlaskit/editor-common": "^107.23.0",
57
57
  "react": "^18.2.0",
58
58
  "react-dom": "^18.2.0",
59
59
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -61,9 +61,9 @@
61
61
  "devDependencies": {
62
62
  "@atlaskit/activity-provider": "^2.5.0",
63
63
  "@atlaskit/link-test-helpers": "^8.3.0",
64
- "@atlaskit/media-test-helpers": "^37.0.0",
64
+ "@atlaskit/media-test-helpers": "^38.0.0",
65
65
  "@atlaskit/ssr": "workspace:^",
66
- "@atlaskit/util-data-test": "^18.0.0",
66
+ "@atlaskit/util-data-test": "^18.1.0",
67
67
  "@atlaskit/visual-regression": "workspace:^",
68
68
  "@testing-library/react": "^13.4.0",
69
69
  "raf-stub": "^2.0.1",