full switch to jotai, finishes schema version query fixes
This commit is contained in:
parent
b529445851
commit
84cbea8ce1
2
.gitignore
vendored
2
.gitignore
vendored
@ -43,3 +43,5 @@ temp.json
|
|||||||
temp.md
|
temp.md
|
||||||
|
|
||||||
.dragonshoard/
|
.dragonshoard/
|
||||||
|
|
||||||
|
certificates
|
@ -3,33 +3,70 @@ import { auth } from "@/auth";
|
|||||||
import { isEmailVerified } from "@/util/isEmailVerified";
|
import { isEmailVerified } from "@/util/isEmailVerified";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { prisma } from "@/prisma/prismaClient";
|
import { prisma } from "@/prisma/prismaClient";
|
||||||
|
import { Schema } from "@/types";
|
||||||
|
|
||||||
export const saveSchemaDb = async (s: Schema) => {
|
export const saveSchemaDb = async (s: Schema, version: number) => {
|
||||||
const sesh = await auth();
|
const sesh = await auth();
|
||||||
if (!sesh?.user?.id) return;
|
if (!sesh?.user?.id) return;
|
||||||
|
|
||||||
const { id } = await prisma.schema.upsert({
|
const { id, SchemaRevision } = await prisma.schema.upsert({
|
||||||
// data: {
|
// data: {
|
||||||
// ...s,
|
// ...s,
|
||||||
// },
|
// },
|
||||||
create: {
|
create: {
|
||||||
...s,
|
name: s.name,
|
||||||
version: 0,
|
SchemaRevision: {
|
||||||
|
create: {
|
||||||
|
fields: s.fields,
|
||||||
|
types: s.types,
|
||||||
|
},
|
||||||
|
},
|
||||||
authorId: sesh.user.id,
|
authorId: sesh.user.id,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
},
|
},
|
||||||
update: s,
|
update: {
|
||||||
|
name: s.name,
|
||||||
|
},
|
||||||
where: {
|
where: {
|
||||||
id: s.id,
|
id: s.id,
|
||||||
},
|
},
|
||||||
|
include: {
|
||||||
|
// id: true,
|
||||||
|
SchemaRevision: {
|
||||||
|
where: {
|
||||||
|
version: s.version,
|
||||||
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
version: true,
|
||||||
|
isFinal: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// const schema2 = await prisma.schema.findUnique({where:{id}})
|
||||||
|
if (
|
||||||
|
!SchemaRevision.at(0) ||
|
||||||
|
SchemaRevision[0].version < version ||
|
||||||
|
SchemaRevision[0].isFinal
|
||||||
|
) {
|
||||||
|
await prisma.schemaRevision.create({
|
||||||
|
data: {
|
||||||
|
schemaId: id,
|
||||||
|
types: s.types,
|
||||||
|
fields: s.fields,
|
||||||
|
version,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
redirect(`/game-systems/${s.gameSystemId}/schema/${id}`);
|
redirect(`/game-systems/${s.gameSystemId}/schema/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findSchema = async (id: string): Promise<Schema | null> => {
|
export const findSchema = async (
|
||||||
|
id: string,
|
||||||
|
version: number,
|
||||||
|
): Promise<Schema | null> => {
|
||||||
const schema = await prisma.schema.findFirst({
|
const schema = await prisma.schema.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
@ -42,17 +79,33 @@ export const findSchema = async (id: string): Promise<Schema | null> => {
|
|||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
|
include: {
|
||||||
|
SchemaRevision: {
|
||||||
|
where: {
|
||||||
|
version,
|
||||||
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
version: true,
|
||||||
name: true,
|
fields: true,
|
||||||
schema: true,
|
|
||||||
types: true,
|
types: true,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// select: {
|
||||||
|
// id: true,
|
||||||
|
// name: true,
|
||||||
|
// },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!schema) return null;
|
if (!schema?.SchemaRevision[0]) return null;
|
||||||
|
|
||||||
return schema as Schema;
|
return {
|
||||||
|
fields: schema.SchemaRevision[0].fields,
|
||||||
|
types: schema.SchemaRevision[0].types,
|
||||||
|
id: schema.id,
|
||||||
|
gameSystemId: schema.gameSystemId,
|
||||||
|
name: schema.name,
|
||||||
|
} as Schema;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createSchema = async (form: FormData) => {
|
export const createSchema = async (form: FormData) => {
|
||||||
@ -67,9 +120,6 @@ export const createSchema = async (form: FormData) => {
|
|||||||
const { id } = await prisma.schema.create({
|
const { id } = await prisma.schema.create({
|
||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
schema: "{}",
|
|
||||||
types: "{}",
|
|
||||||
version: 0,
|
|
||||||
gameSystemId: gsId,
|
gameSystemId: gsId,
|
||||||
authorId: session.user.id,
|
authorId: session.user.id,
|
||||||
},
|
},
|
||||||
|
@ -20,6 +20,8 @@ export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
|
|||||||
Discord({
|
Discord({
|
||||||
clientId,
|
clientId,
|
||||||
clientSecret,
|
clientSecret,
|
||||||
|
// redirectProxyUrl:
|
||||||
|
// "https://bottomsurgery.local:3000/api/auth/callback/discord",
|
||||||
}),
|
}),
|
||||||
Credentials({
|
Credentials({
|
||||||
credentials: {
|
credentials: {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
// import { useRecoilValue } from "recoil";
|
|
||||||
import { SchemaEditAtom } from "../../recoil/atoms/schema";
|
import { SchemaEditAtom } from "../../recoil/atoms/schema";
|
||||||
import { TEMPLATE_TYPES } from "../../constants/TemplateTypes";
|
import { TEMPLATE_TYPES } from "../../constants/TemplateTypes";
|
||||||
import { FC, PropsWithChildren } from "react";
|
import { FC, PropsWithChildren } from "react";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
|
import { InputBinder } from "@/types";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
bind: InputBinder;
|
bind: InputBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FieldTypeInput: FC<PropsWithChildren<IProps>> = ({ bind }) => {
|
export const FieldTypeInput: FC<PropsWithChildren<IProps>> = ({ bind }) => {
|
||||||
// const schema = useRecoilValue(SchemaEditAtom);
|
|
||||||
const [schema] = useAtom(SchemaEditAtom);
|
const [schema] = useAtom(SchemaEditAtom);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -14,10 +14,10 @@ import { FieldTypes } from "./fieldtypes";
|
|||||||
import { findSchema, saveSchemaDb } from "@/actions/Schemas/index";
|
import { findSchema, saveSchemaDb } from "@/actions/Schemas/index";
|
||||||
import { useToast } from "../toast";
|
import { useToast } from "../toast";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { Schema } from "@/types";
|
import { Schema, TypeType } from "@/types";
|
||||||
|
|
||||||
export const SchemaBuilder: FC = () => {
|
export const SchemaBuilder: FC = () => {
|
||||||
const [schema, setSchema] = useAtom(SchemaEditAtom);
|
const [schema, setSchema] = useAtom<Schema>(SchemaEditAtom);
|
||||||
// const resetSchema = useResetRecoilState(SchemaEditAtom);
|
// const resetSchema = useResetRecoilState(SchemaEditAtom);
|
||||||
const { createToast } = useToast();
|
const { createToast } = useToast();
|
||||||
const { update: updateSchema, bindProperty: bindSchemaProperty } =
|
const { update: updateSchema, bindProperty: bindSchemaProperty } =
|
||||||
@ -30,7 +30,7 @@ export const SchemaBuilder: FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (schemaId !== "create" && schemaId !== schema.id)
|
if (schemaId !== "create" && schemaId !== schema.id)
|
||||||
findSchema(schemaId).then((sc) => {
|
findSchema(schemaId, 0).then((sc) => {
|
||||||
if (!sc) return;
|
if (!sc) return;
|
||||||
setSchema(sc);
|
setSchema(sc);
|
||||||
});
|
});
|
||||||
@ -70,7 +70,7 @@ export const SchemaBuilder: FC = () => {
|
|||||||
|
|
||||||
const saveSchema = useCallback(async () => {
|
const saveSchema = useCallback(async () => {
|
||||||
createToast({ msg: "Saving Schema", fading: true });
|
createToast({ msg: "Saving Schema", fading: true });
|
||||||
await saveSchemaDb(schema);
|
await saveSchemaDb(schema, schema.version);
|
||||||
}, [createToast, schema]);
|
}, [createToast, schema]);
|
||||||
|
|
||||||
const selectTypeForEdit = useCallback((typeKey: string) => {
|
const selectTypeForEdit = useCallback((typeKey: string) => {
|
||||||
|
@ -17,6 +17,13 @@ export default function SignIn() {
|
|||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
role="button"
|
||||||
|
type="submit"
|
||||||
|
className="w-full p-2 rounded-lg bg-primary-500"
|
||||||
|
>
|
||||||
|
Sign In
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<div className="dark:border-dark-500 border-primary-600 flex-grow border-b"></div>
|
<div className="dark:border-dark-500 border-primary-600 flex-grow border-b"></div>
|
||||||
@ -24,7 +31,10 @@ export default function SignIn() {
|
|||||||
<div className="dark:border-dark-500 border-primary-600 flex-grow border-b"></div>
|
<div className="dark:border-dark-500 border-primary-600 flex-grow border-b"></div>
|
||||||
</div>
|
</div>
|
||||||
<form action={signInWithDiscord}>
|
<form action={signInWithDiscord}>
|
||||||
<button className="w-full p-2 bg-[#816ab1] rounded-lg" type="submit">
|
<button
|
||||||
|
className="w-full p-2 bg-[#816ab1] rounded-lg flex items-center justify-center"
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
<Icon icon="Discord" className="mr-4 inline-block" />
|
<Icon icon="Discord" className="mr-4 inline-block" />
|
||||||
Sign in with Discord
|
Sign in with Discord
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { PublicationAtom } from "@/recoil/atoms/publication";
|
import { PublicationAtom } from "@/recoil/atoms/publication";
|
||||||
import { useState, useEffect, useCallback, useRef, ReactNode } from "react";
|
import { useState, useEffect, useCallback, useRef, ReactNode } from "react";
|
||||||
import { useRecoilValue } from "recoil";
|
|
||||||
import { TTCQueryResolver } from "../ttcQuery/TTCResolvers";
|
import { TTCQueryResolver } from "../ttcQuery/TTCResolvers";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
|
||||||
export function Resolver({ resolver }: { resolver: string }) {
|
export function Resolver({ resolver }: { resolver: string }) {
|
||||||
const parser = useRecoilValue(PublicationAtom);
|
const [parser] = useAtom(PublicationAtom);
|
||||||
const [res] = useState(new TTCQueryResolver(parser));
|
const [res] = useState(new TTCQueryResolver(parser));
|
||||||
const [content, setContent] = useState<ReactNode>("");
|
const [content, setContent] = useState<ReactNode>("");
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -15,7 +15,7 @@ export function Resolver({ resolver }: { resolver: string }) {
|
|||||||
<resolved.display />
|
<resolved.display />
|
||||||
) : (
|
) : (
|
||||||
resolved?.display
|
resolved?.display
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}, [resolver, res]);
|
}, [resolver, res]);
|
||||||
return <span>{content}</span>;
|
return <span>{content}</span>;
|
||||||
@ -31,7 +31,7 @@ export function OnDemandResolver({
|
|||||||
template: string;
|
template: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
}) {
|
}) {
|
||||||
const parser = useRecoilValue(PublicationAtom);
|
const [parser] = useAtom(PublicationAtom);
|
||||||
const res = useRef(new TTCQueryResolver(parser));
|
const res = useRef(new TTCQueryResolver(parser));
|
||||||
const [content, setContent] = useState<ReactNode>("");
|
const [content, setContent] = useState<ReactNode>("");
|
||||||
const generateContent = useCallback(() => {
|
const generateContent = useCallback(() => {
|
||||||
|
@ -5,11 +5,13 @@ import { Poppable } from "../poppables/components/poppable";
|
|||||||
import { Accordion, AccordionContent } from "../accordion";
|
import { Accordion, AccordionContent } from "../accordion";
|
||||||
import { OnDemandResolver, Resolver } from "./Resolver";
|
import { OnDemandResolver, Resolver } from "./Resolver";
|
||||||
|
|
||||||
|
// import "crypto";
|
||||||
|
|
||||||
export const TokenRenderers = new Map<string, TokenRenderer<any>>();
|
export const TokenRenderers = new Map<string, TokenRenderer<any>>();
|
||||||
|
|
||||||
export function buildIdentifierMap(): [
|
export function buildIdentifierMap(): [
|
||||||
TokenIdentifierMap,
|
TokenIdentifierMap,
|
||||||
IdentifierRegistration
|
IdentifierRegistration,
|
||||||
] {
|
] {
|
||||||
const TokenIdentifiers = new Map<string, TokenIdentifier<any>>();
|
const TokenIdentifiers = new Map<string, TokenIdentifier<any>>();
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ export function buildIdentifierMap(): [
|
|||||||
type: string,
|
type: string,
|
||||||
match: RegExp,
|
match: RegExp,
|
||||||
parseFunction: (s: string, rx: RegExp) => IdentifiedToken<M>,
|
parseFunction: (s: string, rx: RegExp) => IdentifiedToken<M>,
|
||||||
renderFunction: TokenRenderer<M>
|
renderFunction: TokenRenderer<M>,
|
||||||
): void;
|
): void;
|
||||||
function registerIdentifier<M>(
|
function registerIdentifier<M>(
|
||||||
type: string,
|
type: string,
|
||||||
@ -25,7 +27,7 @@ export function buildIdentifierMap(): [
|
|||||||
parseFunction: (s: string, rx: RegExp) => IdentifiedToken<M>,
|
parseFunction: (s: string, rx: RegExp) => IdentifiedToken<M>,
|
||||||
renderFunction: TokenRenderer<M>,
|
renderFunction: TokenRenderer<M>,
|
||||||
openTagRx: RegExp,
|
openTagRx: RegExp,
|
||||||
closeTagRx: RegExp
|
closeTagRx: RegExp,
|
||||||
): void;
|
): void;
|
||||||
function registerIdentifier<M = Record<string, string>>(
|
function registerIdentifier<M = Record<string, string>>(
|
||||||
type: string,
|
type: string,
|
||||||
@ -33,7 +35,7 @@ export function buildIdentifierMap(): [
|
|||||||
parseFunction: (s: string, rx: RegExp) => IdentifiedToken<M>,
|
parseFunction: (s: string, rx: RegExp) => IdentifiedToken<M>,
|
||||||
renderFunction: TokenRenderer<M>,
|
renderFunction: TokenRenderer<M>,
|
||||||
openTagRx?: RegExp,
|
openTagRx?: RegExp,
|
||||||
closeTagRx?: RegExp
|
closeTagRx?: RegExp,
|
||||||
) {
|
) {
|
||||||
TokenIdentifiers.set(type, {
|
TokenIdentifiers.set(type, {
|
||||||
rx: match,
|
rx: match,
|
||||||
@ -54,7 +56,7 @@ export function buildIdentifierMap(): [
|
|||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
new RegExp(openTagRx, "g"),
|
new RegExp(openTagRx, "g"),
|
||||||
new RegExp(closeTagRx, "g")
|
new RegExp(closeTagRx, "g"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
@ -125,7 +127,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
/(?<![\/\?])(?:\[\])+/g,
|
/(?<![\/\?])(?:\[\])+/g,
|
||||||
/\/\[\]/g
|
/\/\[\]/g,
|
||||||
);
|
);
|
||||||
|
|
||||||
// card
|
// card
|
||||||
@ -170,7 +172,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
/\[\[/g,
|
/\[\[/g,
|
||||||
/\]\]/g
|
/\]\]/g,
|
||||||
);
|
);
|
||||||
|
|
||||||
// fenced code block
|
// fenced code block
|
||||||
@ -192,7 +194,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
{token.content}
|
{token.content}
|
||||||
</pre>
|
</pre>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// list
|
// list
|
||||||
@ -231,7 +233,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
</ul>
|
</ul>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// ordered-list
|
// ordered-list
|
||||||
@ -271,7 +273,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
</ol>
|
</ol>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// ordered list-item
|
// ordered list-item
|
||||||
@ -300,7 +302,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
))}
|
))}
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// heading
|
// heading
|
||||||
@ -336,7 +338,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
{token.content}
|
{token.content}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// image
|
// image
|
||||||
@ -373,7 +375,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
}
|
}
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
return <img src={metadata.src} alt={token.content} />;
|
return <img src={metadata.src} alt={token.content} />;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// anchor
|
// anchor
|
||||||
@ -417,7 +419,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
{token.content}
|
{token.content}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// inline-code
|
// inline-code
|
||||||
@ -440,7 +442,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
{token.content}
|
{token.content}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// bold
|
// bold
|
||||||
@ -458,7 +460,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
},
|
},
|
||||||
(token) => {
|
(token) => {
|
||||||
return <span className="font-bold">{token.content}</span>;
|
return <span className="font-bold">{token.content}</span>;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// italic
|
// italic
|
||||||
@ -477,7 +479,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
},
|
},
|
||||||
(token) => {
|
(token) => {
|
||||||
return <span className="italic">{token.content}</span>;
|
return <span className="italic">{token.content}</span>;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// popover
|
// popover
|
||||||
@ -513,7 +515,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
</span>
|
</span>
|
||||||
</Poppable>
|
</Poppable>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// accordion
|
// accordion
|
||||||
@ -543,7 +545,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
</Accordion>
|
</Accordion>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// paragraph
|
// paragraph
|
||||||
@ -569,7 +571,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// horizontal rule
|
// horizontal rule
|
||||||
@ -587,7 +589,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
return <div className="w-full border-b border-mixed-500 my-3"></div>;
|
return <div className="w-full border-b border-mixed-500 my-3"></div>;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// comment
|
// comment
|
||||||
@ -605,7 +607,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// frontmatter
|
// frontmatter
|
||||||
@ -624,7 +626,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
},
|
},
|
||||||
(token) => {
|
(token) => {
|
||||||
return <>{token.raw}</>;
|
return <>{token.raw}</>;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// table
|
// table
|
||||||
@ -655,8 +657,8 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
r
|
r
|
||||||
.split("|")
|
.split("|")
|
||||||
.map((c) => c.trim())
|
.map((c) => c.trim())
|
||||||
.filter((c) => !!c)
|
.filter((c) => !!c),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let headerRows: string[][] = [],
|
let headerRows: string[][] = [],
|
||||||
@ -679,7 +681,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const maxColumns = Math.max(
|
const maxColumns = Math.max(
|
||||||
...[...headerRows, ...bodyRows, ...footerRows].map((r) => r.length)
|
...[...headerRows, ...bodyRows, ...footerRows].map((r) => r.length),
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -770,7 +772,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
)}
|
)}
|
||||||
</table>
|
</table>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// resolver
|
// resolver
|
||||||
@ -797,7 +799,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
if (t.content.startsWith("Error"))
|
if (t.content.startsWith("Error"))
|
||||||
return <span className="red-500">{t.content}</span>;
|
return <span className="red-500">{t.content}</span>;
|
||||||
return <Resolver resolver={t.content} />;
|
return <Resolver resolver={t.content} />;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// on-demand resolver
|
// on-demand resolver
|
||||||
@ -839,7 +841,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
title={t.metadata.title}
|
title={t.metadata.title}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return TokenIdentifiers;
|
return TokenIdentifiers;
|
||||||
@ -848,7 +850,7 @@ export const buildOnlyDefaultElements = () => {
|
|||||||
function findMatchingClosedParenthesis(
|
function findMatchingClosedParenthesis(
|
||||||
str: string,
|
str: string,
|
||||||
openRegex: RegExp,
|
openRegex: RegExp,
|
||||||
closedRegex: RegExp
|
closedRegex: RegExp,
|
||||||
): number | null {
|
): number | null {
|
||||||
let openings = 0;
|
let openings = 0;
|
||||||
let closings = 0;
|
let closings = 0;
|
||||||
@ -904,7 +906,7 @@ function search(
|
|||||||
start: number,
|
start: number,
|
||||||
end: number,
|
end: number,
|
||||||
openRx: RegExp,
|
openRx: RegExp,
|
||||||
closeRx: RegExp
|
closeRx: RegExp,
|
||||||
): SearchResult {
|
): SearchResult {
|
||||||
const oldEnd = end;
|
const oldEnd = end;
|
||||||
|
|
||||||
@ -912,7 +914,7 @@ function search(
|
|||||||
s,
|
s,
|
||||||
// s.substring(0, end - start),
|
// s.substring(0, end - start),
|
||||||
openRx,
|
openRx,
|
||||||
closeRx
|
closeRx,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (newEnd === null)
|
if (newEnd === null)
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import { TTCQueryParser } from "@/lib/ttcQuery/TTCQueryParser";
|
import { TTCQueryParser } from "@/lib/ttcQuery/TTCQueryParser";
|
||||||
import { atom } from "recoil";
|
import { atom } from "jotai";
|
||||||
|
// import { atom } from "recoil";
|
||||||
|
|
||||||
export const PublicationAtom = atom({
|
// export const PublicationAtom = atom({
|
||||||
key: "publication",
|
// key: "publication",
|
||||||
default: new TTCQueryParser({
|
// default: new TTCQueryParser({
|
||||||
path: { to: { dice: "2d6" } },
|
// path: { to: { dice: "2d6" } },
|
||||||
}),
|
// }),
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
export const PublicationAtom = atom(
|
||||||
|
new TTCQueryParser({ path: { to: { dice: "2d6" } } }),
|
||||||
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// import { atom } from "recoil";
|
// import { atom } from "recoil";
|
||||||
|
|
||||||
|
import { Schema } from "@/types";
|
||||||
import { atom } from "jotai";
|
import { atom } from "jotai";
|
||||||
|
|
||||||
// export const SchemaEditAtom = atom<Schema>({
|
// export const SchemaEditAtom = atom<Schema>({
|
||||||
@ -12,4 +13,5 @@ export const SchemaEditAtom = atom<Schema>({
|
|||||||
id: "",
|
id: "",
|
||||||
types: {},
|
types: {},
|
||||||
fields: {},
|
fields: {},
|
||||||
|
version: 0,
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": [
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"esnext"
|
|
||||||
],
|
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
@ -22,23 +18,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": ["./*"]
|
||||||
"./*"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"target": "es2022"
|
"target": "es2022"
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||||
"next-env.d.ts",
|
"exclude": ["node_modules"],
|
||||||
"**/*.ts",
|
"files": ["global.d.ts", "types.d.ts", "./components/mdeditor/TextEditor.tsx"]
|
||||||
"**/*.tsx",
|
|
||||||
".next/types/**/*.ts",
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"global.d.ts",
|
|
||||||
"./components/mdeditor/TextEditor.tsx"
|
|
||||||
]
|
|
||||||
}
|
}
|
3
types.d.ts
vendored
3
types.d.ts
vendored
@ -87,7 +87,8 @@ type Schema = {
|
|||||||
name: string;
|
name: string;
|
||||||
fields: SchemaFields;
|
fields: SchemaFields;
|
||||||
types: SchemaTypes;
|
types: SchemaTypes;
|
||||||
gameSystemId?: string;
|
version: number;
|
||||||
|
gameSystemId?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Input Binder
|
// Input Binder
|
||||||
|
Loading…
x
Reference in New Issue
Block a user