@heyramzi/ui 2.9.0 → 2.10.1
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/dist/agents/helpers.js +52 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/page-state.js +65 -0
- package/dist/agents/types.js +1 -0
- package/dist/agents/vendor/color.js +149 -0
- package/dist/agents/vendor/draw.js +548 -0
- package/dist/agents/vendor/engine.js +632 -0
- package/dist/agents/vendor/mesh.js +727 -0
- package/dist/agents/vendor/plastic.js +3273 -0
- package/dist/agents/vendor/presets.js +171 -0
- package/dist/agents/vendor/shapes.js +24 -0
- package/dist/agents/vendor/ticker.js +56 -0
- package/dist/agents/vendor/types.js +0 -0
- package/dist/agents/vendor/wear.js +1525 -0
- package/dist/ai/ai-button/index.js +2 -0
- package/dist/ai/confirmation/confirmation-context.svelte.js +12 -0
- package/dist/ai/confirmation/index.js +9 -0
- package/dist/ai/generation-progress/index.js +2 -0
- package/dist/ai/index.js +11 -0
- package/dist/ai/loading-state/index.js +3 -0
- package/dist/ai/prompt-input/index.js +6 -0
- package/dist/ai/reasoning/index.js +4 -0
- package/dist/ai/reasoning/reasoning-context.svelte.js +12 -0
- package/dist/ai/response/index.js +3 -0
- package/dist/ai/suggestion/index.js +3 -0
- package/dist/ai/thinking-dots/index.js +3 -0
- package/dist/ai/typing-dots/index.js +2 -0
- package/dist/ai/voice-waveform/index.js +3 -0
- package/dist/animations/text-swap.js +30 -0
- package/dist/brand/index.js +65 -0
- package/dist/canvas/card/resize.js +10 -0
- package/dist/canvas/edges/edge-path.js +284 -0
- package/dist/canvas/editor/context-menu.js +42 -0
- package/dist/canvas/editor/dispatch.svelte.js +157 -0
- package/dist/canvas/editor/editor-context.js +8 -0
- package/dist/canvas/editor/editor-mode.js +0 -0
- package/dist/canvas/editor/frame.js +87 -0
- package/dist/canvas/editor/hand-context.js +8 -0
- package/dist/canvas/editor/history-core.js +221 -0
- package/dist/canvas/editor/keymap.js +193 -0
- package/dist/canvas/editor/layout-actions.js +170 -0
- package/dist/canvas/editor/lock.js +65 -0
- package/dist/canvas/editor/rebase.js +279 -0
- package/dist/canvas/editor/style.js +174 -0
- package/dist/canvas/editor/text-field-context.js +8 -0
- package/dist/canvas/editor/z-order.js +82 -0
- package/dist/canvas/headless/alignment.js +20 -0
- package/dist/canvas/headless/break-apart-find.js +324 -0
- package/dist/canvas/headless/break-apart-pieces.js +74 -0
- package/dist/canvas/headless/break-apart-plan.js +378 -0
- package/dist/canvas/headless/break-apart-style.js +93 -0
- package/dist/canvas/headless/break-apart.js +206 -0
- package/dist/canvas/headless/canvas-cleanup.js +70 -0
- package/dist/canvas/headless/edge-anchors.js +134 -0
- package/dist/canvas/headless/edge-memo.js +28 -0
- package/dist/canvas/headless/edge-serialization.js +31 -0
- package/dist/canvas/headless/figure-geometry.js +331 -0
- package/dist/canvas/headless/fit-viewport.js +82 -0
- package/dist/canvas/headless/grid.js +96 -0
- package/dist/canvas/headless/icon-node.js +45 -0
- package/dist/canvas/headless/index.js +1 -0
- package/dist/canvas/headless/linkify.js +25 -0
- package/dist/canvas/headless/pen-marks.js +115 -0
- package/dist/canvas/headless/sketch.js +250 -0
- package/dist/canvas/headless/snap-guides.js +100 -0
- package/dist/canvas/headless/svg-figure.js +137 -0
- package/dist/canvas/headless/table-layout.js +161 -0
- package/dist/canvas/index.js +25 -0
- package/dist/canvas/lod/lod-mode.svelte.js +22 -0
- package/dist/canvas/lod/render-all.svelte.js +45 -0
- package/dist/canvas/ops/arrange.js +83 -0
- package/dist/canvas/ops/ops.js +318 -0
- package/dist/canvas/pen/colors.js +41 -0
- package/dist/canvas/pen/eraser.js +35 -0
- package/dist/canvas/pen/geometry.js +143 -0
- package/dist/canvas/pen/index.js +9 -0
- package/dist/canvas/pen/ops.js +15 -0
- package/dist/canvas/pen/pen-session.js +171 -0
- package/dist/canvas/pen/plugin.js +129 -0
- package/dist/canvas/pen/shapes.js +80 -0
- package/dist/canvas/pen/stroke-path.js +37 -0
- package/dist/canvas/pen/types.js +30 -0
- package/dist/canvas/pen/ui.js +20 -0
- package/dist/canvas/plugin.js +51 -0
- package/dist/canvas/screen/glyphs.js +24 -0
- package/dist/canvas/screen/labels.js +24 -0
- package/dist/canvas/screen/parts.js +140 -0
- package/dist/canvas/screen/plugin.js +71 -0
- package/dist/canvas/screen/types.js +44 -0
- package/dist/canvas/screen/ui.js +13 -0
- package/dist/canvas/test-utils.js +18 -0
- package/dist/canvas/types.js +0 -0
- package/dist/canvas/ui/forward-wheel.js +27 -0
- package/dist/canvas/ui/icons.js +133 -0
- package/dist/canvas/ui/place-panel.js +57 -0
- package/dist/canvas/ui/shortcut-tip.js +18 -0
- package/dist/canvas/ui/tools.js +411 -0
- package/dist/charts/dashboard/chart.js +1 -0
- package/dist/charts/dashboard/data-table.js +7 -0
- package/dist/charts/dashboard/index.js +13 -0
- package/dist/charts/dashboard/windows.js +5 -0
- package/dist/charts/edge-fade.js +7 -0
- package/dist/charts/hover-band.js +13 -0
- package/dist/charts/index.js +19 -0
- package/dist/charts/motion.js +15 -0
- package/dist/charts/primitives/chart-utils.js +22 -0
- package/dist/charts/primitives/index.js +4 -0
- package/dist/components/copy/clipboard.js +38 -0
- package/dist/components/copy/copied.svelte.js +26 -0
- package/dist/components/copy/index.js +3 -0
- package/dist/components/data-table/data-table.js +55 -0
- package/dist/components/data-table/index.js +7 -0
- package/dist/components/docs/index.js +3 -0
- package/dist/components/docs/scroll-spy.svelte.js +71 -0
- package/dist/components/field-row/index.js +1 -0
- package/dist/components/hold-to-confirm/index.js +1 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/language-flag/index.js +1 -0
- package/dist/components/list-page/filter-section.js +4 -0
- package/dist/components/list-page/index.js +25 -0
- package/dist/components/list-page/list-table.js +5 -0
- package/dist/components/list-page/queue-rail.js +3 -0
- package/dist/components/list-page/section-host.js +8 -0
- package/dist/components/list-page/step.js +5 -0
- package/dist/components/list-page/types.js +0 -0
- package/dist/components/locale-switch/index.js +1 -0
- package/dist/components/mark/index.js +1 -0
- package/dist/components/open-in/index.js +1 -0
- package/dist/components/picker/index.js +3 -0
- package/dist/components/picker/trigger.js +33 -0
- package/dist/components/picker/types.js +0 -0
- package/dist/components/section-card/index.js +1 -0
- package/dist/components/section-header/index.js +2 -0
- package/dist/components/segmented/collapse.js +32 -0
- package/dist/components/segmented/index.js +8 -0
- package/dist/components/segmented/segmented.js +50 -0
- package/dist/components/star-rating-input/index.js +2 -0
- package/dist/components/svg/index.js +1 -0
- package/dist/components/table-view/index.js +1 -0
- package/dist/components/table-view/types.js +0 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags.js +90 -0
- package/dist/components/theme/index.js +3 -0
- package/dist/components/toolbar/index.js +3 -0
- package/dist/components/toolbar/toolbar-trigger.js +4 -0
- package/dist/editor/anchors.js +17 -0
- package/dist/editor/block-id.js +62 -0
- package/dist/editor/block-ops.js +105 -0
- package/dist/editor/doc-blocks.js +181 -0
- package/dist/editor/extensions.js +200 -0
- package/dist/editor/index.js +4 -0
- package/dist/editor/markdown-test-helpers.js +6 -0
- package/dist/editor/markdown.js +486 -0
- package/dist/editor/serializer.js +268 -0
- package/dist/editor/slash-items.js +104 -0
- package/dist/editor/youtube-url.js +27 -0
- package/dist/effects/animated-beam/index.js +1 -0
- package/dist/effects/animated-beam/path-calculator.svelte.js +42 -0
- package/dist/effects/animated-beam/types.js +0 -0
- package/dist/effects/border-beam/css.js +420 -0
- package/dist/effects/border-beam/presets.js +1792 -0
- package/dist/effects/border-beam/register-properties.js +39 -0
- package/dist/effects/border-beam/types.js +0 -0
- package/dist/effects/image-comparison/compare.js +4 -0
- package/dist/effects/image-reveal/index.js +1 -0
- package/dist/effects/image-reveal/types.js +0 -0
- package/dist/effects/magnetic/magnetic.js +54 -0
- package/dist/effects/reveal/index.js +4 -0
- package/dist/effects/reveal/observe.js +43 -0
- package/dist/effects/reveal/types.js +0 -0
- package/dist/effects/shader-gradient/color.js +34 -0
- package/dist/effects/shader-gradient/index.js +1 -0
- package/dist/effects/shader-gradient/renderer.js +320 -0
- package/dist/effects/shader-gradient/shaders.js +280 -0
- package/dist/effects/shader-gradient/types.js +0 -0
- package/dist/icons/apple-symbol-exports.js +126 -0
- package/dist/icons/sf-symbols.js +465 -0
- package/dist/icons/trades.js +34 -0
- package/dist/inbox/index.js +4 -0
- package/dist/inbox/logic.js +156 -0
- package/dist/inbox/types.js +46 -0
- package/dist/index.js +18 -0
- package/dist/lib/arrive.js +13 -0
- package/dist/lib/icon-types.js +0 -0
- package/dist/lib/initials.js +17 -0
- package/dist/lib/layout.js +1 -0
- package/dist/lib/panel.js +3 -0
- package/dist/lib/result.js +26 -0
- package/dist/lib/sliding-pill.js +45 -0
- package/dist/lib/theme-transition.js +53 -0
- package/dist/lib/tone.js +32 -0
- package/dist/lib/utils.js +5 -0
- package/dist/onboarding/define-tours.js +28 -0
- package/dist/onboarding/index.js +4 -0
- package/dist/onboarding/onboarding.svelte.js +15 -0
- package/dist/onboarding/pick.js +16 -0
- package/dist/onboarding/stores.js +50 -0
- package/dist/onboarding/types.js +1 -0
- package/dist/onboarding/wait.js +25 -0
- package/dist/panel/index.js +1 -0
- package/dist/panel/side-panel-types.js +0 -0
- package/dist/record/demo-data.js +512 -0
- package/dist/record/fields.js +148 -0
- package/dist/record/format.js +97 -0
- package/dist/record/gutter.js +1 -0
- package/dist/record/index.js +15 -0
- package/dist/record/kinds.js +110 -0
- package/dist/record/logic.js +255 -0
- package/dist/record/types.js +52 -0
- package/dist/shadcn/accordion/index.js +5 -0
- package/dist/shadcn/alert/index.js +5 -0
- package/dist/shadcn/alert-dialog/index.js +12 -0
- package/dist/shadcn/attachment/index.js +10 -0
- package/dist/shadcn/avatar/index.js +7 -0
- package/dist/shadcn/badge/index.js +2 -0
- package/dist/shadcn/breadcrumb/index.js +8 -0
- package/dist/shadcn/bubble/index.js +5 -0
- package/dist/shadcn/button/index.js +2 -0
- package/dist/shadcn/calendar/index.js +19 -0
- package/dist/shadcn/card/index.js +8 -0
- package/dist/shadcn/checkbox/index.js +2 -0
- package/dist/shadcn/code-block/index.js +9 -0
- package/dist/shadcn/collapsible/index.js +4 -0
- package/dist/shadcn/command/index.js +13 -0
- package/dist/shadcn/context-menu/index.js +17 -0
- package/dist/shadcn/dialog/index.js +11 -0
- package/dist/shadcn/dropdown-menu/index.js +19 -0
- package/dist/shadcn/dropdown-menu/menu-item.js +23 -0
- package/dist/shadcn/empty/index.js +7 -0
- package/dist/shadcn/field/index.js +12 -0
- package/dist/shadcn/hooks/highlighter.js +92 -0
- package/dist/shadcn/hooks/is-mobile.svelte.js +7 -0
- package/dist/shadcn/hooks/use-highlighted-code.svelte.js +65 -0
- package/dist/shadcn/hover-card/index.js +5 -0
- package/dist/shadcn/input/index.js +3 -0
- package/dist/shadcn/input-otp/index.js +5 -0
- package/dist/shadcn/kbd/index.js +3 -0
- package/dist/shadcn/label/index.js +2 -0
- package/dist/shadcn/marker/index.js +4 -0
- package/dist/shadcn/message/index.js +7 -0
- package/dist/shadcn/message-scroller/index.js +8 -0
- package/dist/shadcn/popover/index.js +9 -0
- package/dist/shadcn/progress/index.js +2 -0
- package/dist/shadcn/progress/tone.js +11 -0
- package/dist/shadcn/radio-group/index.js +3 -0
- package/dist/shadcn/scroll-area/index.js +3 -0
- package/dist/shadcn/select/index.js +12 -0
- package/dist/shadcn/separator/index.js +2 -0
- package/dist/shadcn/sheet/index.js +11 -0
- package/dist/shadcn/sidebar/constants.js +6 -0
- package/dist/shadcn/sidebar/context.svelte.js +38 -0
- package/dist/shadcn/sidebar/index.js +25 -0
- package/dist/shadcn/skeleton/index.js +2 -0
- package/dist/shadcn/slider/index.js +2 -0
- package/dist/shadcn/sonner/index.js +1 -0
- package/dist/shadcn/spinner/index.js +1 -0
- package/dist/shadcn/switch/index.js +2 -0
- package/dist/shadcn/table/index.js +9 -0
- package/dist/shadcn/tabs/index.js +5 -0
- package/dist/shadcn/textarea/index.js +2 -0
- package/dist/shadcn/toggle/index.js +3 -0
- package/dist/shadcn/toggle-group/index.js +3 -0
- package/dist/shadcn/tooltip/context.js +8 -0
- package/dist/shadcn/tooltip/index.js +6 -0
- package/dist/shadcn/trace/index.js +9 -0
- package/dist/slides/bridges.js +66 -0
- package/dist/slides/deck-controller.svelte.js +221 -0
- package/dist/slides/export/capture.js +81 -0
- package/dist/slides/export/ffmpeg.js +85 -0
- package/dist/slides/export/index.js +4 -0
- package/dist/slides/export/launch.js +8 -0
- package/dist/slides/export/pdf.js +78 -0
- package/dist/slides/export/types.js +0 -0
- package/dist/slides/index.js +7 -0
- package/dist/slides/labels.js +26 -0
- package/dist/slides/layout.js +47 -0
- package/dist/slides/model.js +9 -0
- package/dist/slides/navigation.js +89 -0
- package/dist/slides/types.js +6 -0
- package/dist/status/define-statuses.js +16 -0
- package/dist/status/index.js +4 -0
- package/dist/status/status-types.js +0 -0
- package/dist/test-setup.js +26 -0
- package/dist/thread/index.js +3 -0
- package/dist/thread/logic.js +94 -0
- package/dist/thread/types.js +23 -0
- package/dist/work/board-order.js +109 -0
- package/dist/work/dates.js +19 -0
- package/dist/work/detail/detail-types.js +20 -0
- package/dist/work/docs/edited.js +39 -0
- package/dist/work/docs/index.js +7 -0
- package/dist/work/docs/labels.js +38 -0
- package/dist/work/docs/menu.js +121 -0
- package/dist/work/docs/outline.js +39 -0
- package/dist/work/gantt/logic.js +260 -0
- package/dist/work/inbox/inbox-logic.js +94 -0
- package/dist/work/inbox/inbox-statuses.js +86 -0
- package/dist/work/inbox/inbox-types.js +0 -0
- package/dist/work/inbox/index.js +1 -0
- package/dist/work/index.js +21 -0
- package/dist/work/kanban-drag.js +25 -0
- package/dist/work/kanban-types.js +0 -0
- package/dist/work/presets/sales.js +35 -0
- package/dist/work/reorder.js +10 -0
- package/dist/work/task-types.js +0 -0
- package/dist/work/time/duration.js +60 -0
- package/dist/work/time/time-types.js +25 -0
- package/dist/work/use-kanban-dnd.svelte.js +128 -0
- package/package.json +45 -3
- package/src/components/toolbar/toolbar-trigger.ts +8 -2
- package/src/record/demo-data.ts +4 -4
- package/src/record/record-demo.svelte +2 -2
- package/src/status/status-dot.svelte +0 -2
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
function slugify(input, maxLength = 60) {
|
|
2
|
+
return input.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, maxLength).replace(/-$/g, "");
|
|
3
|
+
}
|
|
4
|
+
function newContext() {
|
|
5
|
+
return {
|
|
6
|
+
headingSlugs: new Map()
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function uniqueHeadingId(text, ctx) {
|
|
10
|
+
const base = slugify(text) || "section";
|
|
11
|
+
const seen = ctx.headingSlugs.get(base) ?? 0;
|
|
12
|
+
ctx.headingSlugs.set(base, seen + 1);
|
|
13
|
+
return seen === 0 ? base : `${base}-${seen + 1}`;
|
|
14
|
+
}
|
|
15
|
+
export function renderTiptapContent(content) {
|
|
16
|
+
if (!content || typeof content !== "object") return "";
|
|
17
|
+
return renderNode(content, newContext());
|
|
18
|
+
}
|
|
19
|
+
export function extractHeadings(content, options = {}) {
|
|
20
|
+
if (!content || typeof content !== "object") return [];
|
|
21
|
+
const levels = options.levels ?? [
|
|
22
|
+
2,
|
|
23
|
+
3
|
|
24
|
+
];
|
|
25
|
+
const ctx = newContext();
|
|
26
|
+
const headings = [];
|
|
27
|
+
walkHeadings(content, ctx, levels, headings);
|
|
28
|
+
return headings;
|
|
29
|
+
}
|
|
30
|
+
function walkHeadings(node, ctx, levels, out) {
|
|
31
|
+
if (node.type === "heading") {
|
|
32
|
+
const level = clampHeadingLevel(node.attrs?.level);
|
|
33
|
+
const text = extractText(node.content).trim();
|
|
34
|
+
const id = uniqueHeadingId(text, ctx);
|
|
35
|
+
if (text && levels.includes(level)) out.push({
|
|
36
|
+
id,
|
|
37
|
+
level,
|
|
38
|
+
text
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (node.content?.length) {
|
|
43
|
+
for (const child of node.content)walkHeadings(child, ctx, levels, out);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function extractYoutubeVideos(content) {
|
|
47
|
+
if (!content || typeof content !== "object") return [];
|
|
48
|
+
const videos = [];
|
|
49
|
+
walkYoutubeVideos(content, videos);
|
|
50
|
+
return videos;
|
|
51
|
+
}
|
|
52
|
+
function walkYoutubeVideos(node, out) {
|
|
53
|
+
if (node.type === "youtube") {
|
|
54
|
+
const video = youtubeVideoOf(node);
|
|
55
|
+
if (video) out.push(video);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const child of node.content ?? [])walkYoutubeVideos(child, out);
|
|
59
|
+
}
|
|
60
|
+
function youtubeVideoOf(node) {
|
|
61
|
+
const videoId = strAttr(node.attrs, "videoId") ?? "";
|
|
62
|
+
if (!YOUTUBE_VIDEO_ID_RE.test(videoId)) return null;
|
|
63
|
+
return {
|
|
64
|
+
videoId,
|
|
65
|
+
title: strAttr(node.attrs, "title") ?? "",
|
|
66
|
+
start: numAttr(node.attrs, "start") ?? 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function strAttr(attrs, key) {
|
|
70
|
+
const value = attrs?.[key];
|
|
71
|
+
return typeof value === "string" ? value : undefined;
|
|
72
|
+
}
|
|
73
|
+
function numAttr(attrs, key) {
|
|
74
|
+
const value = attrs?.[key];
|
|
75
|
+
return typeof value === "number" ? value : undefined;
|
|
76
|
+
}
|
|
77
|
+
const wrapIn = (tag)=>(node, ctx)=>`<${tag}>${renderChildren(node.content, ctx) || ""}</${tag}>`;
|
|
78
|
+
function renderHeading(node, ctx) {
|
|
79
|
+
const level = clampHeadingLevel(node.attrs?.level);
|
|
80
|
+
const text = extractText(node.content).trim();
|
|
81
|
+
const inner = renderChildren(node.content, ctx) || "";
|
|
82
|
+
if (!text) return `<h${level}>${inner}</h${level}>`;
|
|
83
|
+
const id = uniqueHeadingId(text, ctx);
|
|
84
|
+
return `<h${level} id="${escapeAttr(id)}">${inner}</h${level}>`;
|
|
85
|
+
}
|
|
86
|
+
function renderOrderedList(node, ctx) {
|
|
87
|
+
const start = numAttr(node.attrs, "start");
|
|
88
|
+
const attrs = renderAttributes({
|
|
89
|
+
start: start === undefined ? undefined : String(start)
|
|
90
|
+
});
|
|
91
|
+
return `<ol${attrs}>${renderChildren(node.content, ctx) || ""}</ol>`;
|
|
92
|
+
}
|
|
93
|
+
function renderCodeBlock(node) {
|
|
94
|
+
const lang = strAttr(node.attrs, "language");
|
|
95
|
+
const language = lang ? ` class="language-${escapeAttr(lang)}"` : "";
|
|
96
|
+
return `<pre><code${language}>${escapeHtml(extractText(node.content))}</code></pre>`;
|
|
97
|
+
}
|
|
98
|
+
function numString(attrs, key) {
|
|
99
|
+
const value = numAttr(attrs, key);
|
|
100
|
+
return value === undefined ? undefined : String(value);
|
|
101
|
+
}
|
|
102
|
+
function renderImage(node) {
|
|
103
|
+
const src = strAttr(node.attrs, "src");
|
|
104
|
+
if (!src) return "";
|
|
105
|
+
const attrs = renderAttributes({
|
|
106
|
+
alt: strAttr(node.attrs, "alt") ?? "",
|
|
107
|
+
title: strAttr(node.attrs, "title"),
|
|
108
|
+
width: numString(node.attrs, "width"),
|
|
109
|
+
height: numString(node.attrs, "height"),
|
|
110
|
+
"data-align": strAttr(node.attrs, "align")
|
|
111
|
+
});
|
|
112
|
+
return `<img src="${escapeAttr(src)}"${attrs} />`;
|
|
113
|
+
}
|
|
114
|
+
function renderTable(node, ctx) {
|
|
115
|
+
const winnerColIndex = findWinnerColumnIndex(node);
|
|
116
|
+
const rows = node.content ?? [];
|
|
117
|
+
const body = rows.map((row, rowIdx)=>renderTableRow(row, ctx, {
|
|
118
|
+
winnerColIndex,
|
|
119
|
+
isFirstRow: rowIdx === 0
|
|
120
|
+
})).join("");
|
|
121
|
+
const tableClass = winnerColIndex !== -1 ? ' class="comparison-table"' : "";
|
|
122
|
+
return `<div class="tiptap-table-wrap"><table${tableClass}>${body}</table></div>`;
|
|
123
|
+
}
|
|
124
|
+
const RENDERERS = {
|
|
125
|
+
doc: (node, ctx)=>renderChildren(node.content, ctx),
|
|
126
|
+
paragraph: wrapIn("p"),
|
|
127
|
+
heading: renderHeading,
|
|
128
|
+
blockquote: wrapIn("blockquote"),
|
|
129
|
+
bulletList: wrapIn("ul"),
|
|
130
|
+
orderedList: renderOrderedList,
|
|
131
|
+
listItem: wrapIn("li"),
|
|
132
|
+
codeBlock: renderCodeBlock,
|
|
133
|
+
horizontalRule: ()=>"<hr />",
|
|
134
|
+
hardBreak: ()=>"<br />",
|
|
135
|
+
image: renderImage,
|
|
136
|
+
cmsBlock: ()=>"",
|
|
137
|
+
youtube: renderYoutube,
|
|
138
|
+
table: renderTable,
|
|
139
|
+
tableRow: (node, ctx)=>renderTableRow(node, ctx, {
|
|
140
|
+
winnerColIndex: -1,
|
|
141
|
+
isFirstRow: false
|
|
142
|
+
}),
|
|
143
|
+
tableCell: (node, ctx)=>renderTableCell(node, ctx, false),
|
|
144
|
+
tableHeader: (node, ctx)=>renderTableCell(node, ctx, false),
|
|
145
|
+
text: renderText
|
|
146
|
+
};
|
|
147
|
+
function pick(table, key) {
|
|
148
|
+
return key !== undefined && Object.hasOwn(table, key) ? table[key] : undefined;
|
|
149
|
+
}
|
|
150
|
+
function renderNode(node, ctx) {
|
|
151
|
+
const render = pick(RENDERERS, node.type);
|
|
152
|
+
return render ? render(node, ctx) : renderChildren(node.content, ctx);
|
|
153
|
+
}
|
|
154
|
+
function renderChildren(content, ctx) {
|
|
155
|
+
if (!content?.length) return "";
|
|
156
|
+
return content.map((child)=>renderNode(child, ctx)).join("");
|
|
157
|
+
}
|
|
158
|
+
const YOUTUBE_VIDEO_ID_RE = /^[A-Za-z0-9_-]{11}$/;
|
|
159
|
+
function renderYoutube(node) {
|
|
160
|
+
const videoId = typeof node.attrs?.videoId === "string" ? node.attrs.videoId : "";
|
|
161
|
+
if (!YOUTUBE_VIDEO_ID_RE.test(videoId)) return "";
|
|
162
|
+
const title = typeof node.attrs?.title === "string" ? node.attrs.title : "";
|
|
163
|
+
const start = typeof node.attrs?.start === "number" ? node.attrs.start : 0;
|
|
164
|
+
const safeVideoId = escapeAttr(videoId);
|
|
165
|
+
const safeTitle = escapeAttr(title);
|
|
166
|
+
return `<div class="tiptap-youtube" data-video-id="${safeVideoId}" data-start="${start}">` + `<button type="button" class="tiptap-youtube-trigger" aria-label="Play video: ${safeTitle}">` + `<img class="tiptap-youtube-poster" src="https://i.ytimg.com/vi/${safeVideoId}/hqdefault.jpg" alt="" loading="lazy" width="480" height="360" />` + `<span class="tiptap-youtube-play" aria-hidden="true"></span>` + `<span class="tiptap-youtube-title">${escapeHtml(title)}</span>` + `</button></div>`;
|
|
167
|
+
}
|
|
168
|
+
function renderTableRow(row, ctx, { winnerColIndex, isFirstRow }) {
|
|
169
|
+
if (row.type !== "tableRow" || !row.content?.length) {
|
|
170
|
+
return `<tr>${renderChildren(row.content, ctx)}</tr>`;
|
|
171
|
+
}
|
|
172
|
+
const cellsHtml = row.content.map((cell, cellIdx)=>{
|
|
173
|
+
const isWinnerCell = !isFirstRow && winnerColIndex !== -1 && cellIdx === winnerColIndex;
|
|
174
|
+
return renderTableCell(cell, ctx, isWinnerCell);
|
|
175
|
+
}).join("");
|
|
176
|
+
return `<tr>${cellsHtml}</tr>`;
|
|
177
|
+
}
|
|
178
|
+
function renderTableCell(cell, ctx, isWinnerCell) {
|
|
179
|
+
const tag = cell.type === "tableHeader" ? "th" : "td";
|
|
180
|
+
const colspan = typeof cell.attrs?.colspan === "number" && cell.attrs.colspan !== 1 ? String(cell.attrs.colspan) : undefined;
|
|
181
|
+
const rowspan = typeof cell.attrs?.rowspan === "number" && cell.attrs.rowspan !== 1 ? String(cell.attrs.rowspan) : undefined;
|
|
182
|
+
const inner = renderChildren(cell.content, ctx);
|
|
183
|
+
if (!isWinnerCell) {
|
|
184
|
+
const attrs = renderAttributes({
|
|
185
|
+
colspan,
|
|
186
|
+
rowspan
|
|
187
|
+
});
|
|
188
|
+
return `<${tag}${attrs}>${inner}</${tag}>`;
|
|
189
|
+
}
|
|
190
|
+
const winnerText = extractText(cell.content).trim();
|
|
191
|
+
const winner = normalizeWinner(winnerText);
|
|
192
|
+
const attrs = renderAttributes({
|
|
193
|
+
class: "winner-cell",
|
|
194
|
+
"data-winner": winner,
|
|
195
|
+
colspan,
|
|
196
|
+
rowspan
|
|
197
|
+
});
|
|
198
|
+
return `<${tag}${attrs}>${inner}</${tag}>`;
|
|
199
|
+
}
|
|
200
|
+
const WINNER_HEADERS = [
|
|
201
|
+
"winner",
|
|
202
|
+
"gagnant",
|
|
203
|
+
"vainqueur"
|
|
204
|
+
];
|
|
205
|
+
function findWinnerColumnIndex(table) {
|
|
206
|
+
const firstRow = table.content?.[0];
|
|
207
|
+
if (!firstRow?.content) return -1;
|
|
208
|
+
for(let i = 0; i < firstRow.content.length; i++){
|
|
209
|
+
const headerText = extractText(firstRow.content[i]?.content).trim().toLowerCase();
|
|
210
|
+
if (WINNER_HEADERS.includes(headerText)) return i;
|
|
211
|
+
}
|
|
212
|
+
return -1;
|
|
213
|
+
}
|
|
214
|
+
function normalizeWinner(text) {
|
|
215
|
+
const lower = text.toLowerCase().trim();
|
|
216
|
+
if (!lower) return "other";
|
|
217
|
+
if (lower.startsWith("tie") || lower.startsWith("égal") || lower.startsWith("egal")) {
|
|
218
|
+
return "tie";
|
|
219
|
+
}
|
|
220
|
+
return lower.match(/^[\p{L}\p{N}]+/u)?.[0] ?? "other";
|
|
221
|
+
}
|
|
222
|
+
function renderText(node) {
|
|
223
|
+
const text = escapeHtml(node.text ?? "");
|
|
224
|
+
if (!node.marks?.length) return text;
|
|
225
|
+
return node.marks.reduce((html, mark)=>wrapMark(html, mark), text);
|
|
226
|
+
}
|
|
227
|
+
const MARK_TAGS = {
|
|
228
|
+
bold: "strong",
|
|
229
|
+
italic: "em",
|
|
230
|
+
strike: "s",
|
|
231
|
+
underline: "u",
|
|
232
|
+
code: "code"
|
|
233
|
+
};
|
|
234
|
+
function wrapMark(content, mark) {
|
|
235
|
+
if (mark.type === "link") {
|
|
236
|
+
const attrs = renderAttributes({
|
|
237
|
+
href: strAttr(mark.attrs, "href") ?? "",
|
|
238
|
+
target: strAttr(mark.attrs, "target"),
|
|
239
|
+
rel: strAttr(mark.attrs, "rel")
|
|
240
|
+
});
|
|
241
|
+
return `<a${attrs}>${content}</a>`;
|
|
242
|
+
}
|
|
243
|
+
const tag = pick(MARK_TAGS, mark.type);
|
|
244
|
+
return tag ? `<${tag}>${content}</${tag}>` : content;
|
|
245
|
+
}
|
|
246
|
+
function renderAttributes(attrs) {
|
|
247
|
+
const parts = Object.entries(attrs).filter(([, value])=>value !== undefined && value !== "").map(([key, value])=>` ${key}="${escapeAttr(value ?? "")}"`);
|
|
248
|
+
return parts.join("");
|
|
249
|
+
}
|
|
250
|
+
function extractText(content) {
|
|
251
|
+
if (!content?.length) return "";
|
|
252
|
+
return content.map((node)=>{
|
|
253
|
+
if (node.type === "text") return node.text ?? "";
|
|
254
|
+
return extractText(node.content);
|
|
255
|
+
}).join("");
|
|
256
|
+
}
|
|
257
|
+
function clampHeadingLevel(level) {
|
|
258
|
+
if (level === 1 || level === 2 || level === 3 || level === 4 || level === 5 || level === 6) {
|
|
259
|
+
return level;
|
|
260
|
+
}
|
|
261
|
+
return 2;
|
|
262
|
+
}
|
|
263
|
+
function escapeHtml(value) {
|
|
264
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
265
|
+
}
|
|
266
|
+
function escapeAttr(value) {
|
|
267
|
+
return escapeHtml(value).replaceAll("`", "`");
|
|
268
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { TextB, TextHOne, TextHTwo, TextHThree, ListBullets, ListNumbers, Quotes, CodeBlock, Minus, ImageSquare, Paragraph, VideoCamera, ListChecks, Table } from "phosphor-svelte";
|
|
2
|
+
export function buildSlashItems(editor, query, options) {
|
|
3
|
+
const run = ()=>editor.chain().focus();
|
|
4
|
+
const full = options.preset === "full";
|
|
5
|
+
const allItems = [
|
|
6
|
+
{
|
|
7
|
+
label: "Heading 1",
|
|
8
|
+
description: "Page title",
|
|
9
|
+
icon: TextHOne,
|
|
10
|
+
command: ()=>run().toggleHeading({
|
|
11
|
+
level: 1
|
|
12
|
+
}).run()
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Heading 2",
|
|
16
|
+
description: "Section heading",
|
|
17
|
+
icon: TextHTwo,
|
|
18
|
+
command: ()=>run().toggleHeading({
|
|
19
|
+
level: 2
|
|
20
|
+
}).run()
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "Heading 3",
|
|
24
|
+
description: "Subsection heading",
|
|
25
|
+
icon: TextHThree,
|
|
26
|
+
command: ()=>run().toggleHeading({
|
|
27
|
+
level: 3
|
|
28
|
+
}).run()
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "Bullet List",
|
|
32
|
+
description: "Unordered list",
|
|
33
|
+
icon: ListBullets,
|
|
34
|
+
command: ()=>run().toggleBulletList().run()
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "Ordered List",
|
|
38
|
+
description: "Numbered list",
|
|
39
|
+
icon: ListNumbers,
|
|
40
|
+
command: ()=>run().toggleOrderedList().run()
|
|
41
|
+
},
|
|
42
|
+
...full ? [
|
|
43
|
+
{
|
|
44
|
+
label: "Checklist",
|
|
45
|
+
description: "Tasks with checkboxes",
|
|
46
|
+
icon: ListChecks,
|
|
47
|
+
command: ()=>run().toggleTaskList().run()
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "Table",
|
|
51
|
+
description: "Rows and columns",
|
|
52
|
+
icon: Table,
|
|
53
|
+
command: ()=>run().insertTable({
|
|
54
|
+
rows: 3,
|
|
55
|
+
cols: 3,
|
|
56
|
+
withHeaderRow: true
|
|
57
|
+
}).run()
|
|
58
|
+
}
|
|
59
|
+
] : [],
|
|
60
|
+
{
|
|
61
|
+
label: "Quote",
|
|
62
|
+
description: "Blockquote",
|
|
63
|
+
icon: Quotes,
|
|
64
|
+
command: ()=>run().toggleBlockquote().run()
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: "Code Block",
|
|
68
|
+
description: "Code snippet",
|
|
69
|
+
icon: CodeBlock,
|
|
70
|
+
command: ()=>run().toggleCodeBlock().run()
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: "Divider",
|
|
74
|
+
description: "Horizontal rule",
|
|
75
|
+
icon: Minus,
|
|
76
|
+
command: ()=>run().setHorizontalRule().run()
|
|
77
|
+
},
|
|
78
|
+
...full ? [
|
|
79
|
+
{
|
|
80
|
+
label: "Image",
|
|
81
|
+
description: "Insert from URL",
|
|
82
|
+
icon: ImageSquare,
|
|
83
|
+
command: options.insertImage
|
|
84
|
+
}
|
|
85
|
+
] : [],
|
|
86
|
+
...full ? [
|
|
87
|
+
{
|
|
88
|
+
label: "YouTube",
|
|
89
|
+
description: "Insert a video by URL",
|
|
90
|
+
icon: VideoCamera,
|
|
91
|
+
command: options.insertYoutube
|
|
92
|
+
}
|
|
93
|
+
] : [],
|
|
94
|
+
{
|
|
95
|
+
label: "Paragraph",
|
|
96
|
+
description: "Plain text block",
|
|
97
|
+
icon: Paragraph,
|
|
98
|
+
command: ()=>run().setParagraph().run()
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
if (!query) return allItems;
|
|
102
|
+
const q = query.toLowerCase();
|
|
103
|
+
return allItems.filter((item)=>item.label.toLowerCase().includes(q) || item.description.toLowerCase().includes(q));
|
|
104
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const YOUTUBE_ID_RE = /^[A-Za-z0-9_-]{11}$/;
|
|
2
|
+
function toUrl(url) {
|
|
3
|
+
try {
|
|
4
|
+
return new URL(url);
|
|
5
|
+
} catch {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function videoIdOf(parsed) {
|
|
10
|
+
const host = parsed.hostname.replace(/^www\./, "");
|
|
11
|
+
if (host === "youtu.be") return parsed.pathname.slice(1);
|
|
12
|
+
if (host !== "youtube.com" && host !== "m.youtube.com") return null;
|
|
13
|
+
if (parsed.pathname === "/watch") return parsed.searchParams.get("v");
|
|
14
|
+
if (parsed.pathname.startsWith("/embed/")) return parsed.pathname.slice("/embed/".length);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
export function parseYoutubeUrl(url) {
|
|
18
|
+
const parsed = toUrl(url);
|
|
19
|
+
if (!parsed) return null;
|
|
20
|
+
const videoId = videoIdOf(parsed);
|
|
21
|
+
if (!videoId || !YOUTUBE_ID_RE.test(videoId)) return null;
|
|
22
|
+
const t = parseInt(parsed.searchParams.get("t") ?? "", 10);
|
|
23
|
+
return {
|
|
24
|
+
videoId,
|
|
25
|
+
start: Number.isFinite(t) && t > 0 ? t : 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AnimatedBeam } from "../../../src/effects/animated-beam/AnimatedBeam.svelte";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function anchorX(rect, containerLeft, anchor, offset) {
|
|
2
|
+
const left = rect.left - containerLeft;
|
|
3
|
+
if (anchor === "left") return left + offset;
|
|
4
|
+
if (anchor === "right") return left + rect.width + offset;
|
|
5
|
+
return left + rect.width / 2 + offset;
|
|
6
|
+
}
|
|
7
|
+
export function usePathCalculator() {
|
|
8
|
+
let pathD = $state("");
|
|
9
|
+
let svgDimensions = $state({
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0
|
|
12
|
+
});
|
|
13
|
+
function calculatePath(containerRef, fromRef, toRef, curvature, startXOffset, startYOffset, endXOffset, endYOffset, fromAnchor = "center", toAnchor = "center") {
|
|
14
|
+
if (!containerRef || !fromRef || !toRef) return;
|
|
15
|
+
const containerRect = containerRef.getBoundingClientRect();
|
|
16
|
+
const rectA = fromRef.getBoundingClientRect();
|
|
17
|
+
const rectB = toRef.getBoundingClientRect();
|
|
18
|
+
svgDimensions = {
|
|
19
|
+
width: containerRect.width,
|
|
20
|
+
height: containerRect.height
|
|
21
|
+
};
|
|
22
|
+
const startX = anchorX(rectA, containerRect.left, fromAnchor, startXOffset);
|
|
23
|
+
const startY = rectA.top - containerRect.top + rectA.height / 2 + startYOffset;
|
|
24
|
+
const endX = anchorX(rectB, containerRect.left, toAnchor, endXOffset);
|
|
25
|
+
const endY = rectB.top - containerRect.top + rectB.height / 2 + endYOffset;
|
|
26
|
+
const span = Math.abs(endX - startX);
|
|
27
|
+
const handle = Math.max(span * 0.5, 24);
|
|
28
|
+
const direction = endX >= startX ? 1 : -1;
|
|
29
|
+
const c1x = startX + handle * direction;
|
|
30
|
+
const c2x = endX - handle * direction;
|
|
31
|
+
pathD = `M ${startX},${startY} C ${c1x},${startY - curvature} ${c2x},${endY - curvature} ${endX},${endY}`;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
get pathD () {
|
|
35
|
+
return pathD;
|
|
36
|
+
},
|
|
37
|
+
get svgDimensions () {
|
|
38
|
+
return svgDimensions;
|
|
39
|
+
},
|
|
40
|
+
calculatePath
|
|
41
|
+
};
|
|
42
|
+
}
|
|
File without changes
|