@cgboiler/biz-basic 1.0.24 → 1.0.26

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.
package/es/index.d.ts CHANGED
@@ -5,6 +5,6 @@ declare namespace _default {
5
5
  }
6
6
  export default _default;
7
7
  export function install(app: any): void;
8
- export const version: "1.0.23";
8
+ export const version: "1.0.25";
9
9
  import RichTextEditor from './rich-text-editor';
10
10
  export { RichTextEditor };
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import RichTextEditor from "./rich-text-editor";
2
- const version = "1.0.23";
2
+ const version = "1.0.25";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -1,3 +1,4 @@
1
+ import "viewerjs/dist/viewer.css";
1
2
  import './index.less';
2
3
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
4
  modelValue: {
@@ -1,7 +1,9 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import "./_atomic.css";
3
- import { defineComponent, onMounted, onBeforeUnmount, ref, watch } from "vue";
3
+ import { defineComponent, onMounted, onBeforeUnmount, ref, watch, nextTick } from "vue";
4
4
  import { Editor, EditorContent } from "@tiptap/vue-3";
5
+ import Viewer from "viewerjs";
6
+ import "viewerjs/dist/viewer.css";
5
7
  import { useExtensions } from "./useExtensions";
6
8
  import { richTextEditorProps } from "./types";
7
9
  import "./index.css";
@@ -87,12 +89,52 @@ var stdin_default = defineComponent({
87
89
  isFocusFromPlaceholder = false;
88
90
  }, 100);
89
91
  });
92
+ const viewerRef = ref(null);
93
+ const imageClickHandler = (event) => {
94
+ const target = event.target;
95
+ if (target.tagName === "IMG") {
96
+ if (viewerRef.value) {
97
+ viewerRef.value.destroy();
98
+ }
99
+ viewerRef.value = new Viewer(target, {
100
+ inline: false,
101
+ navbar: true,
102
+ title: true,
103
+ toolbar: {
104
+ zoomIn: true,
105
+ zoomOut: true,
106
+ oneToOne: true,
107
+ reset: true,
108
+ prev: false,
109
+ next: false,
110
+ rotateLeft: true,
111
+ rotateRight: true,
112
+ flipHorizontal: true,
113
+ flipVertical: true
114
+ }
115
+ });
116
+ viewerRef.value.show();
117
+ event.stopPropagation();
118
+ event.preventDefault();
119
+ }
120
+ };
90
121
  onMounted(() => {
91
122
  initEditor();
123
+ nextTick(() => {
124
+ var _a, _b;
125
+ const editorElement = (_b = (_a = editor.value) == null ? void 0 : _a.view) == null ? void 0 : _b.dom;
126
+ if (editorElement) {
127
+ editorElement.addEventListener("click", imageClickHandler);
128
+ }
129
+ });
92
130
  });
93
131
  onBeforeUnmount(() => {
94
- var _a;
95
- (_a = editor.value) == null ? void 0 : _a.destroy();
132
+ var _a, _b, _c;
133
+ const editorElement = (_b = (_a = editor.value) == null ? void 0 : _a.view) == null ? void 0 : _b.dom;
134
+ if (editorElement) {
135
+ editorElement.removeEventListener("click", imageClickHandler);
136
+ }
137
+ (_c = editor.value) == null ? void 0 : _c.destroy();
96
138
  });
97
139
  return () => _createVNode(EditorContent, {
98
140
  "class": "ProseMirror",
@@ -31,4 +31,5 @@
31
31
  }
32
32
 
33
33
  /* layer: default */
34
+ .cgx-atm .inline{display:inline;}
34
35
  .cgx-atm .blur{--un-blur:blur(8px);filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}
@@ -1,2 +1,2 @@
1
1
  import { Extension } from '@tiptap/core';
2
- export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | Extension<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
2
+ export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
@@ -6,14 +6,56 @@ import Mention from "@tiptap/extension-mention";
6
6
  import { TextStyle } from "@tiptap/extension-text-style";
7
7
  import { Color } from "@tiptap/extension-color";
8
8
  import { Markdown } from "tiptap-markdown";
9
- import { Extension } from "@tiptap/core";
10
- import { InputRule } from "@tiptap/core";
9
+ import { Extension, InputRule } from "@tiptap/core";
11
10
  import HtmlBlock from "./extensions/HtmlBlock";
12
11
  import { Placeholder } from "@tiptap/extensions";
13
12
  function useExtensions({ props, emit }) {
14
13
  const extensions = [
15
14
  StarterKit,
16
15
  HtmlBlock,
16
+ // Video input rule extension for !video(url) syntax
17
+ Extension.create({
18
+ name: "videoInputRule",
19
+ addInputRules() {
20
+ return [
21
+ new InputRule({
22
+ find: /!video\(([^)]+)\)\s/,
23
+ handler: ({ state, range, match, commands }) => {
24
+ const [, url] = match;
25
+ if (url) {
26
+ const html = `<video src="${url}" autoplay="" loop="" muted="" controls="" playsinline=""></video>`;
27
+ commands.deleteRange(range);
28
+ commands.insertContent({
29
+ type: "htmlBlock",
30
+ attrs: { html }
31
+ });
32
+ }
33
+ }
34
+ })
35
+ ];
36
+ }
37
+ }),
38
+ Extension.create({
39
+ name: "audioInputRule",
40
+ addInputRules() {
41
+ return [
42
+ new InputRule({
43
+ find: /!audio\(([^)]+)\)\s/,
44
+ handler: ({ state, range, match, commands }) => {
45
+ const [, url] = match;
46
+ if (url) {
47
+ const html = `<audio src="${url}" controls="" playsinline=""></audio>`;
48
+ commands.deleteRange(range);
49
+ commands.insertContent({
50
+ type: "htmlBlock",
51
+ attrs: { html }
52
+ });
53
+ }
54
+ }
55
+ })
56
+ ];
57
+ }
58
+ }),
17
59
  // TextStyle 是 Color 的依赖,必须添加
18
60
  TextStyle.configure({
19
61
  // 如果你还想支持其他 style 属性,可以在这里配置
package/lib/index.d.ts CHANGED
@@ -5,6 +5,6 @@ declare namespace _default {
5
5
  }
6
6
  export default _default;
7
7
  export function install(app: any): void;
8
- export const version: "1.0.23";
8
+ export const version: "1.0.25";
9
9
  import RichTextEditor from './rich-text-editor';
10
10
  export { RichTextEditor };
package/lib/index.js CHANGED
@@ -36,7 +36,7 @@ __export(stdin_exports, {
36
36
  module.exports = __toCommonJS(stdin_exports);
37
37
  var import_rich_text_editor = __toESM(require("./rich-text-editor"));
38
38
  __reExport(stdin_exports, require("./rich-text-editor"), module.exports);
39
- const version = "1.0.23";
39
+ const version = "1.0.25";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -1,3 +1,4 @@
1
+ import "viewerjs/dist/viewer.css";
1
2
  import './index.less';
2
3
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
4
  modelValue: {
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
  var stdin_exports = {};
19
29
  __export(stdin_exports, {
@@ -24,6 +34,8 @@ var import_vue = require("vue");
24
34
  var import_atomic = require("./_atomic.css");
25
35
  var import_vue2 = require("vue");
26
36
  var import_vue_3 = require("@tiptap/vue-3");
37
+ var import_viewerjs = __toESM(require("viewerjs"));
38
+ var import_viewer = require("viewerjs/dist/viewer.css");
27
39
  var import_useExtensions = require("./useExtensions");
28
40
  var import_types = require("./types");
29
41
  var import_index = require("./index.css");
@@ -109,12 +121,52 @@ var stdin_default = (0, import_vue2.defineComponent)({
109
121
  isFocusFromPlaceholder = false;
110
122
  }, 100);
111
123
  });
124
+ const viewerRef = (0, import_vue2.ref)(null);
125
+ const imageClickHandler = (event) => {
126
+ const target = event.target;
127
+ if (target.tagName === "IMG") {
128
+ if (viewerRef.value) {
129
+ viewerRef.value.destroy();
130
+ }
131
+ viewerRef.value = new import_viewerjs.default(target, {
132
+ inline: false,
133
+ navbar: true,
134
+ title: true,
135
+ toolbar: {
136
+ zoomIn: true,
137
+ zoomOut: true,
138
+ oneToOne: true,
139
+ reset: true,
140
+ prev: false,
141
+ next: false,
142
+ rotateLeft: true,
143
+ rotateRight: true,
144
+ flipHorizontal: true,
145
+ flipVertical: true
146
+ }
147
+ });
148
+ viewerRef.value.show();
149
+ event.stopPropagation();
150
+ event.preventDefault();
151
+ }
152
+ };
112
153
  (0, import_vue2.onMounted)(() => {
113
154
  initEditor();
155
+ (0, import_vue2.nextTick)(() => {
156
+ var _a, _b;
157
+ const editorElement = (_b = (_a = editor.value) == null ? void 0 : _a.view) == null ? void 0 : _b.dom;
158
+ if (editorElement) {
159
+ editorElement.addEventListener("click", imageClickHandler);
160
+ }
161
+ });
114
162
  });
115
163
  (0, import_vue2.onBeforeUnmount)(() => {
116
- var _a;
117
- (_a = editor.value) == null ? void 0 : _a.destroy();
164
+ var _a, _b, _c;
165
+ const editorElement = (_b = (_a = editor.value) == null ? void 0 : _a.view) == null ? void 0 : _b.dom;
166
+ if (editorElement) {
167
+ editorElement.removeEventListener("click", imageClickHandler);
168
+ }
169
+ (_c = editor.value) == null ? void 0 : _c.destroy();
118
170
  });
119
171
  return () => (0, import_vue.createVNode)(import_vue_3.EditorContent, {
120
172
  "class": "ProseMirror",
@@ -31,4 +31,5 @@
31
31
  }
32
32
 
33
33
  /* layer: default */
34
+ .cgx-atm .inline{display:inline;}
34
35
  .cgx-atm .blur{--un-blur:blur(8px);filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}
@@ -1,2 +1,2 @@
1
1
  import { Extension } from '@tiptap/core';
2
- export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | Extension<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
2
+ export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
@@ -39,13 +39,55 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
39
39
  var import_extension_color = require("@tiptap/extension-color");
40
40
  var import_tiptap_markdown = require("tiptap-markdown");
41
41
  var import_core = require("@tiptap/core");
42
- var import_core2 = require("@tiptap/core");
43
42
  var import_HtmlBlock = __toESM(require("./extensions/HtmlBlock"));
44
43
  var import_extensions = require("@tiptap/extensions");
45
44
  function useExtensions({ props, emit }) {
46
45
  const extensions = [
47
46
  import_starter_kit.default,
48
47
  import_HtmlBlock.default,
48
+ // Video input rule extension for !video(url) syntax
49
+ import_core.Extension.create({
50
+ name: "videoInputRule",
51
+ addInputRules() {
52
+ return [
53
+ new import_core.InputRule({
54
+ find: /!video\(([^)]+)\)\s/,
55
+ handler: ({ state, range, match, commands }) => {
56
+ const [, url] = match;
57
+ if (url) {
58
+ const html = `<video src="${url}" autoplay="" loop="" muted="" controls="" playsinline=""></video>`;
59
+ commands.deleteRange(range);
60
+ commands.insertContent({
61
+ type: "htmlBlock",
62
+ attrs: { html }
63
+ });
64
+ }
65
+ }
66
+ })
67
+ ];
68
+ }
69
+ }),
70
+ import_core.Extension.create({
71
+ name: "audioInputRule",
72
+ addInputRules() {
73
+ return [
74
+ new import_core.InputRule({
75
+ find: /!audio\(([^)]+)\)\s/,
76
+ handler: ({ state, range, match, commands }) => {
77
+ const [, url] = match;
78
+ if (url) {
79
+ const html = `<audio src="${url}" controls="" playsinline=""></audio>`;
80
+ commands.deleteRange(range);
81
+ commands.insertContent({
82
+ type: "htmlBlock",
83
+ attrs: { html }
84
+ });
85
+ }
86
+ }
87
+ })
88
+ ];
89
+ }
90
+ }),
49
91
  // TextStyle 是 Color 的依赖,必须添加
50
92
  import_extension_text_style.TextStyle.configure({
51
93
  // 如果你还想支持其他 style 属性,可以在这里配置
@@ -69,7 +111,7 @@ function useExtensions({ props, emit }) {
69
111
  name: "markdownLinkInputRule",
70
112
  addInputRules() {
71
113
  return [
72
- new import_core2.InputRule({
114
+ new import_core.InputRule({
73
115
  find: /\[([^\]]+)\]\(([^\)]+)\)\s/,
74
116
  handler: ({ state, range, match, commands }) => {
75
117
  const [, text, href] = match;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -51,7 +51,8 @@
51
51
  "@tiptap/pm": "3.3.0",
52
52
  "@tiptap/starter-kit": "3.3.0",
53
53
  "@tiptap/vue-3": "3.3.0",
54
- "tiptap-markdown": "^0.8.10"
54
+ "tiptap-markdown": "^0.8.10",
55
+ "viewerjs": "^1.11.7"
55
56
  },
56
57
  "browserslist": [
57
58
  "Chrome >= 51",