-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
111 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
html, | ||
body { | ||
margin: 0; | ||
} | ||
|
||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
.editor { | ||
height: 160px; | ||
} | ||
|
||
.toolbar { | ||
} |
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,5 @@ | ||
import React from "react"; | ||
|
||
export const Editor: React.FC = () => { | ||
return <></>; | ||
}; |
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,5 @@ | ||
import React from "react"; | ||
|
||
export const ToolBar: React.FC = () => { | ||
return <></>; | ||
}; |
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,2 @@ | ||
export * from "./Editor"; | ||
export * from "./ToolBar"; |
Empty file.
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,23 @@ | ||
import Quill from "quill"; | ||
|
||
export type Delta = ReturnType<Quill["getContents"]>; | ||
|
||
export const createQuill = (editor: HTMLElement, toolbar: HTMLElement) => { | ||
return new Quill(editor, { | ||
modules: { | ||
toolbar: toolbar | ||
}, | ||
placeholder: "なんか書いて", | ||
theme: "snow" | ||
}); | ||
}; | ||
|
||
export const createTextChangeHandler = (quill: Quill) => { | ||
return (delta?: Delta) => { | ||
const contents = quill.getContents(); | ||
console.log("contents: ", contents); | ||
if (delta) { | ||
console.log("delta ", delta); | ||
} | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import "quill/dist/quill.snow.css"; | ||
import "./assets/styles/global.css"; | ||
import { createQuill, createTextChangeHandler } from "./helpers"; | ||
import { Editor, ToolBar } from "./components"; | ||
|
||
import React from "react"; | ||
import * as ReactDOM from "react-dom/client"; | ||
|
||
const editorElement = document.getElementById("editor")!; | ||
const toolBarElement = document.getElementById("toolbar")!; | ||
const quill = createQuill(editorElement, toolBarElement); | ||
const handleTextChange = createTextChangeHandler(quill); | ||
// NOTE: Output initial values | ||
handleTextChange(); | ||
quill.on("text-change", handleTextChange); | ||
const cheerButtonElement = document.getElementById("cheer-button")!; | ||
cheerButtonElement.addEventListener("click", () => { | ||
alert("Have a fun!"); | ||
}); | ||
|
||
const reactContainer = document.getElementById("root")!; | ||
const root = ReactDOM.createRoot(reactContainer); | ||
root.render( | ||
<> | ||
<Editor /> | ||
<ToolBar /> | ||
</> | ||
); |
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