@jant/core 0.3.42 → 0.3.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/import-site.js +1 -1
- package/bin/commands/search-reindex.js +175 -0
- package/bin/lib/hugo-markdown.js +102 -0
- package/bin/lib/site-pull-media.js +1 -4
- package/dist/app-BI9bnCkO.js +5 -0
- package/dist/{app-Cu3lveYI.js → app-CtJDxZBb.js} +969 -373
- package/dist/client/.vite/manifest.json +2 -2
- package/dist/client/_assets/client-BQH7AQ24.css +2 -0
- package/dist/client/_assets/{client-auth-BRFl5zQA.js → client-auth-CXILhW1b.js} +144 -144
- package/dist/{env-wCpMcNXs.js → env-CgaH9Mut.js} +1 -1
- package/dist/{github-api-CficQztC.js → github-api-BkRWnqMx.js} +1 -1
- package/dist/{github-app-F4qZ05xk.js → github-app-WeadXMb8.js} +1 -1
- package/dist/{github-sync-zohnA9qv.js → github-sync-7y_nTXx1.js} +41 -14
- package/dist/index.js +5 -5
- package/dist/node.js +5 -5
- package/dist/{url-FvvgARU9.js → url-umUptr5z.js} +30 -1
- package/package.json +1 -1
- package/src/__tests__/helpers/app.ts +15 -4
- package/src/app.tsx +8 -0
- package/src/client/tiptap/__tests__/insert-paragraph-around.test.ts +228 -0
- package/src/client/tiptap/extensions.ts +3 -0
- package/src/client/tiptap/insert-paragraph-around.ts +79 -0
- package/src/db/migrations/0018_yummy_franklin_richards.sql +6 -0
- package/src/db/migrations/0019_bored_magus.sql +2 -0
- package/src/db/migrations/meta/0018_snapshot.json +2225 -0
- package/src/db/migrations/meta/0019_snapshot.json +2238 -0
- package/src/db/migrations/meta/_journal.json +15 -1
- package/src/db/migrations/pg/0016_familiar_lionheart.sql +6 -0
- package/src/db/migrations/pg/0017_bright_beyonder.sql +2 -0
- package/src/db/migrations/pg/meta/0016_snapshot.json +2840 -0
- package/src/db/migrations/pg/meta/0017_snapshot.json +2862 -0
- package/src/db/migrations/pg/meta/_journal.json +15 -1
- package/src/db/pg/schema.ts +22 -0
- package/src/db/schema.ts +27 -0
- package/src/index.ts +1 -2
- package/src/lib/__tests__/hosted-signin.test.ts +30 -0
- package/src/lib/__tests__/navigation.test.ts +4 -20
- package/src/lib/__tests__/rate-limit-d1.test.ts +82 -0
- package/src/lib/__tests__/rate-limit-memory.test.ts +69 -0
- package/src/lib/__tests__/summary.test.ts +140 -0
- package/src/lib/__tests__/view.test.ts +66 -0
- package/src/lib/feed.ts +70 -34
- package/src/lib/hosted-signin.ts +9 -3
- package/src/lib/icons.ts +37 -0
- package/src/lib/navigation.ts +11 -12
- package/src/lib/post-meta.ts +20 -2
- package/src/lib/rate-limit-d1.ts +99 -0
- package/src/lib/rate-limit-memory.ts +105 -0
- package/src/lib/rate-limit.ts +63 -0
- package/src/lib/render.tsx +9 -0
- package/src/lib/resolve-config.ts +9 -0
- package/src/lib/summary.ts +42 -7
- package/src/lib/url.ts +34 -0
- package/src/lib/view.ts +42 -8
- package/src/middleware/__tests__/auth.test.ts +44 -4
- package/src/middleware/__tests__/rate-limit.test.ts +113 -0
- package/src/middleware/__tests__/session.test.ts +85 -0
- package/src/middleware/auth.ts +62 -25
- package/src/middleware/rate-limit.ts +54 -0
- package/src/middleware/session.ts +36 -0
- package/src/routes/__tests__/compose.test.ts +1 -1
- package/src/routes/api/__tests__/search.test.ts +48 -0
- package/src/routes/api/__tests__/upload-multipart.test.ts +11 -4
- package/src/routes/api/internal/search-reindex.ts +40 -0
- package/src/routes/api/internal/sites.ts +1 -0
- package/src/routes/api/search.ts +13 -0
- package/src/routes/auth/dev.ts +1 -1
- package/src/routes/auth/signin.tsx +23 -5
- package/src/routes/dash/settings.tsx +3 -5
- package/src/routes/feed/__tests__/sitemap.test.ts +320 -4
- package/src/routes/feed/sitemap.ts +208 -33
- package/src/routes/pages/__tests__/page-canonical.test.ts +101 -0
- package/src/routes/pages/home.tsx +24 -15
- package/src/routes/pages/page.tsx +34 -0
- package/src/routes/pages/partials.tsx +4 -15
- package/src/runtime/cloudflare.ts +4 -0
- package/src/runtime/node.ts +16 -0
- package/src/services/__tests__/post.test.ts +205 -0
- package/src/services/__tests__/search.test.ts +44 -0
- package/src/services/__tests__/site-admin.test.ts +85 -0
- package/src/services/export.ts +9 -2
- package/src/services/post.ts +200 -2
- package/src/services/site-admin.ts +66 -1
- package/src/styles/ui.css +12 -0
- package/src/types/app-context.ts +20 -0
- package/src/types/config.ts +8 -0
- package/src/types/props.ts +0 -7
- package/src/ui/feed/LinkCard.tsx +3 -20
- package/src/ui/feed/LinkPreview.tsx +5 -19
- package/src/ui/feed/PostStatusBadges.tsx +4 -38
- package/src/ui/layouts/BaseLayout.tsx +23 -29
- package/src/ui/shared/DecorativeQuoteMark.tsx +2 -13
- package/src/ui/shared/Icon.tsx +60 -0
- package/src/ui/shared/IconSprite.tsx +57 -0
- package/src/ui/shared/PostFooter.tsx +6 -62
- package/src/ui/shared/custom-icons.ts +132 -0
- package/src/ui/shared/icon-collector.ts +37 -0
- package/dist/app-DzCB4yOp.js +0 -5
- package/dist/client/_assets/client-C_kImWZj.css +0 -2
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insert Paragraph Around Extension
|
|
3
|
+
*
|
|
4
|
+
* Lets the author create breathing room around hard-to-escape top-level
|
|
5
|
+
* blocks like blockquotes, headings, lists, and code blocks.
|
|
6
|
+
*
|
|
7
|
+
* - ArrowUp / ArrowLeft at the very start of the document's first block
|
|
8
|
+
* inserts an empty paragraph above it and moves the cursor there, but
|
|
9
|
+
* only when that first block is not already a paragraph. Without this,
|
|
10
|
+
* the cursor has nowhere to go above a top-level blockquote — "start of
|
|
11
|
+
* the doc" resolves to the start of the first child's content and
|
|
12
|
+
* pressing ArrowUp does nothing.
|
|
13
|
+
* - Mod-Shift-Enter inserts an empty paragraph before the current
|
|
14
|
+
* top-level block from anywhere inside it.
|
|
15
|
+
* - Mod-Alt-Enter does the same after the current top-level block.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { Extension, type Editor } from "@tiptap/core";
|
|
19
|
+
import { TextSelection } from "@tiptap/pm/state";
|
|
20
|
+
|
|
21
|
+
function insertAroundTopBlock(
|
|
22
|
+
editor: Editor,
|
|
23
|
+
placement: "above" | "below",
|
|
24
|
+
): boolean {
|
|
25
|
+
const { state } = editor;
|
|
26
|
+
const paragraphType = state.schema.nodes.paragraph;
|
|
27
|
+
if (!paragraphType) return false;
|
|
28
|
+
|
|
29
|
+
const { selection } = state;
|
|
30
|
+
const { $from, $to } = selection;
|
|
31
|
+
|
|
32
|
+
// When the selection is on the doc itself (NodeSelection of a top-level
|
|
33
|
+
// atom, or a GapCursor) $from.depth is 0 and $from.before(1) would throw.
|
|
34
|
+
// Fall back to the selection edges in that case.
|
|
35
|
+
let insertPos: number;
|
|
36
|
+
if ($from.depth === 0) {
|
|
37
|
+
insertPos = placement === "above" ? selection.from : selection.to;
|
|
38
|
+
} else {
|
|
39
|
+
insertPos = placement === "above" ? $from.before(1) : $to.after(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const tr = state.tr.insert(insertPos, paragraphType.create());
|
|
43
|
+
tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));
|
|
44
|
+
editor.view.dispatch(tr.scrollIntoView());
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const InsertParagraphAround = Extension.create({
|
|
49
|
+
name: "insertParagraphAround",
|
|
50
|
+
|
|
51
|
+
addKeyboardShortcuts() {
|
|
52
|
+
const escapeFromDocStart = ({ editor }: { editor: Editor }) => {
|
|
53
|
+
const { state } = editor;
|
|
54
|
+
const { selection } = state;
|
|
55
|
+
if (!selection.empty) return false;
|
|
56
|
+
|
|
57
|
+
const { $from } = selection;
|
|
58
|
+
// Only fire at the very first position inside the first top-level
|
|
59
|
+
// block. $from.depth >= 1 rules out gap cursors at the doc boundary,
|
|
60
|
+
// and $from.pos === $from.depth means every ancestor index from doc
|
|
61
|
+
// down is 0 and the cursor is at parentOffset 0 — i.e. no text or
|
|
62
|
+
// sibling could plausibly receive the caret to our left / above.
|
|
63
|
+
if ($from.depth < 1) return false;
|
|
64
|
+
if ($from.pos !== $from.depth) return false;
|
|
65
|
+
|
|
66
|
+
const firstBlock = state.doc.firstChild;
|
|
67
|
+
if (!firstBlock || firstBlock.type.name === "paragraph") return false;
|
|
68
|
+
|
|
69
|
+
return insertAroundTopBlock(editor, "above");
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
ArrowUp: escapeFromDocStart,
|
|
74
|
+
ArrowLeft: escapeFromDocStart,
|
|
75
|
+
"Mod-Shift-Enter": ({ editor }) => insertAroundTopBlock(editor, "above"),
|
|
76
|
+
"Mod-Alt-Enter": ({ editor }) => insertAroundTopBlock(editor, "below"),
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
});
|