|
| 1 | +/* |
| 2 | + * GNU AGPL-3.0 License |
| 3 | + * |
| 4 | + * Copyright (c) 2021 - present core.ai . All rights reserved. |
| 5 | + * Original work Copyright (c) 2024 [emmet.io](https://github.com/emmetio/brackets-emmet). |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify it |
| 8 | + * under the terms of the GNU Affero General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License |
| 15 | + * for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Affero General Public License |
| 18 | + * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0. |
| 19 | + */ |
| 20 | + |
| 21 | + |
| 22 | +/** |
| 23 | + * Emmet Snippets Configuration |
| 24 | + * |
| 25 | + * This file defines the configuration for Emmet snippet expansion. |
| 26 | + * It contains four main exports: |
| 27 | + * |
| 28 | + * 1. **markupSnippets**: An object that maps abbreviation keys to their expanded HTML markup. |
| 29 | + * These are all the abbreviations that can be expanded into something other than the usual tags. |
| 30 | + * When an abbreviation matching one of the markup snippets is passed to Emmet, it knows how to expand it. |
| 31 | + * |
| 32 | + * 2. **htmlTags**: An array of standard HTML tags that are expanded by default. |
| 33 | + * This list helps determine whether an abbreviation corresponds to a valid HTML element. |
| 34 | + * Although Emmet can expand any text as an HTML tag, |
| 35 | + * doing so would trigger code hints for every piece of text in the editor. |
| 36 | + * So, we maintain a list of standard tags; |
| 37 | + * only when an abbreviation matches one of these does Emmet display the code hints. |
| 38 | + * |
| 39 | + * 3. **positiveSymbols**: An array of symbols that, when present in an abbreviation, |
| 40 | + * indicate that the abbreviation is eligible for expansion. |
| 41 | + * Examples include `.`, `#`, `>`, `+`, etc., which are used for classes, IDs, nesting, |
| 42 | + * sibling selectors, attributes, and more. |
| 43 | + * |
| 44 | + * 4. **negativeSymbols**: An array of sequences that indicate a word should NOT be expanded. |
| 45 | + * For example, the sequence `</` (which begins a closing tag) signals |
| 46 | + * that the abbreviation should be ignored for expansion. |
| 47 | + */ |
| 48 | +define(function (require, exports, module) { |
| 49 | + |
| 50 | + |
| 51 | + const markupSnippets = { |
| 52 | + "a": "a[href]", |
| 53 | + "a:blank": "a[href='http://${0}' target='_blank' rel='noopener noreferrer']", |
| 54 | + "a:link": "a[href='http://${0}']", |
| 55 | + "a:mail": "a[href='mailto:${0}']", |
| 56 | + "a:tel": "a[href='tel:+${0}']", |
| 57 | + "abbr": "abbr[title]", |
| 58 | + "acr|acronym": "acronym[title]", |
| 59 | + "base": "base[href]/", |
| 60 | + "basefont": "basefont/", |
| 61 | + "br": "br/", |
| 62 | + "frame": "frame/", |
| 63 | + "hr": "hr/", |
| 64 | + "bdo": "bdo[dir]", |
| 65 | + "bdo:r": "bdo[dir=rtl]", |
| 66 | + "bdo:l": "bdo[dir=ltr]", |
| 67 | + "col": "col/", |
| 68 | + "link": "link[rel=stylesheet href]/", |
| 69 | + "link:css": "link[href='${1:style}.css']", |
| 70 | + "link:print": "link[href='${1:print}.css' media=print]", |
| 71 | + "link:favicon": "link[rel='shortcut icon' type=image/x-icon href='${1:favicon.ico}']", |
| 72 | + "link:mf|link:manifest": "link[rel='manifest' href='${1:manifest.json}']", |
| 73 | + "link:touch": "link[rel=apple-touch-icon href='${1:favicon.png}']", |
| 74 | + "link:rss": "link[rel=alternate type=application/rss+xml title=RSS href='${1:rss.xml}']", |
| 75 | + "link:atom": "link[rel=alternate type=application/atom+xml title=Atom href='${1:atom.xml}']", |
| 76 | + "link:im|link:import": "link[rel=import href='${1:component}.html']", |
| 77 | + "meta": "meta/", |
| 78 | + "meta:utf": "meta[http-equiv=Content-Type content='text/html;charset=UTF-8']", |
| 79 | + "meta:vp": "meta[name=viewport content='width=${1:device-width}, initial-scale=${2:1.0}']", |
| 80 | + "meta:compat": "meta[http-equiv=X-UA-Compatible content='${1:IE=7}']", |
| 81 | + "meta:edge": "meta:compat[content='${1:ie=edge}']", |
| 82 | + "meta:redirect": "meta[http-equiv=refresh content='0; url=${1:http://example.com}']", |
| 83 | + "meta:refresh": "meta[http-equiv=refresh content='${1:5}']", |
| 84 | + "meta:kw": "meta[name=keywords content]", |
| 85 | + "meta:desc": "meta[name=description content]", |
| 86 | + "style": "style", |
| 87 | + "script": "script", |
| 88 | + "script:src": "script[src]", |
| 89 | + "script:module": "script[type=module src]", |
| 90 | + "img": "img[src alt]/", |
| 91 | + "img:s|img:srcset": "img[srcset src alt]", |
| 92 | + "img:z|img:sizes": "img[sizes srcset src alt]", |
| 93 | + "picture": "picture", |
| 94 | + "src|source": "source/", |
| 95 | + "src:sc|source:src": "source[src type]", |
| 96 | + "src:s|source:srcset": "source[srcset]", |
| 97 | + "src:t|source:type": "source[srcset type='${1:image/}']", |
| 98 | + "src:z|source:sizes": "source[sizes srcset]", |
| 99 | + "src:m|source:media": "source[media='(${1:min-width: })' srcset]", |
| 100 | + "src:mt|source:media:type": "source:media[type='${2:image/}']", |
| 101 | + "src:mz|source:media:sizes": "source:media[sizes srcset]", |
| 102 | + "src:zt|source:sizes:type": "source[sizes srcset type='${1:image/}']", |
| 103 | + "iframe": "iframe[src frameborder=0]", |
| 104 | + "embed": "embed[src type]/", |
| 105 | + "object": "object[data type]", |
| 106 | + "param": "param[name value]/", |
| 107 | + "map": "map[name]", |
| 108 | + "area": "area[shape coords href alt]/", |
| 109 | + "area:d": "area[shape=default]", |
| 110 | + "area:c": "area[shape=circle]", |
| 111 | + "area:r": "area[shape=rect]", |
| 112 | + "area:p": "area[shape=poly]", |
| 113 | + "form": "form[action]", |
| 114 | + "form:get": "form[method=get]", |
| 115 | + "form:post": "form[method=post]", |
| 116 | + "label": "label[for]", |
| 117 | + "input": "input[type=${1:text}]/", |
| 118 | + "inp": "input[name=${1} id=${1}]", |
| 119 | + "input:h|input:hidden": "input[type=hidden name]", |
| 120 | + "input:t|input:text": "inp[type=text]", |
| 121 | + "input:search": "inp[type=search]", |
| 122 | + "input:email": "inp[type=email]", |
| 123 | + "input:url": "inp[type=url]", |
| 124 | + "input:p|input:password": "inp[type=password]", |
| 125 | + "input:datetime": "inp[type=datetime]", |
| 126 | + "input:date": "inp[type=date]", |
| 127 | + "input:datetime-local": "inp[type=datetime-local]", |
| 128 | + "input:month": "inp[type=month]", |
| 129 | + "input:week": "inp[type=week]", |
| 130 | + "input:time": "inp[type=time]", |
| 131 | + "input:tel": "inp[type=tel]", |
| 132 | + "input:number": "inp[type=number]", |
| 133 | + "input:color": "inp[type=color]", |
| 134 | + "input:c|input:checkbox": "inp[type=checkbox]", |
| 135 | + "input:r|input:radio": "inp[type=radio]", |
| 136 | + "input:range": "inp[type=range]", |
| 137 | + "input:f|input:file": "inp[type=file]", |
| 138 | + "input:s|input:submit": "input[type=submit value]", |
| 139 | + "input:i|input:image": "input[type=image src alt]", |
| 140 | + "input:b|input:btn|input:button": "input[type=button value]", |
| 141 | + "input:reset": "input:button[type=reset]", |
| 142 | + "isindex": "isindex/", |
| 143 | + "select": "select[name=${1} id=${1}]", |
| 144 | + "select:d|select:disabled": "select[disabled.]", |
| 145 | + "opt|option": "option[value]", |
| 146 | + "textarea": "textarea[name=${1} id=${1}]", |
| 147 | + "tarea:c|textarea:cols": "textarea[name=${1} id=${1} cols=${2:30}]", |
| 148 | + "tarea:r|textarea:rows": "textarea[name=${1} id=${1} rows=${3:10}]", |
| 149 | + "tarea:cr|textarea:cols:rows": "textarea[name=${1} id=${1} cols=${2:30} rows=${3:10}]", |
| 150 | + "marquee": "marquee[behavior direction]", |
| 151 | + "menu:c|menu:context": "menu[type=context]", |
| 152 | + "menu:t|menu:toolbar": "menu[type=toolbar]", |
| 153 | + "video": "video[src]", |
| 154 | + "audio": "audio[src]", |
| 155 | + "html:xml": "html[xmlns=http://www.w3.org/1999/xhtml]", |
| 156 | + "keygen": "keygen/", |
| 157 | + "command": "command/", |
| 158 | + "btn:s|button:s|button:submit": "button[type=submit]", |
| 159 | + "btn:r|button:r|button:reset": "button[type=reset]", |
| 160 | + "btn:b|button:b|button:button": "button[type=button]", |
| 161 | + "btn:d|button:d|button:disabled": "button[disabled.]", |
| 162 | + "fst:d|fset:d|fieldset:d|fieldset:disabled": "fieldset[disabled.]", |
| 163 | + |
| 164 | + "bq": "blockquote", |
| 165 | + "fig": "figure", |
| 166 | + "figc": "figcaption", |
| 167 | + "pic": "picture", |
| 168 | + "ifr": "iframe", |
| 169 | + "emb": "embed", |
| 170 | + "obj": "object", |
| 171 | + "cap": "caption", |
| 172 | + "colg": "colgroup", |
| 173 | + "fst": "fieldset", |
| 174 | + "btn": "button", |
| 175 | + "optg": "optgroup", |
| 176 | + "tarea": "textarea", |
| 177 | + "leg": "legend", |
| 178 | + "sect": "section", |
| 179 | + "art": "article", |
| 180 | + "hdr": "header", |
| 181 | + "ftr": "footer", |
| 182 | + "adr": "address", |
| 183 | + "dlg": "dialog", |
| 184 | + "str": "strong", |
| 185 | + "prog": "progress", |
| 186 | + "mn": "main", |
| 187 | + "tem": "template", |
| 188 | + "fset": "fieldset", |
| 189 | + "datal": "datalist", |
| 190 | + "kg": "keygen", |
| 191 | + "out": "output", |
| 192 | + "det": "details", |
| 193 | + "sum": "summary", |
| 194 | + "cmd": "command", |
| 195 | + "data": "data[value]", |
| 196 | + "meter": "meter[value]", |
| 197 | + "time": "time[datetime]", |
| 198 | + |
| 199 | + "ri:d|ri:dpr": "img:s", |
| 200 | + "ri:v|ri:viewport": "img:z", |
| 201 | + "ri:a|ri:art": "pic>src:m+img", |
| 202 | + "ri:t|ri:type": "pic>src:t+img", |
| 203 | + |
| 204 | + "!!!": "{<!DOCTYPE html>}", |
| 205 | + "doc": "html[lang=${lang}]>(head>meta[charset=${charset}]+meta:vp+title{${1:Document}})+body", |
| 206 | + "!|html:5": "!!!+doc", |
| 207 | + |
| 208 | + "c": "{<!-- ${0} -->}", |
| 209 | + "cc:ie": "{<!--[if IE]>${0}<![endif]-->}", |
| 210 | + "cc:noie": "{<!--[if !IE]><!-->${0}<!--<![endif]-->}" |
| 211 | + }; |
| 212 | + |
| 213 | + |
| 214 | + const htmlTags = [ |
| 215 | + "a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", |
| 216 | + "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", |
| 217 | + "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", |
| 218 | + "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", |
| 219 | + "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", |
| 220 | + "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", |
| 221 | + "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", |
| 222 | + "mark", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", |
| 223 | + "option", "output", "p", "param", "picture", "pre", "progress", "q", |
| 224 | + "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", |
| 225 | + "source", "span", "strong", "style", "sub", "summary", "sup", "table", |
| 226 | + "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", |
| 227 | + "title", "tr", "track", "u", "ul", "var", "video", "wbr" |
| 228 | + ]; |
| 229 | + |
| 230 | + |
| 231 | + const positiveSymbols = [ |
| 232 | + '.', '#', '!', '>', '+', '^', '*', '[', ']', '{', '}', '(', ')', '&' |
| 233 | + ]; |
| 234 | + |
| 235 | + |
| 236 | + const negativeSymbols = [ |
| 237 | + '</' |
| 238 | + ]; |
| 239 | + |
| 240 | + exports.markupSnippets = markupSnippets; |
| 241 | + exports.htmlTags = htmlTags; |
| 242 | + exports.positiveSymbols = positiveSymbols; |
| 243 | + exports.negativeSymbols = negativeSymbols; |
| 244 | +}); |
| 245 | + |
0 commit comments