@atlaskit/editor-core 185.1.2 → 185.1.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/create-editor/create-editor.js +4 -0
  3. package/dist/cjs/editor-next/editor-internal.js +2 -1
  4. package/dist/cjs/test-utils.js +4 -0
  5. package/dist/cjs/ui/Appearance/Chromeless.js +4 -2
  6. package/dist/cjs/ui/Appearance/Comment/Comment.js +5 -6
  7. package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -1
  8. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +2 -4
  9. package/dist/cjs/ui/Appearance/FullPage/StyledComponents.js +1 -1
  10. package/dist/cjs/ui/Appearance/Mobile.js +29 -4
  11. package/dist/cjs/ui/AppearanceComponents/Mobile.js +7 -5
  12. package/dist/cjs/ui/ContextPanel/index.js +7 -1
  13. package/dist/cjs/ui/PluginSlot/index.js +11 -5
  14. package/dist/cjs/ui/PluginSlot/mount-plugin-hooks.js +34 -0
  15. package/dist/cjs/version-wrapper.js +1 -1
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/create-editor/create-editor.js +4 -0
  18. package/dist/es2019/editor-next/editor-internal.js +2 -1
  19. package/dist/es2019/test-utils.js +4 -0
  20. package/dist/es2019/ui/Appearance/Chromeless.js +4 -2
  21. package/dist/es2019/ui/Appearance/Comment/Comment.js +5 -6
  22. package/dist/es2019/ui/Appearance/FullPage/FullPage.js +2 -1
  23. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +2 -4
  24. package/dist/es2019/ui/Appearance/FullPage/StyledComponents.js +6 -1
  25. package/dist/es2019/ui/Appearance/Mobile.js +29 -4
  26. package/dist/es2019/ui/AppearanceComponents/Mobile.js +7 -6
  27. package/dist/es2019/ui/ContextPanel/index.js +6 -1
  28. package/dist/es2019/ui/PluginSlot/index.js +11 -5
  29. package/dist/es2019/ui/PluginSlot/mount-plugin-hooks.js +27 -0
  30. package/dist/es2019/version-wrapper.js +1 -1
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/create-editor/create-editor.js +4 -0
  33. package/dist/esm/editor-next/editor-internal.js +2 -1
  34. package/dist/esm/test-utils.js +4 -0
  35. package/dist/esm/ui/Appearance/Chromeless.js +4 -2
  36. package/dist/esm/ui/Appearance/Comment/Comment.js +5 -6
  37. package/dist/esm/ui/Appearance/FullPage/FullPage.js +2 -1
  38. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +2 -4
  39. package/dist/esm/ui/Appearance/FullPage/StyledComponents.js +1 -1
  40. package/dist/esm/ui/Appearance/Mobile.js +29 -4
  41. package/dist/esm/ui/AppearanceComponents/Mobile.js +6 -5
  42. package/dist/esm/ui/ContextPanel/index.js +5 -1
  43. package/dist/esm/ui/PluginSlot/index.js +11 -5
  44. package/dist/esm/ui/PluginSlot/mount-plugin-hooks.js +27 -0
  45. package/dist/esm/version-wrapper.js +1 -1
  46. package/dist/esm/version.json +1 -1
  47. package/dist/types/create-editor/get-plugins.d.ts +2 -1
  48. package/dist/types/test-utils.d.ts +2 -1
  49. package/dist/types/types/editor-appearance-component.d.ts +3 -1
  50. package/dist/types/types/editor-config.d.ts +2 -1
  51. package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +3 -1
  52. package/dist/types/ui/Appearance/Mobile.d.ts +1 -1
  53. package/dist/types/ui/AppearanceComponents/Mobile.d.ts +8 -8
  54. package/dist/types/ui/ContextPanel/index.d.ts +1 -0
  55. package/dist/types/ui/PluginSlot/index.d.ts +3 -1
  56. package/dist/types/ui/PluginSlot/mount-plugin-hooks.d.ts +10 -0
  57. package/dist/types-ts4.5/create-editor/get-plugins.d.ts +2 -1
  58. package/dist/types-ts4.5/test-utils.d.ts +2 -1
  59. package/dist/types-ts4.5/types/editor-appearance-component.d.ts +3 -1
  60. package/dist/types-ts4.5/types/editor-config.d.ts +2 -1
  61. package/dist/types-ts4.5/ui/Appearance/FullPage/FullPageContentArea.d.ts +3 -1
  62. package/dist/types-ts4.5/ui/Appearance/Mobile.d.ts +1 -1
  63. package/dist/types-ts4.5/ui/AppearanceComponents/Mobile.d.ts +8 -8
  64. package/dist/types-ts4.5/ui/ContextPanel/index.d.ts +1 -0
  65. package/dist/types-ts4.5/ui/PluginSlot/index.d.ts +3 -1
  66. package/dist/types-ts4.5/ui/PluginSlot/mount-plugin-hooks.d.ts +10 -0
  67. package/package.json +3 -3
  68. package/report.api.md +3 -0
  69. package/tmp/api-report-tmp.d.ts +3 -0
  70. package/dist/cjs/ui/WidthEmitter/index.js +0 -64
  71. package/dist/es2019/ui/WidthEmitter/index.js +0 -56
  72. package/dist/esm/ui/WidthEmitter/index.js +0 -53
  73. package/dist/types/ui/WidthEmitter/index.d.ts +0 -7
  74. package/dist/types-ts4.5/ui/WidthEmitter/index.d.ts +0 -7
@@ -7,7 +7,7 @@ import { MarkConfig, NodeConfig } from '../types/pm-config';
7
7
  import { EditorReactContext } from '../types/editor-react-context';
8
8
  import { FeatureFlags } from '../types/feature-flags';
9
9
  import { IntlShape } from 'react-intl-next';
10
- import { UIComponentFactory } from '@atlaskit/editor-common/types';
10
+ import type { UIComponentFactory, ReactHookFactory } from '@atlaskit/editor-common/types';
11
11
  export type LightPMPluginFactoryParams = {
12
12
  schema: Schema;
13
13
  dispatch: Dispatch;
@@ -38,6 +38,7 @@ export interface LightEditorPlugin {
38
38
  nodes?: () => NodeConfig[];
39
39
  pmPlugins?: (pluginOptions?: any) => Array<LightPMPlugin>;
40
40
  contentComponent?: UIComponentFactory;
41
+ usePluginHook?: ReactHookFactory;
41
42
  pluginsOptions?: Record<string, any>;
42
43
  onEditorViewStateUpdated?: OnEditorViewStateUpdated;
43
44
  }
@@ -8,12 +8,13 @@ export type { LightEditorPlugin } from './create-editor/get-plugins';
8
8
  export type { DispatchAnalyticsEvent } from './plugins/analytics/types';
9
9
  export type { FeatureFlags } from './types/feature-flags';
10
10
  import { EditorPresetBuilder, type EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
11
- import type { AllEditorPresetPluginTypes, UIComponentFactory } from '@atlaskit/editor-common/types';
11
+ import type { AllEditorPresetPluginTypes, UIComponentFactory, ReactHookFactory } from '@atlaskit/editor-common/types';
12
12
  export interface LightEditorConfig {
13
13
  nodes: NodeConfig[];
14
14
  marks: MarkConfig[];
15
15
  plugins: Array<LightPMPlugin>;
16
16
  contentComponents: UIComponentFactory[];
17
+ pluginHooks: ReactHookFactory[];
17
18
  onEditorViewStateUpdatedCallbacks: Array<OnEditorViewStateUpdated>;
18
19
  }
19
20
  export declare function getFireAnalytics(editorView: EditorView): any;
@@ -8,11 +8,12 @@ import { UIComponentFactory } from '../types/ui-components';
8
8
  import { ReactComponents, PrimaryToolbarComponents, UseStickyToolbarType } from '../types/editor-props';
9
9
  import { ToolbarUIComponentFactory } from '../ui/Toolbar/types';
10
10
  import { CollabEditOptions } from '../plugins/collab-edit/types';
11
- import { DispatchAnalyticsEvent } from '../plugins/analytics';
11
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
12
12
  import { EditorAppearance } from './editor-appearance';
13
13
  import { MenuItem } from '../ui/DropdownMenu/types';
14
14
  import { ReactElement } from 'react';
15
15
  import { FeatureFlags } from './feature-flags';
16
+ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
16
17
  export interface EditorAppearanceComponentProps {
17
18
  appearance?: EditorAppearance;
18
19
  onSave?: (editorView: EditorView) => void;
@@ -26,6 +27,7 @@ export interface EditorAppearanceComponentProps {
26
27
  maxHeight?: number;
27
28
  minHeight?: number;
28
29
  contentComponents?: UIComponentFactory[];
30
+ pluginHooks?: ReactHookFactory[];
29
31
  primaryToolbarComponents?: ToolbarUIComponentFactory[];
30
32
  primaryToolbarIconBefore?: ReactElement;
31
33
  secondaryToolbarComponents?: UIComponentFactory[];
@@ -2,7 +2,7 @@ import { ToolbarUIComponentFactory } from '../ui/Toolbar/types';
2
2
  import { Transaction, EditorState } from 'prosemirror-state';
3
3
  import { PMPlugin } from './pm-plugin';
4
4
  import { MarkConfig, NodeConfig } from './pm-config';
5
- import { UIComponentFactory } from './ui-components';
5
+ import type { UIComponentFactory, ReactHookFactory } from '@atlaskit/editor-common/types';
6
6
  type EditorViewStateUpdatedCallbackProps = {
7
7
  readonly originalTransaction: Readonly<Transaction>;
8
8
  readonly transactions: Transaction[];
@@ -14,6 +14,7 @@ export interface EditorConfig {
14
14
  marks: MarkConfig[];
15
15
  pmPlugins: Array<PMPlugin>;
16
16
  contentComponents: UIComponentFactory[];
17
+ pluginHooks: ReactHookFactory[];
17
18
  primaryToolbarComponents: ToolbarUIComponentFactory[];
18
19
  secondaryToolbarComponents: UIComponentFactory[];
19
20
  onEditorViewStateUpdatedCallbacks: Array<{
@@ -5,11 +5,13 @@ import { WrappedComponentProps } from 'react-intl-next';
5
5
  import EditorActions from '../../../actions';
6
6
  import { EventDispatcher } from '../../../event-dispatcher';
7
7
  import { ReactComponents, EditorAppearance, UIComponentFactory } from '../../../types';
8
- import { DispatchAnalyticsEvent } from '../../../plugins/analytics';
8
+ import { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
9
+ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
9
10
  interface FullPageEditorContentAreaProps {
10
11
  appearance: EditorAppearance | undefined;
11
12
  contentArea: HTMLElement | undefined;
12
13
  contentComponents: UIComponentFactory[] | undefined;
14
+ pluginHooks: ReactHookFactory[] | undefined;
13
15
  contextPanel: ReactComponents | undefined;
14
16
  customContentComponents: ReactComponents | undefined;
15
17
  disabled: boolean | undefined;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { EditorAppearanceComponentProps } from '../../types';
3
- export default function Mobile({ editorView, maxHeight, persistScrollGutter, editorDOMElement, disabled, }: EditorAppearanceComponentProps): JSX.Element;
3
+ export default function Mobile({ editorView, maxHeight, persistScrollGutter, editorDOMElement, disabled, contentComponents, editorActions, eventDispatcher, dispatchAnalyticsEvent, providerFactory, appearance, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, innerRef, pluginHooks, }: EditorAppearanceComponentProps): JSX.Element;
@@ -1,12 +1,12 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
- import { jsx } from '@emotion/react';
4
3
  import { EditorView } from 'prosemirror-view';
5
- type MobileAppearanceProps = React.PropsWithChildren<{
4
+ export declare const MobileAppearance: React.ForwardRefExoticComponent<{
6
5
  editorView: EditorView | null;
7
- maxHeight?: number;
8
- persistScrollGutter?: boolean;
9
- editorDisabled?: boolean;
10
- }>;
11
- export declare function MobileAppearance({ editorView, persistScrollGutter, children, editorDisabled, }: MobileAppearanceProps): jsx.JSX.Element;
12
- export {};
6
+ maxHeight?: number | undefined;
7
+ persistScrollGutter?: boolean | undefined;
8
+ editorDisabled?: boolean | undefined;
9
+ children?: React.ReactNode;
10
+ } & {
11
+ children?: React.ReactNode;
12
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -10,6 +10,7 @@ export type Props = {
10
10
  };
11
11
  type EditorWidth = WidthPluginState & {
12
12
  contentBreakoutModes: BreakoutMarkAttrs['mode'][];
13
+ containerWidth?: number;
13
14
  };
14
15
  export declare const shouldPanelBePositionedOverEditor: (editorWidth: EditorWidth, panelWidth: number) => boolean;
15
16
  export declare const panel: import("@emotion/react").SerializedStyles;
@@ -6,9 +6,11 @@ import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
6
  import { EditorAppearance, UIComponentFactory } from '../../types';
7
7
  import { EventDispatcher } from '../../event-dispatcher';
8
8
  import EditorActions from '../../actions';
9
- import { DispatchAnalyticsEvent } from '../../plugins/analytics';
9
+ import { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
10
+ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
10
11
  export interface Props {
11
12
  items?: UIComponentFactory[];
13
+ pluginHooks?: ReactHookFactory[];
12
14
  editorView?: EditorView;
13
15
  editorActions?: EditorActions;
14
16
  eventDispatcher?: EventDispatcher;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
3
+ import { EditorView } from 'prosemirror-view';
4
+ interface MountPluginHooksProps {
5
+ editorView: EditorView | undefined;
6
+ pluginHooks: ReactHookFactory[] | undefined;
7
+ containerElement: HTMLElement | null;
8
+ }
9
+ export declare function MountPluginHooks({ pluginHooks, editorView, containerElement, }: MountPluginHooksProps): JSX.Element | null;
10
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.1.2",
3
+ "version": "185.1.3",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/code": "^14.6.0",
50
50
  "@atlaskit/date": "^0.10.0",
51
51
  "@atlaskit/datetime-picker": "^12.7.0",
52
- "@atlaskit/editor-common": "^74.4.0",
52
+ "@atlaskit/editor-common": "^74.5.0",
53
53
  "@atlaskit/editor-json-transformer": "^8.9.0",
54
54
  "@atlaskit/editor-markdown-transformer": "^5.2.0",
55
55
  "@atlaskit/editor-palette": "1.4.2",
@@ -59,7 +59,7 @@
59
59
  "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
60
60
  "@atlaskit/editor-plugin-grid": "^0.1.0",
61
61
  "@atlaskit/editor-plugin-table": "^1.5.0",
62
- "@atlaskit/editor-plugin-width": "^0.0.1",
62
+ "@atlaskit/editor-plugin-width": "^0.1.0",
63
63
  "@atlaskit/editor-shared-styles": "^2.4.0",
64
64
  "@atlaskit/editor-tables": "^2.3.0",
65
65
  "@atlaskit/emoji": "^67.4.0",
package/report.api.md CHANGED
@@ -131,6 +131,7 @@ import { QuickInsertItemId } from '@atlaskit/editor-common/provider-factory';
131
131
  import { QuickInsertProvider } from '@atlaskit/editor-common/provider-factory';
132
132
  import { default as React_2 } from 'react';
133
133
  import { ReactElement } from 'react';
134
+ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
134
135
  import { RefObject } from 'react';
135
136
  import { ReplaceRawValue } from '@atlaskit/editor-common/types';
136
137
  import type { ResolvedEditorState } from '@atlaskit/collab-provider';
@@ -745,6 +746,8 @@ interface EditorConfig {
745
746
  callback: (props: EditorViewStateUpdatedCallbackProps) => void;
746
747
  }>;
747
748
  // (undocumented)
749
+ pluginHooks: ReactHookFactory[];
750
+ // (undocumented)
748
751
  pmPlugins: Array<PMPlugin>;
749
752
  // (undocumented)
750
753
  primaryToolbarComponents: ToolbarUIComponentFactory[];
@@ -120,6 +120,7 @@ import { QuickInsertItemId } from '@atlaskit/editor-common/provider-factory';
120
120
  import { QuickInsertProvider } from '@atlaskit/editor-common/provider-factory';
121
121
  import { default as React_2 } from 'react';
122
122
  import { ReactElement } from 'react';
123
+ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
123
124
  import { RefObject } from 'react';
124
125
  import { ReplaceRawValue } from '@atlaskit/editor-common/types';
125
126
  import type { ResolvedEditorState } from '@atlaskit/collab-provider';
@@ -678,6 +679,8 @@ interface EditorConfig {
678
679
  callback: (props: EditorViewStateUpdatedCallbackProps) => void;
679
680
  }>;
680
681
  // (undocumented)
682
+ pluginHooks: ReactHookFactory[];
683
+ // (undocumented)
681
684
  pmPlugins: Array<PMPlugin>;
682
685
  // (undocumented)
683
686
  primaryToolbarComponents: ToolbarUIComponentFactory[];
@@ -1,64 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _ui = require("@atlaskit/editor-common/ui");
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
- // TODO: ED-17870 This workaround will be removed here.
15
- // @ts-ignore
16
- var widthPluginKey = {
17
- key: 'widthPlugin$',
18
- getState: function getState(state) {
19
- return state['widthPlugin$'];
20
- }
21
- };
22
- // Why do we need this? Why not just use the width from the context directly rather than this?
23
- // Well my friend - some of the VR tests break, seemingly due to the fact that existing behaviour
24
- // assumes the initial value is 0, the width from context may not start from 0 however.
25
- // We should investigate further if we can remove this entirely but for now we'll do this
26
- // awkward workaround to keep the behaviour consistent.
27
- var useListener = function useListener(contextValue) {
28
- var _useState = (0, _react.useState)(0),
29
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
30
- value = _useState2[0],
31
- setValue = _useState2[1];
32
- (0, _react.useEffect)(function () {
33
- setValue(contextValue);
34
- }, [contextValue]);
35
- return value;
36
- };
37
- var WidthEmitter = function WidthEmitter(_ref) {
38
- var editorView = _ref.editorView;
39
- var _useContext = (0, _react.useContext)(_ui.ContextPanel),
40
- contextPanelWidthContext = _useContext.width;
41
- var _useContext2 = (0, _react.useContext)(_ui.WidthContext),
42
- containerWidthContext = _useContext2.width;
43
- var containerWidth = useListener(containerWidthContext);
44
- var contextPanelWidth = useListener(contextPanelWidthContext);
45
- (0, _react.useEffect)(function () {
46
- var width = containerWidth - contextPanelWidth;
47
- if (width <= 0 || isNaN(width) || !editorView) {
48
- return;
49
- }
50
- var dom = editorView.dom,
51
- tr = editorView.state.tr,
52
- dispatch = editorView.dispatch;
53
- tr.setMeta(widthPluginKey, {
54
- width: width,
55
- containerWidth: containerWidth,
56
- lineLength: dom ? dom.clientWidth : undefined
57
- });
58
- dispatch(tr);
59
- return function () {};
60
- }, [editorView, contextPanelWidth, containerWidth]);
61
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
62
- };
63
- var _default = WidthEmitter;
64
- exports.default = _default;
@@ -1,56 +0,0 @@
1
- import React, { useContext, useEffect, useState } from 'react';
2
- import { ContextPanel, WidthContext } from '@atlaskit/editor-common/ui';
3
- // TODO: ED-17870 This workaround will be removed here.
4
- // @ts-ignore
5
- const widthPluginKey = {
6
- key: 'widthPlugin$',
7
- getState: state => {
8
- return state['widthPlugin$'];
9
- }
10
- };
11
- // Why do we need this? Why not just use the width from the context directly rather than this?
12
- // Well my friend - some of the VR tests break, seemingly due to the fact that existing behaviour
13
- // assumes the initial value is 0, the width from context may not start from 0 however.
14
- // We should investigate further if we can remove this entirely but for now we'll do this
15
- // awkward workaround to keep the behaviour consistent.
16
- const useListener = contextValue => {
17
- const [value, setValue] = useState(0);
18
- useEffect(() => {
19
- setValue(contextValue);
20
- }, [contextValue]);
21
- return value;
22
- };
23
- const WidthEmitter = ({
24
- editorView
25
- }) => {
26
- const {
27
- width: contextPanelWidthContext
28
- } = useContext(ContextPanel);
29
- const {
30
- width: containerWidthContext
31
- } = useContext(WidthContext);
32
- const containerWidth = useListener(containerWidthContext);
33
- const contextPanelWidth = useListener(contextPanelWidthContext);
34
- useEffect(() => {
35
- const width = containerWidth - contextPanelWidth;
36
- if (width <= 0 || isNaN(width) || !editorView) {
37
- return;
38
- }
39
- const {
40
- dom,
41
- state: {
42
- tr
43
- },
44
- dispatch
45
- } = editorView;
46
- tr.setMeta(widthPluginKey, {
47
- width,
48
- containerWidth,
49
- lineLength: dom ? dom.clientWidth : undefined
50
- });
51
- dispatch(tr);
52
- return () => {};
53
- }, [editorView, contextPanelWidth, containerWidth]);
54
- return /*#__PURE__*/React.createElement(React.Fragment, null);
55
- };
56
- export default WidthEmitter;
@@ -1,53 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useContext, useEffect, useState } from 'react';
3
- import { ContextPanel, WidthContext } from '@atlaskit/editor-common/ui';
4
- // TODO: ED-17870 This workaround will be removed here.
5
- // @ts-ignore
6
- var widthPluginKey = {
7
- key: 'widthPlugin$',
8
- getState: function getState(state) {
9
- return state['widthPlugin$'];
10
- }
11
- };
12
- // Why do we need this? Why not just use the width from the context directly rather than this?
13
- // Well my friend - some of the VR tests break, seemingly due to the fact that existing behaviour
14
- // assumes the initial value is 0, the width from context may not start from 0 however.
15
- // We should investigate further if we can remove this entirely but for now we'll do this
16
- // awkward workaround to keep the behaviour consistent.
17
- var useListener = function useListener(contextValue) {
18
- var _useState = useState(0),
19
- _useState2 = _slicedToArray(_useState, 2),
20
- value = _useState2[0],
21
- setValue = _useState2[1];
22
- useEffect(function () {
23
- setValue(contextValue);
24
- }, [contextValue]);
25
- return value;
26
- };
27
- var WidthEmitter = function WidthEmitter(_ref) {
28
- var editorView = _ref.editorView;
29
- var _useContext = useContext(ContextPanel),
30
- contextPanelWidthContext = _useContext.width;
31
- var _useContext2 = useContext(WidthContext),
32
- containerWidthContext = _useContext2.width;
33
- var containerWidth = useListener(containerWidthContext);
34
- var contextPanelWidth = useListener(contextPanelWidthContext);
35
- useEffect(function () {
36
- var width = containerWidth - contextPanelWidth;
37
- if (width <= 0 || isNaN(width) || !editorView) {
38
- return;
39
- }
40
- var dom = editorView.dom,
41
- tr = editorView.state.tr,
42
- dispatch = editorView.dispatch;
43
- tr.setMeta(widthPluginKey, {
44
- width: width,
45
- containerWidth: containerWidth,
46
- lineLength: dom ? dom.clientWidth : undefined
47
- });
48
- dispatch(tr);
49
- return function () {};
50
- }, [editorView, contextPanelWidth, containerWidth]);
51
- return /*#__PURE__*/React.createElement(React.Fragment, null);
52
- };
53
- export default WidthEmitter;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { EditorView } from 'prosemirror-view';
3
- export interface Props {
4
- editorView?: EditorView;
5
- }
6
- declare const WidthEmitter: ({ editorView }: Props) => JSX.Element;
7
- export default WidthEmitter;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { EditorView } from 'prosemirror-view';
3
- export interface Props {
4
- editorView?: EditorView;
5
- }
6
- declare const WidthEmitter: ({ editorView }: Props) => JSX.Element;
7
- export default WidthEmitter;