@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,34 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Provides access to most commonly used configurations and instances of classes,
|
|
7
|
-
* that most editor components rely on.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const EditorSharedConfigContext = /*#__PURE__*/React.createContext(null);
|
|
11
|
-
export class EditorSharedConfigProvider extends React.Component {
|
|
12
|
-
getChildContext() {
|
|
13
|
-
return {
|
|
14
|
-
editorSharedConfig: this.props.value
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
render() {
|
|
18
|
-
return /*#__PURE__*/React.createElement(EditorSharedConfigContext.Provider, {
|
|
19
|
-
value: this.props.value
|
|
20
|
-
}, this.props.children);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
_defineProperty(EditorSharedConfigProvider, "childContextTypes", {
|
|
24
|
-
editorSharedConfig: PropTypes.object
|
|
25
|
-
});
|
|
26
|
-
export class EditorSharedConfigConsumer extends React.Component {
|
|
27
|
-
render() {
|
|
28
|
-
return /*#__PURE__*/React.createElement(EditorSharedConfigContext.Consumer, null, value => this.props.children(this.context.editorSharedConfig || value));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
_defineProperty(EditorSharedConfigConsumer, "contextTypes", {
|
|
32
|
-
editorSharedConfig: PropTypes.object
|
|
33
|
-
});
|
|
34
|
-
export const useEditorSharedConfig = () => React.useContext(EditorSharedConfigContext);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,32 +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
|
-
const handleAnalyticsEvent = React.useCallback(payload => {
|
|
12
|
-
const 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(() => () => {
|
|
22
|
-
if (!editorSharedConfig || !editorSharedConfig.eventDispatcher) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
editorSharedConfig.eventDispatcher.off(analyticsEventKey, handleAnalyticsEvent);
|
|
26
|
-
}, [editorSharedConfig, handleAnalyticsEvent]);
|
|
27
|
-
}
|
|
28
|
-
export function useCreateAnalyticsHandler(createAnalyticsEvent) {
|
|
29
|
-
// AFP-2511 TODO: Fix automatic suppressions below
|
|
30
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
-
return React.useCallback(fireAnalyticsEvent(createAnalyticsEvent), [createAnalyticsEvent]);
|
|
32
|
-
}
|
|
@@ -1,51 +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
|
-
const {
|
|
14
|
-
editorView,
|
|
15
|
-
onChange,
|
|
16
|
-
transformer,
|
|
17
|
-
dispatch
|
|
18
|
-
} = editorSharedConfig;
|
|
19
|
-
if (!editorView) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const nodes = findChangedNodesFromTransaction(transaction);
|
|
23
|
-
if (validateNodes(nodes)) {
|
|
24
|
-
// go ahead and update the state now we know the transaction is good
|
|
25
|
-
const editorState = editorView.state.apply(transaction);
|
|
26
|
-
editorView.updateState(editorState);
|
|
27
|
-
if (onChange && transaction.docChanged) {
|
|
28
|
-
onChange(getEditorValue(editorView, transformer), {
|
|
29
|
-
source: 'local'
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
// If invalid document, send analytics event with the structure of the nodes
|
|
34
|
-
if (dispatch) {
|
|
35
|
-
const invalidNodes = nodes.filter(node => !validNode(node)).map(node => getDocStructure(node));
|
|
36
|
-
dispatchAnalytics(dispatch, {
|
|
37
|
-
action: ACTION.DISPATCHED_INVALID_TRANSACTION,
|
|
38
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
39
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
40
|
-
attributes: {
|
|
41
|
-
analyticsEventPayloads: getAnalyticsEventsFromTransaction(transaction),
|
|
42
|
-
invalidNodes
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function getEditorValue(editorView, transformer) {
|
|
50
|
-
return compose(doc => transformer && transformer.encode ? transformer.encode(Node.fromJSON(editorView.state.schema, doc)) : doc, toJSON)(editorView.state.doc);
|
|
51
|
-
}
|
|
@@ -1,85 +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({
|
|
8
|
-
context,
|
|
9
|
-
onAnalyticsEvent,
|
|
10
|
-
transformer,
|
|
11
|
-
providerFactory,
|
|
12
|
-
plugins,
|
|
13
|
-
portalProviderAPI,
|
|
14
|
-
defaultValue,
|
|
15
|
-
ref,
|
|
16
|
-
popupsMountPoint,
|
|
17
|
-
popupsBoundariesElement,
|
|
18
|
-
popupsScrollableElement,
|
|
19
|
-
editorActions,
|
|
20
|
-
disabled,
|
|
21
|
-
onChange,
|
|
22
|
-
onDestroy,
|
|
23
|
-
onMount,
|
|
24
|
-
featureFlags,
|
|
25
|
-
getIntl
|
|
26
|
-
}) {
|
|
27
|
-
if (!ref) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
const eventDispatcher = new EventDispatcher();
|
|
31
|
-
const dispatch = createDispatch(eventDispatcher);
|
|
32
|
-
const editorConfig = processPluginsList(plugins || []);
|
|
33
|
-
const schema = createSchema(editorConfig);
|
|
34
|
-
const transformerInstance = transformer && transformer(schema);
|
|
35
|
-
const pmPlugins = createPMPlugins({
|
|
36
|
-
editorConfig,
|
|
37
|
-
schema,
|
|
38
|
-
dispatch,
|
|
39
|
-
eventDispatcher,
|
|
40
|
-
portalProviderAPI: portalProviderAPI,
|
|
41
|
-
providerFactory,
|
|
42
|
-
// Required to workaround issues with multiple react trees.
|
|
43
|
-
// Though it's kinda leaking react to outside world.
|
|
44
|
-
reactContext: () => context,
|
|
45
|
-
// TODO: ED-8133 Need to make types more generic otherwise it's not extensible.
|
|
46
|
-
dispatchAnalyticsEvent: onAnalyticsEvent,
|
|
47
|
-
performanceTracking: {},
|
|
48
|
-
featureFlags,
|
|
49
|
-
getIntl
|
|
50
|
-
});
|
|
51
|
-
const state = EditorState.create({
|
|
52
|
-
schema,
|
|
53
|
-
plugins: pmPlugins,
|
|
54
|
-
doc: transformerInstance ? transformerInstance.parse(defaultValue) : processRawValue(schema, defaultValue)
|
|
55
|
-
});
|
|
56
|
-
const editorView = new EditorView({
|
|
57
|
-
mount: ref
|
|
58
|
-
}, {
|
|
59
|
-
state,
|
|
60
|
-
attributes: {
|
|
61
|
-
'data-gramm': 'false'
|
|
62
|
-
},
|
|
63
|
-
// Ignore all transactions by default
|
|
64
|
-
dispatchTransaction: () => {},
|
|
65
|
-
// Disables the contentEditable attribute of the editor if the editor is disabled
|
|
66
|
-
editable: _state => !!disabled
|
|
67
|
-
});
|
|
68
|
-
return {
|
|
69
|
-
editorView,
|
|
70
|
-
transformer: transformerInstance,
|
|
71
|
-
dispatchAnalyticsEvent: onAnalyticsEvent,
|
|
72
|
-
eventDispatcher,
|
|
73
|
-
dispatch,
|
|
74
|
-
primaryToolbarComponents: editorConfig.primaryToolbarComponents,
|
|
75
|
-
contentComponents: editorConfig.contentComponents,
|
|
76
|
-
popupsMountPoint,
|
|
77
|
-
popupsBoundariesElement,
|
|
78
|
-
popupsScrollableElement,
|
|
79
|
-
providerFactory,
|
|
80
|
-
editorActions,
|
|
81
|
-
onChange,
|
|
82
|
-
onDestroy,
|
|
83
|
-
onMount
|
|
84
|
-
};
|
|
85
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { measureRender, getResponseEndTime, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import measurements from '../../../../../utils/performance/measure-enum';
|
|
4
|
-
import { getNodesCount } from '../../../../../utils';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, PLATFORMS } from '../../../../../plugins/analytics';
|
|
6
|
-
import { getEnabledFeatureFlagKeys } from '@atlaskit/editor-common/normalize-feature-flags';
|
|
7
|
-
import { useAnalyticsHandler } from '../use-analytics';
|
|
8
|
-
import { createDispatchTransaction } from './create-dispatch-transaction';
|
|
9
|
-
import { createEditor } from './create-editor';
|
|
10
|
-
import { analyticsEventKey } from '../../../../../plugins/analytics/consts';
|
|
11
|
-
export function useEditor(config) {
|
|
12
|
-
startMeasure(measurements.EDITOR_MOUNTED);
|
|
13
|
-
const [editorSharedConfig, mountEditor] = useCreateEditor(config);
|
|
14
|
-
useApplyEditorViewProps(editorSharedConfig, config.disabled);
|
|
15
|
-
useHandleEditorLifecycle(editorSharedConfig, config.featureFlags);
|
|
16
|
-
useAnalyticsHandler(editorSharedConfig);
|
|
17
|
-
return [editorSharedConfig, mountEditor];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* Sub hooks ¯\_(ツ)_/¯
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Main hook that creates an instance of EditorView, EditorSharedConfig, etc...
|
|
28
|
-
*/
|
|
29
|
-
function useCreateEditor(config) {
|
|
30
|
-
const [editorSharedConfig, setEditorSharedConfig] = React.useState(null);
|
|
31
|
-
return [editorSharedConfig,
|
|
32
|
-
// This callback is being used as `ref={callback}` on EditorContentProvider,
|
|
33
|
-
// When called with `ref` mounts editor and creates editorSharedConfig.
|
|
34
|
-
React.useCallback(ref => {
|
|
35
|
-
// If editorSharedConfig already exists it means that editorView is mounted
|
|
36
|
-
// and we just need to ignore this function altogether.
|
|
37
|
-
if (!ref) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
setEditorSharedConfig(editorSharedConfig => {
|
|
41
|
-
if (!editorSharedConfig) {
|
|
42
|
-
measureRender(measurements.PROSEMIRROR_RENDERED, ({
|
|
43
|
-
duration,
|
|
44
|
-
startTime,
|
|
45
|
-
distortedDuration
|
|
46
|
-
}) => {
|
|
47
|
-
if (sharedConfig && sharedConfig.dispatch) {
|
|
48
|
-
sharedConfig.dispatch(analyticsEventKey, {
|
|
49
|
-
payload: {
|
|
50
|
-
action: ACTION.PROSEMIRROR_RENDERED,
|
|
51
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
52
|
-
attributes: {
|
|
53
|
-
duration,
|
|
54
|
-
distortedDuration,
|
|
55
|
-
startTime,
|
|
56
|
-
nodes: getNodesCount(sharedConfig.editorView.state.doc),
|
|
57
|
-
ttfb: getResponseEndTime()
|
|
58
|
-
},
|
|
59
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const sharedConfig = editorSharedConfig || createEditor({
|
|
66
|
-
...config,
|
|
67
|
-
ref
|
|
68
|
-
});
|
|
69
|
-
stopMeasure(measurements.EDITOR_MOUNTED, (duration, startTime) => {
|
|
70
|
-
if (!sharedConfig) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Fire editor mounted event
|
|
75
|
-
sharedConfig.dispatch(analyticsEventKey, {
|
|
76
|
-
payload: {
|
|
77
|
-
action: ACTION.EDITOR_MOUNTED,
|
|
78
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
79
|
-
attributes: {
|
|
80
|
-
duration,
|
|
81
|
-
startTime
|
|
82
|
-
},
|
|
83
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
return sharedConfig;
|
|
88
|
-
});
|
|
89
|
-
}, [config])];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Applies updated EditorView properties e.g. set dispatchTransaction or 'disabled' state changes
|
|
94
|
-
*/
|
|
95
|
-
function useApplyEditorViewProps(editorSharedConfig, disabled) {
|
|
96
|
-
React.useEffect(() => {
|
|
97
|
-
if (editorSharedConfig) {
|
|
98
|
-
editorSharedConfig.editorView.setProps({
|
|
99
|
-
dispatchTransaction: createDispatchTransaction(editorSharedConfig)
|
|
100
|
-
});
|
|
101
|
-
editorSharedConfig.editorView.setProps({
|
|
102
|
-
editable: _state => !disabled
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}, [editorSharedConfig, disabled]);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Handles editor component unmount
|
|
110
|
-
*/
|
|
111
|
-
export function useHandleEditorLifecycle(editorSharedConfig, featureFlags) {
|
|
112
|
-
React.useEffect(() => {
|
|
113
|
-
//#region Did mount
|
|
114
|
-
if (editorSharedConfig) {
|
|
115
|
-
const {
|
|
116
|
-
onMount,
|
|
117
|
-
editorActions,
|
|
118
|
-
editorView,
|
|
119
|
-
eventDispatcher,
|
|
120
|
-
dispatch
|
|
121
|
-
} = editorSharedConfig;
|
|
122
|
-
editorActions._privateRegisterEditor(editorView, eventDispatcher);
|
|
123
|
-
if (onMount) {
|
|
124
|
-
onMount(editorActions);
|
|
125
|
-
}
|
|
126
|
-
const featureFlagsEnabled = featureFlags ? getEnabledFeatureFlagKeys(featureFlags) : [];
|
|
127
|
-
|
|
128
|
-
// Fire editor started event
|
|
129
|
-
dispatch(analyticsEventKey, {
|
|
130
|
-
payload: {
|
|
131
|
-
action: ACTION.STARTED,
|
|
132
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
133
|
-
attributes: {
|
|
134
|
-
platform: PLATFORMS.WEB,
|
|
135
|
-
featureFlags: featureFlagsEnabled
|
|
136
|
-
},
|
|
137
|
-
eventType: EVENT_TYPE.UI
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
142
|
-
|
|
143
|
-
return () => {
|
|
144
|
-
if (!editorSharedConfig) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const {
|
|
148
|
-
eventDispatcher,
|
|
149
|
-
editorView,
|
|
150
|
-
onDestroy,
|
|
151
|
-
editorActions
|
|
152
|
-
} = editorSharedConfig;
|
|
153
|
-
if (eventDispatcher) {
|
|
154
|
-
eventDispatcher.destroy();
|
|
155
|
-
}
|
|
156
|
-
if (onDestroy) {
|
|
157
|
-
onDestroy();
|
|
158
|
-
}
|
|
159
|
-
editorActions._privateUnregisterEditor();
|
|
160
|
-
if (editorView) {
|
|
161
|
-
// Prevent any transactions from coming through when unmounting
|
|
162
|
-
editorView.setProps({
|
|
163
|
-
dispatchTransaction: _tr => {}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// Destroy plugin states and editor state
|
|
167
|
-
// when the editor is being unmounted
|
|
168
|
-
const editorState = editorView.state;
|
|
169
|
-
editorState.plugins.forEach(plugin => {
|
|
170
|
-
const state = plugin.getState(editorState);
|
|
171
|
-
if (state && state.destroy) {
|
|
172
|
-
state.destroy();
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
editorView.destroy();
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
}, [editorSharedConfig, featureFlags]);
|
|
179
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
3
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
-
import { MobileAppearance } from '../../ui/AppearanceComponents/Mobile';
|
|
5
|
-
import { EditorSharedConfigConsumer, Editor, EditorContent } from './Editor';
|
|
6
|
-
import { useCreateAnalyticsHandler } from './internal/hooks/use-analytics';
|
|
7
|
-
import { ContextAdapter } from '../../nodeviews/context-adapter';
|
|
8
|
-
export function MobileEditor(props) {
|
|
9
|
-
const {
|
|
10
|
-
maxHeight,
|
|
11
|
-
createAnalyticsEvent,
|
|
12
|
-
disabled
|
|
13
|
-
} = props;
|
|
14
|
-
const handleAnalyticsEvent = useCreateAnalyticsHandler(createAnalyticsEvent);
|
|
15
|
-
const renderWithConfig = useCallback(config => {
|
|
16
|
-
return /*#__PURE__*/React.createElement(MobileAppearance, {
|
|
17
|
-
editorView: config && config.editorView,
|
|
18
|
-
maxHeight: maxHeight,
|
|
19
|
-
editorDisabled: disabled
|
|
20
|
-
}, /*#__PURE__*/React.createElement(EditorContent, null));
|
|
21
|
-
}, [maxHeight, disabled]);
|
|
22
|
-
return /*#__PURE__*/React.createElement(ContextAdapter, null, /*#__PURE__*/React.createElement(Editor, _extends({}, props, {
|
|
23
|
-
onAnalyticsEvent: handleAnalyticsEvent
|
|
24
|
-
}), /*#__PURE__*/React.createElement(EditorSharedConfigConsumer, null, renderWithConfig)));
|
|
25
|
-
}
|
|
26
|
-
MobileEditor.displayName = 'MobileEditor';
|
|
27
|
-
export const Mobile = withAnalyticsEvents()(MobileEditor);
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// #region Imports
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
//import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
5
|
-
//
|
|
6
|
-
//import {
|
|
7
|
-
// panelPlugin,
|
|
8
|
-
// listPlugin,
|
|
9
|
-
// textColorPlugin,
|
|
10
|
-
// breakoutPlugin,
|
|
11
|
-
// jiraIssuePlugin,
|
|
12
|
-
// extensionPlugin,
|
|
13
|
-
// rulePlugin,
|
|
14
|
-
// datePlugin,
|
|
15
|
-
// layoutPlugin,
|
|
16
|
-
// indentationPlugin,
|
|
17
|
-
// cardPlugin,
|
|
18
|
-
// statusPlugin,
|
|
19
|
-
// mediaPlugin,
|
|
20
|
-
// mentionsPlugin,
|
|
21
|
-
// tasksAndDecisionsPlugin,
|
|
22
|
-
// insertBlockPlugin,
|
|
23
|
-
// basePlugin,
|
|
24
|
-
// //placeholderPlugin,
|
|
25
|
-
//} from '../../../plugins';
|
|
26
|
-
import { PresetProvider } from '../Editor';
|
|
27
|
-
import { useDefaultPreset } from './default';
|
|
28
|
-
// #endregion
|
|
29
|
-
|
|
30
|
-
export function useCXHTMLPreset({
|
|
31
|
-
mentionProvider,
|
|
32
|
-
mediaProvider,
|
|
33
|
-
placeholder,
|
|
34
|
-
featureFlags
|
|
35
|
-
}) {
|
|
36
|
-
const [defaultPreset] = useDefaultPreset({
|
|
37
|
-
featureFlags,
|
|
38
|
-
paste: {}
|
|
39
|
-
});
|
|
40
|
-
const preset = defaultPreset;
|
|
41
|
-
//.add([
|
|
42
|
-
// basePlugin,
|
|
43
|
-
// {
|
|
44
|
-
// allowInlineCursorTarget: true,
|
|
45
|
-
// allowScrollGutter: {
|
|
46
|
-
// getScrollElement: (_view) =>
|
|
47
|
-
// document.querySelector('.fabric-editor-popup-scroll-parent') ||
|
|
48
|
-
// null,
|
|
49
|
-
// },
|
|
50
|
-
// },
|
|
51
|
-
//])
|
|
52
|
-
//.add([tablesPlugin, { tableOptions: { advanced: true } }])
|
|
53
|
-
//.add([panelPlugin, { allowCustomPanel: true }])
|
|
54
|
-
//.add(listPlugin)
|
|
55
|
-
//.add(textColorPlugin)
|
|
56
|
-
//.add(breakoutPlugin)
|
|
57
|
-
//.add(jiraIssuePlugin)
|
|
58
|
-
//.add(extensionPlugin)
|
|
59
|
-
//.add(rulePlugin)
|
|
60
|
-
//.add(datePlugin)
|
|
61
|
-
//.add(layoutPlugin)
|
|
62
|
-
//.add(indentationPlugin)
|
|
63
|
-
//.add([cardPlugin, { allowBlockCards: true, platform: 'web' }])
|
|
64
|
-
//.add([statusPlugin, { menuDisabled: false }])
|
|
65
|
-
//.add(tasksAndDecisionsPlugin)
|
|
66
|
-
//.add(insertBlockPlugin)
|
|
67
|
-
////.add([placeholderPlugin, { placeholder }])
|
|
68
|
-
//.maybeAdd(mentionsPlugin, (plugin, builder) => {
|
|
69
|
-
// if (mentionProvider) {
|
|
70
|
-
// return builder.add(plugin);
|
|
71
|
-
// }
|
|
72
|
-
// return builder;
|
|
73
|
-
//})
|
|
74
|
-
//.maybeAdd(mediaPlugin, (plugin, builder) => {
|
|
75
|
-
// if (mediaProvider) {
|
|
76
|
-
// preset.add([
|
|
77
|
-
// plugin,
|
|
78
|
-
// {
|
|
79
|
-
// provider: mediaProvider,
|
|
80
|
-
// allowMediaSingle: true,
|
|
81
|
-
// allowMediaGroup: true,
|
|
82
|
-
// allowResizing: true,
|
|
83
|
-
// allowLinking: true,
|
|
84
|
-
// allowResizingInTables: true,
|
|
85
|
-
// allowAltTextOnImages: true,
|
|
86
|
-
// },
|
|
87
|
-
// ]);
|
|
88
|
-
// }
|
|
89
|
-
// return builder;
|
|
90
|
-
//});
|
|
91
|
-
|
|
92
|
-
return [preset];
|
|
93
|
-
}
|
|
94
|
-
export function EditorPresetCXHTML(props) {
|
|
95
|
-
const {
|
|
96
|
-
children,
|
|
97
|
-
excludes
|
|
98
|
-
} = props;
|
|
99
|
-
const [preset] = useCXHTMLPreset(props);
|
|
100
|
-
const plugins = preset.build({
|
|
101
|
-
excludePlugins: excludes
|
|
102
|
-
});
|
|
103
|
-
return /*#__PURE__*/React.createElement(PresetProvider, {
|
|
104
|
-
value: plugins
|
|
105
|
-
}, children);
|
|
106
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// #region Imports
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
// useProvider,
|
|
5
|
-
useProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
-
//import analyticsPlugin from '../../../plugins/analytics';
|
|
7
|
-
//import basePlugin from '../../../plugins/base';
|
|
8
|
-
//import { cardPlugin } from '@atlaskit/editor-plugin-card';
|
|
9
|
-
//import datePlugin from '../../../plugins/date';
|
|
10
|
-
//import emojiPlugin from '../../../plugins/emoji';
|
|
11
|
-
//import extensionPlugin from '../../../plugins/extension';
|
|
12
|
-
//import layoutPlugin from '../../../plugins/layout';
|
|
13
|
-
//import listPlugin from '../../../plugins/list';
|
|
14
|
-
//import mentionsPlugin from '../../../plugins/mentions';
|
|
15
|
-
//import mobileDimensionsPlugin from '../../../plugins/mobile-dimensions';
|
|
16
|
-
//import panelPlugin from '../../../plugins/panel';
|
|
17
|
-
//import placeholderPlugin from '../../../plugins/placeholder';
|
|
18
|
-
//import rulePlugin from '../../../plugins/rule';
|
|
19
|
-
//import statusPlugin from '../../../plugins/status';
|
|
20
|
-
//import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
21
|
-
//import tasksAndDecisionsPlugin from '../../../plugins/tasks-and-decisions';
|
|
22
|
-
//import textColorPlugin from '../../../plugins/text-color';
|
|
23
|
-
//import maxContentSizePlugin from '../../../plugins/max-content-size';
|
|
24
|
-
//import expandPlugin from '../../../plugins/expand';
|
|
25
|
-
//import selectionPlugin from '../../../plugins/selection';
|
|
26
|
-
import { PresetProvider } from '../Editor';
|
|
27
|
-
import { useDefaultPreset } from './default';
|
|
28
|
-
import { addExcludesFromProviderFactory } from './utils';
|
|
29
|
-
//import { quickInsertPlugin } from '../../../plugins';
|
|
30
|
-
|
|
31
|
-
// #endregion
|
|
32
|
-
export function useMobilePreset({
|
|
33
|
-
media,
|
|
34
|
-
placeholder,
|
|
35
|
-
maxContentSize,
|
|
36
|
-
createAnalyticsEvent,
|
|
37
|
-
featureFlags
|
|
38
|
-
}) {
|
|
39
|
-
//const mediaProvider = useProvider('mediaProvider');
|
|
40
|
-
const [defaultPreset] = useDefaultPreset({
|
|
41
|
-
featureFlags,
|
|
42
|
-
paste: {}
|
|
43
|
-
});
|
|
44
|
-
const preset = defaultPreset;
|
|
45
|
-
//.add([
|
|
46
|
-
// basePlugin,
|
|
47
|
-
// {
|
|
48
|
-
// allowScrollGutter: {
|
|
49
|
-
// getScrollElement: () => document.body,
|
|
50
|
-
// allowCustomScrollHandler: false,
|
|
51
|
-
// },
|
|
52
|
-
// },
|
|
53
|
-
//])
|
|
54
|
-
//.add([analyticsPlugin, createAnalyticsEvent])
|
|
55
|
-
//.add([tablesPlugin, { tableOptions: { allowControls: false } }])
|
|
56
|
-
//.add(panelPlugin)
|
|
57
|
-
//.add(listPlugin)
|
|
58
|
-
//.add(textColorPlugin)
|
|
59
|
-
//.add(extensionPlugin)
|
|
60
|
-
//.add(rulePlugin)
|
|
61
|
-
//.add(datePlugin)
|
|
62
|
-
//.add(layoutPlugin)
|
|
63
|
-
//.add([quickInsertPlugin, { headless: true, disableDefaultItems: true }])
|
|
64
|
-
//.add([statusPlugin, { menuDisabled: false }])
|
|
65
|
-
//.add([placeholderPlugin, { placeholder }])
|
|
66
|
-
//.add(mobileDimensionsPlugin)
|
|
67
|
-
//.add(expandPlugin)
|
|
68
|
-
////.add([selectionPlugin, { useLongPressSelection: false }])
|
|
69
|
-
//// Begin -> This would be exclude if the provider doesnt exist in the factory
|
|
70
|
-
//.add(tasksAndDecisionsPlugin)
|
|
71
|
-
//.add([cardPlugin, { allowBlockCards: true, platform: 'mobile' }])
|
|
72
|
-
//.add(mentionsPlugin)
|
|
73
|
-
//.add(emojiPlugin)
|
|
74
|
-
//// End
|
|
75
|
-
//.maybeAdd(maxContentSizePlugin, (plugin, builder) => {
|
|
76
|
-
// if (maxContentSize) {
|
|
77
|
-
// return builder.add([plugin, maxContentSize as any]);
|
|
78
|
-
// }
|
|
79
|
-
// return builder;
|
|
80
|
-
//})
|
|
81
|
-
//.maybeAdd(mediaPlugin, (plugin, builder) => {
|
|
82
|
-
// if (media) {
|
|
83
|
-
// return builder.add([
|
|
84
|
-
// plugin,
|
|
85
|
-
// {
|
|
86
|
-
// provider: mediaProvider,
|
|
87
|
-
// customMediaPicker: media.picker,
|
|
88
|
-
// fullWidthEnabled: false,
|
|
89
|
-
// allowMediaSingle: true,
|
|
90
|
-
// allowLazyLoading: false,
|
|
91
|
-
// allowMediaSingleEditable: false,
|
|
92
|
-
// allowRemoteDimensionsFetch: false,
|
|
93
|
-
// allowMarkingUploadsAsIncomplete: true,
|
|
94
|
-
// allowAltTextOnImages: true,
|
|
95
|
-
// allowTemplatePlaceholders: { allowInserting: true },
|
|
96
|
-
// },
|
|
97
|
-
// ]);
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
// return builder;
|
|
101
|
-
//});
|
|
102
|
-
|
|
103
|
-
return [preset];
|
|
104
|
-
}
|
|
105
|
-
export function EditorPresetMobile(props) {
|
|
106
|
-
const {
|
|
107
|
-
children,
|
|
108
|
-
excludes
|
|
109
|
-
} = props;
|
|
110
|
-
const [preset] = useMobilePreset(props);
|
|
111
|
-
const providerFactory = useProviderFactory();
|
|
112
|
-
const plugins = preset.build({
|
|
113
|
-
excludePlugins: addExcludesFromProviderFactory(providerFactory, excludes)
|
|
114
|
-
});
|
|
115
|
-
return /*#__PURE__*/React.createElement(PresetProvider, {
|
|
116
|
-
value: plugins
|
|
117
|
-
}, children);
|
|
118
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const addExcludesFromProviderFactory = (providerFactory, excludes = new Set()) => {
|
|
2
|
-
// TODO: Should I make this function pure?
|
|
3
|
-
if (!providerFactory.hasProvider('mentionProvider')) {
|
|
4
|
-
excludes.add('mention');
|
|
5
|
-
}
|
|
6
|
-
if (!providerFactory.hasProvider('emojiProvider')) {
|
|
7
|
-
excludes.add('emoji');
|
|
8
|
-
}
|
|
9
|
-
if (!providerFactory.hasProvider('macroProvider')) {
|
|
10
|
-
excludes.add('macro');
|
|
11
|
-
}
|
|
12
|
-
if (!providerFactory.hasProvider('autoformattingProvider')) {
|
|
13
|
-
excludes.add('customAutoformat');
|
|
14
|
-
}
|
|
15
|
-
if (!providerFactory.hasProvider('taskDecisionProvider')) {
|
|
16
|
-
excludes.add('taskDecision');
|
|
17
|
-
}
|
|
18
|
-
if (!providerFactory.hasProvider('cardProvider')) {
|
|
19
|
-
excludes.add('card');
|
|
20
|
-
}
|
|
21
|
-
return excludes;
|
|
22
|
-
};
|