1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-03-10 08:25:19 +00:00

Compare commits

..

No commits in common. "3ea90fbd06ea430207b6aae47cbfa09f9ce1b614" and "ae22560a8751a41d46113ffc1ebb55126b0f9755" have entirely different histories.

5 changed files with 6 additions and 16 deletions

View file

@ -38,9 +38,7 @@ export default () => {
<a href="/new">📄</a> <a href="/new">📄</a>
</header> </header>
{routes[pathname()] ?? ( {routes[pathname()] ?? (
<Page <Page id={Number(pathname().slice(1)) || random()} />
id={parseInt(pathname().slice(1), 16) || random()}
/>
)} )}
</> </>
); );

View file

@ -1,5 +1,4 @@
import { import {
$createLineBreakNode,
$createParagraphNode, $createParagraphNode,
$createTextNode, $createTextNode,
$getRoot, $getRoot,
@ -26,11 +25,8 @@ export default (props: {
const root = $getRoot(); const root = $getRoot();
if (root.getFirstChild()) return; if (root.getFirstChild()) return;
const paragraphNode = $createParagraphNode(); const paragraphNode = $createParagraphNode();
const text = props.text const textNode = $createTextNode(props.text);
.split("\n") paragraphNode.append(textNode);
.flatMap((line) => [$createTextNode(line), $createLineBreakNode()])
.slice(0, -1);
paragraphNode.append(...text);
root.append(paragraphNode); root.append(paragraphNode);
}; };
onCleanup(registerPlainText(editor, initialEditorState)); onCleanup(registerPlainText(editor, initialEditorState));

View file

@ -1,5 +1,5 @@
function random(): number { function random(): number {
return 0x7f_ff_ff_ff & window.crypto.getRandomValues(new Uint32Array(1))[0]!; return window.crypto.getRandomValues(new Uint16Array(1))[0]!;
} }
export default random; export default random;

View file

@ -20,7 +20,7 @@ export default () => {
<Cards> <Cards>
<For each={pages()}> <For each={pages()}>
{(page) => ( {(page) => (
<a href={`/${page.id.toString(16)}`}> <a href={`/${page.id}`}>
<Card {...page} /> <Card {...page} />
</a> </a>
)} )}

View file

@ -44,11 +44,7 @@ export default (props: { id: number }) => {
async (id: number, content: Pages.RequestContentPage) => { async (id: number, content: Pages.RequestContentPage) => {
if (await (content.text ? updatePage(id, content) : deletePage(id))) { if (await (content.text ? updatePage(id, content) : deletePage(id))) {
unblock(); unblock();
window.history.replaceState( window.history.replaceState({}, "", `/${content.text ? id : "new"}`);
{},
"",
`/${content.text ? id.toString(16) : "new"}`
);
} }
}, },
intervalMs intervalMs