@cgboiler/biz-basic 1.0.69 → 1.0.70
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 +1 -1
- package/es/index.js +1 -1
- package/es/rich-text-editor/RichTextEditor.js +3 -0
- package/es/rich-text-editor/index.css +1 -1
- package/es/rich-text-editor/menu-system/components/_atomic.css +2 -0
- package/es/rich-text-editor/menu-system/components/text-color-button.d.ts +70 -0
- package/es/rich-text-editor/menu-system/components/text-color-button.js +128 -0
- package/es/rich-text-editor/menu-system/components/text-color-popover.d.ts +32 -0
- package/es/rich-text-editor/menu-system/components/text-color-popover.js +127 -0
- package/es/rich-text-editor/menu-system/hooks/use-text-color.d.ts +45 -0
- package/es/rich-text-editor/menu-system/hooks/use-text-color.js +152 -0
- package/es/rich-text-editor/menu-system/icons/index.d.ts +13 -0
- package/es/rich-text-editor/menu-system/icons/index.js +22 -0
- package/es/rich-text-editor/menu-system/styles/button-group.css +1 -1
- package/es/rich-text-editor/menu-system/styles/button.css +1 -1
- package/es/rich-text-editor/menu-system/styles/card.css +1 -1
- package/es/rich-text-editor/menu-system/styles/color-highlight-button.css +1 -1
- package/es/rich-text-editor/menu-system/styles/color-highlight-popover.css +1 -1
- package/es/rich-text-editor/menu-system/styles/dropdown-menu.css +1 -1
- package/es/rich-text-editor/menu-system/styles/image-upload-node.css +1 -1
- package/es/rich-text-editor/menu-system/styles/input.css +1 -1
- package/es/rich-text-editor/menu-system/styles/link-popover.css +1 -1
- package/es/rich-text-editor/menu-system/styles/separator.css +1 -1
- package/es/rich-text-editor/menu-system/styles/simple-editor.css +1 -1
- package/es/rich-text-editor/menu-system/styles/text-color-button.css +1 -0
- package/es/rich-text-editor/menu-system/styles/text-color-button.less +63 -0
- package/es/rich-text-editor/menu-system/styles/text-color-popover.css +1 -0
- package/es/rich-text-editor/menu-system/styles/text-color-popover.less +125 -0
- package/es/rich-text-editor/menu-system/styles/toolbar.css +1 -1
- package/es/rich-text-editor/menu-system/styles/variables.css +1 -1
- package/es/rich-text-editor/menu-system/styles/variables.less +4 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/RichTextEditor.js +3 -0
- package/lib/rich-text-editor/index.css +1 -1
- package/lib/rich-text-editor/menu-system/components/_atomic.css +2 -0
- package/lib/rich-text-editor/menu-system/components/text-color-button.d.ts +70 -0
- package/lib/rich-text-editor/menu-system/components/text-color-button.js +145 -0
- package/lib/rich-text-editor/menu-system/components/text-color-popover.d.ts +32 -0
- package/lib/rich-text-editor/menu-system/components/text-color-popover.js +146 -0
- package/lib/rich-text-editor/menu-system/hooks/use-text-color.d.ts +45 -0
- package/lib/rich-text-editor/menu-system/hooks/use-text-color.js +171 -0
- package/lib/rich-text-editor/menu-system/icons/index.d.ts +13 -0
- package/lib/rich-text-editor/menu-system/icons/index.js +22 -0
- package/lib/rich-text-editor/menu-system/styles/button-group.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/button.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/card.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/color-highlight-button.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/color-highlight-popover.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/dropdown-menu.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/image-upload-node.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/input.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/link-popover.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/separator.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/simple-editor.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/text-color-button.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/text-color-button.less +63 -0
- package/lib/rich-text-editor/menu-system/styles/text-color-popover.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/text-color-popover.less +125 -0
- package/lib/rich-text-editor/menu-system/styles/toolbar.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/variables.css +1 -1
- package/lib/rich-text-editor/menu-system/styles/variables.less +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import '../styles/text-color-button.less';
|
|
3
|
+
export declare const TextColorButton: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
editor: {
|
|
5
|
+
type: PropType<any>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
textColor: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
label: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
hideWhenUnavailable: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
className: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
onApplied: {
|
|
25
|
+
type: PropType<(params: {
|
|
26
|
+
color: string;
|
|
27
|
+
label: string;
|
|
28
|
+
}) => void>;
|
|
29
|
+
};
|
|
30
|
+
isDefault: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
35
|
+
editor: {
|
|
36
|
+
type: PropType<any>;
|
|
37
|
+
required: true;
|
|
38
|
+
};
|
|
39
|
+
textColor: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
label: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
hideWhenUnavailable: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
default: boolean;
|
|
50
|
+
};
|
|
51
|
+
className: {
|
|
52
|
+
type: StringConstructor;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
55
|
+
onApplied: {
|
|
56
|
+
type: PropType<(params: {
|
|
57
|
+
color: string;
|
|
58
|
+
label: string;
|
|
59
|
+
}) => void>;
|
|
60
|
+
};
|
|
61
|
+
isDefault: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
}>> & Readonly<{}>, {
|
|
66
|
+
label: string;
|
|
67
|
+
className: string;
|
|
68
|
+
hideWhenUnavailable: boolean;
|
|
69
|
+
isDefault: boolean;
|
|
70
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
var stdin_exports = {};
|
|
36
|
+
__export(stdin_exports, {
|
|
37
|
+
TextColorButton: () => TextColorButton
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
40
|
+
var import_vue = require("vue");
|
|
41
|
+
var import_atomic = require("./_atomic.css");
|
|
42
|
+
var import_vue2 = require("vue");
|
|
43
|
+
var import_use_text_color = require("../hooks/use-text-color");
|
|
44
|
+
var import_button = require("../primitives/button");
|
|
45
|
+
var import_tiptap_utils = require("../utils/tiptap-utils");
|
|
46
|
+
var import_text_color_button = require("../styles/text-color-button.css");
|
|
47
|
+
const TextColorButton = (0, import_vue2.defineComponent)({
|
|
48
|
+
name: "TextColorButton",
|
|
49
|
+
props: {
|
|
50
|
+
editor: {
|
|
51
|
+
type: Object,
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
textColor: {
|
|
55
|
+
type: String,
|
|
56
|
+
required: true
|
|
57
|
+
},
|
|
58
|
+
label: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: ""
|
|
61
|
+
},
|
|
62
|
+
hideWhenUnavailable: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
66
|
+
className: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: ""
|
|
69
|
+
},
|
|
70
|
+
onApplied: {
|
|
71
|
+
type: Function
|
|
72
|
+
},
|
|
73
|
+
isDefault: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
setup(props, {
|
|
79
|
+
attrs
|
|
80
|
+
}) {
|
|
81
|
+
const {
|
|
82
|
+
isVisible,
|
|
83
|
+
canColor,
|
|
84
|
+
isActive
|
|
85
|
+
} = (0, import_use_text_color.useTextColor)({
|
|
86
|
+
editor: props.editor,
|
|
87
|
+
textColor: props.textColor,
|
|
88
|
+
label: props.label,
|
|
89
|
+
hideWhenUnavailable: props.hideWhenUnavailable
|
|
90
|
+
});
|
|
91
|
+
const handleClick = () => {
|
|
92
|
+
const editor = props.editor && "value" in props.editor ? props.editor.value : props.editor;
|
|
93
|
+
if (!editor || !canColor.value)
|
|
94
|
+
return;
|
|
95
|
+
if (props.isDefault) {
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
var _a;
|
|
98
|
+
editor.chain().focus().unsetColor().run();
|
|
99
|
+
(_a = props.onApplied) == null ? void 0 : _a.call(props, {
|
|
100
|
+
color: "",
|
|
101
|
+
label: props.label || "\u9ED8\u8BA4\u989C\u8272"
|
|
102
|
+
});
|
|
103
|
+
}, 0);
|
|
104
|
+
} else {
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
var _a;
|
|
107
|
+
const success = editor.chain().focus().setColor(props.textColor).run();
|
|
108
|
+
if (success) {
|
|
109
|
+
(_a = props.onApplied) == null ? void 0 : _a.call(props, {
|
|
110
|
+
color: props.textColor,
|
|
111
|
+
label: props.label
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, 0);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return () => {
|
|
118
|
+
if (!isVisible.value)
|
|
119
|
+
return null;
|
|
120
|
+
return (0, import_vue.createVNode)(import_button.Button, (0, import_vue.mergeProps)({
|
|
121
|
+
"type": "button",
|
|
122
|
+
"disabled": !canColor.value,
|
|
123
|
+
"data-style": "ghost",
|
|
124
|
+
"data-active-state": isActive.value ? "on" : "off",
|
|
125
|
+
"role": "button",
|
|
126
|
+
"tabindex": -1,
|
|
127
|
+
"aria-label": props.label,
|
|
128
|
+
"aria-pressed": isActive.value,
|
|
129
|
+
"tooltip": props.label,
|
|
130
|
+
"onClick": handleClick,
|
|
131
|
+
"class": (0, import_tiptap_utils.cn)("tiptap-text-color-button", props.className),
|
|
132
|
+
"style": __spreadProps(__spreadValues({}, attrs.style || {}), {
|
|
133
|
+
"--text-color": props.textColor
|
|
134
|
+
})
|
|
135
|
+
}, attrs), {
|
|
136
|
+
default: () => [(0, import_vue.createVNode)("div", {
|
|
137
|
+
"class": (0, import_tiptap_utils.cn)("tiptap-button-text-color", props.isDefault ? "tiptap-button-text-color--default" : ""),
|
|
138
|
+
"style": {
|
|
139
|
+
"--text-color": props.textColor
|
|
140
|
+
}
|
|
141
|
+
}, null)]
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import '../styles/text-color-popover.less';
|
|
3
|
+
export declare const TextColorPopover: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
editor: {
|
|
5
|
+
type: PropType<any>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
hideWhenUnavailable: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
className: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
|
+
editor: {
|
|
18
|
+
type: PropType<any>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
hideWhenUnavailable: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
className: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
}>> & Readonly<{}>, {
|
|
30
|
+
className: string;
|
|
31
|
+
hideWhenUnavailable: boolean;
|
|
32
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
TextColorPopover: () => TextColorPopover
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
var import_vue = require("vue");
|
|
24
|
+
var import_atomic = require("./_atomic.css");
|
|
25
|
+
var import_vue2 = require("vue");
|
|
26
|
+
var import_use_text_color = require("../hooks/use-text-color");
|
|
27
|
+
var import_text_color_button = require("./text-color-button");
|
|
28
|
+
var import_button = require("../primitives/button");
|
|
29
|
+
var import_element_plus = require("element-plus");
|
|
30
|
+
var import_icons = require("../icons");
|
|
31
|
+
var import_tiptap_utils = require("../utils/tiptap-utils");
|
|
32
|
+
var import_text_color_popover = require("../styles/text-color-popover.css");
|
|
33
|
+
const TextColorPopover = (0, import_vue2.defineComponent)({
|
|
34
|
+
name: "TextColorPopover",
|
|
35
|
+
props: {
|
|
36
|
+
editor: {
|
|
37
|
+
type: Object,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
hideWhenUnavailable: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
className: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: ""
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
setup(props, {
|
|
50
|
+
attrs
|
|
51
|
+
}) {
|
|
52
|
+
const {
|
|
53
|
+
isVisible,
|
|
54
|
+
canColor,
|
|
55
|
+
isActive,
|
|
56
|
+
label,
|
|
57
|
+
currentColor,
|
|
58
|
+
handleRemoveColor
|
|
59
|
+
} = (0, import_use_text_color.useTextColor)({
|
|
60
|
+
editor: props.editor,
|
|
61
|
+
hideWhenUnavailable: props.hideWhenUnavailable
|
|
62
|
+
});
|
|
63
|
+
const isOpen = (0, import_vue2.ref)(false);
|
|
64
|
+
const customColor = (0, import_vue2.ref)("#000000");
|
|
65
|
+
const showCustomPicker = (0, import_vue2.ref)(false);
|
|
66
|
+
const getEditor = () => {
|
|
67
|
+
const editor = props.editor;
|
|
68
|
+
return editor && "value" in editor ? editor.value : editor;
|
|
69
|
+
};
|
|
70
|
+
const handleCustomColorChange = (color) => {
|
|
71
|
+
if (!color)
|
|
72
|
+
return;
|
|
73
|
+
customColor.value = color;
|
|
74
|
+
const editor = getEditor();
|
|
75
|
+
if (editor && canColor.value) {
|
|
76
|
+
editor.chain().focus().setColor(color).run();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const handleCustomColorConfirm = () => {
|
|
80
|
+
isOpen.value = false;
|
|
81
|
+
showCustomPicker.value = false;
|
|
82
|
+
};
|
|
83
|
+
return () => {
|
|
84
|
+
if (!isVisible.value)
|
|
85
|
+
return null;
|
|
86
|
+
const activeColor = currentColor.value || "var(--tt-text-default)";
|
|
87
|
+
const trigger = (0, import_vue.createVNode)(import_button.Button, (0, import_vue.mergeProps)({
|
|
88
|
+
"type": "button",
|
|
89
|
+
"disabled": !canColor.value,
|
|
90
|
+
"data-style": "ghost",
|
|
91
|
+
"data-active-state": isActive.value ? "on" : "off",
|
|
92
|
+
"role": "button",
|
|
93
|
+
"tooltip": label,
|
|
94
|
+
"class": (0, import_tiptap_utils.cn)("tiptap-text-color-trigger", props.className)
|
|
95
|
+
}, attrs), {
|
|
96
|
+
default: () => [(0, import_vue.createVNode)(import_icons.TypeIcon, {
|
|
97
|
+
"class": "tiptap-button-icon"
|
|
98
|
+
}, null), (0, import_vue.createVNode)("span", {
|
|
99
|
+
"class": "tiptap-text-color-trigger-bar",
|
|
100
|
+
"style": {
|
|
101
|
+
backgroundColor: activeColor
|
|
102
|
+
}
|
|
103
|
+
}, null)]
|
|
104
|
+
});
|
|
105
|
+
return (0, import_vue.createVNode)(import_element_plus.ElPopover, {
|
|
106
|
+
"trigger": "click",
|
|
107
|
+
"width": "auto",
|
|
108
|
+
"popper-class": "tiptap-text-color-popover",
|
|
109
|
+
"visible": isOpen.value,
|
|
110
|
+
"onUpdate:visible": ($event) => isOpen.value = $event
|
|
111
|
+
}, {
|
|
112
|
+
reference: () => trigger,
|
|
113
|
+
default: () => (0, import_vue.createVNode)("div", {
|
|
114
|
+
"class": "tiptap-text-color-popover-content"
|
|
115
|
+
}, [(0, import_vue.createVNode)("div", {
|
|
116
|
+
"class": "tiptap-text-color-grid"
|
|
117
|
+
}, [import_use_text_color.TEXT_COLORS.filter((c) => !c.isDefault).map((color) => (0, import_vue.createVNode)(import_text_color_button.TextColorButton, {
|
|
118
|
+
"key": color.value,
|
|
119
|
+
"editor": props.editor,
|
|
120
|
+
"textColor": color.value,
|
|
121
|
+
"label": color.label,
|
|
122
|
+
"onApplied": () => {
|
|
123
|
+
isOpen.value = false;
|
|
124
|
+
}
|
|
125
|
+
}, null))]), (0, import_vue.createVNode)("div", {
|
|
126
|
+
"class": "tiptap-text-color-vertical-separator"
|
|
127
|
+
}, null), (0, import_vue.createVNode)("div", {
|
|
128
|
+
"class": "tiptap-text-color-actions"
|
|
129
|
+
}, [(0, import_vue.createVNode)(import_button.Button, {
|
|
130
|
+
"type": "button",
|
|
131
|
+
"data-style": "ghost",
|
|
132
|
+
"onClick": () => {
|
|
133
|
+
handleRemoveColor();
|
|
134
|
+
isOpen.value = false;
|
|
135
|
+
},
|
|
136
|
+
"tooltip": "\u79FB\u9664\u6587\u5B57\u989C\u8272",
|
|
137
|
+
"class": "tiptap-text-color-remove-button"
|
|
138
|
+
}, {
|
|
139
|
+
default: () => [(0, import_vue.createVNode)(import_icons.BanIcon, {
|
|
140
|
+
"class": "tiptap-button-icon"
|
|
141
|
+
}, null)]
|
|
142
|
+
})])])
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
2
|
+
export declare const TEXT_COLORS: ({
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
isDefault: boolean;
|
|
6
|
+
} | {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
isDefault?: undefined;
|
|
10
|
+
})[];
|
|
11
|
+
export type TextColor = (typeof TEXT_COLORS)[number];
|
|
12
|
+
export declare function canSetTextColor(editor: Editor | null): boolean;
|
|
13
|
+
export declare function isTextColorActive(editor: Editor | null, color?: string): boolean;
|
|
14
|
+
export declare function removeTextColor(editor: Editor | null): boolean;
|
|
15
|
+
export declare function useTextColor(config: {
|
|
16
|
+
editor: any;
|
|
17
|
+
textColor?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
hideWhenUnavailable?: boolean;
|
|
20
|
+
onApplied?: (params: {
|
|
21
|
+
color: string;
|
|
22
|
+
label: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
}): {
|
|
25
|
+
isVisible: import("vue").Ref<boolean, boolean>;
|
|
26
|
+
isActive: import("vue").Ref<boolean, boolean>;
|
|
27
|
+
canColor: import("vue").Ref<boolean, boolean>;
|
|
28
|
+
currentColor: import("vue").Ref<string, string>;
|
|
29
|
+
handleSetColor: (color: string, colorLabel: string) => void;
|
|
30
|
+
handleRemoveColor: () => void;
|
|
31
|
+
label: string;
|
|
32
|
+
Icon: import("vue").Raw<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
33
|
+
className: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
default: string;
|
|
36
|
+
};
|
|
37
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
38
|
+
className: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
}>> & Readonly<{}>, {
|
|
43
|
+
className: string;
|
|
44
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
TEXT_COLORS: () => TEXT_COLORS,
|
|
21
|
+
canSetTextColor: () => canSetTextColor,
|
|
22
|
+
isTextColorActive: () => isTextColorActive,
|
|
23
|
+
removeTextColor: () => removeTextColor,
|
|
24
|
+
useTextColor: () => useTextColor
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
27
|
+
var import_vue = require("vue");
|
|
28
|
+
var import_tiptap_utils = require("../utils/tiptap-utils");
|
|
29
|
+
var import_icons = require("../icons");
|
|
30
|
+
const TEXT_COLORS = [
|
|
31
|
+
{
|
|
32
|
+
label: "\u9ED8\u8BA4\u989C\u8272",
|
|
33
|
+
value: "var(--tt-text-default)",
|
|
34
|
+
isDefault: true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "\u7EA2\u8272",
|
|
38
|
+
value: "var(--tt-color-text-red)"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "\u9ED8\u8BA4\u989C\u8272",
|
|
42
|
+
value: "var(--tt-text-default)"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "\u7070\u8272",
|
|
46
|
+
value: "var(--tt-color-text-gray)"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: "\u68D5\u8272",
|
|
50
|
+
value: "var(--tt-color-text-brown)"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "\u6A59\u8272",
|
|
54
|
+
value: "var(--tt-color-text-orange)"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "\u9EC4\u8272",
|
|
58
|
+
value: "var(--tt-color-text-yellow)"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "\u7EFF\u8272",
|
|
62
|
+
value: "var(--tt-color-text-green)"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "\u84DD\u8272",
|
|
66
|
+
value: "var(--tt-color-text-blue)"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: "\u7D2B\u8272",
|
|
70
|
+
value: "var(--tt-color-text-purple)"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: "\u7C89\u8272",
|
|
74
|
+
value: "var(--tt-color-text-pink)"
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
function canSetTextColor(editor) {
|
|
78
|
+
if (!editor || !editor.isEditable)
|
|
79
|
+
return false;
|
|
80
|
+
if ((0, import_tiptap_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
81
|
+
return false;
|
|
82
|
+
return editor.can().setMark("textStyle");
|
|
83
|
+
}
|
|
84
|
+
function isTextColorActive(editor, color) {
|
|
85
|
+
if (!editor || !editor.isEditable)
|
|
86
|
+
return false;
|
|
87
|
+
if (color) {
|
|
88
|
+
return editor.isActive("textStyle", { color });
|
|
89
|
+
}
|
|
90
|
+
return editor.isActive("textStyle");
|
|
91
|
+
}
|
|
92
|
+
function removeTextColor(editor) {
|
|
93
|
+
if (!editor || !editor.isEditable)
|
|
94
|
+
return false;
|
|
95
|
+
return editor.chain().focus().unsetColor().run();
|
|
96
|
+
}
|
|
97
|
+
function useTextColor(config) {
|
|
98
|
+
const { textColor, label, hideWhenUnavailable = false, onApplied } = config;
|
|
99
|
+
const isVisible = (0, import_vue.ref)(true);
|
|
100
|
+
const isActive = (0, import_vue.ref)(false);
|
|
101
|
+
const canColor = (0, import_vue.ref)(false);
|
|
102
|
+
const currentColor = (0, import_vue.ref)("");
|
|
103
|
+
const getEditor = () => {
|
|
104
|
+
const editor = config.editor;
|
|
105
|
+
return editor && "value" in editor ? editor.value : editor;
|
|
106
|
+
};
|
|
107
|
+
const updateState = () => {
|
|
108
|
+
const editor = getEditor();
|
|
109
|
+
if (!editor || !editor.isEditable) {
|
|
110
|
+
isVisible.value = false;
|
|
111
|
+
isActive.value = false;
|
|
112
|
+
canColor.value = false;
|
|
113
|
+
currentColor.value = "";
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
isActive.value = isTextColorActive(editor, textColor);
|
|
117
|
+
canColor.value = canSetTextColor(editor);
|
|
118
|
+
if (!(0, import_tiptap_utils.isMarkInSchema)("textStyle", editor)) {
|
|
119
|
+
isVisible.value = false;
|
|
120
|
+
} else if (hideWhenUnavailable) {
|
|
121
|
+
isVisible.value = canColor.value;
|
|
122
|
+
} else {
|
|
123
|
+
isVisible.value = true;
|
|
124
|
+
}
|
|
125
|
+
const attrs = editor.getAttributes("textStyle");
|
|
126
|
+
currentColor.value = (attrs == null ? void 0 : attrs.color) || "";
|
|
127
|
+
};
|
|
128
|
+
(0, import_vue.watch)(
|
|
129
|
+
() => getEditor(),
|
|
130
|
+
(editor) => {
|
|
131
|
+
if (!editor)
|
|
132
|
+
return;
|
|
133
|
+
updateState();
|
|
134
|
+
editor.on("selectionUpdate", updateState);
|
|
135
|
+
editor.on("transaction", updateState);
|
|
136
|
+
(0, import_vue.onBeforeUnmount)(() => {
|
|
137
|
+
editor.off("selectionUpdate", updateState);
|
|
138
|
+
editor.off("transaction", updateState);
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
{ immediate: true }
|
|
142
|
+
);
|
|
143
|
+
const handleSetColor = (color, colorLabel) => {
|
|
144
|
+
const editor = getEditor();
|
|
145
|
+
if (!editor || !canColor.value)
|
|
146
|
+
return;
|
|
147
|
+
setTimeout(() => {
|
|
148
|
+
const success = editor.chain().focus().setColor(color).run();
|
|
149
|
+
if (success) {
|
|
150
|
+
onApplied == null ? void 0 : onApplied({ color, label: colorLabel });
|
|
151
|
+
}
|
|
152
|
+
}, 0);
|
|
153
|
+
};
|
|
154
|
+
const handleRemoveColor = () => {
|
|
155
|
+
const editor = getEditor();
|
|
156
|
+
const success = removeTextColor(editor);
|
|
157
|
+
if (success) {
|
|
158
|
+
onApplied == null ? void 0 : onApplied({ color: "", label: "\u79FB\u9664\u6587\u5B57\u989C\u8272" });
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
isVisible,
|
|
163
|
+
isActive,
|
|
164
|
+
canColor,
|
|
165
|
+
currentColor,
|
|
166
|
+
handleSetColor,
|
|
167
|
+
handleRemoveColor,
|
|
168
|
+
label: label || "\u6587\u5B57\u989C\u8272",
|
|
169
|
+
Icon: (0, import_vue.markRaw)(import_icons.TypeIcon)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -557,3 +557,16 @@ export declare const TableIcon: import("vue").DefineComponent<import("vue").Extr
|
|
|
557
557
|
}>> & Readonly<{}>, {
|
|
558
558
|
className: string;
|
|
559
559
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
560
|
+
export declare const TypeIcon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
561
|
+
className: {
|
|
562
|
+
type: StringConstructor;
|
|
563
|
+
default: string;
|
|
564
|
+
};
|
|
565
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
566
|
+
className: {
|
|
567
|
+
type: StringConstructor;
|
|
568
|
+
default: string;
|
|
569
|
+
};
|
|
570
|
+
}>> & Readonly<{}>, {
|
|
571
|
+
className: string;
|
|
572
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -58,6 +58,7 @@ __export(stdin_exports, {
|
|
|
58
58
|
SuperscriptIcon: () => SuperscriptIcon,
|
|
59
59
|
TableIcon: () => TableIcon,
|
|
60
60
|
TrashIcon: () => TrashIcon,
|
|
61
|
+
TypeIcon: () => TypeIcon,
|
|
61
62
|
UnderlineIcon: () => UnderlineIcon,
|
|
62
63
|
Undo2Icon: () => Undo2Icon
|
|
63
64
|
});
|
|
@@ -530,3 +531,24 @@ const TableIcon = createIcon("TableIcon", (0, import_vue.createVNode)(import_vue
|
|
|
530
531
|
"stroke": "currentColor",
|
|
531
532
|
"stroke-width": "2"
|
|
532
533
|
}, null)]));
|
|
534
|
+
const TypeIcon = createIcon("TypeIcon", (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)("path", {
|
|
535
|
+
"d": "M4 20L9.5 4H14.5L20 20",
|
|
536
|
+
"stroke": "currentColor",
|
|
537
|
+
"stroke-width": "2",
|
|
538
|
+
"stroke-linecap": "round",
|
|
539
|
+
"stroke-linejoin": "round",
|
|
540
|
+
"fill": "none"
|
|
541
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
542
|
+
"d": "M6.5 14H17.5",
|
|
543
|
+
"stroke": "currentColor",
|
|
544
|
+
"stroke-width": "2",
|
|
545
|
+
"stroke-linecap": "round",
|
|
546
|
+
"fill": "none"
|
|
547
|
+
}, null), (0, import_vue.createVNode)("rect", {
|
|
548
|
+
"x": "3",
|
|
549
|
+
"y": "21",
|
|
550
|
+
"width": "18",
|
|
551
|
+
"height": "2.5",
|
|
552
|
+
"rx": "1.25",
|
|
553
|
+
"fill": "currentColor"
|
|
554
|
+
}, null)]));
|