Rename RedrawableHTML, remove File API rate limite and fix pull job transaction.

This commit is contained in:
Clément Pons
2026-01-27 17:13:40 +01:00
parent e9a892076d
commit a412116b9c
14 changed files with 153 additions and 117 deletions

View File

@@ -2,7 +2,7 @@ import { safeDestr as parse } from 'destr';
import { Canvas, CanvasEditor } from "#shared/canvas";
import render, { renderMDAsText } from "#shared/markdown";
import { confirm, contextmenu, tooltip } from "#shared/floating";
import { cancelPropagation, dom, icon, text, type Node, type RedrawableHTML } from "#shared/dom";
import { cancelPropagation, dom, icon, text, type Node, type HTMLElement } from "#shared/dom";
import { loading } from "#shared/components";
import prose, { h1, h2 } from "#shared/proses";
import { getID, lerp, parsePath } from '~~/shared/general';
@@ -381,7 +381,7 @@ export class Content
return handlers[overview.type].fromString(content);
}
static async render(parent: RedrawableHTML, path: string): Promise<Omit<LocalContent, 'content'> | undefined>
static async render(parent: HTMLElement, path: string): Promise<Omit<LocalContent, 'content'> | undefined>
{
parent.appendChild(dom('div', { class: 'flex, flex-1 justify-center items-center' }, [loading('normal')]))
@@ -489,7 +489,7 @@ const handlers: { [K in FileType]: ContentTypeHandler<K> } = {
return c.container;
},
renderEditor: (content) => {
let element: RedrawableHTML;
let element: HTMLElement;
if(content.hasOwnProperty('content'))
{
const c = new CanvasEditor(content.content);
@@ -527,7 +527,7 @@ const handlers: { [K in FileType]: ContentTypeHandler<K> } = {
])
},
renderEditor: (content) => {
let element: RedrawableHTML;
let element: HTMLElement;
if(content.hasOwnProperty('content'))
{
MarkdownEditor.singleton.content = content.content;
@@ -582,11 +582,11 @@ export const iconByType: Record<FileType, string> = {
export class Editor
{
tree!: TreeDOM;
container: RedrawableHTML;
container: HTMLElement;
selected?: Recursive<LocalContent & { element?: RedrawableHTML }>;
selected?: Recursive<LocalContent & { element?: HTMLElement }>;
private instruction: RedrawableHTML;
private instruction: HTMLElement;
private cleanup?: CleanupFn;
private history: History;
@@ -638,7 +638,7 @@ export class Editor
if(!action.element)
{
const depth = getPath(action.element as LocalContent).split('/').length;
action.element.element = this.tree.render(action.element as LocalContent, depth) as RedrawableHTML;
action.element.element = this.tree.render(action.element as LocalContent, depth) as HTMLElement;
this.dragndrop(action.element as LocalContent, depth, (action.element as Recursive<LocalContent>).parent);
}
this.tree.tree.insertAt(action.element as Recursive<LocalContent>, action.to as number);
@@ -718,7 +718,7 @@ export class Editor
])]);
});
this.select(this.tree.tree.find(useRouter().currentRoute.value.hash.substring(1)) as Recursive<LocalContent & { element?: RedrawableHTML }> | undefined);
this.select(this.tree.tree.find(useRouter().currentRoute.value.hash.substring(1)) as Recursive<LocalContent & { element?: HTMLElement }> | undefined);
this.cleanup = this.setupDnD();
});
@@ -740,14 +740,14 @@ export class Editor
private add(type: FileType, nextTo: Recursive<LocalContent>)
{
const count = Object.values(Content.files).filter(e => e.title.match(/^Nouveau( \(\d+\))?$/)).length;
const item: Recursive<Omit<LocalContent, 'path' | 'content'> & { element?: RedrawableHTML }> = { id: getID(), navigable: true, private: false, owner: 0, order: nextTo.order + 1, timestamp: new Date(), title: count === 0 ? 'Nouveau' : `Nouveau (${count})`, type: type, parent: nextTo.parent };
const item: Recursive<Omit<LocalContent, 'path' | 'content'> & { element?: HTMLElement }> = { id: getID(), navigable: true, private: false, owner: 0, order: nextTo.order + 1, timestamp: new Date(), title: count === 0 ? 'Nouveau' : `Nouveau (${count})`, type: type, parent: nextTo.parent };
this.history.add('overview', 'add', [{ element: item, from: undefined, to: nextTo.order + 1 }]);
}
private remove(item: LocalContent & { element?: RedrawableHTML })
private remove(item: LocalContent & { element?: HTMLElement })
{
this.history.add('overview', 'remove', [{ element: item, from: item.order, to: undefined }], true);
}
private rename(item: LocalContent & { element?: RedrawableHTML })
private rename(item: LocalContent & { element?: HTMLElement })
{
let exists = true;
const change = () =>
@@ -769,13 +769,13 @@ export class Editor
text?.parentElement?.replaceChild(input, text);
input.focus();
}
private toggleNavigable(e: Event, item: LocalContent & { element?: RedrawableHTML })
private toggleNavigable(e: Event, item: LocalContent & { element?: HTMLElement })
{
cancelPropagation(e);
this.history.add('overview', 'navigable', [{ element: item, from: item.navigable, to: !item.navigable }], true);
}
private togglePrivate(e: Event, item: LocalContent & { element?: RedrawableHTML })
private togglePrivate(e: Event, item: LocalContent & { element?: HTMLElement })
{
cancelPropagation(e);
@@ -800,7 +800,7 @@ export class Editor
element: this.tree.container,
}));
}
private dragndrop(item: Omit<LocalContent & { element?: RedrawableHTML, cleanup?: () => void }, "content">, depth: number, parent?: Omit<LocalContent & { element?: RedrawableHTML }, "content">): CleanupFn
private dragndrop(item: Omit<LocalContent & { element?: HTMLElement, cleanup?: () => void }, "content">, depth: number, parent?: Omit<LocalContent & { element?: HTMLElement }, "content">): CleanupFn
{
item.cleanup && item.cleanup();
@@ -896,7 +896,7 @@ export class Editor
{
return handlers[item.type].renderEditor(item);
}
private select(item?: LocalContent & { element?: RedrawableHTML })
private select(item?: LocalContent & { element?: HTMLElement })
{
if(this.selected && item)
{
@@ -917,7 +917,7 @@ export class Editor
useRouter().push({ hash: this.selected ? '#' + this.selected.id : '' })
this.container.firstElementChild!.replaceChildren();
this.selected && this.container.firstElementChild!.appendChild(this.render(this.selected) as RedrawableHTML);
this.selected && this.container.firstElementChild!.appendChild(this.render(this.selected) as HTMLElement);
}
unmount()
{
@@ -937,8 +937,9 @@ export function getPath(item: any): string
return parsePath(item.title) ?? item.path;
}
/* export function buildSpellMD()
import characterConfig from '#shared/character-config.json';
const config = characterConfig as CharacterConfig;
export function buildSpellMD()
{
const SPELL_ELEMENTS = ["fire","ice","thunder","earth","arcana","air","nature","light","psyche"];
const SPELL_TYPE_TEXTS = { "instinct": "Instinct", "knowledge": "Savoir", "precision": "Précision", "arts": "Oeuvres" };
@@ -981,4 +982,4 @@ export function buildTrainingFile()
return Object.entries(config.training).map(e => {
return `# ${mainStatTexts[e[0] as MainStat]}\n` + Object.entries(e[1]).map(_e => `## Niveau ${_e[0]}\n` + _e[1].map(feature => renderMDAsText(getText(config.features[feature]!.description))).join('\nou\n')).join('\n');
}).join('\n');
} */
}