@blockslides/extension-bubble-menu-preset 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/LICENSE.md +36 -0
- package/README.md +74 -0
- package/dist/index.cjs +701 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +676 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
- package/src/bubble-menu-preset.ts +809 -0
- package/src/index.ts +3 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 BlockSlides
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Acknowledgments
|
|
26
|
+
|
|
27
|
+
This project includes code and patterns adapted from [Tiptap](https://tiptap.dev),
|
|
28
|
+
an open-source headless editor framework for web artisans.
|
|
29
|
+
|
|
30
|
+
**Tiptap License:**
|
|
31
|
+
|
|
32
|
+
- Copyright (c) 2025, Tiptap GmbH
|
|
33
|
+
- Licensed under MIT License
|
|
34
|
+
- Original source: https://github.com/ueberdosis/tiptap
|
|
35
|
+
|
|
36
|
+
See `_tiptap/LICENSE.md` for the full Tiptap license.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# BubbleMenuPreset
|
|
2
|
+
|
|
3
|
+
Opinionated bubble menu with built-in actions (undo/redo, font family/size, bold, italic, underline, text color, highlight color, link, align) on top of `@blockslides/extension-bubble-menu`. Provides a ready-to-use menu element, palettes, and sensible defaults.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @blockslides/extension-bubble-menu-preset
|
|
9
|
+
# pnpm add @blockslides/extension-bubble-menu-preset
|
|
10
|
+
# yarn add @blockslides/extension-bubble-menu-preset
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer deps you’ll typically also want loaded:
|
|
14
|
+
- `@blockslides/extensions/undo-redo`
|
|
15
|
+
- `@blockslides/extension-text-style` (color, fontFamily, fontSize)
|
|
16
|
+
- `@blockslides/extension-highlight` (with `multicolor: true` for per-color)
|
|
17
|
+
- `@blockslides/extension-link`
|
|
18
|
+
- `@blockslides/extension-text-align`
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import BubbleMenuPreset from '@blockslides/extension-bubble-menu-preset'
|
|
24
|
+
import { UndoRedo } from '@blockslides/extensions/undo-redo'
|
|
25
|
+
import { Highlight } from '@blockslides/extension-highlight'
|
|
26
|
+
import { Color, FontFamily, FontSize } from '@blockslides/extension-text-style'
|
|
27
|
+
import { Link } from '@blockslides/extension-link'
|
|
28
|
+
import { TextAlign } from '@blockslides/extension-text-align'
|
|
29
|
+
|
|
30
|
+
new Editor({
|
|
31
|
+
extensions: [
|
|
32
|
+
UndoRedo,
|
|
33
|
+
Color,
|
|
34
|
+
FontFamily,
|
|
35
|
+
FontSize,
|
|
36
|
+
Highlight.configure({ multicolor: true }),
|
|
37
|
+
Link,
|
|
38
|
+
TextAlign.configure({ types: ['paragraph', 'heading'] }),
|
|
39
|
+
BubbleMenuPreset.configure({
|
|
40
|
+
// items is optional; defaults to the full preset shown below.
|
|
41
|
+
// items: [
|
|
42
|
+
// 'undo','redo',
|
|
43
|
+
// 'fontFamily','fontSize',
|
|
44
|
+
// 'bold','italic','underline',
|
|
45
|
+
// 'textColor','highlightColor',
|
|
46
|
+
// 'link','align',
|
|
47
|
+
// ],
|
|
48
|
+
// optional overrides:
|
|
49
|
+
// textColors, highlightColors, fonts, fontSizes, alignments,
|
|
50
|
+
// className, injectStyles, options (placement/offset/flip...), shouldShow, appendTo
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## What you get
|
|
57
|
+
- Built-in controls with sensible defaults and hover states; white background, ~20% radius.
|
|
58
|
+
- Swatch grids for text and highlight colors + “None” + custom color input; auto-repositions via `setMeta('bubbleMenu','updatePosition')`.
|
|
59
|
+
- Disables buttons if commands are absent. If you pass your own `element`, the preset won’t inject its own.
|
|
60
|
+
|
|
61
|
+
## Options (overrides)
|
|
62
|
+
- `items`: order of built-ins. Defaults: `['undo','redo','fontFamily','fontSize','bold','italic','underline','textColor','highlightColor','link','align']`.
|
|
63
|
+
- `textColors`, `highlightColors`: palettes (arrays of strings).
|
|
64
|
+
- `fonts`, `fontSizes`, `alignments`: dropdown choices.
|
|
65
|
+
- `className`: extra class on the root element.
|
|
66
|
+
- `injectStyles`: set `false` to provide your own styles.
|
|
67
|
+
- `options`: forwarded to Floating UI via `@blockslides/extension-bubble-menu` (`placement`, `strategy`, `offset`, `flip`, `shift`, etc.).
|
|
68
|
+
- `shouldShow`, `appendTo`, `pluginKey`, `updateDelay`, `resizeDelay`, `getReferencedVirtualElement`: same semantics as the base bubble menu.
|
|
69
|
+
|
|
70
|
+
## Notes
|
|
71
|
+
- Highlight color requires `Highlight.configure({ multicolor: true })` to respect per-color values.
|
|
72
|
+
- Link prompt is simple; replace with your own UI by supplying a custom `element` or swapping the handler.
|
|
73
|
+
- If the menu size changes (e.g., palette open/close), the preset emits `setMeta('bubbleMenu','updatePosition')` to keep positioning correct.
|
|
74
|
+
|