@atlaskit/editor-core 186.0.1 → 187.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 +12 -0
- package/dist/cjs/labs-next.js +0 -65
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/labs-next.js +0 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/labs-next.js +0 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +2 -3
- package/dist/types/labs-next.d.ts +0 -7
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +2 -3
- package/dist/types-ts4.5/labs-next.d.ts +0 -7
- package/package.json +1 -1
- package/report.api.md +2 -26
- package/dist/cjs/labs/next/ContentComponents.js +0 -43
- package/dist/cjs/labs/next/Editor.js +0 -76
- package/dist/cjs/labs/next/Toolbar.js +0 -39
- package/dist/cjs/labs/next/full-page.js +0 -127
- package/dist/cjs/labs/next/internal/components/EditorContent.js +0 -25
- package/dist/cjs/labs/next/internal/components/EditorInternal.js +0 -81
- package/dist/cjs/labs/next/internal/context/preset-context.js +0 -15
- package/dist/cjs/labs/next/internal/context/shared-config.js +0 -77
- package/dist/cjs/labs/next/internal/editor-props-type.js +0 -5
- package/dist/cjs/labs/next/internal/hooks/use-analytics/index.js +0 -41
- package/dist/cjs/labs/next/internal/hooks/use-editor/create-dispatch-transaction.js +0 -62
- package/dist/cjs/labs/next/internal/hooks/use-editor/create-editor.js +0 -94
- package/dist/cjs/labs/next/internal/hooks/use-editor/index.js +0 -193
- package/dist/cjs/labs/next/mobile.js +0 -37
- package/dist/cjs/labs/next/presets/cxhtml.js +0 -117
- package/dist/cjs/labs/next/presets/mobile.js +0 -130
- package/dist/cjs/labs/next/presets/utils.js +0 -30
- package/dist/es2019/labs/next/ContentComponents.js +0 -38
- package/dist/es2019/labs/next/Editor.js +0 -46
- package/dist/es2019/labs/next/Toolbar.js +0 -34
- package/dist/es2019/labs/next/full-page.js +0 -192
- package/dist/es2019/labs/next/internal/components/EditorContent.js +0 -17
- package/dist/es2019/labs/next/internal/components/EditorInternal.js +0 -66
- package/dist/es2019/labs/next/internal/context/preset-context.js +0 -5
- package/dist/es2019/labs/next/internal/context/shared-config.js +0 -34
- package/dist/es2019/labs/next/internal/editor-props-type.js +0 -1
- package/dist/es2019/labs/next/internal/hooks/use-analytics/index.js +0 -32
- package/dist/es2019/labs/next/internal/hooks/use-editor/create-dispatch-transaction.js +0 -51
- package/dist/es2019/labs/next/internal/hooks/use-editor/create-editor.js +0 -85
- package/dist/es2019/labs/next/internal/hooks/use-editor/index.js +0 -179
- package/dist/es2019/labs/next/mobile.js +0 -27
- package/dist/es2019/labs/next/presets/cxhtml.js +0 -106
- package/dist/es2019/labs/next/presets/mobile.js +0 -118
- package/dist/es2019/labs/next/presets/utils.js +0 -22
- package/dist/esm/labs/next/ContentComponents.js +0 -36
- package/dist/esm/labs/next/Editor.js +0 -48
- package/dist/esm/labs/next/Toolbar.js +0 -32
- package/dist/esm/labs/next/full-page.js +0 -121
- package/dist/esm/labs/next/internal/components/EditorContent.js +0 -17
- package/dist/esm/labs/next/internal/components/EditorInternal.js +0 -73
- package/dist/esm/labs/next/internal/context/preset-context.js +0 -7
- package/dist/esm/labs/next/internal/context/shared-config.js +0 -68
- package/dist/esm/labs/next/internal/editor-props-type.js +0 -1
- package/dist/esm/labs/next/internal/hooks/use-analytics/index.js +0 -34
- package/dist/esm/labs/next/internal/hooks/use-editor/create-dispatch-transaction.js +0 -55
- package/dist/esm/labs/next/internal/hooks/use-editor/create-editor.js +0 -88
- package/dist/esm/labs/next/internal/hooks/use-editor/index.js +0 -185
- package/dist/esm/labs/next/mobile.js +0 -25
- package/dist/esm/labs/next/presets/cxhtml.js +0 -108
- package/dist/esm/labs/next/presets/mobile.js +0 -120
- package/dist/esm/labs/next/presets/utils.js +0 -23
- package/dist/types/labs/next/ContentComponents.d.ts +0 -8
- package/dist/types/labs/next/Editor.d.ts +0 -27
- package/dist/types/labs/next/Toolbar.d.ts +0 -6
- package/dist/types/labs/next/full-page.d.ts +0 -9
- package/dist/types/labs/next/internal/components/EditorContent.d.ts +0 -7
- package/dist/types/labs/next/internal/components/EditorInternal.d.ts +0 -9
- package/dist/types/labs/next/internal/context/preset-context.d.ts +0 -5
- package/dist/types/labs/next/internal/context/shared-config.d.ts +0 -50
- package/dist/types/labs/next/internal/editor-props-type.d.ts +0 -29
- package/dist/types/labs/next/internal/hooks/use-analytics/index.d.ts +0 -8
- package/dist/types/labs/next/internal/hooks/use-editor/create-dispatch-transaction.d.ts +0 -6
- package/dist/types/labs/next/internal/hooks/use-editor/create-editor.d.ts +0 -19
- package/dist/types/labs/next/internal/hooks/use-editor/index.d.ts +0 -11
- package/dist/types/labs/next/mobile.d.ts +0 -12
- package/dist/types/labs/next/presets/cxhtml.d.ts +0 -338
- package/dist/types/labs/next/presets/mobile.d.ts +0 -343
- package/dist/types/labs/next/presets/utils.d.ts +0 -3
- package/dist/types-ts4.5/labs/next/ContentComponents.d.ts +0 -8
- package/dist/types-ts4.5/labs/next/Editor.d.ts +0 -27
- package/dist/types-ts4.5/labs/next/Toolbar.d.ts +0 -6
- package/dist/types-ts4.5/labs/next/full-page.d.ts +0 -9
- package/dist/types-ts4.5/labs/next/internal/components/EditorContent.d.ts +0 -7
- package/dist/types-ts4.5/labs/next/internal/components/EditorInternal.d.ts +0 -9
- package/dist/types-ts4.5/labs/next/internal/context/preset-context.d.ts +0 -5
- package/dist/types-ts4.5/labs/next/internal/context/shared-config.d.ts +0 -50
- package/dist/types-ts4.5/labs/next/internal/editor-props-type.d.ts +0 -29
- package/dist/types-ts4.5/labs/next/internal/hooks/use-analytics/index.d.ts +0 -8
- package/dist/types-ts4.5/labs/next/internal/hooks/use-editor/create-dispatch-transaction.d.ts +0 -6
- package/dist/types-ts4.5/labs/next/internal/hooks/use-editor/create-editor.d.ts +0 -19
- package/dist/types-ts4.5/labs/next/internal/hooks/use-editor/index.d.ts +0 -14
- package/dist/types-ts4.5/labs/next/mobile.d.ts +0 -12
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +0 -414
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +0 -419
- package/dist/types-ts4.5/labs/next/presets/utils.d.ts +0 -3
- package/tmp/api-report-tmp.d.ts +0 -2278
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { pluginKey as disabledPluginKey } from '../../plugins/editor-disabled';
|
|
3
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
4
|
-
import PluginSlot from '../../ui/PluginSlot';
|
|
5
|
-
import { useEditorSharedConfig } from './Editor';
|
|
6
|
-
export function ContentComponents(_ref) {
|
|
7
|
-
var disabled = _ref.disabled,
|
|
8
|
-
wrapperElement = _ref.wrapperElement,
|
|
9
|
-
containerElement = _ref.containerElement;
|
|
10
|
-
var config = useEditorSharedConfig();
|
|
11
|
-
if (!config) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
15
|
-
plugins: {
|
|
16
|
-
disabled: disabledPluginKey
|
|
17
|
-
},
|
|
18
|
-
render: function render(_ref2) {
|
|
19
|
-
var _disabled$editorDisab;
|
|
20
|
-
var disabled = _ref2.disabled;
|
|
21
|
-
return /*#__PURE__*/React.createElement(PluginSlot, {
|
|
22
|
-
editorView: config.editorView,
|
|
23
|
-
eventDispatcher: config.eventDispatcher,
|
|
24
|
-
providerFactory: config.providerFactory,
|
|
25
|
-
items: config.contentComponents,
|
|
26
|
-
popupsMountPoint: config.popupsMountPoint,
|
|
27
|
-
popupsBoundariesElement: config.popupsBoundariesElement,
|
|
28
|
-
popupsScrollableElement: config.popupsScrollableElement,
|
|
29
|
-
containerElement: containerElement // TODO: Figure out how to pass containerElement here ED-8448
|
|
30
|
-
,
|
|
31
|
-
wrapperElement: wrapperElement,
|
|
32
|
-
disabled: (_disabled$editorDisab = disabled === null || disabled === void 0 ? void 0 : disabled.editorDisabled) !== null && _disabled$editorDisab !== void 0 ? _disabled$editorDisab : false
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { IntlProvider } from 'react-intl-next';
|
|
4
|
-
import { PortalRenderer, PortalProvider } from '@atlaskit/editor-common/portal-provider';
|
|
5
|
-
import { EditorInternal } from './internal/components/EditorInternal';
|
|
6
|
-
import { usePresetContext, PresetProvider } from './internal/context/preset-context';
|
|
7
|
-
import { EditorSharedConfigConsumer, useEditorSharedConfig } from './internal/context/shared-config';
|
|
8
|
-
import { EditorContent } from './internal/components/EditorContent';
|
|
9
|
-
/**
|
|
10
|
-
* Main Editor component. Use in combination with `EditorContent` and a `Preset`.
|
|
11
|
-
* Internally it constructs `ProseMirror View` and mounts it to `EditorContent`.
|
|
12
|
-
*
|
|
13
|
-
* `EditorContent` can be wrapped to implement any layout/design requirements.
|
|
14
|
-
*
|
|
15
|
-
* ```js
|
|
16
|
-
* <Preset>
|
|
17
|
-
* <Editor>
|
|
18
|
-
* <EditorContent/>
|
|
19
|
-
* </Editor>
|
|
20
|
-
* </Preset>
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
function Editor(props) {
|
|
24
|
-
var plugins = usePresetContext();
|
|
25
|
-
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
26
|
-
locale: "en"
|
|
27
|
-
}, /*#__PURE__*/React.createElement(PortalProvider, {
|
|
28
|
-
onAnalyticsEvent: props.onAnalyticsEvent,
|
|
29
|
-
render: function render(portalProviderAPI) {
|
|
30
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorInternal, _extends({}, props, {
|
|
31
|
-
plugins: plugins.length ? plugins : props.plugins,
|
|
32
|
-
portalProviderAPI: portalProviderAPI,
|
|
33
|
-
onAnalyticsEvent: props.onAnalyticsEvent
|
|
34
|
-
})), /*#__PURE__*/React.createElement(PortalRenderer, {
|
|
35
|
-
portalProviderAPI: portalProviderAPI
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* Public API Exports.
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
export {
|
|
47
|
-
// Components
|
|
48
|
-
PresetProvider, Editor, EditorContent, EditorSharedConfigConsumer, useEditorSharedConfig };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { pluginKey as disabledPluginKey } from '../../plugins/editor-disabled';
|
|
3
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
4
|
-
import ToolBar from '../../ui/Toolbar';
|
|
5
|
-
import { useEditorSharedConfig } from './Editor';
|
|
6
|
-
export function Toolbar(_ref) {
|
|
7
|
-
var containerElement = _ref.containerElement;
|
|
8
|
-
var config = useEditorSharedConfig();
|
|
9
|
-
if (!config) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
13
|
-
plugins: {
|
|
14
|
-
disabled: disabledPluginKey
|
|
15
|
-
},
|
|
16
|
-
render: function render(_ref2) {
|
|
17
|
-
var _disabled$editorDisab;
|
|
18
|
-
var disabled = _ref2.disabled;
|
|
19
|
-
return /*#__PURE__*/React.createElement(ToolBar, {
|
|
20
|
-
editorView: config.editorView,
|
|
21
|
-
eventDispatcher: config.eventDispatcher,
|
|
22
|
-
providerFactory: config.providerFactory,
|
|
23
|
-
items: config.primaryToolbarComponents,
|
|
24
|
-
popupsMountPoint: config.popupsMountPoint,
|
|
25
|
-
popupsBoundariesElement: config.popupsBoundariesElement,
|
|
26
|
-
popupsScrollableElement: config.popupsScrollableElement,
|
|
27
|
-
disabled: (_disabled$editorDisab = disabled === null || disabled === void 0 ? void 0 : disabled.editorDisabled) !== null && _disabled$editorDisab !== void 0 ? _disabled$editorDisab : false,
|
|
28
|
-
containerElement: containerElement
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
5
|
-
/** @jsx jsx */
|
|
6
|
-
import rafSchedule from 'raf-schd';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { css, jsx } from '@emotion/react';
|
|
9
|
-
import { N30 } from '@atlaskit/theme/colors';
|
|
10
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
11
|
-
import { BaseTheme } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { akEditorMenuZIndex, akEditorToolbarKeylineHeight } from '@atlaskit/editor-shared-styles';
|
|
13
|
-
import ContentStyles from '../../ui/ContentStyles';
|
|
14
|
-
import { ClickAreaBlock } from '../../ui/Addon';
|
|
15
|
-
import { scrollbarStyles } from '../../ui/styles';
|
|
16
|
-
import { tableFullPageEditorStyles } from '@atlaskit/editor-plugin-table/ui/common-styles';
|
|
17
|
-
import AvatarsWithPluginState from '../../plugins/collab-edit/ui';
|
|
18
|
-
import { Editor, EditorContent, useEditorSharedConfig } from './Editor';
|
|
19
|
-
import { Toolbar } from './Toolbar';
|
|
20
|
-
import { ContentComponents } from './ContentComponents';
|
|
21
|
-
import { useCreateAnalyticsHandler } from './internal/hooks/use-analytics';
|
|
22
|
-
import { ContextPanelWidthProvider } from '@atlaskit/editor-common/ui';
|
|
23
|
-
var fullPageEditorWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: 340px;\n height: 100%;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n"])));
|
|
24
|
-
var scrollContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex-grow: 1;\n overflow-y: scroll;\n position: relative;\n display: flex;\n flex-direction: column;\n scroll-behavior: smooth;\n ", ";\n"])), scrollbarStyles);
|
|
25
|
-
var GUTTER_PADDING = 32;
|
|
26
|
-
var GUTTER_STYLE = {
|
|
27
|
-
padding: "0 ".concat(GUTTER_PADDING, "px")
|
|
28
|
-
};
|
|
29
|
-
var contentArea = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n height: 100%;\n box-sizing: border-box;\n"])));
|
|
30
|
-
var editorContentArea = function editorContentArea(theme) {
|
|
31
|
-
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n line-height: 24px;\n height: 100%;\n width: 100%;\n max-width: ", "px;\n padding-top: 50px;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n padding-bottom: 55px;\n\n & .ProseMirror {\n flex-grow: 1;\n box-sizing: border-box;\n }\n\n && .ProseMirror {\n & > * {\n clear: both;\n }\n > p,\n > ul,\n > ol,\n > h1,\n > h2,\n > h3,\n > h4,\n > h5,\n > h6 {\n clear: none;\n }\n }\n ", ";\n"])), theme.layoutMaxWidth + GUTTER_PADDING * 2, tableFullPageEditorStyles);
|
|
32
|
-
};
|
|
33
|
-
var mainToolbar = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: relative;\n align-items: center;\n box-shadow: 'none';\n\n transition: box-shadow 200ms;\n z-index: ", ";\n display: flex;\n height: 80px;\n flex-shrink: 0;\n background-color: ", ";\n\n & object {\n height: 0 !important;\n }\n"])), akEditorMenuZIndex, "var(--ds-surface, white)");
|
|
34
|
-
var mainToolbarWithKeyline = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ", "\n box-shadow: 0 ", "px 0 0 ", "\n"])), mainToolbar, akEditorToolbarKeylineHeight, "var(--ds-border, ".concat(N30, ")"));
|
|
35
|
-
var mainToolbarCustomComponentsSlot = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: flex-end;\n flex-grow: 1;\n"])));
|
|
36
|
-
var sidebarArea = css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n height: 100%;\n box-sizing: border-box;\n"])));
|
|
37
|
-
function useKeyline() {
|
|
38
|
-
var _React$useState = React.useState(false),
|
|
39
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
40
|
-
showKeyline = _React$useState2[0],
|
|
41
|
-
setShowKeyline = _React$useState2[1];
|
|
42
|
-
var scrollContainerRef = React.useRef(null);
|
|
43
|
-
React.useEffect(function () {
|
|
44
|
-
var current = scrollContainerRef.current;
|
|
45
|
-
var handleScroll = rafSchedule(function () {
|
|
46
|
-
if (!current) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
var scrollTop = current.scrollTop;
|
|
50
|
-
setShowKeyline(scrollTop > akEditorToolbarKeylineHeight);
|
|
51
|
-
});
|
|
52
|
-
if (!current) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
window.addEventListener('resize', handleScroll);
|
|
56
|
-
current.addEventListener('scroll', handleScroll);
|
|
57
|
-
handleScroll();
|
|
58
|
-
return function () {
|
|
59
|
-
if (current) {
|
|
60
|
-
current.removeEventListener('scroll', handleScroll);
|
|
61
|
-
}
|
|
62
|
-
window.removeEventListener('resize', handleScroll);
|
|
63
|
-
};
|
|
64
|
-
}, []);
|
|
65
|
-
return [showKeyline, scrollContainerRef];
|
|
66
|
-
}
|
|
67
|
-
function FullPage(props) {
|
|
68
|
-
var primaryToolbarComponents = props.primaryToolbarComponents,
|
|
69
|
-
contentComponents = props.contentComponents,
|
|
70
|
-
collabEdit = props.collabEdit,
|
|
71
|
-
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
72
|
-
contextPanel = props.contextPanel;
|
|
73
|
-
var handleAnalyticsEvent = useCreateAnalyticsHandler(createAnalyticsEvent);
|
|
74
|
-
var _useKeyline = useKeyline(),
|
|
75
|
-
_useKeyline2 = _slicedToArray(_useKeyline, 2),
|
|
76
|
-
showKeyline = _useKeyline2[0],
|
|
77
|
-
scrollContainerRef = _useKeyline2[1];
|
|
78
|
-
var config = useEditorSharedConfig();
|
|
79
|
-
var wrapperElementRef = /*#__PURE__*/React.createRef();
|
|
80
|
-
return jsx(ContextPanelWidthProvider, null, jsx(Editor, _extends({}, props, {
|
|
81
|
-
onAnalyticsEvent: handleAnalyticsEvent
|
|
82
|
-
}), jsx(BaseTheme, null, jsx("div", {
|
|
83
|
-
css: fullPageEditorWrapper,
|
|
84
|
-
className: "akEditor",
|
|
85
|
-
ref: wrapperElementRef
|
|
86
|
-
}, jsx("div", {
|
|
87
|
-
"data-testid": "ak-editor-main-toolbar",
|
|
88
|
-
css: showKeyline ? mainToolbarWithKeyline : mainToolbar
|
|
89
|
-
}, jsx(Toolbar, {
|
|
90
|
-
containerElement: scrollContainerRef.current
|
|
91
|
-
}), jsx("div", {
|
|
92
|
-
css: mainToolbarCustomComponentsSlot
|
|
93
|
-
}, !config ? null : jsx(AvatarsWithPluginState, {
|
|
94
|
-
editorView: config.editorView,
|
|
95
|
-
eventDispatcher: config.eventDispatcher,
|
|
96
|
-
inviteToEditHandler: collabEdit === null || collabEdit === void 0 ? void 0 : collabEdit.inviteToEditHandler,
|
|
97
|
-
isInviteToEditButtonSelected: collabEdit === null || collabEdit === void 0 ? void 0 : collabEdit.isInviteToEditButtonSelected,
|
|
98
|
-
featureFlags: {}
|
|
99
|
-
}), primaryToolbarComponents)), jsx("div", {
|
|
100
|
-
css: contentArea
|
|
101
|
-
}, jsx(ContentStyles, {
|
|
102
|
-
ref: scrollContainerRef,
|
|
103
|
-
className: "fabric-editor-popup-scroll-parent",
|
|
104
|
-
css: scrollContainer
|
|
105
|
-
}, jsx(ClickAreaBlock, {
|
|
106
|
-
editorView: config === null || config === void 0 ? void 0 : config.editorView
|
|
107
|
-
}, jsx("div", {
|
|
108
|
-
css: editorContentArea
|
|
109
|
-
}, jsx("div", {
|
|
110
|
-
style: GUTTER_STYLE,
|
|
111
|
-
className: "ak-editor-content-area"
|
|
112
|
-
}, contentComponents, jsx(EditorContent, null), jsx(ContentComponents, {
|
|
113
|
-
wrapperElement: wrapperElementRef.current,
|
|
114
|
-
containerElement: scrollContainerRef.current
|
|
115
|
-
}))))), contextPanel && jsx("div", {
|
|
116
|
-
css: sidebarArea
|
|
117
|
-
}, contextPanel))))));
|
|
118
|
-
}
|
|
119
|
-
FullPage.displayName = 'FullPageEditor';
|
|
120
|
-
var FullPageWithAnalytics = withAnalyticsEvents()(FullPage);
|
|
121
|
-
export { FullPageWithAnalytics as FullPage };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
var EditorContentContext = /*#__PURE__*/React.createContext(function () {});
|
|
3
|
-
var EditorContentProvider = EditorContentContext.Provider;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* ProseMirror View mount point.
|
|
7
|
-
*/
|
|
8
|
-
var EditorContent = /*#__PURE__*/React.memo(function () {
|
|
9
|
-
var handleRef = React.useContext(EditorContentContext);
|
|
10
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
-
style: {
|
|
12
|
-
height: '100%'
|
|
13
|
-
},
|
|
14
|
-
ref: handleRef
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
export { EditorContentProvider, EditorContent };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { WidthProvider } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { injectIntl } from 'react-intl-next';
|
|
6
|
-
import { useProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
7
|
-
import EditorContext from '../../../../ui/EditorContext';
|
|
8
|
-
import EditorActions from '../../../../actions';
|
|
9
|
-
import { EditorSharedConfigProvider } from '../context/shared-config';
|
|
10
|
-
import { useEditor } from '../hooks/use-editor';
|
|
11
|
-
import { EditorContentProvider } from './EditorContent';
|
|
12
|
-
function BaseEditorInternal(_ref, context) {
|
|
13
|
-
var onAnalyticsEvent = _ref.onAnalyticsEvent,
|
|
14
|
-
disabled = _ref.disabled,
|
|
15
|
-
transformer = _ref.transformer,
|
|
16
|
-
defaultValue = _ref.defaultValue,
|
|
17
|
-
plugins = _ref.plugins,
|
|
18
|
-
portalProviderAPI = _ref.portalProviderAPI,
|
|
19
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
20
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
21
|
-
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
22
|
-
onChange = _ref.onChange,
|
|
23
|
-
onDestroy = _ref.onDestroy,
|
|
24
|
-
onMount = _ref.onMount,
|
|
25
|
-
children = _ref.children,
|
|
26
|
-
intl = _ref.intl;
|
|
27
|
-
// Need to memoize editor actions otherwise in case when editor is not
|
|
28
|
-
// wrapped with EditorContext every prop change triggers all hooks
|
|
29
|
-
// that depend on editorActions
|
|
30
|
-
var maybeEditorActions = (context || {}).editorActions;
|
|
31
|
-
var editorActions = React.useMemo(function () {
|
|
32
|
-
return maybeEditorActions || new EditorActions();
|
|
33
|
-
}, [maybeEditorActions]);
|
|
34
|
-
|
|
35
|
-
// Get the provider factory from context
|
|
36
|
-
var providerFactory = useProviderFactory();
|
|
37
|
-
var getIntl = function getIntl() {
|
|
38
|
-
return intl;
|
|
39
|
-
};
|
|
40
|
-
var _useEditor = useEditor({
|
|
41
|
-
context: context,
|
|
42
|
-
editorActions: editorActions,
|
|
43
|
-
onAnalyticsEvent: onAnalyticsEvent,
|
|
44
|
-
disabled: disabled,
|
|
45
|
-
transformer: transformer,
|
|
46
|
-
defaultValue: defaultValue,
|
|
47
|
-
plugins: plugins,
|
|
48
|
-
portalProviderAPI: portalProviderAPI,
|
|
49
|
-
popupsMountPoint: popupsMountPoint,
|
|
50
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
51
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
52
|
-
onChange: onChange,
|
|
53
|
-
onDestroy: onDestroy,
|
|
54
|
-
onMount: onMount,
|
|
55
|
-
providerFactory: providerFactory,
|
|
56
|
-
featureFlags: {},
|
|
57
|
-
getIntl: getIntl
|
|
58
|
-
}),
|
|
59
|
-
_useEditor2 = _slicedToArray(_useEditor, 2),
|
|
60
|
-
editorSharedConfig = _useEditor2[0],
|
|
61
|
-
mountEditor = _useEditor2[1];
|
|
62
|
-
return /*#__PURE__*/React.createElement(WidthProvider, null, /*#__PURE__*/React.createElement(EditorContext, {
|
|
63
|
-
editorActions: editorActions
|
|
64
|
-
}, /*#__PURE__*/React.createElement(EditorSharedConfigProvider, {
|
|
65
|
-
value: editorSharedConfig
|
|
66
|
-
}, /*#__PURE__*/React.createElement(EditorContentProvider, {
|
|
67
|
-
value: mountEditor
|
|
68
|
-
}, children))));
|
|
69
|
-
}
|
|
70
|
-
BaseEditorInternal.contextTypes = {
|
|
71
|
-
editorActions: PropTypes.object
|
|
72
|
-
};
|
|
73
|
-
export var EditorInternal = injectIntl(BaseEditorInternal);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
var PresetContext = /*#__PURE__*/React.createContext([]);
|
|
3
|
-
var PresetProvider = PresetContext.Provider;
|
|
4
|
-
var usePresetContext = function usePresetContext() {
|
|
5
|
-
return React.useContext(PresetContext);
|
|
6
|
-
};
|
|
7
|
-
export { PresetProvider, usePresetContext };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Provides access to most commonly used configurations and instances of classes,
|
|
14
|
-
* that most editor components rely on.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var EditorSharedConfigContext = /*#__PURE__*/React.createContext(null);
|
|
18
|
-
export var EditorSharedConfigProvider = /*#__PURE__*/function (_React$Component) {
|
|
19
|
-
_inherits(EditorSharedConfigProvider, _React$Component);
|
|
20
|
-
var _super = _createSuper(EditorSharedConfigProvider);
|
|
21
|
-
function EditorSharedConfigProvider() {
|
|
22
|
-
_classCallCheck(this, EditorSharedConfigProvider);
|
|
23
|
-
return _super.apply(this, arguments);
|
|
24
|
-
}
|
|
25
|
-
_createClass(EditorSharedConfigProvider, [{
|
|
26
|
-
key: "getChildContext",
|
|
27
|
-
value: function getChildContext() {
|
|
28
|
-
return {
|
|
29
|
-
editorSharedConfig: this.props.value
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
|
-
key: "render",
|
|
34
|
-
value: function render() {
|
|
35
|
-
return /*#__PURE__*/React.createElement(EditorSharedConfigContext.Provider, {
|
|
36
|
-
value: this.props.value
|
|
37
|
-
}, this.props.children);
|
|
38
|
-
}
|
|
39
|
-
}]);
|
|
40
|
-
return EditorSharedConfigProvider;
|
|
41
|
-
}(React.Component);
|
|
42
|
-
_defineProperty(EditorSharedConfigProvider, "childContextTypes", {
|
|
43
|
-
editorSharedConfig: PropTypes.object
|
|
44
|
-
});
|
|
45
|
-
export var EditorSharedConfigConsumer = /*#__PURE__*/function (_React$Component2) {
|
|
46
|
-
_inherits(EditorSharedConfigConsumer, _React$Component2);
|
|
47
|
-
var _super2 = _createSuper(EditorSharedConfigConsumer);
|
|
48
|
-
function EditorSharedConfigConsumer() {
|
|
49
|
-
_classCallCheck(this, EditorSharedConfigConsumer);
|
|
50
|
-
return _super2.apply(this, arguments);
|
|
51
|
-
}
|
|
52
|
-
_createClass(EditorSharedConfigConsumer, [{
|
|
53
|
-
key: "render",
|
|
54
|
-
value: function render() {
|
|
55
|
-
var _this = this;
|
|
56
|
-
return /*#__PURE__*/React.createElement(EditorSharedConfigContext.Consumer, null, function (value) {
|
|
57
|
-
return _this.props.children(_this.context.editorSharedConfig || value);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}]);
|
|
61
|
-
return EditorSharedConfigConsumer;
|
|
62
|
-
}(React.Component);
|
|
63
|
-
_defineProperty(EditorSharedConfigConsumer, "contextTypes", {
|
|
64
|
-
editorSharedConfig: PropTypes.object
|
|
65
|
-
});
|
|
66
|
-
export var useEditorSharedConfig = function useEditorSharedConfig() {
|
|
67
|
-
return React.useContext(EditorSharedConfigContext);
|
|
68
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { analyticsEventKey } from '@atlaskit/editor-common/utils';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Subscribes to analytics events fired from editor components
|
|
7
|
-
* and passes them through to `fireAnalyticsEvent`.
|
|
8
|
-
*/
|
|
9
|
-
export function useAnalyticsHandler(editorSharedConfig) {
|
|
10
|
-
// handleAnalyticsEvent – must always be the same so we can unsubscribe from events properly.
|
|
11
|
-
var handleAnalyticsEvent = React.useCallback(function (payload) {
|
|
12
|
-
var handleAnalyticsEvent = editorSharedConfig && editorSharedConfig.dispatchAnalyticsEvent;
|
|
13
|
-
if (!handleAnalyticsEvent) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
handleAnalyticsEvent(payload);
|
|
17
|
-
}, [editorSharedConfig]);
|
|
18
|
-
if (editorSharedConfig) {
|
|
19
|
-
editorSharedConfig.eventDispatcher.on(analyticsEventKey, handleAnalyticsEvent);
|
|
20
|
-
}
|
|
21
|
-
React.useEffect(function () {
|
|
22
|
-
return function () {
|
|
23
|
-
if (!editorSharedConfig || !editorSharedConfig.eventDispatcher) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
editorSharedConfig.eventDispatcher.off(analyticsEventKey, handleAnalyticsEvent);
|
|
27
|
-
};
|
|
28
|
-
}, [editorSharedConfig, handleAnalyticsEvent]);
|
|
29
|
-
}
|
|
30
|
-
export function useCreateAnalyticsHandler(createAnalyticsEvent) {
|
|
31
|
-
// AFP-2511 TODO: Fix automatic suppressions below
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
return React.useCallback(fireAnalyticsEvent(createAnalyticsEvent), [createAnalyticsEvent]);
|
|
34
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Node } from 'prosemirror-model';
|
|
2
|
-
import { analyticsEventKey } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { findChangedNodesFromTransaction, validateNodes, validNode } from '../../../../../utils/nodes';
|
|
5
|
-
import { compose, toJSON } from '../../../../../utils';
|
|
6
|
-
import { getDocStructure } from '../../../../../utils/document-logger';
|
|
7
|
-
// Helper to assure correct payload when dispatch analytics
|
|
8
|
-
function dispatchAnalytics(dispatch, payload) {
|
|
9
|
-
dispatch(analyticsEventKey, payload);
|
|
10
|
-
}
|
|
11
|
-
export function createDispatchTransaction(editorSharedConfig) {
|
|
12
|
-
return function dispatchTransaction(transaction) {
|
|
13
|
-
var editorView = editorSharedConfig.editorView,
|
|
14
|
-
onChange = editorSharedConfig.onChange,
|
|
15
|
-
transformer = editorSharedConfig.transformer,
|
|
16
|
-
dispatch = editorSharedConfig.dispatch;
|
|
17
|
-
if (!editorView) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
var nodes = findChangedNodesFromTransaction(transaction);
|
|
21
|
-
if (validateNodes(nodes)) {
|
|
22
|
-
// go ahead and update the state now we know the transaction is good
|
|
23
|
-
var editorState = editorView.state.apply(transaction);
|
|
24
|
-
editorView.updateState(editorState);
|
|
25
|
-
if (onChange && transaction.docChanged) {
|
|
26
|
-
onChange(getEditorValue(editorView, transformer), {
|
|
27
|
-
source: 'local'
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
// If invalid document, send analytics event with the structure of the nodes
|
|
32
|
-
if (dispatch) {
|
|
33
|
-
var invalidNodes = nodes.filter(function (node) {
|
|
34
|
-
return !validNode(node);
|
|
35
|
-
}).map(function (node) {
|
|
36
|
-
return getDocStructure(node);
|
|
37
|
-
});
|
|
38
|
-
dispatchAnalytics(dispatch, {
|
|
39
|
-
action: ACTION.DISPATCHED_INVALID_TRANSACTION,
|
|
40
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
41
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
42
|
-
attributes: {
|
|
43
|
-
analyticsEventPayloads: getAnalyticsEventsFromTransaction(transaction),
|
|
44
|
-
invalidNodes: invalidNodes
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export function getEditorValue(editorView, transformer) {
|
|
52
|
-
return compose(function (doc) {
|
|
53
|
-
return transformer && transformer.encode ? transformer.encode(Node.fromJSON(editorView.state.schema, doc)) : doc;
|
|
54
|
-
}, toJSON)(editorView.state.doc);
|
|
55
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { EditorState } from 'prosemirror-state';
|
|
3
|
-
import { EventDispatcher, createDispatch } from '../../../../../event-dispatcher';
|
|
4
|
-
import { processPluginsList, createPMPlugins } from '../../../../../create-editor/create-editor';
|
|
5
|
-
import { processRawValue } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { createSchema } from '../../../../../create-editor/create-schema';
|
|
7
|
-
export function createEditor(_ref) {
|
|
8
|
-
var context = _ref.context,
|
|
9
|
-
onAnalyticsEvent = _ref.onAnalyticsEvent,
|
|
10
|
-
transformer = _ref.transformer,
|
|
11
|
-
providerFactory = _ref.providerFactory,
|
|
12
|
-
plugins = _ref.plugins,
|
|
13
|
-
portalProviderAPI = _ref.portalProviderAPI,
|
|
14
|
-
defaultValue = _ref.defaultValue,
|
|
15
|
-
ref = _ref.ref,
|
|
16
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
17
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
18
|
-
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
19
|
-
editorActions = _ref.editorActions,
|
|
20
|
-
disabled = _ref.disabled,
|
|
21
|
-
onChange = _ref.onChange,
|
|
22
|
-
onDestroy = _ref.onDestroy,
|
|
23
|
-
onMount = _ref.onMount,
|
|
24
|
-
featureFlags = _ref.featureFlags,
|
|
25
|
-
getIntl = _ref.getIntl;
|
|
26
|
-
if (!ref) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
var eventDispatcher = new EventDispatcher();
|
|
30
|
-
var dispatch = createDispatch(eventDispatcher);
|
|
31
|
-
var editorConfig = processPluginsList(plugins || []);
|
|
32
|
-
var schema = createSchema(editorConfig);
|
|
33
|
-
var transformerInstance = transformer && transformer(schema);
|
|
34
|
-
var pmPlugins = createPMPlugins({
|
|
35
|
-
editorConfig: editorConfig,
|
|
36
|
-
schema: schema,
|
|
37
|
-
dispatch: dispatch,
|
|
38
|
-
eventDispatcher: eventDispatcher,
|
|
39
|
-
portalProviderAPI: portalProviderAPI,
|
|
40
|
-
providerFactory: providerFactory,
|
|
41
|
-
// Required to workaround issues with multiple react trees.
|
|
42
|
-
// Though it's kinda leaking react to outside world.
|
|
43
|
-
reactContext: function reactContext() {
|
|
44
|
-
return context;
|
|
45
|
-
},
|
|
46
|
-
// TODO: ED-8133 Need to make types more generic otherwise it's not extensible.
|
|
47
|
-
dispatchAnalyticsEvent: onAnalyticsEvent,
|
|
48
|
-
performanceTracking: {},
|
|
49
|
-
featureFlags: featureFlags,
|
|
50
|
-
getIntl: getIntl
|
|
51
|
-
});
|
|
52
|
-
var state = EditorState.create({
|
|
53
|
-
schema: schema,
|
|
54
|
-
plugins: pmPlugins,
|
|
55
|
-
doc: transformerInstance ? transformerInstance.parse(defaultValue) : processRawValue(schema, defaultValue)
|
|
56
|
-
});
|
|
57
|
-
var editorView = new EditorView({
|
|
58
|
-
mount: ref
|
|
59
|
-
}, {
|
|
60
|
-
state: state,
|
|
61
|
-
attributes: {
|
|
62
|
-
'data-gramm': 'false'
|
|
63
|
-
},
|
|
64
|
-
// Ignore all transactions by default
|
|
65
|
-
dispatchTransaction: function dispatchTransaction() {},
|
|
66
|
-
// Disables the contentEditable attribute of the editor if the editor is disabled
|
|
67
|
-
editable: function editable(_state) {
|
|
68
|
-
return !!disabled;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
editorView: editorView,
|
|
73
|
-
transformer: transformerInstance,
|
|
74
|
-
dispatchAnalyticsEvent: onAnalyticsEvent,
|
|
75
|
-
eventDispatcher: eventDispatcher,
|
|
76
|
-
dispatch: dispatch,
|
|
77
|
-
primaryToolbarComponents: editorConfig.primaryToolbarComponents,
|
|
78
|
-
contentComponents: editorConfig.contentComponents,
|
|
79
|
-
popupsMountPoint: popupsMountPoint,
|
|
80
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
81
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
82
|
-
providerFactory: providerFactory,
|
|
83
|
-
editorActions: editorActions,
|
|
84
|
-
onChange: onChange,
|
|
85
|
-
onDestroy: onDestroy,
|
|
86
|
-
onMount: onMount
|
|
87
|
-
};
|
|
88
|
-
}
|