renusify 2.3.2 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@
68
68
  <r-icon v-html="$r.icons.delete"></r-icon>
69
69
  </r-btn>
70
70
  <r-img
71
- :src="'/'+img"
71
+ :src="img"
72
72
  alt="img"
73
73
  height="100"></r-img>
74
74
  </div>
@@ -117,6 +117,7 @@
117
117
  :headers="headers"
118
118
  :label="$t('image','renusify')"
119
119
  :size="1"
120
+ :rules="['required']"
120
121
  :upload-link="uploadLink"
121
122
  accept="image/*"></r-file-input>
122
123
  <r-text-input v-model="img_alt"
@@ -124,8 +125,6 @@
124
125
  :rules="['required']"></r-text-input>
125
126
  <r-number-input v-model="img_width" :label="$t('width','renusify')"
126
127
  :rules="['required']"></r-number-input>
127
- <r-number-input v-model="img_height" :label="$t('height','renusify')"
128
- :rules="['required']"></r-number-input>
129
128
  <r-row class="h-end">
130
129
  <r-col class="col-auto">
131
130
  <r-btn class="color-error-text"
@@ -153,6 +152,7 @@
153
152
  :headers="headers"
154
153
  :label="$t('video','renusify')"
155
154
  :size="1"
155
+ :rules="['required']"
156
156
  :upload-link="uploadLink"
157
157
  accept="video/mp4,video/webm"></r-file-input>
158
158
  <r-number-input v-model="img_width" :label="$t('width','renusify')"
@@ -177,16 +177,47 @@
177
177
  </r-container>
178
178
  </r-form>
179
179
  </r-modal>
180
+ <r-modal v-model="showPre"
181
+ :closable="false"
182
+ :closebtn="false">
183
+ <r-form v-model="valid2">
184
+ <r-container>
185
+ <r-text-input :label="$t('name','renusify')" v-model="code_name"></r-text-input>
186
+ <r-select-input v-model="lang" :items="langs"
187
+ :label="$t('lang','renusify')"
188
+ :rules="['required']"
189
+ just-value></r-select-input>
190
+ <r-text-area v-model="code"
191
+ :label="$t('code','renusify')"
192
+ :rules="['required']"
193
+ ltr></r-text-area>
194
+ <div class="text-end my-3">
195
+ <r-btn class="color-error-text"
196
+ outlined
197
+ @click.prevent="showPre=false">{{ $t('cancel', 'renusify') }}
198
+ </r-btn>
199
+ <r-btn :disabled="!valid2"
200
+ class="color-success-text ms-2"
201
+ outlined
202
+ @click.prevent="handlePreForm()">{{ $t('send', 'renusify') }}
203
+ </r-btn>
204
+ </div>
205
+ </r-container>
206
+ </r-form>
207
+ </r-modal>
180
208
 
181
209
  </r-container>
182
210
  </template>
183
211
 
184
212
  <script>
185
213
  import './style.scss'
214
+ import '../../highlight/style.scss'
215
+ import mixin from "../../highlight/mixin";
186
216
 
187
217
  export default {
188
218
  name: 'r-text-editor',
189
219
  inheritAttrs: false,
220
+ mixins: [mixin],
190
221
  props: {
191
222
  uploadLink: {type: String, default: '/storage'},
192
223
  modelValue: {
@@ -221,12 +252,16 @@ export default {
221
252
  preSelected: null,
222
253
  currentPath: [],
223
254
  selectElm: null,
255
+ code_name: null,
256
+ code: '',
257
+ lang: null,
258
+ showPre: false,
259
+ langs: ['asm', 'bash', 'bf', 'c', 'css', 'csv', 'diff', 'docker', 'git', 'go', 'html', 'http', 'ini', 'java', 'js', 'jsdoc', 'json', 'log', 'lua', 'make', 'pl', 'plain', 'py', 'regex', 'rs', 'sql', 'todo', 'toml', 'ts', 'uri', 'xml', 'yaml'],
224
260
  items_undo: {
225
261
  'undo': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88c3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8Z"/></svg>',
226
262
  'redo': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 0 1 7.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6Z"/></svg>',
227
263
  },
228
264
  items_handle: {
229
- 'DIV': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M13 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4h-2v6H9V4h4m0 6a2 2 0 0 0 2-2a2 2 0 0 0-2-2h-2v4h2Z"/></svg>',
230
265
  'insertDIV': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M4 6v13h16V6H4m14 11H6V8h12v9Z"/></svg>',
231
266
  'insertLINE': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M9 7h2v8h4v2H9V7m3-5a10 10 0 0 1 10 10a10 10 0 0 1-10 10A10 10 0 0 1 2 12A10 10 0 0 1 12 2m0 2a8 8 0 0 0-8 8a8 8 0 0 0 8 8a8 8 0 0 0 8-8a8 8 0 0 0-8-8Z"/></svg>',
232
267
  'BLOCKQUOTE': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M14 17h3l2-4V7h-6v6h3M6 17h3l2-4V7H5v6h3l-2 4Z"/></svg>',
@@ -320,7 +355,7 @@ export default {
320
355
  document.execCommand('enableInlineTableEditing', false, true);
321
356
  document.execCommand('enableAbsolutePositionEditor', false, true) */
322
357
 
323
- this.format('defaultParagraphSeparator', 'div')
358
+ this.format('defaultParagraphSeparator', '\n')
324
359
  this.element.addEventListener('paste', function (e) {
325
360
  e.preventDefault()
326
361
  const text = (e.originalEvent || e).clipboardData.getData('text/plain')
@@ -421,7 +456,7 @@ export default {
421
456
  let sel = this.getSelection()
422
457
  sel.removeAllRanges()
423
458
  sel.addRange(this.preSelected)
424
- let url = '<img src="/' + this.image[0] + '?w=' + this.img_width + '&h=' + this.img_height + '" alt="' + this.img_alt + '" width="' + this.img_width + '" height="' + this.img_height + '"/>'
459
+ let url = '<img src="' + this.image[0] + '?w=' + this.img_width + '" alt="' + this.img_alt + '" width="' + this.img_width + '" />'
425
460
  this.files.push(this.image[0])
426
461
  document.execCommand('insertHTML', true, url)
427
462
  this.showImg = false
@@ -434,11 +469,28 @@ export default {
434
469
  let sel = this.getSelection()
435
470
  sel.removeAllRanges()
436
471
  sel.addRange(this.preSelected)
437
- let url = '<video controls="1" src="/' + this.video[0] + '" width="' + this.img_width + '" height="' + this.img_height + '"></video>'
472
+ let url = '<video controls="1" src="' + this.video[0] + '" width="' + this.img_width + '" height="' + this.img_height + '"></video>'
438
473
  this.files.push(this.video[0])
439
474
  document.execCommand('insertHTML', true, url)
440
475
  this.showVideo = false
441
476
  },
477
+ async handlePreForm() {
478
+ if (!this.getSelection() || !this.code || !this.lang) {
479
+ this.$toast(this.$t('invalid_data', 'renusify'), {type: 'error'})
480
+ return
481
+ }
482
+ let sel = this.getSelection()
483
+ sel.removeAllRanges()
484
+ sel.addRange(this.preSelected)
485
+ let url = `<div class="${this.$r.prefix}highlight" >`
486
+ if (this.code_name) {
487
+ url += `<div class="highlight-name title-3 font-weight-bold mb-3">${this.code_name}</div>`
488
+ }
489
+
490
+ url += `<div class="highlight-code highlight-lang-${this.lang}">${await this.highlight(this.code, this.lang)}</div></div>`
491
+ document.execCommand('insertHTML', true, url)
492
+ this.showPre = false
493
+ },
442
494
  handleForm() {
443
495
  if (!this.getSelection() || !this.link) {
444
496
  this.$toast(this.$t('invalid_data', 'renusify'), {type: 'error'})
@@ -449,7 +501,7 @@ export default {
449
501
  sel.addRange(this.preSelected)
450
502
  let url = '<a href="' + this.link.trim() + '"'
451
503
  if (this.target) {
452
- url += 'target="_blank"'
504
+ url += 'target="_blank" rel="nofollow"'
453
505
  }
454
506
  if (this.link.startsWith('#')) {
455
507
  url += `id="${this.link.replace('#', '')}"`
@@ -518,6 +570,11 @@ export default {
518
570
  this.target = false
519
571
  this.handleOpen(true)
520
572
  this.show = true
573
+ } else if (e === 'PRE') {
574
+ this.code = ''
575
+ this.lang = null
576
+ this.handleOpen(true)
577
+ this.showPre = true
521
578
  } else if (e === 'insertImage') {
522
579
  this.image = []
523
580
  this.img_alt = null
@@ -51,6 +51,12 @@
51
51
  min-height: 20px;
52
52
  border: 1px solid rgba(150, 150, 150, 0.6);
53
53
  }
54
+
55
+ .r-highlight div {
56
+ min-width: unset;
57
+ min-height: unset;
58
+ border: unset;
59
+ }
54
60
  }
55
61
 
56
62
  .img-holder {
@@ -0,0 +1 @@
1
+ export * as rHighlight from './index.vue'
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <div :class="`${$r.prefix}highlight`" >
3
+ <div class="title-3 font-weight-bold mb-3" :class="{'highlight-name':name}">
4
+ <div class="d-flex v-top">{{name}}
5
+ <r-spacer></r-spacer>
6
+ <r-btn
7
+ icon
8
+ text
9
+ @click.prevent="$helper.copy(src)"
10
+ >
11
+ <r-icon v-html="$r.icons.copy"></r-icon>
12
+ </r-btn>
13
+ </div>
14
+ </div>
15
+ <div :class="`highlight-code highlight-lang-${lang}`" v-html='txt'></div>
16
+ </div>
17
+ </template>
18
+ <script>
19
+ import './style.scss'
20
+ import mixin from "./mixin";
21
+
22
+ export default {
23
+ name: 'highlight',
24
+ mixins: [mixin],
25
+ props: {
26
+ name: String,
27
+ src: String,
28
+ hideLineNumbers: Boolean,
29
+ lang: {
30
+ type: String,
31
+ validator: function (value) {
32
+ return ['asm', 'bash', 'bf', 'c', 'css', 'csv', 'diff', 'docker', 'git', 'go', 'html', 'http', 'ini', 'java', 'js', 'jsdoc', 'json', 'log', 'lua', 'make', 'pl', 'plain', 'py', 'regex', 'rs', 'sql', 'todo', 'toml', 'ts', 'uri', 'xml', 'yaml'].indexOf(value) !== -1
33
+ }
34
+ }
35
+ },
36
+ data() {
37
+ return {
38
+ txt: '',
39
+ }
40
+ },
41
+ async created() {
42
+ this.txt = await this.highlight(this.src, this.lang, this.hideLineNumbers);
43
+ }
44
+ }
45
+ </script>
46
+