GithubHelp home page GithubHelp logo

codemirror6-plugin's People

Contributors

sergeche avatar sergeichestakov avatar shshaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

codemirror6-plugin's Issues

Ignore expand abbreviation if multiple lines selected

If you have Tab mapped to expand abbreviation and indent, most of the time it seems to work fine, but occasionally if your cursor is inside of some text and you tab to indent, Emmet tries to expand that first word as an abbreviation.

Example: if you have the cursor on <p>, Emmet ignores and indent works properly.

Screen.Recording.2023-10-04.at.9.17.12.AM.mov

Example: If you have your cursor inside on some text, it expands strangely.

Screen.Recording.2023-10-04.at.9.16.53.AM.mov

Perhaps the Emmet expansion should not run if the selection includes a range > 0?

Markup Snippets not working in Vue

CSS snippets seem to be working in Vue, but Markup snippets don't. Am I missing something or is this a bug?

Screen.Recording.2024-03-14.at.11.43.21.AM.mov

Emmet does not use correct syntax highlighting

I'm currently using @codemirror/theme-one-dark on Codemirror 6 alongside Emmet (implemented using the abbreviationTracker extension) and I've noticed that the syntax highlighting is incorrect. See below for images.

How it should look:
Screenshot 2022-08-30 7 15 00 PM

How it looks:
Screenshot 2022-08-30 7 14 36 PM

Thanks.

Populating Custom Snippets

How do you add custom snippets to Emmet in CodeMirror 6?

In the past, we would pass through an emmet property on the CodeMirror config that would contain all the snippets. Obviously we can't do that directly in CodeMirror 6. Would it be a Facet or something?

Set Prec to highest for Tab/Esc key Commands and export Commands

Currently the tab key for the abbreviationTracker has no precedence, but this should probably be set to highest given that the tab key might also be assigned to indentation.

Also please export the key commands, that way I can assign tabKeyHandler to Enter.

HTML should not suggest invalid tags

See below video for examples. The plugin currently suggests invalid HTML tags, and seems to just match any given string. In VSCode, it does not do this. It only suggests Emmet Autocomplete when there is a valid HTML tag.

CodeMirror:

Screen.Recording.2023-02-21.at.5.09.43.PM.mov

VSCode:

Screen.Recording.2023-02-21.at.5.10.01.PM.mov

Conditional Enabling

Should Emmet only be enabled for HTML / CSS compatible languages?
Is there a good way to limit Emmet activation based on the active language in a CodeMirror 6 instance?

Untranspiled code

Hey Sergey, we noticed that there's untranspiled code in the published package and was wondering if you can publish a non-esnext target https://github.com/emmetio/codemirror6-plugin/blob/main/vite.config.ts#L7?

We use codemirror's cm-buildhelper for prod builds and works well for us, for example: https://github.com/replit/codemirror-vscode-keymap/blob/master/package.json#L22. We still use vite for local development (you can click run on replit and you can see how it runs on replit with vite https://github.com/replit/codemirror-vscode-keymap).

mobile support

codemirror 6 has great support for mobile devices.

the current implementation for emmet plugin makes it difficult to use on mobile devices (where most mobile keyboards do not have Tab or Cmd keys to trigger expanding abbreviations).

I suggest allowing click/tap on abbreviation preview to expand abbreviation (this is the behavior implemented in emmet-monaco-es for monaco editor).

It would also help to allow always showing the abbreviation preview (not just when it becomes complex), so that users know that emmet is available. May be this can be exposed as a configuration option.

How to Activate on Sass, Scss, LESS, etc.

Are there any ways to ensure Emmet is active for CodeMirror 6 legacy modes, such as Sass, Scss and LESS? Based on my reading of the source, it seems like the language has to be cssLanguage or htmlLanguage.

Related: Per #10, you recommended manually adding/removing Emmet based on if the language is supported, but as I look at all the Emmet source, it seems like you have a lot of code around if the syntax is supported ( such as

export function isSupported(syntax: string): boolean {
). Do you think it might be possible to add a checker in the abbreviationTracker, expandAbbreviation and other extensions to ensure the extensions can run in the current document?

Make CSS autocomplete option position configurable/dynamic to better handle conflicts with built-in autocomplete

It seems that the Emmet extension currently conflicts with the built-in CSS autocomplete results and is always rendered at the top no matter how relevant it is.

I did some digging into the code and found that Emmet's CSS completion source always sets the filter flag to false and returns a boost of 99 for autocomplete options which causes them to be weighted above all other autocomplete options that may be present (e.g. the default ones).

It would be nice if this was configurable so that Emmet does not always render above other autocomplete options, especially when it may not be the most relevant.

CSS autocomplete extension is not context aware

See below gif for some examples. Typing in h1 at the top level results in height: 1px being inserted which is unexpected in this context (since h1 is a valid tag that can be selected and not inside a section). In the other case, typing in div.class {} results in div: .class; {} which is also unexpected and can be frustrating since it renders that selector impossible to complete on its own.

GIF Recording 2022-06-21 at 3 55 55 PM(1)

Currently, there are 3 known contexts for CSS in Emmet:

  • global: typing something outside any section or property. In this case, Emmet should provide completions for snippets only. Snippets are code blocks of arbitrary content (like @k for @keyframe { … }.
  • inside section: should provide completions for snippets and properties like p10padding: 10px
  • inside property value: should provide value-specific completions, like #f.5rgba(255, 255, 255, 0.5)

The CM6 extension should respect these contexts to match what's expected and what the equivalent extensions in other editors (e.g. Sublime do).

Mount Preview to ShadowDOM root

For reasons we have to mount CodeMirror 6 in ShadowDOM (which CodeMirror 6 supports via the root property of EditorView.

Emmet overall works fine, but theme styles don't work in Emmet in the ShadowDOM since the Emmet Preview's EditorView is using the parent document instead of the ShadowDOM root.

A couple of ideas on how to solve the problem:

  1. Use the parent EditorView's root property when creating the preview EditorView, though it doesn't seem like createPreview gets the parent EditorView which could be referenced.
  2. Give an API to retrieve the preview EditorView to allow setting the root manually with setRoot

Known Syntaxes as Enum

Could the EmmetKnownSyntax list be converted to an enum and exported so those values can be referenced?

Right now in my codebase I'm matching up the CodeMirror 6 Editor's language to an EmmetKnownSyntax but I'm just using a string. Having that value as an enum would ensure matching the exact values and allow authors to know which syntaxes are supported just by referencing the enum.

When used in nextJS setup, it works on dev but when you build it does not work.

I basically copied the source and used it in a page in next js based app. when on dev (yarn dev in nextjs) it works fine, but when you build it you get the following error. Do you know what the problem is?

Im doing expandAbbreviation. Same code as yours.

Cannot read properties of undefined (reading '0')
at i (abbreviation.es.js:12:1)
at l (abbreviation.es.js:24:1)
at abbreviation.es.js:282:1
at abbreviation.es.js:290:1
at e (abbreviation.es.js:136:1)
at abbreviation.es.js:79:1
at F (abbreviation.es.js:47:1)
at emmet.es.js:1443:16
at t5 (emmet.es.js:1457:1)
at et (emmet.ts:48:12)

Snippet Previews

Related to #14: I have the new syntax setup in place. Snippets work correctly, but the snippet autocompletions are not showing up for Sass and SCSS. CSS still shows them fine.

Sass:
https://user-images.githubusercontent.com/777155/233471378-15fb816b-5caf-4134-b67c-871e7b37dd9b.mov

Regular CSS:
Screenshot 2023-04-20 at 1 05 24 PM

I haven't tested the other languages, but I'll provide more details if I do.

Worth noting that I'm using the just released https://github.com/codemirror/lang-sass package via the latest version of https://github.com/codemirror/language-data

Module doesn't export anything

Hey @sergeche! Thanks so much for getting this published.

However, when I tried to install the package and follow the usage instructions in the README, I discovered that abbreviationTracker isn't a valid export. Digging deeper, I found that nothing is actually getting exported via the following code:

import * as emmet from '@emmetio/codemirror6-plugin';

console.log(Object.keys(emmet));

Indeed, when I opened up the bundle (under dist/plugin.js) and grepped for export nothing came up. Possibly an issue with the Vite config's rollup options?

Created a repl with a minimal repro here: https://replit.com/@SergeiChestakov/cm-emmet-exports

Which is hosted here: https://cm-emmet-exports.sergeichestakov.repl.co/

You can visit that URL and check the logs to see that logging the module's exports produces an empty array

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.