@objectifthunes/limestone-sdk 0.1.8 → 0.1.9
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 +50 -18
- package/dist/components/content/block-quote/block-quote.d.ts +4 -0
- package/dist/components/content/block-quote/block-quote.d.ts.map +1 -0
- package/dist/components/content/block-quote/block-quote.js +12 -0
- package/dist/components/content/block-quote/block-quote.js.map +1 -0
- package/dist/components/content/block-quote/index.d.ts +4 -0
- package/dist/components/content/block-quote/index.d.ts.map +1 -0
- package/dist/components/content/block-quote/index.js +4 -0
- package/dist/components/content/block-quote/index.js.map +1 -0
- package/dist/components/content/block-quote/types.d.ts +26 -0
- package/dist/components/content/block-quote/types.d.ts.map +1 -0
- package/dist/components/content/block-quote/types.js +2 -0
- package/dist/components/content/block-quote/types.js.map +1 -0
- package/dist/components/content/block-quote/use-block-quote.d.ts +4 -0
- package/dist/components/content/block-quote/use-block-quote.d.ts.map +1 -0
- package/dist/components/content/block-quote/use-block-quote.js +59 -0
- package/dist/components/content/block-quote/use-block-quote.js.map +1 -0
- package/dist/components/content/callout/callout.d.ts +4 -0
- package/dist/components/content/callout/callout.d.ts.map +1 -0
- package/dist/components/content/callout/callout.js +12 -0
- package/dist/components/content/callout/callout.js.map +1 -0
- package/dist/components/content/callout/index.d.ts +4 -0
- package/dist/components/content/callout/index.d.ts.map +1 -0
- package/dist/components/content/callout/index.js +4 -0
- package/dist/components/content/callout/index.js.map +1 -0
- package/dist/components/content/callout/types.d.ts +33 -0
- package/dist/components/content/callout/types.d.ts.map +1 -0
- package/dist/components/content/callout/types.js +2 -0
- package/dist/components/content/callout/types.js.map +1 -0
- package/dist/components/content/callout/use-callout.d.ts +4 -0
- package/dist/components/content/callout/use-callout.d.ts.map +1 -0
- package/dist/components/content/callout/use-callout.js +81 -0
- package/dist/components/content/callout/use-callout.js.map +1 -0
- package/dist/components/content/code-block/code-block.d.ts +4 -0
- package/dist/components/content/code-block/code-block.d.ts.map +1 -0
- package/dist/components/content/code-block/code-block.js +12 -0
- package/dist/components/content/code-block/code-block.js.map +1 -0
- package/dist/components/content/code-block/index.d.ts +4 -0
- package/dist/components/content/code-block/index.d.ts.map +1 -0
- package/dist/components/content/code-block/index.js +4 -0
- package/dist/components/content/code-block/index.js.map +1 -0
- package/dist/components/content/code-block/types.d.ts +35 -0
- package/dist/components/content/code-block/types.d.ts.map +1 -0
- package/dist/components/content/code-block/types.js +2 -0
- package/dist/components/content/code-block/types.js.map +1 -0
- package/dist/components/content/code-block/use-code-block.d.ts +4 -0
- package/dist/components/content/code-block/use-code-block.d.ts.map +1 -0
- package/dist/components/content/code-block/use-code-block.js +81 -0
- package/dist/components/content/code-block/use-code-block.js.map +1 -0
- package/dist/components/content/index.d.ts +11 -0
- package/dist/components/content/index.d.ts.map +1 -0
- package/dist/components/content/index.js +7 -0
- package/dist/components/content/index.js.map +1 -0
- package/dist/components/content/markdown-renderer/index.d.ts +4 -0
- package/dist/components/content/markdown-renderer/index.d.ts.map +1 -0
- package/dist/components/content/markdown-renderer/index.js +4 -0
- package/dist/components/content/markdown-renderer/index.js.map +1 -0
- package/dist/components/content/markdown-renderer/markdown-renderer.d.ts +4 -0
- package/dist/components/content/markdown-renderer/markdown-renderer.d.ts.map +1 -0
- package/dist/components/content/markdown-renderer/markdown-renderer.js +12 -0
- package/dist/components/content/markdown-renderer/markdown-renderer.js.map +1 -0
- package/dist/components/content/markdown-renderer/types.d.ts +40 -0
- package/dist/components/content/markdown-renderer/types.d.ts.map +1 -0
- package/dist/components/content/markdown-renderer/types.js +2 -0
- package/dist/components/content/markdown-renderer/types.js.map +1 -0
- package/dist/components/content/markdown-renderer/use-markdown-renderer.d.ts +4 -0
- package/dist/components/content/markdown-renderer/use-markdown-renderer.d.ts.map +1 -0
- package/dist/components/content/markdown-renderer/use-markdown-renderer.js +177 -0
- package/dist/components/content/markdown-renderer/use-markdown-renderer.js.map +1 -0
- package/dist/components/content/rich-text-editor/index.d.ts +4 -0
- package/dist/components/content/rich-text-editor/index.d.ts.map +1 -0
- package/dist/components/content/rich-text-editor/index.js +4 -0
- package/dist/components/content/rich-text-editor/index.js.map +1 -0
- package/dist/components/content/rich-text-editor/rich-text-editor.d.ts +4 -0
- package/dist/components/content/rich-text-editor/rich-text-editor.d.ts.map +1 -0
- package/dist/components/content/rich-text-editor/rich-text-editor.js +12 -0
- package/dist/components/content/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/components/content/rich-text-editor/types.d.ts +37 -0
- package/dist/components/content/rich-text-editor/types.d.ts.map +1 -0
- package/dist/components/content/rich-text-editor/types.js +2 -0
- package/dist/components/content/rich-text-editor/types.js.map +1 -0
- package/dist/components/content/rich-text-editor/use-rich-text-editor.d.ts +4 -0
- package/dist/components/content/rich-text-editor/use-rich-text-editor.d.ts.map +1 -0
- package/dist/components/content/rich-text-editor/use-rich-text-editor.js +78 -0
- package/dist/components/content/rich-text-editor/use-rich-text-editor.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export function useCodeBlock(tokens, props) {
|
|
2
|
+
const { code, language, showLineNumbers = false, showCopyButton = true, showLanguageBadge = true, maxHeight, accessibilityLabel, } = props;
|
|
3
|
+
const resolvedLanguage = language?.toLowerCase() ?? '';
|
|
4
|
+
const showLanguageBadgeResolved = showLanguageBadge && !!language;
|
|
5
|
+
const showHeader = showCopyButton || showLanguageBadgeResolved;
|
|
6
|
+
// Compute line count; strip trailing newline to avoid phantom line
|
|
7
|
+
const trimmed = code.endsWith('\n') ? code.trimEnd() : code;
|
|
8
|
+
const lineCount = trimmed.split('\n').length;
|
|
9
|
+
const containerStyle = {
|
|
10
|
+
backgroundColor: tokens.colors.card,
|
|
11
|
+
borderRadius: tokens.radii.md,
|
|
12
|
+
overflow: 'hidden',
|
|
13
|
+
};
|
|
14
|
+
const headerStyle = {
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'space-between',
|
|
18
|
+
paddingHorizontal: tokens.spacing.sm,
|
|
19
|
+
paddingVertical: tokens.spacing.xs,
|
|
20
|
+
borderBottomWidth: 1,
|
|
21
|
+
borderBottomColor: tokens.colors.border,
|
|
22
|
+
};
|
|
23
|
+
const languageBadgeStyle = {
|
|
24
|
+
fontFamily: tokens.typography.fontFamily.mono,
|
|
25
|
+
fontSize: tokens.typography.sizes.xs,
|
|
26
|
+
color: tokens.colors.mutedForeground,
|
|
27
|
+
textTransform: 'uppercase',
|
|
28
|
+
letterSpacing: 1,
|
|
29
|
+
};
|
|
30
|
+
const copyButtonStyle = {
|
|
31
|
+
padding: tokens.spacing.xs,
|
|
32
|
+
borderRadius: tokens.radii.sm,
|
|
33
|
+
};
|
|
34
|
+
const copyButtonIconColor = tokens.colors.mutedForeground;
|
|
35
|
+
const codeContainerStyle = {
|
|
36
|
+
padding: tokens.spacing.md,
|
|
37
|
+
overflow: 'scroll',
|
|
38
|
+
...(maxHeight !== undefined ? { maxHeight } : {}),
|
|
39
|
+
};
|
|
40
|
+
const lineNumberStyle = {
|
|
41
|
+
fontFamily: tokens.typography.fontFamily.mono,
|
|
42
|
+
fontSize: tokens.typography.sizes.xs,
|
|
43
|
+
color: tokens.colors.mutedForeground,
|
|
44
|
+
width: 32,
|
|
45
|
+
textAlign: 'right',
|
|
46
|
+
paddingRight: tokens.spacing.sm,
|
|
47
|
+
lineHeight: tokens.typography.sizes.sm * tokens.typography.lineHeights.relaxed,
|
|
48
|
+
};
|
|
49
|
+
const codeTextStyle = {
|
|
50
|
+
fontFamily: tokens.typography.fontFamily.mono,
|
|
51
|
+
fontSize: tokens.typography.sizes.sm,
|
|
52
|
+
color: tokens.colors.foreground,
|
|
53
|
+
lineHeight: tokens.typography.sizes.sm * tokens.typography.lineHeights.relaxed,
|
|
54
|
+
};
|
|
55
|
+
const getLineStyle = (_index) => ({
|
|
56
|
+
flexDirection: 'row',
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
containerStyle,
|
|
60
|
+
headerStyle,
|
|
61
|
+
languageBadgeStyle,
|
|
62
|
+
copyButtonStyle,
|
|
63
|
+
copyButtonIconColor,
|
|
64
|
+
codeContainerStyle,
|
|
65
|
+
lineNumberStyle,
|
|
66
|
+
codeTextStyle,
|
|
67
|
+
lineCount,
|
|
68
|
+
getLineStyle,
|
|
69
|
+
showHeader,
|
|
70
|
+
showLineNumbers,
|
|
71
|
+
showCopyButton,
|
|
72
|
+
showLanguageBadge: showLanguageBadgeResolved,
|
|
73
|
+
resolvedLanguage,
|
|
74
|
+
accessibilityProps: {
|
|
75
|
+
accessibilityLabel: accessibilityLabel ?? `${resolvedLanguage} code block`,
|
|
76
|
+
accessibilityRole: 'none',
|
|
77
|
+
accessibilityHint: 'Code block. Double-tap copy button to copy code.',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=use-code-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-code-block.js","sourceRoot":"","sources":["../../../../src/components/content/code-block/use-code-block.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,KAAqB;IAErB,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR,eAAe,GAAG,KAAK,EACvB,cAAc,GAAG,IAAI,EACrB,iBAAiB,GAAG,IAAI,EACxB,SAAS,EACT,kBAAkB,GACnB,GAAG,KAAK,CAAC;IAEV,MAAM,gBAAgB,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAEvD,MAAM,yBAAyB,GAAG,iBAAiB,IAAI,CAAC,CAAC,QAAQ,CAAC;IAClE,MAAM,UAA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kB,EAAE,kBAAkB,IAAI,GAAG,gBAAgB,aAAa;YAC1E,iBAAiB,EAAE,MAAM;YACzB,iBAAiB,EAAE,kDAAkD;SACtE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { MarkdownRenderer, useMarkdownRenderer, } from './markdown-renderer/index.js';
|
|
2
|
+
export type { MarkdownRendererProps, UseMarkdownRendererResult } from './markdown-renderer/index.js';
|
|
3
|
+
export { CodeBlock, useCodeBlock, } from './code-block/index.js';
|
|
4
|
+
export type { CodeBlockProps, UseCodeBlockResult } from './code-block/index.js';
|
|
5
|
+
export { RichTextEditor, useRichTextEditor, } from './rich-text-editor/index.js';
|
|
6
|
+
export type { RichTextEditorProps, UseRichTextEditorResult, ToolbarAction } from './rich-text-editor/index.js';
|
|
7
|
+
export { BlockQuote, useBlockQuote, } from './block-quote/index.js';
|
|
8
|
+
export type { BlockQuoteProps, UseBlockQuoteResult } from './block-quote/index.js';
|
|
9
|
+
export { Callout, useCallout, } from './callout/index.js';
|
|
10
|
+
export type { CalloutProps, UseCalloutResult, CalloutType } from './callout/index.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/content/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAAE,mBAAmB,GACtC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAErG,OAAO,EACL,SAAS,EAAE,YAAY,GACxB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EACL,cAAc,EAAE,iBAAiB,GAClC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE/G,OAAO,EACL,UAAU,EAAE,aAAa,GAC1B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EACL,OAAO,EAAE,UAAU,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/components/content/index.ts
|
|
2
|
+
export { MarkdownRenderer, useMarkdownRenderer, } from './markdown-renderer/index.js';
|
|
3
|
+
export { CodeBlock, useCodeBlock, } from './code-block/index.js';
|
|
4
|
+
export { RichTextEditor, useRichTextEditor, } from './rich-text-editor/index.js';
|
|
5
|
+
export { BlockQuote, useBlockQuote, } from './block-quote/index.js';
|
|
6
|
+
export { Callout, useCallout, } from './callout/index.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/content/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EACL,gBAAgB,EAAE,mBAAmB,GACtC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,SAAS,EAAE,YAAY,GACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,cAAc,EAAE,iBAAiB,GAClC,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,UAAU,EAAE,aAAa,GAC1B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,OAAO,EAAE,UAAU,GACpB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { View, type ViewProps } from 'react-native';
|
|
2
|
+
import type { MarkdownRendererProps } from './types.js';
|
|
3
|
+
export declare const MarkdownRenderer: import("react").ForwardRefExoticComponent<MarkdownRendererProps & Omit<ViewProps, keyof MarkdownRendererProps> & import("react").RefAttributes<View>>;
|
|
4
|
+
//# sourceMappingURL=markdown-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/markdown-renderer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,eAAO,MAAM,gBAAgB,uJA0B3B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/components/content/markdown-renderer/markdown-renderer.tsx
|
|
2
|
+
import { forwardRef, createElement } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { useTheme } from '../../../theme/context.js';
|
|
5
|
+
import { useMarkdownRenderer } from './use-markdown-renderer.js';
|
|
6
|
+
export const MarkdownRenderer = forwardRef(function MarkdownRenderer(props, ref) {
|
|
7
|
+
const { tokens } = useTheme();
|
|
8
|
+
const { content: _content, onLinkPress: _onLinkPress, baseTextSize: _baseTextSize, showLineNumbers: _showLineNumbers, bg: _bg, p: _p, px: _px, py: _py, pt: _pt, pb: _pb, pl: _pl, pr: _pr, m: _m, mx: _mx, my: _my, mt: _mt, mb: _mb, ml: _ml, mr: _mr, rounded: _r, shadow: _sh, flex: _f, row: _row, center: _cen, w: _w, h: _h, borderWidth: _bw, borderColor: _bc, opacity: _op, overflow: _ov, position: _pos, top: _top, bottom: _bot, left: _left, right: _right, zIndex: _zi, accessibilityLabel: _al, testID, ...rest } = props;
|
|
9
|
+
const { containerStyle, accessibilityProps } = useMarkdownRenderer(tokens, props);
|
|
10
|
+
return createElement(View, { ref, style: containerStyle, ...accessibilityProps, testID, ...rest });
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=markdown-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-renderer.js","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/markdown-renderer.tsx"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAY,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,gBAAgB,CAClE,KAA2E,EAC3E,GAAc;IAEd,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC9B,MAAM,EACJ,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,aAAa,EAC3B,eAAe,EAAE,gBAAgB,EACjC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EACpE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAC3D,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAC9D,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAC/F,kBAAkB,EAAE,GAAG,EACvB,MAAM,EACN,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAElF,OAAO,aAAa,CAClB,IAAW,EACX,EAAE,GAAG,EAAE,KAAK,EAAE,cAAqB,EAAE,GAAG,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAC9E,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
import type { BoxStyleProps } from '../../types.js';
|
|
3
|
+
export interface MarkdownRendererProps extends BoxStyleProps {
|
|
4
|
+
content: string;
|
|
5
|
+
onLinkPress?: (url: string) => void;
|
|
6
|
+
baseTextSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
7
|
+
showLineNumbers?: boolean;
|
|
8
|
+
accessibilityLabel?: string;
|
|
9
|
+
testID?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UseMarkdownRendererResult {
|
|
12
|
+
containerStyle: ViewStyle;
|
|
13
|
+
h1Style: TextStyle;
|
|
14
|
+
h2Style: TextStyle;
|
|
15
|
+
h3Style: TextStyle;
|
|
16
|
+
h4Style: TextStyle;
|
|
17
|
+
h5Style: TextStyle;
|
|
18
|
+
h6Style: TextStyle;
|
|
19
|
+
paragraphStyle: TextStyle;
|
|
20
|
+
boldStyle: TextStyle;
|
|
21
|
+
italicStyle: TextStyle;
|
|
22
|
+
linkStyle: TextStyle;
|
|
23
|
+
listItemStyle: ViewStyle;
|
|
24
|
+
bulletStyle: TextStyle;
|
|
25
|
+
orderedNumberStyle: TextStyle;
|
|
26
|
+
inlineCodeStyle: TextStyle;
|
|
27
|
+
codeBlockStyle: ViewStyle;
|
|
28
|
+
codeBlockTextStyle: TextStyle;
|
|
29
|
+
blockquoteStyle: ViewStyle;
|
|
30
|
+
blockquoteTextStyle: TextStyle;
|
|
31
|
+
hrStyle: ViewStyle;
|
|
32
|
+
imageContainerStyle: ViewStyle;
|
|
33
|
+
resolvedBaseSize: number;
|
|
34
|
+
showLineNumbers: boolean;
|
|
35
|
+
accessibilityProps: {
|
|
36
|
+
accessibilityLabel: string;
|
|
37
|
+
accessibilityRole: 'text';
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC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er/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ThemeTokens } from '../../../theme/tokens.js';
|
|
2
|
+
import type { MarkdownRendererProps, UseMarkdownRendererResult } from './types.js';
|
|
3
|
+
export declare function useMarkdownRenderer(tokens: ThemeTokens, props: MarkdownRendererProps): UseMarkdownRendererResult;
|
|
4
|
+
//# sourceMappingURL=use-markdown-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/use-markdown-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAUnF,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,qBAAqB,GAC3B,yBAAyB,CAmM3B"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const BASE_SIZE_MAP = {
|
|
2
|
+
xs: 'xs',
|
|
3
|
+
sm: 'sm',
|
|
4
|
+
md: 'md',
|
|
5
|
+
lg: 'lg',
|
|
6
|
+
xl: 'xl',
|
|
7
|
+
};
|
|
8
|
+
export function useMarkdownRenderer(tokens, props) {
|
|
9
|
+
const { baseTextSize = 'md', showLineNumbers = false, accessibilityLabel, } = props;
|
|
10
|
+
const sizeKey = BASE_SIZE_MAP[baseTextSize] ?? 'md';
|
|
11
|
+
const resolvedBaseSize = tokens.typography.sizes[sizeKey];
|
|
12
|
+
const containerStyle = {
|
|
13
|
+
flex: 1,
|
|
14
|
+
};
|
|
15
|
+
const h1Style = {
|
|
16
|
+
fontFamily: tokens.typography.fontFamily.display,
|
|
17
|
+
fontSize: tokens.typography.sizes['3xl'],
|
|
18
|
+
fontWeight: tokens.typography.weights.bold,
|
|
19
|
+
color: tokens.colors.foreground,
|
|
20
|
+
lineHeight: tokens.typography.sizes['3xl'] * tokens.typography.lineHeights.tight,
|
|
21
|
+
marginBottom: tokens.spacing.md,
|
|
22
|
+
marginTop: tokens.spacing.lg,
|
|
23
|
+
};
|
|
24
|
+
const h2Style = {
|
|
25
|
+
fontFamily: tokens.typography.fontFamily.display,
|
|
26
|
+
fontSize: tokens.typography.sizes['2xl'],
|
|
27
|
+
fontWeight: tokens.typography.weights.bold,
|
|
28
|
+
color: tokens.colors.foreground,
|
|
29
|
+
lineHeight: tokens.typography.sizes['2xl'] * tokens.typography.lineHeights.tight,
|
|
30
|
+
marginBottom: tokens.spacing.sm,
|
|
31
|
+
marginTop: tokens.spacing.md,
|
|
32
|
+
};
|
|
33
|
+
const h3Style = {
|
|
34
|
+
fontFamily: tokens.typography.fontFamily.display,
|
|
35
|
+
fontSize: tokens.typography.sizes.xl,
|
|
36
|
+
fontWeight: tokens.typography.weights.bold,
|
|
37
|
+
color: tokens.colors.foreground,
|
|
38
|
+
lineHeight: tokens.typography.sizes.xl * tokens.typography.lineHeights.tight,
|
|
39
|
+
marginBottom: tokens.spacing.sm,
|
|
40
|
+
marginTop: tokens.spacing.md,
|
|
41
|
+
};
|
|
42
|
+
const h4Style = {
|
|
43
|
+
fontFamily: tokens.typography.fontFamily.display,
|
|
44
|
+
fontSize: tokens.typography.sizes.lg,
|
|
45
|
+
fontWeight: tokens.typography.weights.bold,
|
|
46
|
+
color: tokens.colors.foreground,
|
|
47
|
+
lineHeight: tokens.typography.sizes.lg * tokens.typography.lineHeights.tight,
|
|
48
|
+
marginBottom: tokens.spacing.xs,
|
|
49
|
+
marginTop: tokens.spacing.sm,
|
|
50
|
+
};
|
|
51
|
+
const h5Style = {
|
|
52
|
+
fontFamily: tokens.typography.fontFamily.display,
|
|
53
|
+
fontSize: tokens.typography.sizes.md,
|
|
54
|
+
fontWeight: tokens.typography.weights.bold,
|
|
55
|
+
color: tokens.colors.foreground,
|
|
56
|
+
lineHeight: tokens.typography.sizes.md * tokens.typography.lineHeights.tight,
|
|
57
|
+
marginBottom: tokens.spacing.xs,
|
|
58
|
+
marginTop: tokens.spacing.sm,
|
|
59
|
+
};
|
|
60
|
+
const h6Style = {
|
|
61
|
+
fontFamily: tokens.typography.fontFamily.display,
|
|
62
|
+
fontSize: tokens.typography.sizes.sm,
|
|
63
|
+
fontWeight: tokens.typography.weights.bold,
|
|
64
|
+
color: tokens.colors.mutedForeground,
|
|
65
|
+
lineHeight: tokens.typography.sizes.sm * tokens.typography.lineHeights.tight,
|
|
66
|
+
marginBottom: tokens.spacing.xs,
|
|
67
|
+
marginTop: tokens.spacing.sm,
|
|
68
|
+
};
|
|
69
|
+
const paragraphStyle = {
|
|
70
|
+
fontSize: resolvedBaseSize,
|
|
71
|
+
color: tokens.colors.foreground,
|
|
72
|
+
lineHeight: resolvedBaseSize * tokens.typography.lineHeights.normal,
|
|
73
|
+
marginBottom: tokens.spacing.sm,
|
|
74
|
+
};
|
|
75
|
+
const boldStyle = {
|
|
76
|
+
fontWeight: tokens.typography.weights.bold,
|
|
77
|
+
};
|
|
78
|
+
const italicStyle = {
|
|
79
|
+
fontStyle: 'italic',
|
|
80
|
+
};
|
|
81
|
+
const linkStyle = {
|
|
82
|
+
color: tokens.colors.primary,
|
|
83
|
+
textDecorationLine: 'underline',
|
|
84
|
+
};
|
|
85
|
+
const listItemStyle = {
|
|
86
|
+
flexDirection: 'row',
|
|
87
|
+
marginBottom: tokens.spacing.xs,
|
|
88
|
+
paddingLeft: tokens.spacing.md,
|
|
89
|
+
};
|
|
90
|
+
const bulletStyle = {
|
|
91
|
+
fontSize: resolvedBaseSize,
|
|
92
|
+
color: tokens.colors.mutedForeground,
|
|
93
|
+
marginRight: tokens.spacing.sm,
|
|
94
|
+
lineHeight: resolvedBaseSize * 1.5,
|
|
95
|
+
};
|
|
96
|
+
const orderedNumberStyle = {
|
|
97
|
+
fontSize: resolvedBaseSize,
|
|
98
|
+
color: tokens.colors.mutedForeground,
|
|
99
|
+
fontWeight: tokens.typography.weights.medium,
|
|
100
|
+
marginRight: tokens.spacing.sm,
|
|
101
|
+
minWidth: tokens.spacing.md,
|
|
102
|
+
};
|
|
103
|
+
const inlineCodeStyle = {
|
|
104
|
+
fontFamily: tokens.typography.fontFamily.mono,
|
|
105
|
+
fontSize: resolvedBaseSize - 2,
|
|
106
|
+
backgroundColor: tokens.colors.card,
|
|
107
|
+
borderRadius: tokens.radii.sm,
|
|
108
|
+
paddingHorizontal: 2,
|
|
109
|
+
color: tokens.colors.foreground,
|
|
110
|
+
};
|
|
111
|
+
const codeBlockStyle = {
|
|
112
|
+
backgroundColor: tokens.colors.card,
|
|
113
|
+
borderRadius: tokens.radii.md,
|
|
114
|
+
padding: tokens.spacing.md,
|
|
115
|
+
marginBottom: tokens.spacing.sm,
|
|
116
|
+
overflow: 'hidden',
|
|
117
|
+
};
|
|
118
|
+
const codeBlockTextStyle = {
|
|
119
|
+
fontFamily: tokens.typography.fontFamily.mono,
|
|
120
|
+
fontSize: tokens.typography.sizes.sm,
|
|
121
|
+
color: tokens.colors.foreground,
|
|
122
|
+
lineHeight: tokens.typography.sizes.sm * tokens.typography.lineHeights.relaxed,
|
|
123
|
+
};
|
|
124
|
+
const blockquoteStyle = {
|
|
125
|
+
borderLeftWidth: 3,
|
|
126
|
+
borderLeftColor: tokens.colors.primary,
|
|
127
|
+
paddingLeft: tokens.spacing.md,
|
|
128
|
+
paddingVertical: tokens.spacing.sm,
|
|
129
|
+
marginBottom: tokens.spacing.sm,
|
|
130
|
+
};
|
|
131
|
+
const blockquoteTextStyle = {
|
|
132
|
+
fontStyle: 'italic',
|
|
133
|
+
color: tokens.colors.mutedForeground,
|
|
134
|
+
fontSize: resolvedBaseSize,
|
|
135
|
+
};
|
|
136
|
+
const hrStyle = {
|
|
137
|
+
height: 1,
|
|
138
|
+
backgroundColor: tokens.colors.border,
|
|
139
|
+
marginVertical: tokens.spacing.md,
|
|
140
|
+
};
|
|
141
|
+
const imageContainerStyle = {
|
|
142
|
+
width: '100%',
|
|
143
|
+
marginBottom: tokens.spacing.sm,
|
|
144
|
+
borderRadius: tokens.radii.md,
|
|
145
|
+
overflow: 'hidden',
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
containerStyle,
|
|
149
|
+
h1Style,
|
|
150
|
+
h2Style,
|
|
151
|
+
h3Style,
|
|
152
|
+
h4Style,
|
|
153
|
+
h5Style,
|
|
154
|
+
h6Style,
|
|
155
|
+
paragraphStyle,
|
|
156
|
+
boldStyle,
|
|
157
|
+
italicStyle,
|
|
158
|
+
linkStyle,
|
|
159
|
+
listItemStyle,
|
|
160
|
+
bulletStyle,
|
|
161
|
+
orderedNumberStyle,
|
|
162
|
+
inlineCodeStyle,
|
|
163
|
+
codeBlockStyle,
|
|
164
|
+
codeBlockTextStyle,
|
|
165
|
+
blockquoteStyle,
|
|
166
|
+
blockquoteTextStyle,
|
|
167
|
+
hrStyle,
|
|
168
|
+
imageContainerStyle,
|
|
169
|
+
resolvedBaseSize,
|
|
170
|
+
showLineNumbers,
|
|
171
|
+
accessibilityProps: {
|
|
172
|
+
accessibilityLabel: accessibilityLabel ?? 'Markdown content',
|
|
173
|
+
accessibilityRole: 'text',
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=use-markdown-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-markdown-renderer.js","sourceRoot":"","sources":["../../../../src/components/content/markdown-renderer/use-markdown-renderer.ts"],"names":[],"mappings":"AAIA,MAAM,aAAa,GAA6D;IAC9E,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACT,CAAC;AAEF,MAAM,UAAU,mBAAmB,CACjC,MAAmB,EACnB,KAA4B;IAE5B,MAAM,EACJ,YAAY,GAAG,IAAI,EACnB,eAAe,GAAG,KAAK,EACvB,kBA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eAAe;QACf,kBAAkB,EAAE;YAClB,kBAAkB,EAAE,kBAAkB,IAAI,kBAAkB;YAC5D,iBAAiB,EAAE,MAAM;SAC1B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { View, type ViewProps } from 'react-native';
|
|
2
|
+
import type { RichTextEditorProps } from './types.js';
|
|
3
|
+
export declare const RichTextEditor: import("react").ForwardRefExoticComponent<RichTextEditorProps & Omit<ViewProps, keyof RichTextEditorProps> & import("react").RefAttributes<View>>;
|
|
4
|
+
//# sourceMappingURL=rich-text-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/rich-text-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,cAAc,mJA8BzB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/components/content/rich-text-editor/rich-text-editor.tsx
|
|
2
|
+
import { forwardRef, createElement } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { useTheme } from '../../../theme/context.js';
|
|
5
|
+
import { useRichTextEditor } from './use-rich-text-editor.js';
|
|
6
|
+
export const RichTextEditor = forwardRef(function RichTextEditor(props, ref) {
|
|
7
|
+
const { tokens } = useTheme();
|
|
8
|
+
const { value: _value, onValueChange: _onValueChange, placeholder: _placeholder, disabled: _disabled, showToolbar: _showToolbar, toolbarActions: _toolbarActions, activeFormats: _activeFormats, size: _size, bg: _bg, p: _p, px: _px, py: _py, pt: _pt, pb: _pb, pl: _pl, pr: _pr, m: _m, mx: _mx, my: _my, mt: _mt, mb: _mb, ml: _ml, mr: _mr, rounded: _r, shadow: _sh, flex: _f, row: _row, center: _cen, w: _w, h: _h, borderWidth: _bw, borderColor: _bc, opacity: _op, overflow: _ov, position: _pos, top: _top, bottom: _bot, left: _left, right: _right, zIndex: _zi, accessibilityLabel: _al, testID, ...rest } = props;
|
|
9
|
+
const { containerStyle, accessibilityProps } = useRichTextEditor(tokens, props);
|
|
10
|
+
return createElement(View, { ref, style: containerStyle, ...accessibilityProps, testID, ...rest });
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=rich-text-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-editor.js","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/rich-text-editor.tsx"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAY,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,SAAS,c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,CAAC,CAAC;IAEhF,OAAO,aAAa,CAClB,IAAW,EACX,EAAE,GAAG,EAAE,KAAK,EAAE,cAAqB,EAAE,GAAG,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAC9E,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
import type { BoxStyleProps } from '../../types.js';
|
|
3
|
+
export type ToolbarAction = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'list-ordered' | 'list-unordered' | 'link';
|
|
4
|
+
export interface RichTextEditorProps extends BoxStyleProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
showToolbar?: boolean;
|
|
10
|
+
toolbarActions?: ToolbarAction[];
|
|
11
|
+
activeFormats?: Set<ToolbarAction>;
|
|
12
|
+
size?: 'sm' | 'md' | 'lg';
|
|
13
|
+
accessibilityLabel?: string;
|
|
14
|
+
testID?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface UseRichTextEditorResult {
|
|
17
|
+
containerStyle: ViewStyle;
|
|
18
|
+
toolbarStyle: ViewStyle;
|
|
19
|
+
getToolbarButtonStyle: (action: ToolbarAction, active: boolean) => ViewStyle;
|
|
20
|
+
getToolbarButtonIconColor: (action: ToolbarAction, active: boolean) => string;
|
|
21
|
+
toolbarButtonIconSize: number;
|
|
22
|
+
editorStyle: ViewStyle;
|
|
23
|
+
editorMinHeight: number;
|
|
24
|
+
editorTextStyle: TextStyle;
|
|
25
|
+
placeholderStyle: TextStyle;
|
|
26
|
+
resolvedToolbarActions: ToolbarAction[];
|
|
27
|
+
showToolbar: boolean;
|
|
28
|
+
isActionActive: (action: ToolbarAction) => boolean;
|
|
29
|
+
accessibilityProps: {
|
|
30
|
+
accessibilityLabel: string;
|
|
31
|
+
accessibilityRole: 'none';
|
|
32
|
+
accessibilityState: {
|
|
33
|
+
disabled: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,QAAQ,GACR,WAAW,GACX,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,MAAM,CAAC;AAEX,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,SAAS,CAAC;IAC1B,YAAY,EAAE,SAAS,CAAC;IACxB,qBAAqB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC;IAC7E,yBAAyB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAC9E,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,SAAS,CAAC;IAC3B,gBAAgB,EAAE,SAAS,CAAC;IAC5B,sBAAsB,EAAE,aAAa,EAAE,CAAC;IACxC,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;IACnD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE;YAAE,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAC3C,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ThemeTokens } from '../../../theme/tokens.js';
|
|
2
|
+
import type { RichTextEditorProps, UseRichTextEditorResult } from './types.js';
|
|
3
|
+
export declare function useRichTextEditor(tokens: ThemeTokens, props: RichTextEditorProps): UseRichTextEditorResult;
|
|
4
|
+
//# sourceMappingURL=use-rich-text-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rich-text-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/use-rich-text-editor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAiB,MAAM,YAAY,CAAC;AAkB9F,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,mBAAmB,GACzB,uBAAuB,CAmFzB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const DEFAULT_TOOLBAR_ACTIONS = [
|
|
2
|
+
'bold', 'italic', 'underline', 'list-ordered', 'list-unordered', 'link',
|
|
3
|
+
];
|
|
4
|
+
const EDITOR_PADDING_MAP = {
|
|
5
|
+
sm: 'sm',
|
|
6
|
+
md: 'md',
|
|
7
|
+
lg: 'lg',
|
|
8
|
+
};
|
|
9
|
+
const EDITOR_MIN_HEIGHT_MAP = {
|
|
10
|
+
sm: 80,
|
|
11
|
+
md: 120,
|
|
12
|
+
lg: 160,
|
|
13
|
+
};
|
|
14
|
+
export function useRichTextEditor(tokens, props) {
|
|
15
|
+
const { disabled = false, showToolbar: showToolbarProp = true, toolbarActions, activeFormats, size = 'md', accessibilityLabel, } = props;
|
|
16
|
+
const resolvedToolbarActions = toolbarActions ?? DEFAULT_TOOLBAR_ACTIONS;
|
|
17
|
+
const showToolbar = showToolbarProp && !disabled;
|
|
18
|
+
const editorMinHeight = EDITOR_MIN_HEIGHT_MAP[size] ?? 120;
|
|
19
|
+
const paddingKey = EDITOR_PADDING_MAP[size];
|
|
20
|
+
const editorPadding = tokens.spacing[paddingKey];
|
|
21
|
+
const containerStyle = {
|
|
22
|
+
borderWidth: 1,
|
|
23
|
+
borderColor: tokens.colors.border,
|
|
24
|
+
borderRadius: tokens.radii.md,
|
|
25
|
+
opacity: disabled ? 0.5 : 1,
|
|
26
|
+
};
|
|
27
|
+
const toolbarStyle = {
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
borderBottomWidth: 1,
|
|
30
|
+
borderBottomColor: tokens.colors.border,
|
|
31
|
+
padding: tokens.spacing.xs,
|
|
32
|
+
gap: tokens.spacing.xs,
|
|
33
|
+
flexWrap: 'wrap',
|
|
34
|
+
};
|
|
35
|
+
const getToolbarButtonStyle = (_action, active) => ({
|
|
36
|
+
paddingHorizontal: tokens.spacing.sm,
|
|
37
|
+
paddingVertical: tokens.spacing.xs,
|
|
38
|
+
borderRadius: tokens.radii.sm,
|
|
39
|
+
backgroundColor: active ? tokens.colors.primary : 'transparent',
|
|
40
|
+
});
|
|
41
|
+
const getToolbarButtonIconColor = (_action, active) => active ? tokens.colors.primaryForeground : tokens.colors.foreground;
|
|
42
|
+
const toolbarButtonIconSize = 16;
|
|
43
|
+
const editorStyle = {
|
|
44
|
+
flex: 1,
|
|
45
|
+
padding: editorPadding,
|
|
46
|
+
};
|
|
47
|
+
const editorTextStyle = {
|
|
48
|
+
fontFamily: tokens.typography.fontFamily.body,
|
|
49
|
+
fontSize: tokens.typography.sizes[size],
|
|
50
|
+
color: tokens.colors.foreground,
|
|
51
|
+
lineHeight: tokens.typography.sizes[size] * tokens.typography.lineHeights.normal,
|
|
52
|
+
};
|
|
53
|
+
const placeholderStyle = {
|
|
54
|
+
color: tokens.colors.mutedForeground,
|
|
55
|
+
fontSize: tokens.typography.sizes[size],
|
|
56
|
+
};
|
|
57
|
+
const isActionActive = (action) => activeFormats?.has(action) ?? false;
|
|
58
|
+
return {
|
|
59
|
+
containerStyle,
|
|
60
|
+
toolbarStyle,
|
|
61
|
+
getToolbarButtonStyle,
|
|
62
|
+
getToolbarButtonIconColor,
|
|
63
|
+
toolbarButtonIconSize,
|
|
64
|
+
editorStyle,
|
|
65
|
+
editorMinHeight,
|
|
66
|
+
editorTextStyle,
|
|
67
|
+
placeholderStyle,
|
|
68
|
+
resolvedToolbarActions,
|
|
69
|
+
showToolbar,
|
|
70
|
+
isActionActive,
|
|
71
|
+
accessibilityProps: {
|
|
72
|
+
accessibilityLabel: accessibilityLabel ?? 'Rich text editor',
|
|
73
|
+
accessibilityRole: 'none',
|
|
74
|
+
accessibilityState: { disabled },
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=use-rich-text-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rich-text-editor.js","sourceRoot":"","sources":["../../../../src/components/content/rich-text-editor/use-rich-text-editor.ts"],"names":[],"mappings":"AAIA,MAAM,uBAAuB,GAAoB;IAC/C,MAAM,EAAE,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AAE,CACxD,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;IAEtC,OAAO;QACL,cAAc;QACd,YAAY;QACZ,qBAAqB;QACrB,yBAAyB;QACzB,qBAAqB;QACrB,WAAW;QACX,eAAe;QACf,eAAe;QACf,gBAAgB;QAChB,sBAAsB;QACtB,WAAW;QACX,cAAc;QACd,kBAAkB,EAAE;YAClB,kBAAkB,EAAE,kBAAkB,IAAI,kBAAkB;YAC5D,iBAAiB,EAAE,MAAM;YACzB,kBAAkB,EAAE,EAAE,QAAQ,EAAE;SACjC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -46,4 +46,5 @@ export type { ParallaxHeaderProps, UseParallaxHeaderResult } from './interactive
|
|
|
46
46
|
export { PageView, usePageView } from './interactive/index.js';
|
|
47
47
|
export type { PageViewProps, UsePageViewResult, IndicatorVariant } from './interactive/index.js';
|
|
48
48
|
export * from './social/index.js';
|
|
49
|
+
export * from './content/index.js';
|
|
49
50
|
//# sourceMappingURL=index.d.ts.map
|