Help us understand the problem. What is going on with this article?

CodeMirror Addon の hint/show-hint.js でスニペット実装

More than 1 year has passed since last update.

CodeMirror AutoComplete で検索すると以下のコードがヒットするんですが、もう少し単純なサンプルが欲しかったので実装してみました。

CodePen

エディター上で Cmd-E もしくは Ctrl-E すると、コンテキストメニューみたいなものが出てきて入力出来ます。

See the Pen CodeMirror Addon hint/show-hint.js sample by kkeisuke (@_kkeisuke) on CodePen.

補足

候補を絞り込んでいるのは以下の行で仕組みは単純です。

// snippets は { text: string, displayText: string }[] みたいな感じです。
const list: any[] = snippets.filter(function (item): boolean {
  return item.text.indexOf(currentWord) >= 0
})

もう少し細かい制御をしようと思うと大変そうです。冒頭の記事をご参考ください。

CodeMirror は英語、日本語ともにサンプルが少ないですね :disappointed_relieved:

kkeisuke
TypeScript / Vue.js / Go / 母・妹・妻と自社システム開発中(ベータ版テスト中)
https://kkeisuke.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした