-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: print templates, slide layers and rewrite export function #1513
Closed
Closed
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7f03f74
feat: custom page templates
KermanX 1c237df
rewrite notes page
KermanX 604bee4
fix: overview style
KermanX ef9c67c
feat: implement print template
KermanX 0c235e9
feat: implement entry template
KermanX 0f6c200
Merge branch 'main' into feat/custom-pages
KermanX 8cf763c
fix: print styles
KermanX 6d326db
fix: warnings
KermanX 05e7b7a
fix: e2e test
KermanX 98f3bc9
feat: implement slide top & bottom layer
KermanX 3f1dac5
Merge branch 'main' into feat/custom-pages
KermanX 06d2e72
fix: restore id
KermanX 8ff21ca
Merge branch 'main' into feat/custom-pages
KermanX 4ed3e8b
fix
KermanX 5112946
chore: update
KermanX 3b491b3
docs: fix dead link
KermanX 0587c2d
Merge branch 'main' into feat/custom-pages
KermanX cecfced
fix
KermanX 6428d19
Merge branch 'feat/custom-pages' of https://github.com/KermanX/slidev…
KermanX c567e87
Merge branch 'main' into feat/custom-pages
KermanX dec41e1
feat: handout print template (wip)
KermanX 8b8637b
chore: update
KermanX 869da0e
chore: update
KermanX c6c151d
wip: rewrite export function
KermanX 152d6fd
chore: update
KermanX 408f0e3
wip
KermanX 75f0744
Merge branch 'main' into feat/custom-pages
KermanX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,7 @@ | ||
# Custom Print Templates | ||
|
||
You can create custom print templates for your documents via custom print templates. To start, create a new file in the `./pages/print` directory, for example, `./pages/print/my-template.vue`. | ||
|
||
To print your slides using the custom template, use the `--template` option in the CLI, more details in the [exporting guide](/guide/exporting#print-template). | ||
|
||
To debug your print template, you can use the `--print-template` option in dev mode, and access `http://localhost:3030/print?print` to see the print preview. |
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
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,11 @@ | ||
import { useStyleTag } from '@vueuse/core' | ||
import { slideHeight, slideWidth } from '../env' | ||
|
||
export function usePrintStyle() { | ||
return useStyleTag(` | ||
@page { | ||
size: ${slideWidth}px ${slideHeight}px; | ||
margin: 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,38 @@ | ||
import type { Ref } from 'vue' | ||
import { computed } from 'vue' | ||
import { useStyleTag } from '@vueuse/core' | ||
import { slideAspect, slideHeight, slideWidth } from '../env' | ||
import { slideScale } from '../state' | ||
import { useNav } from './useNav' | ||
|
||
export function useSlideScale( | ||
containerSize: { width: Ref<number>, height: Ref<number> }, | ||
expectedWidth?: number, | ||
isMain: boolean = false, | ||
) { | ||
const { isPrintMode } = useNav() | ||
|
||
const width = computed(() => expectedWidth ?? containerSize.width.value) | ||
const height = computed(() => expectedWidth ? expectedWidth / slideAspect.value : containerSize.height.value) | ||
|
||
const scale = computed(() => { | ||
if (slideScale.value && !isPrintMode.value) | ||
return +slideScale.value | ||
return Math.min(width.value / slideWidth.value, height.value / slideHeight.value) | ||
}) | ||
|
||
const style = computed(() => ({ | ||
'height': `${slideHeight.value}px`, | ||
'width': `${slideWidth.value}px`, | ||
'transform': `translate(-50%, -50%) scale(${scale.value})`, | ||
'--slidev-slide-scale': scale.value, | ||
})) | ||
|
||
if (isMain) | ||
useStyleTag(computed(() => `:root { --slidev-slide-scale: ${scale.value}; }`)) | ||
|
||
return { | ||
scale, | ||
style, | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer
--type
with hard-coded options likeslides
notes
handout
- and let ppl to override them instead of creating arbitrary options. Because we might want to do some special handling for each type - over-generalize it might not be ideal for long term.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is OK to allow users to create new print templates. This is because it will be the user/addon's responsibility to handle other options like
--with-clicks
or so. Otherwise, users are forced to override one of the 3 templates even if there is no connection between the default one and the overridden one.About the name of this option, should we change all "print templates" into "print types" or only the CLI flag?