@fishawack/lab-velocity 2.0.0-beta.57 → 2.0.0-beta.58

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.
@@ -417,6 +417,42 @@
417
417
  ></path>
418
418
  </svg>
419
419
  </button>
420
+ <button
421
+ v-if="media"
422
+ type="button"
423
+ @click="openMediaDialog('image')"
424
+ >
425
+ <svg viewBox="0 0 18 18">
426
+ <rect
427
+ class="ql-stroke"
428
+ height="10"
429
+ width="12"
430
+ x="3"
431
+ y="4"
432
+ ></rect>
433
+ <circle class="ql-fill" cx="6" cy="7" r="1"></circle>
434
+ <polyline
435
+ class="ql-even ql-stroke"
436
+ points="5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12"
437
+ ></polyline>
438
+ </svg>
439
+ </button>
440
+ <button
441
+ v-if="media"
442
+ type="button"
443
+ @click="openMediaDialog('video')"
444
+ >
445
+ <svg viewBox="0 0 18 18">
446
+ <rect
447
+ class="ql-stroke"
448
+ height="12"
449
+ width="12"
450
+ x="3"
451
+ y="3"
452
+ ></rect>
453
+ <path class="ql-fill" d="M7,7v4l4-2Z"></path>
454
+ </svg>
455
+ </button>
420
456
  </div>
421
457
  <editor-content :editor="editor" />
422
458
  <el-dialog v-model="dialogVisible" title="URL" width="500">
@@ -431,6 +467,27 @@
431
467
  </div>
432
468
  </template>
433
469
  </el-dialog>
470
+ <el-dialog
471
+ v-model="mediaDialogVisible"
472
+ :title="mediaType === 'image' ? 'Insert Image' : 'Insert Video'"
473
+ width="500"
474
+ >
475
+ <label
476
+ >Enter
477
+ {{ mediaType === "image" ? "image" : "video" }} URL</label
478
+ >
479
+ <el-input v-model="mediaUrl" type="url" placeholder="https://" />
480
+ <template #footer>
481
+ <div class="dialog-footer">
482
+ <el-button @click="mediaDialogVisible = false"
483
+ >Cancel</el-button
484
+ >
485
+ <el-button type="primary" @click="insertMedia">
486
+ Insert
487
+ </el-button>
488
+ </div>
489
+ </template>
490
+ </el-dialog>
434
491
  </XInput>
435
492
  </template>
436
493
 
@@ -456,6 +513,8 @@ import TableRow from "@tiptap/extension-table-row";
456
513
  import Superscript from "@tiptap/extension-superscript";
457
514
  import Subscript from "@tiptap/extension-subscript";
458
515
  import Link from "@tiptap/extension-link";
516
+ import Image from "@tiptap/extension-image";
517
+ import Video from "./wysiwyg2-video.js";
459
518
 
460
519
  export default {
461
520
  mixins: [input],
@@ -476,6 +535,10 @@ export default {
476
535
  type: Boolean,
477
536
  default: false,
478
537
  },
538
+ media: {
539
+ type: Boolean,
540
+ default: false,
541
+ },
479
542
  baseClass: {
480
543
  type: String,
481
544
  default: "vel-wysiwyg",
@@ -488,6 +551,9 @@ export default {
488
551
  previousUrl: null,
489
552
  newUrl: null,
490
553
  dialogVisible: false,
554
+ mediaDialogVisible: false,
555
+ mediaUrl: null,
556
+ mediaType: null,
491
557
  }),
492
558
 
493
559
  watch: {
@@ -536,6 +602,22 @@ export default {
536
602
  .setLink({ href: url })
537
603
  .run();
538
604
  },
605
+ openMediaDialog(type) {
606
+ this.mediaType = type;
607
+ this.mediaUrl = null;
608
+ this.mediaDialogVisible = true;
609
+ },
610
+ insertMedia() {
611
+ this.mediaDialogVisible = false;
612
+ let url = this.mediaUrl;
613
+ if (!url) return;
614
+
615
+ if (this.mediaType === "image") {
616
+ this.editor.chain().focus().setImage({ src: url }).run();
617
+ } else {
618
+ this.editor.chain().focus().setVideo({ src: url }).run();
619
+ }
620
+ },
539
621
  },
540
622
 
541
623
  mounted() {
@@ -559,6 +641,9 @@ export default {
559
641
  TableCell,
560
642
  );
561
643
  }
644
+ if (this.$props.media) {
645
+ extensions.push(Image, Video);
646
+ }
562
647
 
563
648
  this.editor = new Editor({
564
649
  extensions: extensions,
@@ -0,0 +1,41 @@
1
+ import { Node, mergeAttributes } from "@tiptap/core";
2
+
3
+ export default Node.create({
4
+ name: "video",
5
+ group: "block",
6
+ atom: true,
7
+
8
+ addAttributes() {
9
+ return {
10
+ src: { default: null },
11
+ controls: { default: true },
12
+ width: { default: "100%" },
13
+ };
14
+ },
15
+
16
+ parseHTML() {
17
+ return [{ tag: "video" }];
18
+ },
19
+
20
+ renderHTML({ HTMLAttributes }) {
21
+ return [
22
+ "video",
23
+ mergeAttributes(HTMLAttributes, {
24
+ controls: HTMLAttributes.controls ? "" : null,
25
+ }),
26
+ ];
27
+ },
28
+
29
+ addCommands() {
30
+ return {
31
+ setVideo:
32
+ (options) =>
33
+ ({ commands }) => {
34
+ return commands.insertContent({
35
+ type: this.name,
36
+ attrs: options,
37
+ });
38
+ },
39
+ };
40
+ },
41
+ });
@@ -117,6 +117,16 @@
117
117
  a {
118
118
  text-decoration: underline;
119
119
  }
120
+ img,
121
+ video {
122
+ max-width: 100%;
123
+ height: auto;
124
+ border-radius: 4px;
125
+ width: 75%;
126
+ display: block;
127
+ margin: 0 auto;
128
+ margin-bottom: $spacing;
129
+ }
120
130
  }
121
131
 
122
132
  .lab-table,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-velocity",
3
- "version": "2.0.0-beta.57",
3
+ "version": "2.0.0-beta.58",
4
4
  "description": "Avalere Health branded style system",
5
5
  "scripts": {
6
6
  "setup": "npm ci || npm i && npm run content",
@@ -42,6 +42,7 @@
42
42
  "vuex-persistedstate": "^4.1.0"
43
43
  },
44
44
  "dependencies": {
45
+ "@tiptap/extension-image": "^2.27.2",
45
46
  "@tiptap/extension-link": "^2.11.2",
46
47
  "@tiptap/extension-subscript": "^2.11.2",
47
48
  "@tiptap/extension-superscript": "^2.11.2",