-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update deps + rename options for clarity * Add typescript definitions reshapeCustomElements(..) returns a plain 'Function' for now since the core reshape module doesn't include definitions yet * Make it possible to locally override the default replacement tag This may not seem like a useful feature at first (since we're typing both the class an tag name again), but in my opinion it helps convey *semantic* meaning rather than *syntactical* meaning when editing templates. Possible improvement points: - Not sure how I'm supposed to handle multiple attribute values here - pretty-quick is being a bit weird, are you sure this is how you want it to be formatted? - Maybe a different default attribute name? - Maybe a shorter option name? - The replacementTag option (#22) should probably be renamed to defaultReplacementTag * Custom tag ↔ replacement tag map option The README could probably be worded better * Move the HTML in the README to it's own (syntax highlighted) section * Add a generic blacklist * Change the replacementTagMap to a more convenient format * Make sure option names are consistent and update TS definitions * Infer additionalTags from replacementTagMap
- Loading branch information
1 parent
0ef19c2
commit 46df66e
Showing
6 changed files
with
358 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
export default function reshapeCustomElements( | ||
options?: ReshapeCustomElementsOptions | ||
): Function | ||
|
||
export interface ReshapeCustomElementsOptions { | ||
defaultReplacementTag?: string | ||
additionalTags?: HtmlTags[] | ||
blacklist?: string[] | ||
replacementTagMap?: ReplacementTagMap | ||
replacementTagAttr?: string | ||
} | ||
|
||
export type ReplacementTagMap = { [tag: string]: string[] } | ||
|
||
type HtmlTags = | ||
| 'a' | ||
| 'abbr' | ||
| 'address' | ||
| 'area' | ||
| 'article' | ||
| 'aside' | ||
| 'audio' | ||
| 'b' | ||
| 'base' | ||
| 'bdi' | ||
| 'bdo' | ||
| 'blockquote' | ||
| 'body' | ||
| 'br' | ||
| 'button' | ||
| 'canvas' | ||
| 'caption' | ||
| 'cite' | ||
| 'code' | ||
| 'col' | ||
| 'colgroup' | ||
| 'datalist' | ||
| 'dd' | ||
| 'del' | ||
| 'details' | ||
| 'dfn' | ||
| 'dialog' | ||
| 'div' | ||
| 'dl' | ||
| 'dt' | ||
| 'em' | ||
| 'embed' | ||
| 'fieldset' | ||
| 'figcaption' | ||
| 'figure' | ||
| 'footer' | ||
| 'form' | ||
| 'h1' | ||
| 'h2' | ||
| 'h3' | ||
| 'h4' | ||
| 'h5' | ||
| 'h6' | ||
| 'head' | ||
| 'header' | ||
| 'hr' | ||
| 'html' | ||
| 'i' | ||
| 'iframe' | ||
| 'img' | ||
| 'input' | ||
| 'ins' | ||
| 'kbd' | ||
| 'keygen' | ||
| 'label' | ||
| 'legend' | ||
| 'li' | ||
| 'link' | ||
| 'main' | ||
| 'map' | ||
| 'mark' | ||
| 'menu' | ||
| 'menuitem' | ||
| 'meta' | ||
| 'meter' | ||
| 'nav' | ||
| 'noscript' | ||
| 'object' | ||
| 'ol' | ||
| 'optgroup' | ||
| 'option' | ||
| 'output' | ||
| 'p' | ||
| 'param' | ||
| 'pre' | ||
| 'progress' | ||
| 'q' | ||
| 'rp' | ||
| 'rt' | ||
| 'ruby' | ||
| 's' | ||
| 'samp' | ||
| 'script' | ||
| 'section' | ||
| 'select' | ||
| 'small' | ||
| 'source' | ||
| 'span' | ||
| 'strong' | ||
| 'style' | ||
| 'sub' | ||
| 'summary' | ||
| 'sup' | ||
| 'table' | ||
| 'tbody' | ||
| 'td' | ||
| 'textarea' | ||
| 'tfoot' | ||
| 'th' | ||
| 'thead' | ||
| 'time' | ||
| 'title' | ||
| 'tr' | ||
| 'track' | ||
| 'u' | ||
| 'ul' | ||
| 'var' | ||
| 'video' | ||
| 'wbr' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.