More printing improvements
This commit is contained in:
parent
1ee90ad49b
commit
fefec71495
4 changed files with 87 additions and 48 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "front",
|
"name": "Chattypub",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<section :class="['content', currentStream]">
|
<section id="content" :class="['content', currentStream]">
|
||||||
<h1 class="title">{{ currentStream.replace("pub-", "") }}</h1>
|
<h1 class="title">{{ currentStream.replace("pub-", "") }}</h1>
|
||||||
<Chapter
|
<Chapter
|
||||||
v-for="topic in sortedTopics"
|
v-for="topic in sortedTopics"
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,29 @@
|
||||||
<template>
|
<template>
|
||||||
<section class="streams">
|
<section class="streams">
|
||||||
<!-- <p class="title">{{ $.type.name }}</p> -->
|
<!-- <p class="title">{{ $.type.name }}</p> -->
|
||||||
<Stream
|
<Stream v-for="stream in streams" :key="stream.id" :stream="stream" />
|
||||||
v-for="stream in streams"
|
|
||||||
:key="stream.id"
|
|
||||||
:stream="stream"
|
|
||||||
/>
|
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from "vuex";
|
||||||
import Stream from './Stream'
|
import Stream from "./Stream";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Streams',
|
name: "Streams",
|
||||||
components: {
|
components: {
|
||||||
Stream
|
Stream,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState(["streams"]),
|
||||||
'streams',
|
},
|
||||||
])
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.streams {
|
.streams {
|
||||||
min-width: 10em;
|
min-width: 10em;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
margin-bottom: 1em;
|
||||||
@media print {
|
|
||||||
.streams { display: none; }
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -3,27 +3,48 @@
|
||||||
<button v-if="!show_ui" @click="toggle_ui" class="float-btn ui">
|
<button v-if="!show_ui" @click="toggle_ui" class="float-btn ui">
|
||||||
{{ show_ui ? "Hide" : "Show" }} UI
|
{{ show_ui ? "Hide" : "Show" }} UI
|
||||||
</button>
|
</button>
|
||||||
<splitpanes class="default-theme">
|
<splitpanes class="default-theme" @resize="resizer">
|
||||||
<pane v-if="show_ui" size="10" min-size="5" @resize="resizer">
|
<pane
|
||||||
|
class="controls-pane"
|
||||||
|
v-if="show_ui"
|
||||||
|
:size="panel_sizes[0]"
|
||||||
|
min-size="5"
|
||||||
|
>
|
||||||
<Streams />
|
<Streams />
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button @click="toggle_ui">{{ show_ui ? "Hide" : "Show" }} UI</button>
|
<button @click="toggle_ui">{{ show_ui ? "Hide" : "Show" }} UI</button>
|
||||||
<button @click="print">Print</button>
|
<button @click="print">Print</button>
|
||||||
<input
|
<!-- <button @click="print_preview">Preview</button> -->
|
||||||
|
<label for="msg-data"
|
||||||
|
><input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="msg-data"
|
id="msg-data"
|
||||||
value="1"
|
value="1"
|
||||||
v-model="show_message_data"
|
v-model="show_message_data"
|
||||||
/>
|
/>
|
||||||
<label for="msg-data">Show chat message data</label>
|
Show chat message data</label
|
||||||
|
>
|
||||||
|
<p class="notice">
|
||||||
|
Regrettably support for
|
||||||
|
<a href="https://caniuse.com/css-paged-media">@page</a> is very poor
|
||||||
|
in most browsers. Use Google Chrome for best results when printing
|
||||||
|
or creating PDFs.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</pane>
|
</pane>
|
||||||
<pane size="55">
|
<pane :size="panel_sizes[1]">
|
||||||
<Content :print="!show_ui" :show_message_data="show_message_data" />
|
<Content
|
||||||
|
:print="!show_ui || expand_content"
|
||||||
|
:show_message_data="show_message_data"
|
||||||
|
ref="content"
|
||||||
|
/>
|
||||||
</pane>
|
</pane>
|
||||||
<pane v-if="show_ui" size="35" min-size="15">
|
<pane v-if="show_ui" :size="panel_sizes[2]" min-size="15">
|
||||||
<Rules />
|
<Rules />
|
||||||
</pane>
|
</pane>
|
||||||
|
<!-- <pane v-if="show_ui" size="35" min-size="15"
|
||||||
|
><div ref="preview"></div>
|
||||||
|
</pane> -->
|
||||||
</splitpanes>
|
</splitpanes>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -38,6 +59,8 @@ import { Splitpanes, Pane } from "splitpanes";
|
||||||
import "splitpanes/dist/splitpanes.css";
|
import "splitpanes/dist/splitpanes.css";
|
||||||
import { Previewer } from "pagedjs";
|
import { Previewer } from "pagedjs";
|
||||||
|
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Home",
|
name: "Home",
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -47,11 +70,22 @@ export default {
|
||||||
Splitpanes,
|
Splitpanes,
|
||||||
Pane,
|
Pane,
|
||||||
},
|
},
|
||||||
|
setup() {
|
||||||
|
const preview = ref(null);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
console.log("preview", preview.value); // <div>This is a root element</div>
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
preview,
|
||||||
|
};
|
||||||
|
},
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
show_ui: true,
|
show_ui: true,
|
||||||
show_message_data: false,
|
show_message_data: false,
|
||||||
panel_sizes: { 0: 10, 1: 55, 2: 35 },
|
panel_sizes: { 0: 10, 1: 55, 2: 35 },
|
||||||
|
expand_content: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -60,28 +94,33 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resizer(e, i) {
|
resizer(panels) {
|
||||||
console.log(e, i);
|
for (let i = 0; i < panels.length; i++) {
|
||||||
|
this.panel_sizes[i] = panels[i].size;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
print() {
|
print() {
|
||||||
// let prev = this.show_ui;
|
let prev = this.show_ui;
|
||||||
this.toggle_ui(null, false);
|
this.toggle_ui(null, false);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.print();
|
window.print();
|
||||||
// if (prev) this.toggle_ui(null, true);
|
if (prev) this.toggle_ui(null, true);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
},
|
||||||
|
print_preview() {
|
||||||
|
this.expand_content = true;
|
||||||
|
let content = document.getElementById("content");
|
||||||
let paged = new Previewer();
|
let paged = new Previewer();
|
||||||
console.log(paged);
|
paged
|
||||||
// let flow = paged
|
.preview(content, ["path/to/css/file.css"], this.preview)
|
||||||
// .preview(DOMContent, ["path/to/css/file.css"], document.body)
|
.then((flow) => {
|
||||||
// .then((flow) => {
|
console.log("Rendered", flow.total, "pages.");
|
||||||
// console.log("Rendered", flow.total, "pages.");
|
});
|
||||||
// });
|
|
||||||
// console.log(flow);
|
|
||||||
},
|
},
|
||||||
toggle_ui(evt, state) {
|
toggle_ui(evt, state) {
|
||||||
if (state !== undefined) this.show_ui = state;
|
if (state !== undefined) this.show_ui = state;
|
||||||
else this.show_ui = !this.show_ui;
|
else this.show_ui = !this.show_ui;
|
||||||
|
this.$forceUpdate();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -95,11 +134,18 @@ export default {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
.controls-pane {
|
||||||
|
background-color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
.splitpanes--vertical .splitpanes__pane {
|
.splitpanes--vertical .splitpanes__pane {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.splitpanes.default-theme .splitpanes__pane {
|
||||||
|
background-color: unset;
|
||||||
|
}
|
||||||
|
|
||||||
.pane-wrapper {
|
.pane-wrapper {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
@ -107,6 +153,7 @@ export default {
|
||||||
.controls {
|
.controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print .pane-wrapper {
|
.print .pane-wrapper {
|
||||||
|
|
@ -129,12 +176,12 @@ export default {
|
||||||
|
|
||||||
.print .body {
|
.print .body {
|
||||||
page-break-after: always;
|
page-break-after: always;
|
||||||
border-bottom: 3px dotted green;
|
/* border-bottom: 3px dotted green; */
|
||||||
}
|
}
|
||||||
.print .body:first-of-type {
|
/* .print .body:first-of-type {
|
||||||
page-break-after: always;
|
page-break-after: always;
|
||||||
border-bottom: 3px dotted yellow;
|
border-bottom: 3px dotted yellow;
|
||||||
}
|
} */
|
||||||
|
|
||||||
.float-btn {
|
.float-btn {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue