-
Notifications
You must be signed in to change notification settings - Fork 14
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
6 changed files
with
123 additions
and
87 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
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { UUID, Node } from "./types" | ||
import { getItemByEvent } from "./item" | ||
import { UUID, Node } from "./types"; | ||
import { getItemByEvent } from "./item"; | ||
|
||
export function getNodeByEvent(event: Event): Node { | ||
const item = getItemByEvent(event) | ||
const item = getItemByEvent(event); | ||
|
||
return getNodeByItem(item) | ||
return getNodeByItem(item); | ||
} | ||
|
||
export function getNodeByItem(item: HTMLLIElement): Node { | ||
const uuid = item.id.split("outline-node-")[1] as UUID | ||
const input = item.firstChild as HTMLDivElement | ||
const content = input.textContent || "" | ||
export function getNodeByItem(item: HTMLDivElement): Node { | ||
const uuid = item.id.split("outline-node-")[1] as UUID; | ||
const span = item.querySelector(".innerContent") as HTMLSpanElement; | ||
const content = span.textContent || ""; | ||
|
||
const parent_id = item.getAttribute("data-parent") as UUID || undefined | ||
const prev_id = item.getAttribute("data-prev") as UUID || undefined | ||
const parent_id = (item.getAttribute("data-parent") as UUID) || undefined; | ||
const prev_id = (item.getAttribute("data-prev") as UUID) || undefined; | ||
const dirty = item.getAttribute("data-dirty") == "true" ? true : false; | ||
|
||
return { uuid, content, parent_id, prev_id } | ||
return { uuid, content, parent_id, prev_id, dirty }; | ||
} |
Oops, something went wrong.