forked from simov/markdown-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add domino to vendor and fix turndown package
- Loading branch information
Showing
8 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# set current working directory to directory of the shell script | ||
cd "$(dirname "$0")" | ||
|
||
# before | ||
npm ci 2> /dev/null || npm i | ||
mkdir -p tmp | ||
|
||
# domino.min.js | ||
npx rollup --config rollup.mjs --input domino.mjs --file tmp/domino.js | ||
npx terser --compress --mangle -- tmp/domino.js > tmp/domino.min.js | ||
|
||
# copy | ||
cp tmp/domino.min.js ../../vendor/ | ||
|
||
# after | ||
rm -rf node_modules/ tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Import necessary modules from the @mixmark-io/domino package | ||
import { createWindow, createDocument } from '@mixmark-io/domino'; | ||
|
||
// Export the modules for use in your project | ||
export { createWindow, createDocument }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"@rollup/plugin-commonjs": "^28.0.1", | ||
"@rollup/plugin-node-resolve": "^15.3.0", | ||
"@mixmark-io/domino": "^2.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
|
||
export default { | ||
input: 'node_modules/@mixmark-io/domino/lib/index.js', | ||
output: { | ||
file: 'tmp/domino.js', | ||
format: 'umd', | ||
name: 'domino' | ||
}, | ||
plugins: [ | ||
commonjs(), | ||
resolve() | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
if (!window.TurndownScript) { | ||
const turndownScript = document.createElement('script'); | ||
turndownScript.src = chrome.runtime.getURL('vendor/turndown/turndown.browser.umd.js'); | ||
document.head.appendChild(turndownScript); | ||
window.TurndownScript = turndownScript; | ||
} | ||
|
||
window.TurndownScript.onload = () => { | ||
const turndownService = new TurndownService(); | ||
const markdown = turndownService.turndown(document.documentElement.outerHTML); | ||
console.log(markdown); | ||
|
||
// Create a new window to display the Markdown | ||
const markdownWindow = window.open('', '_blank'); | ||
markdownWindow.document.write('<pre>' + markdownWindow.document.createTextNode(markdown).textContent + '</pre>'); | ||
}; |