nxt-highlightjs 19.0.5
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/README.md +64 -0
- package/extras/code-file-location.d.ts +12 -0
- package/extras/code-from-url.d.ts +10 -0
- package/extras/code-loader.d.ts +22 -0
- package/extras/gist.d.ts +20 -0
- package/extras/gist.model.d.ts +95 -0
- package/extras/highlight-extras.module.d.ts +8 -0
- package/extras/index.d.ts +5 -0
- package/extras/public_api.d.ts +5 -0
- package/fesm2022/nxt-highlightjs-extras.mjs +203 -0
- package/fesm2022/nxt-highlightjs-extras.mjs.map +1 -0
- package/fesm2022/nxt-highlightjs-line-numbers.mjs +311 -0
- package/fesm2022/nxt-highlightjs-line-numbers.mjs.map +1 -0
- package/fesm2022/nxt-highlightjs.mjs +389 -0
- package/fesm2022/nxt-highlightjs.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/highlight-auto.d.ts +27 -0
- package/lib/highlight-base.d.ts +27 -0
- package/lib/highlight.d.ts +30 -0
- package/lib/highlight.loader.d.ts +28 -0
- package/lib/highlight.model.d.ts +22 -0
- package/lib/highlight.module.d.ts +8 -0
- package/lib/highlight.service.d.ts +64 -0
- package/lib/loader-errors.d.ts +7 -0
- package/lib/trusted-types.d.ts +1 -0
- package/line-numbers/index.d.ts +5 -0
- package/line-numbers/line-numbers-lib.d.ts +6 -0
- package/line-numbers/line-numbers.d.ts +12 -0
- package/line-numbers/public_api.d.ts +2 -0
- package/package.json +52 -0
- package/public-api.d.ts +7 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, makeEnvironmentProviders, inject, PendingTasks, Injectable, ElementRef, effect, SecurityContext, Directive, input, signal, booleanAttribute, output, NgModule } from '@angular/core';
|
|
3
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { from } from 'rxjs';
|
|
6
|
+
import { DOCUMENT } from '@angular/common';
|
|
7
|
+
|
|
8
|
+
const NXT_HIGHLIGHT_OPTIONS = new InjectionToken('NXT_HIGHLIGHT_OPTIONS');
|
|
9
|
+
function provideHighlightOptions(options) {
|
|
10
|
+
return makeEnvironmentProviders([
|
|
11
|
+
{
|
|
12
|
+
provide: NXT_HIGHLIGHT_OPTIONS,
|
|
13
|
+
useValue: options
|
|
14
|
+
}
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var LoaderErrors;
|
|
19
|
+
(function (LoaderErrors) {
|
|
20
|
+
LoaderErrors["FULL_WITH_CORE_LIBRARY_IMPORTS"] = "The full library and the core library were imported, only one of them should be imported!";
|
|
21
|
+
LoaderErrors["FULL_WITH_LANGUAGE_IMPORTS"] = "The highlighting languages were imported they are not needed!";
|
|
22
|
+
LoaderErrors["CORE_WITHOUT_LANGUAGE_IMPORTS"] = "The highlighting languages were not imported!";
|
|
23
|
+
LoaderErrors["LANGUAGE_WITHOUT_CORE_IMPORTS"] = "The core library was not imported!";
|
|
24
|
+
LoaderErrors["NO_FULL_AND_NO_CORE_IMPORTS"] = "Highlight.js library was not imported!";
|
|
25
|
+
})(LoaderErrors || (LoaderErrors = {}));
|
|
26
|
+
|
|
27
|
+
class HighlightLoader {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.document = inject(DOCUMENT);
|
|
30
|
+
this.options = inject(NXT_HIGHLIGHT_OPTIONS, { optional: true });
|
|
31
|
+
this.pendingTasks = inject(PendingTasks);
|
|
32
|
+
this.ready = this.pendingTasks.run(() => this.loadLibrary()
|
|
33
|
+
.then(async (hljs) => {
|
|
34
|
+
if (this.options?.lineNumbersLoader) {
|
|
35
|
+
const plugin = await this.options.lineNumbersLoader();
|
|
36
|
+
hljs.lineNumbersBlock = plugin.activateLineNumbers(this.document);
|
|
37
|
+
}
|
|
38
|
+
if (this.options?.highlightOptions)
|
|
39
|
+
hljs.configure(this.options.highlightOptions);
|
|
40
|
+
return hljs;
|
|
41
|
+
}));
|
|
42
|
+
if (this.options?.themePath) {
|
|
43
|
+
this.loadTheme(this.options.themePath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Lazy-Load highlight.js library
|
|
48
|
+
*/
|
|
49
|
+
async loadLibrary() {
|
|
50
|
+
if (this.options) {
|
|
51
|
+
if (this.options.fullLibraryLoader && this.options.coreLibraryLoader) {
|
|
52
|
+
throw new Error(LoaderErrors.FULL_WITH_CORE_LIBRARY_IMPORTS);
|
|
53
|
+
}
|
|
54
|
+
if (this.options.fullLibraryLoader && this.options.languages) {
|
|
55
|
+
throw new Error(LoaderErrors.FULL_WITH_LANGUAGE_IMPORTS);
|
|
56
|
+
}
|
|
57
|
+
if (this.options.coreLibraryLoader && !this.options.languages) {
|
|
58
|
+
throw new Error(LoaderErrors.CORE_WITHOUT_LANGUAGE_IMPORTS);
|
|
59
|
+
}
|
|
60
|
+
if (!this.options.coreLibraryLoader && this.options.languages) {
|
|
61
|
+
throw new Error(LoaderErrors.LANGUAGE_WITHOUT_CORE_IMPORTS);
|
|
62
|
+
}
|
|
63
|
+
if (this.options.fullLibraryLoader) {
|
|
64
|
+
return this.options.fullLibraryLoader();
|
|
65
|
+
}
|
|
66
|
+
if (this.options.coreLibraryLoader && this.options.languages && Object.keys(this.options.languages).length) {
|
|
67
|
+
return this.options.coreLibraryLoader().then(hljs => this.loadLanguages(hljs));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw new Error(LoaderErrors.NO_FULL_AND_NO_CORE_IMPORTS);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Lazy-load highlight.js languages
|
|
74
|
+
*/
|
|
75
|
+
async loadLanguages(hljs) {
|
|
76
|
+
await Promise.all(Object.entries(this.options?.languages || {})
|
|
77
|
+
.map(([langName, langLoader]) => langLoader().then(langFunc => hljs.registerLanguage(langName, langFunc))));
|
|
78
|
+
return hljs;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Reload theme styles
|
|
82
|
+
*/
|
|
83
|
+
setTheme(path) {
|
|
84
|
+
if (this.themeLinkElement) {
|
|
85
|
+
this.themeLinkElement.href = path;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.loadTheme(path);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Load theme
|
|
93
|
+
*/
|
|
94
|
+
loadTheme(path) {
|
|
95
|
+
this.themeLinkElement = this.document.createElement('link');
|
|
96
|
+
this.themeLinkElement.href = path;
|
|
97
|
+
this.themeLinkElement.type = 'text/css';
|
|
98
|
+
this.themeLinkElement.rel = 'stylesheet';
|
|
99
|
+
this.themeLinkElement.media = 'screen,print';
|
|
100
|
+
this.document.head.appendChild(this.themeLinkElement);
|
|
101
|
+
}
|
|
102
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightLoader, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
103
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightLoader, providedIn: 'root' }); }
|
|
104
|
+
}
|
|
105
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightLoader, decorators: [{
|
|
106
|
+
type: Injectable,
|
|
107
|
+
args: [{
|
|
108
|
+
providedIn: 'root'
|
|
109
|
+
}]
|
|
110
|
+
}], ctorParameters: () => [] });
|
|
111
|
+
|
|
112
|
+
class HighlightJS {
|
|
113
|
+
constructor() {
|
|
114
|
+
this.loader = inject(HighlightLoader);
|
|
115
|
+
this.hljs = toSignal(from(this.loader.ready));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Core highlighting function. Accepts the code to highlight (string) and a list of options (object)
|
|
119
|
+
*/
|
|
120
|
+
async highlight(code, options) {
|
|
121
|
+
const hljs = await this.loader.ready;
|
|
122
|
+
return hljs.highlight(code, options);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Highlighting with language detection.
|
|
126
|
+
*/
|
|
127
|
+
async highlightAuto(value, languageSubset) {
|
|
128
|
+
const hljs = await this.loader.ready;
|
|
129
|
+
return hljs.highlightAuto(value, languageSubset);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Applies highlighting to a DOM node containing code.
|
|
133
|
+
* This function is the one to use to apply highlighting dynamically after page load or within initialization code of third-party JavaScript frameworks.
|
|
134
|
+
* The function uses language detection by default but you can specify the language in the class attribute of the DOM node. See the scopes reference for all available language names and scopes.
|
|
135
|
+
*/
|
|
136
|
+
async highlightElement(element) {
|
|
137
|
+
const hljs = await this.loader.ready;
|
|
138
|
+
hljs.highlightElement(element);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Applies highlighting to all elements on a page matching the configured cssSelector. The default cssSelector value is 'pre code',
|
|
142
|
+
* which highlights all code blocks. This can be called before or after the page’s onload event has fired.
|
|
143
|
+
*/
|
|
144
|
+
async highlightAll() {
|
|
145
|
+
const hljs = await this.loader.ready;
|
|
146
|
+
hljs.highlightAll();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Adds new language to the library under the specified name. Used mostly internally.
|
|
150
|
+
* The function is passed the hljs object to be able to use common regular expressions defined within it.
|
|
151
|
+
*/
|
|
152
|
+
async registerLanguage(languageName, languageDefinition) {
|
|
153
|
+
const hljs = await this.loader.ready;
|
|
154
|
+
hljs.registerLanguage(languageName, languageDefinition);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Removes a language and its aliases from the library. Used mostly internally
|
|
158
|
+
*/
|
|
159
|
+
async unregisterLanguage(languageName) {
|
|
160
|
+
const hljs = await this.loader.ready;
|
|
161
|
+
hljs.unregisterLanguage(languageName);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Adds new language alias or aliases to the library for the specified language name defined under languageName key.
|
|
165
|
+
*/
|
|
166
|
+
async registerAliases(alias, { languageName }) {
|
|
167
|
+
const hljs = await this.loader.ready;
|
|
168
|
+
hljs.registerAliases(alias, { languageName });
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @return The languages names list.
|
|
172
|
+
*/
|
|
173
|
+
async listLanguages() {
|
|
174
|
+
const hljs = await this.loader.ready;
|
|
175
|
+
return hljs.listLanguages();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Looks up a language by name or alias.
|
|
179
|
+
*/
|
|
180
|
+
async getLanguage(name) {
|
|
181
|
+
const hljs = await this.loader.ready;
|
|
182
|
+
return hljs.getLanguage(name);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Enables safe mode. This is the default mode, providing the most reliable experience for production usage.
|
|
186
|
+
*/
|
|
187
|
+
async safeMode() {
|
|
188
|
+
const hljs = await this.loader.ready;
|
|
189
|
+
hljs.safeMode();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Enables debug/development mode.
|
|
193
|
+
*/
|
|
194
|
+
async debugMode() {
|
|
195
|
+
const hljs = await this.loader.ready;
|
|
196
|
+
hljs.debugMode();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Display line numbers
|
|
200
|
+
*/
|
|
201
|
+
async lineNumbersBlock(el, options) {
|
|
202
|
+
const hljs = await this.loader.ready;
|
|
203
|
+
if (hljs.lineNumbersBlock) {
|
|
204
|
+
hljs.lineNumbersBlock(el, options);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightJS, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
208
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightJS, providedIn: 'root' }); }
|
|
209
|
+
}
|
|
210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightJS, decorators: [{
|
|
211
|
+
type: Injectable,
|
|
212
|
+
args: [{
|
|
213
|
+
providedIn: 'root'
|
|
214
|
+
}]
|
|
215
|
+
}], ctorParameters: () => [] });
|
|
216
|
+
|
|
217
|
+
/// <reference types="trusted-types" />
|
|
218
|
+
/**
|
|
219
|
+
* Enable usage of the library together with "trusted-types" HTTP Content-Security-Policy (CSP)
|
|
220
|
+
*
|
|
221
|
+
* Can be added to angular.json -> serve -> options -> headers to try it out in DEV mode
|
|
222
|
+
* "Content-Security-Policy": "trusted-types nxt-highlightjs; require-trusted-types-for 'script'"
|
|
223
|
+
*
|
|
224
|
+
* Read more...
|
|
225
|
+
* Angular Security: https://angular.io/guide/security#enforcing-trusted-types
|
|
226
|
+
* Trusted Types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
227
|
+
*/
|
|
228
|
+
let policy;
|
|
229
|
+
function getPolicy() {
|
|
230
|
+
if (!policy) {
|
|
231
|
+
try {
|
|
232
|
+
policy = window?.trustedTypes?.createPolicy('nxt-highlightjs', {
|
|
233
|
+
createHTML: (s) => s
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// trustedTypes.createPolicy throws if called with a name that is
|
|
238
|
+
// already registered, even in report-only mode. Until the API changes,
|
|
239
|
+
// catch the error not to break the applications functionally. In such
|
|
240
|
+
// cases, the code will fall back to using strings.
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return policy;
|
|
244
|
+
}
|
|
245
|
+
function trustedHTMLFromStringBypass(html) {
|
|
246
|
+
return getPolicy()?.createHTML(html) || html;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
class HighlightBase {
|
|
250
|
+
constructor() {
|
|
251
|
+
this.hljs = inject(HighlightJS);
|
|
252
|
+
this.nativeElement = inject((ElementRef)).nativeElement;
|
|
253
|
+
this.sanitizer = inject(DomSanitizer);
|
|
254
|
+
effect(() => {
|
|
255
|
+
const code = this.code();
|
|
256
|
+
if (code) {
|
|
257
|
+
const res = this.highlightElement(code);
|
|
258
|
+
if (res) {
|
|
259
|
+
this.setInnerHTML(res?.value ?? undefined);
|
|
260
|
+
this.highlightResult.set(res);
|
|
261
|
+
// Forward highlight response to the highlighted output
|
|
262
|
+
this.highlighted.emit(res);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
this.setTextContent('');
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
setTextContent(content) {
|
|
271
|
+
this.nativeElement.textContent = content;
|
|
272
|
+
}
|
|
273
|
+
setInnerHTML(content) {
|
|
274
|
+
this.nativeElement.innerHTML = trustedHTMLFromStringBypass(this.sanitizer.sanitize(SecurityContext.HTML, content || null) || '');
|
|
275
|
+
}
|
|
276
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
277
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.3", type: HighlightBase, isStandalone: true, ngImport: i0 }); }
|
|
278
|
+
}
|
|
279
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightBase, decorators: [{
|
|
280
|
+
type: Directive
|
|
281
|
+
}], ctorParameters: () => [] });
|
|
282
|
+
|
|
283
|
+
class HighlightDirective extends HighlightBase {
|
|
284
|
+
constructor() {
|
|
285
|
+
super(...arguments);
|
|
286
|
+
/**
|
|
287
|
+
* Code to highlight
|
|
288
|
+
*/
|
|
289
|
+
this.code = input(undefined, { alias: 'nxtHighlight' });
|
|
290
|
+
/**
|
|
291
|
+
* Highlighted result
|
|
292
|
+
*/
|
|
293
|
+
this.highlightResult = signal(undefined);
|
|
294
|
+
/**
|
|
295
|
+
* The language name highlight only one language
|
|
296
|
+
*/
|
|
297
|
+
this.language = input.required();
|
|
298
|
+
/**
|
|
299
|
+
* An optional flag, when set to true it forces highlighting to finish even in case of detecting
|
|
300
|
+
* illegal syntax for the language instead of throwing an exception
|
|
301
|
+
*/
|
|
302
|
+
this.ignoreIllegals = input(undefined, {
|
|
303
|
+
transform: booleanAttribute
|
|
304
|
+
});
|
|
305
|
+
/**
|
|
306
|
+
* Stream that emits when code string is highlighted
|
|
307
|
+
*/
|
|
308
|
+
this.highlighted = output();
|
|
309
|
+
}
|
|
310
|
+
highlightElement(code) {
|
|
311
|
+
const hljs = this.hljs.hljs();
|
|
312
|
+
return hljs?.highlight(code, {
|
|
313
|
+
language: this.language(),
|
|
314
|
+
ignoreIllegals: this.ignoreIllegals()
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
318
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.3", type: HighlightDirective, isStandalone: true, selector: "[nxtHighlight]", inputs: { code: { classPropertyName: "code", publicName: "nxtHighlight", isSignal: true, isRequired: false, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: true, transformFunction: null }, ignoreIllegals: { classPropertyName: "ignoreIllegals", publicName: "ignoreIllegals", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { highlighted: "highlighted" }, host: { properties: { "class.hljs": "true" } }, providers: [{ provide: HighlightBase, useExisting: HighlightDirective }], usesInheritance: true, ngImport: i0 }); }
|
|
319
|
+
}
|
|
320
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightDirective, decorators: [{
|
|
321
|
+
type: Directive,
|
|
322
|
+
args: [{
|
|
323
|
+
selector: '[nxtHighlight]',
|
|
324
|
+
providers: [{ provide: HighlightBase, useExisting: HighlightDirective }],
|
|
325
|
+
host: {
|
|
326
|
+
'[class.hljs]': 'true'
|
|
327
|
+
}
|
|
328
|
+
}]
|
|
329
|
+
}] });
|
|
330
|
+
|
|
331
|
+
class HighlightAutoDirective extends HighlightBase {
|
|
332
|
+
constructor() {
|
|
333
|
+
super(...arguments);
|
|
334
|
+
/**
|
|
335
|
+
* Code to highlight
|
|
336
|
+
*/
|
|
337
|
+
this.code = input(undefined, { alias: 'nxtHighlightAuto' });
|
|
338
|
+
/**
|
|
339
|
+
* Highlighted result
|
|
340
|
+
*/
|
|
341
|
+
this.highlightResult = signal(undefined);
|
|
342
|
+
/**
|
|
343
|
+
* An optional array of language names and aliases restricting detection to only those languages
|
|
344
|
+
*
|
|
345
|
+
* The subset can also be set with configure, but the local parameter overrides the option if set.
|
|
346
|
+
*/
|
|
347
|
+
this.languages = input();
|
|
348
|
+
/**
|
|
349
|
+
* Stream that emits when code string is highlighted
|
|
350
|
+
*/
|
|
351
|
+
this.highlighted = output();
|
|
352
|
+
}
|
|
353
|
+
highlightElement(code) {
|
|
354
|
+
const hljs = this.hljs.hljs();
|
|
355
|
+
return hljs?.highlightAuto(code, this.languages());
|
|
356
|
+
}
|
|
357
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightAutoDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
358
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.3", type: HighlightAutoDirective, isStandalone: true, selector: "[nxtHighlightAuto]", inputs: { code: { classPropertyName: "code", publicName: "nxtHighlightAuto", isSignal: true, isRequired: false, transformFunction: null }, languages: { classPropertyName: "languages", publicName: "languages", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { highlighted: "highlighted" }, host: { properties: { "class.hljs": "true" } }, providers: [{ provide: HighlightBase, useExisting: HighlightAutoDirective }], usesInheritance: true, ngImport: i0 }); }
|
|
359
|
+
}
|
|
360
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightAutoDirective, decorators: [{
|
|
361
|
+
type: Directive,
|
|
362
|
+
args: [{
|
|
363
|
+
selector: '[nxtHighlightAuto]',
|
|
364
|
+
providers: [{ provide: HighlightBase, useExisting: HighlightAutoDirective }],
|
|
365
|
+
host: {
|
|
366
|
+
'[class.hljs]': 'true'
|
|
367
|
+
}
|
|
368
|
+
}]
|
|
369
|
+
}] });
|
|
370
|
+
|
|
371
|
+
class HighlightModule {
|
|
372
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
373
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.3", ngImport: i0, type: HighlightModule, imports: [HighlightDirective, HighlightAutoDirective], exports: [HighlightDirective, HighlightAutoDirective] }); }
|
|
374
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightModule }); }
|
|
375
|
+
}
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HighlightModule, decorators: [{
|
|
377
|
+
type: NgModule,
|
|
378
|
+
args: [{
|
|
379
|
+
imports: [HighlightDirective, HighlightAutoDirective],
|
|
380
|
+
exports: [HighlightDirective, HighlightAutoDirective]
|
|
381
|
+
}]
|
|
382
|
+
}] });
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Generated bundle index. Do not edit.
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
export { HighlightAutoDirective, HighlightBase, HighlightDirective, HighlightJS, HighlightLoader, HighlightModule, NXT_HIGHLIGHT_OPTIONS, provideHighlightOptions };
|
|
389
|
+
//# sourceMappingURL=nxt-highlightjs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nxt-highlightjs.mjs","sources":["../../../packages/highlightjs/src/lib/highlight.model.ts","../../../packages/highlightjs/src/lib/loader-errors.ts","../../../packages/highlightjs/src/lib/highlight.loader.ts","../../../packages/highlightjs/src/lib/highlight.service.ts","../../../packages/highlightjs/src/lib/trusted-types.ts","../../../packages/highlightjs/src/lib/highlight-base.ts","../../../packages/highlightjs/src/lib/highlight.ts","../../../packages/highlightjs/src/lib/highlight-auto.ts","../../../packages/highlightjs/src/lib/highlight.module.ts","../../../packages/highlightjs/src/nxt-highlightjs.ts"],"sourcesContent":["import { InjectionToken, makeEnvironmentProviders } from '@angular/core'\r\nimport type { HLJSApi, HLJSOptions, LanguageFn } from 'highlight.js'\r\n\r\n/**\r\n * Full documentation is available here https://highlightjs.readthedocs.io/en/latest/api.html\r\n */\r\n\r\nexport interface LineNumbersOptions {\r\n startFrom?: number\r\n singleLine?: boolean\r\n}\r\n\r\nexport interface HighlightJSOptions {\r\n highlightOptions?: Partial<HLJSOptions>\r\n lineNumbersOptions?: LineNumbersOptions\r\n languages?: Record<string, () => Promise<LanguageFn>>\r\n coreLibraryLoader?: () => Promise<HLJSApi>\r\n fullLibraryLoader?: () => Promise<HLJSApi>\r\n lineNumbersLoader?: () => Promise<{ activateLineNumbers: (document: Document) => (element: HTMLElement, options?: LineNumbersOptions) => void }>\r\n themePath?: string\r\n}\r\n\r\nexport const NXT_HIGHLIGHT_OPTIONS = new InjectionToken<HighlightJSOptions>('NXT_HIGHLIGHT_OPTIONS')\r\n\r\nexport function provideHighlightOptions(options: HighlightJSOptions) {\r\n return makeEnvironmentProviders([\r\n {\r\n provide: NXT_HIGHLIGHT_OPTIONS,\r\n useValue: options\r\n }\r\n ])\r\n}\r\n","export enum LoaderErrors {\r\n FULL_WITH_CORE_LIBRARY_IMPORTS = 'The full library and the core library were imported, only one of them should be imported!',\r\n FULL_WITH_LANGUAGE_IMPORTS = 'The highlighting languages were imported they are not needed!',\r\n CORE_WITHOUT_LANGUAGE_IMPORTS = 'The highlighting languages were not imported!',\r\n LANGUAGE_WITHOUT_CORE_IMPORTS = 'The core library was not imported!',\r\n NO_FULL_AND_NO_CORE_IMPORTS = 'Highlight.js library was not imported!'\r\n}\r\n","import { DOCUMENT } from '@angular/common'\r\nimport { Injectable, PendingTasks, inject } from '@angular/core'\r\nimport type { HLJSApi } from 'highlight.js'\r\nimport { NXT_HIGHLIGHT_OPTIONS } from './highlight.model'\r\nimport { LoaderErrors } from './loader-errors'\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class HighlightLoader {\r\n\r\n private readonly document: Document = inject(DOCUMENT)\r\n private readonly options = inject(NXT_HIGHLIGHT_OPTIONS, { optional: true })\r\n private readonly pendingTasks = inject(PendingTasks)\r\n\r\n readonly ready: Promise<HLJSApi> = this.pendingTasks.run(() => this.loadLibrary()\r\n .then(async hljs => {\r\n if (this.options?.lineNumbersLoader) {\r\n const plugin = await this.options.lineNumbersLoader();\r\n (hljs as any).lineNumbersBlock = plugin.activateLineNumbers(this.document)\r\n }\r\n\r\n if (this.options?.highlightOptions)\r\n hljs.configure(this.options.highlightOptions)\r\n\r\n return hljs\r\n })\r\n )\r\n\r\n private themeLinkElement?: HTMLLinkElement\r\n\r\n constructor() {\r\n if (this.options?.themePath) {\r\n this.loadTheme(this.options.themePath)\r\n }\r\n }\r\n\r\n /**\r\n * Lazy-Load highlight.js library\r\n */\r\n private async loadLibrary(): Promise<HLJSApi> {\r\n if (this.options) {\r\n if (this.options.fullLibraryLoader && this.options.coreLibraryLoader) {\r\n throw new Error(LoaderErrors.FULL_WITH_CORE_LIBRARY_IMPORTS)\r\n }\r\n if (this.options.fullLibraryLoader && this.options.languages) {\r\n throw new Error(LoaderErrors.FULL_WITH_LANGUAGE_IMPORTS)\r\n }\r\n if (this.options.coreLibraryLoader && !this.options.languages) {\r\n throw new Error(LoaderErrors.CORE_WITHOUT_LANGUAGE_IMPORTS)\r\n }\r\n if (!this.options.coreLibraryLoader && this.options.languages) {\r\n throw new Error(LoaderErrors.LANGUAGE_WITHOUT_CORE_IMPORTS)\r\n }\r\n if (this.options.fullLibraryLoader) {\r\n return this.options.fullLibraryLoader()\r\n }\r\n if (this.options.coreLibraryLoader && this.options.languages && Object.keys(this.options.languages).length) {\r\n return this.options.coreLibraryLoader().then(hljs => this.loadLanguages(hljs))\r\n }\r\n }\r\n throw new Error(LoaderErrors.NO_FULL_AND_NO_CORE_IMPORTS)\r\n }\r\n\r\n /**\r\n * Lazy-load highlight.js languages\r\n */\r\n private async loadLanguages(hljs: HLJSApi) {\r\n await Promise.all(Object.entries(this.options?.languages || {})\r\n .map(([langName, langLoader]) => langLoader().then(langFunc => hljs.registerLanguage(langName, langFunc))))\r\n return hljs\r\n }\r\n\r\n /**\r\n * Reload theme styles\r\n */\r\n setTheme(path: string): void {\r\n if (this.themeLinkElement) {\r\n this.themeLinkElement.href = path\r\n } else {\r\n this.loadTheme(path)\r\n }\r\n }\r\n\r\n /**\r\n * Load theme\r\n */\r\n private loadTheme(path: string): void {\r\n this.themeLinkElement = this.document.createElement('link')\r\n this.themeLinkElement.href = path\r\n this.themeLinkElement.type = 'text/css'\r\n this.themeLinkElement.rel = 'stylesheet'\r\n this.themeLinkElement.media = 'screen,print'\r\n this.document.head.appendChild(this.themeLinkElement)\r\n }\r\n}\r\n","import { Injectable, inject } from '@angular/core'\r\nimport { toSignal } from '@angular/core/rxjs-interop'\r\nimport type {\r\n AutoHighlightResult,\r\n HLJSApi,\r\n HighlightOptions,\r\n HighlightResult,\r\n LanguageFn\r\n} from 'highlight.js'\r\nimport { from } from 'rxjs'\r\nimport { HighlightLoader } from './highlight.loader'\r\nimport { LineNumbersOptions } from './highlight.model'\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class HighlightJS {\r\n\r\n private readonly loader = inject(HighlightLoader)\r\n\r\n readonly hljs = toSignal(from(this.loader.ready))\r\n\r\n constructor() { }\r\n\r\n /**\r\n * Core highlighting function. Accepts the code to highlight (string) and a list of options (object)\r\n */\r\n async highlight(code: string, options: HighlightOptions): Promise<HighlightResult> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n return hljs.highlight(code, options)\r\n }\r\n\r\n /**\r\n * Highlighting with language detection.\r\n */\r\n async highlightAuto(value: string, languageSubset?: string[]): Promise<AutoHighlightResult> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n return hljs.highlightAuto(value, languageSubset)\r\n }\r\n\r\n /**\r\n * Applies highlighting to a DOM node containing code.\r\n * This function is the one to use to apply highlighting dynamically after page load or within initialization code of third-party JavaScript frameworks.\r\n * The function uses language detection by default but you can specify the language in the class attribute of the DOM node. See the scopes reference for all available language names and scopes.\r\n */\r\n async highlightElement(element: HTMLElement): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.highlightElement(element)\r\n }\r\n\r\n /**\r\n * Applies highlighting to all elements on a page matching the configured cssSelector. The default cssSelector value is 'pre code',\r\n * which highlights all code blocks. This can be called before or after the page’s onload event has fired.\r\n */\r\n async highlightAll(): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.highlightAll()\r\n }\r\n\r\n /**\r\n * Adds new language to the library under the specified name. Used mostly internally.\r\n * The function is passed the hljs object to be able to use common regular expressions defined within it.\r\n */\r\n async registerLanguage(languageName: string, languageDefinition: LanguageFn): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.registerLanguage(languageName, languageDefinition)\r\n }\r\n\r\n /**\r\n * Removes a language and its aliases from the library. Used mostly internally\r\n */\r\n async unregisterLanguage(languageName: string): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.unregisterLanguage(languageName)\r\n }\r\n\r\n /**\r\n * Adds new language alias or aliases to the library for the specified language name defined under languageName key.\r\n */\r\n async registerAliases(alias: string | string[], { languageName }: { languageName: string }): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.registerAliases(alias, { languageName })\r\n }\r\n\r\n /**\r\n * @return The languages names list.\r\n */\r\n async listLanguages(): Promise<string[]> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n return hljs.listLanguages()\r\n }\r\n\r\n /**\r\n * Looks up a language by name or alias.\r\n */\r\n async getLanguage(name: string): Promise<any> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n return hljs.getLanguage(name)\r\n }\r\n\r\n /**\r\n * Enables safe mode. This is the default mode, providing the most reliable experience for production usage.\r\n */\r\n async safeMode(): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.safeMode()\r\n }\r\n\r\n /**\r\n * Enables debug/development mode.\r\n */\r\n async debugMode(): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n hljs.debugMode()\r\n }\r\n\r\n /**\r\n * Display line numbers\r\n */\r\n async lineNumbersBlock(el: HTMLElement, options: LineNumbersOptions): Promise<void> {\r\n const hljs: HLJSApi = await this.loader.ready\r\n if ((hljs as any).lineNumbersBlock) {\r\n (hljs as any).lineNumbersBlock(el, options)\r\n }\r\n }\r\n}\r\n","/// <reference types=\"trusted-types\" />\r\n\r\nimport { TrustedTypePolicy } from 'trusted-types/lib'\r\n\r\n/**\r\n * Enable usage of the library together with \"trusted-types\" HTTP Content-Security-Policy (CSP)\r\n *\r\n * Can be added to angular.json -> serve -> options -> headers to try it out in DEV mode\r\n * \"Content-Security-Policy\": \"trusted-types nxt-highlightjs; require-trusted-types-for 'script'\"\r\n *\r\n * Read more...\r\n * Angular Security: https://angular.io/guide/security#enforcing-trusted-types\r\n * Trusted Types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\r\n */\r\nlet policy: Pick<TrustedTypePolicy<{\r\n createHTML: (s: string) => string\r\n}>, 'name' | 'createHTML'> | undefined\r\n\r\nfunction getPolicy() {\r\n if (!policy) {\r\n try {\r\n policy = window?.trustedTypes?.createPolicy('nxt-highlightjs', {\r\n createHTML: (s: string) => s\r\n })\r\n } catch {\r\n // trustedTypes.createPolicy throws if called with a name that is\r\n // already registered, even in report-only mode. Until the API changes,\r\n // catch the error not to break the applications functionally. In such\r\n // cases, the code will fall back to using strings.\r\n }\r\n }\r\n return policy\r\n}\r\n\r\nexport function trustedHTMLFromStringBypass(html: string) {\r\n return getPolicy()?.createHTML(html) || html\r\n}\r\n","import {\r\n Directive,\r\n ElementRef,\r\n InputSignal,\r\n OutputEmitterRef,\r\n SecurityContext,\r\n WritableSignal,\r\n effect,\r\n inject\r\n} from '@angular/core'\r\nimport { DomSanitizer } from '@angular/platform-browser'\r\nimport type { AutoHighlightResult, HighlightResult } from 'highlight.js'\r\nimport { HighlightJS } from './highlight.service'\r\nimport { trustedHTMLFromStringBypass } from './trusted-types'\r\n\r\n@Directive()\r\nexport abstract class HighlightBase {\r\n\r\n protected readonly hljs: HighlightJS = inject(HighlightJS)\r\n\r\n private readonly nativeElement: HTMLElement = inject(ElementRef<HTMLElement>).nativeElement\r\n private readonly sanitizer: DomSanitizer = inject(DomSanitizer)\r\n\r\n /**\r\n * Code to highlight\r\n */\r\n abstract code: InputSignal<string | null | undefined>\r\n\r\n /**\r\n * Highlighted result\r\n */\r\n abstract highlightResult: WritableSignal<HighlightResult | AutoHighlightResult | undefined>\r\n\r\n /**\r\n * Stream that emits when code string is highlighted\r\n */\r\n abstract highlighted: OutputEmitterRef<HighlightResult | AutoHighlightResult | undefined>\r\n\r\n constructor() {\r\n effect(() => {\r\n const code = this.code()\r\n if (code) {\r\n const res = this.highlightElement(code)\r\n if (res) {\r\n this.setInnerHTML(res?.value ?? undefined)\r\n this.highlightResult.set(res)\r\n // Forward highlight response to the highlighted output\r\n this.highlighted.emit(res)\r\n }\r\n } else {\r\n this.setTextContent('')\r\n }\r\n })\r\n }\r\n\r\n protected abstract highlightElement(code: string): HighlightResult | AutoHighlightResult | undefined\r\n\r\n private setTextContent(content: string): void {\r\n this.nativeElement.textContent = content\r\n }\r\n\r\n private setInnerHTML(content: string | undefined): void {\r\n this.nativeElement.innerHTML = trustedHTMLFromStringBypass(\r\n this.sanitizer.sanitize(SecurityContext.HTML, content || null) || ''\r\n ) as any\r\n }\r\n}\r\n","import {\r\n booleanAttribute,\r\n Directive,\r\n input,\r\n InputSignal,\r\n output,\r\n signal\r\n} from '@angular/core'\r\nimport type { HighlightResult } from 'highlight.js'\r\nimport { HighlightBase } from './highlight-base'\r\n\r\n@Directive({\r\n selector: '[nxtHighlight]',\r\n providers: [{ provide: HighlightBase, useExisting: HighlightDirective }],\r\n host: {\r\n '[class.hljs]': 'true'\r\n }\r\n})\r\nexport class HighlightDirective extends HighlightBase {\r\n\r\n /**\r\n * Code to highlight\r\n */\r\n code = input<string | null>(undefined, { alias: 'nxtHighlight' })\r\n\r\n /**\r\n * Highlighted result\r\n */\r\n highlightResult = signal<HighlightResult | undefined>(undefined)\r\n\r\n /**\r\n * The language name highlight only one language\r\n */\r\n readonly language: InputSignal<string> = input.required<string>()\r\n\r\n /**\r\n * An optional flag, when set to true it forces highlighting to finish even in case of detecting\r\n * illegal syntax for the language instead of throwing an exception\r\n */\r\n readonly ignoreIllegals = input<boolean, unknown>(undefined, {\r\n transform: booleanAttribute\r\n })\r\n\r\n /**\r\n * Stream that emits when code string is highlighted\r\n */\r\n highlighted = output<HighlightResult>()\r\n\r\n highlightElement(code: string) {\r\n const hljs = this.hljs.hljs()\r\n return hljs?.highlight(code, {\r\n language: this.language(),\r\n ignoreIllegals: this.ignoreIllegals()\r\n })\r\n }\r\n}\r\n","import {\r\n Directive,\r\n input,\r\n output,\r\n OutputEmitterRef,\r\n signal\r\n} from '@angular/core'\r\nimport type { AutoHighlightResult } from 'highlight.js'\r\nimport { HighlightBase } from './highlight-base'\r\n\r\n@Directive({\r\n selector: '[nxtHighlightAuto]',\r\n providers: [{ provide: HighlightBase, useExisting: HighlightAutoDirective }],\r\n host: {\r\n '[class.hljs]': 'true'\r\n }\r\n})\r\nexport class HighlightAutoDirective extends HighlightBase {\r\n\r\n /**\r\n * Code to highlight\r\n */\r\n code = input<string | null>(undefined, { alias: 'nxtHighlightAuto' })\r\n\r\n /**\r\n * Highlighted result\r\n */\r\n highlightResult = signal<AutoHighlightResult | undefined>(undefined)\r\n\r\n /**\r\n * An optional array of language names and aliases restricting detection to only those languages\r\n *\r\n * The subset can also be set with configure, but the local parameter overrides the option if set.\r\n */\r\n readonly languages = input<string[]>()\r\n\r\n /**\r\n * Stream that emits when code string is highlighted\r\n */\r\n highlighted: OutputEmitterRef<AutoHighlightResult> = output<AutoHighlightResult>()\r\n\r\n protected highlightElement(code: string) {\r\n const hljs = this.hljs.hljs()\r\n return hljs?.highlightAuto(code, this.languages())\r\n }\r\n}\r\n\r\n","import { NgModule } from '@angular/core'\r\nimport { HighlightDirective } from './highlight'\r\nimport { HighlightAutoDirective } from './highlight-auto'\r\n\r\n@NgModule({\r\n imports: [HighlightDirective, HighlightAutoDirective],\r\n exports: [HighlightDirective, HighlightAutoDirective]\r\n})\r\nexport class HighlightModule {\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAsBa,qBAAqB,GAAG,IAAI,cAAc,CAAqB,uBAAuB;AAE7F,SAAU,uBAAuB,CAAC,OAA2B,EAAA;AAC/D,IAAA,OAAO,wBAAwB,CAAC;AAC5B,QAAA;AACI,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE;AACb;AACJ,KAAA,CAAC;AACN;;AC/BA,IAAY,YAMX;AAND,CAAA,UAAY,YAAY,EAAA;AACpB,IAAA,YAAA,CAAA,gCAAA,CAAA,GAAA,2FAA4H;AAC5H,IAAA,YAAA,CAAA,4BAAA,CAAA,GAAA,+DAA4F;AAC5F,IAAA,YAAA,CAAA,+BAAA,CAAA,GAAA,+CAA+E;AAC/E,IAAA,YAAA,CAAA,+BAAA,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1
|
+
import { OutputEmitterRef } from '@angular/core';
|
|
2
|
+
import type { AutoHighlightResult } from 'highlight.js';
|
|
3
|
+
import { HighlightBase } from './highlight-base';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class HighlightAutoDirective extends HighlightBase {
|
|
6
|
+
/**
|
|
7
|
+
* Code to highlight
|
|
8
|
+
*/
|
|
9
|
+
code: import("@angular/core").InputSignal<string | null | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Highlighted result
|
|
12
|
+
*/
|
|
13
|
+
highlightResult: import("@angular/core").WritableSignal<AutoHighlightResult | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* An optional array of language names and aliases restricting detection to only those languages
|
|
16
|
+
*
|
|
17
|
+
* The subset can also be set with configure, but the local parameter overrides the option if set.
|
|
18
|
+
*/
|
|
19
|
+
readonly languages: import("@angular/core").InputSignal<string[] | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Stream that emits when code string is highlighted
|
|
22
|
+
*/
|
|
23
|
+
highlighted: OutputEmitterRef<AutoHighlightResult>;
|
|
24
|
+
protected highlightElement(code: string): AutoHighlightResult | undefined;
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightAutoDirective, never>;
|
|
26
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HighlightAutoDirective, "[nxtHighlightAuto]", never, { "code": { "alias": "nxtHighlightAuto"; "required": false; "isSignal": true; }; "languages": { "alias": "languages"; "required": false; "isSignal": true; }; }, { "highlighted": "highlighted"; }, never, never, true, never>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InputSignal, OutputEmitterRef, WritableSignal } from '@angular/core';
|
|
2
|
+
import type { AutoHighlightResult, HighlightResult } from 'highlight.js';
|
|
3
|
+
import { HighlightJS } from './highlight.service';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare abstract class HighlightBase {
|
|
6
|
+
protected readonly hljs: HighlightJS;
|
|
7
|
+
private readonly nativeElement;
|
|
8
|
+
private readonly sanitizer;
|
|
9
|
+
/**
|
|
10
|
+
* Code to highlight
|
|
11
|
+
*/
|
|
12
|
+
abstract code: InputSignal<string | null | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Highlighted result
|
|
15
|
+
*/
|
|
16
|
+
abstract highlightResult: WritableSignal<HighlightResult | AutoHighlightResult | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Stream that emits when code string is highlighted
|
|
19
|
+
*/
|
|
20
|
+
abstract highlighted: OutputEmitterRef<HighlightResult | AutoHighlightResult | undefined>;
|
|
21
|
+
constructor();
|
|
22
|
+
protected abstract highlightElement(code: string): HighlightResult | AutoHighlightResult | undefined;
|
|
23
|
+
private setTextContent;
|
|
24
|
+
private setInnerHTML;
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightBase, never>;
|
|
26
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HighlightBase, never, never, {}, {}, never, never, true, never>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InputSignal } from '@angular/core';
|
|
2
|
+
import type { HighlightResult } from 'highlight.js';
|
|
3
|
+
import { HighlightBase } from './highlight-base';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class HighlightDirective extends HighlightBase {
|
|
6
|
+
/**
|
|
7
|
+
* Code to highlight
|
|
8
|
+
*/
|
|
9
|
+
code: InputSignal<string | null | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Highlighted result
|
|
12
|
+
*/
|
|
13
|
+
highlightResult: import("@angular/core").WritableSignal<HighlightResult | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* The language name highlight only one language
|
|
16
|
+
*/
|
|
17
|
+
readonly language: InputSignal<string>;
|
|
18
|
+
/**
|
|
19
|
+
* An optional flag, when set to true it forces highlighting to finish even in case of detecting
|
|
20
|
+
* illegal syntax for the language instead of throwing an exception
|
|
21
|
+
*/
|
|
22
|
+
readonly ignoreIllegals: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Stream that emits when code string is highlighted
|
|
25
|
+
*/
|
|
26
|
+
highlighted: import("@angular/core").OutputEmitterRef<HighlightResult>;
|
|
27
|
+
highlightElement(code: string): HighlightResult | undefined;
|
|
28
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightDirective, never>;
|
|
29
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<HighlightDirective, "[nxtHighlight]", never, { "code": { "alias": "nxtHighlight"; "required": false; "isSignal": true; }; "language": { "alias": "language"; "required": true; "isSignal": true; }; "ignoreIllegals": { "alias": "ignoreIllegals"; "required": false; "isSignal": true; }; }, { "highlighted": "highlighted"; }, never, never, true, never>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HLJSApi } from 'highlight.js';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class HighlightLoader {
|
|
4
|
+
private readonly document;
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly pendingTasks;
|
|
7
|
+
readonly ready: Promise<HLJSApi>;
|
|
8
|
+
private themeLinkElement?;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Lazy-Load highlight.js library
|
|
12
|
+
*/
|
|
13
|
+
private loadLibrary;
|
|
14
|
+
/**
|
|
15
|
+
* Lazy-load highlight.js languages
|
|
16
|
+
*/
|
|
17
|
+
private loadLanguages;
|
|
18
|
+
/**
|
|
19
|
+
* Reload theme styles
|
|
20
|
+
*/
|
|
21
|
+
setTheme(path: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Load theme
|
|
24
|
+
*/
|
|
25
|
+
private loadTheme;
|
|
26
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightLoader, never>;
|
|
27
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<HighlightLoader>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import type { HLJSApi, HLJSOptions, LanguageFn } from 'highlight.js';
|
|
3
|
+
/**
|
|
4
|
+
* Full documentation is available here https://highlightjs.readthedocs.io/en/latest/api.html
|
|
5
|
+
*/
|
|
6
|
+
export interface LineNumbersOptions {
|
|
7
|
+
startFrom?: number;
|
|
8
|
+
singleLine?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface HighlightJSOptions {
|
|
11
|
+
highlightOptions?: Partial<HLJSOptions>;
|
|
12
|
+
lineNumbersOptions?: LineNumbersOptions;
|
|
13
|
+
languages?: Record<string, () => Promise<LanguageFn>>;
|
|
14
|
+
coreLibraryLoader?: () => Promise<HLJSApi>;
|
|
15
|
+
fullLibraryLoader?: () => Promise<HLJSApi>;
|
|
16
|
+
lineNumbersLoader?: () => Promise<{
|
|
17
|
+
activateLineNumbers: (document: Document) => (element: HTMLElement, options?: LineNumbersOptions) => void;
|
|
18
|
+
}>;
|
|
19
|
+
themePath?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const NXT_HIGHLIGHT_OPTIONS: InjectionToken<HighlightJSOptions>;
|
|
22
|
+
export declare function provideHighlightOptions(options: HighlightJSOptions): import("@angular/core").EnvironmentProviders;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./highlight";
|
|
3
|
+
import * as i2 from "./highlight-auto";
|
|
4
|
+
export declare class HighlightModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<HighlightModule, never, [typeof i1.HighlightDirective, typeof i2.HighlightAutoDirective], [typeof i1.HighlightDirective, typeof i2.HighlightAutoDirective]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<HighlightModule>;
|
|
8
|
+
}
|