@atlaskit/editor-plugin-panel 0.1.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/.eslintrc.js +18 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +30 -0
- package/dist/cjs/actions.js +125 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/message.js +44 -0
- package/dist/cjs/nodeviews/panel.js +94 -0
- package/dist/cjs/plugin.js +215 -0
- package/dist/cjs/pm-plugins/keymaps.js +81 -0
- package/dist/cjs/pm-plugins/main.js +28 -0
- package/dist/cjs/toolbar.js +293 -0
- package/dist/cjs/types.js +8 -0
- package/dist/cjs/utils.js +53 -0
- package/dist/es2019/actions.js +116 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/message.js +38 -0
- package/dist/es2019/nodeviews/panel.js +82 -0
- package/dist/es2019/plugin.js +191 -0
- package/dist/es2019/pm-plugins/keymaps.js +82 -0
- package/dist/es2019/pm-plugins/main.js +21 -0
- package/dist/es2019/toolbar.js +279 -0
- package/dist/es2019/types.js +2 -0
- package/dist/es2019/utils.js +48 -0
- package/dist/esm/actions.js +116 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/message.js +38 -0
- package/dist/esm/nodeviews/panel.js +87 -0
- package/dist/esm/plugin.js +208 -0
- package/dist/esm/pm-plugins/keymaps.js +74 -0
- package/dist/esm/pm-plugins/main.js +22 -0
- package/dist/esm/toolbar.js +286 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/utils.js +46 -0
- package/dist/types/actions.d.ts +12 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/message.d.ts +37 -0
- package/dist/types/nodeviews/panel.d.ts +36 -0
- package/dist/types/plugin.d.ts +17 -0
- package/dist/types/pm-plugins/keymaps.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +11 -0
- package/dist/types/toolbar.d.ts +15 -0
- package/dist/types/types.d.ts +21 -0
- package/dist/types/utils.d.ts +5 -0
- package/dist/types-ts4.5/actions.d.ts +12 -0
- package/dist/types-ts4.5/index.d.ts +3 -0
- package/dist/types-ts4.5/message.d.ts +37 -0
- package/dist/types-ts4.5/nodeviews/panel.d.ts +36 -0
- package/dist/types-ts4.5/plugin.d.ts +17 -0
- package/dist/types-ts4.5/pm-plugins/keymaps.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +11 -0
- package/dist/types-ts4.5/toolbar.d.ts +15 -0
- package/dist/types-ts4.5/types.d.ts +21 -0
- package/dist/types-ts4.5/utils.d.ts +5 -0
- package/package.json +102 -0
- package/report.api.md +74 -0
- package/tmp/api-report-tmp.d.ts +44 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
var _panelIconMap;
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
8
|
+
import commonMessages from '@atlaskit/editor-common/messages';
|
|
9
|
+
import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
|
|
10
|
+
import { DEFAULT_BORDER_COLOR, panelBackgroundPalette } from '@atlaskit/editor-common/ui-color';
|
|
11
|
+
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
12
|
+
import ErrorIcon from '@atlaskit/icon/glyph/editor/error';
|
|
13
|
+
import InfoIcon from '@atlaskit/icon/glyph/editor/info';
|
|
14
|
+
import NoteIcon from '@atlaskit/icon/glyph/editor/note';
|
|
15
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
16
|
+
import RemoveEmojiIcon from '@atlaskit/icon/glyph/editor/remove-emoji';
|
|
17
|
+
import SuccessIcon from '@atlaskit/icon/glyph/editor/success';
|
|
18
|
+
import WarningIcon from '@atlaskit/icon/glyph/editor/warning';
|
|
19
|
+
import { changePanelType, removePanel } from './actions';
|
|
20
|
+
import { messages } from './message';
|
|
21
|
+
import { findPanel } from './utils';
|
|
22
|
+
export var panelIconMap = (_panelIconMap = {}, _defineProperty(_panelIconMap, PanelType.INFO, {
|
|
23
|
+
shortName: ':info:',
|
|
24
|
+
id: 'atlassian-info'
|
|
25
|
+
}), _defineProperty(_panelIconMap, PanelType.NOTE, {
|
|
26
|
+
shortName: ':note:',
|
|
27
|
+
id: 'atlassian-note'
|
|
28
|
+
}), _defineProperty(_panelIconMap, PanelType.WARNING, {
|
|
29
|
+
shortName: ':warning:',
|
|
30
|
+
id: 'atlassian-warning'
|
|
31
|
+
}), _defineProperty(_panelIconMap, PanelType.ERROR, {
|
|
32
|
+
shortName: ':cross_mark:',
|
|
33
|
+
id: 'atlassian-cross_mark'
|
|
34
|
+
}), _defineProperty(_panelIconMap, PanelType.SUCCESS, {
|
|
35
|
+
shortName: ':check_mark:',
|
|
36
|
+
id: 'atlassian-check_mark'
|
|
37
|
+
}), _defineProperty(_panelIconMap, PanelType.TIP, {
|
|
38
|
+
shortName: ':tip:',
|
|
39
|
+
id: 'atlassian-tip'
|
|
40
|
+
}), _panelIconMap);
|
|
41
|
+
export var getToolbarItems = function getToolbarItems(formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, editorAnalyticsAPI, activePanelType, activePanelColor, activePanelIcon, state) {
|
|
42
|
+
// TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
|
|
43
|
+
var items = [{
|
|
44
|
+
id: 'editor.panel.info',
|
|
45
|
+
type: 'button',
|
|
46
|
+
icon: InfoIcon,
|
|
47
|
+
onClick: changePanelType(editorAnalyticsAPI)(PanelType.INFO),
|
|
48
|
+
selected: activePanelType === PanelType.INFO,
|
|
49
|
+
title: formatMessage(messages.info),
|
|
50
|
+
tabIndex: null
|
|
51
|
+
}, {
|
|
52
|
+
id: 'editor.panel.note',
|
|
53
|
+
type: 'button',
|
|
54
|
+
icon: NoteIcon,
|
|
55
|
+
onClick: changePanelType(editorAnalyticsAPI)(PanelType.NOTE),
|
|
56
|
+
selected: activePanelType === PanelType.NOTE,
|
|
57
|
+
title: formatMessage(messages.note),
|
|
58
|
+
tabIndex: null
|
|
59
|
+
}, {
|
|
60
|
+
id: 'editor.panel.success',
|
|
61
|
+
type: 'button',
|
|
62
|
+
icon: SuccessIcon,
|
|
63
|
+
onClick: changePanelType(editorAnalyticsAPI)(PanelType.SUCCESS),
|
|
64
|
+
selected: activePanelType === PanelType.SUCCESS,
|
|
65
|
+
title: formatMessage(messages.success),
|
|
66
|
+
tabIndex: null
|
|
67
|
+
}, {
|
|
68
|
+
id: 'editor.panel.warning',
|
|
69
|
+
type: 'button',
|
|
70
|
+
icon: WarningIcon,
|
|
71
|
+
onClick: changePanelType(editorAnalyticsAPI)(PanelType.WARNING),
|
|
72
|
+
selected: activePanelType === PanelType.WARNING,
|
|
73
|
+
title: formatMessage(messages.warning),
|
|
74
|
+
tabIndex: null
|
|
75
|
+
}, {
|
|
76
|
+
id: 'editor.panel.error',
|
|
77
|
+
type: 'button',
|
|
78
|
+
icon: ErrorIcon,
|
|
79
|
+
onClick: changePanelType(editorAnalyticsAPI)(PanelType.ERROR),
|
|
80
|
+
selected: activePanelType === PanelType.ERROR,
|
|
81
|
+
title: formatMessage(messages.error),
|
|
82
|
+
tabIndex: null
|
|
83
|
+
}];
|
|
84
|
+
if (isCustomPanelEnabled) {
|
|
85
|
+
var changeColor = function changeColor(color) {
|
|
86
|
+
return function (state, dispatch) {
|
|
87
|
+
var panelNode = findPanel(state);
|
|
88
|
+
if (panelNode === undefined) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
var previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : getPanelTypeBackgroundNoTokens(panelNode.node.attrs.panelType);
|
|
92
|
+
var emojiInfo = panelNode.node.attrs.panelType;
|
|
93
|
+
var panelEmoji = panelIconMap[emojiInfo];
|
|
94
|
+
var previousEmoji = panelEmoji ? {
|
|
95
|
+
emoji: panelEmoji.shortName,
|
|
96
|
+
emojiId: panelEmoji.id
|
|
97
|
+
} : {};
|
|
98
|
+
if (previousColor === color) {
|
|
99
|
+
changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, _objectSpread({
|
|
100
|
+
color: color
|
|
101
|
+
}, previousEmoji), isCustomPanelEnabled)(state, dispatch);
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
var payload = {
|
|
105
|
+
action: ACTION.CHANGED_BACKGROUND_COLOR,
|
|
106
|
+
actionSubject: ACTION_SUBJECT.PANEL,
|
|
107
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
108
|
+
attributes: {
|
|
109
|
+
newColor: color,
|
|
110
|
+
previousColor: previousColor
|
|
111
|
+
},
|
|
112
|
+
eventType: EVENT_TYPE.TRACK
|
|
113
|
+
};
|
|
114
|
+
withAnalytics(editorAnalyticsAPI, payload)(changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, _objectSpread({
|
|
115
|
+
color: color
|
|
116
|
+
}, previousEmoji), isCustomPanelEnabled))(state, dispatch);
|
|
117
|
+
return false;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
var changeEmoji = function changeEmoji(emoji) {
|
|
121
|
+
return function (state, dispatch) {
|
|
122
|
+
var panelNode = findPanel(state);
|
|
123
|
+
if (panelNode === undefined) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
var previousIcon = panelNode.node.attrs.panelIcon || '';
|
|
127
|
+
if (previousIcon === emoji.shortName) {
|
|
128
|
+
changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
|
|
129
|
+
emoji: emoji.shortName,
|
|
130
|
+
emojiId: emoji.id,
|
|
131
|
+
emojiText: emoji.fallback
|
|
132
|
+
}, true)(state, dispatch);
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
var payload = {
|
|
136
|
+
action: ACTION.CHANGED_ICON,
|
|
137
|
+
actionSubject: ACTION_SUBJECT.PANEL,
|
|
138
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
139
|
+
attributes: {
|
|
140
|
+
newIcon: emoji.shortName,
|
|
141
|
+
previousIcon: previousIcon
|
|
142
|
+
},
|
|
143
|
+
eventType: EVENT_TYPE.TRACK
|
|
144
|
+
};
|
|
145
|
+
withAnalytics(editorAnalyticsAPI, payload)(changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
|
|
146
|
+
emoji: emoji.shortName,
|
|
147
|
+
emojiId: emoji.id,
|
|
148
|
+
emojiText: emoji.fallback
|
|
149
|
+
}, true))(state, dispatch);
|
|
150
|
+
return false;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
var removeEmoji = function removeEmoji() {
|
|
154
|
+
return function (state, dispatch) {
|
|
155
|
+
var panelNode = findPanel(state);
|
|
156
|
+
if (activePanelType === PanelType.CUSTOM && !activePanelIcon) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if (panelNode === undefined) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
var payload = {
|
|
163
|
+
action: ACTION.REMOVE_ICON,
|
|
164
|
+
actionSubject: ACTION_SUBJECT.PANEL,
|
|
165
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
166
|
+
attributes: {
|
|
167
|
+
icon: panelNode.node.attrs.panelIcon
|
|
168
|
+
},
|
|
169
|
+
eventType: EVENT_TYPE.TRACK
|
|
170
|
+
};
|
|
171
|
+
withAnalytics(editorAnalyticsAPI, payload)(changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
|
|
172
|
+
emoji: undefined,
|
|
173
|
+
emojiId: undefined,
|
|
174
|
+
emojiText: undefined
|
|
175
|
+
}, isCustomPanelEnabled))(state, dispatch);
|
|
176
|
+
return false;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
var panelColor = activePanelType === PanelType.CUSTOM ? activePanelColor || getPanelTypeBackgroundNoTokens(PanelType.INFO) : getPanelTypeBackgroundNoTokens(activePanelType);
|
|
180
|
+
var defaultPalette = panelBackgroundPalette.find(function (item) {
|
|
181
|
+
return item.value === panelColor;
|
|
182
|
+
}) || {
|
|
183
|
+
label: 'Custom',
|
|
184
|
+
value: panelColor,
|
|
185
|
+
border: DEFAULT_BORDER_COLOR
|
|
186
|
+
};
|
|
187
|
+
if (isCustomPanelEditable) {
|
|
188
|
+
var colorPicker = {
|
|
189
|
+
id: 'editor.panel.colorPicker',
|
|
190
|
+
title: formatMessage(messages.backgroundColor),
|
|
191
|
+
type: 'select',
|
|
192
|
+
selectType: 'color',
|
|
193
|
+
defaultValue: defaultPalette,
|
|
194
|
+
options: panelBackgroundPalette,
|
|
195
|
+
onChange: function onChange(option) {
|
|
196
|
+
return changeColor(option.value);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
var emojiPicker = {
|
|
200
|
+
id: 'editor.panel.emojiPicker',
|
|
201
|
+
title: formatMessage(messages.emoji),
|
|
202
|
+
type: 'select',
|
|
203
|
+
selectType: 'emoji',
|
|
204
|
+
options: [],
|
|
205
|
+
selected: activePanelType === PanelType.CUSTOM && !!activePanelIcon,
|
|
206
|
+
onChange: function onChange(emoji) {
|
|
207
|
+
return changeEmoji(emoji);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
var removeEmojiButton = {
|
|
211
|
+
id: 'editor.panel.removeEmoji',
|
|
212
|
+
type: 'button',
|
|
213
|
+
icon: RemoveEmojiIcon,
|
|
214
|
+
onClick: removeEmoji(),
|
|
215
|
+
title: formatMessage(commonMessages.removeEmoji),
|
|
216
|
+
disabled: activePanelIcon ? false : true
|
|
217
|
+
};
|
|
218
|
+
items.push(emojiPicker, removeEmojiButton, {
|
|
219
|
+
type: 'separator'
|
|
220
|
+
}, colorPicker);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (state) {
|
|
224
|
+
items.push({
|
|
225
|
+
type: 'copy-button',
|
|
226
|
+
items: [{
|
|
227
|
+
type: 'separator'
|
|
228
|
+
}, {
|
|
229
|
+
state: state,
|
|
230
|
+
formatMessage: formatMessage,
|
|
231
|
+
nodeType: panelNodeType
|
|
232
|
+
}]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
items.push({
|
|
236
|
+
type: 'separator'
|
|
237
|
+
}, {
|
|
238
|
+
id: 'editor.panel.delete',
|
|
239
|
+
type: 'button',
|
|
240
|
+
appearance: 'danger',
|
|
241
|
+
focusEditoronEnter: true,
|
|
242
|
+
icon: RemoveIcon,
|
|
243
|
+
onClick: removePanel(editorAnalyticsAPI),
|
|
244
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, true),
|
|
245
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, false),
|
|
246
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, true),
|
|
247
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, false),
|
|
248
|
+
title: formatMessage(commonMessages.remove),
|
|
249
|
+
tabIndex: null
|
|
250
|
+
});
|
|
251
|
+
return items;
|
|
252
|
+
};
|
|
253
|
+
export var getToolbarConfig = function getToolbarConfig(state, intl) {
|
|
254
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
255
|
+
var providerFactory = arguments.length > 3 ? arguments[3] : undefined;
|
|
256
|
+
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
257
|
+
var formatMessage = intl.formatMessage;
|
|
258
|
+
var panelObject = findPanel(state);
|
|
259
|
+
if (panelObject) {
|
|
260
|
+
var _api$analytics;
|
|
261
|
+
var nodeType = state.schema.nodes.panel;
|
|
262
|
+
var _panelObject$node$att = panelObject.node.attrs,
|
|
263
|
+
panelType = _panelObject$node$att.panelType,
|
|
264
|
+
panelColor = _panelObject$node$att.panelColor,
|
|
265
|
+
panelIcon = _panelObject$node$att.panelIcon;
|
|
266
|
+
var isStandardPanel = function isStandardPanel(panelType) {
|
|
267
|
+
return panelType !== PanelType.CUSTOM ? panelType : undefined;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// force toolbar to be turned on
|
|
271
|
+
var items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
|
|
272
|
+
var getDomRef = function getDomRef(editorView) {
|
|
273
|
+
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
274
|
+
var element = findDomRefAtPos(panelObject.pos, domAtPos);
|
|
275
|
+
return element;
|
|
276
|
+
};
|
|
277
|
+
return {
|
|
278
|
+
title: 'Panel floating controls',
|
|
279
|
+
getDomRef: getDomRef,
|
|
280
|
+
nodeType: nodeType,
|
|
281
|
+
items: items,
|
|
282
|
+
scrollable: true
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return;
|
|
286
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { PanelType } from '@atlaskit/adf-schema';
|
|
5
|
+
import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
6
|
+
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
7
|
+
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
export var findPanel = function findPanel(state, selection) {
|
|
9
|
+
var panel = state.schema.nodes.panel;
|
|
10
|
+
return findSelectedNodeOfType(panel)(selection || state.selection) || findParentNodeOfType(panel)(selection || state.selection);
|
|
11
|
+
};
|
|
12
|
+
export var panelAttrsToDom = function panelAttrsToDom(attrs, allowCustomPanel) {
|
|
13
|
+
var panelColor = attrs.panelColor,
|
|
14
|
+
panelType = attrs.panelType,
|
|
15
|
+
panelIcon = attrs.panelIcon,
|
|
16
|
+
panelIconId = attrs.panelIconId,
|
|
17
|
+
panelIconText = attrs.panelIconText;
|
|
18
|
+
var isCustomPanel = panelType === PanelType.CUSTOM && allowCustomPanel;
|
|
19
|
+
var hasIcon = !isCustomPanel || !!panelIcon || !!panelIconId;
|
|
20
|
+
var tokenColor = panelColor && hexToEditorBackgroundPaletteColor(panelColor);
|
|
21
|
+
var panelBackgroundColor = tokenColor || panelColor;
|
|
22
|
+
var style = ["".concat(panelColor && isCustomPanel ? "background-color: ".concat(panelBackgroundColor, ";") : ''), "".concat(hasIcon ? '' : 'padding-left: 12px;')].join('');
|
|
23
|
+
var panelAttrs = {
|
|
24
|
+
class: PanelSharedCssClassName.prefix,
|
|
25
|
+
'data-panel-type': panelType || PanelType.INFO,
|
|
26
|
+
style: style
|
|
27
|
+
};
|
|
28
|
+
if (panelColor && isCustomPanel) {
|
|
29
|
+
panelAttrs = _objectSpread(_objectSpread({}, panelAttrs), {}, {
|
|
30
|
+
'data-panel-color': panelColor,
|
|
31
|
+
'data-panel-icon-id': panelIconId,
|
|
32
|
+
'data-panel-icon-text': panelIconText
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var iconDiv = ['div', {
|
|
36
|
+
class: PanelSharedCssClassName.icon
|
|
37
|
+
}];
|
|
38
|
+
var contentDiv = ['div', {
|
|
39
|
+
class: PanelSharedCssClassName.content
|
|
40
|
+
}, 0];
|
|
41
|
+
if (hasIcon) {
|
|
42
|
+
return ['div', panelAttrs, iconDiv, contentDiv];
|
|
43
|
+
} else {
|
|
44
|
+
return ['div', panelAttrs, contentDiv];
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { PanelOptions } from './pm-plugins/main';
|
|
6
|
+
export type DomAtPos = (pos: number) => {
|
|
7
|
+
node: HTMLElement;
|
|
8
|
+
offset: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const removePanel: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
11
|
+
export declare const changePanelType: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (panelType: PanelType, panelOptions?: PanelOptions, allowCustomPanel?: boolean) => Command;
|
|
12
|
+
export declare function insertPanelWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const messages: {
|
|
2
|
+
info: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
note: {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
success: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
warning: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
error: {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
emoji: {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
backgroundColor: {
|
|
33
|
+
id: string;
|
|
34
|
+
defaultMessage: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PanelAttributes } from '@atlaskit/adf-schema';
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
import type { getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { PanelPluginOptions } from '../types';
|
|
9
|
+
export declare const panelIcons: {
|
|
10
|
+
[key in PanelType]: React.ComponentType<{
|
|
11
|
+
label: string;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
interface PanelIconAttributes {
|
|
15
|
+
panelAttributes: PanelAttributes;
|
|
16
|
+
providerFactory?: ProviderFactory;
|
|
17
|
+
allowCustomPanel?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const PanelIcon: (props: PanelIconAttributes) => JSX.Element;
|
|
20
|
+
declare class PanelNodeView {
|
|
21
|
+
node: Node;
|
|
22
|
+
dom: HTMLElement;
|
|
23
|
+
contentDOM: HTMLElement;
|
|
24
|
+
icon: HTMLElement;
|
|
25
|
+
getPos: getPosHandlerNode;
|
|
26
|
+
view: EditorView;
|
|
27
|
+
providerFactory?: ProviderFactory;
|
|
28
|
+
pluginOptions: PanelPluginOptions;
|
|
29
|
+
constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, pluginOptions: PanelPluginOptions, providerFactory?: ProviderFactory);
|
|
30
|
+
ignoreMutation(mutation: MutationRecord | {
|
|
31
|
+
type: 'selection';
|
|
32
|
+
target: Element;
|
|
33
|
+
}): boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const getPanelNodeView: (pluginOptions: PanelPluginOptions, providerFactory?: ProviderFactory) => (node: Node, view: EditorView, getPos: getPosHandler) => PanelNodeView;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
+
import type { PanelPluginOptions } from './types';
|
|
6
|
+
export type PanelPlugin = NextEditorPlugin<'panel', {
|
|
7
|
+
pluginConfiguration: PanelPluginOptions | undefined;
|
|
8
|
+
dependencies: [
|
|
9
|
+
typeof decorationsPlugin,
|
|
10
|
+
OptionalPlugin<typeof analyticsPlugin>
|
|
11
|
+
];
|
|
12
|
+
actions: {
|
|
13
|
+
insertPanel: (inputMethod: INPUT_METHOD) => Command;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
declare const panelPlugin: PanelPlugin;
|
|
17
|
+
export default panelPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { PanelPluginOptions } from '../types';
|
|
5
|
+
export type PanelOptions = {
|
|
6
|
+
color?: string;
|
|
7
|
+
emoji?: string;
|
|
8
|
+
emojiId?: string;
|
|
9
|
+
emojiText?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const createPlugin: (dispatch: Dispatch, providerFactory: ProviderFactory, pluginOptions: PanelPluginOptions) => SafePlugin<any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarConfig, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
|
|
7
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import type { EmojiInfo, PanelPluginOptions } from './types';
|
|
10
|
+
import type { PanelPlugin } from './index';
|
|
11
|
+
export declare const panelIconMap: {
|
|
12
|
+
[key in Exclude<PanelType, PanelType.CUSTOM>]: EmojiInfo;
|
|
13
|
+
};
|
|
14
|
+
export declare const getToolbarItems: (formatMessage: IntlShape['formatMessage'], panelNodeType: NodeType, isCustomPanelEnabled: boolean, isCustomPanelEditable: boolean, providerFactory: ProviderFactory, hoverDecoration: HoverDecorationHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, activePanelType?: string, activePanelColor?: string, activePanelIcon?: string, state?: EditorState) => FloatingToolbarItem<Command>[];
|
|
15
|
+
export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, options: PanelPluginOptions | undefined, providerFactory: ProviderFactory, api: ExtractInjectionAPI<PanelPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LongPressSelectionPluginOptions } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const pluginKey: PluginKey<any>;
|
|
4
|
+
export interface PanelPluginOptions extends LongPressSelectionPluginOptions, PanelPluginConfig {
|
|
5
|
+
}
|
|
6
|
+
export interface PanelPluginConfig {
|
|
7
|
+
allowCustomPanel?: boolean;
|
|
8
|
+
allowCustomPanelEdit?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type DomPanelAtrrs = {
|
|
11
|
+
class: string;
|
|
12
|
+
'data-panel-type': string;
|
|
13
|
+
'data-panel-color'?: string;
|
|
14
|
+
'data-panel-icon-id'?: string;
|
|
15
|
+
'data-panel-icon-text'?: string;
|
|
16
|
+
style: string;
|
|
17
|
+
};
|
|
18
|
+
export type EmojiInfo = {
|
|
19
|
+
shortName: string;
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PanelAttributes } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { DOMOutputSpec } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
export declare const findPanel: (state: EditorState, selection?: Selection | null) => import("prosemirror-utils/dist/types").FindResult;
|
|
5
|
+
export declare const panelAttrsToDom: (attrs: PanelAttributes, allowCustomPanel: boolean) => DOMOutputSpec;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { PanelOptions } from './pm-plugins/main';
|
|
6
|
+
export type DomAtPos = (pos: number) => {
|
|
7
|
+
node: HTMLElement;
|
|
8
|
+
offset: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const removePanel: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
11
|
+
export declare const changePanelType: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (panelType: PanelType, panelOptions?: PanelOptions, allowCustomPanel?: boolean) => Command;
|
|
12
|
+
export declare function insertPanelWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const messages: {
|
|
2
|
+
info: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
note: {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
success: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
warning: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
error: {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
emoji: {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
backgroundColor: {
|
|
33
|
+
id: string;
|
|
34
|
+
defaultMessage: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PanelAttributes } from '@atlaskit/adf-schema';
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
import type { getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { PanelPluginOptions } from '../types';
|
|
9
|
+
export declare const panelIcons: {
|
|
10
|
+
[key in PanelType]: React.ComponentType<{
|
|
11
|
+
label: string;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
interface PanelIconAttributes {
|
|
15
|
+
panelAttributes: PanelAttributes;
|
|
16
|
+
providerFactory?: ProviderFactory;
|
|
17
|
+
allowCustomPanel?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const PanelIcon: (props: PanelIconAttributes) => JSX.Element;
|
|
20
|
+
declare class PanelNodeView {
|
|
21
|
+
node: Node;
|
|
22
|
+
dom: HTMLElement;
|
|
23
|
+
contentDOM: HTMLElement;
|
|
24
|
+
icon: HTMLElement;
|
|
25
|
+
getPos: getPosHandlerNode;
|
|
26
|
+
view: EditorView;
|
|
27
|
+
providerFactory?: ProviderFactory;
|
|
28
|
+
pluginOptions: PanelPluginOptions;
|
|
29
|
+
constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, pluginOptions: PanelPluginOptions, providerFactory?: ProviderFactory);
|
|
30
|
+
ignoreMutation(mutation: MutationRecord | {
|
|
31
|
+
type: 'selection';
|
|
32
|
+
target: Element;
|
|
33
|
+
}): boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const getPanelNodeView: (pluginOptions: PanelPluginOptions, providerFactory?: ProviderFactory) => (node: Node, view: EditorView, getPos: getPosHandler) => PanelNodeView;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
+
import type { PanelPluginOptions } from './types';
|
|
6
|
+
export type PanelPlugin = NextEditorPlugin<'panel', {
|
|
7
|
+
pluginConfiguration: PanelPluginOptions | undefined;
|
|
8
|
+
dependencies: [
|
|
9
|
+
typeof decorationsPlugin,
|
|
10
|
+
OptionalPlugin<typeof analyticsPlugin>
|
|
11
|
+
];
|
|
12
|
+
actions: {
|
|
13
|
+
insertPanel: (inputMethod: INPUT_METHOD) => Command;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
declare const panelPlugin: PanelPlugin;
|
|
17
|
+
export default panelPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { PanelPluginOptions } from '../types';
|
|
5
|
+
export type PanelOptions = {
|
|
6
|
+
color?: string;
|
|
7
|
+
emoji?: string;
|
|
8
|
+
emojiId?: string;
|
|
9
|
+
emojiText?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const createPlugin: (dispatch: Dispatch, providerFactory: ProviderFactory, pluginOptions: PanelPluginOptions) => SafePlugin<any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarConfig, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
|
|
7
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import type { EmojiInfo, PanelPluginOptions } from './types';
|
|
10
|
+
import type { PanelPlugin } from './index';
|
|
11
|
+
export declare const panelIconMap: {
|
|
12
|
+
[key in Exclude<PanelType, PanelType.CUSTOM>]: EmojiInfo;
|
|
13
|
+
};
|
|
14
|
+
export declare const getToolbarItems: (formatMessage: IntlShape['formatMessage'], panelNodeType: NodeType, isCustomPanelEnabled: boolean, isCustomPanelEditable: boolean, providerFactory: ProviderFactory, hoverDecoration: HoverDecorationHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, activePanelType?: string, activePanelColor?: string, activePanelIcon?: string, state?: EditorState) => FloatingToolbarItem<Command>[];
|
|
15
|
+
export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, options: PanelPluginOptions | undefined, providerFactory: ProviderFactory, api: ExtractInjectionAPI<PanelPlugin> | undefined) => FloatingToolbarConfig | undefined;
|