rails-domternal 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +20 -0
- data/app/assets/javascripts/domternal/element.js +12 -0
- data/lib/rails/domternal/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a3fe5a247cff03bf6c637edeccc0d1401773dce754b72e284bd547ff5b7043c
|
|
4
|
+
data.tar.gz: 695395c691f38f150cd560dde279f18ee5238d9f68ddcfdd2c8a673c8adcf69f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80b0e8838e6b6ffbaae774c23c393521c9d6fa31ba64f4e3c6311580a49a0293155bd3192f16828bf9c23516b11437ab7d97672455b20ec98ba46790a9b77a2f
|
|
7
|
+
data.tar.gz: e3d28b7e185c1a95b28be8a5c0a81e037497c075e9d54bf5dac35c8c6522f6abf773a1f162cfa06de201ab19ca45eb3ca4f9acb5446282d70fe439e0c6c4596b
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 (2026-08-11)
|
|
4
|
+
|
|
5
|
+
- Expose the mounted ProseMirror instance through `<domternal-editor>.editor`.
|
|
6
|
+
- Expose the fixed toolbar through `<domternal-editor>.toolbar`.
|
|
7
|
+
- Document the custom element's public JavaScript API and deferred-mounting behavior.
|
data/README.md
CHANGED
|
@@ -52,6 +52,26 @@ Configure defaults in `config/initializers/domternal.rb` (generated by the insta
|
|
|
52
52
|
see `Rails::Domternal::Configuration` for the full list of options (default extensions,
|
|
53
53
|
toolbar, theme, sanitizer allowlist, upload limits).
|
|
54
54
|
|
|
55
|
+
### JavaScript API
|
|
56
|
+
|
|
57
|
+
`<domternal-editor>` exposes a small public API for integrations that need to coordinate
|
|
58
|
+
with the editor without depending on its internal implementation:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const element = document.querySelector("domternal-editor")
|
|
62
|
+
|
|
63
|
+
await element.ready() // Mounts a deferred editor and resolves with the element.
|
|
64
|
+
element.editor // The mounted ProseMirror editor, or null before mounting.
|
|
65
|
+
element.toolbar // The fixed toolbar, or null for :notion / toolbar: false.
|
|
66
|
+
element.value // The current HTML, including the server-rendered value before mounting.
|
|
67
|
+
element.input // The linked hidden input, or null when the input is missing.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Call `ready()` before using `editor` or `toolbar` when the editor may still be deferred.
|
|
71
|
+
The `domternal:initialize` event fires after the editor and configured toolbar have been
|
|
72
|
+
created. The `domternal:change` event fires after the linked input is updated; both events
|
|
73
|
+
bubble from the `<domternal-editor>` element.
|
|
74
|
+
|
|
55
75
|
`#to_plain_text` converts a body to text the way ActionText does: block boundaries and
|
|
56
76
|
`<br>` become newlines rather than collapsing into spaces, so line-oriented content (one
|
|
57
77
|
list entry or answer per line) survives, and search columns built from rich text stay
|
|
@@ -87,6 +87,18 @@ export class DomternalEditorElement extends HTMLElement {
|
|
|
87
87
|
return id ? document.getElementById(id) : null
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// Public access to the mounted ProseMirror editor. Returns null while the editor is
|
|
91
|
+
// deferred or mounting; call `await element.ready()` before using it when necessary.
|
|
92
|
+
get editor() {
|
|
93
|
+
return this._wrapper?.editor ?? null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Public access to the fixed toolbar, when one is configured. Notion-style and
|
|
97
|
+
// toolbar-less editors return null.
|
|
98
|
+
get toolbar() {
|
|
99
|
+
return this._toolbar ?? null
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
// The editor's current HTML. Falls back to the linked input while the editor is still
|
|
91
103
|
// deferred or mounting — an unmounted editor never touches the input, so the value the
|
|
92
104
|
// server rendered is still the right answer and submitting the form is always safe.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-domternal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stefan
|
|
@@ -32,6 +32,7 @@ executables: []
|
|
|
32
32
|
extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
|
34
34
|
files:
|
|
35
|
+
- CHANGELOG.md
|
|
35
36
|
- LICENSE.txt
|
|
36
37
|
- README.md
|
|
37
38
|
- Rakefile
|