-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add EJS support in anime text file (#135)
- Loading branch information
Showing
6 changed files
with
1,732 additions
and
47 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script> | ||
import { _ } from "@/libs/i18next"; | ||
import CodeMirror from "codemirror"; | ||
import { debounce } from "throttle-debounce"; | ||
import { createEventDispatcher } from "svelte"; | ||
import "codemirror/mode/htmlembedded/htmlembedded"; | ||
import "codemirror/lib/codemirror.css"; | ||
import "codemirror/theme/material-palenight.css"; | ||
export let code; | ||
const dispatch = createEventDispatcher(); | ||
const changeDebounce = debounce(500, change); | ||
let codeArea = null; | ||
$: if (codeArea) codeMirrorInit(); | ||
function change(value) { | ||
dispatch("change", value.trim()); | ||
} | ||
function codeMirrorInit() { | ||
const myCodeMirror = CodeMirror.fromTextArea(codeArea, { | ||
theme: "material-palenight", | ||
mode: "application/x-ejs", | ||
lineNumbers: true, | ||
tabSize: 2, | ||
}); | ||
myCodeMirror.on("changes", () => { | ||
changeDebounce(myCodeMirror.getValue()); | ||
}); | ||
} | ||
</script> | ||
|
||
<textarea | ||
bind:this="{codeArea}" | ||
class="p-2 text-dark" | ||
style="min-width:50vw; min-height:250px" | ||
>{code}</textarea> |
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
Oops, something went wrong.