PasteTextPage.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div ref="main" class="main" @click="close">
  3. <div class="mainWindow" @click.stop>
  4. <Window @close="close">
  5. <template slot="header">
  6. Вставьте текст и нажмите
  7. <el-button size="mini" style="font-size: 120%; color: blue" @click="loadBuffer">Загрузить</el-button>
  8. или F2
  9. </template>
  10. <textarea ref="textArea" class="text"></textarea>
  11. </Window>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. //-----------------------------------------------------------------------------
  17. import Vue from 'vue';
  18. import Component from 'vue-class-component';
  19. import Window from '../../../share/Window.vue';
  20. export default @Component({
  21. components: {
  22. Window,
  23. },
  24. })
  25. class PasteTextPage extends Vue {
  26. created() {
  27. }
  28. mounted() {
  29. this.$refs.textArea.focus();
  30. }
  31. loadBuffer() {
  32. this.$emit('load-buffer', {buffer: this.$refs.textArea.value});
  33. this.close();
  34. }
  35. close() {
  36. this.$emit('paste-text-toggle');
  37. }
  38. keyHook(event) {
  39. if (event.type == 'keydown') {
  40. switch (event.code) {
  41. case 'F2':
  42. this.loadBuffer();
  43. break;
  44. case 'Escape':
  45. this.close();
  46. break;
  47. }
  48. }
  49. return true;
  50. }
  51. }
  52. //-----------------------------------------------------------------------------
  53. </script>
  54. <style scoped>
  55. .main {
  56. position: absolute;
  57. width: 100%;
  58. height: 100%;
  59. z-index: 40;
  60. display: flex;
  61. flex-direction: column;
  62. justify-content: center;
  63. align-items: center;
  64. }
  65. .mainWindow {
  66. width: 100%;
  67. height: 100%;
  68. display: flex;
  69. }
  70. .text {
  71. flex: 1;
  72. overflow-wrap: anywhere;
  73. overflow-y: auto;
  74. padding: 0 10px 0 10px;
  75. position: relative;
  76. font-size: 120%;
  77. }
  78. .text:focus {
  79. outline: none;
  80. }
  81. </style>