Fix eslint warnings
This commit is contained in:
parent
fba72e723f
commit
7b10670a88
6 changed files with 19 additions and 10 deletions
|
|
@ -41,7 +41,9 @@ function createSomeNotes() {
|
||||||
.map(({ it }) => it);
|
.map(({ it }) => it);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => createSomeNotes());
|
onMounted(() => {
|
||||||
|
createSomeNotes();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const { floatingStyles } = useFloating(reference, floating, {
|
||||||
offset(4),
|
offset(4),
|
||||||
size({
|
size({
|
||||||
apply({ availableHeight, elements }) {
|
apply({ availableHeight, elements }) {
|
||||||
elements.floating.style.maxHeight = `${Math.max(100, availableHeight)}px`;
|
elements.floating.style.maxHeight = `${Math.max(100, availableHeight).toFixed()}px`;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ const children = computed(() => {
|
||||||
const seen = new Map<string, number>();
|
const seen = new Map<string, number>();
|
||||||
const children = [];
|
const children = [];
|
||||||
for (const id of note.value.children) {
|
for (const id of note.value.children) {
|
||||||
const iteration = seen.get(id) || 0;
|
const iteration = seen.get(id) ?? 0;
|
||||||
seen.set(id, iteration + 1);
|
seen.set(id, iteration + 1);
|
||||||
children.push(new Segment(id, iteration));
|
children.push(new Segment(id, iteration));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ const emit = defineEmits<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const textarea = useTemplateRef<HTMLTextAreaElement>("textarea");
|
const textarea = useTemplateRef<HTMLTextAreaElement>("textarea");
|
||||||
const text = ref(props.initialText || "");
|
const text = ref(props.initialText ?? "");
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
textarea.value?.focus();
|
textarea.value?.focus();
|
||||||
|
|
@ -23,7 +23,7 @@ onMounted(() => {
|
||||||
function updateTextareaHeight() {
|
function updateTextareaHeight() {
|
||||||
if (!textarea.value) return;
|
if (!textarea.value) return;
|
||||||
textarea.value.style.height = "0px";
|
textarea.value.style.height = "0px";
|
||||||
textarea.value.style.height = `${textarea.value.scrollHeight}px`;
|
textarea.value.style.height = `${textarea.value.scrollHeight.toFixed()}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInput() {
|
function onInput() {
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,19 @@ export class Segment {
|
||||||
}
|
}
|
||||||
|
|
||||||
static parse(text: string): Segment {
|
static parse(text: string): Segment {
|
||||||
const match = text.match(/^([^/]+):([0-9]{1,10})$/);
|
const match = /^([^/]+):([0-9]{1,10})$/.exec(text);
|
||||||
assert(match !== null, "invalid segment string");
|
assert(match !== null, "invalid segment string");
|
||||||
return new Segment(match[1]!, Number.parseInt(match[2]!));
|
|
||||||
|
const id = match[1];
|
||||||
|
const iteration = match[2];
|
||||||
|
assert(id !== undefined, "invalid regex");
|
||||||
|
assert(iteration !== undefined, "invalid regex");
|
||||||
|
|
||||||
|
return new Segment(id, Number.parseInt(iteration));
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt(): string {
|
fmt(): string {
|
||||||
return `${this.id}:${this.iteration}`;
|
return `${this.id}:${this.iteration.toFixed()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
eq(other: Segment): boolean {
|
eq(other: Segment): boolean {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export const useNotesStore = defineStore("notes", () => {
|
||||||
const result = new Map<string, Set<string>>();
|
const result = new Map<string, Set<string>>();
|
||||||
for (const note of notes.value.values()) {
|
for (const note of notes.value.values()) {
|
||||||
for (const childId of note.children) {
|
for (const childId of note.children) {
|
||||||
const parents = result.get(childId) || new Set();
|
const parents = result.get(childId) ?? new Set();
|
||||||
result.set(childId, parents);
|
result.set(childId, parents);
|
||||||
parents.add(note.id);
|
parents.add(note.id);
|
||||||
}
|
}
|
||||||
|
|
@ -27,12 +27,13 @@ export const useNotesStore = defineStore("notes", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParents(id: string): ReadonlySet<string> {
|
function getParents(id: string): ReadonlySet<string> {
|
||||||
return parents.value.get(id) || new Set();
|
return parents.value.get(id) ?? new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNote(text: string): Note {
|
function createNote(text: string): Note {
|
||||||
const id = crypto.randomUUID();
|
const id = crypto.randomUUID();
|
||||||
notes.value.set(id, { id, text, children: [] });
|
notes.value.set(id, { id, text, children: [] });
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return notes.value.get(id)!; // Re-getting so returned Note is reactive
|
return notes.value.get(id)!; // Re-getting so returned Note is reactive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue