@aglyn/aglyn-markdown-editor 1.0.0-beta.143 → 1.0.0-beta.145
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 +70 -23
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,34 +1,81 @@
|
|
|
1
1
|
# @aglyn/aglyn-markdown-editor
|
|
2
2
|
|
|
3
3
|
The markdown-lite WYSIWYG editor: visual surface, toolbar, source/visual
|
|
4
|
-
toggle, HTML
|
|
4
|
+
toggle, HTML-to-markdown paste, link dialog, and the read-only view. It is the
|
|
5
|
+
editor the Aglyn console uses for content, and the one `@aglyn/besigner-ui`
|
|
6
|
+
uses for a Markdown component's `content` attribute. Install it on its own if
|
|
7
|
+
you need to edit or preview Aglyn's markdown-lite dialect in a React and MUI
|
|
8
|
+
app; most consumers get it as a dependency of `@aglyn/besigner-ui`.
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
the marketplace listing editor. The besigner attributes panel needs the same
|
|
8
|
-
editor for the Markdown component's `content` attribute, and the designer
|
|
9
|
-
(`libs/besigner/feature/designer`) is a lib — a lib cannot import an app, so
|
|
10
|
-
the editor moved here (AGL-1616).
|
|
10
|
+
> Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Install
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
(`scope:aglyn`). The `scope:shared` constraint is
|
|
16
|
-
`onlyDependOnLibsWithTags: ['scope:shared']`, so a shared-UI home would have
|
|
17
|
-
had to re-implement the dialect — the wall AGL-1558 hit and correctly refused
|
|
18
|
-
to climb.
|
|
14
|
+
npm install @aglyn/aglyn-markdown-editor@beta
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
already exists, with no change to `eslint.config.mjs`:
|
|
16
|
+
Peer dependencies:
|
|
22
17
|
|
|
23
|
-
- `
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
carries `scope:data`.
|
|
18
|
+
- `react`
|
|
19
|
+
- `@mui/material`
|
|
20
|
+
- `@mui/icons-material`
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
from `aglyn:addons`) and `besigner-feature-designer`, whose `scope:feature`
|
|
30
|
-
constraint admits a `scope:ui` target.
|
|
22
|
+
## What's in it
|
|
31
23
|
|
|
32
|
-
|
|
24
|
+
Components:
|
|
33
25
|
|
|
34
|
-
`
|
|
26
|
+
- `MarkdownField` is the complete field: a label, the toolbar, the visual
|
|
27
|
+
editor and a raw-source mode, driven by `value` and `onChange`. It takes an
|
|
28
|
+
optional `onPickImageFromMedia` callback so the caller can supply its own
|
|
29
|
+
media picker, and an `editorRef` that hands back a `MarkdownFieldHandle` for
|
|
30
|
+
inserting a picked image.
|
|
31
|
+
- `MarkdownVisualEditor` is the visual editing surface by itself, and
|
|
32
|
+
`MarkdownEditorToolbar` is its toolbar, for callers that lay the pieces out
|
|
33
|
+
themselves.
|
|
34
|
+
- `MarkdownLinkDialog` and `LinkTargetAutocomplete` are the link controls. The
|
|
35
|
+
autocomplete offers the targets the caller passes in, and searches entries
|
|
36
|
+
when the core's link-target search context is mounted.
|
|
37
|
+
- `MarkdownLiteView` renders markdown-lite `source` read-only.
|
|
38
|
+
|
|
39
|
+
Functions:
|
|
40
|
+
|
|
41
|
+
- `markdownToRows`, `rowsToMarkdown` and `readInlinesFromElement` convert
|
|
42
|
+
between markdown-lite source and the editor's row model.
|
|
43
|
+
- `htmlToRows` and `htmlToInlines` convert pasted HTML.
|
|
44
|
+
- `applyCommandToSource` and `applyLinkToSource` apply a toolbar command to a
|
|
45
|
+
raw-source selection.
|
|
46
|
+
|
|
47
|
+
The markdown-lite dialect itself (its parser and serializer) lives in
|
|
48
|
+
`@aglyn/aglyn`, not here. This package is the UI over it.
|
|
49
|
+
|
|
50
|
+
Every file under `src/lib` is also reachable by subpath, for example
|
|
51
|
+
`@aglyn/aglyn-markdown-editor/markdown-lite-view.component`.
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { MarkdownField, MarkdownLiteView } from '@aglyn/aglyn-markdown-editor'
|
|
57
|
+
import { useState } from 'react'
|
|
58
|
+
|
|
59
|
+
export function BodyEditor() {
|
|
60
|
+
const [body, setBody] = useState('')
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<MarkdownField label="Body" value={body} onChange={setBody} />
|
|
64
|
+
<MarkdownLiteView source={body} />
|
|
65
|
+
</>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## How it fits
|
|
71
|
+
|
|
72
|
+
This package sits in the `core` scope of the package map as its UI piece: it
|
|
73
|
+
imports only `@aglyn/aglyn`, because the editor speaks the markdown-lite
|
|
74
|
+
dialect the core defines. That is also why it is not one of the generic
|
|
75
|
+
`@aglyn/shared-*` packages, which may not know Aglyn's model. It is a library
|
|
76
|
+
rather than part of an app because both the console and the designer UI need
|
|
77
|
+
the same editor. It imports no plugin and no other UI package.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/aglyn-markdown-editor
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/aglyn-markdown-editor",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.145",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.145",
|
|
29
29
|
"@swc/helpers": "0.5.23"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|