@incremark/svelte 0.3.5 → 0.3.7
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/ThemeProvider.svelte +7 -1
- package/dist/ThemeProvider.svelte.d.ts.map +1 -1
- package/dist/components/IncremarkBlockquote.svelte +15 -2
- package/dist/components/IncremarkBlockquote.svelte.d.ts +8 -0
- package/dist/components/IncremarkBlockquote.svelte.d.ts.map +1 -1
- package/dist/components/IncremarkList.svelte +15 -2
- package/dist/components/IncremarkList.svelte.d.ts +8 -0
- package/dist/components/IncremarkList.svelte.d.ts.map +1 -1
- package/dist/components/IncremarkRenderer.svelte +20 -0
- package/dist/components/IncremarkRenderer.svelte.d.ts.map +1 -1
- package/dist/context/themeContext.svelte.d.ts +71 -0
- package/dist/context/themeContext.svelte.d.ts.map +1 -0
- package/dist/context/themeContext.svelte.js +85 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +10 -10
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
import type { DesignTokens } from '@incremark/theme'
|
|
8
8
|
import { applyTheme } from '@incremark/theme'
|
|
9
9
|
import { isBrowser } from '@incremark/shared'
|
|
10
|
+
import { setThemeContext } from './context/themeContext.svelte.ts'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* 组件 Props
|
|
13
14
|
*/
|
|
14
15
|
interface Props {
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
16
17
|
* 主题配置,可以是:
|
|
17
18
|
* - 字符串:'default' | 'dark'
|
|
18
19
|
* - 完整主题对象:DesignTokens
|
|
@@ -34,6 +35,11 @@
|
|
|
34
35
|
// 容器引用
|
|
35
36
|
let containerRef: HTMLElement | null = null
|
|
36
37
|
|
|
38
|
+
// 使用 $effect 追踪 theme prop 的变化并更新 context
|
|
39
|
+
$effect(() => {
|
|
40
|
+
setThemeContext(theme)
|
|
41
|
+
})
|
|
42
|
+
|
|
37
43
|
// 监听主题变化
|
|
38
44
|
// 在 Svelte 5 中,$effect 会自动追踪在 effect 内部访问的响应式值
|
|
39
45
|
// 直接访问 theme prop 和 containerRef,确保都被追踪
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.svelte.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"ThemeProvider.svelte.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAMlD;;GAEG;AACH,UAAU,KAAK;IACb;;;;;OAKG;IACH,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAChE,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU;IACV,QAAQ,CAAC,EAAE,OAAO,QAAQ,EAAE,OAAO,CAAA;CACpC;AA8CH,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -13,14 +13,27 @@
|
|
|
13
13
|
interface Props {
|
|
14
14
|
/** 引用节点 */
|
|
15
15
|
node: Blockquote
|
|
16
|
+
/** 自定义组件映射 */
|
|
17
|
+
components?: Record<string, any>
|
|
18
|
+
customContainers?: Record<string, any>
|
|
19
|
+
customCodeBlocks?: Record<string, any>
|
|
20
|
+
codeBlockConfigs?: Record<string, { takeOver?: boolean }>
|
|
21
|
+
blockStatus?: 'pending' | 'stable' | 'completed'
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
let { node }: Props = $props()
|
|
24
|
+
let { node, components, customContainers, customCodeBlocks, codeBlockConfigs, blockStatus }: Props = $props()
|
|
19
25
|
</script>
|
|
20
26
|
|
|
21
27
|
<blockquote class="incremark-blockquote">
|
|
22
28
|
{#each node.children as child, index (index)}
|
|
23
|
-
<IncremarkRenderer
|
|
29
|
+
<IncremarkRenderer
|
|
30
|
+
node={child}
|
|
31
|
+
{components}
|
|
32
|
+
{customContainers}
|
|
33
|
+
{customCodeBlocks}
|
|
34
|
+
{codeBlockConfigs}
|
|
35
|
+
{blockStatus}
|
|
36
|
+
/>
|
|
24
37
|
{/each}
|
|
25
38
|
</blockquote>
|
|
26
39
|
|
|
@@ -5,6 +5,14 @@ import type { Blockquote } from 'mdast';
|
|
|
5
5
|
interface Props {
|
|
6
6
|
/** 引用节点 */
|
|
7
7
|
node: Blockquote;
|
|
8
|
+
/** 自定义组件映射 */
|
|
9
|
+
components?: Record<string, any>;
|
|
10
|
+
customContainers?: Record<string, any>;
|
|
11
|
+
customCodeBlocks?: Record<string, any>;
|
|
12
|
+
codeBlockConfigs?: Record<string, {
|
|
13
|
+
takeOver?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
blockStatus?: 'pending' | 'stable' | 'completed';
|
|
8
16
|
}
|
|
9
17
|
declare const IncremarkBlockquote: import("svelte").Component<Props, {}, "">;
|
|
10
18
|
type IncremarkBlockquote = ReturnType<typeof IncremarkBlockquote>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncremarkBlockquote.svelte.d.ts","sourceRoot":"","sources":["../../src/components/IncremarkBlockquote.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIrC;;GAEG;AACH,UAAU,KAAK;IACb,WAAW;IACX,IAAI,EAAE,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"IncremarkBlockquote.svelte.d.ts","sourceRoot":"","sources":["../../src/components/IncremarkBlockquote.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIrC;;GAEG;AACH,UAAU,KAAK;IACb,WAAW;IACX,IAAI,EAAE,UAAU,CAAA;IAChB,cAAc;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACzD,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAA;CACjD;AAoBH,QAAA,MAAM,mBAAmB,2CAAwC,CAAC;AAClE,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
|
|
@@ -14,9 +14,15 @@
|
|
|
14
14
|
interface Props {
|
|
15
15
|
/** 列表节点 */
|
|
16
16
|
node: List
|
|
17
|
+
/** 自定义组件映射 */
|
|
18
|
+
components?: Record<string, any>
|
|
19
|
+
customContainers?: Record<string, any>
|
|
20
|
+
customCodeBlocks?: Record<string, any>
|
|
21
|
+
codeBlockConfigs?: Record<string, { takeOver?: boolean }>
|
|
22
|
+
blockStatus?: 'pending' | 'stable' | 'completed'
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
let { node }: Props = $props()
|
|
25
|
+
let { node, components, customContainers, customCodeBlocks, codeBlockConfigs, blockStatus }: Props = $props()
|
|
20
26
|
|
|
21
27
|
/**
|
|
22
28
|
* 根据 ordered 属性计算标签名
|
|
@@ -99,7 +105,14 @@
|
|
|
99
105
|
<IncremarkInline nodes={getItemInlineContent(item)} />
|
|
100
106
|
<!-- 递归渲染所有块级内容(嵌套列表、heading、blockquote、code、table 等) -->
|
|
101
107
|
{#each getItemBlockChildren(item) as child, childIndex (childIndex)}
|
|
102
|
-
<IncremarkRenderer
|
|
108
|
+
<IncremarkRenderer
|
|
109
|
+
node={child}
|
|
110
|
+
{components}
|
|
111
|
+
{customContainers}
|
|
112
|
+
{customCodeBlocks}
|
|
113
|
+
{codeBlockConfigs}
|
|
114
|
+
{blockStatus}
|
|
115
|
+
/>
|
|
103
116
|
{/each}
|
|
104
117
|
{/if}
|
|
105
118
|
</li>
|
|
@@ -5,6 +5,14 @@ import type { List } from 'mdast';
|
|
|
5
5
|
interface Props {
|
|
6
6
|
/** 列表节点 */
|
|
7
7
|
node: List;
|
|
8
|
+
/** 自定义组件映射 */
|
|
9
|
+
components?: Record<string, any>;
|
|
10
|
+
customContainers?: Record<string, any>;
|
|
11
|
+
customCodeBlocks?: Record<string, any>;
|
|
12
|
+
codeBlockConfigs?: Record<string, {
|
|
13
|
+
takeOver?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
blockStatus?: 'pending' | 'stable' | 'completed';
|
|
8
16
|
}
|
|
9
17
|
declare const IncremarkList: import("svelte").Component<Props, {}, "">;
|
|
10
18
|
type IncremarkList = ReturnType<typeof IncremarkList>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncremarkList.svelte.d.ts","sourceRoot":"","sources":["../../src/components/IncremarkList.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAyB,MAAM,OAAO,CAAA;AAKtD;;GAEG;AACH,UAAU,KAAK;IACb,WAAW;IACX,IAAI,EAAE,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"IncremarkList.svelte.d.ts","sourceRoot":"","sources":["../../src/components/IncremarkList.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAyB,MAAM,OAAO,CAAA;AAKtD;;GAEG;AACH,UAAU,KAAK;IACb,WAAW;IACX,IAAI,EAAE,IAAI,CAAA;IACV,cAAc;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACzD,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAA;CACjD;AAyFH,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -100,6 +100,26 @@
|
|
|
100
100
|
blockStatus={blockStatus}
|
|
101
101
|
defaultCodeComponent={components?.['code']}
|
|
102
102
|
/>
|
|
103
|
+
<!-- 列表节点:传递所有 props -->
|
|
104
|
+
{:else if node.type === 'list'}
|
|
105
|
+
<IncremarkList
|
|
106
|
+
node={node}
|
|
107
|
+
{components}
|
|
108
|
+
{customContainers}
|
|
109
|
+
{customCodeBlocks}
|
|
110
|
+
{codeBlockConfigs}
|
|
111
|
+
{blockStatus}
|
|
112
|
+
/>
|
|
113
|
+
<!-- 引用块节点:传递所有 props -->
|
|
114
|
+
{:else if node.type === 'blockquote'}
|
|
115
|
+
<IncremarkBlockquote
|
|
116
|
+
node={node}
|
|
117
|
+
{components}
|
|
118
|
+
{customContainers}
|
|
119
|
+
{customCodeBlocks}
|
|
120
|
+
{codeBlockConfigs}
|
|
121
|
+
{blockStatus}
|
|
122
|
+
/>
|
|
103
123
|
{:else}
|
|
104
124
|
<!-- 其他节点:使用对应组件 -->
|
|
105
125
|
{@const Component = getComponent(node.type)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncremarkRenderer.svelte.d.ts","sourceRoot":"","sources":["../../src/components/IncremarkRenderer.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,OAAO,CAAA;AAW9C,OAA2B,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGnF;;GAEG;AACH,UAAU,KAAK;IACb,aAAa;IACb,IAAI,EAAE,WAAW,GAAG,aAAa,CAAA;IACjC,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACzD,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAA;CACjD;
|
|
1
|
+
{"version":3,"file":"IncremarkRenderer.svelte.d.ts","sourceRoot":"","sources":["../../src/components/IncremarkRenderer.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,OAAO,CAAA;AAW9C,OAA2B,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGnF;;GAEG;AACH,UAAU,KAAK;IACb,aAAa;IACb,IAAI,EAAE,WAAW,GAAG,aAAa,CAAA;IACjC,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACzD,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAA;CACjD;AA+FH,QAAA,MAAM,iBAAiB,2CAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Theme Context - Svelte Context 实现
|
|
3
|
+
* @description 管理主题的共享状态,使用 Svelte 5 runes 语法
|
|
4
|
+
*/
|
|
5
|
+
import type { DesignTokens } from '@incremark/theme';
|
|
6
|
+
/**
|
|
7
|
+
* 主题值类型
|
|
8
|
+
*/
|
|
9
|
+
export type ThemeValue = 'default' | 'dark' | DesignTokens | Partial<DesignTokens>;
|
|
10
|
+
/**
|
|
11
|
+
* 设置 Theme Context
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* 在父组件中调用,为子组件提供 theme context
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```svelte
|
|
18
|
+
* <script>
|
|
19
|
+
* import { setThemeContext } from '@incremark/svelte'
|
|
20
|
+
*
|
|
21
|
+
* let { theme = 'default' } = $props()
|
|
22
|
+
* setThemeContext(theme)
|
|
23
|
+
* </script>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function setThemeContext(theme: ThemeValue): void;
|
|
27
|
+
/**
|
|
28
|
+
* 获取 Theme Context
|
|
29
|
+
*
|
|
30
|
+
* @description
|
|
31
|
+
* 在子组件中调用,获取父组件提供的 theme context
|
|
32
|
+
*
|
|
33
|
+
* @returns 主题值
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```svelte
|
|
37
|
+
* <script>
|
|
38
|
+
* import { getThemeContext } from '@incremark/svelte'
|
|
39
|
+
*
|
|
40
|
+
* const theme = getThemeContext()
|
|
41
|
+
* const isDark = $derived(typeof theme === 'string' ? theme === 'dark' : false)
|
|
42
|
+
* </script>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function getThemeContext(): ThemeValue;
|
|
46
|
+
/**
|
|
47
|
+
* 使用 Theme Context Hook
|
|
48
|
+
*
|
|
49
|
+
* @description
|
|
50
|
+
* 便捷 hook,返回 theme 和 isDark 计算属性
|
|
51
|
+
*
|
|
52
|
+
* @returns 包含 theme 和 isDark 的对象
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```svelte
|
|
56
|
+
* <script>
|
|
57
|
+
* import { useThemeContext } from '@incremark/svelte'
|
|
58
|
+
*
|
|
59
|
+
* const { theme, isDark } = useThemeContext()
|
|
60
|
+
* </script>
|
|
61
|
+
*
|
|
62
|
+
* <div class:dark={isDark}>
|
|
63
|
+
* ...
|
|
64
|
+
* </div>
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function useThemeContext(): {
|
|
68
|
+
readonly theme: ThemeValue;
|
|
69
|
+
readonly isDark: boolean;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=themeContext.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeContext.svelte.d.ts","sourceRoot":"","sources":["../../src/context/themeContext.svelte.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAOlF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAEvD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAQ5C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe;oBAEd,UAAU;qBAGT,OAAO;EAKxB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Theme Context - Svelte Context 实现
|
|
3
|
+
* @description 管理主题的共享状态,使用 Svelte 5 runes 语法
|
|
4
|
+
*/
|
|
5
|
+
import { setContext, getContext } from 'svelte';
|
|
6
|
+
/**
|
|
7
|
+
* Context key
|
|
8
|
+
*/
|
|
9
|
+
const THEME_CONTEXT_KEY = Symbol('themeContext');
|
|
10
|
+
/**
|
|
11
|
+
* 设置 Theme Context
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* 在父组件中调用,为子组件提供 theme context
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```svelte
|
|
18
|
+
* <script>
|
|
19
|
+
* import { setThemeContext } from '@incremark/svelte'
|
|
20
|
+
*
|
|
21
|
+
* let { theme = 'default' } = $props()
|
|
22
|
+
* setThemeContext(theme)
|
|
23
|
+
* </script>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function setThemeContext(theme) {
|
|
27
|
+
setContext(THEME_CONTEXT_KEY, theme);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 获取 Theme Context
|
|
31
|
+
*
|
|
32
|
+
* @description
|
|
33
|
+
* 在子组件中调用,获取父组件提供的 theme context
|
|
34
|
+
*
|
|
35
|
+
* @returns 主题值
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```svelte
|
|
39
|
+
* <script>
|
|
40
|
+
* import { getThemeContext } from '@incremark/svelte'
|
|
41
|
+
*
|
|
42
|
+
* const theme = getThemeContext()
|
|
43
|
+
* const isDark = $derived(typeof theme === 'string' ? theme === 'dark' : false)
|
|
44
|
+
* </script>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function getThemeContext() {
|
|
48
|
+
const context = getContext(THEME_CONTEXT_KEY);
|
|
49
|
+
if (!context) {
|
|
50
|
+
return 'default'; // 返回默认值而不是抛出错误
|
|
51
|
+
}
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 使用 Theme Context Hook
|
|
56
|
+
*
|
|
57
|
+
* @description
|
|
58
|
+
* 便捷 hook,返回 theme 和 isDark 计算属性
|
|
59
|
+
*
|
|
60
|
+
* @returns 包含 theme 和 isDark 的对象
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```svelte
|
|
64
|
+
* <script>
|
|
65
|
+
* import { useThemeContext } from '@incremark/svelte'
|
|
66
|
+
*
|
|
67
|
+
* const { theme, isDark } = useThemeContext()
|
|
68
|
+
* </script>
|
|
69
|
+
*
|
|
70
|
+
* <div class:dark={isDark}>
|
|
71
|
+
* ...
|
|
72
|
+
* </div>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function useThemeContext() {
|
|
76
|
+
return {
|
|
77
|
+
get theme() {
|
|
78
|
+
return getThemeContext();
|
|
79
|
+
},
|
|
80
|
+
get isDark() {
|
|
81
|
+
const currentTheme = getThemeContext();
|
|
82
|
+
return typeof currentTheme === 'string' ? currentTheme === 'dark' : false;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { useIncremark, type UseIncremarkOptions, type UseIncremarkReturn, type T
|
|
|
6
6
|
export { useBlockTransformer, type UseBlockTransformerOptions, type UseBlockTransformerReturn } from './stores/useBlockTransformer.svelte.ts';
|
|
7
7
|
export { useLocale, type UseLocaleReturn } from './stores/useLocale.svelte.ts';
|
|
8
8
|
export { setDefinitionsContext, getDefinitionsContext, type DefinitionsContextValue } from './context/definitionsContext.svelte.ts';
|
|
9
|
+
export { setThemeContext, getThemeContext, useThemeContext, type ThemeValue } from './context/themeContext.svelte.ts';
|
|
9
10
|
export { Incremark, IncremarkContent, IncremarkParagraph, IncremarkInline, IncremarkHeading, IncremarkCode, IncremarkList, IncremarkTable, IncremarkBlockquote, IncremarkThematicBreak, IncremarkMath, IncremarkHtmlElement, IncremarkFootnotes, IncremarkDefault, IncremarkRenderer, type ComponentMap, type RenderableBlock, type IncremarkContentProps, type CodeBlockConfig } from './components';
|
|
10
11
|
export { default as AutoScrollContainer } from './components/AutoScrollContainer.svelte';
|
|
11
12
|
export { default as ThemeProvider } from './ThemeProvider.svelte';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAClK,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9E,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAClK,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9E,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AACnI,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAGrH,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AACxF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAG9E,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,IAAI,EACJ,WAAW,EAEX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AAGxB,YAAY,EACV,IAAI,IAAI,SAAS,EACjB,MAAM,EAEN,OAAO,EACP,SAAS,EACT,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,SAAS,EACT,aAAa,EAEb,IAAI,EACJ,eAAe,EACf,UAAU,EACV,IAAI,EACJ,aAAa,EACb,KAAK,EACL,cAAc,EAEd,IAAI,EAEJ,UAAU,EACV,kBAAkB,EACnB,MAAM,OAAO,CAAA;AAGd,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,eAAe,EACf,aAAa,EACb,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,YAAY,EACb,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EACL,KAAK,YAAY,EACjB,YAAY,EACZ,SAAS,EACT,eAAe,EACf,UAAU,EACV,UAAU,EACX,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,UAAU,IAAI,IAAI,EAAE,CAAA;AAC7C,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { useBlockTransformer } from './stores/useBlockTransformer.svelte.ts';
|
|
|
8
8
|
export { useLocale } from './stores/useLocale.svelte.ts';
|
|
9
9
|
// Context
|
|
10
10
|
export { setDefinitionsContext, getDefinitionsContext } from './context/definitionsContext.svelte.ts';
|
|
11
|
+
export { setThemeContext, getThemeContext, useThemeContext } from './context/themeContext.svelte.ts';
|
|
11
12
|
// Components
|
|
12
13
|
export { Incremark, IncremarkContent, IncremarkParagraph, IncremarkInline, IncremarkHeading, IncremarkCode, IncremarkList, IncremarkTable, IncremarkBlockquote, IncremarkThematicBreak, IncremarkMath, IncremarkHtmlElement, IncremarkFootnotes, IncremarkDefault, IncremarkRenderer } from './components';
|
|
13
14
|
// Additional Components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@incremark/svelte",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "High-performance streaming markdown renderer for Svelte 5 ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"@antfu/utils": "^9.3.0",
|
|
27
27
|
"shiki": "^3.20.0",
|
|
28
28
|
"shiki-stream": "^0.1.4",
|
|
29
|
-
"@incremark/core": "0.3.
|
|
30
|
-
"@incremark/
|
|
31
|
-
"@incremark/
|
|
32
|
-
"@incremark/
|
|
33
|
-
"@incremark/
|
|
29
|
+
"@incremark/core": "0.3.7",
|
|
30
|
+
"@incremark/theme": "0.3.7",
|
|
31
|
+
"@incremark/devtools": "0.3.7",
|
|
32
|
+
"@incremark/shared": "0.3.7",
|
|
33
|
+
"@incremark/icons": "0.3.7"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"svelte": "^5.
|
|
36
|
+
"svelte": "^5.46.1",
|
|
37
37
|
"mermaid": "^10.0.0 || ^11.0.0",
|
|
38
38
|
"katex": "^0.16.0"
|
|
39
39
|
},
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"@shikijs/core": "^3.21.0",
|
|
50
50
|
"@types/mdast": "^4.0.0",
|
|
51
51
|
"@sveltejs/package": "^2.4.0",
|
|
52
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
53
|
-
"svelte": "^5.
|
|
54
|
-
"typescript": "^5.3
|
|
52
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
53
|
+
"svelte": "^5.46.1",
|
|
54
|
+
"typescript": "^5.9.3"
|
|
55
55
|
},
|
|
56
56
|
"keywords": [
|
|
57
57
|
"markdown",
|