@whletsgo/editor 0.0.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.
- package/LICENSE +21 -0
- package/dist/cjs/HaoRichEditor/index.d.ts +9 -0
- package/dist/cjs/HaoRichEditor/index.js +80 -0
- package/dist/cjs/HaoRichEditor/index.styled.d.ts +5 -0
- package/dist/cjs/HaoRichEditor/index.styled.js +55 -0
- package/dist/cjs/components/menu-bar/index.d.ts +6 -0
- package/dist/cjs/components/menu-bar/index.js +340 -0
- package/dist/cjs/components/menu-bar/index.styled.d.ts +8 -0
- package/dist/cjs/components/menu-bar/index.styled.js +92 -0
- package/dist/cjs/extensions/video/index.d.ts +24 -0
- package/dist/cjs/extensions/video/index.js +116 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +41 -0
- package/dist/esm/HaoRichEditor/index.d.ts +9 -0
- package/dist/esm/HaoRichEditor/index.js +50 -0
- package/dist/esm/HaoRichEditor/index.styled.d.ts +5 -0
- package/dist/esm/HaoRichEditor/index.styled.js +10 -0
- package/dist/esm/components/menu-bar/index.d.ts +6 -0
- package/dist/esm/components/menu-bar/index.js +362 -0
- package/dist/esm/components/menu-bar/index.styled.d.ts +8 -0
- package/dist/esm/components/menu-bar/index.styled.js +31 -0
- package/dist/esm/extensions/video/index.d.ts +24 -0
- package/dist/esm/extensions/video/index.js +129 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/package.json +39 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const MenuBarContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const MenuBarContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export declare const MenuBarButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
5
|
+
isActive?: boolean | undefined;
|
|
6
|
+
}>> & string;
|
|
7
|
+
export declare const MenuBarInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
8
|
+
export declare const MenuBarColorInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export var MenuBarContainer = styled.div.withConfig({
|
|
3
|
+
displayName: "MenuBarContainer",
|
|
4
|
+
componentId: "editor-9e80__sc-1hhsgpu-0"
|
|
5
|
+
})(["position:sticky;top:0;background-color:#fff;z-index:10;border-bottom:1px solid #e0e0e0;padding:0 10px;"]);
|
|
6
|
+
export var MenuBarContent = styled.div.withConfig({
|
|
7
|
+
displayName: "MenuBarContent",
|
|
8
|
+
componentId: "editor-9e80__sc-1hhsgpu-1"
|
|
9
|
+
})(["display:flex;flex-wrap:wrap;gap:10px;padding:10px 0;"]);
|
|
10
|
+
export var MenuBarButton = styled.button.withConfig({
|
|
11
|
+
displayName: "MenuBarButton",
|
|
12
|
+
componentId: "editor-9e80__sc-1hhsgpu-2"
|
|
13
|
+
})(["position:relative;background-color:", ";padding:6px 10px;cursor:pointer;border-radius:8px;border:none;font-size:12px;color:", ";line-height:1.5;transition:background-color 0.3s ease;user-select:none;&:hover{background-color:", ";}&:active{background-color:", ";}"], function (props) {
|
|
14
|
+
return props.isActive ? '#6a00f5' : '#f0f0f0';
|
|
15
|
+
}, function (props) {
|
|
16
|
+
return props.isActive ? '#fff' : '#110F0E';
|
|
17
|
+
}, function (props) {
|
|
18
|
+
return props.isActive ? '#6a00f5' : '#dadada';
|
|
19
|
+
}, function (props) {
|
|
20
|
+
return props.isActive ? '#5500c5' : '#bbb';
|
|
21
|
+
});
|
|
22
|
+
export var MenuBarInput = styled.input.withConfig({
|
|
23
|
+
displayName: "MenuBarInput",
|
|
24
|
+
componentId: "editor-9e80__sc-1hhsgpu-3"
|
|
25
|
+
})(["position:absolute;opacity:0;inset:0;cursor:pointer;"]);
|
|
26
|
+
|
|
27
|
+
// 颜色选择input
|
|
28
|
+
export var MenuBarColorInput = styled.input.withConfig({
|
|
29
|
+
displayName: "MenuBarColorInput",
|
|
30
|
+
componentId: "editor-9e80__sc-1hhsgpu-4"
|
|
31
|
+
})(["padding:6px 10px;display:block;border-radius:8px;border:none;"]);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface VideoAttributes {
|
|
3
|
+
src: string;
|
|
4
|
+
controls?: boolean;
|
|
5
|
+
autoplay?: boolean;
|
|
6
|
+
loop?: boolean;
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
playsInline?: boolean;
|
|
9
|
+
poster?: string | null;
|
|
10
|
+
preload?: 'auto' | 'metadata' | 'none' | '';
|
|
11
|
+
width?: string | number | null;
|
|
12
|
+
height?: string | number | null;
|
|
13
|
+
}
|
|
14
|
+
export interface VideoOptions {
|
|
15
|
+
HTMLAttributes: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
declare module '@tiptap/core' {
|
|
18
|
+
interface Commands<ReturnType> {
|
|
19
|
+
video: {
|
|
20
|
+
setVideo: (options: VideoAttributes) => ReturnType;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const Video: Node<VideoOptions, any>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
export var Video = Node.create({
|
|
3
|
+
name: 'video',
|
|
4
|
+
group: 'block',
|
|
5
|
+
atom: true,
|
|
6
|
+
selectable: true,
|
|
7
|
+
draggable: true,
|
|
8
|
+
addOptions: function addOptions() {
|
|
9
|
+
return {
|
|
10
|
+
HTMLAttributes: {}
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
addAttributes: function addAttributes() {
|
|
14
|
+
return {
|
|
15
|
+
src: {
|
|
16
|
+
default: null,
|
|
17
|
+
parseHTML: function parseHTML(element) {
|
|
18
|
+
var _element$querySelecto;
|
|
19
|
+
return element.getAttribute('src') || ((_element$querySelecto = element.querySelector('source')) === null || _element$querySelecto === void 0 ? void 0 : _element$querySelecto.getAttribute('src'));
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
controls: {
|
|
23
|
+
default: true,
|
|
24
|
+
parseHTML: function parseHTML(element) {
|
|
25
|
+
return element.hasAttribute('controls');
|
|
26
|
+
},
|
|
27
|
+
renderHTML: function renderHTML(attributes) {
|
|
28
|
+
return attributes.controls ? {
|
|
29
|
+
controls: ''
|
|
30
|
+
} : {};
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
autoplay: {
|
|
34
|
+
default: false,
|
|
35
|
+
parseHTML: function parseHTML(element) {
|
|
36
|
+
return element.hasAttribute('autoplay');
|
|
37
|
+
},
|
|
38
|
+
renderHTML: function renderHTML(attributes) {
|
|
39
|
+
return attributes.autoplay ? {
|
|
40
|
+
autoplay: ''
|
|
41
|
+
} : {};
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
loop: {
|
|
45
|
+
default: false,
|
|
46
|
+
parseHTML: function parseHTML(element) {
|
|
47
|
+
return element.hasAttribute('loop');
|
|
48
|
+
},
|
|
49
|
+
renderHTML: function renderHTML(attributes) {
|
|
50
|
+
return attributes.loop ? {
|
|
51
|
+
loop: ''
|
|
52
|
+
} : {};
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
muted: {
|
|
56
|
+
default: false,
|
|
57
|
+
parseHTML: function parseHTML(element) {
|
|
58
|
+
return element.hasAttribute('muted');
|
|
59
|
+
},
|
|
60
|
+
renderHTML: function renderHTML(attributes) {
|
|
61
|
+
return attributes.muted ? {
|
|
62
|
+
muted: ''
|
|
63
|
+
} : {};
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
playsInline: {
|
|
67
|
+
default: true,
|
|
68
|
+
parseHTML: function parseHTML(element) {
|
|
69
|
+
return element.hasAttribute('playsinline');
|
|
70
|
+
},
|
|
71
|
+
renderHTML: function renderHTML(attributes) {
|
|
72
|
+
return attributes.playsInline ? {
|
|
73
|
+
playsinline: ''
|
|
74
|
+
} : {};
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
poster: {
|
|
78
|
+
default: null,
|
|
79
|
+
parseHTML: function parseHTML(element) {
|
|
80
|
+
return element.getAttribute('poster');
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
preload: {
|
|
84
|
+
default: 'metadata',
|
|
85
|
+
parseHTML: function parseHTML(element) {
|
|
86
|
+
return element.getAttribute('preload');
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
width: {
|
|
90
|
+
default: null,
|
|
91
|
+
parseHTML: function parseHTML(element) {
|
|
92
|
+
return element.getAttribute('width');
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
height: {
|
|
96
|
+
default: null,
|
|
97
|
+
parseHTML: function parseHTML(element) {
|
|
98
|
+
return element.getAttribute('height');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
parseHTML: function parseHTML() {
|
|
104
|
+
return [{
|
|
105
|
+
tag: 'video'
|
|
106
|
+
}];
|
|
107
|
+
},
|
|
108
|
+
renderHTML: function renderHTML(_ref) {
|
|
109
|
+
var HTMLAttributes = _ref.HTMLAttributes;
|
|
110
|
+
return ['video', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
111
|
+
},
|
|
112
|
+
addCommands: function addCommands() {
|
|
113
|
+
var _this = this;
|
|
114
|
+
return {
|
|
115
|
+
setVideo: function setVideo(options) {
|
|
116
|
+
return function (_ref2) {
|
|
117
|
+
var commands = _ref2.commands;
|
|
118
|
+
if (!(options !== null && options !== void 0 && options.src)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return commands.insertContent({
|
|
122
|
+
type: _this.name,
|
|
123
|
+
attrs: options
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@whletsgo/editor",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "富文本编辑器组件",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@tiptap/core": "^3.20.5",
|
|
13
|
+
"@tiptap/extension-image": "^3.15.3",
|
|
14
|
+
"@tiptap/extension-text-align": "^3.15.3",
|
|
15
|
+
"@tiptap/extension-text-style": "^3.15.3",
|
|
16
|
+
"@tiptap/pm": "^3.15.3",
|
|
17
|
+
"@tiptap/react": "^3.15.3",
|
|
18
|
+
"@tiptap/starter-kit": "^3.15.3",
|
|
19
|
+
"styled-components": "^6.3.6"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=16.9.0",
|
|
23
|
+
"react-dom": ">=16.9.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"authors": [
|
|
29
|
+
"27276971@qq.com"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^25.0.8"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "father build",
|
|
37
|
+
"build:watch": "father dev"
|
|
38
|
+
}
|
|
39
|
+
}
|