activeadmin_mitosis_editor 0.1.12 → 0.1.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca2e10a9137746e33548aaa5f457f9b48217e999414c8ff5f9c0e73002e21387
4
- data.tar.gz: d6aeafeae87972ce5302ae89957c8398d6e55a0dc2d46d188e5a5a1f37f11f8c
3
+ metadata.gz: 4df996e893b8484e76bd01f34ac7ef38a328a4867fe4e2e3bfef0ed51dd7045a
4
+ data.tar.gz: 77bdc7bed72bd009fa70bcfe09e476e3b54abd8f4b01d22a3955b96750a45454
5
5
  SHA512:
6
- metadata.gz: 3126619b7ba98ae09c759dceeade708c5ef4471677fab255a3addfeaaf76a5c8b262369e77f52d39efe13a0a6075e075cab2c10d34cc4abc7f2657b9ffdd7e0b
7
- data.tar.gz: f848b053fccec0b538c570a61052a9077ce183eb1f2794bf38a0da599e026e9a5163cdd31ab5a69616dc4dcdbd8556fa3638bdfaef2cb12d4ac34e88ecd529d8
6
+ metadata.gz: df9523f738f98dd3f6fd26b1c160f136c5e41066e101913758689ec7bb5150552bdfa730c1859e77d980c131d27a0e15d9c8501bb1fef9d3a46a7d7ec0e38ff8
7
+ data.tar.gz: fbf4234fd9ea870c798b83d56fd0d24f05866e83288195845404f22c70b3cf15a88e6478def5ae6a94b979cb92f196b003fb356e545b01597bb387f039c20ccf
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.14](https://github.com/codxse/mitosis-active-admin/compare/v0.1.13...v0.1.14) (2026-05-01)
6
+
7
+ ### [0.1.13](https://github.com/codxse/mitosis-active-admin/compare/v0.1.12...v0.1.13) (2026-04-16)
8
+
5
9
  ### [0.1.12](https://github.com/codxse/mitosis-active-admin/compare/v0.1.11...v0.1.12) (2026-04-16)
6
10
 
7
11
  ### [0.1.11](https://github.com/codxse/mitosis-active-admin/compare/v0.1.10...v0.1.11) (2026-03-07)
data/README.md CHANGED
@@ -107,6 +107,44 @@ This creates `app/views/inputs/mitosis_editor_input/_dependencies.html.erb` with
107
107
 
108
108
  The editor JS auto-detects `window.Prism` and passes it to `createEditor()` when present.
109
109
 
110
+ ### JavaScript API
111
+
112
+ The editor instance is accessible via the container element and a custom event.
113
+
114
+ **Container ID** follows the pattern `mitosis-editor-{object_name}_{method}`:
115
+
116
+ ```js
117
+ // For f.input :body, as: :mitosis_editor on a Post form:
118
+ const container = document.getElementById("mitosis-editor-post_body")
119
+ ```
120
+
121
+ **`mitosis-editor:ready` event** — dispatched on the container when the editor finishes initializing. The editor instance is passed as `event.detail`. The event does not bubble.
122
+
123
+ ```js
124
+ const container = document.getElementById("mitosis-editor-post_body")
125
+
126
+ if (container.editor) {
127
+ // editor already initialized
128
+ doSomething(container.editor)
129
+ } else {
130
+ container.addEventListener("mitosis-editor:ready", e => doSomething(e.detail), { once: true })
131
+ }
132
+ ```
133
+
134
+ **Editor methods:**
135
+
136
+ | Method | Description |
137
+ |--------|-------------|
138
+ | `getMarkdown()` | Returns current content as a Markdown string |
139
+ | `setMarkdown(content)` | Replaces editor content |
140
+ | `getHTML()` | Returns rendered HTML string |
141
+ | `getBoth()` | Returns `{ markdown, html }` |
142
+ | `setTheme(theme)` | Sets theme: `'light'`, `'dark'`, or `'auto'` |
143
+ | `getTheme()` | Returns current theme string |
144
+ | `destroy()` | Tears down the editor and removes its DOM |
145
+
146
+ **Adding custom scripts alongside the editor** — the `_dependencies.html.erb` partial (see [Customizing Dependencies](#customizing-dependencies)) is the right place to load additional scripts that interact with the editor, since it renders on every page that includes a mitosis editor input.
147
+
110
148
  ## Requirements
111
149
 
112
150
  - Ruby >= 3.0
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -1,21 +1,21 @@
1
- require_relative "lib/activeadmin_mitosis_editor/version"
1
+ require_relative 'lib/activeadmin_mitosis_editor/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = "activeadmin_mitosis_editor"
4
+ spec.name = 'activeadmin_mitosis_editor'
5
5
  spec.version = ActiveAdminMitosisEditor::VERSION
6
- spec.authors = ["Nadiar"]
7
- spec.email = ["codex@nadiar.id"]
8
- spec.summary = "A split-view markdown editor input for ActiveAdmin"
9
- spec.description = "Wraps mitosis-js as a custom input for ActiveAdmin forms"
10
- spec.license = "MIT"
11
- spec.homepage = "https://github.com/codxse/mitosis-active-admin"
12
- spec.metadata["source_code_uri"] = "https://github.com/codxse/mitosis-active-admin"
13
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|\.git)}) }
14
- spec.require_paths = ["lib"]
6
+ spec.authors = ['Nadiar']
7
+ spec.email = ['codex@nadiar.id']
8
+ spec.summary = 'A split-view markdown editor input for ActiveAdmin'
9
+ spec.description = 'Wraps mitosis-js as a custom input for ActiveAdmin forms'
10
+ spec.license = 'MIT'
11
+ spec.homepage = 'https://github.com/codxse/mitosis-active-admin'
12
+ spec.metadata['source_code_uri'] = 'https://github.com/codxse/mitosis-active-admin'
13
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(spec|\.git)/) }
14
+ spec.require_paths = ['lib']
15
15
 
16
- spec.required_ruby_version = ">= 3.0"
16
+ spec.required_ruby_version = '>= 3.0'
17
17
 
18
- spec.add_runtime_dependency "railties", ">= 7.0"
19
- spec.add_runtime_dependency "formtastic", "~> 5.0"
20
- spec.add_runtime_dependency "activesupport", ">= 7.0"
18
+ spec.add_runtime_dependency 'activesupport', '>= 7.0'
19
+ spec.add_runtime_dependency 'formtastic', '~> 5.0'
20
+ spec.add_runtime_dependency 'railties', '>= 7.0'
21
21
  end
@@ -24,6 +24,9 @@
24
24
  if (window.MitosisEditor && window.MitosisEditor.createEditor) {
25
25
  var editor = window.MitosisEditor.createEditor(options);
26
26
 
27
+ container.editor = editor;
28
+ container.dispatchEvent(new CustomEvent('mitosis-editor:ready', { detail: editor }));
29
+
27
30
  if (options.theme === 'auto') {
28
31
  var htmlEl = document.documentElement;
29
32
  var mutationObserver = new MutationObserver(function(mutations) {
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminMitosisEditor
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.14"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activeadmin-mitosis-editor",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "private": true,
5
5
  "devDependencies": {
6
6
  "standard-version": "^9.5.0"
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_mitosis_editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nadiar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-16 00:00:00.000000000 Z
11
+ date: 2026-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="