diff --git a/packages/frontend/src/components/MkCode.core.vue b/packages/frontend/src/components/MkCode.core.vue index 579c72b18676fe61c94c26f5d6b13d41395ea6a9..77a01627ba3cf336d51a1300b90ab873f8b6705f 100644 --- a/packages/frontend/src/components/MkCode.core.vue +++ b/packages/frontend/src/components/MkCode.core.vue @@ -58,6 +58,21 @@ watch(() => props.lang, (to) => { </script> <style scoped lang="scss"> +.codeBlockRoot :deep(.shiki) > code { + counter-reset: step; + counter-increment: step 0; +} + +.codeBlockRoot :deep(.shiki) > code > .line::before { + content: counter(step); + counter-increment: step; + width: 1rem; + margin-right: 1.5rem; + display: inline-block; + text-align: right; + color: rgba(115,138,148,.4) +} + .codeBlockRoot :deep(.shiki) { padding: 1em; margin: .5em 0; diff --git a/packages/frontend/src/components/MkCodeEditor.vue b/packages/frontend/src/components/MkCodeEditor.vue index 789acbd4c16d935e0bfd71b18f49caeb6e664f8a..7334fc4d0e4305ce27d6722beede37d6436f1afb 100644 --- a/packages/frontend/src/components/MkCodeEditor.vue +++ b/packages/frontend/src/components/MkCodeEditor.vue @@ -204,6 +204,8 @@ watch(v, newValue => { min-width: calc(100% - 24px); height: 100%; padding: 12px; + // the +2.5 rem is because of the line numbers + padding-left: calc(12px + 2.5rem); line-height: 1.5em; font-size: 1em; font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace; diff --git a/packages/frontend/src/scripts/install-plugin.ts b/packages/frontend/src/scripts/install-plugin.ts index ee218df0182f8be43e8d4e5c6940a2ff2db94f57..1d1a8a3f770400ffbcd21505555407640caef4d5 100644 --- a/packages/frontend/src/scripts/install-plugin.ts +++ b/packages/frontend/src/scripts/install-plugin.ts @@ -64,7 +64,11 @@ export async function parsePluginMeta(code: string): Promise<AiScriptPluginMeta> try { ast = parser.parse(code); } catch (err) { - throw new Error('Aiscript syntax error'); + if (err instanceof Error) { + throw new Error(`Aiscript syntax error\n${(err as Error).message}`); + } else { + throw new Error('Aiscript syntax error'); + } } const meta = Interpreter.collectMetadata(ast);