Add Prism.js.
This commit is contained in:
39
frontend/package-lock.json
generated
39
frontend/package-lock.json
generated
@@ -18,6 +18,7 @@
|
|||||||
"@angular/platform-browser": "^17.0.0",
|
"@angular/platform-browser": "^17.0.0",
|
||||||
"@angular/platform-browser-dynamic": "^17.0.0",
|
"@angular/platform-browser-dynamic": "^17.0.0",
|
||||||
"@angular/router": "^17.0.0",
|
"@angular/router": "^17.0.0",
|
||||||
|
"clipboard": "^2.0.11",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.14.2"
|
"zone.js": "~0.14.2"
|
||||||
@@ -6047,6 +6048,17 @@
|
|||||||
"node": ">= 12"
|
"node": ">= 12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/clipboard": {
|
||||||
|
"version": "2.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz",
|
||||||
|
"integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"good-listener": "^1.2.2",
|
||||||
|
"select": "^1.1.2",
|
||||||
|
"tiny-emitter": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cliui": {
|
"node_modules/cliui": {
|
||||||
"version": "8.0.1",
|
"version": "8.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||||
@@ -6766,6 +6778,12 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/delegate": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/depd": {
|
"node_modules/depd": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||||
@@ -7912,6 +7930,15 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/good-listener": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"delegate": "^3.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/gopd": {
|
"node_modules/gopd": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
||||||
@@ -11992,6 +12019,12 @@
|
|||||||
"url": "https://opencollective.com/webpack"
|
"url": "https://opencollective.com/webpack"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/select": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/select-hose": {
|
"node_modules/select-hose": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
|
||||||
@@ -12963,6 +12996,12 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/tiny-emitter": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/tmp": {
|
"node_modules/tmp": {
|
||||||
"version": "0.0.33",
|
"version": "0.0.33",
|
||||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"@angular/platform-browser": "^17.0.0",
|
"@angular/platform-browser": "^17.0.0",
|
||||||
"@angular/platform-browser-dynamic": "^17.0.0",
|
"@angular/platform-browser-dynamic": "^17.0.0",
|
||||||
"@angular/router": "^17.0.0",
|
"@angular/router": "^17.0.0",
|
||||||
|
"clipboard": "^2.0.11",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.14.2"
|
"zone.js": "~0.14.2"
|
||||||
|
|||||||
@@ -16,22 +16,70 @@ export const PROGRAMMING_LANGUAGES: ProgramingLanguage[] = [
|
|||||||
code: 'bash',
|
code: 'bash',
|
||||||
label: 'Bash'
|
label: 'Bash'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: 'c',
|
||||||
|
label: 'C'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'cpp',
|
||||||
|
label: 'C++'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'cs',
|
||||||
|
label: 'C#'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'lua',
|
||||||
|
label: 'Lua'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
code: 'java',
|
code: 'java',
|
||||||
label: 'Java'
|
label: 'Java'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: 'json5',
|
||||||
|
label: 'JSON'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'kt',
|
||||||
|
label: 'Kotlin'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
code: 'markup',
|
code: 'markup',
|
||||||
label: 'html/xml'
|
label: 'html/xml'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: 'php',
|
||||||
|
label: 'PHP'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'plsql',
|
||||||
|
label: 'PL/SQL'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
code: 'python',
|
code: 'python',
|
||||||
label: 'Python'
|
label: 'Python'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: 'powershell',
|
||||||
|
label: 'PowerShell'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'rust',
|
||||||
|
label: 'Rust'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
code: 'sql',
|
code: 'sql',
|
||||||
label: 'SQL'
|
label: 'SQL'
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
code: 'ts',
|
||||||
|
label: 'Typescript'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'yml',
|
||||||
|
label: 'YAML'
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import { MatTooltip, MatTooltipModule } from '@angular/material/tooltip';
|
|||||||
import { MatIcon } from '@angular/material/icon';
|
import { MatIcon } from '@angular/material/icon';
|
||||||
import { AuthenticationService } from '../../core/service/authentication.service';
|
import { AuthenticationService } from '../../core/service/authentication.service';
|
||||||
|
|
||||||
|
declare let Prism: any;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-publication',
|
selector: 'app-publication',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@@ -40,6 +42,7 @@ export class PublicationComponent implements OnInit, OnDestroy {
|
|||||||
.then(publication => {
|
.then(publication => {
|
||||||
this.publication = publication;
|
this.publication = publication;
|
||||||
this.isAuthorAndUserEquals = this.authenticationService.getAuthenticatedUser()?.id === this.publication.author.id;
|
this.isAuthorAndUserEquals = this.authenticationService.getAuthenticatedUser()?.id === this.publication.author.id;
|
||||||
|
setTimeout(() => Prism.highlightAll(), 100);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.snackBar.open('An error occurred while loading publication...', 'Close', { duration: 5000 });
|
this.snackBar.open('An error occurred while loading publication...', 'Close', { duration: 5000 });
|
||||||
|
|||||||
6
frontend/src/assets/css/prism.css
Normal file
6
frontend/src/assets/css/prism.css
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/* PrismJS 1.29.0
|
||||||
|
https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript+bash+json+json5+lua+plsql+powershell+python+rust+sql+xml-doc+yaml&plugins=line-numbers+show-language+unescaped-markup+toolbar+copy-to-clipboard */
|
||||||
|
code[class*=language-],pre[class*=language-]{color:#f8f8f2;background:0 0;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#272822}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#8292a2}.token.punctuation{color:#f8f8f2}.token.namespace{opacity:.7}.token.constant,.token.deleted,.token.property,.token.symbol,.token.tag{color:#f92672}.token.boolean,.token.number{color:#ae81ff}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#a6e22e}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value,.token.class-name,.token.function{color:#e6db74}.token.keyword{color:#66d9ef}.token.important,.token.regex{color:#fd971f}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}
|
||||||
|
pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}
|
||||||
|
div.code-toolbar{position:relative}div.code-toolbar>.toolbar{position:absolute;z-index:10;top:.3em;right:.2em;transition:opacity .3s ease-in-out;opacity:0}div.code-toolbar:hover>.toolbar{opacity:1}div.code-toolbar:focus-within>.toolbar{opacity:1}div.code-toolbar>.toolbar>.toolbar-item{display:inline-block}div.code-toolbar>.toolbar>.toolbar-item>a{cursor:pointer}div.code-toolbar>.toolbar>.toolbar-item>button{background:0 0;border:0;color:inherit;font:inherit;line-height:normal;overflow:visible;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}div.code-toolbar>.toolbar>.toolbar-item>a,div.code-toolbar>.toolbar>.toolbar-item>button,div.code-toolbar>.toolbar>.toolbar-item>span{color:#bbb;font-size:.8em;padding:0 .5em;background:#f5f2f0;background:rgba(224,224,224,.2);box-shadow:0 2px 0 0 rgba(0,0,0,.2);border-radius:.5em}div.code-toolbar>.toolbar>.toolbar-item>a:focus,div.code-toolbar>.toolbar>.toolbar-item>a:hover,div.code-toolbar>.toolbar>.toolbar-item>button:focus,div.code-toolbar>.toolbar>.toolbar-item>button:hover,div.code-toolbar>.toolbar>.toolbar-item>span:focus,div.code-toolbar>.toolbar>.toolbar-item>span:hover{color:inherit;text-decoration:none}
|
||||||
|
[class*=lang-] script[type='text/plain'],[class*=language-] script[type='text/plain'],script[type='text/plain'][class*=lang-],script[type='text/plain'][class*=language-]{display:block;font:100% Consolas,Monaco,monospace;white-space:pre;overflow:auto}
|
||||||
23
frontend/src/assets/js/prism.js
Normal file
23
frontend/src/assets/js/prism.js
Normal file
File diff suppressed because one or more lines are too long
@@ -8,8 +8,11 @@
|
|||||||
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
|
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<link href="./assets/css/prism.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
<body class="mat-typography">
|
<body class="mat-typography">
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.8/clipboard.min.js"></script>
|
||||||
|
<script type="text/javascript" src="./assets/js/prism.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user