@connextar/house 0.1.1 → 0.2.0
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/README.md +205 -28
- package/dist/changelog/changelog.d.ts +60 -0
- package/dist/changelog/changelog.d.ts.map +1 -0
- package/dist/changelog/changelog.js +61 -0
- package/dist/changelog/changelog.js.map +1 -0
- package/dist/changelog/index.d.ts +2 -0
- package/dist/changelog/index.d.ts.map +1 -0
- package/dist/changelog/index.js +2 -0
- package/dist/changelog/index.js.map +1 -0
- package/dist/editor/block-handle.d.ts +15 -0
- package/dist/editor/block-handle.d.ts.map +1 -0
- package/dist/editor/block-handle.js +106 -0
- package/dist/editor/block-handle.js.map +1 -0
- package/dist/editor/blocks.d.ts +35 -0
- package/dist/editor/blocks.d.ts.map +1 -0
- package/dist/editor/blocks.js +114 -0
- package/dist/editor/blocks.js.map +1 -0
- package/dist/editor/bubble-toolbar.d.ts +11 -0
- package/dist/editor/bubble-toolbar.d.ts.map +1 -0
- package/dist/editor/bubble-toolbar.js +87 -0
- package/dist/editor/bubble-toolbar.js.map +1 -0
- package/dist/editor/content-index.d.ts +2 -0
- package/dist/editor/content-index.d.ts.map +1 -0
- package/dist/editor/content-index.js +2 -0
- package/dist/editor/content-index.js.map +1 -0
- package/dist/editor/content.d.ts +30 -0
- package/dist/editor/content.d.ts.map +1 -0
- package/dist/editor/content.js +256 -0
- package/dist/editor/content.js.map +1 -0
- package/dist/editor/editor.d.ts +52 -0
- package/dist/editor/editor.d.ts.map +1 -0
- package/dist/editor/editor.js +160 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/emoji-index.d.ts +2 -0
- package/dist/editor/emoji-index.d.ts.map +1 -0
- package/dist/editor/emoji-index.js +2 -0
- package/dist/editor/emoji-index.js.map +1 -0
- package/dist/editor/emoji-picker.d.ts +16 -0
- package/dist/editor/emoji-picker.d.ts.map +1 -0
- package/dist/editor/emoji-picker.js +37 -0
- package/dist/editor/emoji-picker.js.map +1 -0
- package/dist/editor/emoji.d.ts +18 -0
- package/dist/editor/emoji.d.ts.map +1 -0
- package/dist/editor/emoji.js +418 -0
- package/dist/editor/emoji.js.map +1 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +6 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/suggestion-popup.d.ts +17 -0
- package/dist/editor/suggestion-popup.d.ts.map +1 -0
- package/dist/editor/suggestion-popup.js +57 -0
- package/dist/editor/suggestion-popup.js.map +1 -0
- package/dist/editor/suggestions.d.ts +93 -0
- package/dist/editor/suggestions.d.ts.map +1 -0
- package/dist/editor/suggestions.js +179 -0
- package/dist/editor/suggestions.js.map +1 -0
- package/dist/editor/ui.d.ts +54 -0
- package/dist/editor/ui.d.ts.map +1 -0
- package/dist/editor/ui.js +58 -0
- package/dist/editor/ui.js.map +1 -0
- package/dist/house.css +267 -0
- package/dist/internal/cx.d.ts +3 -0
- package/dist/internal/cx.d.ts.map +1 -0
- package/dist/internal/cx.js +5 -0
- package/dist/internal/cx.js.map +1 -0
- package/dist/internal/next-link.d.ts +23 -0
- package/dist/internal/next-link.d.ts.map +1 -0
- package/dist/internal/next-link.js +3 -0
- package/dist/internal/next-link.js.map +1 -0
- package/dist/markdown/guide.d.ts +98 -0
- package/dist/markdown/guide.d.ts.map +1 -0
- package/dist/markdown/guide.js +328 -0
- package/dist/markdown/guide.js.map +1 -0
- package/dist/markdown/index.d.ts +4 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +4 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/markdown/table-view.d.ts +28 -0
- package/dist/markdown/table-view.d.ts.map +1 -0
- package/dist/markdown/table-view.js +25 -0
- package/dist/markdown/table-view.js.map +1 -0
- package/dist/markdown/table.d.ts +35 -0
- package/dist/markdown/table.d.ts.map +1 -0
- package/dist/markdown/table.js +79 -0
- package/dist/markdown/table.js.map +1 -0
- package/dist/release/changelog.d.ts +72 -0
- package/dist/release/changelog.d.ts.map +1 -0
- package/dist/release/changelog.js +92 -0
- package/dist/release/changelog.js.map +1 -0
- package/dist/release/index.d.ts +3 -0
- package/dist/release/index.d.ts.map +1 -0
- package/dist/release/index.js +3 -0
- package/dist/release/index.js.map +1 -0
- package/dist/release/version.d.ts +33 -0
- package/dist/release/version.d.ts.map +1 -0
- package/dist/release/version.js +57 -0
- package/dist/release/version.js.map +1 -0
- package/dist/trail/index.d.ts +3 -0
- package/dist/trail/index.d.ts.map +1 -0
- package/dist/trail/index.js +3 -0
- package/dist/trail/index.js.map +1 -0
- package/dist/trail/rules.d.ts +44 -0
- package/dist/trail/rules.d.ts.map +1 -0
- package/dist/trail/rules.js +74 -0
- package/dist/trail/rules.js.map +1 -0
- package/dist/trail/trail.d.ts +49 -0
- package/dist/trail/trail.d.ts.map +1 -0
- package/dist/trail/trail.js +188 -0
- package/dist/trail/trail.js.map +1 -0
- package/docs/ReleaseProcess.md +315 -0
- package/package.json +75 -11
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Extension, type Editor, type Range } from "@tiptap/core";
|
|
2
|
+
import { type LucideIcon } from "lucide-react";
|
|
3
|
+
/**
|
|
4
|
+
* The character-triggered lookups the editor offers:
|
|
5
|
+
*
|
|
6
|
+
* - `/` opens the block menu — the same list the bubble menu's "Turn into" and
|
|
7
|
+
* each block's grip use, plus a few insert-only actions;
|
|
8
|
+
* - `:` completes an emoji shortcode from the curated set;
|
|
9
|
+
* - `@` references something linkable, and `#` completes a tag — both only when
|
|
10
|
+
* the host app supplies a source, because only the app knows what its people,
|
|
11
|
+
* records and tags are.
|
|
12
|
+
*
|
|
13
|
+
* None of them inserts a custom node. `@` becomes ordinary text carrying an
|
|
14
|
+
* ordinary link mark (`[@label](href)` in Markdown), `#` and `:` become plain
|
|
15
|
+
* text, and `/` converts the current block through the same commands the
|
|
16
|
+
* Markdown input rules use — so the stored Markdown needs no special dialect,
|
|
17
|
+
* survives any renderer, and a server can mirror `@` and `#` by regex without an
|
|
18
|
+
* editor in the loop.
|
|
19
|
+
*/
|
|
20
|
+
/** One row in the suggestion popup — every kind, one shape. */
|
|
21
|
+
export interface SuggestionItem {
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
hint: string | null;
|
|
25
|
+
/** A lucide icon for block/action rows. */
|
|
26
|
+
icon?: LucideIcon;
|
|
27
|
+
/** A literal glyph instead of an icon — an emoji. */
|
|
28
|
+
glyph?: string;
|
|
29
|
+
/** A person: initials (and picture), shown as an avatar. */
|
|
30
|
+
avatar?: {
|
|
31
|
+
initials: string;
|
|
32
|
+
image: string | null;
|
|
33
|
+
};
|
|
34
|
+
/** The heading this row sits under; the popup prints one per run of rows. */
|
|
35
|
+
group?: string;
|
|
36
|
+
/** What accepting this row does to the document. */
|
|
37
|
+
insert: {
|
|
38
|
+
kind: "reference";
|
|
39
|
+
href: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: "text";
|
|
42
|
+
text: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "emoji";
|
|
45
|
+
char: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "block";
|
|
48
|
+
run: (editor: Editor) => void;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Where `@` and `#` get their rows. Omit one and its trigger does nothing. */
|
|
52
|
+
export interface SuggestionSources {
|
|
53
|
+
references?: (query: string) => Promise<SuggestionItem[]>;
|
|
54
|
+
tags?: (query: string) => Promise<SuggestionItem[]>;
|
|
55
|
+
}
|
|
56
|
+
/** What the editor component needs to render and drive the popup. */
|
|
57
|
+
export interface SuggestionSession {
|
|
58
|
+
items: SuggestionItem[];
|
|
59
|
+
clientRect: (() => DOMRect | null) | null;
|
|
60
|
+
command: (item: SuggestionItem) => void;
|
|
61
|
+
}
|
|
62
|
+
export interface SuggestionUiHandle {
|
|
63
|
+
onOpen: (session: SuggestionSession) => void;
|
|
64
|
+
onClose: () => void;
|
|
65
|
+
/** Returns true when the popup consumed the key (arrows, Enter, Escape). */
|
|
66
|
+
onKeyDown: (event: KeyboardEvent) => boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface SuggestionOptions {
|
|
69
|
+
/** Today's date as the `/` menu inserts it. */
|
|
70
|
+
formatDate: (date: Date) => string;
|
|
71
|
+
}
|
|
72
|
+
export declare const DEFAULT_SUGGESTION_OPTIONS: SuggestionOptions;
|
|
73
|
+
export declare function emojiItems(query: string): SuggestionItem[];
|
|
74
|
+
/**
|
|
75
|
+
* The `/` menu: every block type, then the insert-only actions. Filtered by
|
|
76
|
+
* label and keywords so `/todo`, `/h2`, `/date` all land where expected.
|
|
77
|
+
*/
|
|
78
|
+
export declare function slashItems(query: string, sources: SuggestionSources, options: SuggestionOptions): SuggestionItem[];
|
|
79
|
+
/** Apply an accepted row to the document, replacing the trigger text. */
|
|
80
|
+
export declare function applySuggestion(editor: Editor, range: Range, item: SuggestionItem): void;
|
|
81
|
+
/**
|
|
82
|
+
* Every lookup as one extension. `ui` and `sources` are ref-like holders read
|
|
83
|
+
* lazily on every callback, so the extension (created once per editor) always
|
|
84
|
+
* talks to the current render's handlers and the app's current sources.
|
|
85
|
+
*/
|
|
86
|
+
export declare function createSuggestions(ui: {
|
|
87
|
+
current: SuggestionUiHandle;
|
|
88
|
+
}, sources: {
|
|
89
|
+
current: SuggestionSources;
|
|
90
|
+
}, options: {
|
|
91
|
+
current: SuggestionOptions;
|
|
92
|
+
}): Extension<any, any>;
|
|
93
|
+
//# sourceMappingURL=suggestions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../src/editor/suggestions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAA0C,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAKvF;;;;;;;;;;;;;;;;GAgBG;AAE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W,kBAAkB;IACjC,MAAM,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,4EAA4E;IAC5E,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;CAC9C;AAED,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;CACpC;AAID,eAAO,MAAM,0BAA0B,EAAE,iBAExC,CAAC;AAIF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,GAAG,cAAc,EAAE,CAsDlH;AAID,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CA0BxF;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,EACnC,OAAO,EAAE;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,EACvC,OAAO,EAAE;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,uBA0DxC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
|
+
import { PluginKey } from "@tiptap/pm/state";
|
|
4
|
+
import { Suggestion } from "@tiptap/suggestion";
|
|
5
|
+
import { AtSign, CalendarDays, Minus, SmilePlus } from "lucide-react";
|
|
6
|
+
import { BLOCK_TYPES } from "./blocks.js";
|
|
7
|
+
import { searchEmoji } from "./emoji.js";
|
|
8
|
+
const ukShortDate = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric" });
|
|
9
|
+
export const DEFAULT_SUGGESTION_OPTIONS = {
|
|
10
|
+
formatDate: (date) => ukShortDate.format(date),
|
|
11
|
+
};
|
|
12
|
+
/* ── Item sources ─────────────────────────────────────────────────────── */
|
|
13
|
+
export function emojiItems(query) {
|
|
14
|
+
return searchEmoji(query, 8).map((entry) => ({
|
|
15
|
+
key: `emoji:${entry.name}`,
|
|
16
|
+
label: entry.name.replace(/_/g, " "),
|
|
17
|
+
hint: null,
|
|
18
|
+
glyph: entry.char,
|
|
19
|
+
insert: { kind: "emoji", char: entry.char },
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `/` menu: every block type, then the insert-only actions. Filtered by
|
|
24
|
+
* label and keywords so `/todo`, `/h2`, `/date` all land where expected.
|
|
25
|
+
*/
|
|
26
|
+
export function slashItems(query, sources, options) {
|
|
27
|
+
const term = query.trim().toLowerCase();
|
|
28
|
+
const blocks = BLOCK_TYPES.map((type) => ({
|
|
29
|
+
key: `block:${type.id}`,
|
|
30
|
+
label: type.label,
|
|
31
|
+
hint: type.shortcut.trim() || null,
|
|
32
|
+
icon: type.icon,
|
|
33
|
+
insert: { kind: "block", run: (editor) => void type.apply(editor.chain().focus()).run() },
|
|
34
|
+
}));
|
|
35
|
+
const today = options.formatDate(new Date());
|
|
36
|
+
const actions = [
|
|
37
|
+
{
|
|
38
|
+
key: "action:divider",
|
|
39
|
+
label: "Divider",
|
|
40
|
+
hint: "---",
|
|
41
|
+
icon: Minus,
|
|
42
|
+
insert: { kind: "block", run: (editor) => void editor.chain().focus().setHorizontalRule().run() },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: "action:date",
|
|
46
|
+
label: "Today's date",
|
|
47
|
+
hint: today,
|
|
48
|
+
icon: CalendarDays,
|
|
49
|
+
insert: { kind: "block", run: (editor) => void editor.chain().focus().insertContent(`${today} `).run() },
|
|
50
|
+
},
|
|
51
|
+
...(sources.references
|
|
52
|
+
? [
|
|
53
|
+
{
|
|
54
|
+
key: "action:reference",
|
|
55
|
+
label: "Reference…",
|
|
56
|
+
hint: "@",
|
|
57
|
+
icon: AtSign,
|
|
58
|
+
insert: { kind: "block", run: (editor) => void editor.chain().focus().insertContent("@").run() },
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
: []),
|
|
62
|
+
{
|
|
63
|
+
key: "action:emoji",
|
|
64
|
+
label: "Emoji…",
|
|
65
|
+
hint: ":",
|
|
66
|
+
icon: SmilePlus,
|
|
67
|
+
insert: { kind: "block", run: (editor) => void editor.chain().focus().insertContent(":").run() },
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
const all = [...blocks, ...actions];
|
|
71
|
+
if (!term)
|
|
72
|
+
return all;
|
|
73
|
+
const keywordsOf = (item) => BLOCK_TYPES.find((type) => `block:${type.id}` === item.key)?.keywords ?? [];
|
|
74
|
+
return all.filter((item) => item.label.toLowerCase().includes(term) ||
|
|
75
|
+
(item.hint ?? "").toLowerCase().startsWith(term) ||
|
|
76
|
+
keywordsOf(item).some((keyword) => keyword.includes(term)));
|
|
77
|
+
}
|
|
78
|
+
/* ── Applying a choice ────────────────────────────────────────────────── */
|
|
79
|
+
/** Apply an accepted row to the document, replacing the trigger text. */
|
|
80
|
+
export function applySuggestion(editor, range, item) {
|
|
81
|
+
switch (item.insert.kind) {
|
|
82
|
+
case "reference":
|
|
83
|
+
editor
|
|
84
|
+
.chain()
|
|
85
|
+
.focus()
|
|
86
|
+
.insertContentAt(range, [
|
|
87
|
+
{ type: "text", text: `@${item.label}`, marks: [{ type: "link", attrs: { href: item.insert.href } }] },
|
|
88
|
+
// The space deliberately carries no marks, so the link stops here
|
|
89
|
+
// instead of bleeding into whatever is typed next.
|
|
90
|
+
{ type: "text", text: " " },
|
|
91
|
+
])
|
|
92
|
+
.run();
|
|
93
|
+
return;
|
|
94
|
+
case "text":
|
|
95
|
+
editor.chain().focus().insertContentAt(range, `${item.insert.text} `).run();
|
|
96
|
+
return;
|
|
97
|
+
case "emoji":
|
|
98
|
+
editor.chain().focus().insertContentAt(range, `${item.insert.char} `).run();
|
|
99
|
+
return;
|
|
100
|
+
case "block":
|
|
101
|
+
// Remove the "/query" first, then run the block command on what's left.
|
|
102
|
+
editor.chain().focus().deleteRange(range).run();
|
|
103
|
+
item.insert.run(editor);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function renderInto(ui) {
|
|
108
|
+
return () => ({
|
|
109
|
+
onStart: (props) => {
|
|
110
|
+
ui.current.onOpen({ items: props.items, clientRect: props.clientRect ?? null, command: props.command });
|
|
111
|
+
},
|
|
112
|
+
onUpdate: (props) => {
|
|
113
|
+
ui.current.onOpen({ items: props.items, clientRect: props.clientRect ?? null, command: props.command });
|
|
114
|
+
},
|
|
115
|
+
onKeyDown: (props) => ui.current.onKeyDown(props.event),
|
|
116
|
+
onExit: () => ui.current.onClose(),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Every lookup as one extension. `ui` and `sources` are ref-like holders read
|
|
121
|
+
* lazily on every callback, so the extension (created once per editor) always
|
|
122
|
+
* talks to the current render's handlers and the app's current sources.
|
|
123
|
+
*/
|
|
124
|
+
export function createSuggestions(ui, sources, options) {
|
|
125
|
+
const shared = {
|
|
126
|
+
decorationClass: "house-suggestion",
|
|
127
|
+
command: ({ editor, range, props }) => applySuggestion(editor, range, props),
|
|
128
|
+
render: renderInto(ui),
|
|
129
|
+
};
|
|
130
|
+
return Extension.create({
|
|
131
|
+
name: "houseSuggestions",
|
|
132
|
+
addProseMirrorPlugins() {
|
|
133
|
+
return [
|
|
134
|
+
Suggestion({
|
|
135
|
+
...shared,
|
|
136
|
+
pluginKey: new PluginKey("houseReferenceSuggestion"),
|
|
137
|
+
editor: this.editor,
|
|
138
|
+
char: "@",
|
|
139
|
+
// Open on the `@` itself, as Notion does: the list shows what you
|
|
140
|
+
// work with before anything is typed.
|
|
141
|
+
minQueryLength: 0,
|
|
142
|
+
debounce: 150,
|
|
143
|
+
allow: () => Boolean(sources.current.references),
|
|
144
|
+
items: ({ query }) => sources.current.references?.(query) ?? [],
|
|
145
|
+
}),
|
|
146
|
+
Suggestion({
|
|
147
|
+
...shared,
|
|
148
|
+
pluginKey: new PluginKey("houseTagSuggestion"),
|
|
149
|
+
editor: this.editor,
|
|
150
|
+
char: "#",
|
|
151
|
+
minQueryLength: 1,
|
|
152
|
+
debounce: 150,
|
|
153
|
+
allow: () => Boolean(sources.current.tags),
|
|
154
|
+
items: ({ query }) => sources.current.tags?.(query) ?? [],
|
|
155
|
+
}),
|
|
156
|
+
Suggestion({
|
|
157
|
+
...shared,
|
|
158
|
+
pluginKey: new PluginKey("houseSlashSuggestion"),
|
|
159
|
+
editor: this.editor,
|
|
160
|
+
char: "/",
|
|
161
|
+
// Only after a space or at the start of a block, so `and/or` and the
|
|
162
|
+
// `/` inside a URL never open the menu.
|
|
163
|
+
allowedPrefixes: [" "],
|
|
164
|
+
items: ({ query }) => slashItems(query, sources.current, options.current),
|
|
165
|
+
}),
|
|
166
|
+
Suggestion({
|
|
167
|
+
...shared,
|
|
168
|
+
pluginKey: new PluginKey("houseEmojiSuggestion"),
|
|
169
|
+
editor: this.editor,
|
|
170
|
+
char: ":",
|
|
171
|
+
minQueryLength: 2,
|
|
172
|
+
allowedPrefixes: [" "],
|
|
173
|
+
items: ({ query }) => emojiItems(query),
|
|
174
|
+
}),
|
|
175
|
+
];
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../../src/editor/suggestions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAA2B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAA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SAAS,CAAC,sBAAsB,CAAC;oBAChD,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,IAAI,EAAE,GAAG;oBACT,cAAc,EAAE,CAAC;oBACjB,eAAe,EAAE,CAAC,GAAG,CAAC;oBACtB,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;iBACxC,CAAC;aACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
2
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
3
|
+
import { type ButtonHTMLAttributes, type InputHTMLAttributes, type ReactNode } from "react";
|
|
4
|
+
/**
|
|
5
|
+
* The few controls the editor's own chrome needs — a menu, a popover, a small
|
|
6
|
+
* button — built on Radix and the house token classes.
|
|
7
|
+
*
|
|
8
|
+
* Not the host app's design system, and not a replacement for it. The package
|
|
9
|
+
* README's rule is that nothing here brings a second Button into an app; these
|
|
10
|
+
* are the editor's internal parts (the formatting bubble, the block menu, the
|
|
11
|
+
* link box), never exported, and they exist because the apps' own primitive
|
|
12
|
+
* sets differ — several have no popover or toggle at all — so the editor
|
|
13
|
+
* cannot ask for them.
|
|
14
|
+
*/
|
|
15
|
+
export declare const buttonClass = "inline-flex shrink-0 items-center justify-center gap-1.5 rounded-md text-sm font-medium whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50";
|
|
16
|
+
export declare const ghostButtonClass: string;
|
|
17
|
+
export declare const primaryButtonClass: string;
|
|
18
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
19
|
+
pressed?: boolean;
|
|
20
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
export declare const TextInput: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & import("react").RefAttributes<HTMLInputElement>>;
|
|
22
|
+
export declare function VerticalSeparator(): import("react").JSX.Element;
|
|
23
|
+
export declare const Menu: import("react").FC<DropdownMenu.DropdownMenuProps>;
|
|
24
|
+
export declare const MenuTrigger: import("react").ForwardRefExoticComponent<DropdownMenu.DropdownMenuTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
export declare const MenuSub: import("react").FC<DropdownMenu.DropdownMenuSubProps>;
|
|
26
|
+
export declare function MenuContent({ children, className, align, }: {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
className?: string;
|
|
29
|
+
align?: "start" | "center" | "end";
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
export declare function MenuItem({ children, onSelect, className, }: {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
onSelect: () => void;
|
|
34
|
+
className?: string;
|
|
35
|
+
}): import("react").JSX.Element;
|
|
36
|
+
export declare function MenuLabel({ children }: {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}): import("react").JSX.Element;
|
|
39
|
+
export declare function MenuSeparator(): import("react").JSX.Element;
|
|
40
|
+
export declare function MenuSubTrigger({ children }: {
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): import("react").JSX.Element;
|
|
43
|
+
export declare function MenuSubContent({ children, className }: {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
className?: string;
|
|
46
|
+
}): import("react").JSX.Element;
|
|
47
|
+
export declare const PopoverRoot: import("react").FC<Popover.PopoverProps>;
|
|
48
|
+
export declare const PopoverTrigger: import("react").ForwardRefExoticComponent<Popover.PopoverTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
49
|
+
export declare function PopoverContent({ children, className, align, }: {
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
className?: string;
|
|
52
|
+
align?: "start" | "center" | "end";
|
|
53
|
+
}): import("react").JSX.Element;
|
|
54
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
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E,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAMnE;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAQlG;AAED,eAAO,MAAM,WAAW,0CAAe,CAAC;AACxC,eAAO,MAAM,cAAc,2HAAkB,CAAC;AAE9C,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,SAAS,EACT,KAAe,GAChB,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CACpC,+BAeA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
4
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
5
|
+
import { forwardRef } from "react";
|
|
6
|
+
import { cx } from "../internal/cx.js";
|
|
7
|
+
/**
|
|
8
|
+
* The few controls the editor's own chrome needs — a menu, a popover, a small
|
|
9
|
+
* button — built on Radix and the house token classes.
|
|
10
|
+
*
|
|
11
|
+
* Not the host app's design system, and not a replacement for it. The package
|
|
12
|
+
* README's rule is that nothing here brings a second Button into an app; these
|
|
13
|
+
* are the editor's internal parts (the formatting bubble, the block menu, the
|
|
14
|
+
* link box), never exported, and they exist because the apps' own primitive
|
|
15
|
+
* sets differ — several have no popover or toggle at all — so the editor
|
|
16
|
+
* cannot ask for them.
|
|
17
|
+
*/
|
|
18
|
+
export const buttonClass = "inline-flex shrink-0 items-center justify-center gap-1.5 rounded-md text-sm font-medium whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50";
|
|
19
|
+
export const ghostButtonClass = cx(buttonClass, "text-foreground hover:bg-accent hover:text-accent-foreground");
|
|
20
|
+
export const primaryButtonClass = cx(buttonClass, "h-8 bg-primary px-3 text-primary-foreground hover:bg-primary/90");
|
|
21
|
+
const menuSurfaceClass = "z-50 min-w-[10rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md";
|
|
22
|
+
const menuItemClass = "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
|
|
23
|
+
export const IconButton = forwardRef(function IconButton({ pressed, className, type = "button", ...props }, ref) {
|
|
24
|
+
return (_jsx("button", { ref: ref, type: type, "aria-pressed": pressed, className: cx(ghostButtonClass, "size-8 p-0", pressed && "bg-accent text-accent-foreground", className), ...props }));
|
|
25
|
+
});
|
|
26
|
+
export const TextInput = forwardRef(function TextInput({ className, ...props }, ref) {
|
|
27
|
+
return (_jsx("input", { ref: ref, className: cx("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm text-foreground shadow-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring", className), ...props }));
|
|
28
|
+
});
|
|
29
|
+
export function VerticalSeparator() {
|
|
30
|
+
return _jsx("span", { role: "separator", "aria-orientation": "vertical", className: "mx-0.5 h-5 w-px bg-border" });
|
|
31
|
+
}
|
|
32
|
+
export const Menu = DropdownMenu.Root;
|
|
33
|
+
export const MenuTrigger = DropdownMenu.Trigger;
|
|
34
|
+
export const MenuSub = DropdownMenu.Sub;
|
|
35
|
+
export function MenuContent({ children, className, align = "start", }) {
|
|
36
|
+
return (_jsx(DropdownMenu.Portal, { children: _jsx(DropdownMenu.Content, { align: align, sideOffset: 4, className: cx(menuSurfaceClass, className), children: children }) }));
|
|
37
|
+
}
|
|
38
|
+
export function MenuItem({ children, onSelect, className, }) {
|
|
39
|
+
return (_jsx(DropdownMenu.Item, { onSelect: onSelect, className: cx(menuItemClass, className), children: children }));
|
|
40
|
+
}
|
|
41
|
+
export function MenuLabel({ children }) {
|
|
42
|
+
return (_jsx(DropdownMenu.Label, { className: "px-2 py-1.5 text-[11px] font-semibold tracking-wide text-muted-foreground uppercase", children: children }));
|
|
43
|
+
}
|
|
44
|
+
export function MenuSeparator() {
|
|
45
|
+
return _jsx(DropdownMenu.Separator, { className: "-mx-1 my-1 h-px bg-border" });
|
|
46
|
+
}
|
|
47
|
+
export function MenuSubTrigger({ children }) {
|
|
48
|
+
return (_jsx(DropdownMenu.SubTrigger, { className: cx(menuItemClass, "data-[state=open]:bg-accent"), children: children }));
|
|
49
|
+
}
|
|
50
|
+
export function MenuSubContent({ children, className }) {
|
|
51
|
+
return (_jsx(DropdownMenu.Portal, { children: _jsx(DropdownMenu.SubContent, { sideOffset: 4, className: cx(menuSurfaceClass, className), children: children }) }));
|
|
52
|
+
}
|
|
53
|
+
export const PopoverRoot = Popover.Root;
|
|
54
|
+
export const PopoverTrigger = Popover.Trigger;
|
|
55
|
+
export function PopoverContent({ children, className, align = "start", }) {
|
|
56
|
+
return (_jsx(Popover.Portal, { children: _jsx(Popover.Content, { align: align, sideOffset: 6, className: cx("z-50 rounded-md border border-border bg-popover p-3 text-popover-foreground shadow-md outline-none", className), children: children }) }));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/editor/ui.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAuE,MAAM,OAAO,CAAC;AAExG,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAEvC;;;;;;;;;;GAUG;AAEH,MAAM,CAAC,MAAM,WAAW,GACtB,wOAAwO,CAAC;AAE3O,MAAM,CAAC,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