autocomplete without react
This commit is contained in:
parent
1b55a5e3e0
commit
47aa4cf198
3 changed files with 48 additions and 36 deletions
17
packages/codemirror/html.mjs
Normal file
17
packages/codemirror/html.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const parser = new DOMParser();
|
||||
export let html = (string) => {
|
||||
return parser.parseFromString(string, 'text/html').querySelectorAll('*');
|
||||
};
|
||||
let parseChunk = (chunk) => {
|
||||
if (Array.isArray(chunk)) return chunk.flat().join('');
|
||||
if (chunk === undefined) return '';
|
||||
return chunk;
|
||||
};
|
||||
export let h = (strings, ...vars) => {
|
||||
let string = '';
|
||||
for (let i in strings) {
|
||||
string += parseChunk(strings[i]);
|
||||
string += parseChunk(vars[i]);
|
||||
}
|
||||
return html(string);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue