Skip to content

Commit 56903b9

Browse files
committed
feat(editor): expose stock node projection + types; bump to 0.2.0
Adds stock projection + shared types (StockVariant, StockKLineInterval, StockKLineRange, StockNodePayload, SerializedStockNode). Lets admin and yohaku consume one canonical definition instead of redeclaring per app.
1 parent 0c769ac commit 56903b9

4 files changed

Lines changed: 58 additions & 5 deletions

File tree

packages/editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mx-space/editor",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"type": "module",
55
"description": "Mx-space business editor contracts and projection utilities built on Lexical",
66
"license": "MIT",

packages/editor/src/core/nodes/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './afilmory'
22
export * from './litexml'
33
export * from './map'
44
export * from './registry'
5+
export * from './stock'

packages/editor/src/core/nodes/stock.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@ import { serializeLiteXmlFallbackNode } from './litexml'
33

44
export type StockVariant = 'snapshot' | 'kline'
55

6-
export type StockKLineRange = {
7-
interval: string
8-
from?: string
9-
to?: string
6+
export type StockKLineInterval = '5m' | '15m' | '1h' | '1d'
7+
8+
export interface StockKLineRange {
9+
from: string
10+
interval: StockKLineInterval
11+
to: string
1012
}
1113

14+
export type StockNodePayload =
15+
| {
16+
variant: 'snapshot'
17+
symbol: string
18+
}
19+
| {
20+
variant: 'kline'
21+
symbol: string
22+
range: StockKLineRange
23+
ema?: [number, number] | false
24+
}
25+
1226
export interface SerializedStockNode {
1327
$?: {
1428
blockId?: unknown

packages/editor/test/markdown.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,44 @@ describe('mxLexicalToMarkdown', () => {
116116
)
117117
})
118118

119+
it('projects stock snapshot node as LiteXML fallback', () => {
120+
const markdown = mxLexicalToMarkdown(
121+
state([
122+
{
123+
type: 'stock',
124+
version: 1,
125+
variant: 'snapshot',
126+
symbol: 'AAPL',
127+
},
128+
]),
129+
)
130+
131+
expect(markdown).toContain('<node type="stock"')
132+
expect(markdown).toContain('&quot;variant&quot;:&quot;snapshot&quot;')
133+
expect(markdown).toContain('&quot;symbol&quot;:&quot;AAPL&quot;')
134+
})
135+
136+
it('projects stock kline node carrying range + ema as LiteXML fallback', () => {
137+
const markdown = mxLexicalToMarkdown(
138+
state([
139+
{
140+
type: 'stock',
141+
version: 1,
142+
variant: 'kline',
143+
symbol: 'TSLA',
144+
range: { interval: '1day', from: '2026-01-01', to: '2026-06-01' },
145+
ema: [12, 26],
146+
},
147+
]),
148+
)
149+
150+
expect(markdown).toContain('<node type="stock"')
151+
expect(markdown).toContain('&quot;variant&quot;:&quot;kline&quot;')
152+
expect(markdown).toContain('&quot;symbol&quot;:&quot;TSLA&quot;')
153+
expect(markdown).toContain('&quot;interval&quot;:&quot;1day&quot;')
154+
expect(markdown).toContain('&quot;ema&quot;:[12,26]')
155+
})
156+
119157
it('throws on unknown node types', () => {
120158
expect(() =>
121159
mxLexicalToMarkdown(state([{ type: 'unknown-private', version: 1 }])),

0 commit comments

Comments
 (0)