This commit is contained in:
Cat /dev/Nulo 2023-08-29 11:05:34 -03:00
parent 559f107b14
commit e3b2edd214
13 changed files with 37 additions and 22 deletions

View file

@ -8,7 +8,8 @@
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --tsconfig ./tsconfig.json",
"upload": "scp -CrP993 dist/* root@nulo.in:/var/www/beta.schreiben.nulo.ar/" "upload": "scp -CrP993 dist/* root@nulo.in:/var/www/beta.schreiben.nulo.ar/",
"format": "prettier --write src/"
}, },
"devDependencies": { "devDependencies": {
"@poppanator/sveltekit-svg": "^2.1.2", "@poppanator/sveltekit-svg": "^2.1.2",

View file

@ -1,3 +1,3 @@
module.exports = { module.exports = {
plugins: ["prettier-plugin-tailwindcss", "prettier-plugin-svelte"], plugins: ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
}; };

View file

@ -3,7 +3,22 @@
@tailwind utilities; @tailwind utilities;
:root { :root {
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-family:
Inter,
ui-sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
Arial,
"Noto Sans",
sans-serif,
"Apple Color Emoji",
"Segoe UI Emoji",
"Segoe UI Symbol",
"Noto Color Emoji";
font-weight: 400; font-weight: 400;
font-synthesis: none; font-synthesis: none;

View file

@ -55,4 +55,3 @@
content: "Descripción: "; content: "Descripción: ";
color: #666; color: #666;
} }

View file

@ -26,7 +26,7 @@ import { schema } from "./schema";
const backspace = chainCommands( const backspace = chainCommands(
deleteSelection, deleteSelection,
joinBackward, joinBackward,
selectNodeBackward selectNodeBackward,
); );
const del = chainCommands(deleteSelection, joinForward, selectNodeForward); const del = chainCommands(deleteSelection, joinForward, selectNodeForward);
@ -37,7 +37,7 @@ const pcBaseKeymap = {
liftEmptyBlock, liftEmptyBlock,
// XXX: hack // XXX: hack
splitListItem(schema.nodes.list_item as any), splitListItem(schema.nodes.list_item as any),
splitBlock splitBlock,
), ),
"Mod-Enter": chainCommands(exitCode, splitBlock), "Mod-Enter": chainCommands(exitCode, splitBlock),
Backspace: backspace, Backspace: backspace,

View file

@ -11,14 +11,14 @@ import type { EditorView } from "prosemirror-view";
export type Command = ( export type Command = (
state: EditorState, state: EditorState,
dispatch?: EditorView["dispatch"] dispatch?: EditorView["dispatch"],
) => boolean; ) => boolean;
// A lot of this is from https://github.com/ueberdosis/tiptap/blob/main/packages/tiptap-commands // A lot of this is from https://github.com/ueberdosis/tiptap/blob/main/packages/tiptap-commands
export function getMarkRange( export function getMarkRange(
$pos: ResolvedPos | null = null, $pos: ResolvedPos | null = null,
type: MarkType | null = null type: MarkType | null = null,
) { ) {
if (!$pos || !type) { if (!$pos || !type) {
return false; return false;
@ -122,14 +122,14 @@ export function toggleNode(
attrs: any, attrs: any,
/// es el tipo que se setea si ya es el type querido; probablemente querés /// es el tipo que se setea si ya es el type querido; probablemente querés
/// que sea el type de párrafo /// que sea el type de párrafo
alternateType: NodeType alternateType: NodeType,
): Command { ): Command {
return chainCommands(setBlockType(type, attrs), setBlockType(alternateType)); return chainCommands(setBlockType(type, attrs), setBlockType(alternateType));
} }
export function commandListener( export function commandListener(
view: EditorView, view: EditorView,
command: Command command: Command,
): (event: Event) => void { ): (event: Event) => void {
return (event) => { return (event) => {
event.preventDefault(); event.preventDefault();
@ -139,7 +139,7 @@ export function commandListener(
export default function findParentNodeClosestToPos( export default function findParentNodeClosestToPos(
$pos: ResolvedPos, $pos: ResolvedPos,
predicate: (node: ProsemirrorNode) => boolean predicate: (node: ProsemirrorNode) => boolean,
) { ) {
for (let i = $pos.depth; i > 0; i -= 1) { for (let i = $pos.depth; i > 0; i -= 1) {
const node = $pos.node(i); const node = $pos.node(i);
@ -158,7 +158,7 @@ export default function findParentNodeClosestToPos(
export function nodeIsActiveFn( export function nodeIsActiveFn(
type: NodeType, type: NodeType,
attrs?: any, attrs?: any,
checkParents: boolean = false checkParents: boolean = false,
): (state: EditorState) => boolean { ): (state: EditorState) => boolean {
return (state) => { return (state) => {
let { $from, to } = state.selection; let { $from, to } = state.selection;
@ -196,7 +196,7 @@ export interface MarkMatch {
export function getFirstMarkInSelection( export function getFirstMarkInSelection(
state: EditorState, state: EditorState,
type: MarkType type: MarkType,
): MarkMatch | null { ): MarkMatch | null {
const { to, from } = state.selection; const { to, from } = state.selection;

View file

@ -315,7 +315,7 @@ export const schema = new Schema({
if ( if (
href && href &&
/[useandom\-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict]{21}/.test( /[useandom\-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict]{21}/.test(
href href,
) )
) { ) {
return { return {

View file

@ -9,7 +9,7 @@ interface Props {
export function h( export function h(
tagName: string, tagName: string,
props: Props, props: Props,
children: (Node | string | undefined)[] children: (Node | string | undefined)[],
): HTMLElement { ): HTMLElement {
const el = document.createElement(tagName); const el = document.createElement(tagName);
if (props.class) { if (props.class) {

View file

@ -25,7 +25,7 @@ export function generateNewWorld(): WorldIdentifier {
let worldYCache: { [key: string]: WorldY } = {}; let worldYCache: { [key: string]: WorldY } = {};
const credsReq = fetch( const credsReq = fetch(
"https://nulo.metered.live/api/v1/turn/credentials?apiKey=205de2914a8564e2efa19a7d7f299a95e574" "https://nulo.metered.live/api/v1/turn/credentials?apiKey=205de2914a8564e2efa19a7d7f299a95e574",
).then((res) => res.json()); ).then((res) => res.json());
export function getWorldY(world: WorldIdentifier): WorldY { export function getWorldY(world: WorldIdentifier): WorldY {

View file

@ -24,6 +24,6 @@ export function lastUpdated(ydoc: Doc) {
} }
return map; return map;
}, },
() => observers.forEach(({ y, observer }) => y.unobserveDeep(observer)) () => observers.forEach(({ y, observer }) => y.unobserveDeep(observer)),
)(ydoc); )(ydoc);
} }

View file

@ -6,9 +6,9 @@ export function makeYdocStore<T>(
update: Uint8Array | null, update: Uint8Array | null,
origin: any, origin: any,
ydoc: Doc, ydoc: Doc,
tr: Transaction | null tr: Transaction | null,
) => T, ) => T,
unhandler?: () => void unhandler?: () => void,
) { ) {
return (ydoc: Doc): Readable<T> => { return (ydoc: Doc): Readable<T> => {
// thanks https://github.com/relm-us/svelt-yjs/blob/main/src/types/array.ts // thanks https://github.com/relm-us/svelt-yjs/blob/main/src/types/array.ts
@ -18,7 +18,7 @@ export function makeYdocStore<T>(
update: Uint8Array | null, update: Uint8Array | null,
origin: any, origin: any,
ydoc: Doc, ydoc: Doc,
tr: Transaction | null tr: Transaction | null,
) { ) {
run(handler(update, origin, ydoc, tr)); run(handler(update, origin, ydoc, tr));
} }

View file

@ -27,6 +27,6 @@ export function titleStore(ydoc, id) {
return title; return title;
}, },
() => observer && y?.unobserveDeep(observer) () => observer && y?.unobserveDeep(observer),
)(ydoc); )(ydoc);
} }

View file

@ -14,7 +14,7 @@ export function loadWorlds(): Promise<WorldIdentifier[]> {
} }
export async function writeWorlds( export async function writeWorlds(
callback: (worlds: WorldIdentifier[]) => WorldIdentifier[] callback: (worlds: WorldIdentifier[]) => WorldIdentifier[],
): Promise<WorldIdentifier[]> { ): Promise<WorldIdentifier[]> {
const oldWorlds = await loadWorlds(); const oldWorlds = await loadWorlds();
const newWorlds = callback(oldWorlds); const newWorlds = callback(oldWorlds);