{"id":18263142,"url":"https://github.com/vanillawc/wc-codemirror","last_synced_at":"2025-07-21T03:34:45.686Z","repository":{"id":36462407,"uuid":"225258450","full_name":"vanillawc/wc-codemirror","owner":"vanillawc","description":"CodeMirror as a vanilla web component","archived":false,"fork":false,"pushed_at":"2021-11-15T17:54:12.000Z","size":1517,"stargazers_count":43,"open_issues_count":8,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T01:06:36.122Z","etag":null,"topics":["codemirror","editor","vanilla","web-componenets"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/vanillawc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-02T01:21:16.000Z","updated_at":"2025-04-05T16:09:10.000Z","dependencies_parsed_at":"2022-08-18T03:05:11.402Z","dependency_job_id":null,"html_url":"https://github.com/vanillawc/wc-codemirror","commit_stats":null,"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"purl":"pkg:github/vanillawc/wc-codemirror","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanillawc%2Fwc-codemirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanillawc%2Fwc-codemirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanillawc%2Fwc-codemirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanillawc%2Fwc-codemirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vanillawc","download_url":"https://codeload.github.com/vanillawc/wc-codemirror/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanillawc%2Fwc-codemirror/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266235565,"owners_count":23897182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["codemirror","editor","vanilla","web-componenets"],"created_at":"2024-11-05T11:09:57.733Z","updated_at":"2025-07-21T03:34:45.666Z","avatar_url":"https://github.com/vanillawc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u0026lt;wc-codemirror\u0026gt; Easily embed a CodeMirror editor\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/vanillawc/wc-codemirror/releases\"\u003e\u003cimg src=\"https://badgen.net/github/tag/vanillawc/wc-codemirror\" alt=\"GitHub Releases\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@vanillawc/wc-codemirror\"\u003e\u003cimg src=\"https://badgen.net/npm/v/@vanillawc/wc-codemirror\" alt=\"NPM Releases\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=@vanillawc/wc-codemirror\"\u003e\u003cimg src=\"https://badgen.net/bundlephobia/minzip/@vanillawc/wc-codemirror\" alt=\"Bundlephobia\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/vanillawc/wc-codemirror/actions\"\u003e\u003cimg src=\"https://github.com/vanillawc/wc-codemirror/workflows/Latest/badge.svg\" alt=\"Latest Status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/vanillawc/wc-codemirror/actions\"\u003e\u003cimg src=\"https://github.com/vanillawc/wc-codemirror/workflows/Release/badge.svg\" alt=\"Release Status\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://discord.gg/aSWYgtybzV\"\u003e\u003cimg alt=\"Discord\" src=\"https://img.shields.io/discord/723296249121603604?color=%23738ADB\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.webcomponents.org/element/@vanillawc/wc-codemirror\"\u003e\u003cimg src=\"https://img.shields.io/badge/webcomponents.org-published-blue.svg\" alt=\"Published on WebComponents.org\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## Setup\n\n*Install and import from [NPM](https://www.npmjs.com/package/@vanillawc/wc-codemirror)*\n\n```sh\nnpm i @vanillawc/wc-codemirror\n```\n\n```html\n\u003cscript type=\"module\" src=\"[node_modules]/@vanillawc/wc-codemirror/index.js\"\u003e\u003c/script\u003e\n```\n\n*Import from CDN*\n```html\n\u003cscript type=\"module\" src=\"https://cdn.jsdelivr.net/gh/vanillawc/wc-codemirror@1/index.js\"\u003e\u003c/script\u003e\n```\n\n## Demo\n\nTry it on [WebComponents.dev](https://webcomponents.dev/edit/uQEePfQ92jOWOpupDzps?sv=1\u0026pm=1)\n\n## Usage\n\n**Attributes**\n\n- `src` - load an external source file\n- `style` - CSS styling (default `height:100%;width:100%;`)\n- `viewport-margin`\u003csup\u003e1\u003c/sup\u003e - sets the `viewportMargin` option of the CodeMirrror editor instance (default `10`)\n- `readonly` - sets the codemirror's \"readOnly\" configuration attribute to true, you may set `readonly=\"nocursor\"` if you want to disable the cursor and not let the user copy the text inside\n\n*\u003csup\u003e1\u003c/sup\u003eSetting `viewport-margin` to `infinity` will auto-resize the editor to its contents. To see this in action, check out the [CodeMirror Auto-Resize Demo](https://codemirror.net/demo/resize.html).*\n\n**Properties**\n\n- `editor` - the CodeMirror editor instance\n- `value` - get/set the editor's contents\n\n*Note: The ID attribute is required when multiple editors instances are present*\n\n### Basic Usage\n\nAn empty tag loads a basic CodeMirror editor pane\n\n```html\n\u003cwc-codemirror\u003e\u003c/wc-codemirror\u003e\n```\n\n### Inline Source\n\nInline source can be loaded by including a `\u003cscript\u003e` of type `wc-content` in the body of the component. The `\u003cscript\u003e` wrapper is necessary so '\u003c' and '\u003e' chars in the source are not interpreted as HTML.\n\n```html\n\u003cwc-codemirror mode=\"javascript\"\u003e\n  \u003cscript type=\"wc-content\"\u003e\n  function myGoodPerson(){\n     return \"what can I do for you ?\"\n  }\n  \u003c/script\u003e\n\u003c/wc-codemirror\u003e\n```\n\n*Note: `\u003c/script\u003e` cannot be used inside of `\u003cscript type=\"wc-content\"\u003e` until it's the angle brackets are escaped (ie `\u0026lt;` and `\u0026gt;`)*\n\n### External Source\n\nLoad an external source file with the `src` attribute\n\n```html\n\u003cwc-codemirror src=\"sample.txt\"\u003e\u003c/wc-codemirror\u003e\n```\n\n### Syntax Highlighting\n\nSyntax highlighting requires importing a `mode` module for the language\n\n```html\n\u003cscript type=\"module\" src=\"[wc-codemirror]/mode/javascript/javascript.js\"\u003e\u003c/script\u003e\n```\n\nThen specify the language with the `mode` attribute\n\n```html\n\u003cwc-codemirror mode=\"javascript\"\u003e\u003c/wc-codemirror\u003e\n```\n\n### Theming\n\nTheming requires importing an editor theme stylesheet within `wc-codemirror` tag. You can import few themes this way and switch them with the `theme` attribute.\n\n```html\n\u003cwc-codemirror mode=\"javascript\" theme=\"monokai\"\u003e\n  \u003clink rel=\"stylesheet\" href=\"[wc-codemirror]/theme/monokai.css\"\u003e\n\u003c/wc-codemirror\u003e\n```\n\n*Note: Check out the [CodeMirror Theme Demo](https://codemirror.net/demo/theme.html) to try sample the full selection of editor themes.*\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/vanillawc/vanillawc/blob/main/CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanillawc%2Fwc-codemirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanillawc%2Fwc-codemirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanillawc%2Fwc-codemirror/lists"}