-
Notifications
You must be signed in to change notification settings - Fork 28
Add task description preview #154
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -99,14 +99,39 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <%= form.text_field :content, class: "form-control", placeholder: "タスクの内容を入力してください", required: true %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div class="mb-4"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <%= form.label :description, "説明", class: "form-label fw-bold" %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <%= form.text_area :description, class: "form-control", rows: 10, placeholder: "タスクの説明を入力してください" %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div class="tabs"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <input id="write" type="radio" name="tab_item" checked> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <label class="tab_item" for="write">Write</label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <input id="preview" type="radio" name="tab_item"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <label class="tab_item" for="preview">Preview</label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div class="tab_content" id="write_content"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <%= form.text_area :description, class: "border-2 w-full", rows: 10, id: "write-area", placeholder: "タスクの説明を入力してください" %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div class="tab_content" id="preview_content"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div style="height: 300px" class="overflow-y-scroll"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div id="preview-area" class="markdown-body p-12 list-style-none"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div class="d-grid"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <%= form.submit "保存", class: "btn btn-danger" %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('preview').onchange=function(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const text = document.getElementById("write-area").value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const preview = document.getElementById("preview-area") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+125
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const text = document.getElementById("write-area").value | |
| const preview = document.getElementById("preview-area") | |
| const text = document.getElementById("write-area").value; | |
| const preview = document.getElementById("preview-area"); |
Copilot
AI
Oct 23, 2025
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.
The preview innerHTML is set directly from the API response without sanitization, which could lead to XSS vulnerabilities if the markdown rendering doesn't properly escape HTML. Ensure the backend sanitizes the output or use textContent/safer DOM manipulation methods.
Copilot
AI
Oct 23, 2025
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.
[nitpick] The entire inline script lacks proper indentation and formatting. The function body should be properly indented for readability and maintainability.
| document.getElementById('preview').onchange=function(){ | |
| const text = document.getElementById("write-area").value | |
| const preview = document.getElementById("preview-area") | |
| const obj = {text: text}; | |
| const method = "POST"; | |
| const body = JSON.stringify(obj); | |
| const headers = { | |
| 'Accept': 'application/json', | |
| 'Content-Type': 'application/json' | |
| }; | |
| fetch("/documents/api_markdown", {method, headers, body}).then((res)=> res.json()).then((obj) => {preview.innerHTML=obj.text}).catch(console.error);} | |
| document.getElementById('preview').onchange = function() { | |
| const text = document.getElementById("write-area").value; | |
| const preview = document.getElementById("preview-area"); | |
| const obj = { text: text }; | |
| const method = "POST"; | |
| const body = JSON.stringify(obj); | |
| const headers = { | |
| 'Accept': 'application/json', | |
| 'Content-Type': 'application/json' | |
| }; | |
| fetch("/documents/api_markdown", { method, headers, body }) | |
| .then((res) => res.json()) | |
| .then((obj) => { preview.innerHTML = obj.text; }) | |
| .catch(console.error); | |
| } |
Copilot
AI
Oct 23, 2025
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.
[nitpick] The promise chain should be formatted across multiple lines for better readability. Additionally, the error handling with console.error doesn't provide user feedback when the preview fails to load.
| fetch("/documents/api_markdown", {method, headers, body}).then((res)=> res.json()).then((obj) => {preview.innerHTML=obj.text}).catch(console.error);} | |
| fetch("/documents/api_markdown", { method, headers, body }) | |
| .then((res) => res.json()) | |
| .then((obj) => { | |
| preview.innerHTML = obj.text; | |
| }) | |
| .catch((error) => { | |
| console.error(error); | |
| preview.innerHTML = '<div class="alert alert-danger">プレビューの読み込みに失敗しました。</div>'; | |
| }); | |
| } |
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.
The 'p-12' class appears to be a Tailwind CSS utility class (padding: 3rem), while 'list-style-none' is not standard Tailwind syntax (should be 'list-none'). This mixing of frameworks and potential class name errors could cause unexpected styling behavior.