@atlaskit/editor-core 186.0.0 → 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 +19 -0
- package/dist/cjs/labs-next.js +0 -65
- package/dist/cjs/plugins/expand/commands.js +2 -0
- package/dist/cjs/plugins/expand/index.js +1 -1
- 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/plugins/expand/commands.js +2 -0
- package/dist/es2019/plugins/expand/index.js +1 -1
- 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/plugins/expand/commands.js +2 -0
- package/dist/esm/plugins/expand/index.js +1 -1
- 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/plugins/expand/commands.d.ts +3 -3
- package/dist/types/plugins/expand/index.d.ts +2 -2
- 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/dist/types-ts4.5/plugins/expand/commands.d.ts +3 -3
- package/dist/types-ts4.5/plugins/expand/index.d.ts +2 -2
- package/package.json +5 -5
- 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,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
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { measureRender, getResponseEndTime, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import measurements from '../../../../../utils/performance/measure-enum';
|
|
8
|
-
import { getNodesCount } from '../../../../../utils';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, PLATFORMS } from '../../../../../plugins/analytics';
|
|
10
|
-
import { getEnabledFeatureFlagKeys } from '@atlaskit/editor-common/normalize-feature-flags';
|
|
11
|
-
import { useAnalyticsHandler } from '../use-analytics';
|
|
12
|
-
import { createDispatchTransaction } from './create-dispatch-transaction';
|
|
13
|
-
import { createEditor } from './create-editor';
|
|
14
|
-
import { analyticsEventKey } from '../../../../../plugins/analytics/consts';
|
|
15
|
-
export function useEditor(config) {
|
|
16
|
-
startMeasure(measurements.EDITOR_MOUNTED);
|
|
17
|
-
var _useCreateEditor = useCreateEditor(config),
|
|
18
|
-
_useCreateEditor2 = _slicedToArray(_useCreateEditor, 2),
|
|
19
|
-
editorSharedConfig = _useCreateEditor2[0],
|
|
20
|
-
mountEditor = _useCreateEditor2[1];
|
|
21
|
-
useApplyEditorViewProps(editorSharedConfig, config.disabled);
|
|
22
|
-
useHandleEditorLifecycle(editorSharedConfig, config.featureFlags);
|
|
23
|
-
useAnalyticsHandler(editorSharedConfig);
|
|
24
|
-
return [editorSharedConfig, mountEditor];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* Sub hooks ¯\_(ツ)_/¯
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Main hook that creates an instance of EditorView, EditorSharedConfig, etc...
|
|
35
|
-
*/
|
|
36
|
-
function useCreateEditor(config) {
|
|
37
|
-
var _React$useState = React.useState(null),
|
|
38
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
39
|
-
editorSharedConfig = _React$useState2[0],
|
|
40
|
-
setEditorSharedConfig = _React$useState2[1];
|
|
41
|
-
return [editorSharedConfig,
|
|
42
|
-
// This callback is being used as `ref={callback}` on EditorContentProvider,
|
|
43
|
-
// When called with `ref` mounts editor and creates editorSharedConfig.
|
|
44
|
-
React.useCallback(function (ref) {
|
|
45
|
-
// If editorSharedConfig already exists it means that editorView is mounted
|
|
46
|
-
// and we just need to ignore this function altogether.
|
|
47
|
-
if (!ref) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
setEditorSharedConfig(function (editorSharedConfig) {
|
|
51
|
-
if (!editorSharedConfig) {
|
|
52
|
-
measureRender(measurements.PROSEMIRROR_RENDERED, function (_ref) {
|
|
53
|
-
var duration = _ref.duration,
|
|
54
|
-
startTime = _ref.startTime,
|
|
55
|
-
distortedDuration = _ref.distortedDuration;
|
|
56
|
-
if (sharedConfig && sharedConfig.dispatch) {
|
|
57
|
-
sharedConfig.dispatch(analyticsEventKey, {
|
|
58
|
-
payload: {
|
|
59
|
-
action: ACTION.PROSEMIRROR_RENDERED,
|
|
60
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
61
|
-
attributes: {
|
|
62
|
-
duration: duration,
|
|
63
|
-
distortedDuration: distortedDuration,
|
|
64
|
-
startTime: startTime,
|
|
65
|
-
nodes: getNodesCount(sharedConfig.editorView.state.doc),
|
|
66
|
-
ttfb: getResponseEndTime()
|
|
67
|
-
},
|
|
68
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
var sharedConfig = editorSharedConfig || createEditor(_objectSpread(_objectSpread({}, config), {}, {
|
|
75
|
-
ref: ref
|
|
76
|
-
}));
|
|
77
|
-
stopMeasure(measurements.EDITOR_MOUNTED, function (duration, startTime) {
|
|
78
|
-
if (!sharedConfig) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Fire editor mounted event
|
|
83
|
-
sharedConfig.dispatch(analyticsEventKey, {
|
|
84
|
-
payload: {
|
|
85
|
-
action: ACTION.EDITOR_MOUNTED,
|
|
86
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
87
|
-
attributes: {
|
|
88
|
-
duration: duration,
|
|
89
|
-
startTime: startTime
|
|
90
|
-
},
|
|
91
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
return sharedConfig;
|
|
96
|
-
});
|
|
97
|
-
}, [config])];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Applies updated EditorView properties e.g. set dispatchTransaction or 'disabled' state changes
|
|
102
|
-
*/
|
|
103
|
-
function useApplyEditorViewProps(editorSharedConfig, disabled) {
|
|
104
|
-
React.useEffect(function () {
|
|
105
|
-
if (editorSharedConfig) {
|
|
106
|
-
editorSharedConfig.editorView.setProps({
|
|
107
|
-
dispatchTransaction: createDispatchTransaction(editorSharedConfig)
|
|
108
|
-
});
|
|
109
|
-
editorSharedConfig.editorView.setProps({
|
|
110
|
-
editable: function editable(_state) {
|
|
111
|
-
return !disabled;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}, [editorSharedConfig, disabled]);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Handles editor component unmount
|
|
120
|
-
*/
|
|
121
|
-
export function useHandleEditorLifecycle(editorSharedConfig, featureFlags) {
|
|
122
|
-
React.useEffect(function () {
|
|
123
|
-
//#region Did mount
|
|
124
|
-
if (editorSharedConfig) {
|
|
125
|
-
var onMount = editorSharedConfig.onMount,
|
|
126
|
-
editorActions = editorSharedConfig.editorActions,
|
|
127
|
-
editorView = editorSharedConfig.editorView,
|
|
128
|
-
eventDispatcher = editorSharedConfig.eventDispatcher,
|
|
129
|
-
dispatch = editorSharedConfig.dispatch;
|
|
130
|
-
editorActions._privateRegisterEditor(editorView, eventDispatcher);
|
|
131
|
-
if (onMount) {
|
|
132
|
-
onMount(editorActions);
|
|
133
|
-
}
|
|
134
|
-
var featureFlagsEnabled = featureFlags ? getEnabledFeatureFlagKeys(featureFlags) : [];
|
|
135
|
-
|
|
136
|
-
// Fire editor started event
|
|
137
|
-
dispatch(analyticsEventKey, {
|
|
138
|
-
payload: {
|
|
139
|
-
action: ACTION.STARTED,
|
|
140
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
141
|
-
attributes: {
|
|
142
|
-
platform: PLATFORMS.WEB,
|
|
143
|
-
featureFlags: featureFlagsEnabled
|
|
144
|
-
},
|
|
145
|
-
eventType: EVENT_TYPE.UI
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
//#endregion
|
|
150
|
-
|
|
151
|
-
return function () {
|
|
152
|
-
if (!editorSharedConfig) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
var eventDispatcher = editorSharedConfig.eventDispatcher,
|
|
156
|
-
editorView = editorSharedConfig.editorView,
|
|
157
|
-
onDestroy = editorSharedConfig.onDestroy,
|
|
158
|
-
editorActions = editorSharedConfig.editorActions;
|
|
159
|
-
if (eventDispatcher) {
|
|
160
|
-
eventDispatcher.destroy();
|
|
161
|
-
}
|
|
162
|
-
if (onDestroy) {
|
|
163
|
-
onDestroy();
|
|
164
|
-
}
|
|
165
|
-
editorActions._privateUnregisterEditor();
|
|
166
|
-
if (editorView) {
|
|
167
|
-
// Prevent any transactions from coming through when unmounting
|
|
168
|
-
editorView.setProps({
|
|
169
|
-
dispatchTransaction: function dispatchTransaction(_tr) {}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Destroy plugin states and editor state
|
|
173
|
-
// when the editor is being unmounted
|
|
174
|
-
var editorState = editorView.state;
|
|
175
|
-
editorState.plugins.forEach(function (plugin) {
|
|
176
|
-
var state = plugin.getState(editorState);
|
|
177
|
-
if (state && state.destroy) {
|
|
178
|
-
state.destroy();
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
editorView.destroy();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}, [editorSharedConfig, featureFlags]);
|
|
185
|
-
}
|
|
@@ -1,25 +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
|
-
var maxHeight = props.maxHeight,
|
|
10
|
-
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
11
|
-
disabled = props.disabled;
|
|
12
|
-
var handleAnalyticsEvent = useCreateAnalyticsHandler(createAnalyticsEvent);
|
|
13
|
-
var renderWithConfig = useCallback(function (config) {
|
|
14
|
-
return /*#__PURE__*/React.createElement(MobileAppearance, {
|
|
15
|
-
editorView: config && config.editorView,
|
|
16
|
-
maxHeight: maxHeight,
|
|
17
|
-
editorDisabled: disabled
|
|
18
|
-
}, /*#__PURE__*/React.createElement(EditorContent, null));
|
|
19
|
-
}, [maxHeight, disabled]);
|
|
20
|
-
return /*#__PURE__*/React.createElement(ContextAdapter, null, /*#__PURE__*/React.createElement(Editor, _extends({}, props, {
|
|
21
|
-
onAnalyticsEvent: handleAnalyticsEvent
|
|
22
|
-
}), /*#__PURE__*/React.createElement(EditorSharedConfigConsumer, null, renderWithConfig)));
|
|
23
|
-
}
|
|
24
|
-
MobileEditor.displayName = 'MobileEditor';
|
|
25
|
-
export var Mobile = withAnalyticsEvents()(MobileEditor);
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
// #region Imports
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
//import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
6
|
-
//
|
|
7
|
-
//import {
|
|
8
|
-
// panelPlugin,
|
|
9
|
-
// listPlugin,
|
|
10
|
-
// textColorPlugin,
|
|
11
|
-
// breakoutPlugin,
|
|
12
|
-
// jiraIssuePlugin,
|
|
13
|
-
// extensionPlugin,
|
|
14
|
-
// rulePlugin,
|
|
15
|
-
// datePlugin,
|
|
16
|
-
// layoutPlugin,
|
|
17
|
-
// indentationPlugin,
|
|
18
|
-
// cardPlugin,
|
|
19
|
-
// statusPlugin,
|
|
20
|
-
// mediaPlugin,
|
|
21
|
-
// mentionsPlugin,
|
|
22
|
-
// tasksAndDecisionsPlugin,
|
|
23
|
-
// insertBlockPlugin,
|
|
24
|
-
// basePlugin,
|
|
25
|
-
// //placeholderPlugin,
|
|
26
|
-
//} from '../../../plugins';
|
|
27
|
-
import { PresetProvider } from '../Editor';
|
|
28
|
-
import { useDefaultPreset } from './default';
|
|
29
|
-
// #endregion
|
|
30
|
-
|
|
31
|
-
export function useCXHTMLPreset(_ref) {
|
|
32
|
-
var mentionProvider = _ref.mentionProvider,
|
|
33
|
-
mediaProvider = _ref.mediaProvider,
|
|
34
|
-
placeholder = _ref.placeholder,
|
|
35
|
-
featureFlags = _ref.featureFlags;
|
|
36
|
-
var _useDefaultPreset = useDefaultPreset({
|
|
37
|
-
featureFlags: featureFlags,
|
|
38
|
-
paste: {}
|
|
39
|
-
}),
|
|
40
|
-
_useDefaultPreset2 = _slicedToArray(_useDefaultPreset, 1),
|
|
41
|
-
defaultPreset = _useDefaultPreset2[0];
|
|
42
|
-
var preset = defaultPreset;
|
|
43
|
-
//.add([
|
|
44
|
-
// basePlugin,
|
|
45
|
-
// {
|
|
46
|
-
// allowInlineCursorTarget: true,
|
|
47
|
-
// allowScrollGutter: {
|
|
48
|
-
// getScrollElement: (_view) =>
|
|
49
|
-
// document.querySelector('.fabric-editor-popup-scroll-parent') ||
|
|
50
|
-
// null,
|
|
51
|
-
// },
|
|
52
|
-
// },
|
|
53
|
-
//])
|
|
54
|
-
//.add([tablesPlugin, { tableOptions: { advanced: true } }])
|
|
55
|
-
//.add([panelPlugin, { allowCustomPanel: true }])
|
|
56
|
-
//.add(listPlugin)
|
|
57
|
-
//.add(textColorPlugin)
|
|
58
|
-
//.add(breakoutPlugin)
|
|
59
|
-
//.add(jiraIssuePlugin)
|
|
60
|
-
//.add(extensionPlugin)
|
|
61
|
-
//.add(rulePlugin)
|
|
62
|
-
//.add(datePlugin)
|
|
63
|
-
//.add(layoutPlugin)
|
|
64
|
-
//.add(indentationPlugin)
|
|
65
|
-
//.add([cardPlugin, { allowBlockCards: true, platform: 'web' }])
|
|
66
|
-
//.add([statusPlugin, { menuDisabled: false }])
|
|
67
|
-
//.add(tasksAndDecisionsPlugin)
|
|
68
|
-
//.add(insertBlockPlugin)
|
|
69
|
-
////.add([placeholderPlugin, { placeholder }])
|
|
70
|
-
//.maybeAdd(mentionsPlugin, (plugin, builder) => {
|
|
71
|
-
// if (mentionProvider) {
|
|
72
|
-
// return builder.add(plugin);
|
|
73
|
-
// }
|
|
74
|
-
// return builder;
|
|
75
|
-
//})
|
|
76
|
-
//.maybeAdd(mediaPlugin, (plugin, builder) => {
|
|
77
|
-
// if (mediaProvider) {
|
|
78
|
-
// preset.add([
|
|
79
|
-
// plugin,
|
|
80
|
-
// {
|
|
81
|
-
// provider: mediaProvider,
|
|
82
|
-
// allowMediaSingle: true,
|
|
83
|
-
// allowMediaGroup: true,
|
|
84
|
-
// allowResizing: true,
|
|
85
|
-
// allowLinking: true,
|
|
86
|
-
// allowResizingInTables: true,
|
|
87
|
-
// allowAltTextOnImages: true,
|
|
88
|
-
// },
|
|
89
|
-
// ]);
|
|
90
|
-
// }
|
|
91
|
-
// return builder;
|
|
92
|
-
//});
|
|
93
|
-
|
|
94
|
-
return [preset];
|
|
95
|
-
}
|
|
96
|
-
export function EditorPresetCXHTML(props) {
|
|
97
|
-
var children = props.children,
|
|
98
|
-
excludes = props.excludes;
|
|
99
|
-
var _useCXHTMLPreset = useCXHTMLPreset(props),
|
|
100
|
-
_useCXHTMLPreset2 = _slicedToArray(_useCXHTMLPreset, 1),
|
|
101
|
-
preset = _useCXHTMLPreset2[0];
|
|
102
|
-
var plugins = preset.build({
|
|
103
|
-
excludePlugins: excludes
|
|
104
|
-
});
|
|
105
|
-
return /*#__PURE__*/React.createElement(PresetProvider, {
|
|
106
|
-
value: plugins
|
|
107
|
-
}, children);
|
|
108
|
-
}
|