Closed dmitriyrotaenko closed 11 months ago
I'm new to rails and trying to create a simple app with tinymce as the page editor. I want to initialize the editor in a hotwired component but when I run bin/dev, I get this error in the terminal:
bin/dev
22:15:46 js.1 | ✘ [ERROR] Could not resolve "tinymce" 22:15:46 js.1 | 22:15:46 js.1 | app/javascript/controllers/editor_controller.js:2:7: 22:15:46 js.1 | 2 │ import "tinymce"
ruby "3.1.2" gem "rails", "~> 7.0.5", ">= 7.0.5.1" gem "tinymce-rails", "~> 6.6"
/app/javascript/application.js
import "@hotwired/turbo-rails" import "./controllers" //= require tinymce
/app/javascript/controllers/editor_controller.js
import { Controller } from "@hotwired/stimulus"; import "tinymce" export default class extends Controller { connect() { tinymce.init({ selector: "textarea.editor" }) } }
= form_with(model: [@project, @page], class: "contents", data: { controller: "editor" }) do |form| - if page.errors.any? #error_explanation.bg-red-50.text-red-500.px-3.py-2.font-medium.rounded-lg.mt-3 %h2 = pluralize(page.errors.count, "error") prohibited this page from being saved: %ul - page.errors.each do |error| %li= error.full_message .my-5 = text_area_tag :editor, "", :rows => 40, :cols => 120
What am I missing?
Was missing the following code in application.html.haml
application.html.haml
= tinymce_assets %script{src: "/assets/tinymce.js", type: "text/javascript"}
I'm new to rails and trying to create a simple app with tinymce as the page editor. I want to initialize the editor in a hotwired component but when I run
bin/dev
, I get this error in the terminal:Gemfile
/app/javascript/application.js
/app/javascript/controllers/editor_controller.js
My form partial
What am I missing?