-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 64b43cb
Showing
11 changed files
with
870 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
package-lock.json | ||
|
||
# build | ||
main.js | ||
*.js.map | ||
|
||
# obsidian | ||
data.json |
Large diffs are not rendered by default.
Oops, something went wrong.
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,38 @@ | ||
## Obsidian Print Preview | ||
|
||
This plugin helps theme designers debug export to pdf issues by allowing them to inspect the print results | ||
|
||
### Features | ||
|
||
<img src="imgs/obsidian-print-preview.gif" alt="plugin demo" style="zoom: 67%;" /> | ||
|
||
- Regex functionality added to the default Obsidian search | ||
- Regex also works with Search & Replace | ||
- Capture groups are now supported for replacement | ||
- Use dollar sign references to refer to capture groups: $1 $2 etc | ||
- Support for case-insensitive mode using /foo/i | ||
|
||
### Instructions | ||
|
||
- Export to PDF as you normally would | ||
- After export, the rendered print window will show up overlaid on top of your workspace | ||
- You can now use the Dev Tools inspector to check the styling of the printed content | ||
- To dismiss the print window, left click anywhere in the workspace | ||
|
||
### FAQ | ||
|
||
- My PDF doesn't look like the print preview | ||
- Make sure to set "Emulate CSS media type" to "print" in chrome (see the demo video for details) | ||
- I dismissed the print preview and now my Obisidian screen is blank | ||
- Make sure to turn "Emulate CSS media type" back to "no emulation" as the default Obsidian theme hides all UI elements in print media mode. | ||
|
||
### Not currently supported | ||
|
||
- Viewing the preview prior to PDF creation | ||
- The preview will only be visible after export has completed. | ||
- Downscale support | ||
- Currently the preview will show at 100% despite the % specified in the downscale setting | ||
|
||
### Manually installing the plugin | ||
|
||
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/obsidian-print-preview/`. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
{ | ||
"id": "obsidian-print-preview", | ||
"name": "Print Preview", | ||
"version": "0.0.1", | ||
"minAppVersion": "0.9.12", | ||
"description": "This plugin helps theme designers debug export to pdf issues by allowing them to inspect the print results", | ||
"author": "NothingIsLost", | ||
"authorUrl": "https://github.com/nothingislost", | ||
"isDesktopOnly": true | ||
} |
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,24 @@ | ||
{ | ||
"name": "obsidian-print-preview", | ||
"version": "0.0.1", | ||
"description": "This plugin helps theme designers debug export to pdf issues by allowing them to inspect the print results", | ||
"main": "main.js", | ||
"scripts": { | ||
"dev": "rollup --config rollup.config.js -w", | ||
"build": "rollup --config rollup.config.js --environment BUILD:production" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^18.0.0", | ||
"@rollup/plugin-node-resolve": "^11.2.1", | ||
"@rollup/plugin-typescript": "^8.2.1", | ||
"@types/node": "^14.14.37", | ||
"obsidian": "^0.12.0", | ||
"rollup": "^2.32.1", | ||
"rollup-plugin-copy": "^3.3.0", | ||
"tslib": "^2.2.0", | ||
"typescript": "^4.2.4" | ||
} | ||
} |
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,37 @@ | ||
import typescript from '@rollup/plugin-typescript'; | ||
import {nodeResolve} from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import copy from 'rollup-plugin-copy'; | ||
|
||
const isProd = (process.env.BUILD === 'production'); | ||
|
||
const banner = | ||
`/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP | ||
if you want to view the source visit the plugins github repository | ||
*/ | ||
`; | ||
|
||
export default { | ||
input: './src/main.ts', | ||
output: { | ||
dir: './dist/', | ||
sourcemap: 'inline', | ||
sourcemapExcludeSources: isProd, | ||
format: 'cjs', | ||
exports: 'default', | ||
banner, | ||
}, | ||
external: ['obsidian'], | ||
plugins: [ | ||
typescript(), | ||
nodeResolve({browser: true}), | ||
commonjs(), | ||
copy({ | ||
targets: [ | ||
{ src: 'manifest.json', dest: './dist/' }, | ||
{ src: 'styles.css', dest: './dist/' } | ||
], flatten: true | ||
}) | ||
] | ||
}; |
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,25 @@ | ||
import { Plugin } from "obsidian"; | ||
|
||
export default class PrintPreview extends Plugin { | ||
private observer: MutationObserver; | ||
|
||
onload() { | ||
const bodyEl = document.querySelector("body") | ||
this.observer = new MutationObserver((mutations, observer) => { | ||
mutations.forEach((mutation) => { | ||
mutation.removedNodes.forEach((nodeEl) => { | ||
if ((nodeEl as HTMLElement).className == 'print') { | ||
(nodeEl as HTMLElement).addClass('print-preview'); | ||
// (nodeEl as HTMLElement).querySelector(".markdown-preview-view").addClass('markdown-preview-section') | ||
bodyEl.appendChild(nodeEl); | ||
} | ||
}); | ||
}); | ||
}); | ||
this.observer.observe(bodyEl, { childList: true, subtree: false }) | ||
} | ||
|
||
onunload() { | ||
this.observer.disconnect() | ||
} | ||
} |
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,23 @@ | ||
.print-preview .markdown-preview-view { | ||
margin: auto; | ||
width: 50rem; /* this appears to be the static width of the PDF output */ | ||
z-index: 1; | ||
background-color: white; | ||
} | ||
|
||
.print-preview { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
bottom: 0; | ||
right: 0; | ||
z-index: 1; | ||
overflow: scroll; | ||
background-color: var(--background-primary); | ||
} | ||
|
||
@media print { | ||
* { | ||
-webkit-print-color-adjust: exact; | ||
} | ||
} |
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,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"module": "ESNext", | ||
"target": "es6", | ||
"allowJs": true, | ||
"noImplicitAny": true, | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"lib": [ | ||
"dom", | ||
"es5", | ||
"scripthost", | ||
"es2015" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts" | ||
] | ||
} |
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,3 @@ | ||
{ | ||
"0.0.1": "0.9.12" | ||
} |