@cgboiler/biz-basic 1.0.2 → 1.0.3

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.1";
8
+ export const version: "1.0.2";
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.1";
2
+ const version = "1.0.2";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -8,7 +8,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
8
8
  type: StringConstructor;
9
9
  default: string;
10
10
  };
11
- }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
11
+ onMentionTriggered: {
12
+ type: FunctionConstructor;
13
+ };
14
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mention-triggered" | "update:modelValue")[], "mention-triggered" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
12
15
  modelValue: {
13
16
  type: StringConstructor;
14
17
  default: string;
@@ -17,10 +20,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
17
20
  type: StringConstructor;
18
21
  default: string;
19
22
  };
23
+ onMentionTriggered: {
24
+ type: FunctionConstructor;
25
+ };
20
26
  }>> & Readonly<{
27
+ "onMention-triggered"?: ((...args: any[]) => any) | undefined;
21
28
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
22
29
  }>, {
23
- modelValue: string;
24
30
  placeholder: string;
31
+ modelValue: string;
25
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
33
  export default _default;
@@ -1,60 +1,25 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import "./_atomic.css";
3
3
  import { defineComponent, onMounted, onBeforeUnmount, ref, watch } from "vue";
4
- import StarterKit from "@tiptap/starter-kit";
5
4
  import { Editor, EditorContent } from "@tiptap/vue-3";
6
- import { TableKit } from "@tiptap/extension-table";
7
- import { ListKit } from "@tiptap/extension-list";
8
- import Image from "@tiptap/extension-image";
9
- import { Placeholder } from "@tiptap/extensions";
5
+ import { useExtensions } from "./useExtensions";
10
6
  import { richTextEditorProps } from "./types";
11
7
  import "./index.css";
12
8
  var stdin_default = defineComponent({
13
9
  name: "RichTextEditor",
14
10
  props: richTextEditorProps,
15
- emits: ["update:modelValue"],
11
+ emits: ["update:modelValue", "mention-triggered"],
16
12
  setup(props, {
17
13
  emit
18
14
  }) {
19
15
  const editor = ref();
16
+ const extensions = useExtensions({
17
+ props,
18
+ emit
19
+ });
20
20
  const initEditor = () => {
21
21
  editor.value = new Editor({
22
- extensions: [StarterKit, ListKit.extend({
23
- addKeyboardShortcuts() {
24
- return {
25
- Tab: ({
26
- editor: editor2
27
- }) => {
28
- const {
29
- $from
30
- } = editor2.state.selection;
31
- const currentItem = $from.node(-1);
32
- if (currentItem.type.name === "listItem") {
33
- return true;
34
- }
35
- return false;
36
- },
37
- "Shift-Tab": ({
38
- editor: editor2
39
- }) => {
40
- const {
41
- $from
42
- } = editor2.state.selection;
43
- const currentItem = $from.node(-1);
44
- if (currentItem.type.name === "doc") {
45
- return true;
46
- }
47
- return false;
48
- }
49
- };
50
- }
51
- }), Image, TableKit.configure({
52
- table: {
53
- resizable: true
54
- }
55
- }), Placeholder.configure({
56
- placeholder: props.placeholder
57
- })],
22
+ extensions,
58
23
  content: props.modelValue,
59
24
  onUpdate: ({
60
25
  editor: editor2
@@ -30,5 +30,3 @@
30
30
  flex-wrap: wrap;
31
31
  }
32
32
 
33
- /* layer: default */
34
- .cgx-atm .table{display:table;}
@@ -1 +1 @@
1
- .ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
1
+ .ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.ProseMirror .mention{color:#c02537;padding:0 .3em}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
@@ -201,6 +201,11 @@
201
201
  img {
202
202
  max-width: 100%;
203
203
  }
204
+ // @人的样式
205
+ .mention {
206
+ color: #c02537;
207
+ padding: 0 0.3em;
208
+ }
204
209
  }
205
210
 
206
211
  // animation
@@ -1,4 +1,8 @@
1
1
  import { ExtractPropTypes } from 'vue';
2
+ export interface MentionData {
3
+ userId: string;
4
+ name: string;
5
+ }
2
6
  export declare const richTextEditorProps: {
3
7
  modelValue: {
4
8
  type: StringConstructor;
@@ -8,5 +12,10 @@ export declare const richTextEditorProps: {
8
12
  type: StringConstructor;
9
13
  default: string;
10
14
  };
15
+ onMentionTriggered: {
16
+ type: FunctionConstructor;
17
+ };
18
+ };
19
+ export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps> & {
20
+ onMentionTriggered?: () => void;
11
21
  };
12
- export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps>;
@@ -6,6 +6,9 @@ const richTextEditorProps = {
6
6
  placeholder: {
7
7
  type: String,
8
8
  default: "\u8BF7\u5199\u70B9\u4EC0\u4E48..."
9
+ },
10
+ onMentionTriggered: {
11
+ type: Function
9
12
  }
10
13
  };
11
14
  export {
@@ -0,0 +1,5 @@
1
+ export interface MentionData {
2
+ name: string;
3
+ userId: string;
4
+ }
5
+ export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
@@ -0,0 +1,67 @@
1
+ import StarterKit from "@tiptap/starter-kit";
2
+ import { TableKit } from "@tiptap/extension-table";
3
+ import { ListKit } from "@tiptap/extension-list";
4
+ import Image from "@tiptap/extension-image";
5
+ import Mention from "@tiptap/extension-mention";
6
+ import { Placeholder } from "@tiptap/extensions";
7
+ function useExtensions({ props, emit }) {
8
+ const extensions = [
9
+ StarterKit,
10
+ Image,
11
+ TableKit.configure({
12
+ table: { resizable: true }
13
+ }),
14
+ Placeholder.configure({
15
+ placeholder: props.placeholder
16
+ }),
17
+ ListKit.extend({
18
+ addKeyboardShortcuts() {
19
+ return {
20
+ Tab: ({ editor }) => {
21
+ const { $from } = editor.state.selection;
22
+ const currentItem = $from.node(-1);
23
+ if (currentItem.type.name === "listItem") {
24
+ return true;
25
+ }
26
+ return false;
27
+ },
28
+ "Shift-Tab": ({ editor }) => {
29
+ const { $from } = editor.state.selection;
30
+ const currentItem = $from.node(-1);
31
+ if (currentItem.type.name === "doc") {
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ };
37
+ }
38
+ }),
39
+ Mention.configure({
40
+ HTMLAttributes: {
41
+ class: "mention"
42
+ },
43
+ deleteTriggerWithBackspace: true,
44
+ suggestion: {
45
+ char: "@",
46
+ allowedPrefixes: null,
47
+ // 允许任何前缀
48
+ render() {
49
+ return {
50
+ onStart({ command }) {
51
+ emit("mention-triggered", (data) => {
52
+ command({
53
+ id: data.userId,
54
+ label: data.name
55
+ });
56
+ });
57
+ }
58
+ };
59
+ }
60
+ }
61
+ })
62
+ ];
63
+ return extensions;
64
+ }
65
+ export {
66
+ useExtensions
67
+ };
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.1";
8
+ export const version: "1.0.2";
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.1";
39
+ const version = "1.0.2";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -8,7 +8,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
8
8
  type: StringConstructor;
9
9
  default: string;
10
10
  };
11
- }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
11
+ onMentionTriggered: {
12
+ type: FunctionConstructor;
13
+ };
14
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mention-triggered" | "update:modelValue")[], "mention-triggered" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
12
15
  modelValue: {
13
16
  type: StringConstructor;
14
17
  default: string;
@@ -17,10 +20,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
17
20
  type: StringConstructor;
18
21
  default: string;
19
22
  };
23
+ onMentionTriggered: {
24
+ type: FunctionConstructor;
25
+ };
20
26
  }>> & Readonly<{
27
+ "onMention-triggered"?: ((...args: any[]) => any) | undefined;
21
28
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
22
29
  }>, {
23
- modelValue: string;
24
30
  placeholder: string;
31
+ modelValue: string;
25
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
33
  export default _default;
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
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
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
  var stdin_exports = {};
29
19
  __export(stdin_exports, {
@@ -33,60 +23,25 @@ module.exports = __toCommonJS(stdin_exports);
33
23
  var import_vue = require("vue");
34
24
  var import_atomic = require("./_atomic.css");
35
25
  var import_vue2 = require("vue");
36
- var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
37
26
  var import_vue_3 = require("@tiptap/vue-3");
38
- var import_extension_table = require("@tiptap/extension-table");
39
- var import_extension_list = require("@tiptap/extension-list");
40
- var import_extension_image = __toESM(require("@tiptap/extension-image"));
41
- var import_extensions = require("@tiptap/extensions");
27
+ var import_useExtensions = require("./useExtensions");
42
28
  var import_types = require("./types");
43
29
  var import_index = require("./index.css");
44
30
  var stdin_default = (0, import_vue2.defineComponent)({
45
31
  name: "RichTextEditor",
46
32
  props: import_types.richTextEditorProps,
47
- emits: ["update:modelValue"],
33
+ emits: ["update:modelValue", "mention-triggered"],
48
34
  setup(props, {
49
35
  emit
50
36
  }) {
51
37
  const editor = (0, import_vue2.ref)();
38
+ const extensions = (0, import_useExtensions.useExtensions)({
39
+ props,
40
+ emit
41
+ });
52
42
  const initEditor = () => {
53
43
  editor.value = new import_vue_3.Editor({
54
- extensions: [import_starter_kit.default, import_extension_list.ListKit.extend({
55
- addKeyboardShortcuts() {
56
- return {
57
- Tab: ({
58
- editor: editor2
59
- }) => {
60
- const {
61
- $from
62
- } = editor2.state.selection;
63
- const currentItem = $from.node(-1);
64
- if (currentItem.type.name === "listItem") {
65
- return true;
66
- }
67
- return false;
68
- },
69
- "Shift-Tab": ({
70
- editor: editor2
71
- }) => {
72
- const {
73
- $from
74
- } = editor2.state.selection;
75
- const currentItem = $from.node(-1);
76
- if (currentItem.type.name === "doc") {
77
- return true;
78
- }
79
- return false;
80
- }
81
- };
82
- }
83
- }), import_extension_image.default, import_extension_table.TableKit.configure({
84
- table: {
85
- resizable: true
86
- }
87
- }), import_extensions.Placeholder.configure({
88
- placeholder: props.placeholder
89
- })],
44
+ extensions,
90
45
  content: props.modelValue,
91
46
  onUpdate: ({
92
47
  editor: editor2
@@ -30,5 +30,3 @@
30
30
  flex-wrap: wrap;
31
31
  }
32
32
 
33
- /* layer: default */
34
- .cgx-atm .table{display:table;}
@@ -1 +1 @@
1
- .ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
1
+ .ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.ProseMirror .mention{color:#c02537;padding:0 .3em}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
@@ -201,6 +201,11 @@
201
201
  img {
202
202
  max-width: 100%;
203
203
  }
204
+ // @人的样式
205
+ .mention {
206
+ color: #c02537;
207
+ padding: 0 0.3em;
208
+ }
204
209
  }
205
210
 
206
211
  // animation
@@ -1,4 +1,8 @@
1
1
  import { ExtractPropTypes } from 'vue';
2
+ export interface MentionData {
3
+ userId: string;
4
+ name: string;
5
+ }
2
6
  export declare const richTextEditorProps: {
3
7
  modelValue: {
4
8
  type: StringConstructor;
@@ -8,5 +12,10 @@ export declare const richTextEditorProps: {
8
12
  type: StringConstructor;
9
13
  default: string;
10
14
  };
15
+ onMentionTriggered: {
16
+ type: FunctionConstructor;
17
+ };
18
+ };
19
+ export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps> & {
20
+ onMentionTriggered?: () => void;
11
21
  };
12
- export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps>;
@@ -28,5 +28,8 @@ const richTextEditorProps = {
28
28
  placeholder: {
29
29
  type: String,
30
30
  default: "\u8BF7\u5199\u70B9\u4EC0\u4E48..."
31
+ },
32
+ onMentionTriggered: {
33
+ type: Function
31
34
  }
32
35
  };
@@ -0,0 +1,5 @@
1
+ export interface MentionData {
2
+ name: string;
3
+ userId: string;
4
+ }
5
+ export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
@@ -0,0 +1,96 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var stdin_exports = {};
29
+ __export(stdin_exports, {
30
+ useExtensions: () => useExtensions
31
+ });
32
+ module.exports = __toCommonJS(stdin_exports);
33
+ var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
34
+ var import_extension_table = require("@tiptap/extension-table");
35
+ var import_extension_list = require("@tiptap/extension-list");
36
+ var import_extension_image = __toESM(require("@tiptap/extension-image"));
37
+ var import_extension_mention = __toESM(require("@tiptap/extension-mention"));
38
+ var import_extensions = require("@tiptap/extensions");
39
+ function useExtensions({ props, emit }) {
40
+ const extensions = [
41
+ import_starter_kit.default,
42
+ import_extension_image.default,
43
+ import_extension_table.TableKit.configure({
44
+ table: { resizable: true }
45
+ }),
46
+ import_extensions.Placeholder.configure({
47
+ placeholder: props.placeholder
48
+ }),
49
+ import_extension_list.ListKit.extend({
50
+ addKeyboardShortcuts() {
51
+ return {
52
+ Tab: ({ editor }) => {
53
+ const { $from } = editor.state.selection;
54
+ const currentItem = $from.node(-1);
55
+ if (currentItem.type.name === "listItem") {
56
+ return true;
57
+ }
58
+ return false;
59
+ },
60
+ "Shift-Tab": ({ editor }) => {
61
+ const { $from } = editor.state.selection;
62
+ const currentItem = $from.node(-1);
63
+ if (currentItem.type.name === "doc") {
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+ };
69
+ }
70
+ }),
71
+ import_extension_mention.default.configure({
72
+ HTMLAttributes: {
73
+ class: "mention"
74
+ },
75
+ deleteTriggerWithBackspace: true,
76
+ suggestion: {
77
+ char: "@",
78
+ allowedPrefixes: null,
79
+ // 允许任何前缀
80
+ render() {
81
+ return {
82
+ onStart({ command }) {
83
+ emit("mention-triggered", (data) => {
84
+ command({
85
+ id: data.userId,
86
+ label: data.name
87
+ });
88
+ });
89
+ }
90
+ };
91
+ }
92
+ }
93
+ })
94
+ ];
95
+ return extensions;
96
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -41,6 +41,7 @@
41
41
  "@tiptap/extension-collaboration": "3.0.0-beta.16",
42
42
  "@tiptap/extension-image": "^3.0.7",
43
43
  "@tiptap/extension-list": "^3.0.7",
44
+ "@tiptap/extension-mention": "^3.0.7",
44
45
  "@tiptap/extension-table": "3.0.0-beta.5",
45
46
  "@tiptap/extensions": "3.0.0-beta.5",
46
47
  "@tiptap/pm": "3.0.0-beta.5",