Skip to content

Commit

Permalink
fix typescript type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lukad committed May 19, 2024
1 parent ff87bc5 commit e91920b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/js/hooks/events/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function handleContentChange({ node }: { node: Node }) {
}

const input = item.firstChild!;
input.textContent = node.content;
input.textContent = node.content || "";

setItemDirty(item, false);
}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/hooks/events/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function keydown(event: KeyboardEvent) {
break;

case "ArrowDown":
if (selection?.anchorOffset != node.content.length) return;
if (selection?.anchorOffset != node.content?.length) return;
event.preventDefault();

if (!nextItem || !nextNode) return;
Expand Down Expand Up @@ -98,7 +98,7 @@ export function keydown(event: KeyboardEvent) {

if (!prevItem || !prevNode) return;

prevNode.content += node.content;
prevNode.content += node.content || "";
updateItem(prevNode, container);
focusItem(prevItem);
prevNode.dirty = true;
Expand All @@ -110,12 +110,12 @@ export function keydown(event: KeyboardEvent) {
break;

case "Delete":
if (selection?.anchorOffset != node.content.length) return;
if (selection?.anchorOffset != node.content?.length) return;
event.preventDefault();

if (!nextItem || !nextNode) return;

node.content += nextNode.content;
node.content += nextNode.content || "";
updateItem(node, container);
focusItem(item);
node.dirty = true;
Expand Down
4 changes: 2 additions & 2 deletions assets/js/hooks/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Node } from "./types";

export function createItem({ uuid, content, parent_id, prev_id, dirty }: Node) {
const input = document.createElement("div");
input.textContent = content;
input.textContent = content || "";
input.contentEditable = "true"; // firefox does not support "plaintext-only"

const ol = document.createElement("ol");
Expand Down Expand Up @@ -31,7 +31,7 @@ export function updateItem(
if (!item) return;

const input = item.firstChild!;
input.textContent = content;
input.textContent = content || "";

item.className = dirty ? "my-1 ml-4 bg-red-100" : "my-1 ml-4";

Expand Down

0 comments on commit e91920b

Please sign in to comment.