{"id":13600898,"url":"https://github.com/weirongxu/coc-webview","last_synced_at":"2025-10-29T09:30:17.624Z","repository":{"id":43645035,"uuid":"401088589","full_name":"weirongxu/coc-webview","owner":"weirongxu","description":"Using an external browser to support the webview in coc.nvim.","archived":false,"fork":false,"pushed_at":"2023-01-06T04:42:28.000Z","size":109,"stargazers_count":31,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T00:24:50.661Z","etag":null,"topics":["coc","coc-nvim","neovim","vim","webview"],"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/weirongxu.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":"2021-08-29T16:24:53.000Z","updated_at":"2025-01-17T14:11:04.000Z","dependencies_parsed_at":"2023-02-05T08:31:58.127Z","dependency_job_id":null,"html_url":"https://github.com/weirongxu/coc-webview","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirongxu%2Fcoc-webview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirongxu%2Fcoc-webview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirongxu%2Fcoc-webview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirongxu%2Fcoc-webview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weirongxu","download_url":"https://codeload.github.com/weirongxu/coc-webview/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238795474,"owners_count":19531752,"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":["coc","coc-nvim","neovim","vim","webview"],"created_at":"2024-08-01T18:00:50.667Z","updated_at":"2025-10-29T09:30:17.142Z","avatar_url":"https://github.com/weirongxu.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","SDK"],"sub_categories":[],"readme":"# coc-webview\n\nWebview panel ported to coc.nvim\n\n## Install\n\n`:CocInstall coc-webview`\n\n## Lists\n\n`:CocList webview`\n\n## Webview as API\n\nInstall the coc-webview to `devDependencies`\n\n```typescript\n// import only type\nimport type { WebviewAPI, WebviewPanel } from 'coc-webview';\n\n// fetch API\nlet webviewExt: Extension\u003cWebviewAPI\u003e | undefined;\n\nconst getWebviewAPI = () =\u003e {\n  if (!webviewExt) {\n    webviewExt = extensions.all.find((ext) =\u003e ext.id === 'coc-webview') as Extension\u003cWebviewAPI\u003e | undefined;\n  }\n  if (!webviewExt) {\n    const hint = 'Please install the coc-webview extension';\n    void window.showErrorMessage(hint);\n    throw new Error(hint);\n  }\n  return webviewExt.exports;\n};\n\n// create webview panel\nexport async function example(): Promise\u003cvoid\u003e {\n  const panel = await getWebviewAPI().createWebviewPanel(\n    // viewType\n    'markdown-preview-enhanced',\n    // title\n    `Preview markdown`,\n    {\n      // open in browser\n      openURL: true,\n      // route name\n      routeName: 'markdown-preview-enhanced',\n    },\n    {\n      localResourceRoots: [...],\n      enableScripts: true,\n    }\n  );\n\n  // update title\n  panel.title = 'Preview markdown-2'\n\n  // update html\n  panel.webview.html = '\u003chtml\u003e...\u003c/html\u003e'\n\n  // postMessage\n  panel.webview.postMessage({type: 'command', 'token': 'xxx'})\n\n  this.onDidReceiveMessage((msg: {type: string, token: string}) =\u003e {\n    // msg.type\n  });\n\n  cosnt util = getWebviewAPI().util;\n  util.openUri('https://domain.com/');\n}\n```\n\n## Configurations\n\nUsage: https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file\n\n- `webview.debug`: Enable debug mode\n- `webview.colorStrategy`: Color strategy for webview\n- `webview.primaryColors`: Primary colors for webview\n- `webview.minPort`: Mix port for webview service\n- `webview.maxPort`: Max port for webview service\n- `webview.openCommand`: Command template for open webview, arguments(%u webview url), example: `chrome \"%u\"`\n\n## TODO\n\n- [x] dark mode\n- [x] webview reveal\n- [x] display iconPath\n- [ ] vim keybinding\n- [ ] cspSource\n\n## License\n\nMIT\n\n---\n\n\u003e This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweirongxu%2Fcoc-webview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweirongxu%2Fcoc-webview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweirongxu%2Fcoc-webview/lists"}