@atlaskit/editor-core 188.8.0 → 188.9.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 +13 -0
- package/dist/cjs/composable-editor/editor-internal.js +2 -2
- package/dist/cjs/create-editor/ReactEditorView.js +796 -8
- package/dist/cjs/labs/next/presets/universal.js +7 -4
- package/dist/cjs/plugins/index.js +0 -21
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/editor-internal.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +753 -2
- package/dist/es2019/labs/next/presets/universal.js +4 -1
- package/dist/es2019/plugins/index.js +0 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/editor-internal.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +797 -8
- package/dist/esm/labs/next/presets/universal.js +4 -1
- package/dist/esm/plugins/index.js +0 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
- package/dist/types/plugins/index.d.ts +0 -3
- package/dist/types/plugins/insert-block/types.d.ts +1 -1
- package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
- package/dist/types-ts4.5/plugins/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/package.json +5 -3
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
- package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
- package/dist/cjs/plugins/save-on-enter/index.js +0 -70
- package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
- package/dist/cjs/plugins/status/actions.js +0 -158
- package/dist/cjs/plugins/status/analytics.js +0 -31
- package/dist/cjs/plugins/status/index.js +0 -143
- package/dist/cjs/plugins/status/keymap.js +0 -22
- package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
- package/dist/cjs/plugins/status/plugin-key.js +0 -9
- package/dist/cjs/plugins/status/plugin.js +0 -133
- package/dist/cjs/plugins/status/types.js +0 -5
- package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
- package/dist/cjs/plugins/status/utils.js +0 -22
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
- package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
- package/dist/es2019/plugins/save-on-enter/index.js +0 -63
- package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
- package/dist/es2019/plugins/status/actions.js +0 -144
- package/dist/es2019/plugins/status/analytics.js +0 -18
- package/dist/es2019/plugins/status/index.js +0 -135
- package/dist/es2019/plugins/status/keymap.js +0 -13
- package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
- package/dist/es2019/plugins/status/plugin-key.js +0 -3
- package/dist/es2019/plugins/status/plugin.js +0 -113
- package/dist/es2019/plugins/status/types.js +0 -1
- package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
- package/dist/es2019/plugins/status/utils.js +0 -12
- package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
- package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
- package/dist/esm/plugins/save-on-enter/index.js +0 -63
- package/dist/esm/plugins/scroll-into-view/index.js +0 -50
- package/dist/esm/plugins/status/actions.js +0 -151
- package/dist/esm/plugins/status/analytics.js +0 -24
- package/dist/esm/plugins/status/index.js +0 -136
- package/dist/esm/plugins/status/keymap.js +0 -15
- package/dist/esm/plugins/status/nodeviews/status.js +0 -51
- package/dist/esm/plugins/status/plugin-key.js +0 -3
- package/dist/esm/plugins/status/plugin.js +0 -115
- package/dist/esm/plugins/status/types.js +0 -1
- package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
- package/dist/esm/plugins/status/utils.js +0 -16
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
- package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
- package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
- package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
- package/dist/types/plugins/status/actions.d.ts +0 -16
- package/dist/types/plugins/status/analytics.d.ts +0 -4
- package/dist/types/plugins/status/index.d.ts +0 -15
- package/dist/types/plugins/status/keymap.d.ts +0 -3
- package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
- package/dist/types/plugins/status/plugin-key.d.ts +0 -4
- package/dist/types/plugins/status/plugin.d.ts +0 -7
- package/dist/types/plugins/status/types.d.ts +0 -18
- package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
- package/dist/types/plugins/status/utils.d.ts +0 -5
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
- package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
- package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
- package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
- package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
- package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
- package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
- package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
- package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
- package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
- package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ReactEditorView } from './ReactEditorViewInternal';
|
|
3
|
-
import { injectIntl } from 'react-intl-next';
|
|
4
|
-
export function ReactEditorViewEditor(props) {
|
|
5
|
-
return /*#__PURE__*/React.createElement(ReactEditorView, props);
|
|
6
|
-
}
|
|
7
|
-
export default injectIntl(ReactEditorViewEditor);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../plugins/analytics';
|
|
3
|
-
import { analyticsEventKey } from '../analytics/consts';
|
|
4
|
-
export function createPlugin(eventDispatch, onSave) {
|
|
5
|
-
if (!onSave) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
return keymap({
|
|
9
|
-
Enter: function Enter(state, _dispatch, editorView) {
|
|
10
|
-
if (editorView && canSaveOnEnter(editorView)) {
|
|
11
|
-
eventDispatch(analyticsEventKey, analyticsPayload(state));
|
|
12
|
-
onSave(editorView);
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function canSaveOnEnter(editorView) {
|
|
20
|
-
var _ref = editorView.state.selection,
|
|
21
|
-
$cursor = _ref.$cursor;
|
|
22
|
-
var _editorView$state$sch = editorView.state.schema.nodes,
|
|
23
|
-
decisionItem = _editorView$state$sch.decisionItem,
|
|
24
|
-
paragraph = _editorView$state$sch.paragraph,
|
|
25
|
-
taskItem = _editorView$state$sch.taskItem;
|
|
26
|
-
return !$cursor || $cursor.parent.type === paragraph && $cursor.depth === 1 || $cursor.parent.type === decisionItem && !isEmptyAtCursor($cursor) || $cursor.parent.type === taskItem && !isEmptyAtCursor($cursor);
|
|
27
|
-
}
|
|
28
|
-
function isEmptyAtCursor($cursor) {
|
|
29
|
-
var content = $cursor.parent.content;
|
|
30
|
-
return !(content && content.size);
|
|
31
|
-
}
|
|
32
|
-
var analyticsPayload = function analyticsPayload(state) {
|
|
33
|
-
return {
|
|
34
|
-
payload: {
|
|
35
|
-
action: ACTION.STOPPED,
|
|
36
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
37
|
-
actionSubjectId: ACTION_SUBJECT_ID.SAVE,
|
|
38
|
-
attributes: {
|
|
39
|
-
inputMethod: INPUT_METHOD.SHORTCUT,
|
|
40
|
-
documentSize: state.doc.nodeSize
|
|
41
|
-
// TODO add individual node counts - tables, headings, lists, mediaSingles, mediaGroups, mediaCards, panels, extensions, decisions, action, codeBlocks
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
eventType: EVENT_TYPE.UI
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
var saveOnEnterPlugin = function saveOnEnterPlugin(_ref2) {
|
|
49
|
-
var onSave = _ref2.config;
|
|
50
|
-
return {
|
|
51
|
-
name: 'saveOnEnter',
|
|
52
|
-
pmPlugins: function pmPlugins() {
|
|
53
|
-
return [{
|
|
54
|
-
name: 'saveOnEnter',
|
|
55
|
-
plugin: function plugin(_ref3) {
|
|
56
|
-
var dispatch = _ref3.dispatch;
|
|
57
|
-
return createPlugin(dispatch, onSave);
|
|
58
|
-
}
|
|
59
|
-
}];
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export default saveOnEnterPlugin;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { TEXT_INPUT_RULE_TRANSACTION_KEY } from '@atlaskit/prosemirror-input-rules';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Plugin to scroll the user's selection into view whenever the user updates
|
|
7
|
-
* the document eg. inserting, deleting, formatting
|
|
8
|
-
*
|
|
9
|
-
* Behaviour is on by default, can be explicitly opted out of for a transaction by
|
|
10
|
-
* setting scrollIntoView=false meta
|
|
11
|
-
* We ignore collab transactions, appended transactions, transactions without steps,
|
|
12
|
-
* transactions with addToHistory=false meta and typeahead trigger transactions
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export var scrollIntoViewPluginKey = new PluginKey('scrollIntoViewPlugin');
|
|
16
|
-
var createPlugin = function createPlugin() {
|
|
17
|
-
return new SafePlugin({
|
|
18
|
-
key: scrollIntoViewPluginKey,
|
|
19
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
20
|
-
if (!transactions.length) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
var tr = transactions[0];
|
|
24
|
-
if ((tr.docChanged || tr.storedMarksSet) && !tr.scrolledIntoView && tr.getMeta('scrollIntoView') !== false &&
|
|
25
|
-
// ignore anything we would not want to undo
|
|
26
|
-
// this covers things like autofixing layouts, hovering table rows/cols
|
|
27
|
-
tr.getMeta('addToHistory') !== false &&
|
|
28
|
-
// ignore collab changes from another user
|
|
29
|
-
!tr.getMeta('isRemote') &&
|
|
30
|
-
// ignore any transaction coming from the input text rule plugin
|
|
31
|
-
!tr.getMeta(TEXT_INPUT_RULE_TRANSACTION_KEY)) {
|
|
32
|
-
return newState.tr.scrollIntoView();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var scrollIntoViewPlugin = function scrollIntoViewPlugin() {
|
|
38
|
-
return {
|
|
39
|
-
name: 'scrollIntoView',
|
|
40
|
-
pmPlugins: function pmPlugins() {
|
|
41
|
-
return [{
|
|
42
|
-
name: 'scrollIntoView',
|
|
43
|
-
plugin: function plugin() {
|
|
44
|
-
return createPlugin();
|
|
45
|
-
}
|
|
46
|
-
}];
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export default scrollIntoViewPlugin;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
9
|
-
import { pluginKey } from './plugin-key';
|
|
10
|
-
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
-
export var DEFAULT_STATUS = {
|
|
12
|
-
text: '',
|
|
13
|
-
color: 'neutral'
|
|
14
|
-
};
|
|
15
|
-
export var createStatus = function createStatus() {
|
|
16
|
-
var showStatusPickerAtOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
17
|
-
return function (insert, state) {
|
|
18
|
-
var statusNode = state.schema.nodes.status.createChecked(_objectSpread(_objectSpread({}, DEFAULT_STATUS), {}, {
|
|
19
|
-
localId: uuid.generate()
|
|
20
|
-
}));
|
|
21
|
-
var space = state.schema.text(' ');
|
|
22
|
-
var tr = insert(Fragment.from([statusNode, space]), {
|
|
23
|
-
selectInlineNode: true
|
|
24
|
-
});
|
|
25
|
-
var showStatusPickerAt = tr.selection.from + showStatusPickerAtOffset;
|
|
26
|
-
return tr.setSelection(NodeSelection.create(tr.doc, showStatusPickerAt)).setMeta(pluginKey, {
|
|
27
|
-
showStatusPickerAt: showStatusPickerAt,
|
|
28
|
-
isNew: true
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export var updateStatus = function updateStatus(status) {
|
|
33
|
-
return function (state, dispatch) {
|
|
34
|
-
var schema = state.schema;
|
|
35
|
-
var selectedStatus = status ? Object.assign(status, {
|
|
36
|
-
text: status.text.trim(),
|
|
37
|
-
localId: status.localId || uuid.generate()
|
|
38
|
-
}) : status;
|
|
39
|
-
var statusProps = _objectSpread(_objectSpread({}, DEFAULT_STATUS), selectedStatus);
|
|
40
|
-
var tr = state.tr;
|
|
41
|
-
var _ref = pluginKey.getState(state) || {},
|
|
42
|
-
showStatusPickerAt = _ref.showStatusPickerAt;
|
|
43
|
-
if (!showStatusPickerAt) {
|
|
44
|
-
// Same behaviour as quick insert (used in createStatus)
|
|
45
|
-
var statusNode = schema.nodes.status.createChecked(statusProps);
|
|
46
|
-
var fragment = Fragment.fromArray([statusNode, state.schema.text(' ')]);
|
|
47
|
-
var insertable = canInsert(tr.selection.$from, fragment);
|
|
48
|
-
if (!insertable) {
|
|
49
|
-
var parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
50
|
-
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
51
|
-
} else {
|
|
52
|
-
tr.insert(tr.selection.from, fragment).setSelection(NodeSelection.create(tr.doc, tr.selection.from - fragment.size));
|
|
53
|
-
}
|
|
54
|
-
tr.setMeta(pluginKey, {
|
|
55
|
-
showStatusPickerAt: tr.selection.from,
|
|
56
|
-
isNew: true
|
|
57
|
-
}).scrollIntoView();
|
|
58
|
-
if (dispatch) {
|
|
59
|
-
dispatch(tr);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
if (state.doc.nodeAt(showStatusPickerAt)) {
|
|
64
|
-
tr.setNodeMarkup(showStatusPickerAt, schema.nodes.status, statusProps).setSelection(NodeSelection.create(tr.doc, showStatusPickerAt)).setMeta(pluginKey, {
|
|
65
|
-
showStatusPickerAt: showStatusPickerAt
|
|
66
|
-
}).scrollIntoView();
|
|
67
|
-
if (dispatch) {
|
|
68
|
-
dispatch(tr);
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
export var updateStatusWithAnalytics = function updateStatusWithAnalytics(editorAnalyticsAPI) {
|
|
76
|
-
return function (inputMethod, status) {
|
|
77
|
-
return withAnalytics(editorAnalyticsAPI, {
|
|
78
|
-
action: ACTION.INSERTED,
|
|
79
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
80
|
-
actionSubjectId: ACTION_SUBJECT_ID.STATUS,
|
|
81
|
-
attributes: {
|
|
82
|
-
inputMethod: inputMethod
|
|
83
|
-
},
|
|
84
|
-
eventType: EVENT_TYPE.TRACK
|
|
85
|
-
})(updateStatus(status));
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
export var setStatusPickerAt = function setStatusPickerAt(showStatusPickerAt) {
|
|
89
|
-
return function (state, dispatch) {
|
|
90
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
91
|
-
showStatusPickerAt: showStatusPickerAt,
|
|
92
|
-
isNew: false
|
|
93
|
-
}));
|
|
94
|
-
return true;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
export var removeStatus = function removeStatus(showStatusPickerAt) {
|
|
98
|
-
return function (state, dispatch) {
|
|
99
|
-
var tr = state.tr;
|
|
100
|
-
tr.replace(showStatusPickerAt, showStatusPickerAt + 1);
|
|
101
|
-
if (dispatch) {
|
|
102
|
-
dispatch(tr);
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
var handleClosingByArrows = function handleClosingByArrows(closingMethod, state, showStatusPickerAt, tr) {
|
|
108
|
-
if (closingMethod === 'arrowLeft') {
|
|
109
|
-
// put cursor right before status Lozenge
|
|
110
|
-
tr = tr.setSelection(Selection.near(state.tr.doc.resolve(showStatusPickerAt), -1));
|
|
111
|
-
} else if (closingMethod === 'arrowRight') {
|
|
112
|
-
// put cursor right after status Lozenge
|
|
113
|
-
tr = tr.setSelection(Selection.near(state.tr.doc.resolve(showStatusPickerAt + 1)));
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
export var commitStatusPicker = function commitStatusPicker(closingPayload) {
|
|
117
|
-
return function (editorView) {
|
|
118
|
-
var state = editorView.state,
|
|
119
|
-
dispatch = editorView.dispatch;
|
|
120
|
-
var _ref2 = pluginKey.getState(state) || {},
|
|
121
|
-
showStatusPickerAt = _ref2.showStatusPickerAt;
|
|
122
|
-
var _ref3 = closingPayload || {},
|
|
123
|
-
closingMethod = _ref3.closingMethod;
|
|
124
|
-
if (!showStatusPickerAt) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
var statusNode = state.tr.doc.nodeAt(showStatusPickerAt);
|
|
128
|
-
if (!statusNode) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
var tr = state.tr;
|
|
132
|
-
tr = tr.setMeta(pluginKey, {
|
|
133
|
-
showStatusPickerAt: null,
|
|
134
|
-
isNew: false
|
|
135
|
-
});
|
|
136
|
-
if (closingMethod) {
|
|
137
|
-
handleClosingByArrows(closingMethod, state, showStatusPickerAt, tr);
|
|
138
|
-
} else if (statusNode.attrs.text) {
|
|
139
|
-
// still has content - keep content
|
|
140
|
-
// move selection after status if selection did not change
|
|
141
|
-
if (tr.selection.from === showStatusPickerAt) {
|
|
142
|
-
tr = tr.setSelection(Selection.near(state.tr.doc.resolve(showStatusPickerAt + 2)));
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
// no content - remove node
|
|
146
|
-
tr = tr.delete(showStatusPickerAt, showStatusPickerAt + 1);
|
|
147
|
-
}
|
|
148
|
-
dispatch(tr);
|
|
149
|
-
editorView.focus();
|
|
150
|
-
};
|
|
151
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { name as packageName, version as packageVersion } from '../../version-wrapper';
|
|
5
|
-
export var FABRIC_CHANNEL = 'fabric-elements';
|
|
6
|
-
export var createStatusAnalyticsAndFire = function createStatusAnalyticsAndFire(createAnalyticsEvent) {
|
|
7
|
-
return function (payload) {
|
|
8
|
-
if (createAnalyticsEvent && payload) {
|
|
9
|
-
var statusPayload = _objectSpread(_objectSpread({}, payload), {}, {
|
|
10
|
-
eventType: 'ui'
|
|
11
|
-
});
|
|
12
|
-
if (!statusPayload.attributes) {
|
|
13
|
-
statusPayload.attributes = {};
|
|
14
|
-
}
|
|
15
|
-
statusPayload.attributes.packageName = packageName;
|
|
16
|
-
statusPayload.attributes.packageVersion = packageVersion;
|
|
17
|
-
statusPayload.attributes.componentName = 'status';
|
|
18
|
-
createAnalyticsEvent(statusPayload).fire(FABRIC_CHANNEL);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export var analyticsState = function analyticsState(isNew) {
|
|
23
|
-
return isNew ? 'new' : 'update';
|
|
24
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import { status } from '@atlaskit/adf-schema';
|
|
4
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { IconStatus } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
-
import { updateStatusWithAnalytics, commitStatusPicker, createStatus, updateStatus } from './actions';
|
|
9
|
-
import { keymapPlugin } from './keymap';
|
|
10
|
-
import createStatusPlugin from './plugin';
|
|
11
|
-
import { pluginKey } from './plugin-key';
|
|
12
|
-
import StatusPicker from './ui/statusPicker';
|
|
13
|
-
var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
14
|
-
var _api$analytics;
|
|
15
|
-
var options = _ref.config,
|
|
16
|
-
api = _ref.api;
|
|
17
|
-
return {
|
|
18
|
-
name: 'status',
|
|
19
|
-
nodes: function nodes() {
|
|
20
|
-
return [{
|
|
21
|
-
name: 'status',
|
|
22
|
-
node: status
|
|
23
|
-
}];
|
|
24
|
-
},
|
|
25
|
-
pmPlugins: function pmPlugins() {
|
|
26
|
-
return [{
|
|
27
|
-
name: 'status',
|
|
28
|
-
plugin: function plugin(pmPluginFactoryParams) {
|
|
29
|
-
return createStatusPlugin(pmPluginFactoryParams, options);
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
name: 'statusKeymap',
|
|
33
|
-
plugin: keymapPlugin
|
|
34
|
-
}];
|
|
35
|
-
},
|
|
36
|
-
actions: {
|
|
37
|
-
commitStatusPicker: commitStatusPicker,
|
|
38
|
-
updateStatus: updateStatusWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
39
|
-
},
|
|
40
|
-
contentComponent: function contentComponent(_ref2) {
|
|
41
|
-
var editorView = _ref2.editorView,
|
|
42
|
-
popupsMountPoint = _ref2.popupsMountPoint,
|
|
43
|
-
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
44
|
-
popupsScrollableElement = _ref2.popupsScrollableElement;
|
|
45
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
46
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
47
|
-
plugins: {
|
|
48
|
-
statusState: pluginKey
|
|
49
|
-
},
|
|
50
|
-
render: function render(_ref3) {
|
|
51
|
-
var _ref3$statusState = _ref3.statusState,
|
|
52
|
-
statusState = _ref3$statusState === void 0 ? {} : _ref3$statusState;
|
|
53
|
-
var showStatusPickerAt = statusState.showStatusPickerAt;
|
|
54
|
-
if (typeof showStatusPickerAt !== 'number') {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
var target = findDomRefAtPos(showStatusPickerAt, domAtPos);
|
|
58
|
-
var statusNode = editorView.state.doc.nodeAt(showStatusPickerAt);
|
|
59
|
-
if (!statusNode || statusNode.type.name !== 'status') {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
var _statusNode$attrs = statusNode.attrs,
|
|
63
|
-
text = _statusNode$attrs.text,
|
|
64
|
-
color = _statusNode$attrs.color,
|
|
65
|
-
localId = _statusNode$attrs.localId;
|
|
66
|
-
return /*#__PURE__*/React.createElement(StatusPicker, {
|
|
67
|
-
isNew: statusState.isNew,
|
|
68
|
-
target: target,
|
|
69
|
-
defaultText: text,
|
|
70
|
-
defaultColor: color,
|
|
71
|
-
defaultLocalId: localId,
|
|
72
|
-
mountTo: popupsMountPoint,
|
|
73
|
-
boundariesElement: popupsBoundariesElement,
|
|
74
|
-
scrollableElement: popupsScrollableElement,
|
|
75
|
-
onSelect: function onSelect(status) {
|
|
76
|
-
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
77
|
-
},
|
|
78
|
-
onTextChanged: function onTextChanged(status) {
|
|
79
|
-
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
80
|
-
},
|
|
81
|
-
closeStatusPicker: function closeStatusPicker(closingPayload) {
|
|
82
|
-
commitStatusPicker(closingPayload)(editorView);
|
|
83
|
-
},
|
|
84
|
-
onEnter: function onEnter() {
|
|
85
|
-
commitStatusPicker()(editorView);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
94
|
-
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
95
|
-
return plugin;
|
|
96
|
-
}
|
|
97
|
-
plugin.pluginsOptions = {
|
|
98
|
-
quickInsert: function quickInsert(_ref4) {
|
|
99
|
-
var formatMessage = _ref4.formatMessage;
|
|
100
|
-
return [{
|
|
101
|
-
id: 'status',
|
|
102
|
-
title: formatMessage(messages.status),
|
|
103
|
-
description: formatMessage(messages.statusDescription),
|
|
104
|
-
priority: 700,
|
|
105
|
-
keywords: ['lozenge'],
|
|
106
|
-
icon: function icon() {
|
|
107
|
-
return /*#__PURE__*/React.createElement(IconStatus, null);
|
|
108
|
-
},
|
|
109
|
-
action: function action(insert, state) {
|
|
110
|
-
var _api$analytics2;
|
|
111
|
-
var tr = createStatus()(insert, state);
|
|
112
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
113
|
-
action: ACTION.INSERTED,
|
|
114
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
115
|
-
actionSubjectId: ACTION_SUBJECT_ID.STATUS,
|
|
116
|
-
attributes: {
|
|
117
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
118
|
-
},
|
|
119
|
-
eventType: EVENT_TYPE.TRACK
|
|
120
|
-
})(tr);
|
|
121
|
-
return tr;
|
|
122
|
-
}
|
|
123
|
-
}];
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
return plugin;
|
|
127
|
-
};
|
|
128
|
-
var statusPlugin = function statusPlugin(_ref5) {
|
|
129
|
-
var options = _ref5.config,
|
|
130
|
-
api = _ref5.api;
|
|
131
|
-
return decorateWithPluginOptions(baseStatusPlugin({
|
|
132
|
-
config: options,
|
|
133
|
-
api: api
|
|
134
|
-
}), options, api);
|
|
135
|
-
};
|
|
136
|
-
export default statusPlugin;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import { bindKeymapWithCommand, enter, tab } from '@atlaskit/editor-common/keymaps';
|
|
3
|
-
import { mayGetStatusAtSelection } from './utils';
|
|
4
|
-
export function keymapPlugin() {
|
|
5
|
-
var list = {};
|
|
6
|
-
bindKeymapWithCommand(enter.common, consumeKeyEvent, list);
|
|
7
|
-
bindKeymapWithCommand(tab.common, consumeKeyEvent, list);
|
|
8
|
-
return keymap(list);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// consume event to prevent status node problems with positioning and selection
|
|
12
|
-
var consumeKeyEvent = function consumeKeyEvent(state, _dispatch) {
|
|
13
|
-
return !!mayGetStatusAtSelection(state.tr.selection);
|
|
14
|
-
};
|
|
15
|
-
export default keymapPlugin;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2;
|
|
3
|
-
/** @jsx jsx */
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { css, jsx } from '@emotion/react';
|
|
6
|
-
import { injectIntl } from 'react-intl-next';
|
|
7
|
-
import { Status } from '@atlaskit/status/element';
|
|
8
|
-
import { statusMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
var styledStatus = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n opacity: 1;\n"])));
|
|
10
|
-
var styledStatusPlaceholder = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n opacity: 0.5;\n"])));
|
|
11
|
-
var StatusContainerView = function StatusContainerView(props) {
|
|
12
|
-
var text = props.text,
|
|
13
|
-
color = props.color,
|
|
14
|
-
localId = props.localId,
|
|
15
|
-
style = props.style,
|
|
16
|
-
formatMessage = props.intl.formatMessage;
|
|
17
|
-
var statusText = text ? text : formatMessage(messages.placeholder);
|
|
18
|
-
var handleClick = function handleClick(event) {
|
|
19
|
-
if (event.nativeEvent.stopImmediatePropagation) {
|
|
20
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
21
|
-
}
|
|
22
|
-
// handling of popup is done in plugin.apply on selection change.
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return jsx("span", {
|
|
26
|
-
css: text ? styledStatus : styledStatusPlaceholder,
|
|
27
|
-
"data-testid": "statusContainerView"
|
|
28
|
-
}, jsx(Status, {
|
|
29
|
-
text: statusText,
|
|
30
|
-
color: color,
|
|
31
|
-
localId: localId,
|
|
32
|
-
style: style,
|
|
33
|
-
onClick: handleClick
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
36
|
-
export var IntlStatusContainerView = injectIntl(StatusContainerView);
|
|
37
|
-
export var StatusNodeView = function StatusNodeView(props) {
|
|
38
|
-
var view = props.view;
|
|
39
|
-
var _props$node$attrs = props.node.attrs,
|
|
40
|
-
text = _props$node$attrs.text,
|
|
41
|
-
color = _props$node$attrs.color,
|
|
42
|
-
localId = _props$node$attrs.localId,
|
|
43
|
-
style = _props$node$attrs.style;
|
|
44
|
-
return jsx(IntlStatusContainerView, {
|
|
45
|
-
view: view,
|
|
46
|
-
text: text,
|
|
47
|
-
color: color,
|
|
48
|
-
style: style,
|
|
49
|
-
localId: localId
|
|
50
|
-
});
|
|
51
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
-
import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
|
|
8
|
-
import { StatusNodeView } from './nodeviews/status';
|
|
9
|
-
import { pluginKey } from './plugin-key';
|
|
10
|
-
import { isEmptyStatus, mayGetStatusAtSelection } from './utils';
|
|
11
|
-
export { pluginKey, pluginKeyName } from './plugin-key';
|
|
12
|
-
var createPlugin = function createPlugin(pmPluginFactoryParams, options) {
|
|
13
|
-
return new SafePlugin({
|
|
14
|
-
state: {
|
|
15
|
-
init: function init() {
|
|
16
|
-
return {
|
|
17
|
-
isNew: false,
|
|
18
|
-
showStatusPickerAt: null
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
apply: function apply(tr, state, oldEditorState) {
|
|
22
|
-
var meta = tr.getMeta(pluginKey);
|
|
23
|
-
if (meta) {
|
|
24
|
-
var newState = _objectSpread(_objectSpread({}, state), meta);
|
|
25
|
-
pmPluginFactoryParams.dispatch(pluginKey, newState);
|
|
26
|
-
return newState;
|
|
27
|
-
}
|
|
28
|
-
if (tr.docChanged && state.showStatusPickerAt) {
|
|
29
|
-
var _tr$mapping$mapResult = tr.mapping.mapResult(state.showStatusPickerAt),
|
|
30
|
-
pos = _tr$mapping$mapResult.pos,
|
|
31
|
-
deleted = _tr$mapping$mapResult.deleted;
|
|
32
|
-
var showStatusPickerAt = deleted ? null : pos;
|
|
33
|
-
var _newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
34
|
-
showStatusPickerAt: showStatusPickerAt
|
|
35
|
-
});
|
|
36
|
-
if (_newState.showStatusPickerAt !== state.showStatusPickerAt) {
|
|
37
|
-
pmPluginFactoryParams.dispatch(pluginKey, _newState);
|
|
38
|
-
return _newState;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (tr.selectionSet) {
|
|
42
|
-
// Change in selection, while status picker was open, update state, if required.
|
|
43
|
-
var selectionFrom = tr.selection.from;
|
|
44
|
-
var nodeAtSelection = tr.doc.nodeAt(selectionFrom);
|
|
45
|
-
var _showStatusPickerAt = null;
|
|
46
|
-
if (nodeAtSelection && nodeAtSelection.type === oldEditorState.schema.nodes.status && tr.selection instanceof NodeSelection) {
|
|
47
|
-
_showStatusPickerAt = selectionFrom;
|
|
48
|
-
}
|
|
49
|
-
if (_showStatusPickerAt !== state.showStatusPickerAt) {
|
|
50
|
-
var _newState2 = _objectSpread(_objectSpread({}, state), {}, {
|
|
51
|
-
isNew: false,
|
|
52
|
-
showStatusPickerAt: _showStatusPickerAt
|
|
53
|
-
});
|
|
54
|
-
pmPluginFactoryParams.dispatch(pluginKey, _newState2);
|
|
55
|
-
return _newState2;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return state;
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
filterTransaction: function filterTransaction(tr, state) {
|
|
62
|
-
// if it is a selection change transaction, and selection changes from node to text
|
|
63
|
-
if (tr.selectionSet && !tr.steps.length && tr.isGeneric && tr.selection instanceof TextSelection && state.selection instanceof NodeSelection) {
|
|
64
|
-
var _ref = pluginKey.getState(state) || {},
|
|
65
|
-
isNew = _ref.isNew,
|
|
66
|
-
showStatusPickerAt = _ref.showStatusPickerAt;
|
|
67
|
-
var nodeAtSelection = tr.doc.nodeAt(tr.selection.from);
|
|
68
|
-
// prevent changing node selection to text selection on dom change right after inserting status
|
|
69
|
-
// if newly selected status is selected with status picker opened
|
|
70
|
-
if (isNew && showStatusPickerAt && nodeAtSelection && nodeAtSelection.type === state.schema.nodes.status) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
},
|
|
76
|
-
appendTransaction: function appendTransaction(transactions, oldEditorState, newEditorState) {
|
|
77
|
-
var changed = false;
|
|
78
|
-
var tr = newEditorState.tr;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* When user start creating status, and, when users navigates away
|
|
82
|
-
* while empty, then we want to remove empty ("set a status") status.
|
|
83
|
-
* But when transaction to add empty status happens from undo/redo
|
|
84
|
-
* we don't want to remove it.
|
|
85
|
-
*/
|
|
86
|
-
if (transactions.find(function (tr) {
|
|
87
|
-
return tr.selectionSet && !tr.getMeta(pmHistoryPluginKey);
|
|
88
|
-
})) {
|
|
89
|
-
var oldStatus = mayGetStatusAtSelection(oldEditorState.selection);
|
|
90
|
-
var newStatus = mayGetStatusAtSelection(newEditorState.selection);
|
|
91
|
-
if (oldStatus && (newStatus && oldStatus.localId !== newStatus.localId || !newStatus)) {
|
|
92
|
-
if (isEmptyStatus(oldStatus)) {
|
|
93
|
-
var pos = oldEditorState.selection.from;
|
|
94
|
-
tr.delete(tr.mapping.map(pos), tr.mapping.map(pos + 1));
|
|
95
|
-
changed = true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return changed ? tr : undefined;
|
|
100
|
-
},
|
|
101
|
-
key: pluginKey,
|
|
102
|
-
props: {
|
|
103
|
-
nodeViews: {
|
|
104
|
-
status: getInlineNodeViewProducer({
|
|
105
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
106
|
-
Component: StatusNodeView,
|
|
107
|
-
extraComponentProps: {
|
|
108
|
-
options: options
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
export default createPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|