@eui/base 21.0.0-alpha.4 → 21.0.0-alpha.40
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/docs/changelog.html +769 -7568
- package/docs/classes/ConsoleAppender.html +18 -0
- package/docs/classes/EuiEuLanguages.html +18 -0
- package/docs/classes/EuiLazyService.html +18 -0
- package/docs/classes/EuiPagination.html +18 -0
- package/docs/classes/EuiService.html +18 -0
- package/docs/classes/LogAppender.html +18 -0
- package/docs/classes/Logger.html +18 -0
- package/docs/classes/LoggerMock.html +18 -0
- package/docs/classes/UrlAppender.html +18 -0
- package/docs/classes/UxBadgeLegacy.html +18 -0
- package/docs/classes/UxClearErrorFeedbackEvent.html +18 -0
- package/docs/classes/UxErrorGroupOnClickEvent.html +18 -0
- package/docs/classes/UxErrorOutput.html +18 -0
- package/docs/classes/UxLinkLegacy.html +18 -0
- package/docs/classes/UxPublishErrorFeedbackEvent.html +18 -0
- package/docs/classes/UxValidationErrorClass.html +18 -0
- package/docs/dependencies.html +18 -0
- package/docs/index.html +20 -2
- package/docs/interfaces/ApiQueue.html +18 -0
- package/docs/interfaces/ApiQueueItem.html +18 -0
- package/docs/interfaces/AppState.html +18 -0
- package/docs/interfaces/ConnectionStatus.html +18 -0
- package/docs/interfaces/ConsoleAppenderConfig.html +18 -0
- package/docs/interfaces/ConsoleAppenderTypeConfig.html +18 -0
- package/docs/interfaces/CoreState.html +18 -0
- package/docs/interfaces/EnvDynamicConfig.html +18 -0
- package/docs/interfaces/EuiAppHandlersConfig.html +18 -0
- package/docs/interfaces/EuiAppJsonConfig.html +18 -0
- package/docs/interfaces/EuiAuthConfig.html +18 -0
- package/docs/interfaces/EuiConfig.html +18 -0
- package/docs/interfaces/EuiEnvConfig.html +18 -0
- package/docs/interfaces/EuiGlobalConfig.html +18 -0
- package/docs/interfaces/EuiGrowlMessage.html +18 -0
- package/docs/interfaces/EuiLanguage.html +18 -0
- package/docs/interfaces/EuiMenuItem.html +153 -0
- package/docs/interfaces/EuiPaginationConfig.html +18 -0
- package/docs/interfaces/EuiServiceModel.html +18 -0
- package/docs/interfaces/EuiServiceStatus.html +18 -0
- package/docs/interfaces/EuiStoreServiceModel.html +18 -0
- package/docs/interfaces/EuiUserRight.html +18 -0
- package/docs/interfaces/GlobalConfig.html +18 -0
- package/docs/interfaces/HttpErrorHandlerConfig.html +18 -0
- package/docs/interfaces/HttpErrorRouteConfig.html +18 -0
- package/docs/interfaces/I18nConfig.html +18 -0
- package/docs/interfaces/I18nLoaderConfig.html +24 -3
- package/docs/interfaces/I18nResource.html +18 -0
- package/docs/interfaces/I18nServiceConfig.html +18 -0
- package/docs/interfaces/I18nState.html +18 -0
- package/docs/interfaces/LoadedConfigModules.html +18 -0
- package/docs/interfaces/LocaleServiceConfig.html +18 -0
- package/docs/interfaces/LocaleState.html +18 -0
- package/docs/interfaces/LogAppenderConfig.html +18 -0
- package/docs/interfaces/LogAppenderTypeConfig.html +18 -0
- package/docs/interfaces/LogConfig.html +18 -0
- package/docs/interfaces/LogEvent.html +18 -0
- package/docs/interfaces/LogPosition.html +18 -0
- package/docs/interfaces/ModuleConfig.html +18 -0
- package/docs/interfaces/ModulesConfig.html +18 -0
- package/docs/interfaces/NotificationsState.html +18 -0
- package/docs/interfaces/UrlAppenderConfig.html +18 -0
- package/docs/interfaces/UrlAppenderTypeConfig.html +18 -0
- package/docs/interfaces/UrlLogEvent.html +18 -0
- package/docs/interfaces/UserConfig.html +18 -0
- package/docs/interfaces/UserDetails.html +18 -0
- package/docs/interfaces/UserPreferences.html +18 -0
- package/docs/interfaces/UserState.html +18 -0
- package/docs/interfaces/UxErrorFeedback.html +18 -0
- package/docs/interfaces/UxErrorFollowMap.html +18 -0
- package/docs/interfaces/UxErrorInfo.html +18 -0
- package/docs/interfaces/UxErrorMessage.html +18 -0
- package/docs/interfaces/UxFormValidationError.html +18 -0
- package/docs/interfaces/UxHttpErrorInfo.html +18 -0
- package/docs/interfaces/UxHttpErrorResponse.html +18 -0
- package/docs/interfaces/UxModalLegacy.html +18 -0
- package/docs/interfaces/UxValidationErrorAttribute.html +18 -0
- package/docs/interfaces/UxValidationErrorFeedback.html +18 -0
- package/docs/interfaces/UxValidationErrorI18nMessage.html +18 -0
- package/docs/interfaces/VersionsConfig.html +18 -0
- package/docs/interfaces/XHRConfig.html +18 -0
- package/docs/js/libs/bootstrap-native.js +1 -1
- package/docs/js/libs/jszip.min.js +13 -0
- package/docs/js/libs/svg-pan-zoom.min.js +3 -3
- package/docs/js/libs/tablesort.min.js +3 -3
- package/docs/js/libs/tablesort.number.min.js +3 -3
- package/docs/js/menu-wc.js +16 -20
- package/docs/js/menu-wc_es5.js +1 -1
- package/docs/js/routes/routes_index.js +1 -0
- package/docs/js/routes.js +15 -8
- package/docs/js/search/search_index.js +2 -2
- package/docs/license.html +20 -2
- package/docs/miscellaneous/enumerations.html +18 -0
- package/docs/miscellaneous/functions.html +18 -0
- package/docs/miscellaneous/typealiases.html +18 -0
- package/docs/miscellaneous/variables.html +44 -0
- package/docs/modules.html +18 -0
- package/docs/overview.html +28 -0
- package/docs/properties.html +19 -1
- package/docs/routes.html +204 -0
- package/docs/template-playground/default-templates.json +192 -0
- package/docs/template-playground/hbs-render.service.ts +212 -0
- package/docs/template-playground/main.ts +9 -0
- package/docs/template-playground/template-editor.service.ts +173 -0
- package/docs/template-playground/template-playground.component.ts +614 -0
- package/docs/template-playground/template-playground.module.ts +29 -0
- package/docs/template-playground/zip-export.service.ts +86 -0
- package/docs/template-playground-app/app.js +1389 -0
- package/docs/template-playground-app/index.html +462 -0
- package/package.json +35 -36
- package/{index.d.ts → types/eui-base.d.ts} +4 -1
- package/types/eui-base.d.ts.map +1 -0
- package/index.d.ts.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"templates": [
|
|
3
|
+
{
|
|
4
|
+
"name": "page.hbs",
|
|
5
|
+
"path": "page.hbs",
|
|
6
|
+
"description": "Main page template - the base layout for all documentation pages",
|
|
7
|
+
"type": "hbs",
|
|
8
|
+
"category": "core",
|
|
9
|
+
"content": "<!-- This will be populated with the actual page.hbs content -->"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "component.hbs",
|
|
13
|
+
"path": "partials/component.hbs",
|
|
14
|
+
"description": "Component detail template - displays Angular component documentation",
|
|
15
|
+
"type": "hbs",
|
|
16
|
+
"category": "partials",
|
|
17
|
+
"content": "<!-- This will be populated with the actual component.hbs content -->"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "module.hbs",
|
|
21
|
+
"path": "partials/module.hbs",
|
|
22
|
+
"description": "Module detail template - displays Angular module documentation",
|
|
23
|
+
"type": "hbs",
|
|
24
|
+
"category": "partials",
|
|
25
|
+
"content": "<!-- This will be populated with the actual module.hbs content -->"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "overview.hbs",
|
|
29
|
+
"path": "partials/overview.hbs",
|
|
30
|
+
"description": "Overview template - displays the main overview page",
|
|
31
|
+
"type": "hbs",
|
|
32
|
+
"category": "partials",
|
|
33
|
+
"content": "<!-- This will be populated with the actual overview.hbs content -->"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "class.hbs",
|
|
37
|
+
"path": "partials/class.hbs",
|
|
38
|
+
"description": "Class detail template - displays TypeScript class documentation",
|
|
39
|
+
"type": "hbs",
|
|
40
|
+
"category": "partials",
|
|
41
|
+
"content": "<!-- This will be populated with the actual class.hbs content -->"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "interface.hbs",
|
|
45
|
+
"path": "partials/interface.hbs",
|
|
46
|
+
"description": "Interface detail template - displays TypeScript interface documentation",
|
|
47
|
+
"type": "hbs",
|
|
48
|
+
"category": "partials",
|
|
49
|
+
"content": "<!-- This will be populated with the actual interface.hbs content -->"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "injectable.hbs",
|
|
53
|
+
"path": "partials/injectable.hbs",
|
|
54
|
+
"description": "Injectable service template - displays Angular service documentation",
|
|
55
|
+
"type": "hbs",
|
|
56
|
+
"category": "partials",
|
|
57
|
+
"content": "<!-- This will be populated with the actual injectable.hbs content -->"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "directive.hbs",
|
|
61
|
+
"path": "partials/directive.hbs",
|
|
62
|
+
"description": "Directive template - displays Angular directive documentation",
|
|
63
|
+
"type": "hbs",
|
|
64
|
+
"category": "partials",
|
|
65
|
+
"content": "<!-- This will be populated with the actual directive.hbs content -->"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "pipe.hbs",
|
|
69
|
+
"path": "partials/pipe.hbs",
|
|
70
|
+
"description": "Pipe template - displays Angular pipe documentation",
|
|
71
|
+
"type": "hbs",
|
|
72
|
+
"category": "partials",
|
|
73
|
+
"content": "<!-- This will be populated with the actual pipe.hbs content -->"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "guard.hbs",
|
|
77
|
+
"path": "partials/guard.hbs",
|
|
78
|
+
"description": "Guard template - displays Angular guard documentation",
|
|
79
|
+
"type": "hbs",
|
|
80
|
+
"category": "partials",
|
|
81
|
+
"content": "<!-- This will be populated with the actual guard.hbs content -->"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "interceptor.hbs",
|
|
85
|
+
"path": "partials/interceptor.hbs",
|
|
86
|
+
"description": "Interceptor template - displays Angular interceptor documentation",
|
|
87
|
+
"type": "hbs",
|
|
88
|
+
"category": "partials",
|
|
89
|
+
"content": "<!-- This will be populated with the actual interceptor.hbs content -->"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "menu.hbs",
|
|
93
|
+
"path": "partials/menu.hbs",
|
|
94
|
+
"description": "Navigation menu template - displays the sidebar navigation",
|
|
95
|
+
"type": "hbs",
|
|
96
|
+
"category": "partials",
|
|
97
|
+
"content": "<!-- This will be populated with the actual menu.hbs content -->"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"styles": [
|
|
101
|
+
{
|
|
102
|
+
"name": "compodoc.css",
|
|
103
|
+
"path": "styles/compodoc.css",
|
|
104
|
+
"description": "Main stylesheet - contains the core styles for Compodoc",
|
|
105
|
+
"type": "css",
|
|
106
|
+
"category": "core",
|
|
107
|
+
"content": "/* This will be populated with the actual compodoc.css content */"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "bootstrap.min.css",
|
|
111
|
+
"path": "styles/bootstrap.min.css",
|
|
112
|
+
"description": "Bootstrap CSS framework - provides base styling components",
|
|
113
|
+
"type": "css",
|
|
114
|
+
"category": "vendor",
|
|
115
|
+
"content": "/* This will be populated with the actual bootstrap.min.css content */"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "dark.css",
|
|
119
|
+
"path": "styles/dark.css",
|
|
120
|
+
"description": "Dark mode styles - contains dark theme styling",
|
|
121
|
+
"type": "css",
|
|
122
|
+
"category": "theme",
|
|
123
|
+
"content": "/* This will be populated with the actual dark.css content */"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "gitbook.css",
|
|
127
|
+
"path": "styles/gitbook.css",
|
|
128
|
+
"description": "GitBook theme styles - alternative theme styling",
|
|
129
|
+
"type": "css",
|
|
130
|
+
"category": "theme",
|
|
131
|
+
"content": "/* This will be populated with the actual gitbook.css content */"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "material.css",
|
|
135
|
+
"path": "styles/material.css",
|
|
136
|
+
"description": "Material design theme styles - Material theme styling",
|
|
137
|
+
"type": "css",
|
|
138
|
+
"category": "theme",
|
|
139
|
+
"content": "/* This will be populated with the actual material.css content */"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"scripts": [
|
|
143
|
+
{
|
|
144
|
+
"name": "compodoc.js",
|
|
145
|
+
"path": "js/compodoc.js",
|
|
146
|
+
"description": "Main JavaScript file - contains core Compodoc functionality",
|
|
147
|
+
"type": "js",
|
|
148
|
+
"category": "core",
|
|
149
|
+
"content": "// This will be populated with the actual compodoc.js content"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "menu.js",
|
|
153
|
+
"path": "js/menu.js",
|
|
154
|
+
"description": "Menu functionality - handles navigation menu interactions",
|
|
155
|
+
"type": "js",
|
|
156
|
+
"category": "core",
|
|
157
|
+
"content": "// This will be populated with the actual menu.js content"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"name": "tabs.js",
|
|
161
|
+
"path": "js/tabs.js",
|
|
162
|
+
"description": "Tab functionality - handles tab navigation in documentation pages",
|
|
163
|
+
"type": "js",
|
|
164
|
+
"category": "core",
|
|
165
|
+
"content": "// This will be populated with the actual tabs.js content"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "search.js",
|
|
169
|
+
"path": "js/search/search.js",
|
|
170
|
+
"description": "Search functionality - handles documentation search features",
|
|
171
|
+
"type": "js",
|
|
172
|
+
"category": "feature",
|
|
173
|
+
"content": "// This will be populated with the actual search.js content"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "sourceCode.js",
|
|
177
|
+
"path": "js/sourceCode.js",
|
|
178
|
+
"description": "Source code display - handles syntax highlighting and code display",
|
|
179
|
+
"type": "js",
|
|
180
|
+
"category": "feature",
|
|
181
|
+
"content": "// This will be populated with the actual sourceCode.js content"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "lazy-load-graphs.js",
|
|
185
|
+
"path": "js/lazy-load-graphs.js",
|
|
186
|
+
"description": "Graph loading - handles lazy loading of dependency graphs",
|
|
187
|
+
"type": "js",
|
|
188
|
+
"category": "feature",
|
|
189
|
+
"content": "// This will be populated with the actual lazy-load-graphs.js content"
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare const Handlebars: any;
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root'
|
|
7
|
+
})
|
|
8
|
+
export class HbsRenderService {
|
|
9
|
+
private handlebarsInstance: any;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
this.initializeHandlebars();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private initializeHandlebars() {
|
|
16
|
+
// Create a new Handlebars instance for the playground
|
|
17
|
+
this.handlebarsInstance = Handlebars.create();
|
|
18
|
+
|
|
19
|
+
// Register common helpers used in Compodoc templates
|
|
20
|
+
this.registerHelpers();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private registerHelpers() {
|
|
24
|
+
// Register the 'compare' helper
|
|
25
|
+
this.handlebarsInstance.registerHelper('compare', (left: any, operator: string, right: any, options: any) => {
|
|
26
|
+
let result;
|
|
27
|
+
switch (operator) {
|
|
28
|
+
case '===':
|
|
29
|
+
result = left === right;
|
|
30
|
+
break;
|
|
31
|
+
case '!==':
|
|
32
|
+
result = left !== right;
|
|
33
|
+
break;
|
|
34
|
+
case '<':
|
|
35
|
+
result = left < right;
|
|
36
|
+
break;
|
|
37
|
+
case '>':
|
|
38
|
+
result = left > right;
|
|
39
|
+
break;
|
|
40
|
+
case '<=':
|
|
41
|
+
result = left <= right;
|
|
42
|
+
break;
|
|
43
|
+
case '>=':
|
|
44
|
+
result = left >= right;
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
result = false;
|
|
48
|
+
}
|
|
49
|
+
return result ? options.fn(this) : options.inverse(this);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Register the 'unless' helper
|
|
53
|
+
this.handlebarsInstance.registerHelper('unless', (conditional: any, options: any) => {
|
|
54
|
+
return !conditional ? options.fn(this) : options.inverse(this);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Register the 'each' helper with index
|
|
58
|
+
this.handlebarsInstance.registerHelper('each', (context: any, options: any) => {
|
|
59
|
+
let ret = '';
|
|
60
|
+
for (let i = 0; i < context.length; i++) {
|
|
61
|
+
ret += options.fn(context[i], { data: { index: i } });
|
|
62
|
+
}
|
|
63
|
+
return ret;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Register the 'if' helper
|
|
67
|
+
this.handlebarsInstance.registerHelper('if', (conditional: any, options: any) => {
|
|
68
|
+
return conditional ? options.fn(this) : options.inverse(this);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Register the 'relativeURL' helper
|
|
72
|
+
this.handlebarsInstance.registerHelper('relativeURL', (depth: number, page?: string) => {
|
|
73
|
+
let url = '';
|
|
74
|
+
for (let i = 0; i < depth; i++) {
|
|
75
|
+
url += '../';
|
|
76
|
+
}
|
|
77
|
+
return url + (page || '');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Register the 't' helper for translations
|
|
81
|
+
this.handlebarsInstance.registerHelper('t', (key: string) => {
|
|
82
|
+
// Simple translation mapping for preview
|
|
83
|
+
const translations: { [key: string]: string } = {
|
|
84
|
+
'info': 'Information',
|
|
85
|
+
'source': 'Source',
|
|
86
|
+
'example': 'Example',
|
|
87
|
+
'template': 'Template',
|
|
88
|
+
'styles': 'Styles',
|
|
89
|
+
'component': 'Component',
|
|
90
|
+
'module': 'Module',
|
|
91
|
+
'overview': 'Overview',
|
|
92
|
+
'components': 'Components',
|
|
93
|
+
'modules': 'Modules',
|
|
94
|
+
'file': 'File',
|
|
95
|
+
'description': 'Description',
|
|
96
|
+
'selector': 'Selector',
|
|
97
|
+
'properties': 'Properties',
|
|
98
|
+
'methods': 'Methods',
|
|
99
|
+
'inputs': 'Inputs',
|
|
100
|
+
'outputs': 'Outputs'
|
|
101
|
+
};
|
|
102
|
+
return translations[key] || key;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Register the 'orLength' helper
|
|
106
|
+
this.handlebarsInstance.registerHelper('orLength', (...args: any[]) => {
|
|
107
|
+
const options = args[args.length - 1];
|
|
108
|
+
const values = args.slice(0, -1);
|
|
109
|
+
|
|
110
|
+
for (const value of values) {
|
|
111
|
+
if (value && value.length && value.length > 0) {
|
|
112
|
+
return options.fn(this);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return options.inverse(this);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Register the 'isTabEnabled' helper
|
|
119
|
+
this.handlebarsInstance.registerHelper('isTabEnabled', (navTabs: any[], tabId: string, options: any) => {
|
|
120
|
+
const tab = navTabs && navTabs.find((t: any) => t.id === tabId);
|
|
121
|
+
return tab ? options.fn(this) : options.inverse(this);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Register the 'isInitialTab' helper
|
|
125
|
+
this.handlebarsInstance.registerHelper('isInitialTab', (navTabs: any[], tabId: string, options: any) => {
|
|
126
|
+
const isInitial = navTabs && navTabs.length > 0 && navTabs[0].id === tabId;
|
|
127
|
+
return isInitial ? options.fn(this) : options.inverse(this);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
renderTemplate(templateContent: string, data: any): string {
|
|
132
|
+
try {
|
|
133
|
+
// Create a complete HTML document for preview
|
|
134
|
+
const template = this.handlebarsInstance.compile(templateContent);
|
|
135
|
+
const rendered = template({ data });
|
|
136
|
+
|
|
137
|
+
// Wrap in a basic HTML structure for preview
|
|
138
|
+
return `
|
|
139
|
+
<!DOCTYPE html>
|
|
140
|
+
<html>
|
|
141
|
+
<head>
|
|
142
|
+
<meta charset="utf-8">
|
|
143
|
+
<title>Template Preview</title>
|
|
144
|
+
<style>
|
|
145
|
+
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
146
|
+
.preview-wrapper { border: 1px solid #ddd; padding: 20px; }
|
|
147
|
+
.preview-notice { background: #f0f8ff; padding: 10px; margin-bottom: 20px; border-left: 4px solid #007bff; }
|
|
148
|
+
</style>
|
|
149
|
+
</head>
|
|
150
|
+
<body>
|
|
151
|
+
<div class="preview-notice">
|
|
152
|
+
<strong>Template Preview:</strong> This is a live preview of your template with mock data.
|
|
153
|
+
</div>
|
|
154
|
+
<div class="preview-wrapper">
|
|
155
|
+
${rendered}
|
|
156
|
+
</div>
|
|
157
|
+
</body>
|
|
158
|
+
</html>
|
|
159
|
+
`;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return `
|
|
162
|
+
<!DOCTYPE html>
|
|
163
|
+
<html>
|
|
164
|
+
<head>
|
|
165
|
+
<meta charset="utf-8">
|
|
166
|
+
<title>Template Preview - Error</title>
|
|
167
|
+
<style>
|
|
168
|
+
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
169
|
+
.error { color: red; background: #fff5f5; padding: 20px; border: 1px solid #red; }
|
|
170
|
+
</style>
|
|
171
|
+
</head>
|
|
172
|
+
<body>
|
|
173
|
+
<div class="error">
|
|
174
|
+
<h3>Template Error</h3>
|
|
175
|
+
<p><strong>Error:</strong> ${error.message}</p>
|
|
176
|
+
<p>Please check your template syntax and try again.</p>
|
|
177
|
+
</div>
|
|
178
|
+
</body>
|
|
179
|
+
</html>
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
getMockData(): any {
|
|
185
|
+
return {
|
|
186
|
+
documentationMainName: 'Sample Documentation',
|
|
187
|
+
depth: 0,
|
|
188
|
+
context: 'component',
|
|
189
|
+
components: [
|
|
190
|
+
{
|
|
191
|
+
name: 'SampleComponent',
|
|
192
|
+
selector: 'app-sample',
|
|
193
|
+
file: 'src/app/sample/sample.component.ts',
|
|
194
|
+
description: 'A sample component for demonstration',
|
|
195
|
+
properties: [
|
|
196
|
+
{ name: 'title', type: 'string', description: 'The component title' },
|
|
197
|
+
{ name: 'isVisible', type: 'boolean', description: 'Whether the component is visible' }
|
|
198
|
+
],
|
|
199
|
+
methods: [
|
|
200
|
+
{ name: 'ngOnInit', description: 'Lifecycle hook', signature: 'ngOnInit(): void' },
|
|
201
|
+
{ name: 'onClick', description: 'Handle click events', signature: 'onClick(event: MouseEvent): void' }
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
navTabs: [
|
|
206
|
+
{ id: 'info', label: 'Info', href: '#info' },
|
|
207
|
+
{ id: 'source', label: 'Source', href: '#source' },
|
|
208
|
+
{ id: 'example', label: 'Example', href: '#example' }
|
|
209
|
+
]
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
2
|
+
import { TemplatePlaygroundModule } from './template-playground.module';
|
|
3
|
+
|
|
4
|
+
// Bootstrap the Angular application when the DOM is ready
|
|
5
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
6
|
+
platformBrowserDynamic()
|
|
7
|
+
.bootstrapModule(TemplatePlaygroundModule)
|
|
8
|
+
.catch(err => console.error('Error starting template playground:', err));
|
|
9
|
+
});
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare const monaco: any;
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root'
|
|
7
|
+
})
|
|
8
|
+
export class TemplateEditorService {
|
|
9
|
+
private editor: any;
|
|
10
|
+
private onChangeCallback: ((value: string) => void) | null = null;
|
|
11
|
+
|
|
12
|
+
initializeEditor(container: HTMLElement) {
|
|
13
|
+
// Initialize Monaco Editor
|
|
14
|
+
this.editor = monaco.editor.create(container, {
|
|
15
|
+
value: '',
|
|
16
|
+
language: 'html',
|
|
17
|
+
theme: 'vs-dark',
|
|
18
|
+
automaticLayout: true,
|
|
19
|
+
minimap: {
|
|
20
|
+
enabled: true
|
|
21
|
+
},
|
|
22
|
+
scrollBeyondLastLine: false,
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
wordWrap: 'on',
|
|
25
|
+
lineNumbers: 'on',
|
|
26
|
+
roundedSelection: false,
|
|
27
|
+
scrollbar: {
|
|
28
|
+
horizontal: 'visible',
|
|
29
|
+
vertical: 'visible'
|
|
30
|
+
},
|
|
31
|
+
overviewRulerLanes: 2,
|
|
32
|
+
quickSuggestions: {
|
|
33
|
+
other: true,
|
|
34
|
+
comments: true,
|
|
35
|
+
strings: true
|
|
36
|
+
},
|
|
37
|
+
parameterHints: {
|
|
38
|
+
enabled: true
|
|
39
|
+
},
|
|
40
|
+
autoClosingBrackets: 'always',
|
|
41
|
+
autoClosingQuotes: 'always',
|
|
42
|
+
suggestOnTriggerCharacters: true,
|
|
43
|
+
acceptSuggestionOnEnter: 'on',
|
|
44
|
+
tabCompletion: 'on',
|
|
45
|
+
wordBasedSuggestions: false
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Set up change listener
|
|
49
|
+
this.editor.onDidChangeModelContent(() => {
|
|
50
|
+
if (this.onChangeCallback) {
|
|
51
|
+
this.onChangeCallback(this.editor.getValue());
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Register custom language definitions
|
|
56
|
+
this.registerHandlebarsLanguage();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
setEditorContent(content: string, fileType: string) {
|
|
60
|
+
if (this.editor) {
|
|
61
|
+
const language = this.getLanguageFromFileType(fileType);
|
|
62
|
+
const model = monaco.editor.createModel(content, language);
|
|
63
|
+
this.editor.setModel(model);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
setOnChangeCallback(callback: (value: string) => void) {
|
|
68
|
+
this.onChangeCallback = callback;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private getLanguageFromFileType(fileType: string): string {
|
|
72
|
+
switch (fileType) {
|
|
73
|
+
case 'hbs':
|
|
74
|
+
return 'handlebars';
|
|
75
|
+
case 'css':
|
|
76
|
+
case 'scss':
|
|
77
|
+
return 'css';
|
|
78
|
+
case 'js':
|
|
79
|
+
return 'javascript';
|
|
80
|
+
case 'ts':
|
|
81
|
+
return 'typescript';
|
|
82
|
+
default:
|
|
83
|
+
return 'html';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private registerHandlebarsLanguage() {
|
|
88
|
+
// Register Handlebars language for Monaco Editor
|
|
89
|
+
if (monaco.languages.getLanguages().find((lang: any) => lang.id === 'handlebars')) {
|
|
90
|
+
return; // Already registered
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
monaco.languages.register({ id: 'handlebars' });
|
|
94
|
+
|
|
95
|
+
monaco.languages.setMonarchTokensProvider('handlebars', {
|
|
96
|
+
tokenizer: {
|
|
97
|
+
root: [
|
|
98
|
+
[/\{\{\{/, { token: 'keyword', next: '@handlebars_unescaped' }],
|
|
99
|
+
[/\{\{/, { token: 'keyword', next: '@handlebars' }],
|
|
100
|
+
[/<!DOCTYPE/, 'metatag', '@doctype'],
|
|
101
|
+
[/<!--/, 'comment', '@comment'],
|
|
102
|
+
[/(<)(\w+)/, ['delimiter', { token: 'tag', next: '@tag' }]],
|
|
103
|
+
[/(<\/)(\w+)/, ['delimiter', { token: 'tag', next: '@tag' }]],
|
|
104
|
+
[/</, 'delimiter'],
|
|
105
|
+
[/[^<]+/]
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
handlebars_unescaped: [
|
|
109
|
+
[/\}\}\}/, { token: 'keyword', next: '@pop' }],
|
|
110
|
+
[/[^}]+/, 'variable']
|
|
111
|
+
],
|
|
112
|
+
|
|
113
|
+
handlebars: [
|
|
114
|
+
[/\}\}/, { token: 'keyword', next: '@pop' }],
|
|
115
|
+
[/#if|#unless|#each|#with|\/if|\/unless|\/each|\/with/, 'keyword'],
|
|
116
|
+
[/[a-zA-Z_][\w]*/, 'variable'],
|
|
117
|
+
[/[^}]+/, 'variable']
|
|
118
|
+
],
|
|
119
|
+
|
|
120
|
+
comment: [
|
|
121
|
+
[/-->/, 'comment', '@pop'],
|
|
122
|
+
[/[^-]+/, 'comment'],
|
|
123
|
+
[/./, 'comment']
|
|
124
|
+
],
|
|
125
|
+
|
|
126
|
+
doctype: [
|
|
127
|
+
[/[^>]+/, 'metatag.content'],
|
|
128
|
+
[/>/, 'metatag', '@pop']
|
|
129
|
+
],
|
|
130
|
+
|
|
131
|
+
tag: [
|
|
132
|
+
[/[ \t\r\n]+/, 'white'],
|
|
133
|
+
[/(\w+)(\s*=\s*)("([^"]*)")/, ['attribute.name', 'delimiter', 'attribute.value', 'attribute.value']],
|
|
134
|
+
[/(\w+)(\s*=\s*)('([^']*)')/, ['attribute.name', 'delimiter', 'attribute.value', 'attribute.value']],
|
|
135
|
+
[/\w+/, 'attribute.name'],
|
|
136
|
+
[/>/, 'delimiter', '@pop']
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
monaco.languages.setLanguageConfiguration('handlebars', {
|
|
142
|
+
comments: {
|
|
143
|
+
blockComment: ['<!--', '-->']
|
|
144
|
+
},
|
|
145
|
+
brackets: [
|
|
146
|
+
['<', '>'],
|
|
147
|
+
['{{', '}}'],
|
|
148
|
+
['{{{', '}}}']
|
|
149
|
+
],
|
|
150
|
+
autoClosingPairs: [
|
|
151
|
+
{ open: '<', close: '>' },
|
|
152
|
+
{ open: '{{', close: '}}' },
|
|
153
|
+
{ open: '{{{', close: '}}}' },
|
|
154
|
+
{ open: '"', close: '"' },
|
|
155
|
+
{ open: "'", close: "'" }
|
|
156
|
+
],
|
|
157
|
+
surroundingPairs: [
|
|
158
|
+
{ open: '<', close: '>' },
|
|
159
|
+
{ open: '{{', close: '}}' },
|
|
160
|
+
{ open: '{{{', close: '}}}' },
|
|
161
|
+
{ open: '"', close: '"' },
|
|
162
|
+
{ open: "'", close: "'" }
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
destroy() {
|
|
168
|
+
if (this.editor) {
|
|
169
|
+
this.editor.dispose();
|
|
170
|
+
this.editor = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|