diff --git a/services/web/frontend/js/highlight.js b/services/web/frontend/js/highlight.js new file mode 100644 index 0000000000..472c50dc32 --- /dev/null +++ b/services/web/frontend/js/highlight.js @@ -0,0 +1,5 @@ +// Entry point that bundles highlight.js with common languages for the +// Open in Overleaf documentation page. Exposes window.hljs. +import hljs from 'highlight.js/lib/common' + +window.hljs = hljs diff --git a/services/web/frontend/js/vendor/libs/sharejs.js b/services/web/frontend/js/vendor/libs/sharejs.js index 1749e61e6d..5229935e22 100644 --- a/services/web/frontend/js/vendor/libs/sharejs.js +++ b/services/web/frontend/js/vendor/libs/sharejs.js @@ -1,3 +1,16 @@ +/** + * ShareJS client v0.5.0 + * https://github.com/josephg/ShareJS + * + * Copyright (c) 2011-2014 Joseph Gentle + * Licensed under the MIT License + * SPDX-License-Identifier: MIT + * + * This file was transpiled from CoffeeScript and adapted for the + * Overleaf frontend. See https://github.com/overleaf/internal/issues/25227 + * for provenance details. + */ + import { generateSHA1Hash } from '../../shared/utils/sha1' import { debugging, debugConsole } from '@/utils/debugging' import getMeta from '@/utils/meta' diff --git a/services/web/package.json b/services/web/package.json index 78ebed859e..df7f283574 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -139,6 +139,7 @@ "form-data": "^4.0.5", "globby": "^5.0.0", "helmet": "^6.0.1", + "highlight.js": "11.11.1", "https-proxy-agent": "^7.0.6", "i18next": "^23.10.0", "jose": "^4.3.8", diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index d7eb9a9470..35c9c40819 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -23,6 +23,7 @@ const entryPoints = { 'main-style': './frontend/stylesheets/main-style.scss', tracking: './frontend/js/infrastructure/tracking.ts', 'linkedin-insight': './frontend/js/infrastructure/linkedin-insight.ts', + highlight: './frontend/js/highlight.js', } // Add entrypoints for each "page" @@ -63,6 +64,7 @@ const mathjaxDir = getModuleDirectory('mathjax') const pdfjsDir = getModuleDirectory('pdfjs-dist') const dictionariesDir = getModuleDirectory('@overleaf/dictionaries') const pyodideDir = getModuleDirectory('pyodide') +const highlightJsDir = getModuleDirectory('highlight.js') const vendorDir = path.join(__dirname, 'frontend/js/vendor') @@ -425,6 +427,13 @@ module.exports = { toType: 'dir', context: pyodideDir, }, + // Copy highlight.js stylesheet for the Open in Overleaf documentation page + { + from: 'styles/github.min.css', + to: 'js/libs/highlight.js/github.min.css', + toType: 'file', + context: highlightJsDir, + }, // Copy CMap files (used to provide support for non-Latin characters), // wasm, ICC profiles, fonts and images from pdfjs-dist package to build output. { diff --git a/yarn.lock b/yarn.lock index 5533881dbf..571b4fd90d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7644,6 +7644,7 @@ __metadata: handlebars: "npm:^4.7.9" handlebars-loader: "npm:^1.7.3" helmet: "npm:^6.0.1" + highlight.js: "npm:11.11.1" html-webpack-plugin: "npm:^5.6.7" https-proxy-agent: "npm:^7.0.6" i18next: "npm:^23.10.0" @@ -20689,6 +20690,13 @@ __metadata: languageName: node linkType: hard +"highlight.js@npm:11.11.1": + version: 11.11.1 + resolution: "highlight.js@npm:11.11.1" + checksum: 10c0/40f53ac19dac079891fcefd5bd8a21cf2e8931fd47da5bd1dca73b7e4375c1defed0636fc39120c639b9c44119b7d110f7f0c15aa899557a5a1c8910f3c0144c + languageName: node + linkType: hard + "highlight.js@npm:^10.4.1, highlight.js@npm:~10.7.0": version: 10.7.3 resolution: "highlight.js@npm:10.7.3"