feat: $[small ] and $[center ] MFM syntax

This commit is contained in:
ThatOneCalculator 2023-06-22 17:41:34 -07:00
parent e5bcb2e2c7
commit 8539e4c7fd
2 changed files with 26 additions and 4 deletions

View file

@ -110,7 +110,7 @@ export default defineComponent({
case "fn": { case "fn": {
// TODO: CSSを文字列で組み立てていくと token.props.args.~~~ 経由でCSSインジェクションできるのでよしなにやる // TODO: CSSを文字列で組み立てていくと token.props.args.~~~ 経由でCSSインジェクションできるのでよしなにやる
let style; let style: string;
switch (token.props.name) { switch (token.props.name) {
case "tada": { case "tada": {
const speed = validTime(token.props.args.speed) || "1s"; const speed = validTime(token.props.args.speed) || "1s";
@ -300,6 +300,24 @@ export default defineComponent({
style = `background-color: #${color};`; style = `background-color: #${color};`;
break; break;
} }
case "small": {
return h(
"small",
{
style: "opacity: 0.7;",
},
genEl(token.children),
);
}
case "center": {
return h(
"div",
{
style: "text-align: center;",
},
genEl(token.children),
);
}
} }
if (style == null) { if (style == null) {
return h("span", {}, [ return h("span", {}, [
@ -337,7 +355,7 @@ export default defineComponent({
h( h(
"div", "div",
{ {
style: "text-align:center;", style: "text-align: center;",
}, },
genEl(token.children), genEl(token.children),
), ),

View file

@ -460,8 +460,12 @@ let preview_emoji = $ref(
instance.emojis.length ? `:${instance.emojis[0].name}:` : ":emojiname:" instance.emojis.length ? `:${instance.emojis[0].name}:` : ":emojiname:"
); );
let preview_bold = $ref(`**${i18n.ts._mfm.dummy}**`); let preview_bold = $ref(`**${i18n.ts._mfm.dummy}**`);
let preview_small = $ref(`<small>${i18n.ts._mfm.dummy}</small>`); let preview_small = $ref(
let preview_center = $ref(`<center>${i18n.ts._mfm.dummy}</center>`); `<small>${i18n.ts._mfm.dummy}</small> $[small ${i18n.ts._mfm.dummy}]`
);
let preview_center = $ref(
`<center>${i18n.ts._mfm.dummy}</center> $[center ${i18n.ts._mfm.dummy}]`
);
let preview_inlineCode = $ref('`<: "Hello, world!"`'); let preview_inlineCode = $ref('`<: "Hello, world!"`');
let preview_blockCode = $ref( let preview_blockCode = $ref(
'```\n~ (#i, 100) {\n\t<: ? ((i % 15) = 0) "FizzBuzz"\n\t\t.? ((i % 3) = 0) "Fizz"\n\t\t.? ((i % 5) = 0) "Buzz"\n\t\t. i\n}\n```' '```\n~ (#i, 100) {\n\t<: ? ((i % 15) = 0) "FizzBuzz"\n\t\t.? ((i % 3) = 0) "Fizz"\n\t\t.? ((i % 5) = 0) "Buzz"\n\t\t. i\n}\n```'