upd md render
This commit is contained in:
parent
1752e3c27c
commit
6e35822708
|
|
@ -1 +1 @@
|
||||||
1.1.104
|
1.1.105
|
||||||
|
|
@ -35,18 +35,27 @@
|
||||||
chip.style.color = color;
|
chip.style.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function markUnknown(chip: HTMLElement, prefix: string) {
|
||||||
|
// Replace the chip (and its preceding arrow span) with plain text
|
||||||
|
const arrow = chip.previousElementSibling;
|
||||||
|
const text = document.createTextNode(`${prefix}${chip.dataset.assignment ?? chip.dataset.person ?? ''}`);
|
||||||
|
chip.parentNode?.insertBefore(text, chip);
|
||||||
|
chip.remove();
|
||||||
|
if (arrow && /→|→/.test(arrow.textContent ?? '')) arrow.remove();
|
||||||
|
}
|
||||||
|
|
||||||
const assignmentChips = containerEl.querySelectorAll<HTMLElement>('[data-assignment]');
|
const assignmentChips = containerEl.querySelectorAll<HTMLElement>('[data-assignment]');
|
||||||
const personChips = containerEl.querySelectorAll<HTMLElement>('[data-person]');
|
const personChips = containerEl.querySelectorAll<HTMLElement>('[data-person]');
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
...Array.from(assignmentChips).map(async chip => {
|
...Array.from(assignmentChips).map(async chip => {
|
||||||
const ctx = await findContextByAbbreviation(chip.dataset.assignment!);
|
const ctx = await findContextByAbbreviation(chip.dataset.assignment!);
|
||||||
if (!ctx) return;
|
if (!ctx) { markUnknown(chip, '-> '); return; }
|
||||||
const subType = (ctx.meta as Record<string, unknown> | null)?.personSubType as PersonSubType | undefined;
|
const subType = (ctx.meta as Record<string, unknown> | null)?.personSubType as PersonSubType | undefined;
|
||||||
applySubtypeColor(chip, subType);
|
applySubtypeColor(chip, subType);
|
||||||
}),
|
}),
|
||||||
...Array.from(personChips).map(async chip => {
|
...Array.from(personChips).map(async chip => {
|
||||||
const ctx = await findContextByMentionName(chip.dataset.person!, 'person');
|
const ctx = await findContextByMentionName(chip.dataset.person!, 'person');
|
||||||
if (!ctx) return;
|
if (!ctx) { markUnknown(chip, '@'); return; }
|
||||||
const subType = (ctx.meta as Record<string, unknown> | null)?.personSubType as PersonSubType | undefined;
|
const subType = (ctx.meta as Record<string, unknown> | null)?.personSubType as PersonSubType | undefined;
|
||||||
applySubtypeColor(chip, subType);
|
applySubtypeColor(chip, subType);
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue