GithubHelp home page GithubHelp logo

pushqrdx / vscode-inline-html Goto Github PK

View Code? Open in Web Editor NEW
54.0 3.0 15.0 657 KB

🎨 Adding Syntax Highlighting, Emmet, IntelliSense support for ES6 Template Strings in Visual Studio Code.

Home Page: https://marketplace.visualstudio.com/items?itemName=pushqrdx.inline-html

License: GNU General Public License v3.0

TypeScript 91.84% JavaScript 8.16%
vscode vscode-extension intellisense emmet es6-javascript typescript

vscode-inline-html's People

Contributors

kidonng avatar luxemburgo avatar maroon1 avatar p-froggy avatar pushqrdx 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-inline-html's Issues

less repetitive if possible?

I wish webstorm could add this

also is there a way I dont have to keep repeating css like here:

image

doesnt seem to work with ternary's if you put it in the 2nd condition:

image

whole code:

//stored in /components/nav.js

/**
 * IMPORTANT This component assumes a single parent wrapper alongside a main sibling for content so
 * that it can change the flex direction of the parent
 * @param hostComponent
 *
 * @example
 * in sidebar mode
 *       <nav data-component="nav" data-header-bar="true"></nav>
 *
 */
export default (hostComponent) => {
  const render = (isHeaderBarMode = false) => {
    // dont display the nav if we are in header bar mode and modify the parent flex direction
    let { burgerPx,headerBar} = hostComponent.dataset
    if(!headerBar && burgerPx) {
throw new Error("you do not need burgerPx when headerBar isn't true" )
    }

    if (headerBar === 'true') {
      hostComponent.style.display = 'none';
    }







    // CSS styles for the navigation component

    // language=CSS
    const navStyles = /* css */`
      nav {
  animation: 0.5s ease-in-out 0s 1 slideInFromLeft;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 10px 20px;
  background-color: var(--sidenav-color);
  min-width: 140px;
  flex-wrap: wrap;


  & button {
    width: 100%;
  }
  &.header-bar-mode {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    & a {
      color: var(--default-text);
      justify-content: center;
      align-items: center;
    }
    
  }
          
         
        
          ${burgerPx?/* css */ `
        @media (max-width: ${burgerPx}px) {
          &.header-bar-mode {

        flex-direction: column;
        
        }
        }`:/* css */`
          @media (max-width: 600px) {
    & .text {
      display: none;
    }
    min-width: auto;
  }
        `}
}`;
    // Update the count display and button markup together
    hostComponent.innerHTML = `
        <style>${navStyles}</style>
        <a data-nav href="/" title="Home">
          <span class="icon">&#x1F3E0;</span>
          <!-- Unicode for a house, similar to a home icon -->
          <span class="text">Home</span>
        </a>
        <a data-nav href="/button-badge" title="Button + Badges Design System">
          <span class="icon">&#x1F518;</span>
          <!-- Unicode for a pencil, similar to an edit or form icon -->
          <span class="text">Button + Badges</span>
        </a>
        <a data-nav href="/form" title="Form Design System">
          <span class="icon">&#x270F;</span>
          <!-- Unicode for a pencil, similar to an edit or form icon -->
          <span class="text">Form</span>
        </a>
        <a data-nav href="/maps" title="Map example">
          <span class="icon">&#x1F5FA;</span>
          <!-- Unicode for a pencil, similar to an edit or form icon -->
          <span class="text">Maps</span>
        </a>

        <a data-nav href="/users" title="DB retrival example (requires the deno backend to run - see readme (Optional Backend))">
          <span class="icon">👥</span>
          <span class="text">DB users</span>
        </a>
        <a data-nav href="/calendar" title="Calendar Example">
          <span class="icon"> 📆 </span>
          <span class="text"> Calendar</span>
        </a>
        <a data-nav href="/multiple-instances" title="Multiple instances of vanilla.js comoonets in action with shared state">
          <span class="icon">🧬</span>
          <span class="text">Multiple instances</span>
        </a>
        <a data-nav href="/cookies" title="Elementary cookie popup permissions thing">
          <span class="icon">🍪</span>
          <span class="text">Cookie popup</span>
        </a>`;

    //add classes button secondary squarify to all nav links
    hostComponent.querySelectorAll('a').forEach((navLink) => {
      navLink.classList.add('button', 'secondary', 'squarify');
    });
    if (hostComponent.dataset.headerBar === 'true') {
      hostComponent.classList.add('header-bar-mode');
      // todo find a better way to do this
      hostComponent.parentElement.style.flexDirection = 'column';

      //remove the icons to save horizontal space only if the flex container starts to run out of space

      hostComponent.querySelectorAll('.icon').forEach((icon) => {
        //  icon.style.display = 'none';
      });
    }
    // the only thing not in css to make visible after we change the parent
    hostComponent.style.display = 'flex';
  };

  // Display the initial count
  render();
};

Unrelated executable present in the extension

I noticed there is a file named croc taking up more than half the extension size:

$ du -sh ~/.vscode/extensions/pushqrdx.inline-html-*/* | sort -h | tail -n4
540K	/Users/kid/.vscode/extensions/pushqrdx.inline-html-0.3.5/docs
3.8M	/Users/kid/.vscode/extensions/pushqrdx.inline-html-0.3.5/node_modules
5.4M	/Users/kid/.vscode/extensions/pushqrdx.inline-html-0.3.5/croc
9.8M	total

Upon inspecting it seems to be an executable of https://github.com/schollz/croc:

$ file ~/.vscode/extensions/pushqrdx.inline-html-*/croc
/Users/kid/.vscode/extensions/pushqrdx.inline-html-0.3.5/croc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=6ad6eCjoCpDzAgT4fa1q/zgtYT6Jqz8Hudut1Z9pr/XktDKbBkBi9_EQ6gPETk/GnREkn9n1QHz_srmnqP8, stripped

There is no mention of the file in the repository, and its usage has nothing to do with the extension. I believe this is a mistake, and the extension should be republished with the executable removed.

Comment-style tags broken

Unfortunately 81839d4 has broken the comment-style tags. I wish I knew enough regex to fix it!

Eg.

doSomething( /*html*/`<div class="test">test</div>`);

VSCode with v0.3.4:
Screenshot - 24_01_2022 , 12_12_39 PM

VSCode with v0.3.3:
Screenshot - 24_01_2022 , 12_13_50 PM

Support for HTML files

Add support for HTML files.

It would be nice if the html template literal was syntax highlighted also within a script in an HTML file (like in HTML imports of Polymer 2 components).

For example:

...
<script>
const foo = html`<p class="bar">foo</p>`;
</script>

syntax highlighting breaks

double curly braces inside the /html/ template string break syntax highlighting throughout the file
example4

everything is fine without them
example5

Bug: wrong comment syntax inside <style> tags

Environment Observed In

Extension version: v0.3.5
VS Code version: 1.69.1
OS: Windows 11

Steps to reproduce

  • In a Javascript or Typescript file, paste the following:
    const markup = /*html*/`
      <style>
        
      </style>
    `;
  • Place the cursor on the blank line
  • Execute the Toggle Line Comment (command id is editor.action.commentLine) command
    • By default on Windows this command is bound to ctrl+/

Expected Behavior

The editor adds the sequence /* */ (CSS comment) in place as it does when you execute the same command inside a <style> tag in an HTML file.

Observed Behavior

The editor adds the sequence <!-- --> (HTML comment) in place.

Variables inside strings not highlighted correctly?

Perhaps I'm missing a way of escaping double quotes, below doesn't look quite right. es6-string-html highlights it more according to expectation.

image

Thanks for the extension otherwise - having emmet etc is great!

Support for CSS tag

Please add the possibility to intellisense for CSS, something like this:

css`
    div {
        color: red
    }
`

No Emmet expansion for same line template literals

I just installed the extension (thanks! :)

When I create an html inline string, the first tag I add does not get emmet-expanded - I see the emmet popup, but when I hit Enter, it disappears without substituting.

After I manually enter a valid closed tag, all works fine following it.

Support /* html */

It would be nice to support a syntax like

return /* html */`
    <h2>foo</h2>
  `;

as well.

Especially as eslint usually will complain if you write it like this /*html*/.

so you end up writing it like this :(

// eslint-disable-next-line spaced-comment
return /*html*/`
    <h2>foo</h2>
  `;

Formatting?

I'm loving it! Ever thought about formatting? I'm using it in the context of lit-html and have to format the templates by hand at the moment o.o

Have a great day!

html completion for attribute quotes doesn't work

Hello, first, thank you so much for the VSCode extension, it's great.

About the issue:
In .html file, when I autocomplete an attribute, it creates double quotes. But this is not happening in .js files.

Before enter:
image

After enter:
image

Expected:
image

This is my config in vscode

  "html.autoCreateQuotes": true,
  "html.completion.attributeDefaultValue": "doublequotes",

Support for script tag?

Hi, thank you very much for creating this vs code extension. I use it every day for my work. But i miss one thing: syntax highlighting and code intellisense for <script> tags like:

const template = () => html`
  <script>
    console.log(navigator.userAgent)
  </script>
`

To be honest, it's quite annoying when you don't get any code suggestions etc.. Especially with the many DOM Apis that would be really helpful.

I would be very happy if inline html could support this in the future

Support for PHP files

For example:

heredoc:

function outputhtml()
{
echo <<<html
   <html>
   <head><title>主页</title></head>
   <body>主页内容</body>
   </html>
html;
}


function outputhtml()
{
echo /*html*/'
   <html>
   <head><title>主页</title></head>
   <body>主页内容</body>
   </html>
   ';
}

html is not defined

when doing html`markup`
when running my code I get errors because of the apparent random reference to "html"

I had to use

/*html*/`markup`

and that worked, but it'd be nice if I could get the other method to work.
I'm using the string in an assignment directly to a template element's innerHTML, similar to the template-literal seen here on a repo of mine.

No intellisense nor Emmet inside a child template string

Can't get the intellisense/Emmet in a child template string, consider this snippet:

inline_html_no_intellisense

As you can see, the template string inside the array map callback, doesn't give intellisense nor Emmet, only syntax highlighting as showed in the below screenshot.

inline_html_issue

Vs Code Version + OS

vs_code_version

Idea: Add full autocompletion in HTML and CSS

When I write atributes for HTML tags and properties in CSS don't autocomplete full.

Example in HTML

Actually: class
Request: class = "( cursor inside )"

Example in CSS

Actually: box-sizing
Request: box-sizing: ( after appear the select property and select the property autocomplete the ; )

Thanks for your good extension

It does not work

I tried this extension inside a javascript file and Emmet did not work or anything.

Context breaking in js if the string `html` is found

If I have code like:

let a = document.querySelector(`html`);
let b;
let c = document.querySelectorAll(`a`);

It seems to think that anything between the html and the a is in an html or css context, not sure of which, it gives hover tooltips like these:
imagen
imagen

Things I have tried, these all make the problem go away:

  • Disable/enable extension when it's the only one in the workspace (it's how I know it's this extension that causes it when enabled)
  • Change the quotation marks in either html or a from backticks to single or double quotes
  • Change the html string to something else that is not the literal html string (like htm or tml ).

Does not highlight with recent vscode version

Hey,

since the last update from VSCode, it seems like the highlighting is not working anymore:

image

Also it looks like the intellisense for default html tags is working:

image

But Emmet is not:

image

(Keine Vorschläge = no results)

Best Regards
Marcel

The head of the arrow functions has an error color

Hi! First of all: this extension is 10/10, it allows me to create dynamic HTML elements on a totally different level!

I have a little remark. The head (character: &gt) of the arrow functions inside template literal expressions has an error color. Can you do something with it?

image

Feature Request: tsx & jsx support.

Hi, thanks for the awesome plugin!

Would it be possible to add support for other types of syntax highlighters? I'm building a code mod tool and it would be great to have this IDE feature when writing test tables that contain tsx syntax as inputs:

const codeFixerTestTable = [{
    input: /* tsx */ `
        export const Test1 = ({ id }) => {
            return <div id={id}>foo</div>;
        };
    `,
    expect: /* tsx */ `
        export const Test1 = ({ id }) => {
            return <div id={id}>
                <wrapper>foo</wrapper>
            </div>;
        };        
    `
}]

Perhaps I'm oversimplifying things but wouldn't it be possible to use any built-in language mode in VS Code if the file extension was specified in the comment prefix? I'd be happy to help contribute to the project if you could point me in the right direction!

Thanks

Varied colors in nested template placeholders

First of all, thanks for your work on this extension, its awesome.

I'm not actually sure if this is a bug, but it seemed odd so I thought I'd document it here.

Here's the relevant example (all of this is within an /* html */ template literal.

image

Its interesting that there a 3 different colors used across the 4 instances of ${. I've observed this with different themes applied, the screenshot is with VS Code's default dark theme.

Feature Request: Support for css styles without selectors

Currently, this is supported:

/*css*/`
  .selector {
    display: block;
  }
`

But this is not:

/*css*/`
  display: block;
`

I propose adding a new syntax specific for CSS styles—a commonly used pattern when adding styles to an element inline in JavaScript frameworks—like this:

/*style*/`
  display: block;
`

problem whith auto complete

When I select a tag em press return:
image

the autocomplet return this
image

and when I press ctr+z, it complets with this
image

Some times I select width and the autocomplete complets with windows.

Support for /*JS*/

I have a specific situation - I need to be able to write inline Web Workers and I need JS syntax highliting for this.

1

Would you add this option?

Add support for styled components

We often use this syntax:

const StyledDiv = styled.div`
  color: red;
  font-size: 20px;
`;

But this is the syntax highlighting I see:

It would be great to support that syntax out of the box for CSS strings while retaining support for CSS intellisense and Emmet, etc.:

styled.element`...`

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.