planet-editor 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 +24 -0
- package/README.md +129 -0
- package/THIRD-PARTY-LICENSES.md +76 -0
- package/dist/lib/components/planet-extension/node-background-extension.d.ts +23 -0
- package/dist/lib/components/planet-extension/search-extension.d.ts +39 -0
- package/dist/lib/components/planet-icons/align-center-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/align-justify-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/align-left-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/align-right-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/arrow-left-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/ban-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/blockquote-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/bold-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/check-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/chevron-down-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/close-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/code-block-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/code2-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/corner-down-left-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/external-link-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-five-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-four-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-one-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-six-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-three-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-two-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/highlighter-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/image-plus-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/italic-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/line-numbers-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/link-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/list-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/list-ordered-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/list-todo-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/moon-star-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/redo2-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/search-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/strike-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/subscript-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/sun-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/superscript-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/table-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/trash-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/underline-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/undo2-icon.d.ts +3 -0
- package/dist/lib/components/planet-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +2 -0
- package/dist/lib/components/planet-node/image-node/resizable-image-extension.d.ts +10 -0
- package/dist/lib/components/planet-node/image-node/resizable-image-node-view.d.ts +7 -0
- package/dist/lib/components/planet-node/image-upload-node/image-upload-node-extension.d.ts +58 -0
- package/dist/lib/components/planet-node/image-upload-node/image-upload-node.d.ts +68 -0
- package/dist/lib/components/planet-node/image-upload-node/index.d.ts +1 -0
- package/dist/lib/components/planet-templates/simple/data/content.json.d.ts +479 -0
- package/dist/lib/components/planet-templates/simple/simple-editor.d.ts +31 -0
- package/dist/lib/components/planet-templates/simple/theme-toggle.d.ts +1 -0
- package/dist/lib/components/planet-ui/blockquote-button/blockquote-button.d.ts +22 -0
- package/dist/lib/components/planet-ui/blockquote-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/blockquote-button/use-blockquote.d.ts +80 -0
- package/dist/lib/components/planet-ui/code-block-button/code-block-button.d.ts +22 -0
- package/dist/lib/components/planet-ui/code-block-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/code-block-button/use-code-block.d.ts +87 -0
- package/dist/lib/components/planet-ui/color-highlight-button/color-highlight-button.d.ts +45 -0
- package/dist/lib/components/planet-ui/color-highlight-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/color-highlight-button/use-color-highlight.d.ts +93 -0
- package/dist/lib/components/planet-ui/color-highlight-popover/color-highlight-popover.d.ts +35 -0
- package/dist/lib/components/planet-ui/color-highlight-popover/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/font-size-dropdown-menu/font-size-dropdown-menu.d.ts +10 -0
- package/dist/lib/components/planet-ui/font-size-dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/heading-button/heading-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/heading-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/heading-button/use-heading.d.ts +108 -0
- package/dist/lib/components/planet-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +19 -0
- package/dist/lib/components/planet-ui/heading-dropdown-menu/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +73 -0
- package/dist/lib/components/planet-ui/image-upload-button/image-upload-button.d.ts +29 -0
- package/dist/lib/components/planet-ui/image-upload-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/image-upload-button/use-image-upload.d.ts +84 -0
- package/dist/lib/components/planet-ui/link-popover/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/link-popover/link-popover.d.ts +57 -0
- package/dist/lib/components/planet-ui/link-popover/use-link-popover.d.ts +117 -0
- package/dist/lib/components/planet-ui/list-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/list-button/list-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/list-button/use-list.d.ts +97 -0
- package/dist/lib/components/planet-ui/list-dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/list-dropdown-menu/list-dropdown-menu.d.ts +28 -0
- package/dist/lib/components/planet-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +90 -0
- package/dist/lib/components/planet-ui/mark-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/mark-button/mark-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/mark-button/use-mark.d.ts +104 -0
- package/dist/lib/components/planet-ui/search-bar/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/search-bar/search-bar.d.ts +11 -0
- package/dist/lib/components/planet-ui/table-dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/table-dropdown-menu/table-dropdown-menu.d.ts +11 -0
- package/dist/lib/components/planet-ui/text-align-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/text-align-button/text-align-button.d.ts +30 -0
- package/dist/lib/components/planet-ui/text-align-button/use-text-align.d.ts +101 -0
- package/dist/lib/components/planet-ui/undo-redo-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/undo-redo-button/undo-redo-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/undo-redo-button/use-undo-redo.d.ts +90 -0
- package/dist/lib/components/planet-ui-primitive/badge/badge.d.ts +8 -0
- package/dist/lib/components/planet-ui-primitive/badge/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/button/button.d.ts +14 -0
- package/dist/lib/components/planet-ui-primitive/button/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/button-group/button-group.d.ts +10 -0
- package/dist/lib/components/planet-ui-primitive/button-group/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/card/card.d.ts +9 -0
- package/dist/lib/components/planet-ui-primitive/card/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/dropdown-menu/dropdown-menu.d.ts +28 -0
- package/dist/lib/components/planet-ui-primitive/dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/input/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/input/input.d.ts +2 -0
- package/dist/lib/components/planet-ui-primitive/popover/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/popover/popover.d.ts +5 -0
- package/dist/lib/components/planet-ui-primitive/separator/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/separator/separator.d.ts +5 -0
- package/dist/lib/components/planet-ui-primitive/spacer/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/spacer/spacer.d.ts +5 -0
- package/dist/lib/components/planet-ui-primitive/toolbar/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/toolbar/toolbar.d.ts +8 -0
- package/dist/lib/components/planet-ui-primitive/tooltip/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/tooltip/tooltip.d.ts +28 -0
- package/dist/lib/favicon.svg +1 -0
- package/dist/lib/hooks/use-composed-ref.d.ts +3 -0
- package/dist/lib/hooks/use-cursor-visibility.d.ts +20 -0
- package/dist/lib/hooks/use-element-rect.d.ts +35 -0
- package/dist/lib/hooks/use-is-breakpoint.d.ts +9 -0
- package/dist/lib/hooks/use-line-numbers.d.ts +15 -0
- package/dist/lib/hooks/use-menu-navigation.d.ts +52 -0
- package/dist/lib/hooks/use-planet-editor.d.ts +6 -0
- package/dist/lib/hooks/use-scrolling.d.ts +8 -0
- package/dist/lib/hooks/use-throttled-callback.d.ts +18 -0
- package/dist/lib/hooks/use-unmount.d.ts +7 -0
- package/dist/lib/hooks/use-window-size.d.ts +35 -0
- package/dist/lib/icons.svg +24 -0
- package/dist/lib/images/planet-ui-placeholder-image.svg +10 -0
- package/dist/lib/index.js +5102 -0
- package/dist/lib/lib/index.d.ts +2 -0
- package/dist/lib/lib/planet-utils.d.ts +173 -0
- package/dist/lib/lib/upload.d.ts +10 -0
- package/dist/lib/styles.css +2 -0
- package/dist/web-component/favicon.svg +1 -0
- package/dist/web-component/icons.svg +24 -0
- package/dist/web-component/images/planet-ui-placeholder-image.svg +10 -0
- package/dist/web-component/planet-editor.css +2 -0
- package/dist/web-component/planet-editor.html +224 -0
- package/dist/web-component/planet-editor.js +203 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Umar @umarzahid
|
|
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
|
+
This product includes third-party open-source software. See
|
|
16
|
+
THIRD-PARTY-LICENSES.md for the required notices.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# planet-editor
|
|
2
|
+
|
|
3
|
+
A batteries-included [Planet](https://planet.dev) rich-text editor that works in **React**, **Next.js**, and **standalone HTML** — with a ready-made toolbar, font sizing, tables, and resizable images with captions. No backend required (images embed as base64 by default).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Find-in-document search (toolbar button or ⌘F / Ctrl+F) with match count + next/prev
|
|
8
|
+
- Bold / italic / underline / strike, headings, lists, task lists, blockquotes, code blocks
|
|
9
|
+
- Font-size dropdown (presets + custom px) and text alignment
|
|
10
|
+
- Tables (insert, add/remove rows & columns, merge/split, header toggles)
|
|
11
|
+
- Resizable images with editable captions
|
|
12
|
+
- Link popover, highlight colors, sub/superscript
|
|
13
|
+
- Light/dark mode, mobile toolbar, keyboard shortcuts
|
|
14
|
+
- SSR-safe (renders cleanly in Next.js App Router)
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install planet-editor
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`react` and `react-dom` (v18 or v19) are peer dependencies — your app provides them.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 1. React
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Editor } from "planet-editor"
|
|
30
|
+
import "planet-editor/styles.css"
|
|
31
|
+
|
|
32
|
+
export default function App() {
|
|
33
|
+
return (
|
|
34
|
+
<Editor
|
|
35
|
+
content="<p>Hello world</p>"
|
|
36
|
+
editable
|
|
37
|
+
onChange={({ html, json }) => console.log(html, json)}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 2. Next.js (App Router)
|
|
44
|
+
|
|
45
|
+
The editor is a client component. Import it from a client component or disable SSR:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
"use client"
|
|
49
|
+
|
|
50
|
+
import { Editor } from "planet-editor"
|
|
51
|
+
import "planet-editor/styles.css"
|
|
52
|
+
|
|
53
|
+
export default function EditorPage() {
|
|
54
|
+
return <Editor content="<p>Start writing…</p>" onChange={({ html }) => save(html)} />
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> Import `planet-editor/styles.css` once (e.g. in `app/layout.tsx` or the page).
|
|
59
|
+
|
|
60
|
+
## 3. Standalone HTML (no build step)
|
|
61
|
+
|
|
62
|
+
Drop in the web component from a CDN — it registers a `<planet-editor>` element:
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<link rel="stylesheet" href="https://unpkg.com/planet-editor/dist/web-component/planet-editor.css" />
|
|
66
|
+
<script src="https://unpkg.com/planet-editor/dist/web-component/planet-editor.js"></script>
|
|
67
|
+
|
|
68
|
+
<planet-editor content="<p>Hello</p>"></planet-editor>
|
|
69
|
+
|
|
70
|
+
<script>
|
|
71
|
+
document
|
|
72
|
+
.querySelector("planet-editor")
|
|
73
|
+
.addEventListener("change", (e) => console.log(e.detail.html, e.detail.json))
|
|
74
|
+
</script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Attributes: `content` (initial HTML), `editable` (`"false"` for read-only), `line-numbers` (present = on). Event: `change` → `{ html, json }`.
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<planet-editor line-numbers content="<p>Numbered</p>"></planet-editor>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Prefer **one self-contained file**? Run `npm run build:standalone` to generate
|
|
84
|
+
`dist/web-component/planet-editor.html` — JS and CSS inlined, no external files,
|
|
85
|
+
no iframe. Open it directly, host it anywhere, or embed its markup in any page.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Props (React / Next.js)
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Default | Description |
|
|
92
|
+
|------|------|---------|-------------|
|
|
93
|
+
| `content` | `string \| object` | demo content | Initial HTML string or Planet JSON |
|
|
94
|
+
| `editable` | `boolean` | `true` | Read-only when `false` |
|
|
95
|
+
| `onChange` | `({ html, json }) => void` | — | Fires on every change |
|
|
96
|
+
| `uploadImage` | `(file, onProgress?, signal?) => Promise<string>` | base64 | Upload handler; return the stored image URL |
|
|
97
|
+
| `lineNumbers` | `boolean` | `false` | Show a line-number gutter numbering each top-level block |
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<Editor lineNumbers /> {/* start with the line-number gutter on */}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The `lineNumbers` prop sets the **initial** state. Users can also toggle line
|
|
104
|
+
numbers on/off at any time with the line-numbers button in the toolbar. Every
|
|
105
|
+
visual row is numbered (wrapped lines included).
|
|
106
|
+
|
|
107
|
+
### Uploading images to a backend
|
|
108
|
+
|
|
109
|
+
By default images are embedded as base64 data URLs (no network). To store them on a server, pass `uploadImage`:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { Editor } from "planet-editor"
|
|
113
|
+
|
|
114
|
+
<Editor
|
|
115
|
+
uploadImage={async (file) => {
|
|
116
|
+
const body = new FormData()
|
|
117
|
+
body.append("file", file)
|
|
118
|
+
const res = await fetch("/api/upload", { method: "POST", body })
|
|
119
|
+
const { url } = await res.json()
|
|
120
|
+
return url
|
|
121
|
+
}}
|
|
122
|
+
/>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`base64Upload` (the default handler) is also exported if you want to compose with it.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Third-Party Licenses
|
|
2
|
+
|
|
3
|
+
Planet Editor is built on top of open-source software. Their license notices are
|
|
4
|
+
reproduced below as required by their respective licenses. The editor engine is
|
|
5
|
+
accessed internally through `src/planet-core/` (see that directory).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Tiptap
|
|
10
|
+
|
|
11
|
+
Planet Editor's rich-text engine is based on Tiptap (https://tiptap.dev),
|
|
12
|
+
including `@tiptap/core`, `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit`,
|
|
13
|
+
and the `@tiptap/extension-*` packages.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
MIT License
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
19
|
+
|
|
20
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
21
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
22
|
+
in the Software without restriction, including without limitation the rights
|
|
23
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
24
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
25
|
+
furnished to do so, subject to the following conditions:
|
|
26
|
+
|
|
27
|
+
The above copyright notice and this permission notice shall be included in all
|
|
28
|
+
copies or substantial portions of the Software.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
33
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
34
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
35
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
36
|
+
SOFTWARE.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## ProseMirror
|
|
42
|
+
|
|
43
|
+
Tiptap is built on ProseMirror (https://prosemirror.net), which is bundled via
|
|
44
|
+
`@tiptap/pm` (`prosemirror-state`, `prosemirror-view`, `prosemirror-model`,
|
|
45
|
+
`prosemirror-transform`, `prosemirror-commands`, and related packages).
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
Copyright (C) 2015-2017 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
49
|
+
|
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
51
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
52
|
+
in the Software without restriction, including without limitation the rights
|
|
53
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
54
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
55
|
+
furnished to do so, subject to the following conditions:
|
|
56
|
+
|
|
57
|
+
The above copyright notice and this permission notice shall be included in
|
|
58
|
+
all copies or substantial portions of the Software.
|
|
59
|
+
|
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
61
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
62
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
63
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
64
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
65
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
66
|
+
THE SOFTWARE.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Other dependencies
|
|
72
|
+
|
|
73
|
+
Planet Editor also depends on other MIT-licensed packages, including
|
|
74
|
+
`@floating-ui/react`, `@radix-ui/*`, `react-hotkeys-hook`, `clsx`,
|
|
75
|
+
`class-variance-authority`, and `lodash.throttle`. Their full license texts are
|
|
76
|
+
available in each package's directory under `node_modules`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Extension } from '../../planet-core/core';
|
|
2
|
+
declare module '../../planet-core/core' {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
nodeBackground: {
|
|
5
|
+
setNodeBackgroundColor: (backgroundColor: string) => ReturnType;
|
|
6
|
+
unsetNodeBackgroundColor: () => ReturnType;
|
|
7
|
+
toggleNodeBackgroundColor: (backgroundColor: string) => ReturnType;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export interface NodeBackgroundOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Node types that should support background colors
|
|
14
|
+
* @default ["paragraph", "heading", "blockquote", "taskList", "bulletList", "orderedList", "tableCell", "tableHeader"]
|
|
15
|
+
*/
|
|
16
|
+
types: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Use inline style instead of data attribute
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
useStyle?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const NodeBackground: Extension<NodeBackgroundOptions, any>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Extension } from '../../planet-core/core';
|
|
2
|
+
import { PluginKey } from '../../planet-core/pm/state';
|
|
3
|
+
import { DecorationSet } from '../../planet-core/pm/view';
|
|
4
|
+
/**
|
|
5
|
+
* Planet Search — find-in-document for the editor.
|
|
6
|
+
*
|
|
7
|
+
* A ProseMirror plugin that finds all occurrences of a search term, highlights
|
|
8
|
+
* them with decorations (with a distinct style for the active match), and
|
|
9
|
+
* exposes commands to navigate between matches. Pure client-side, no network.
|
|
10
|
+
*/
|
|
11
|
+
export interface SearchMatch {
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SearchPluginState {
|
|
16
|
+
searchTerm: string;
|
|
17
|
+
caseSensitive: boolean;
|
|
18
|
+
matches: SearchMatch[];
|
|
19
|
+
currentIndex: number;
|
|
20
|
+
decorations: DecorationSet;
|
|
21
|
+
}
|
|
22
|
+
export declare const searchPluginKey: PluginKey<SearchPluginState>;
|
|
23
|
+
declare module "@tiptap/core" {
|
|
24
|
+
interface Commands<ReturnType> {
|
|
25
|
+
planetSearch: {
|
|
26
|
+
/** Set the search term (and reset to the first match). */
|
|
27
|
+
setSearchTerm: (term: string) => ReturnType;
|
|
28
|
+
/** Toggle case-sensitive matching. */
|
|
29
|
+
setSearchCaseSensitive: (value: boolean) => ReturnType;
|
|
30
|
+
/** Move to the next match (wraps around). */
|
|
31
|
+
nextSearchMatch: () => ReturnType;
|
|
32
|
+
/** Move to the previous match (wraps around). */
|
|
33
|
+
previousSearchMatch: () => ReturnType;
|
|
34
|
+
/** Clear the search and remove all highlights. */
|
|
35
|
+
clearSearch: () => ReturnType;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export declare const SearchExtension: Extension<any, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ImageOptions } from '../../../planet-core/extension-image';
|
|
2
|
+
/**
|
|
3
|
+
* The default Image extension with:
|
|
4
|
+
* - base64 (data URL) sources allowed (our demo uploads embed data URLs)
|
|
5
|
+
* - a `width` attribute that survives round-trips (for resizing)
|
|
6
|
+
* - a `caption` attribute, rendered as a <figcaption>
|
|
7
|
+
* - a React node view providing a drag-to-resize handle + editable caption
|
|
8
|
+
*/
|
|
9
|
+
export declare const ResizableImage: import('@tiptap/core').Node<ImageOptions, any>;
|
|
10
|
+
export default ResizableImage;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NodeViewProps } from '../../../planet-core/react';
|
|
2
|
+
/**
|
|
3
|
+
* Node view for the image node: renders the image with a bottom-right resize
|
|
4
|
+
* handle (drag to shrink/grow, aspect ratio preserved) and an editable caption
|
|
5
|
+
* underneath.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ResizableImageNodeView({ node, updateAttributes, selected, editor, }: NodeViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Node } from '../../../planet-core/react';
|
|
2
|
+
import { NodeType } from '../../../planet-core/pm/model';
|
|
3
|
+
export type UploadFunction = (file: File, onProgress?: (event: {
|
|
4
|
+
progress: number;
|
|
5
|
+
}) => void, abortSignal?: AbortSignal) => Promise<string>;
|
|
6
|
+
export interface ImageUploadNodeOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The type of the node.
|
|
9
|
+
* @default 'image'
|
|
10
|
+
*/
|
|
11
|
+
type?: string | NodeType | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Acceptable file types for upload.
|
|
14
|
+
* @default 'image/*'
|
|
15
|
+
*/
|
|
16
|
+
accept?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of files that can be uploaded.
|
|
19
|
+
* @default 1
|
|
20
|
+
*/
|
|
21
|
+
limit?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum file size in bytes (0 for unlimited).
|
|
24
|
+
* @default 0
|
|
25
|
+
*/
|
|
26
|
+
maxSize?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Function to handle the upload process.
|
|
29
|
+
*/
|
|
30
|
+
upload?: UploadFunction;
|
|
31
|
+
/**
|
|
32
|
+
* Callback for upload errors.
|
|
33
|
+
*/
|
|
34
|
+
onError?: (error: Error) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Callback for successful uploads.
|
|
37
|
+
*/
|
|
38
|
+
onSuccess?: (url: string) => void;
|
|
39
|
+
/**
|
|
40
|
+
* HTML attributes to add to the image element.
|
|
41
|
+
* @default {}
|
|
42
|
+
* @example { class: 'foo' }
|
|
43
|
+
*/
|
|
44
|
+
HTMLAttributes: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
declare module '../../../planet-core/react' {
|
|
47
|
+
interface Commands<ReturnType> {
|
|
48
|
+
imageUpload: {
|
|
49
|
+
setImageUploadNode: (options?: ImageUploadNodeOptions) => ReturnType;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A Planet node extension that creates an image upload component.
|
|
55
|
+
* @see registry/planet-node/image-upload-node/image-upload-node
|
|
56
|
+
*/
|
|
57
|
+
export declare const ImageUploadNode: Node<ImageUploadNodeOptions, any>;
|
|
58
|
+
export default ImageUploadNode;
|