@atlaskit/editor-core 191.0.9 → 191.1.3
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 +14 -0
- package/afm-cc/tsconfig.json +3 -6
- package/dist/cjs/plugins/index.js +1 -8
- package/dist/cjs/presets/universal.js +10 -13
- package/dist/cjs/ui/Addon/click-area-helper.js +2 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -3
- package/dist/cjs/ui/Appearance/Comment/Toolbar.js +19 -6
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +6 -12
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +1 -2
- package/dist/es2019/presets/universal.js +11 -14
- package/dist/es2019/ui/Addon/click-area-helper.js +2 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +6 -3
- package/dist/es2019/ui/Appearance/Comment/Toolbar.js +38 -6
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +4 -10
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +1 -2
- package/dist/esm/presets/universal.js +11 -14
- package/dist/esm/ui/Addon/click-area-helper.js +2 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -3
- package/dist/esm/ui/Appearance/Comment/Toolbar.js +19 -6
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +4 -10
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/presets/default.d.ts +6 -36
- package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/presets/default.d.ts +6 -36
- package/dist/types-ts4.5/ui/Appearance/Comment/Toolbar.d.ts +2 -1
- package/docs/0-intro.tsx +252 -174
- package/docs/1-legacy-editor.tsx +268 -0
- package/package.json +7 -7
- package/dist/cjs/plugins/avatar-group/index.js +0 -40
- package/dist/cjs/plugins/avatar-group/messages.js +0 -14
- package/dist/cjs/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -49
- package/dist/cjs/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -42
- package/dist/cjs/plugins/avatar-group/ui/avatars.js +0 -70
- package/dist/cjs/plugins/avatar-group/ui/colored-avatar-item.js +0 -20
- package/dist/cjs/plugins/avatar-group/ui/index.js +0 -9
- package/dist/cjs/plugins/avatar-group/ui/invite-to-edit.js +0 -45
- package/dist/cjs/plugins/avatar-group/ui/styles.js +0 -17
- package/dist/cjs/plugins/avatar-group/ui/to-avatar.js +0 -30
- package/dist/es2019/plugins/avatar-group/index.js +0 -35
- package/dist/es2019/plugins/avatar-group/messages.js +0 -8
- package/dist/es2019/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -53
- package/dist/es2019/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -38
- package/dist/es2019/plugins/avatar-group/ui/avatars.js +0 -62
- package/dist/es2019/plugins/avatar-group/ui/colored-avatar-item.js +0 -13
- package/dist/es2019/plugins/avatar-group/ui/index.js +0 -2
- package/dist/es2019/plugins/avatar-group/ui/invite-to-edit.js +0 -32
- package/dist/es2019/plugins/avatar-group/ui/styles.js +0 -46
- package/dist/es2019/plugins/avatar-group/ui/to-avatar.js +0 -16
- package/dist/esm/plugins/avatar-group/index.js +0 -33
- package/dist/esm/plugins/avatar-group/messages.js +0 -8
- package/dist/esm/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -42
- package/dist/esm/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -35
- package/dist/esm/plugins/avatar-group/ui/avatars.js +0 -62
- package/dist/esm/plugins/avatar-group/ui/colored-avatar-item.js +0 -13
- package/dist/esm/plugins/avatar-group/ui/index.js +0 -2
- package/dist/esm/plugins/avatar-group/ui/invite-to-edit.js +0 -34
- package/dist/esm/plugins/avatar-group/ui/styles.js +0 -10
- package/dist/esm/plugins/avatar-group/ui/to-avatar.js +0 -23
- package/dist/types/plugins/avatar-group/index.d.ts +0 -19
- package/dist/types/plugins/avatar-group/messages.d.ts +0 -7
- package/dist/types/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +0 -18
- package/dist/types/plugins/avatar-group/ui/avatars-with-plugin-state.d.ts +0 -81
- package/dist/types/plugins/avatar-group/ui/avatars.d.ts +0 -17
- package/dist/types/plugins/avatar-group/ui/colored-avatar-item.d.ts +0 -10
- package/dist/types/plugins/avatar-group/ui/index.d.ts +0 -2
- package/dist/types/plugins/avatar-group/ui/invite-to-edit.d.ts +0 -10
- package/dist/types/plugins/avatar-group/ui/styles.d.ts +0 -3
- package/dist/types/plugins/avatar-group/ui/to-avatar.d.ts +0 -30
- package/dist/types-ts4.5/plugins/avatar-group/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/avatar-group/messages.d.ts +0 -7
- package/dist/types-ts4.5/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +0 -18
- package/dist/types-ts4.5/plugins/avatar-group/ui/avatars-with-plugin-state.d.ts +0 -97
- package/dist/types-ts4.5/plugins/avatar-group/ui/avatars.d.ts +0 -19
- package/dist/types-ts4.5/plugins/avatar-group/ui/colored-avatar-item.d.ts +0 -12
- package/dist/types-ts4.5/plugins/avatar-group/ui/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/avatar-group/ui/invite-to-edit.d.ts +0 -10
- package/dist/types-ts4.5/plugins/avatar-group/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/plugins/avatar-group/ui/to-avatar.d.ts +0 -37
- /package/docs/{1-labs.tsx → 2-labs.tsx} +0 -0
- /package/docs/{2-autoformatting.tsx → 3-autoformatting.tsx} +0 -0
- /package/docs/{3-annotations.tsx → 4-annotations.tsx} +0 -0
package/docs/0-intro.tsx
CHANGED
|
@@ -9,252 +9,329 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export default md`
|
|
11
11
|
${(<AtlassianInternalWarning />)}
|
|
12
|
+
## Introduction
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
The \`@atlaskit/editor-core\` package is part of the Atlassian front-end platform and provides core functionality for the rich text editor. It provides an easy-to-use and highly customizable editing experience, built on React as our primary rendering approach. It relies on the ProseMirror libraries, which offer a wide range of out-of-the-box features, including support for text formatting, lists, and more.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
There is a separate Renderer package that caters for rendering the edited content without the editing experience.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
* Fetch API ([polyfill](https://www.npmjs.com/package/whatwg-fetch), [browser support](http://caniuse.com/#feat=fetch))
|
|
19
|
-
* Element.closest ([polyfill](https://www.npmjs.com/package/element-closest), [browser support](http://caniuse.com/#feat=element-closest))
|
|
18
|
+
This documentation will provide you with everything you need to get started using the Atlassian Editor, including:
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
* Installation instructions
|
|
21
|
+
* Basic usage examples
|
|
22
|
+
* Advanced customization options
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
## Prerequisites
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
* **React 16:** at the time of writing, the Atlassian Editor is built on top of React 16 and doesn’t explicitly support any higher versions of React yet, which means both the \`react\` and \`react-dom\` libraries and their dependencies need to be set to React 16 compatible version.
|
|
27
|
+
* **Singleton:** the ProseMirror libraries in use and the document format \(Atlassian Document Format, ADF\) demand that some of the libraries using them are singletons, as multiple versions of the library will cause breaking issues. So, consumers of the Atlassian Editor need to enforce these singletons; this is usually done by deduplicating after installing the dependencies or by setting libraries to specific versions through resolutions to avoid multiple versions. Our recommendation is to use [yarn-deduplicate](https://www.npmjs.com/package/yarn-deduplicate).
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
## Installation
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
1. Install the editor libraries
|
|
32
|
+
- **npm:** \`npm install --save @atlaskit/editor-core @atlaskit/css-reset\`
|
|
33
|
+
- **yarn:** \`yarn add @atlaskit/editor-core @atlaskit/css-reset\`
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
2. Deduplicate the dependencies \(if necessary\) by setting resolutions to avoid multiple versions of the editor libraries or by running [npm dedupe](https://docs.npmjs.com/cli/v6/commands/npm-dedupe) or [yarn dedupe](https://yarnpkg.com/cli/dedupe) after installation.
|
|
36
|
+
3. Setup the CSS reset in your application
|
|
37
|
+
\`import '@atlaskit/css-reset';\`
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### [Legacy Editor](editor-core/docs/legacy-editor)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Composable Editor
|
|
45
|
+
|
|
46
|
+
#### Simplest implementation
|
|
47
|
+
|
|
48
|
+
The following code example will render the comment editor with only basic text formatting enabled.
|
|
34
49
|
|
|
35
50
|
${code`
|
|
36
|
-
|
|
51
|
+
import { ComposableEditor } from '@atlaskit/editor-core/composable-editor';
|
|
52
|
+
import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
|
|
53
|
+
import { usePreset } from '@atlaskit/editor-core/use-preset';
|
|
54
|
+
import { basePlugin } from '@atlaskit/editor-plugin-base';
|
|
55
|
+
|
|
56
|
+
const CommentEditor = () => {
|
|
57
|
+
const { preset } = usePreset(() =>
|
|
58
|
+
new EditorPresetBuilder().add(basePlugin)
|
|
59
|
+
, []);
|
|
60
|
+
|
|
61
|
+
return <ComposableEditor preset={preset} />;
|
|
62
|
+
};
|
|
63
|
+
`}
|
|
64
|
+
|
|
65
|
+
You can enable more editor functionality by passing extra plugins to the preset as discussed below.
|
|
37
66
|
|
|
38
|
-
|
|
67
|
+
If coming from the legacy editor, the simplest migration would be via the \`universal\` preset.
|
|
68
|
+
|
|
69
|
+
**Warning**: The \`universal\` preset brings in all editor plugins which can impact heavily bundle size. It is generally recommended to build your own custom preset as will be discussed.
|
|
70
|
+
|
|
71
|
+
${code`
|
|
72
|
+
import { ComposableEditor } from '@atlaskit/editor-core/composable-editor';
|
|
73
|
+
import { useUniversalPreset } from '@atlaskit/editor-core/preset-universal';
|
|
74
|
+
|
|
75
|
+
const CommentEditor = () => {
|
|
76
|
+
const presetProps = {
|
|
77
|
+
props: {},
|
|
78
|
+
};
|
|
79
|
+
const universalPreset = useUniversalPreset(presetProps);
|
|
80
|
+
|
|
81
|
+
return <ComposableEditor preset={universalPreset} />;
|
|
82
|
+
};
|
|
39
83
|
`}
|
|
40
84
|
|
|
41
|
-
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
### Presets
|
|
42
88
|
|
|
43
|
-
|
|
89
|
+
The Atlassian Editor employs a plugin system to extend its capabilities, offering a wide range of plugins to enhance its feature set. Plugins can also have dependencies on one another to deliver their functionality \(for example, the table plugin depends on the guideline plugin\). To simplify the process of including and configuring these plugins, we've introduced the concept of presets. Presets are a collection of plugins that work seamlessly together.
|
|
44
90
|
|
|
45
|
-
|
|
91
|
+
You can start with one of the preset provided with \`editor-core\` and extend their functionality, or build your own using \`EditorPresetBuilder\`. You always need the \`basePlugin\` in any preset.
|
|
46
92
|
|
|
47
|
-
|
|
93
|
+
#### Using the Pre-defined Default Preset
|
|
48
94
|
|
|
49
95
|
${code`
|
|
50
|
-
|
|
51
|
-
|
|
96
|
+
import { createDefaultPreset } from '@atlaskit/editor-core/preset-default';
|
|
97
|
+
import { usePreset } from '@atlaskit/editor-core/use-preset';
|
|
52
98
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/>;
|
|
99
|
+
const createPreset = () =>
|
|
100
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
101
|
+
const { preset } = usePreset(createPreset, []);
|
|
57
102
|
`}
|
|
58
103
|
|
|
59
|
-
|
|
104
|
+
The default preset encompasses all the essentials needed for the Editor to function, representing the minimum set of plugins. It includes core Atlassian libraries essential for editor development \(feature flags, analytics, editor state management\), as well as common editor features \(copy/paste, clipboard support, focus, composition, decorations, undo/redo, block elements, annotations, hyperlink support, basic text formatting, responsive width support, quick-insert, type-ahead, placeholder text, editor controls, selections, code blocks\). Some of these core plugins can be disabled through the configuration object passed into \`createDefaultPreset\`.
|
|
60
105
|
|
|
61
|
-
|
|
106
|
+
|
|
107
|
+
#### Using the Pre-defined Universal Preset
|
|
62
108
|
|
|
63
109
|
${code`
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
collapseEditor = () => this.setState({ isExpanded: false });
|
|
71
|
-
|
|
72
|
-
onSave = () => {
|
|
73
|
-
/* do something */
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
render() {
|
|
77
|
-
return (
|
|
78
|
-
<CollapsedEditor
|
|
79
|
-
placeholder="What would you like to say?"
|
|
80
|
-
isExpanded={this.state.isExpanded}
|
|
81
|
-
onFocus={this.expandEditor}
|
|
82
|
-
>
|
|
83
|
-
<Editor
|
|
84
|
-
appearance="comment"
|
|
85
|
-
onSave={this.onSave}
|
|
86
|
-
onCancel={this.collapseEditor}
|
|
87
|
-
/>
|
|
88
|
-
</CollapsedEditor>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
110
|
+
import { useUniversalPreset } from '@atlaskit/editor-core/preset-universal';
|
|
111
|
+
|
|
112
|
+
const presetProps = {
|
|
113
|
+
props: {},
|
|
114
|
+
};
|
|
115
|
+
const universalPreset = useUniversalPreset(presetProps);
|
|
92
116
|
`}
|
|
93
117
|
|
|
94
|
-
|
|
118
|
+
In addition to the default preset, the universal preset contains a comprehensive set of features for a fully-featured editor. It supports functionalities like data consumers, content insertion, breakout, alignment, text color, lists, rules, expands, guidelines, media, captions, mentions, emoji, tables, tasks & decisions, feedback dialogs, help dialogs, collaborative editing, maximum content size restrictions, Jira issue linking, panels, context panels, extensions, macros, annotations, dates, placeholder text, layouts, cards, auto-formatting rules, status elements, indentation, scroll-into-view behavior, complex history behavior, mobile support, and advanced toolbar support.
|
|
119
|
+
|
|
95
120
|
|
|
96
|
-
|
|
121
|
+
#### Adding a plugin to a preset
|
|
122
|
+
|
|
123
|
+
To add a plugin to a preset, use the following methods:
|
|
124
|
+
|
|
125
|
+
* Use \`maybeAdd\` to conditionally add the plugin.
|
|
126
|
+
* Use \`add\` for plugins that should always be included.
|
|
97
127
|
|
|
98
128
|
${code`
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
import { createDefaultPreset } from '@atlaskit/editor-core/preset-default';
|
|
130
|
+
import { usePreset } from '@atlaskit/editor-core/use-preset';
|
|
131
|
+
|
|
132
|
+
const createPreset = () =>
|
|
133
|
+
createDefaultPreset({ featureFlags: {}, paste: {} })
|
|
134
|
+
.add(listPlugin)
|
|
135
|
+
.maybeAdd(NextEditorPluginAI, (plugin, builder) => {
|
|
136
|
+
if (editorPluginAIProvider) {
|
|
137
|
+
return builder.add([plugin, { editorPluginAIProvider }]); // Add the plugin
|
|
138
|
+
}
|
|
139
|
+
return builder; // Don't add the plugin
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const { preset } = usePreset(createPreset, []);
|
|
143
|
+
`}
|
|
144
|
+
|
|
145
|
+
Some plugins are dependent on others. If you encounter type issues with a specific plugin, it's crucial to verify that all necessary dependencies have been added. These can be cross-checked within the individual documentation of each plugin.
|
|
146
|
+
|
|
147
|
+
#### Create a custom preset
|
|
148
|
+
|
|
149
|
+
Create your custom preset using the \`default\` preset as a base (extending with card and list functionality).
|
|
150
|
+
|
|
151
|
+
${code`
|
|
152
|
+
import { usePreset } from '@atlaskit/editor-core/use-preset';
|
|
153
|
+
import { createDefaultPreset } from '@atlaskit/editor-core/labs-next';
|
|
154
|
+
|
|
155
|
+
const createPreset = () =>
|
|
156
|
+
createDefaultPreset({ featureFlags: {}, paste: {} })
|
|
157
|
+
.add(gridPlugin)
|
|
158
|
+
.add([cardPlugin, { platform: 'web' }])
|
|
159
|
+
.add(listPlugin);
|
|
160
|
+
|
|
161
|
+
const { preset } = usePreset(createPreset, []);
|
|
115
162
|
`}
|
|
116
163
|
|
|
117
|
-
|
|
164
|
+
Or from scratch (simple preset with basic text formatting, list, analytics, and headings):
|
|
165
|
+
|
|
166
|
+
${code`
|
|
167
|
+
import { ComposableEditor } from '@atlaskit/editor-core/composable-editor';
|
|
168
|
+
import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
|
|
169
|
+
import { usePreset } from '@atlaskit/editor-core/use-preset';
|
|
170
|
+
import { basePlugin } from '@atlaskit/editor-plugin-base';
|
|
171
|
+
import { blockTypePlugin } from '@atlaskit/editor-plugin-block-type';
|
|
172
|
+
import { listPlugin } from '@atlaskit/editor-plugin-list';
|
|
173
|
+
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
174
|
+
|
|
175
|
+
const createPreset = () =>
|
|
176
|
+
new EditorPresetBuilder()
|
|
177
|
+
.add(basePlugin)
|
|
178
|
+
.add(analyticsPlugin)
|
|
179
|
+
.add(blockTypePlugin)
|
|
180
|
+
.add(listPlugin)
|
|
181
|
+
|
|
182
|
+
const { preset } = usePreset(createPreset, []);
|
|
183
|
+
`}
|
|
118
184
|
|
|
119
|
-
|
|
185
|
+
To keep your integrated editor running smoothly, it's important to have a stable preset. If you generate a new preset every time the editor re-renders, it can slow things down significantly. The best way to maintain a stable preset across re-renders is to use the \`usePreset\` hook or similar memoization techniques. This helps your editor run efficiently without unnecessary recalculations.
|
|
120
186
|
|
|
121
|
-
|
|
187
|
+
---
|
|
122
188
|
|
|
123
|
-
|
|
189
|
+
### Appearances
|
|
124
190
|
|
|
125
|
-
|
|
191
|
+
Appearances determine how the editor's user interface \(UI\) is displayed and can be configured using a property passed into the editor component.
|
|
126
192
|
|
|
127
|
-
You can use \`WithEditorActions\` and \`actions.replaceDocument(documentValueHere)\` together
|
|
128
193
|
|
|
129
|
-
|
|
194
|
+
#### Comment
|
|
130
195
|
|
|
131
|
-
|
|
196
|
+
The comment editor appearance provides a contained editor UI with a simple toolbar. It is best used when the Editor isn't the primary focus area of the page, such as when it's used for editing comments on a page. This editor appearance still includes a toolbar with editor controls.
|
|
132
197
|
|
|
133
198
|
${code`
|
|
134
|
-
import { Editor, BitbucketTransformer } from '@atlaskit/editor-core';
|
|
135
199
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
200
|
+
const createPreset = () =>
|
|
201
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
202
|
+
const { preset } = usePreset(createPreset, []);
|
|
203
|
+
|
|
204
|
+
// 'comment' is the default appearance, you don't need to pass it
|
|
205
|
+
return <ComposableEditor appearance='comment' preset={preset} />;
|
|
140
206
|
`}
|
|
141
207
|
|
|
142
|
-
|
|
208
|
+
Comment is the default appearance so this is equivalent:
|
|
143
209
|
|
|
144
|
-
|
|
210
|
+
${code`
|
|
211
|
+
|
|
212
|
+
const createPreset = () =>
|
|
213
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
214
|
+
const { preset } = usePreset(createPreset, []);
|
|
215
|
+
|
|
216
|
+
return <ComposableEditor preset={preset} />;
|
|
217
|
+
`}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
#### Full Page and Full Width
|
|
221
|
+
|
|
222
|
+
The full-page and full-width editor appearances provide an editor UI that stretches to fill the entire page. They are suitable when the Editor is the main focus area on the page.
|
|
145
223
|
|
|
146
224
|
${code`
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
render() {
|
|
157
|
-
return (
|
|
158
|
-
<EditorContext>
|
|
159
|
-
<WithEditorActions
|
|
160
|
-
render={actions => (
|
|
161
|
-
<Editor
|
|
162
|
-
appearance="comment"
|
|
163
|
-
onSave={this.onSubmit(actions)}
|
|
164
|
-
/>
|
|
165
|
-
)}
|
|
166
|
-
/>
|
|
167
|
-
</EditorContext>
|
|
168
|
-
)
|
|
169
|
-
}
|
|
225
|
+
const createPreset = () =>
|
|
226
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
227
|
+
const { preset } = usePreset(createPreset, []);
|
|
228
|
+
|
|
229
|
+
return <ComposableEditor appearance='full-page' preset={preset} />;
|
|
230
|
+
// Or full-width
|
|
231
|
+
return <ComposableEditor appearance='full-width' preset={preset} />;
|
|
170
232
|
`}
|
|
171
233
|
|
|
172
|
-
|
|
234
|
+
|
|
235
|
+
#### Chromeless
|
|
236
|
+
|
|
237
|
+
The chromeless editor appearance provides the Editor without any of the standard UI features. It's ideal for cases where the integrator wants complete control and responsibility over the editor UI.
|
|
173
238
|
|
|
174
239
|
${code`
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.props.actions.getValue().then(value => {
|
|
180
|
-
if (value != null) {
|
|
181
|
-
dispatch({ type: 'SAVE_COMMENT', payload: value });
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
render() {
|
|
187
|
-
return (
|
|
188
|
-
<Editor
|
|
189
|
-
appearance="comment"
|
|
190
|
-
onSave={this.onSubmit}
|
|
191
|
-
/>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
class SaveExample extends React.Component {
|
|
197
|
-
render() {
|
|
198
|
-
return (
|
|
199
|
-
<EditorContext>
|
|
200
|
-
<WithEditorActions
|
|
201
|
-
render={actions => <EditorWrapper actions={actions} />}
|
|
202
|
-
/>
|
|
203
|
-
</EditorContext>
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
240
|
+
const createPreset = () =>
|
|
241
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
242
|
+
const { preset } = usePreset(createPreset, []);
|
|
243
|
+
return <ComposableEditor appearance='chromeless' preset={preset} />;
|
|
207
244
|
`}
|
|
208
245
|
|
|
209
|
-
|
|
246
|
+
#### Mobile
|
|
210
247
|
|
|
211
|
-
|
|
212
|
-
To render certain ADF content correctly in different color themes, such as light and dark mode, this package utilise
|
|
213
|
-
the \`@atlaskit/editor-palette\` package, which converts colors stored in ADF to Atlassian Design Tokens.
|
|
214
|
-
Learn more about this utility in the [Editor Palette docs](/packages/editor/editor-palette).
|
|
248
|
+
The mobile editor appearance is tailored to deliver a mobile experience through a mobile web view. It's essentially a full-page editor version for mobile.
|
|
215
249
|
|
|
216
|
-
|
|
217
|
-
|
|
250
|
+
${code`
|
|
251
|
+
const createPreset = () =>
|
|
252
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
253
|
+
const { preset } = usePreset(createPreset, []);
|
|
254
|
+
return <ComposableEditor appearance='mobile' preset={preset} />;
|
|
255
|
+
`}
|
|
218
256
|
|
|
219
|
-
## Tab indexing / focus
|
|
220
|
-
If you are displaying a title you may need to listen for a tab event to
|
|
221
|
-
explicitly enable and focus the editor.
|
|
222
257
|
|
|
223
|
-
|
|
258
|
+
### Collapsible Editor
|
|
224
259
|
|
|
225
|
-
|
|
260
|
+
Sometimes, you may not want to display the whole Editor initially, and you'd prefer to show it in a collapsed state so that users can expand it when needed.
|
|
226
261
|
|
|
227
|
-
|
|
262
|
+
Here's how you can implement this behavior:
|
|
228
263
|
|
|
229
264
|
${code`
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
265
|
+
import { useState } from 'react';
|
|
266
|
+
import { CollapsedEditor } from '@atlaskit/editor-core';
|
|
267
|
+
import { ComposableEditor } from '@atlaskit/editor-core/composable-editor';
|
|
268
|
+
import { useUniversalPreset } from '@atlaskit/editor-core/preset-universal';
|
|
269
|
+
|
|
270
|
+
const CollapsibleEditor = () => {
|
|
271
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
272
|
+
|
|
273
|
+
const createPreset = () =>
|
|
274
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
275
|
+
const { preset } = usePreset(createPreset, []);
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<CollapsedEditor
|
|
279
|
+
placeholder='What would you like to say?'
|
|
280
|
+
onFocus={() => setIsExpanded(true)}
|
|
281
|
+
isExpanded={isExpanded}>
|
|
282
|
+
<ComposableEditor
|
|
283
|
+
preset={preset}
|
|
284
|
+
// TODO: We don't actually want people to use onSave
|
|
285
|
+
onSave={(_editorView) => alert('The save button is a lie.')}
|
|
286
|
+
onCancel={() => setIsExpanded(false)}
|
|
238
287
|
/>
|
|
239
|
-
|
|
240
|
-
|
|
288
|
+
</CollapsedEditor>
|
|
289
|
+
);
|
|
290
|
+
};
|
|
241
291
|
`}
|
|
242
292
|
|
|
293
|
+
|
|
294
|
+
### Editor with providers
|
|
295
|
+
|
|
296
|
+
The Editor can't access information from its context by default. Instead, specific plugins provide a mechanism to allow you to supply custom logic for accessing environment variables.
|
|
297
|
+
|
|
298
|
+
An excellent example of this is mentions, where you would want to provide user information the Editor can access and define how it should be presented inside the Editor. To enable the capability of mentioning users inside the Editor, you need to pass in a "mention provider." This object allows you to define the logic used to determine which users can be mentioned in the Editor.
|
|
299
|
+
|
|
300
|
+
This could look something like this:
|
|
301
|
+
|
|
243
302
|
${code`
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
303
|
+
import { ComposableEditor } from '@atlaskit/editor-core/composable-editor';
|
|
304
|
+
import { useUniversalPreset } from '@atlaskit/editor-core/preset-universal';
|
|
305
|
+
import { MentionDescription, MentionProvider } from '@atlaskit/mention';
|
|
306
|
+
|
|
307
|
+
const CommentEditorWithMentions = () => {
|
|
308
|
+
const exampleMentionProvider: MentionProvider = {
|
|
309
|
+
filter(_query?: string): void {},
|
|
310
|
+
recordMentionSelection(_mention: MentionDescription): void {},
|
|
311
|
+
shouldHighlightMention(_mention: MentionDescription): boolean {
|
|
312
|
+
return false;
|
|
313
|
+
},
|
|
314
|
+
isFiltering(_query: string): boolean {
|
|
247
315
|
return false;
|
|
248
|
-
}
|
|
316
|
+
},
|
|
317
|
+
subscribe(): void {},
|
|
318
|
+
unsubscribe(_key: string): void {},
|
|
249
319
|
};
|
|
320
|
+
|
|
321
|
+
const createPreset = () =>
|
|
322
|
+
createDefaultPreset({ featureFlags: {}, paste: {} });
|
|
323
|
+
const { preset } = usePreset(createPreset, []);
|
|
324
|
+
|
|
325
|
+
return <ComposableEditor preset={preset} mentionProvider={presetProps.props.mentionProvider} />;
|
|
326
|
+
};
|
|
250
327
|
`}
|
|
251
328
|
|
|
252
329
|
${(
|
|
253
330
|
<Example
|
|
254
|
-
packageName="@atlaskit/editor-core"
|
|
255
|
-
Component={require('../examples/1-basic').default}
|
|
331
|
+
packageName="@atlaskit/editor-core/composable-editor"
|
|
332
|
+
Component={require('../examples/1-basic-composable-editor').default}
|
|
256
333
|
title="Basic"
|
|
257
|
-
source={require('!!raw-loader!../examples/1-basic')}
|
|
334
|
+
source={require('!!raw-loader!../examples/1-basic-composable-editor')}
|
|
258
335
|
/>
|
|
259
336
|
)}
|
|
260
337
|
|
|
@@ -262,7 +339,8 @@ ${(
|
|
|
262
339
|
<Props
|
|
263
340
|
shouldCollapseProps
|
|
264
341
|
heading="Props"
|
|
265
|
-
props={require('!!extract-react-types-loader!../src/editor')}
|
|
342
|
+
props={require('!!extract-react-types-loader!../src/composable-editor')}
|
|
266
343
|
/>
|
|
267
344
|
)}
|
|
345
|
+
|
|
268
346
|
`;
|