@rbxts/uiblox 0.2.0-alpha.22 → 0.2.0-alpha.24
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/out/ui/packages/cframeEditor/components/CFrameEditor.luau +64 -38
- package/out/ui/packages/cframeEditor/components/CFrameEditor.styles.luau +26 -9
- package/out/ui/packages/checkbox/components/checkboxLook.d.ts +1 -1
- package/out/ui/packages/colorPicker/components/ColorPicker.luau +3 -3
- package/out/ui/packages/colorPicker/components/ColorPicker.styles.luau +34 -20
- package/out/ui/packages/colorPicker/components/ColorSequenceEditor.luau +23 -20
- package/out/ui/packages/colorPicker/components/NumberSequenceEditor.luau +54 -47
- package/out/ui/packages/divider/components/Divider.styles.luau +5 -2
- package/out/ui/packages/drawer/components/Drawer.d.ts +1 -1
- package/out/ui/packages/drawer/components/Drawer.luau +54 -36
- package/out/ui/packages/gradientEditor/components/GradientEditor.luau +45 -27
- package/out/ui/packages/gradientEditor/components/GradientEditor.styles.luau +37 -4
- package/out/ui/packages/imageList/components/ImageList.luau +1 -1
- package/out/ui/packages/index.d.ts +1 -0
- package/out/ui/packages/init.luau +3 -0
- package/out/ui/packages/markdown/components/Markdown.d.ts +6 -0
- package/out/ui/packages/markdown/components/Markdown.luau +228 -0
- package/out/ui/packages/markdown/components/Markdown.styles.d.ts +2 -0
- package/out/ui/packages/markdown/components/Markdown.styles.luau +101 -0
- package/out/ui/packages/markdown/components/MarkdownEditor.d.ts +16 -0
- package/out/ui/packages/markdown/components/MarkdownEditor.luau +322 -0
- package/out/ui/packages/markdown/components/MarkdownEditor.styles.d.ts +6 -0
- package/out/ui/packages/markdown/components/MarkdownEditor.styles.luau +132 -0
- package/out/ui/packages/markdown/htmlToMarkdown.d.ts +2 -0
- package/out/ui/packages/markdown/htmlToMarkdown.luau +350 -0
- package/out/ui/packages/markdown/index.d.ts +8 -0
- package/out/ui/packages/markdown/init.luau +11 -0
- package/out/ui/packages/markdown/parseMarkdown.d.ts +42 -0
- package/out/ui/packages/markdown/parseMarkdown.luau +459 -0
- package/out/ui/packages/splitPane/components/splitLook.d.ts +1 -1
- package/out/ui/packages/stateMatrix.luau +42 -1
- package/out/ui/packages/switch/components/switchLook.d.ts +1 -1
- package/out/ui/packages/toast/components/Toast.styles.luau +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local function trim(value)
|
|
3
|
+
local start = 1
|
|
4
|
+
local stop = #value
|
|
5
|
+
while start <= stop do
|
|
6
|
+
local _value = value
|
|
7
|
+
local _start = start
|
|
8
|
+
local _start_1 = start
|
|
9
|
+
local ch = string.sub(_value, _start, _start_1)
|
|
10
|
+
if ch ~= " " and ch ~= "\t" and ch ~= "\r" and ch ~= "\n" then
|
|
11
|
+
break
|
|
12
|
+
end
|
|
13
|
+
start += 1
|
|
14
|
+
end
|
|
15
|
+
while stop >= start do
|
|
16
|
+
local _value = value
|
|
17
|
+
local _stop = stop
|
|
18
|
+
local _stop_1 = stop
|
|
19
|
+
local ch = string.sub(_value, _stop, _stop_1)
|
|
20
|
+
if ch ~= " " and ch ~= "\t" and ch ~= "\r" and ch ~= "\n" then
|
|
21
|
+
break
|
|
22
|
+
end
|
|
23
|
+
stop -= 1
|
|
24
|
+
end
|
|
25
|
+
if start > stop then
|
|
26
|
+
return ""
|
|
27
|
+
end
|
|
28
|
+
local _value = value
|
|
29
|
+
local _start = start
|
|
30
|
+
local _stop = stop
|
|
31
|
+
return string.sub(_value, _start, _stop)
|
|
32
|
+
end
|
|
33
|
+
local function decodeEntities(value)
|
|
34
|
+
local out = value
|
|
35
|
+
for _, _binding in { { "<", "<" }, { ">", ">" }, { "&", "&" }, { """, '"' }, { " ", " " } } do
|
|
36
|
+
local from = _binding[1]
|
|
37
|
+
local to = _binding[2]
|
|
38
|
+
local replaced = string.gsub(out, from, to)
|
|
39
|
+
out = replaced
|
|
40
|
+
end
|
|
41
|
+
return out
|
|
42
|
+
end
|
|
43
|
+
local function collapseSpace(value)
|
|
44
|
+
local out = ""
|
|
45
|
+
local gap = false
|
|
46
|
+
for i = 1, #value do
|
|
47
|
+
local _value = value
|
|
48
|
+
local _i = i
|
|
49
|
+
local _i_1 = i
|
|
50
|
+
local ch = string.sub(_value, _i, _i_1)
|
|
51
|
+
if ch == " " or ch == "\t" or ch == "\n" or ch == "\r" then
|
|
52
|
+
gap = true
|
|
53
|
+
continue
|
|
54
|
+
end
|
|
55
|
+
if gap then
|
|
56
|
+
out = `{out} `
|
|
57
|
+
gap = false
|
|
58
|
+
end
|
|
59
|
+
out = `{out}{ch}`
|
|
60
|
+
end
|
|
61
|
+
if gap then
|
|
62
|
+
out = `{out} `
|
|
63
|
+
end
|
|
64
|
+
return out
|
|
65
|
+
end
|
|
66
|
+
local function attr(tag, name)
|
|
67
|
+
local needle = `{name}="`
|
|
68
|
+
local found = { string.find(string.lower(tag), needle, 1, true) }
|
|
69
|
+
local at = found[1]
|
|
70
|
+
if at == nil then
|
|
71
|
+
return nil
|
|
72
|
+
end
|
|
73
|
+
local start = at + #needle
|
|
74
|
+
local close = { string.find(tag, '"', start, true) }
|
|
75
|
+
local endAt = close[1]
|
|
76
|
+
if endAt == nil then
|
|
77
|
+
return nil
|
|
78
|
+
end
|
|
79
|
+
local _tag = tag
|
|
80
|
+
local _arg1 = endAt - 1
|
|
81
|
+
return string.sub(_tag, start, _arg1)
|
|
82
|
+
end
|
|
83
|
+
local function tokenize(html)
|
|
84
|
+
local toks = {}
|
|
85
|
+
local i = 1
|
|
86
|
+
local n = #html
|
|
87
|
+
while i <= n do
|
|
88
|
+
local _html = html
|
|
89
|
+
local _i = i
|
|
90
|
+
local lt = { string.find(_html, "<", _i, true) }
|
|
91
|
+
local ltAt = lt[1]
|
|
92
|
+
if ltAt == nil then
|
|
93
|
+
local _object = {
|
|
94
|
+
kind = "text",
|
|
95
|
+
}
|
|
96
|
+
local _left = "text"
|
|
97
|
+
local _html_1 = html
|
|
98
|
+
local _i_1 = i
|
|
99
|
+
_object[_left] = string.sub(_html_1, _i_1)
|
|
100
|
+
table.insert(toks, _object)
|
|
101
|
+
break
|
|
102
|
+
end
|
|
103
|
+
if ltAt > i then
|
|
104
|
+
local _object = {
|
|
105
|
+
kind = "text",
|
|
106
|
+
}
|
|
107
|
+
local _left = "text"
|
|
108
|
+
local _html_1 = html
|
|
109
|
+
local _i_1 = i
|
|
110
|
+
local _arg1 = ltAt - 1
|
|
111
|
+
_object[_left] = string.sub(_html_1, _i_1, _arg1)
|
|
112
|
+
table.insert(toks, _object)
|
|
113
|
+
end
|
|
114
|
+
local _html_1 = html
|
|
115
|
+
local _arg1 = ltAt + 1
|
|
116
|
+
local gt = { string.find(_html_1, ">", _arg1, true) }
|
|
117
|
+
local gtAt = gt[1]
|
|
118
|
+
if gtAt == nil then
|
|
119
|
+
local _arg0 = {
|
|
120
|
+
kind = "text",
|
|
121
|
+
text = string.sub(html, ltAt),
|
|
122
|
+
}
|
|
123
|
+
table.insert(toks, _arg0)
|
|
124
|
+
break
|
|
125
|
+
end
|
|
126
|
+
local _html_2 = html
|
|
127
|
+
local _arg0 = ltAt + 1
|
|
128
|
+
local _arg1_1 = gtAt - 1
|
|
129
|
+
local raw = string.sub(_html_2, _arg0, _arg1_1)
|
|
130
|
+
if string.sub(raw, 1, 3) == "!--" then
|
|
131
|
+
i = gtAt + 1
|
|
132
|
+
continue
|
|
133
|
+
end
|
|
134
|
+
local isClose = string.sub(raw, 1, 1) == "/"
|
|
135
|
+
local body = if isClose then string.sub(raw, 2) else raw
|
|
136
|
+
local nameEnd = 1
|
|
137
|
+
while nameEnd <= #body do
|
|
138
|
+
local _nameEnd = nameEnd
|
|
139
|
+
local _nameEnd_1 = nameEnd
|
|
140
|
+
local c = string.sub(body, _nameEnd, _nameEnd_1)
|
|
141
|
+
if c == " " or c == "\t" or c == "/" or c == "\n" or c == "\r" then
|
|
142
|
+
break
|
|
143
|
+
end
|
|
144
|
+
nameEnd += 1
|
|
145
|
+
end
|
|
146
|
+
local _arg1_2 = nameEnd - 1
|
|
147
|
+
local name = string.lower(string.sub(body, 1, _arg1_2))
|
|
148
|
+
local _condition = not isClose
|
|
149
|
+
if _condition then
|
|
150
|
+
local _arg0_1 = #body
|
|
151
|
+
local _arg1_3 = #body
|
|
152
|
+
local _condition_1 = string.sub(body, _arg0_1, _arg1_3) == "/"
|
|
153
|
+
if not _condition_1 then
|
|
154
|
+
_condition_1 = name == "br" or name == "hr"
|
|
155
|
+
end
|
|
156
|
+
_condition = _condition_1
|
|
157
|
+
end
|
|
158
|
+
local selfClose = _condition
|
|
159
|
+
if name == "script" or name == "style" then
|
|
160
|
+
if not isClose and not selfClose then
|
|
161
|
+
local closer = `</{name}>`
|
|
162
|
+
local _exp = string.lower(html)
|
|
163
|
+
local _arg1_3 = gtAt + 1
|
|
164
|
+
local closeTag = { string.find(_exp, closer, _arg1_3, true) }
|
|
165
|
+
local endAt = closeTag[1]
|
|
166
|
+
i = if endAt ~= nil then endAt + #closer else gtAt + 1
|
|
167
|
+
continue
|
|
168
|
+
end
|
|
169
|
+
i = gtAt + 1
|
|
170
|
+
continue
|
|
171
|
+
end
|
|
172
|
+
if isClose then
|
|
173
|
+
local _arg0_1 = {
|
|
174
|
+
kind = "close",
|
|
175
|
+
name = name,
|
|
176
|
+
}
|
|
177
|
+
table.insert(toks, _arg0_1)
|
|
178
|
+
elseif selfClose then
|
|
179
|
+
local _arg0_1 = {
|
|
180
|
+
kind = "void",
|
|
181
|
+
name = name,
|
|
182
|
+
}
|
|
183
|
+
table.insert(toks, _arg0_1)
|
|
184
|
+
else
|
|
185
|
+
local _arg0_1 = {
|
|
186
|
+
kind = "open",
|
|
187
|
+
name = name,
|
|
188
|
+
raw = body,
|
|
189
|
+
}
|
|
190
|
+
table.insert(toks, _arg0_1)
|
|
191
|
+
end
|
|
192
|
+
i = gtAt + 1
|
|
193
|
+
end
|
|
194
|
+
return toks
|
|
195
|
+
end
|
|
196
|
+
local function hashes(level)
|
|
197
|
+
local out = ""
|
|
198
|
+
do
|
|
199
|
+
local i = 0
|
|
200
|
+
local _shouldIncrement = false
|
|
201
|
+
while true do
|
|
202
|
+
if _shouldIncrement then
|
|
203
|
+
i += 1
|
|
204
|
+
else
|
|
205
|
+
_shouldIncrement = true
|
|
206
|
+
end
|
|
207
|
+
if not (i < level) then
|
|
208
|
+
break
|
|
209
|
+
end
|
|
210
|
+
out = `{out}#`
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
return out
|
|
214
|
+
end
|
|
215
|
+
--* Map a small HTML subset to the markdown preview subset. Unknown tags unwrap to text.
|
|
216
|
+
local function htmlToMarkdown(html)
|
|
217
|
+
local toks = tokenize(html)
|
|
218
|
+
local out = ""
|
|
219
|
+
local listOrdered
|
|
220
|
+
local listIndex = 0
|
|
221
|
+
local inPre = false
|
|
222
|
+
local pending = ""
|
|
223
|
+
local hrefs = {}
|
|
224
|
+
local flushPending = function()
|
|
225
|
+
local t = trim(pending)
|
|
226
|
+
pending = ""
|
|
227
|
+
if #t > 0 then
|
|
228
|
+
out = `{out}{t}\n\n`
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
local pushInline = function(text)
|
|
232
|
+
pending = `{pending}{text}`
|
|
233
|
+
end
|
|
234
|
+
for _, tok in toks do
|
|
235
|
+
if tok.kind == "text" then
|
|
236
|
+
if inPre then
|
|
237
|
+
pending = `{pending}{tok.text}`
|
|
238
|
+
else
|
|
239
|
+
pushInline(collapseSpace(decodeEntities(tok.text)))
|
|
240
|
+
end
|
|
241
|
+
continue
|
|
242
|
+
end
|
|
243
|
+
local name = tok.name
|
|
244
|
+
if tok.kind == "void" then
|
|
245
|
+
if name == "br" then
|
|
246
|
+
pushInline(" \n")
|
|
247
|
+
elseif name == "hr" then
|
|
248
|
+
flushPending()
|
|
249
|
+
out = `{out}---\n\n`
|
|
250
|
+
end
|
|
251
|
+
continue
|
|
252
|
+
end
|
|
253
|
+
if tok.kind == "open" then
|
|
254
|
+
if #name == 2 and string.sub(name, 1, 1) == "h" then
|
|
255
|
+
local level = tonumber(string.sub(name, 2))
|
|
256
|
+
if level ~= nil and level >= 1 and level <= 6 then
|
|
257
|
+
flushPending()
|
|
258
|
+
pending = `{hashes(level)} `
|
|
259
|
+
end
|
|
260
|
+
elseif name == "p" then
|
|
261
|
+
flushPending()
|
|
262
|
+
elseif name == "strong" or name == "b" then
|
|
263
|
+
pushInline("**")
|
|
264
|
+
elseif name == "em" or name == "i" then
|
|
265
|
+
pushInline("*")
|
|
266
|
+
elseif name == "code" and not inPre then
|
|
267
|
+
pushInline("`")
|
|
268
|
+
elseif name == "pre" then
|
|
269
|
+
flushPending()
|
|
270
|
+
inPre = true
|
|
271
|
+
pending = "```\n"
|
|
272
|
+
elseif name == "a" then
|
|
273
|
+
pushInline("[")
|
|
274
|
+
local _condition = attr(tok.raw, "href")
|
|
275
|
+
if _condition == nil then
|
|
276
|
+
_condition = ""
|
|
277
|
+
end
|
|
278
|
+
table.insert(hrefs, _condition)
|
|
279
|
+
elseif name == "ul" then
|
|
280
|
+
flushPending()
|
|
281
|
+
listOrdered = false
|
|
282
|
+
listIndex = 0
|
|
283
|
+
elseif name == "ol" then
|
|
284
|
+
flushPending()
|
|
285
|
+
listOrdered = true
|
|
286
|
+
listIndex = 0
|
|
287
|
+
elseif name == "li" then
|
|
288
|
+
flushPending()
|
|
289
|
+
if listOrdered == true then
|
|
290
|
+
listIndex += 1
|
|
291
|
+
pending = `{listIndex}. `
|
|
292
|
+
else
|
|
293
|
+
pending = "- "
|
|
294
|
+
end
|
|
295
|
+
elseif name == "blockquote" then
|
|
296
|
+
flushPending()
|
|
297
|
+
pending = "> "
|
|
298
|
+
end
|
|
299
|
+
continue
|
|
300
|
+
end
|
|
301
|
+
if #name == 2 and string.sub(name, 1, 1) == "h" then
|
|
302
|
+
flushPending()
|
|
303
|
+
elseif name == "p" then
|
|
304
|
+
flushPending()
|
|
305
|
+
elseif name == "strong" or name == "b" then
|
|
306
|
+
pushInline("**")
|
|
307
|
+
elseif name == "em" or name == "i" then
|
|
308
|
+
pushInline("*")
|
|
309
|
+
elseif name == "code" and not inPre then
|
|
310
|
+
pushInline("`")
|
|
311
|
+
elseif name == "pre" then
|
|
312
|
+
inPre = false
|
|
313
|
+
local _condition = #pending > 0
|
|
314
|
+
if _condition then
|
|
315
|
+
local _pending = pending
|
|
316
|
+
local _arg0 = #pending
|
|
317
|
+
_condition = string.sub(_pending, _arg0) ~= "\n"
|
|
318
|
+
end
|
|
319
|
+
if _condition then
|
|
320
|
+
pending = `{pending}\n`
|
|
321
|
+
end
|
|
322
|
+
pending = `{pending}\`\`\``
|
|
323
|
+
flushPending()
|
|
324
|
+
elseif name == "a" then
|
|
325
|
+
-- ▼ Array.pop ▼
|
|
326
|
+
local _length = #hrefs
|
|
327
|
+
local _result = hrefs[_length]
|
|
328
|
+
hrefs[_length] = nil
|
|
329
|
+
-- ▲ Array.pop ▲
|
|
330
|
+
local _condition = _result
|
|
331
|
+
if _condition == nil then
|
|
332
|
+
_condition = ""
|
|
333
|
+
end
|
|
334
|
+
local href = _condition
|
|
335
|
+
pushInline(`]({href})`)
|
|
336
|
+
elseif name == "ul" or name == "ol" then
|
|
337
|
+
flushPending()
|
|
338
|
+
listOrdered = nil
|
|
339
|
+
listIndex = 0
|
|
340
|
+
elseif name == "li" or name == "blockquote" then
|
|
341
|
+
flushPending()
|
|
342
|
+
end
|
|
343
|
+
end
|
|
344
|
+
flushPending()
|
|
345
|
+
local result = trim(out)
|
|
346
|
+
return if #result > 0 then `{result}\n` else ""
|
|
347
|
+
end
|
|
348
|
+
return {
|
|
349
|
+
htmlToMarkdown = htmlToMarkdown,
|
|
350
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Markdown } from "./components/Markdown";
|
|
2
|
+
export type { MarkdownProps } from "./components/Markdown";
|
|
3
|
+
export { default as MarkdownEditor } from "./components/MarkdownEditor";
|
|
4
|
+
export type { MarkdownEditorProps } from "./components/MarkdownEditor";
|
|
5
|
+
export type { MarkdownEditorMode } from "./components/MarkdownEditor.styles";
|
|
6
|
+
export { parseMarkdown, inlinesToPlain, inlinesToRichText } from "./parseMarkdown";
|
|
7
|
+
export type { MdBlock, MdInline } from "./parseMarkdown";
|
|
8
|
+
export { htmlToMarkdown } from "./htmlToMarkdown";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local exports = {}
|
|
4
|
+
exports.Markdown = TS.import(script, script, "components", "Markdown").default
|
|
5
|
+
exports.MarkdownEditor = TS.import(script, script, "components", "MarkdownEditor").default
|
|
6
|
+
local _parseMarkdown = TS.import(script, script, "parseMarkdown")
|
|
7
|
+
exports.parseMarkdown = _parseMarkdown.parseMarkdown
|
|
8
|
+
exports.inlinesToPlain = _parseMarkdown.inlinesToPlain
|
|
9
|
+
exports.inlinesToRichText = _parseMarkdown.inlinesToRichText
|
|
10
|
+
exports.htmlToMarkdown = TS.import(script, script, "htmlToMarkdown").htmlToMarkdown
|
|
11
|
+
return exports
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type MdInline = {
|
|
2
|
+
kind: "text";
|
|
3
|
+
text: string;
|
|
4
|
+
} | {
|
|
5
|
+
kind: "bold";
|
|
6
|
+
text: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "italic";
|
|
9
|
+
text: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "code";
|
|
12
|
+
text: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "link";
|
|
15
|
+
text: string;
|
|
16
|
+
href: string;
|
|
17
|
+
};
|
|
18
|
+
export type MdBlock = {
|
|
19
|
+
kind: "heading";
|
|
20
|
+
level: number;
|
|
21
|
+
inlines: MdInline[];
|
|
22
|
+
} | {
|
|
23
|
+
kind: "paragraph";
|
|
24
|
+
inlines: MdInline[];
|
|
25
|
+
} | {
|
|
26
|
+
kind: "code";
|
|
27
|
+
text: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "list";
|
|
30
|
+
ordered: boolean;
|
|
31
|
+
items: MdInline[][];
|
|
32
|
+
} | {
|
|
33
|
+
kind: "blockquote";
|
|
34
|
+
inlines: MdInline[];
|
|
35
|
+
} | {
|
|
36
|
+
kind: "hr";
|
|
37
|
+
};
|
|
38
|
+
/** Small markdown subset → blocks. Unsupported syntax stays plain text. */
|
|
39
|
+
export declare function parseMarkdown(source: string): MdBlock[];
|
|
40
|
+
export declare function inlinesToPlain(inlines: MdInline[]): string;
|
|
41
|
+
/** Turn inline nodes into Roblox RichText. Links become colored label + (url). */
|
|
42
|
+
export declare function inlinesToRichText(inlines: MdInline[]): string;
|