-
Notifications
You must be signed in to change notification settings - Fork 28
[Mission4/우대현] - Project_Notion_VanillaJS #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WooDaeHyun
wants to merge
3
commits into
3/#4_woodaehyun
Choose a base branch
from
3/#4_woodaehyun_working
base: 3/#4_woodaehyun
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| Api |
This file contains hidden or 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,148 @@ | ||
| /* http://meyerweb.com/eric/tools/css/reset/ | ||
| v2.0 | 20110126 | ||
| License: none (public domain) | ||
| */ | ||
|
|
||
| html, | ||
| body, | ||
| div, | ||
| span, | ||
| applet, | ||
| object, | ||
| iframe, | ||
| h1, | ||
| h2, | ||
| h3, | ||
| h4, | ||
| h5, | ||
| h6, | ||
| p, | ||
| blockquote, | ||
| pre, | ||
| a, | ||
| abbr, | ||
| acronym, | ||
| address, | ||
| big, | ||
| cite, | ||
| code, | ||
| del, | ||
| dfn, | ||
| em, | ||
| img, | ||
| ins, | ||
| kbd, | ||
| q, | ||
| s, | ||
| samp, | ||
| small, | ||
| strike, | ||
| strong, | ||
| sub, | ||
| sup, | ||
| tt, | ||
| var, | ||
| b, | ||
| u, | ||
| i, | ||
| center, | ||
| dl, | ||
| dt, | ||
| dd, | ||
| ol, | ||
| ul, | ||
| li, | ||
| fieldset, | ||
| form, | ||
| label, | ||
| legend, | ||
| table, | ||
| caption, | ||
| tbody, | ||
| tfoot, | ||
| thead, | ||
| tr, | ||
| th, | ||
| td, | ||
| article, | ||
| aside, | ||
| canvas, | ||
| details, | ||
| embed, | ||
| figure, | ||
| figcaption, | ||
| footer, | ||
| header, | ||
| hgroup, | ||
| menu, | ||
| nav, | ||
| output, | ||
| ruby, | ||
| section, | ||
| summary, | ||
| time, | ||
| mark, | ||
| audio, | ||
| video { | ||
| margin: 0; | ||
| padding: 0; | ||
| border: 0; | ||
| font-size: 100%; | ||
| font: inherit; | ||
| vertical-align: baseline; | ||
| } | ||
| /* HTML5 display-role reset for older browsers */ | ||
| article, | ||
| aside, | ||
| details, | ||
| figcaption, | ||
| figure, | ||
| footer, | ||
| header, | ||
| hgroup, | ||
| menu, | ||
| nav, | ||
| section { | ||
| display: block; | ||
| } | ||
| body { | ||
| line-height: 1; | ||
| } | ||
| ol, | ||
| ul { | ||
| list-style: none; | ||
| } | ||
| blockquote, | ||
| q { | ||
| quotes: none; | ||
| } | ||
| blockquote:before, | ||
| blockquote:after, | ||
| q:before, | ||
| q:after { | ||
| content: ""; | ||
| content: none; | ||
| } | ||
| table { | ||
| border-collapse: collapse; | ||
| border-spacing: 0; | ||
| } | ||
| button { | ||
| border: none; | ||
| background-color: transparent; | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
| input { | ||
| border: none; | ||
| outline: none; | ||
| } | ||
| textarea { | ||
| border: none; | ||
| resize: none; | ||
| outline: none; | ||
| } | ||
| input::placeholder, | ||
| textarea::placeholder { | ||
| color: #d7d7d7; | ||
| } |
This file contains hidden or 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,126 @@ | ||
| main { | ||
| display: flex; | ||
| width: 100%; | ||
| height: 100vh; | ||
| } | ||
|
|
||
| div.left { | ||
| width: 20%; | ||
| background-color: #f7f5f0; | ||
| color: #696969; | ||
| } | ||
|
|
||
| .left .header { | ||
| width: 100%; | ||
| height: 10%; | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .left .header h2 { | ||
| font-size: 20px; | ||
| font-weight: 500; | ||
| margin-left: 15px; | ||
| } | ||
|
|
||
| .left .postList { | ||
| width: 100%; | ||
| height: 90%; | ||
| overflow-y: auto; | ||
| } | ||
|
|
||
| .postList ul { | ||
| padding-left: 1.5vh; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .document { | ||
| width: 100%; | ||
| height: fit-content; | ||
| padding: 1.5vh 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: flex-end; | ||
| } | ||
|
|
||
| .document:hover { | ||
| background-color: #e8e6e0de; | ||
| } | ||
|
|
||
| .document span { | ||
| width: 75%; | ||
| overflow: hidden; | ||
| white-space: nowrap; | ||
| text-overflow: ellipsis; | ||
| font-size: 15px; | ||
| margin-right: 5px; | ||
| } | ||
|
|
||
| .document button { | ||
| width: 30px; | ||
| height: 30px; | ||
| font-size: 20px; | ||
| border-radius: 5px; | ||
| margin-right: 5px; | ||
| color: #565656; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .document button:hover { | ||
| background-color: #cac8c5cc; | ||
| } | ||
|
|
||
| .new-post { | ||
| width: 100%; | ||
| height: fit-content; | ||
| padding: 15px 0; | ||
| font-size: 20px; | ||
| text-align: left; | ||
| padding-left: 15px; | ||
| color: #565656; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .new-post:hover { | ||
| background-color: #e8e6e0de; | ||
| } | ||
|
|
||
| div.right { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| width: 80%; | ||
| } | ||
|
|
||
| .editor { | ||
| width: 80%; | ||
| height: 80%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| .editor input { | ||
| width: 100%; | ||
| padding: 10px 0; | ||
| font-size: 45px; | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| .editor div:focus { | ||
| outline: none; | ||
| } | ||
|
|
||
| .content-container:empty:before { | ||
| content: attr(placeholder); | ||
| display: block; | ||
| color: rgb(174, 174, 174); | ||
| } | ||
|
|
||
| .content-container { | ||
| width: 100%; | ||
| height: 84%; | ||
| font-size: 25px; | ||
| padding: 10px 0; | ||
| overflow-y: auto; | ||
| } |
This file contains hidden or 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 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="ko"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <link rel="stylesheet" href="./css/reset.css" /> | ||
| <link rel="stylesheet" href="./css/style.css" /> | ||
| <title>Notion cloning</title> | ||
| </head> | ||
| <body> | ||
| <main id="app"></main> | ||
| <script src="./src/main.js" type="module"></script> | ||
| </body> | ||
| </html> | ||
This file contains hidden or 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,57 @@ | ||
| import { request } from "../../Api/api.js"; | ||
|
|
||
| export default function Editor({ $target, initialState }) { | ||
| const $editor = document.createElement("div"); | ||
| const $div = document.createElement("div"); | ||
| $editor.setAttribute("class", "right"); | ||
| $div.setAttribute("class", "editor"); | ||
|
|
||
| $target.appendChild($editor); | ||
| $editor.appendChild($div); | ||
|
|
||
| this.state = initialState; | ||
|
|
||
| this.handleRevise = () => { | ||
| const plusEvent = new CustomEvent("@ReviseCompleted"); | ||
| $editor.dispatchEvent(plusEvent); | ||
| }; | ||
|
|
||
| this.render = () => { | ||
| $div.innerHTML = ` | ||
| <input type="text" name="title" placeholder="제목 없음" /> | ||
| <div class="content-container" name="content" contentEditable="true" placeholder="내용을 입력해주세요."></div> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| `; | ||
| }; | ||
| this.render(); | ||
|
|
||
| this.setState = (nextState) => { | ||
| this.state = nextState; | ||
| $div.querySelector("[name=title]").value = this.state.title; | ||
| $div.querySelector("[name=content]").innerHTML = this.state.content; | ||
| }; | ||
|
|
||
| $div.querySelector("[name=title]").addEventListener("keyup", async (e) => { | ||
| e.preventDefault(); | ||
| const $input = $div.querySelector("input"); | ||
| await request(`/documents/${this.state.id}`, { | ||
| method: "PUT", | ||
| body: JSON.stringify({ | ||
| title: $input.value, | ||
| }), | ||
| }); | ||
| this.handleRevise(); | ||
| }); | ||
|
|
||
| $editor | ||
| .querySelector("[name=content]") | ||
| .addEventListener("input", async (e) => { | ||
| e.preventDefault(); | ||
| await request(`/documents/${this.state.id}`, { | ||
| method: "PUT", | ||
| body: JSON.stringify({ | ||
| content: e.target.innerHTML, | ||
| }), | ||
| }); | ||
| this.handleRevise(); | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
History API를 이용해 SPA형태로 만드려면 상대경로가 아닌 절대경로로 하셔야 한다고 들었습니다 !
URL이 바뀌는 걸 기준으로 src를 참조하기 때문에 문제가 생길 수도 있다네요 🧐