forked from excid3/simple_discussion
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding markdown editor using simplemde
- Loading branch information
Showing
5 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/assets/javascripts/simple_discussion/controllers/simplemde_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
//import SimpleMDE from "simplemde"; | ||
|
||
export default class extends Controller { | ||
static targets = ["textarea"] | ||
|
||
connect() { | ||
this.initializeEditor(); | ||
|
||
const previewButton = document.querySelector(".preview") | ||
previewButton.style.width = "80px" | ||
previewButton.style.height = "34px" | ||
} | ||
|
||
initializeEditor() { | ||
this.editor = new SimpleMDE({ | ||
element: this.textareaTarget, | ||
forceSync: true, | ||
toolbar: [ | ||
"bold", | ||
"italic", | ||
"heading", | ||
"|", | ||
"quote", | ||
"unordered-list", | ||
"ordered-list", | ||
"|", | ||
"link", | ||
{ | ||
name: "preview", | ||
className: "preview no-disable", | ||
action: function(editor) { | ||
SimpleMDE.togglePreview(editor); | ||
}, | ||
title: "Preview", | ||
} | ||
], | ||
spellChecker: false, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters