{"id":47757134,"url":"https://github.com/codemonster-ru/vue-codeblock","last_synced_at":"2026-05-02T12:04:59.669Z","repository":{"id":341431931,"uuid":"1170068628","full_name":"codemonster-ru/vue-codeblock","owner":"codemonster-ru","description":"Standalone Vue code block component with syntax highlighting and light/dark theming","archived":false,"fork":false,"pushed_at":"2026-04-28T14:42:02.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-28T16:29:01.697Z","etag":null,"topics":["code","code-block","documentation","syntax-highlighting","vue","vue3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemonster-ru.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-01T16:50:14.000Z","updated_at":"2026-04-28T14:45:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/codemonster-ru/vue-codeblock","commit_stats":null,"previous_names":["codemonster-ru/vue-codeblock"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/codemonster-ru/vue-codeblock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonster-ru%2Fvue-codeblock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonster-ru%2Fvue-codeblock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonster-ru%2Fvue-codeblock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonster-ru%2Fvue-codeblock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonster-ru","download_url":"https://codeload.github.com/codemonster-ru/vue-codeblock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonster-ru%2Fvue-codeblock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32533350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T11:28:32.350Z","status":"ssl_error","status_checked_at":"2026-05-02T11:27:30.140Z","response_time":132,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code","code-block","documentation","syntax-highlighting","vue","vue3"],"created_at":"2026-04-03T04:36:18.154Z","updated_at":"2026-05-02T12:04:59.664Z","avatar_url":"https://github.com/codemonster-ru.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @codemonster-ru/vue-codeblock\n\n[![npm version](https://img.shields.io/npm/v/%40codemonster-ru%2Fvue-codeblock)](https://www.npmjs.com/package/@codemonster-ru/vue-codeblock)\n[![npm downloads](https://img.shields.io/npm/dw/%40codemonster-ru%2Fvue-codeblock)](https://www.npmjs.com/package/@codemonster-ru/vue-codeblock)\n[![license](https://img.shields.io/npm/l/%40codemonster-ru%2Fvue-codeblock)](https://github.com/codemonster-ru/vue-codeblock/blob/main/LICENSE)\n\nStandalone Vue 3 code block component with Shiki-powered syntax highlighting, light/dark theme support, copy actions, and line numbers.\n\n## Install\n\n```bash\nnpm i @codemonster-ru/vue-codeblock\n```\n\n## Use Cases\n\n- package documentation\n- design system docs\n- internal developer portals\n- settings/admin panels that need to render code examples\n\n## Component Usage\n\nRegister the plugin:\n\n```ts\nimport { createApp } from \"vue\";\nimport App from \"./App.vue\";\nimport VueCodeBlock from \"@codemonster-ru/vue-codeblock\";\n\ncreateApp(App).use(VueCodeBlock).mount(\"#app\");\n```\n\nRegister the plugin with runtime theme variables:\n\n```ts\ncreateApp(App)\n  .use(VueCodeBlock, {\n    themeScope: \":root\",\n    styleNonce: \"nonce-from-csp\",\n    themeVars: {\n      base: {\n        \"--vcb-border-radius\": \"0.75rem\",\n        \"--vcb-padding\": \"0.75rem 1rem\",\n      },\n      light: {\n        \"--vcb-background-color\": \"#ffffff\",\n      },\n      dark: {\n        \"--vcb-dark-background-color\": \"#1f2430\",\n      },\n    },\n  })\n  .mount(\"#app\");\n```\n\nOr import the component directly:\n\n```vue\n\u003cscript setup lang=\"ts\"\u003e\nimport { CodeBlock } from \"@codemonster-ru/vue-codeblock\";\n\u003c/script\u003e\n\n\u003ctemplate\u003e\n  \u003cCodeBlock\n    language=\"vue\"\n    filename=\"ButtonExample.vue\"\n    :show-line-numbers=\"true\"\n    :code=\"`\u003cButton label=\u0026quot;Save\u0026quot; /\u003e`\"\n  /\u003e\n\u003c/template\u003e\n```\n\nIf you want the package CSS explicitly:\n\n```ts\nimport \"@codemonster-ru/vue-codeblock/style.css\";\n```\n\n## Runtime Usage\n\nThe package also exports the shared highlighter:\n\n```ts\nimport {\n  highlightCodeBlock,\n  escapeCodeHtml,\n} from \"@codemonster-ru/vue-codeblock\";\n\nconst html = await highlightCodeBlock(\"ts\", \"const answer = 42;\", \"light\");\nconst escaped = escapeCodeHtml(\"\u003cButton /\u003e\");\n```\n\n## Props\n\n| Prop              | Type                             | Default        | Purpose                              |\n| ----------------- | -------------------------------- | -------------- | ------------------------------------ |\n| `code`            | `string`                         | `''`           | Raw source code                      |\n| `language`        | `CodeBlockLanguage`              | `'plaintext'`  | Language hint for highlighting       |\n| `filename`        | `string`                         | `''`           | Optional filename in header          |\n| `showHeader`      | `boolean`                        | `true`         | Shows the top meta/action bar        |\n| `showLineNumbers` | `boolean`                        | `false`        | Renders line numbers                 |\n| `copyable`        | `boolean`                        | `true`         | Shows copy action                    |\n| `copyLabel`       | `string`                         | `'Copy'`       | Copy button text                     |\n| `copiedLabel`     | `string`                         | `'Copied'`     | Temporary copied state label         |\n| `copiedDuration`  | `number`                         | `1200`         | Copied state timeout in ms           |\n| `languageLabel`   | `string`                         | `'Language'`   | Header label before language         |\n| `disabled`        | `boolean`                        | `false`        | Disables actions                     |\n| `wrap`            | `boolean`                        | `false`        | Enables wrapped lines                |\n| `highlight`       | `boolean`                        | `true`         | Turns highlighting on/off            |\n| `maxHeight`       | `string`                         | `''`           | Optional scroll container max height |\n| `ariaLabel`       | `string`                         | `'Code block'` | Accessibility label                  |\n| `theme`           | `'inherit' \\| 'light' \\| 'dark'` | `'inherit'`    | Theme mode override                  |\n\n## Events\n\n| Event  | Payload            |\n| ------ | ------------------ |\n| `copy` | `{ text: string }` |\n\n## Slots\n\n| Slot      | Purpose                                    |\n| --------- | ------------------------------------------ |\n| `actions` | Add custom actions next to the copy button |\n\n## Supported Languages\n\nCanonical built-in values:\n\n`plaintext`, `text`, `txt`, `js`, `javascript`, `ts`, `typescript`, `vue`, `html`, `json`, `bash`, `shell`, `sh`, `css`, `scss`, `sass`\n\nYou can import them as `SUPPORTED_CODE_BLOCK_LANGUAGES`.\n\n## Theming\n\nThe component ships with light and dark defaults. You can override it with:\n\n- `theme=\"light\"`\n- `theme=\"dark\"`\n- `theme=\"inherit\"` and the nearest ancestor theme from `data-theme` or, if absent, `data-vf-theme`\n\nMain CSS custom properties:\n\n- `--vcb-background-color`\n- `--vcb-text-color`\n- `--vcb-border-color`\n- `--vcb-border-radius`\n- `--vcb-header-background-color`\n- `--vcb-header-border-color`\n- `--vcb-header-padding`\n- `--vcb-code-background-color`\n- `--vcb-action-background-color`\n- `--vcb-action-border-color`\n- `--vcb-padding`\n- `--vcb-font-size`\n- `--vcb-line-height`\n- `--vcb-line-number-color`\n- `--vcb-margin-block`\n- `--vcb-margin-block-start`\n- `--vcb-margin-block-end`\n\nYou can also provide these variables at plugin install time via `themeVars`:\n\n- `themeVars.base` is applied to `:root`\n- `themeVars.light` is applied to `:root[data-theme=\"light\"]` and `:root[data-vf-theme=\"light\"]`\n- `themeVars.dark` is applied to `:root[data-theme=\"dark\"]` and `:root[data-vf-theme=\"dark\"]`\n\nOptional plugin option:\n\n- `themeScope` (`string`, default `:root`) controls where runtime variables are injected.\n- `styleNonce` adds a CSP nonce to the runtime `\u003cstyle\u003e` tag.\n\nFor dynamic runtime updates after app initialization, use:\n\n```ts\nimport { setCodeBlockThemeVars } from \"@codemonster-ru/vue-codeblock\";\n\nsetCodeBlockThemeVars(\n  {\n    dark: {\n      \"--vcb-dark-background-color\": \"#181c25\",\n    },\n  },\n  { themeScope: \":root\" },\n);\n```\n\nExample:\n\n```css\n.docs-surface {\n  --vcb-background-color: #081224;\n  --vcb-border-color: rgba(96, 165, 250, 0.28);\n  --vcb-margin-block: 1rem;\n}\n```\n\nBy default, `CodeBlock` behaves like standalone prose block content with:\n\n- `margin-block-start: var(--vcb-margin-block-start)` where `--vcb-margin-block-start` defaults to `--vcb-margin-block`\n- `margin-block-end: var(--vcb-margin-block-end)` where `--vcb-margin-block-end` defaults to `--vcb-margin-block`\n- `margin-block-start: 0` when `.vcb:first-child`\n- `margin-block-end: 0` when `.vcb:last-child`\n\nSyntax token colors are provided by Shiki themes:\n\n- light mode uses `github-light`\n- dark mode uses `github-dark`\n\nThe default styles are tuned to feel closer to a documentation surface:\n\n- the outer container stays close to the page background\n- separation comes mostly from border and header chrome\n- the code area does not introduce a heavy extra panel by default\n- light and dark themes follow the same surface logic\n\n## Notes\n\n- Highlighting is powered by Shiki and runs asynchronously.\n- `plaintext`, `text`, and `txt` render as escaped plain text.\n- Unsupported language hints safely fall back to escaped plain text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonster-ru%2Fvue-codeblock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonster-ru%2Fvue-codeblock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonster-ru%2Fvue-codeblock/lists"}