@refrakt-md/svelte 0.9.3 → 0.9.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@refrakt-md/svelte",
3
3
  "description": "Svelte renderer for refrakt.md content",
4
- "version": "0.9.3",
4
+ "version": "0.9.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -27,9 +27,9 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@markdoc/markdoc": "0.4.0",
30
- "@refrakt-md/behaviors": "0.9.3",
31
- "@refrakt-md/transform": "0.9.3",
32
- "@refrakt-md/types": "0.9.3"
30
+ "@refrakt-md/behaviors": "0.9.4",
31
+ "@refrakt-md/transform": "0.9.4",
32
+ "@refrakt-md/types": "0.9.4"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "svelte": "^5.0.0"
@@ -121,6 +121,8 @@
121
121
  </ElementOverride>
122
122
  {:else if node.name === 'svg'}
123
123
  {@html svgToHtml(node)}
124
+ {:else if VOID_ELEMENTS.has(node.name)}
125
+ <svelte:element this={node.name} {...htmlAttrs(node.attributes)} />
124
126
  {:else}
125
127
  <svelte:element this={node.name} {...htmlAttrs(node.attributes)}>
126
128
  {#each node.children as child}
@@ -139,7 +139,7 @@
139
139
  {@const tree = layoutTransform(layoutEntry, page, 'rf')}
140
140
  <Renderer node={tree} />
141
141
  {:else if layoutEntry}
142
- <svelte:component this={layoutEntry}
142
+ <layoutEntry
143
143
  title={page.title}
144
144
  description={page.description}
145
145
  frontmatter={page.frontmatter}
@@ -148,6 +148,6 @@
148
148
  pages={page.pages}
149
149
  url={page.url}
150
150
  headings={page.headings}
151
- />
151
+ ></layoutEntry>
152
152
  {/if}
153
153
  {/key}
package/src/elements.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import type { ElementOverrides } from './context.js';
2
- import Table from './elements/Table.svelte';
3
- import Pre from './elements/Pre.svelte';
4
2
 
5
- /** Base element overrides — functional enhancements for HTML elements */
6
- export const elements: ElementOverrides = {
7
- 'table': Table,
8
- 'pre': Pre,
9
- };
3
+ /** Base element overrides — empty by default. User-defined overrides can be
4
+ * registered via setElementOverrides(). */
5
+ export const elements: ElementOverrides = {};
@@ -1,77 +0,0 @@
1
- <script lang="ts">
2
- import type { SerializedTag } from '../types.js';
3
- import type { Snippet } from 'svelte';
4
-
5
- let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
6
-
7
- const isCodeBlock = 'data-language' in (tag.attributes || {});
8
-
9
- let preEl: HTMLPreElement;
10
- let copied = $state(false);
11
- let timer: ReturnType<typeof setTimeout>;
12
-
13
- function copy() {
14
- const text = preEl.textContent ?? '';
15
- navigator.clipboard.writeText(text);
16
- copied = true;
17
- clearTimeout(timer);
18
- timer = setTimeout(() => copied = false, 2000);
19
- }
20
- </script>
21
-
22
- {#if isCodeBlock}
23
- <div class="rf-codeblock">
24
- <pre bind:this={preEl} {...tag.attributes}>{@render children()}</pre>
25
- <button class="rf-codeblock__copy" class:rf-codeblock__copy--copied={copied} onclick={copy} aria-label="Copy code">
26
- {#if copied}
27
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
28
- <polyline points="20 6 9 17 4 12" />
29
- </svg>
30
- {:else}
31
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
32
- <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
33
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
34
- </svg>
35
- {/if}
36
- </button>
37
- </div>
38
- {:else}
39
- <pre {...tag.attributes}>{@render children()}</pre>
40
- {/if}
41
-
42
- <style>
43
- .rf-codeblock {
44
- position: relative;
45
- }
46
- .rf-codeblock :global(pre) {
47
- margin: 0;
48
- }
49
- .rf-codeblock__copy {
50
- position: absolute;
51
- top: 0.5rem;
52
- right: 0.5rem;
53
- display: flex;
54
- align-items: center;
55
- justify-content: center;
56
- width: 2rem;
57
- height: 2rem;
58
- border: none;
59
- border-radius: var(--rf-radius-sm);
60
- background: transparent;
61
- color: var(--rf-color-code-text, #e2e8f0);
62
- cursor: pointer;
63
- opacity: 0;
64
- transition: opacity 150ms ease, background-color 150ms ease;
65
- }
66
- .rf-codeblock:hover .rf-codeblock__copy {
67
- opacity: 0.6;
68
- }
69
- .rf-codeblock__copy:hover {
70
- opacity: 1 !important;
71
- background: rgba(255, 255, 255, 0.1);
72
- }
73
- .rf-codeblock__copy--copied {
74
- opacity: 1 !important;
75
- color: var(--rf-color-success, #4ade80);
76
- }
77
- </style>
@@ -1,12 +0,0 @@
1
- <script lang="ts">
2
- import type { SerializedTag } from '../types.js';
3
- import type { Snippet } from 'svelte';
4
-
5
- let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
6
- </script>
7
-
8
- <div class="rf-table-wrapper">
9
- <table {...tag.attributes}>
10
- {@render children()}
11
- </table>
12
- </div>