@editora/ui-editor 0.1.7 → 0.1.8
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/README.md +114 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<h1 align="center">@editora/ui-editor</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
The editor-focused interface elements of Editora: a command palette, a floating toolbar, a context menu, a selection
|
|
5
|
+
popup, block controls and a plugin panel. <strong>They are provided by <code>@editora/ui-core</code></strong>; this package
|
|
6
|
+
re-exports older copies of their classes and registers no element.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@editora/ui-editor"><img src="https://img.shields.io/npm/v/@editora/ui-editor.svg" alt="npm version"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@editora/ui-editor"><img src="https://img.shields.io/npm/dm/@editora/ui-editor.svg" alt="npm downloads"></a>
|
|
12
|
+
<a href="https://github.com/ajaykr089/Editora/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@editora/ui-editor.svg" alt="license"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@editora/ui-editor"><img src="https://img.shields.io/npm/types/@editora/ui-editor.svg" alt="TypeScript types included"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://editora-ecosystem.netlify.app/">Website</a> ·
|
|
18
|
+
<a href="https://editora-ecosystem-storybook.netlify.app/">Storybook</a> ·
|
|
19
|
+
<a href="https://github.com/ajaykr089/Editora">GitHub</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/ui-editor/docs/images/command-palette.png" alt="The ui-command-palette element open over a page: a search box reading Type a command and three commands under it, Insert table, Toggle bold and Clear formatting, the first one highlighted" width="700">
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
> **Use [`@editora/ui-core`](https://www.npmjs.com/package/@editora/ui-core).** The six elements below are defined and
|
|
27
|
+
> maintained there, and wrapped for React by [`@editora/ui-react`](https://www.npmjs.com/package/@editora/ui-react).
|
|
28
|
+
> Installing `@editora/ui-editor` does not add them and does not change them: the page is the same with it and without it.
|
|
29
|
+
|
|
30
|
+
## The elements
|
|
31
|
+
|
|
32
|
+
| Element | What it is | React component |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `<ui-command-palette>` | A modal search box over a list of commands, driven by the keyboard. | `CommandPalette` |
|
|
35
|
+
| `<ui-floating-toolbar>` | A toolbar that opens next to an anchor element, and closes on Escape or an outside click. | `FloatingToolbar` |
|
|
36
|
+
| `<ui-context-menu>` | A menu that opens on right-click, with typeahead. | `ContextMenu` |
|
|
37
|
+
| `<ui-selection-popup>` | A popup that opens next to an anchor element, with an optional arrow. | `SelectionPopup` |
|
|
38
|
+
| `<ui-block-controls>` | A group of controls for one block of content, moved between with the arrow keys. | `BlockControls` |
|
|
39
|
+
| `<ui-plugin-panel>` | A titled panel docked to the right, left or bottom of the page, which can be dismissed. | `PluginPanel` |
|
|
40
|
+
|
|
41
|
+
The React components are in [`@editora/ui-react`](https://www.npmjs.com/package/@editora/ui-react), and the options of every
|
|
42
|
+
element are in [`@editora/ui-core`](https://www.npmjs.com/package/@editora/ui-core).
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
Install `@editora/ui-core`, and use the elements as HTML. A command palette is a list of your own buttons with
|
|
47
|
+
`slot="command"`: open it with `openPalette()`, and listen for `select`.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @editora/ui-core
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<script type="importmap">
|
|
55
|
+
{
|
|
56
|
+
"imports": {
|
|
57
|
+
"@editora/ui-core": "https://cdn.jsdelivr.net/npm/@editora/ui-core/dist/index.esm.js",
|
|
58
|
+
"@editora/icons": "https://cdn.jsdelivr.net/npm/@editora/icons/dist/index.esm.js"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
<script type="module">
|
|
63
|
+
import '@editora/ui-core';
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
/* The commands are your own buttons, so you style them. The palette marks the one the arrow keys are on. */
|
|
68
|
+
ui-command-palette button { display: block; width: 100%; margin: 0; padding: 10px 14px; border: 0; border-radius: 6px; background: transparent; color: #24292f; font: 15px system-ui, sans-serif; text-align: left; cursor: pointer; }
|
|
69
|
+
ui-command-palette button[data-active='true'] { background: #dbeafe; }
|
|
70
|
+
</style>
|
|
71
|
+
|
|
72
|
+
<button id="open" type="button">Open the command palette</button>
|
|
73
|
+
<p id="status">Nothing run yet</p>
|
|
74
|
+
|
|
75
|
+
<ui-command-palette id="palette" placeholder="Type a command...">
|
|
76
|
+
<button slot="command">Insert table</button>
|
|
77
|
+
<button slot="command">Toggle bold</button>
|
|
78
|
+
<button slot="command">Clear formatting</button>
|
|
79
|
+
</ui-command-palette>
|
|
80
|
+
|
|
81
|
+
<script type="module">
|
|
82
|
+
const palette = document.getElementById('palette');
|
|
83
|
+
|
|
84
|
+
document.getElementById('open').addEventListener('click', () => palette.openPalette());
|
|
85
|
+
|
|
86
|
+
// The palette filters as you type, moves with the arrow keys, runs a command on Enter and closes on Escape.
|
|
87
|
+
palette.addEventListener('select', (event) => {
|
|
88
|
+
document.getElementById('status').textContent = `Ran: ${event.detail.label}`;
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## What this package contains
|
|
94
|
+
|
|
95
|
+
It exports six classes: `UIFloatingToolbar`, `UICommandPalette`, `UIContextMenu`, `UIPluginPanel`, `UIBlockControls` and
|
|
96
|
+
`UISelectionPopup`. They are earlier, simpler versions of the elements in `@editora/ui-core`, and each module defines its
|
|
97
|
+
tag only if the tag is still free (`if (!customElements.get(tag))`).
|
|
98
|
+
|
|
99
|
+
It never is: `@editora/ui-editor` imports `@editora/ui-core` first, and that defines all six tags. Loading this package
|
|
100
|
+
therefore registers nothing, and `customElements.get('ui-command-palette')` is the element of `@editora/ui-core`, not the
|
|
101
|
+
class of this package. If you want to extend one of the elements, import its class from `@editora/ui-core`, which exports
|
|
102
|
+
the same names.
|
|
103
|
+
|
|
104
|
+
## Install
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install @editora/ui-editor
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
It depends on `@editora/ui-core` (and lists it as a peer dependency), so that is installed with it.
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT © [Ajay Kumar](https://github.com/ajaykr089)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/ui-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Editor-focused UI extensions for Editora (floating toolbar, command palette, context menus)",
|
|
5
5
|
"author": "Ajay Kumar <ajaykr089@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"prepare": "npm run build"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@editora/ui-core": "^0.1.
|
|
29
|
+
"@editora/ui-core": "^0.1.23"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@editora/ui-core": "^0.1.
|
|
32
|
+
"@editora/ui-core": "^0.1.23"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^5.0.0",
|