Initial RuneStone project

This commit is contained in:
Knotty Wyvern
2026-09-26 01:25:42 -07:00
commit bdc15e952d
190 changed files with 25986 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import { StateEffect, StateField } from "@codemirror/state";
export const trackImageDrop = StateEffect.define<{ id: symbol; from: number; to: number }>();
export const clearImageDrop = StateEffect.define<symbol>();
export const imageDrops = StateField.define<Map<symbol, { from: number; to: number }>>({
create: () => new Map(),
update(value, transaction) {
const next = new Map([...value].map(([id, range]) => [id, {
from: transaction.changes.mapPos(range.from, 1),
to: transaction.changes.mapPos(range.to, 1),
}]));
for (const effect of transaction.effects) {
if (effect.is(trackImageDrop)) next.set(effect.value.id, effect.value);
if (effect.is(clearImageDrop)) next.delete(effect.value);
}
return next;
},
});