Techioz Blog

Rails 7 で importmap と Stimulus を使用して EditorJS を構成するにはどうすればよいですか?

概要

importmaps を使用して Rails 7 アプリケーションのコンテンツ エディターとして EditorJS をセットアップしようとしていますが、いくつかのエラーが発生します。

EditorJS を固定するには、ターミナルで ./bin/importmap pin editor-js を実行しました。これにより、importmap.rbに次のようになりました

pin "editor-js", to: "https://ga.jspm.io/npm:[email protected]/src/js/editor.js"
pin "babel-runtime/core-js/weak-map", to: "https://ga.jspm.io/npm:[email protected]/core-js/weak-map.js"
pin "babel-runtime/helpers/classCallCheck", to: "https://ga.jspm.io/npm:[email protected]/helpers/classCallCheck.js"
pin "babel-runtime/helpers/createClass", to: "https://ga.jspm.io/npm:[email protected]/helpers/createClass.js"
pin "browser-split", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "class-list", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "core-js/library/fn/object/define-property", to: "https://ga.jspm.io/npm:[email protected]/library/fn/object/define-property.js"
pin "core-js/library/fn/weak-map", to: "https://ga.jspm.io/npm:[email protected]/library/fn/weak-map.js"
pin "editable", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "es6-event-emitter", to: "https://ga.jspm.io/npm:[email protected]/dist/emitter.js"
pin "events", to: "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/events.js"
pin "html-element", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "hyperscript", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "indexof", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "inherits", to: "https://ga.jspm.io/npm:[email protected]/inherits_browser.js"
pin "jquery", to: "https://ga.jspm.io/npm:[email protected]/dist/jquery.js"
pin "styles", to: "https://ga.jspm.io/npm:[email protected]/Gruntfile.js"
pin "text-content", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "toastr", to: "https://ga.jspm.io/npm:[email protected]/toastr.js"

次に、これらすべての依存関係を editor-js とともに刺激コントローラーにインポートしようとしましたが、依然としてコンソール エラーが発生します。これも単に実装が間違っているような気がします。

Rails 7 で importmaps と Stimulus を使用して EditorJS を構成した経験のある人はいますか?

解決策

editor-js はあなたが探しているパッケージではないと思います。ここにオビワンのGIFを挿入

$ ./bin/importmap pin @editorjs/editorjs を試してください