@pictogrammers/components 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/css.d.ts +4 -0
- package/@types/html.d.ts +4 -0
- package/README.md +49 -0
- package/dist/main.js +3819 -0
- package/dist/pgAnnoy.js +116 -0
- package/dist/pgAvatar.js +136 -0
- package/dist/pgButton.js +116 -0
- package/dist/pgButtonGroup.js +116 -0
- package/dist/pgButtonLink.js +116 -0
- package/dist/pgButtonToggle.js +146 -0
- package/dist/pgCard.js +116 -0
- package/dist/pgCardUser.js +196 -0
- package/dist/pgColor.js +136 -0
- package/dist/pgDatabase.js +236 -0
- package/dist/pgDropdown.js +686 -0
- package/dist/pgGrid.js +126 -0
- package/dist/pgHeader.js +116 -0
- package/dist/pgIcon.js +116 -0
- package/dist/pgInputCheck.js +116 -0
- package/dist/pgInputCheckList.js +126 -0
- package/dist/pgInputFileLocal.js +116 -0
- package/dist/pgInputHexRgb.js +126 -0
- package/dist/pgInputRange.js +116 -0
- package/dist/pgInputSelect.js +116 -0
- package/dist/pgInputText.js +116 -0
- package/dist/pgInputTextIcon.js +176 -0
- package/dist/pgInputUserSelect.js +116 -0
- package/dist/pgListTag.js +136 -0
- package/dist/pgMarkdown.js +346 -0
- package/dist/pgMenuIcon.js +206 -0
- package/dist/pgModalAlert.js +126 -0
- package/dist/pgModification.js +396 -0
- package/dist/pgNav.js +116 -0
- package/dist/pgOverlay.js +96 -0
- package/dist/pgPicker.js +116 -0
- package/dist/pgPreview.js +116 -0
- package/dist/pgScroll.js +266 -0
- package/dist/pgSearch.js +146 -0
- package/dist/pgTab.js +116 -0
- package/dist/pgTabs.js +136 -0
- package/dist/pgToast.js +136 -0
- package/dist/pgToasts.js +136 -0
- package/dist/pgTooltip.js +126 -0
- package/index.html +302 -0
- package/package.json +25 -0
- package/pg/annoy/README.md +18 -0
- package/pg/annoy/__examples__/basic/basic.html +8 -0
- package/pg/annoy/__examples__/basic/basic.ts +11 -0
- package/pg/annoy/annoy.css +238 -0
- package/pg/annoy/annoy.html +59 -0
- package/pg/annoy/annoy.ts +48 -0
- package/pg/annoy/index.ts +3 -0
- package/pg/avatar/README.md +23 -0
- package/pg/avatar/__examples__/basic/basic.html +6 -0
- package/pg/avatar/__examples__/basic/basic.ts +41 -0
- package/pg/avatar/__examples__/basic/constants.ts +1 -0
- package/pg/avatar/avatar.css +45 -0
- package/pg/avatar/avatar.html +8 -0
- package/pg/avatar/avatar.spec.ts +51 -0
- package/pg/avatar/avatar.ts +37 -0
- package/pg/avatar/index.ts +3 -0
- package/pg/button/README.md +51 -0
- package/pg/button/__examples__/basic/basic.html +11 -0
- package/pg/button/__examples__/basic/basic.ts +11 -0
- package/pg/button/__examples__/states/states.html +8 -0
- package/pg/button/__examples__/states/states.ts +20 -0
- package/pg/button/button.css +91 -0
- package/pg/button/button.html +3 -0
- package/pg/button/button.ts +45 -0
- package/pg/button/index.ts +3 -0
- package/pg/buttonGroup/README.md +28 -0
- package/pg/buttonGroup/__examples__/basic/basic.html +12 -0
- package/pg/buttonGroup/__examples__/basic/basic.ts +11 -0
- package/pg/buttonGroup/buttonGroup.css +4 -0
- package/pg/buttonGroup/buttonGroup.html +1 -0
- package/pg/buttonGroup/buttonGroup.spec.ts +30 -0
- package/pg/buttonGroup/buttonGroup.ts +50 -0
- package/pg/buttonGroup/index.ts +3 -0
- package/pg/buttonLink/README.md +51 -0
- package/pg/buttonLink/__examples__/basic/basic.html +17 -0
- package/pg/buttonLink/__examples__/basic/basic.ts +11 -0
- package/pg/buttonLink/buttonLink.css +91 -0
- package/pg/buttonLink/buttonLink.html +3 -0
- package/pg/buttonLink/buttonLink.ts +46 -0
- package/pg/buttonLink/index.ts +3 -0
- package/pg/buttonToggle/README.md +54 -0
- package/pg/buttonToggle/__examples__/basic/basic.html +10 -0
- package/pg/buttonToggle/__examples__/basic/basic.ts +23 -0
- package/pg/buttonToggle/buttonToggle.css +8 -0
- package/pg/buttonToggle/buttonToggle.html +4 -0
- package/pg/buttonToggle/buttonToggle.ts +44 -0
- package/pg/buttonToggle/index.ts +3 -0
- package/pg/card/README.md +21 -0
- package/pg/card/__examples__/basic/basic.html +5 -0
- package/pg/card/__examples__/basic/basic.ts +11 -0
- package/pg/card/card.css +11 -0
- package/pg/card/card.html +3 -0
- package/pg/card/card.spec.ts +30 -0
- package/pg/card/card.ts +13 -0
- package/pg/card/index.ts +3 -0
- package/pg/cardUser/README.md +22 -0
- package/pg/cardUser/__examples__/basic/basic.html +3 -0
- package/pg/cardUser/__examples__/basic/basic.ts +30 -0
- package/pg/cardUser/__examples__/basic/constants.ts +1 -0
- package/pg/cardUser/cardUser.css +67 -0
- package/pg/cardUser/cardUser.html +23 -0
- package/pg/cardUser/cardUser.spec.ts +46 -0
- package/pg/cardUser/cardUser.ts +53 -0
- package/pg/cardUser/index.ts +3 -0
- package/pg/color/README.md +13 -0
- package/pg/color/__examples__/basic/basic.html +4 -0
- package/pg/color/__examples__/basic/basic.ts +20 -0
- package/pg/color/color.css +21 -0
- package/pg/color/color.html +1 -0
- package/pg/color/color.ts +97 -0
- package/pg/color/constants.ts +357 -0
- package/pg/color/index.ts +3 -0
- package/pg/color/utils.ts +27 -0
- package/pg/database/README.md +28 -0
- package/pg/database/__examples__/basic/basic.html +9 -0
- package/pg/database/__examples__/basic/basic.ts +37 -0
- package/pg/database/database.css +0 -0
- package/pg/database/database.html +0 -0
- package/pg/database/database.ts +42 -0
- package/pg/database/index.ts +3 -0
- package/pg/dropdown/README.md +13 -0
- package/pg/dropdown/__examples__/basic/basic.html +14 -0
- package/pg/dropdown/__examples__/basic/basic.ts +11 -0
- package/pg/dropdown/dropdown.css +46 -0
- package/pg/dropdown/dropdown.html +5 -0
- package/pg/dropdown/dropdown.ts +60 -0
- package/pg/dropdown/index.ts +3 -0
- package/pg/grid/README.md +97 -0
- package/pg/grid/__examples__/basic/basic.html +29 -0
- package/pg/grid/__examples__/basic/basic.ts +139 -0
- package/pg/grid/grid.css +68 -0
- package/pg/grid/grid.html +6 -0
- package/pg/grid/grid.spec.ts +66 -0
- package/pg/grid/grid.ts +417 -0
- package/pg/grid/index.ts +3 -0
- package/pg/header/README.md +23 -0
- package/pg/header/__examples__/basic/basic.html +8 -0
- package/pg/header/__examples__/basic/basic.ts +11 -0
- package/pg/header/header.css +42 -0
- package/pg/header/header.html +15 -0
- package/pg/header/header.ts +28 -0
- package/pg/header/index.ts +3 -0
- package/pg/icon/README.md +26 -0
- package/pg/icon/__examples__/basic/basic.html +16 -0
- package/pg/icon/__examples__/basic/basic.ts +34 -0
- package/pg/icon/__examples__/basic/constants.ts +2 -0
- package/pg/icon/icon.css +9 -0
- package/pg/icon/icon.html +3 -0
- package/pg/icon/icon.spec.ts +46 -0
- package/pg/icon/icon.ts +23 -0
- package/pg/icon/index.ts +3 -0
- package/pg/inputCheck/README.md +32 -0
- package/pg/inputCheck/__examples__/basic/basic.html +8 -0
- package/pg/inputCheck/__examples__/basic/basic.ts +23 -0
- package/pg/inputCheck/index.ts +3 -0
- package/pg/inputCheck/inputCheck.css +45 -0
- package/pg/inputCheck/inputCheck.html +6 -0
- package/pg/inputCheck/inputCheck.ts +42 -0
- package/pg/inputCheckList/README.md +35 -0
- package/pg/inputCheckList/__examples__/basic/basic.html +4 -0
- package/pg/inputCheckList/__examples__/basic/basic.ts +31 -0
- package/pg/inputCheckList/index.ts +3 -0
- package/pg/inputCheckList/inputCheckList.css +70 -0
- package/pg/inputCheckList/inputCheckList.html +1 -0
- package/pg/inputCheckList/inputCheckList.ts +103 -0
- package/pg/inputCheckList/templates/option.html +8 -0
- package/pg/inputFileLocal/README.md +30 -0
- package/pg/inputFileLocal/__examples__/basic/basic.html +4 -0
- package/pg/inputFileLocal/__examples__/basic/basic.ts +23 -0
- package/pg/inputFileLocal/index.ts +3 -0
- package/pg/inputFileLocal/inputFileLocal.css +80 -0
- package/pg/inputFileLocal/inputFileLocal.html +5 -0
- package/pg/inputFileLocal/inputFileLocal.ts +82 -0
- package/pg/inputHexRgb/README.md +15 -0
- package/pg/inputHexRgb/__examples__/basic/basic.html +4 -0
- package/pg/inputHexRgb/__examples__/basic/basic.ts +23 -0
- package/pg/inputHexRgb/index.ts +3 -0
- package/pg/inputHexRgb/inputHexRgb.css +96 -0
- package/pg/inputHexRgb/inputHexRgb.html +9 -0
- package/pg/inputHexRgb/inputHexRgb.ts +79 -0
- package/pg/inputHexRgb/utils.ts +27 -0
- package/pg/inputRange/README.md +18 -0
- package/pg/inputRange/__examples__/basic/basic.html +9 -0
- package/pg/inputRange/__examples__/basic/basic.ts +30 -0
- package/pg/inputRange/index.ts +3 -0
- package/pg/inputRange/inputRange.css +0 -0
- package/pg/inputRange/inputRange.html +1 -0
- package/pg/inputRange/inputRange.ts +53 -0
- package/pg/inputSelect/README.md +25 -0
- package/pg/inputSelect/__examples__/basic/basic.html +6 -0
- package/pg/inputSelect/__examples__/basic/basic.ts +30 -0
- package/pg/inputSelect/index.ts +3 -0
- package/pg/inputSelect/inputSelect.css +36 -0
- package/pg/inputSelect/inputSelect.html +4 -0
- package/pg/inputSelect/inputSelect.ts +57 -0
- package/pg/inputText/README.md +27 -0
- package/pg/inputText/__examples__/basic/basic.html +9 -0
- package/pg/inputText/__examples__/basic/basic.ts +30 -0
- package/pg/inputText/index.ts +3 -0
- package/pg/inputText/inputText.css +20 -0
- package/pg/inputText/inputText.html +1 -0
- package/pg/inputText/inputText.spec.ts +59 -0
- package/pg/inputText/inputText.ts +59 -0
- package/pg/inputTextIcon/README.md +26 -0
- package/pg/inputTextIcon/index.ts +3 -0
- package/pg/inputTextIcon/inputTextIcon.css +24 -0
- package/pg/inputTextIcon/inputTextIcon.html +4 -0
- package/pg/inputTextIcon/inputTextIcon.spec.ts +44 -0
- package/pg/inputTextIcon/inputTextIcon.ts +26 -0
- package/pg/inputUserSelect/README.md +31 -0
- package/pg/inputUserSelect/__examples__/basic/basic.html +4 -0
- package/pg/inputUserSelect/__examples__/basic/basic.ts +25 -0
- package/pg/inputUserSelect/__examples__/basic/constants.ts +33 -0
- package/pg/inputUserSelect/index.ts +3 -0
- package/pg/inputUserSelect/inputUserSelect.css +174 -0
- package/pg/inputUserSelect/inputUserSelect.html +18 -0
- package/pg/inputUserSelect/inputUserSelect.ts +266 -0
- package/pg/listTag/README.md +26 -0
- package/pg/listTag/__examples__/basic/basic.html +16 -0
- package/pg/listTag/__examples__/basic/basic.ts +53 -0
- package/pg/listTag/__examples__/basic/constants.ts +22 -0
- package/pg/listTag/index.ts +3 -0
- package/pg/listTag/listTag.css +9 -0
- package/pg/listTag/listTag.html +1 -0
- package/pg/listTag/listTag.ts +48 -0
- package/pg/listTag/partials/tag.html +3 -0
- package/pg/markdown/README.md +13 -0
- package/pg/markdown/__examples__/basic/basic.html +3 -0
- package/pg/markdown/__examples__/basic/basic.ts +51 -0
- package/pg/markdown/__examples__/basic/constants.ts +129 -0
- package/pg/markdown/index.ts +5 -0
- package/pg/markdown/markdown.css +760 -0
- package/pg/markdown/markdown.html +1 -0
- package/pg/markdown/markdown.md +123 -0
- package/pg/markdown/markdown.spec.ts +87 -0
- package/pg/markdown/markdown.ts +381 -0
- package/pg/markdown/markdownReplace.ts +7 -0
- package/pg/menuIcon/README.md +13 -0
- package/pg/menuIcon/__examples__/basic/basic.html +3 -0
- package/pg/menuIcon/__examples__/basic/basic.ts +15 -0
- package/pg/menuIcon/index.ts +3 -0
- package/pg/menuIcon/menuIcon.css +168 -0
- package/pg/menuIcon/menuIcon.html +64 -0
- package/pg/menuIcon/menuIcon.ts +271 -0
- package/pg/modalAlert/README.md +17 -0
- package/pg/modalAlert/__examples__/basic/basic.html +4 -0
- package/pg/modalAlert/__examples__/basic/basic.ts +27 -0
- package/pg/modalAlert/index.ts +3 -0
- package/pg/modalAlert/modalAlert.css +43 -0
- package/pg/modalAlert/modalAlert.html +22 -0
- package/pg/modalAlert/modalAlert.ts +45 -0
- package/pg/modification/README.md +34 -0
- package/pg/modification/__examples__/basic/basic.html +8 -0
- package/pg/modification/__examples__/basic/basic.ts +63 -0
- package/pg/modification/__examples__/basic/constants.ts +416 -0
- package/pg/modification/index.ts +3 -0
- package/pg/modification/modification.css +311 -0
- package/pg/modification/modification.html +1 -0
- package/pg/modification/modification.spec.ts +33 -0
- package/pg/modification/modification.ts +201 -0
- package/pg/modification/type/date.html +1 -0
- package/pg/modification/type/iconAliasCreated.html +13 -0
- package/pg/modification/type/iconAliasDeleted.html +13 -0
- package/pg/modification/type/iconAuthorModified.html +13 -0
- package/pg/modification/type/iconCreated.html +13 -0
- package/pg/modification/type/iconDeleted.html +13 -0
- package/pg/modification/type/iconDeprecated.html +13 -0
- package/pg/modification/type/iconDescriptionModified.html +10 -0
- package/pg/modification/type/iconModified.html +14 -0
- package/pg/modification/type/iconRenamed.html +13 -0
- package/pg/modification/type/iconTagCreated.html +13 -0
- package/pg/modification/type/iconTagDeleted.html +13 -0
- package/pg/modification/type/news.html +5 -0
- package/pg/nav/README.md +16 -0
- package/pg/nav/__examples__/basic/basic.html +5 -0
- package/pg/nav/__examples__/basic/basic.ts +11 -0
- package/pg/nav/index.ts +3 -0
- package/pg/nav/nav.css +14 -0
- package/pg/nav/nav.html +16 -0
- package/pg/nav/nav.ts +21 -0
- package/pg/overlay/README.md +37 -0
- package/pg/overlay/__examples__/basic/basic.css +3 -0
- package/pg/overlay/__examples__/basic/basic.html +3 -0
- package/pg/overlay/__examples__/basic/basic.ts +13 -0
- package/pg/overlay/index.ts +3 -0
- package/pg/overlay/overlay.ts +26 -0
- package/pg/picker/README.md +13 -0
- package/pg/picker/index.ts +3 -0
- package/pg/picker/picker.css +56 -0
- package/pg/picker/picker.html +8 -0
- package/pg/picker/picker.ts +66 -0
- package/pg/preview/README.md +19 -0
- package/pg/preview/__examples__/basic/basic.html +11 -0
- package/pg/preview/__examples__/basic/basic.ts +22 -0
- package/pg/preview/index.ts +3 -0
- package/pg/preview/preview.css +34 -0
- package/pg/preview/preview.html +5 -0
- package/pg/preview/preview.ts +38 -0
- package/pg/scroll/README.md +42 -0
- package/pg/scroll/__examples__/basic/basic.css +4 -0
- package/pg/scroll/__examples__/basic/basic.html +11 -0
- package/pg/scroll/__examples__/basic/basic.ts +88 -0
- package/pg/scroll/index.ts +3 -0
- package/pg/scroll/scroll.css +7 -0
- package/pg/scroll/scroll.html +3 -0
- package/pg/scroll/scroll.ts +158 -0
- package/pg/search/README.md +59 -0
- package/pg/search/__examples__/basic/basic.html +3 -0
- package/pg/search/__examples__/basic/basic.ts +29 -0
- package/pg/search/__examples__/basic/constants.ts +3 -0
- package/pg/search/index.ts +3 -0
- package/pg/search/search.css +188 -0
- package/pg/search/search.html +18 -0
- package/pg/search/search.ts +252 -0
- package/pg/search/utils.ts +12 -0
- package/pg/shared/README.md +28 -0
- package/pg/shared/copy.ts +25 -0
- package/pg/shared/database.ts +35 -0
- package/pg/shared/databaseService.ts +230 -0
- package/pg/shared/debounce.ts +12 -0
- package/pg/shared/enums/modificationType.ts +19 -0
- package/pg/shared/filter.ts +14 -0
- package/pg/shared/http.ts +83 -0
- package/pg/shared/iconFilter.spec.ts +61 -0
- package/pg/shared/iconFilter.ts +71 -0
- package/pg/shared/list.ts +34 -0
- package/pg/shared/models/alias.ts +40 -0
- package/pg/shared/models/font.ts +31 -0
- package/pg/shared/models/fontIcon.ts +25 -0
- package/pg/shared/models/fontVersion.ts +22 -0
- package/pg/shared/models/icon.ts +97 -0
- package/pg/shared/models/modification.ts +45 -0
- package/pg/shared/models/style.ts +12 -0
- package/pg/shared/models/tag.ts +37 -0
- package/pg/shared/models/user.ts +35 -0
- package/pg/shared/models/version.ts +20 -0
- package/pg/shared/removeDiacritics.ts +94 -0
- package/pg/shared/toast.ts +47 -0
- package/pg/shared/uuid.ts +6 -0
- package/pg/tab/README.md +18 -0
- package/pg/tab/index.ts +3 -0
- package/pg/tab/tab.css +13 -0
- package/pg/tab/tab.html +3 -0
- package/pg/tab/tab.ts +51 -0
- package/pg/tabs/README.md +31 -0
- package/pg/tabs/__examples__/basic/basic.html +13 -0
- package/pg/tabs/__examples__/basic/basic.ts +11 -0
- package/pg/tabs/index.ts +3 -0
- package/pg/tabs/partials/tab.html +3 -0
- package/pg/tabs/tabs.css +69 -0
- package/pg/tabs/tabs.html +4 -0
- package/pg/tabs/tabs.ts +102 -0
- package/pg/toast/README.md +13 -0
- package/pg/toast/index.ts +3 -0
- package/pg/toast/toast.css +112 -0
- package/pg/toast/toast.html +13 -0
- package/pg/toast/toast.ts +39 -0
- package/pg/toasts/README.md +37 -0
- package/pg/toasts/__examples__/basic/basic.html +11 -0
- package/pg/toasts/__examples__/basic/basic.ts +86 -0
- package/pg/toasts/index.ts +3 -0
- package/pg/toasts/toasts.css +8 -0
- package/pg/toasts/toasts.html +1 -0
- package/pg/toasts/toasts.ts +51 -0
- package/pg/tooltip/README.md +51 -0
- package/pg/tooltip/__examples__/basic/basic.css +38 -0
- package/pg/tooltip/__examples__/basic/basic.html +21 -0
- package/pg/tooltip/__examples__/basic/basic.ts +55 -0
- package/pg/tooltip/addTooltip.ts +31 -0
- package/pg/tooltip/index.ts +20 -0
- package/pg/tooltip/position.ts +15 -0
- package/pg/tooltip/tooltip.css +36 -0
- package/pg/tooltip/tooltip.html +4 -0
- package/pg/tooltip/tooltip.ts +170 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div part="content"></div>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# `<pg-markdown>`
|
|
2
|
+
|
|
3
|
+
The `pg-markdown` component allows a standard way to render markdown files and apply customizations. Built in customizations include:
|
|
4
|
+
|
|
5
|
+
- `import: /path/to/file.md` - Import files
|
|
6
|
+
- `yaml` - JSON Previewer for all yaml code blocks
|
|
7
|
+
- `$ref: '#/api/model/user'` import complex models.
|
|
8
|
+
- Tabsets - Organize complex pages into tabs
|
|
9
|
+
- `> **Note:** Blockquote` - Special styling.
|
|
10
|
+
- `note` - Sticky Note
|
|
11
|
+
- `warning` - Pastel Orange
|
|
12
|
+
- `alert`, `error`, `danger` - Pastel Red
|
|
13
|
+
- `good`, `success` - Pastel Green
|
|
14
|
+
- `information`, `attention` - Pastel Blue
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import '@pictogrammers/components/pg/markdown';
|
|
18
|
+
import PgMarkdown, {
|
|
19
|
+
MarkdownReplace
|
|
20
|
+
} from '@pictogrammers/components/pg/markdown';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<pg-markdown text="# Hello World"></pg-markdown>
|
|
25
|
+
<pg-markdown file="/content/file.md"></pg-markdown>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Attributes
|
|
29
|
+
|
|
30
|
+
| Attributes | Tested | Description |
|
|
31
|
+
| ---------- | -------- | ----------- |
|
|
32
|
+
| file | ✅ | File location to load markdown file |
|
|
33
|
+
| text | ✅ | Text to render as markdown |
|
|
34
|
+
| replace | ✅ | Apply transforms |
|
|
35
|
+
|
|
36
|
+
### `file`
|
|
37
|
+
|
|
38
|
+
The `file` will load the markdown data and place it into the text value. This shorthand sometimes preferred.
|
|
39
|
+
|
|
40
|
+
### `text`
|
|
41
|
+
|
|
42
|
+
The `text` can be any valid markdown. This also bakes in rich code highlighting from the PrismJS library.
|
|
43
|
+
|
|
44
|
+
Only the languages listed below have been imported to reduce file size:
|
|
45
|
+
|
|
46
|
+
- `html`, `xml`
|
|
47
|
+
- `css`, `sass`, `scss`
|
|
48
|
+
- `javascript` / `typescript` / `jsx` / `tsx`
|
|
49
|
+
- `json`
|
|
50
|
+
- `java`
|
|
51
|
+
- `yaml`
|
|
52
|
+
- `php`
|
|
53
|
+
- `bash`
|
|
54
|
+
|
|
55
|
+
### `replace`
|
|
56
|
+
|
|
57
|
+
For customizing after a render it is helpful to regex replace some content then perform additional event binding.
|
|
58
|
+
|
|
59
|
+
An example that uses `find`, `replace`, and `render` is handling anchors in the shadow DOM.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const mdiLinkVariant = 'M...Z';
|
|
63
|
+
|
|
64
|
+
component.replace = [{
|
|
65
|
+
find: new RegExp('<(h[2-6])>([^<]+)</h[2-6]>', 'g'),
|
|
66
|
+
replace: (m1, m2, m3) => {
|
|
67
|
+
let id = m3.toLowerCase().replace(/ /g, '-').replace(/\//, '');
|
|
68
|
+
return `<${m2} data-id="${id}">
|
|
69
|
+
${m3}
|
|
70
|
+
<a href="${this.url}#${id}" style="display:inline-block;vertical-align:middle;">
|
|
71
|
+
<svg viewBox="0 0 24 24" style="width:18px;height:18px;">
|
|
72
|
+
<path d="${mdiLinkVariant}" fill="#999" />
|
|
73
|
+
</svg>
|
|
74
|
+
</a>
|
|
75
|
+
</${m2}>`;
|
|
76
|
+
},
|
|
77
|
+
render: (template) {
|
|
78
|
+
// On page load if match scroll to
|
|
79
|
+
}
|
|
80
|
+
}]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Events
|
|
84
|
+
|
|
85
|
+
| Event | Tested | Description |
|
|
86
|
+
| ---------- | -------- | ----------- |
|
|
87
|
+
| load | - | Everything is rendered. |
|
|
88
|
+
| error | - | Error processing something. |
|
|
89
|
+
|
|
90
|
+
## Methods
|
|
91
|
+
|
|
92
|
+
| Method | Tested | Description |
|
|
93
|
+
| ---------- | -------- | ----------- |
|
|
94
|
+
| modify(callback) | - | Triggers after |
|
|
95
|
+
|
|
96
|
+
### `modify(callback)`
|
|
97
|
+
|
|
98
|
+
To wire up custom logic on the rendered html. The `callback` triggers right before the `load` event. Any updates to `text` (or `file`) will trigger the `callback`.
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
markdown.modify(($content) => {
|
|
102
|
+
// $content is the rendered markdown html
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Custom Tabsets
|
|
107
|
+
|
|
108
|
+
The `tabs` syntax is really ugly, but needed something that would work with the existing markdown.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
tabs
|
|
112
|
+
tab Tab Title 1
|
|
113
|
+
|
|
114
|
+
Anything...
|
|
115
|
+
|
|
116
|
+
/tab
|
|
117
|
+
tab Tab Title 2
|
|
118
|
+
|
|
119
|
+
Another tab's `content`.
|
|
120
|
+
|
|
121
|
+
/tab
|
|
122
|
+
/tabs
|
|
123
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { selectComponent, getAttributes } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import './markdown';
|
|
4
|
+
import PgMarkdown from './markdown';
|
|
5
|
+
|
|
6
|
+
const PG_MARKDOWN = 'pg-markdown';
|
|
7
|
+
|
|
8
|
+
describe('pg-markdown', () => {
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
var c = document.createElement(PG_MARKDOWN);
|
|
12
|
+
document.body.appendChild(c);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
while (document.body.firstChild) {
|
|
17
|
+
document.body.removeChild(document.body.firstChild);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should be registered', () => {
|
|
22
|
+
expect(customElements.get(PG_MARKDOWN)).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should only expose known props', () => {
|
|
26
|
+
const props = getAttributes(PG_MARKDOWN);
|
|
27
|
+
expect(props.length).toBe(3);
|
|
28
|
+
expect(props).toContain('text');
|
|
29
|
+
expect(props).toContain('file');
|
|
30
|
+
expect(props).toContain('replace');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should be empty', () => {
|
|
34
|
+
const component = selectComponent<PgMarkdown>(PG_MARKDOWN);
|
|
35
|
+
const {
|
|
36
|
+
$content
|
|
37
|
+
} = component;
|
|
38
|
+
expect($content.innerHTML).toEqual('');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should markdown text input', async () => {
|
|
42
|
+
const component = selectComponent<PgMarkdown>(PG_MARKDOWN);
|
|
43
|
+
component.text = '# Hello';
|
|
44
|
+
const {
|
|
45
|
+
$content
|
|
46
|
+
} = component;
|
|
47
|
+
const result = $content.innerHTML.trim(); // '<h1>Hello</h1> '
|
|
48
|
+
await (async () => {
|
|
49
|
+
expect(result).toEqual('<h1>Hello</h1>');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should transform markdown text input', async () => {
|
|
54
|
+
const component = selectComponent<PgMarkdown>(PG_MARKDOWN);
|
|
55
|
+
component.replace = [{
|
|
56
|
+
find: new RegExp('<h1>([^<]*)</h1>', 'g'),
|
|
57
|
+
replace: (m, header) => {
|
|
58
|
+
return `<h1 class="header">${header}</h1>`;
|
|
59
|
+
}
|
|
60
|
+
}]
|
|
61
|
+
component.text = '# Hello';
|
|
62
|
+
const {
|
|
63
|
+
$content
|
|
64
|
+
} = component;
|
|
65
|
+
const result = $content.innerHTML.trim(); // '<h1 class="header">Hello</h1> '
|
|
66
|
+
await (async () => {
|
|
67
|
+
expect(result).toEqual('<h1 class="header">Hello</h1>');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should markdown code block', async () => {
|
|
72
|
+
const component = selectComponent<PgMarkdown>(PG_MARKDOWN);
|
|
73
|
+
component.text = [
|
|
74
|
+
'```',
|
|
75
|
+
'Hello',
|
|
76
|
+
'```'
|
|
77
|
+
].join('\n');
|
|
78
|
+
const {
|
|
79
|
+
$content
|
|
80
|
+
} = component;
|
|
81
|
+
const result = $content.innerHTML.trim();
|
|
82
|
+
await (async () => {
|
|
83
|
+
expect(result).toEqual('<pre><code>Hello\n</code></pre>');
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
});
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
import { Remarkable } from 'remarkable';
|
|
3
|
+
import * as YAML from 'js-yaml';
|
|
4
|
+
import { MarkdownReplace } from './markdownReplace';
|
|
5
|
+
import { http } from '../shared/http';
|
|
6
|
+
|
|
7
|
+
import 'prismjs';
|
|
8
|
+
import 'prismjs/components/prism-markup-templating';
|
|
9
|
+
import 'prismjs/components/prism-css';
|
|
10
|
+
import 'prismjs/components/prism-groovy';
|
|
11
|
+
import 'prismjs/components/prism-javascript';
|
|
12
|
+
import 'prismjs/components/prism-json';
|
|
13
|
+
import 'prismjs/components/prism-jsx';
|
|
14
|
+
import 'prismjs/components/prism-tsx';
|
|
15
|
+
import 'prismjs/components/prism-java';
|
|
16
|
+
import 'prismjs/components/prism-markup';
|
|
17
|
+
import 'prismjs/components/prism-typescript';
|
|
18
|
+
import 'prismjs/components/prism-sass';
|
|
19
|
+
import 'prismjs/components/prism-scss';
|
|
20
|
+
import 'prismjs/components/prism-yaml';
|
|
21
|
+
import 'prismjs/components/prism-php';
|
|
22
|
+
import 'prismjs/components/prism-bash';
|
|
23
|
+
import 'prismjs/components/prism-markdown';
|
|
24
|
+
|
|
25
|
+
const supported = [
|
|
26
|
+
'css',
|
|
27
|
+
'sass',
|
|
28
|
+
'scss',
|
|
29
|
+
'groovy',
|
|
30
|
+
'typescript',
|
|
31
|
+
'javascript',
|
|
32
|
+
'jsx',
|
|
33
|
+
'tsx',
|
|
34
|
+
'java',
|
|
35
|
+
'html',
|
|
36
|
+
'xml',
|
|
37
|
+
'php',
|
|
38
|
+
'bash',
|
|
39
|
+
'json',
|
|
40
|
+
'yaml',
|
|
41
|
+
'markdown'
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function yamlToggle(e) {
|
|
45
|
+
const button = e.target;
|
|
46
|
+
const parent = button.parentNode;
|
|
47
|
+
const ul = parent.querySelector('ul');
|
|
48
|
+
if (ul.className === 'yaml-hide') {
|
|
49
|
+
ul.className = '';
|
|
50
|
+
button.innerText = '-';
|
|
51
|
+
} else {
|
|
52
|
+
ul.className = 'yaml-hide';
|
|
53
|
+
button.innerText = '+';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function yamlTab(e, tab) {
|
|
58
|
+
const button = e.target;
|
|
59
|
+
const parent = button.parentNode;
|
|
60
|
+
const buttons = parent.querySelectorAll('button');
|
|
61
|
+
buttons.forEach(b => b.className = '');
|
|
62
|
+
button.className = 'active';
|
|
63
|
+
const jsonTab = button.parentNode.nextElementSibling;
|
|
64
|
+
const yamlTab = button.parentNode.parentNode.nextElementSibling;
|
|
65
|
+
switch (tab) {
|
|
66
|
+
case 'json':
|
|
67
|
+
jsonTab.className = 'yaml-preview yaml-show';
|
|
68
|
+
yamlTab.className = 'language-yaml yaml-hide';
|
|
69
|
+
break;
|
|
70
|
+
case 'yaml':
|
|
71
|
+
jsonTab.className = 'yaml-preview yaml-hide';
|
|
72
|
+
yamlTab.className = 'language-yaml yaml-show';
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare var Prism: any;
|
|
78
|
+
|
|
79
|
+
import template from './markdown.html';
|
|
80
|
+
import style from './markdown.css';
|
|
81
|
+
|
|
82
|
+
@Component({
|
|
83
|
+
selector: 'pg-markdown',
|
|
84
|
+
style,
|
|
85
|
+
template
|
|
86
|
+
})
|
|
87
|
+
export default class PgMarkdown extends HTMLElement {
|
|
88
|
+
@Prop() file = '';
|
|
89
|
+
@Prop() text = '';
|
|
90
|
+
@Prop() replace: MarkdownReplace[] = [];
|
|
91
|
+
|
|
92
|
+
@Part() $content: HTMLDivElement;
|
|
93
|
+
|
|
94
|
+
modifiers = [
|
|
95
|
+
($content) => {
|
|
96
|
+
// Wire up code blocks
|
|
97
|
+
const blocks = $content.querySelectorAll('code[class*="language-"]');
|
|
98
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
99
|
+
const block = blocks[i] as HTMLElement;
|
|
100
|
+
const pre = block.parentNode as HTMLPreElement;
|
|
101
|
+
pre.classList.add(block.classList.value);
|
|
102
|
+
const language = block.classList.value.replace('language-', '');
|
|
103
|
+
if (supported.includes(language)) {
|
|
104
|
+
block.innerHTML = Prism.highlight(block.innerText, Prism.languages[language], language);
|
|
105
|
+
} else if (language !== '' && language !== 'text') {
|
|
106
|
+
console.error(`Markdown contains a codeblock with "${language}" which is not loaded.`);
|
|
107
|
+
}
|
|
108
|
+
pre.addEventListener('scroll', () => {
|
|
109
|
+
if (pre.scrollLeft === 0) {
|
|
110
|
+
pre.style.removeProperty('--pg-markdown-language-display');
|
|
111
|
+
} else {
|
|
112
|
+
pre.style.setProperty('--pg-markdown-language-display', `none`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
($content) => {
|
|
118
|
+
// Wire up yaml block preview
|
|
119
|
+
const yamlToggles = $content.querySelectorAll('[data-id="yamlToggle"]');
|
|
120
|
+
for (let i = 0; i < yamlToggles.length; i++) {
|
|
121
|
+
yamlToggles[i].addEventListener('click', (e) => {
|
|
122
|
+
yamlToggle(e);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const yamlTabJsons = $content.querySelectorAll('[data-id="yamlTabJson"]');
|
|
126
|
+
for (let i = 0; i < yamlTabJsons.length; i++) {
|
|
127
|
+
yamlTabJsons[i].addEventListener('click', (e) => {
|
|
128
|
+
yamlTab(e, 'json');
|
|
129
|
+
});
|
|
130
|
+
yamlTabJsons[i].click();
|
|
131
|
+
}
|
|
132
|
+
const yamlTabYamls = $content.querySelectorAll('[data-id="yamlTabYaml"]');
|
|
133
|
+
for (let i = 0; i < yamlTabYamls.length; i++) {
|
|
134
|
+
yamlTabYamls[i].addEventListener('click', (e) => {
|
|
135
|
+
yamlTab(e, 'yaml');
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
($content) => {
|
|
140
|
+
const allTabs = $content.querySelectorAll('.tabs');
|
|
141
|
+
for (let i = 0; i < allTabs.length; i++) {
|
|
142
|
+
const tab = allTabs[i];
|
|
143
|
+
const tabItems: any[] = [];
|
|
144
|
+
const tabContentItems: any[] = [];
|
|
145
|
+
const tabs = tab.querySelectorAll('.tab-title a');
|
|
146
|
+
const tabContents = tab.querySelectorAll('.tab-content');
|
|
147
|
+
for (let j = 0; j < tabs.length; j++) {
|
|
148
|
+
tabItems.push(tabs[j]);
|
|
149
|
+
tabContentItems.push(tabContents[j]);
|
|
150
|
+
}
|
|
151
|
+
tabItems.forEach((tabItem, ei) => {
|
|
152
|
+
tabItem.addEventListener('click', (e) => {
|
|
153
|
+
tabItems.forEach((tabItem2, index) => {
|
|
154
|
+
const tabLi = tabItem2.parentNode;
|
|
155
|
+
tabLi.classList.toggle('active', ei === index);
|
|
156
|
+
});
|
|
157
|
+
tabContentItems.forEach((tabContent, index) => {
|
|
158
|
+
tabContent.classList.toggle('tab-hide', ei !== index);
|
|
159
|
+
});
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
] as Function[];
|
|
166
|
+
|
|
167
|
+
modify(callback) {
|
|
168
|
+
this.modifiers.push(callback);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async render(changes) {
|
|
172
|
+
if (changes.file && this.file) {
|
|
173
|
+
this.text = await http.asset(this.file);
|
|
174
|
+
}
|
|
175
|
+
if (changes.text) {
|
|
176
|
+
const md = new Remarkable({
|
|
177
|
+
html: true
|
|
178
|
+
});
|
|
179
|
+
const markdown = await this.loadContent(this.text);
|
|
180
|
+
let html = md.render(markdown);
|
|
181
|
+
this.replace.forEach(o => {
|
|
182
|
+
html = html.replace(o.find, o.replace);
|
|
183
|
+
});
|
|
184
|
+
this.$content.innerHTML = html;
|
|
185
|
+
this.modifiers.forEach(callback => callback(this.$content));
|
|
186
|
+
// Additional Rendering
|
|
187
|
+
this.replace.forEach(o => {
|
|
188
|
+
if (o.render) {
|
|
189
|
+
o.render(this.$content);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
// Dispatch load
|
|
193
|
+
this.dispatchEvent(
|
|
194
|
+
new CustomEvent('load', {
|
|
195
|
+
detail: {
|
|
196
|
+
$content: this.$content
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async loadFile(file) {
|
|
204
|
+
let markdown = await http.asset(file);
|
|
205
|
+
return this.loadContent(markdown);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async loadContent(markdown) {
|
|
209
|
+
// Import - 2 deep
|
|
210
|
+
markdown = await this.processImports(markdown);
|
|
211
|
+
markdown = await this.processImports(markdown);
|
|
212
|
+
// Remove line returns
|
|
213
|
+
markdown = markdown.replace(/\r/g, '');
|
|
214
|
+
// Process Refs - 3 deep
|
|
215
|
+
markdown = await this.processRefs(markdown);
|
|
216
|
+
markdown = await this.processRefs(markdown);
|
|
217
|
+
markdown = await this.processRefs(markdown);
|
|
218
|
+
// YAML Swagger Docs
|
|
219
|
+
markdown = markdown.replace(
|
|
220
|
+
/```yaml\r?\n([\s\S]*?)\r?\n```/g,
|
|
221
|
+
(m, content) => this.processYaml(m, content)
|
|
222
|
+
);
|
|
223
|
+
markdown = this.tabs(markdown);
|
|
224
|
+
return markdown;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Rewrite tabs...
|
|
229
|
+
*
|
|
230
|
+
* @param markdown
|
|
231
|
+
*/
|
|
232
|
+
tabs(markdown: string) {
|
|
233
|
+
var tabset = '';
|
|
234
|
+
return markdown.replace(/tabs ?([^\n]+)?\n([\s\S]+?)\n\/tabs/g, (m, label, tabs) => {
|
|
235
|
+
var i = 0;
|
|
236
|
+
tabset = label ? `<li class="tab-label">${label}</li>` : '';
|
|
237
|
+
var t = tabs.replace(/tab ([^\n]+)\n([\s\S]+?)\n\/tab/g, (m, title, content) => {
|
|
238
|
+
title = title.replace(/^(icon:\w[\w-]*)? ? (.+?) ?(icon:\w.*)?$/, (m, m1, m2, m3) => {
|
|
239
|
+
return `${m1 || ''}<span>${m2 || ''}</span>${m3 || ''}`;
|
|
240
|
+
});
|
|
241
|
+
tabset += [
|
|
242
|
+
i === 0 ? '<li class="tab-title active">' : '<li class="tab-title">',
|
|
243
|
+
'<a href="#" role="tab" aria-selected="true">',
|
|
244
|
+
title,
|
|
245
|
+
'</a>',
|
|
246
|
+
'</li>'
|
|
247
|
+
].join('\n');
|
|
248
|
+
const tabContent = [
|
|
249
|
+
i === 0 ? '<div class="tab-content">' : '<div class="tab-content tab-hide">',
|
|
250
|
+
`\n${content.trim()}\n`,
|
|
251
|
+
'</div>'
|
|
252
|
+
].join('\n');
|
|
253
|
+
i++;
|
|
254
|
+
return tabContent;
|
|
255
|
+
});
|
|
256
|
+
return [
|
|
257
|
+
'<div class="tabs">',
|
|
258
|
+
'<ul class="tabset">',
|
|
259
|
+
tabset,
|
|
260
|
+
`</ul>`,
|
|
261
|
+
t,
|
|
262
|
+
'</div>'
|
|
263
|
+
].join('\n');
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async processImports(markdown) {
|
|
268
|
+
let imports: string[] = [];
|
|
269
|
+
markdown.replace(/import:(.*)/g, (m, m1) => {
|
|
270
|
+
imports.push(m1);
|
|
271
|
+
return m;
|
|
272
|
+
});
|
|
273
|
+
let c: string[] = await Promise.all(imports.map(async (url, i) => await http.asset(url)));
|
|
274
|
+
imports.forEach((url, i) => {
|
|
275
|
+
markdown = markdown.replace(`import:${url}`, c[i]);
|
|
276
|
+
});
|
|
277
|
+
return markdown;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async processRefs(markdown) {
|
|
281
|
+
let imports: any[] = [];
|
|
282
|
+
let unique = 0;
|
|
283
|
+
markdown = markdown.replace(/([ ]*)\$ref: '#([^']+)'/g, (m, spaces, file) => {
|
|
284
|
+
unique++;
|
|
285
|
+
imports.push({ unique, spaces, file });
|
|
286
|
+
console.log(`${m}-${unique}`);
|
|
287
|
+
return `${m}-${unique}`;
|
|
288
|
+
});
|
|
289
|
+
let c: string[] = await Promise.all(
|
|
290
|
+
imports.map(async (obj) => await http.asset(`/content/${obj.file}.yaml`))
|
|
291
|
+
);
|
|
292
|
+
imports.forEach((obj, i) => {
|
|
293
|
+
const lines = c[i].split(/\r?\n/);
|
|
294
|
+
const content = lines.map((line, i) => {
|
|
295
|
+
return `${i === 0 ? '' : obj.spaces}${line}`
|
|
296
|
+
}).join("\n");
|
|
297
|
+
markdown = markdown.replace(`$ref: '#${obj.file}'-${obj.unique}`, content);
|
|
298
|
+
});
|
|
299
|
+
return markdown;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
processYaml(m, content) {
|
|
303
|
+
let error = ''
|
|
304
|
+
try {
|
|
305
|
+
const json = YAML.load(content) as any;
|
|
306
|
+
if (json.type) {
|
|
307
|
+
const html = [] as any[];
|
|
308
|
+
html.push('<div class="yaml">');
|
|
309
|
+
html.push('<div class="yaml-toolbar">');
|
|
310
|
+
html.push(`<button data-id="yamlTabJson" class="yaml-click">JSON Preview</button>`);
|
|
311
|
+
html.push(`<button data-id="yamlTabYaml" class="">YAML</button>`);
|
|
312
|
+
html.push('</div>');
|
|
313
|
+
html.push('<div class="yaml-preview">');
|
|
314
|
+
html.push('<ul>');
|
|
315
|
+
this.processYamlRecursive(html, json);
|
|
316
|
+
html.push('</ul>');
|
|
317
|
+
html.push('</div>');
|
|
318
|
+
html.push('</div>');
|
|
319
|
+
html.push("\r\n\r\n");
|
|
320
|
+
html.push(m);
|
|
321
|
+
return html.join('');
|
|
322
|
+
}
|
|
323
|
+
} catch (e) {
|
|
324
|
+
error = [
|
|
325
|
+
'<div class="alert alert-danger">',
|
|
326
|
+
'<strong>YAML Error:</strong><br/>',
|
|
327
|
+
e.message,
|
|
328
|
+
'</div>',
|
|
329
|
+
''
|
|
330
|
+
].join("") + "\r\n\r\n";
|
|
331
|
+
}
|
|
332
|
+
return `${error}${m}`;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
processYamlRecursive(html, partial, part = '') {
|
|
336
|
+
if (partial.$ref) {
|
|
337
|
+
html.push(`<li><code class="yaml-prop">`);
|
|
338
|
+
html.push(`<code class="yaml-key">${part}</code>: <code class="yaml-error">$ref: '${partial.$ref}'</code> `);
|
|
339
|
+
html.push(`<code class="yaml-example">Too many nested levels</code>`);
|
|
340
|
+
html.push(`</code></li>`);
|
|
341
|
+
} else if (partial.type) {
|
|
342
|
+
switch (partial.type) {
|
|
343
|
+
case 'object':
|
|
344
|
+
const oName = part === '' ? '' : `<code class="yaml-key">${part}</code>: `;
|
|
345
|
+
html.push(`<li><button data-id="yamlToggle">+</button><code>${oName}{</code><ul class="d-none">`);
|
|
346
|
+
for (let part of Object.keys(partial.properties)) {
|
|
347
|
+
this.processYamlRecursive(html, partial.properties[part], part);
|
|
348
|
+
}
|
|
349
|
+
html.push('</ul><code class="yaml-end">}</code></li>');
|
|
350
|
+
break;
|
|
351
|
+
case 'array':
|
|
352
|
+
const aName = part === '' ? '' : `<code class="yaml-key">${part}</code>: `;
|
|
353
|
+
html.push(`<li><button data-id="yamlToggle">+</button><code>${aName}[</code><ul class="d-none">`);
|
|
354
|
+
this.processYamlRecursive(html, partial.items);
|
|
355
|
+
html.push('</ul><code class="yaml-end">]</code></li>');
|
|
356
|
+
break;
|
|
357
|
+
case 'string':
|
|
358
|
+
case 'integer':
|
|
359
|
+
case 'number':
|
|
360
|
+
case 'boolean':
|
|
361
|
+
html.push(`<li><code class="yaml-prop">`);
|
|
362
|
+
html.push(`<code class="yaml-key">${part}</code>`);
|
|
363
|
+
if (partial.auth) {
|
|
364
|
+
html.push(` <svg width="24" height="24" viewBox="0 0 24 24" class="yaml-auth" title="${partial.auth} Access Required"><path d="M12,17C13.1,17 14,16.1 14,15C14,13.89 13.1,13 12,13C10.9,13 10,13.9 10,15C10,16.1 10.9,17 12,17M18,8C19.1,8 20,8.9 20,10V20C20,21.1 19.1,22 18,22H6C4.9,22 4,21.1 4,20V10C4,8.89 4.9,8 6,8H7V6C7,3.24 9.24,1 12,1C14.76,1 17,3.24 17,6V8H18M12,3C10.34,3 9,4.34 9,6V8H15V6C15,4.34 13.66,3 12,3Z" /></svg>`);
|
|
365
|
+
}
|
|
366
|
+
html.push(`: `);
|
|
367
|
+
html.push(`<code class="yaml-type">${partial.type}</code>`);
|
|
368
|
+
|
|
369
|
+
if (partial.example) {
|
|
370
|
+
html.push(` <code class="yaml-example">${partial.example}</code>`);
|
|
371
|
+
}
|
|
372
|
+
html.push(`</code></li>`);
|
|
373
|
+
break;
|
|
374
|
+
default:
|
|
375
|
+
html.push(`<li><code class="yaml-prop"><code class="yaml-key">${part}</code>: <code class="yaml-error">Error: Invalid type "${partial.type}".</code></code></li>`);
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
html.push(`<li><code class="yaml-prop"><code class="yaml-key">${part}</code>: <code class="yaml-error">Error: No type found.</code></code></li>`);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# `<pg-menu-icon>`
|
|
2
|
+
|
|
3
|
+
Visual color picker using the standard Material Design pallet.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import '@pictogrammers/components/pg/menuIcon';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
| Events | Description |
|
|
12
|
+
| ------ | ----------- |
|
|
13
|
+
| `onchange` | `event = { detail: { r, g, b, hex } }` |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import template from './basic.html';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'x-pg-menu-icon-basic',
|
|
7
|
+
template
|
|
8
|
+
})
|
|
9
|
+
export default class XPgMenuIconBasic extends HTMLElement {
|
|
10
|
+
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|