@oix1987/yjd 1.0.0 → 1.0.2
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/README.md +73 -22
- package/dist/rich-editor.esm.js +2 -0
- package/dist/rich-editor.esm.js.map +1 -0
- package/dist/rich-editor.min.js +2 -0
- package/dist/rich-editor.min.js.map +1 -0
- package/package.json +12 -7
- package/index.js +0 -221
- package/lib/core/editor.js +0 -1175
- package/lib/core/format.js +0 -542
- package/lib/core/module.js +0 -81
- package/lib/core/registry.js +0 -152
- package/lib/formats/background.js +0 -212
- package/lib/formats/bold.js +0 -67
- package/lib/formats/capitalization.js +0 -563
- package/lib/formats/color.js +0 -165
- package/lib/formats/emoji.js +0 -282
- package/lib/formats/font-family.js +0 -547
- package/lib/formats/heading.js +0 -502
- package/lib/formats/image.js +0 -344
- package/lib/formats/import.js +0 -385
- package/lib/formats/indent.js +0 -297
- package/lib/formats/italic.js +0 -27
- package/lib/formats/line-height.js +0 -558
- package/lib/formats/link.js +0 -251
- package/lib/formats/list.js +0 -635
- package/lib/formats/strike.js +0 -31
- package/lib/formats/subscript.js +0 -36
- package/lib/formats/superscript.js +0 -35
- package/lib/formats/table.js +0 -288
- package/lib/formats/tag.js +0 -304
- package/lib/formats/text-align.js +0 -421
- package/lib/formats/text-size.js +0 -497
- package/lib/formats/underline.js +0 -30
- package/lib/formats/video.js +0 -372
- package/lib/modules/block-toolbar.js +0 -628
- package/lib/modules/code-view.js +0 -434
- package/lib/modules/history.js +0 -410
- package/lib/modules/resize-handles.js +0 -677
- package/lib/modules/table-toolbar.js +0 -618
- package/lib/modules/toolbar.js +0 -424
- package/lib/styles-loader.js +0 -144
- package/lib/styles.css +0 -2123
- package/lib/ui/color-picker.js +0 -296
- package/lib/ui/customselect.js +0 -319
- package/lib/ui/emoji-picker.js +0 -196
- package/lib/ui/icons.js +0 -413
- package/lib/ui/image-popup.js +0 -444
- package/lib/ui/import-popup.js +0 -288
- package/lib/ui/link-popup.js +0 -191
- package/lib/ui/list-picker.js +0 -307
- package/lib/ui/select-button.js +0 -61
- package/lib/ui/table-popup.js +0 -171
- package/lib/ui/tag-popup.js +0 -249
- package/lib/ui/text-align-picker.js +0 -281
- package/lib/ui/video-popup.js +0 -422
- package/lib/utils/history-helper.js +0 -50
- package/lib/utils/popup-helper.js +0 -219
- package/lib/utils/popup-positioning.js +0 -231
package/lib/ui/emoji-picker.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Emoji Picker Component - Popup for selecting emojis
|
|
3
|
-
*/
|
|
4
|
-
import { appendPopup, calculatePopupPosition, setPopupPosition } from '../utils/popup-helper.js';
|
|
5
|
-
|
|
6
|
-
class EmojiPicker {
|
|
7
|
-
constructor(options = {}) {
|
|
8
|
-
this.options = {
|
|
9
|
-
emojis: [
|
|
10
|
-
// Smileys & People
|
|
11
|
-
'😀', '😁', '😂', '🤣', '😃', '😄', '😅', '😆', '😉', '😊',
|
|
12
|
-
'😋', '😎', '😍', '🥰', '😘', '😗', '😙', '😚', '🙂', '🤗',
|
|
13
|
-
'😳', '🥺', '😦', '😧', '😨', '😰', '😥', '😢', '😭', '😱',
|
|
14
|
-
'🤬', '😈', '👿', '💀', '☠️', '💩', '🤡', '👹', '👺', '👻',
|
|
15
|
-
],
|
|
16
|
-
onEmojiSelect: null,
|
|
17
|
-
...options
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
this.popup = null;
|
|
21
|
-
this.isVisible = false;
|
|
22
|
-
this.clickOutsideHandler = null;
|
|
23
|
-
|
|
24
|
-
this.createEmojiPicker();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Detect operating system
|
|
29
|
-
* @returns {string} 'mac' or 'windows'
|
|
30
|
-
*/
|
|
31
|
-
detectOS() {
|
|
32
|
-
const platform = navigator.platform.toLowerCase();
|
|
33
|
-
if (platform.includes('mac')) {
|
|
34
|
-
return 'mac';
|
|
35
|
-
} else if (platform.includes('win')) {
|
|
36
|
-
return 'windows';
|
|
37
|
-
}
|
|
38
|
-
// Default to windows for other platforms
|
|
39
|
-
return 'windows';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get emoji shortcut message based on OS
|
|
44
|
-
* @returns {string} HTML string for the shortcut message
|
|
45
|
-
*/
|
|
46
|
-
getEmojiShortcutMessage() {
|
|
47
|
-
const os = this.detectOS();
|
|
48
|
-
|
|
49
|
-
if (os === 'mac') {
|
|
50
|
-
return `<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">⌘</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">CTRL</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">SPACE</span></div>`;
|
|
51
|
-
} else {
|
|
52
|
-
return `<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">WIN</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">.</span></div>`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Create emoji picker popup
|
|
58
|
-
*/
|
|
59
|
-
createEmojiPicker() {
|
|
60
|
-
// Create popup
|
|
61
|
-
this.popup = document.createElement('div');
|
|
62
|
-
this.popup.className = 'emoji-picker-popup';
|
|
63
|
-
|
|
64
|
-
// Create emoji grid
|
|
65
|
-
this.createEmojiGrid();
|
|
66
|
-
const emojiTextMessage = document.createElement('div');
|
|
67
|
-
emojiTextMessage.className = 'emoji-text-message';
|
|
68
|
-
|
|
69
|
-
emojiTextMessage.innerHTML = this.getEmojiShortcutMessage();
|
|
70
|
-
this.popup.appendChild(emojiTextMessage);
|
|
71
|
-
|
|
72
|
-
// Add popup to container
|
|
73
|
-
appendPopup(this.popup);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Create emoji grid
|
|
78
|
-
*/
|
|
79
|
-
createEmojiGrid() {
|
|
80
|
-
const emojiGrid = document.createElement('div');
|
|
81
|
-
emojiGrid.className = 'emoji-grid';
|
|
82
|
-
|
|
83
|
-
// Create emoji buttons
|
|
84
|
-
this.options.emojis.forEach(emoji => {
|
|
85
|
-
const emojiButton = document.createElement('button');
|
|
86
|
-
emojiButton.type = 'button';
|
|
87
|
-
emojiButton.className = 'emoji-button';
|
|
88
|
-
emojiButton.textContent = emoji;
|
|
89
|
-
emojiButton.title = emoji;
|
|
90
|
-
|
|
91
|
-
emojiButton.addEventListener('click', (e) => {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
this.selectEmoji(emoji);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
emojiGrid.appendChild(emojiButton);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
this.popup.appendChild(emojiGrid);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Setup click outside handler
|
|
105
|
-
*/
|
|
106
|
-
setupClickOutside() {
|
|
107
|
-
if (this.clickOutsideHandler) {
|
|
108
|
-
document.removeEventListener('click', this.clickOutsideHandler);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this.clickOutsideHandler = (e) => {
|
|
112
|
-
if (!this.popup.contains(e.target)) {
|
|
113
|
-
this.hide();
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// Add slight delay to avoid immediate close
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
document.addEventListener('click', this.clickOutsideHandler);
|
|
120
|
-
}, 100);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Remove click outside handler
|
|
125
|
-
*/
|
|
126
|
-
removeClickOutside() {
|
|
127
|
-
if (this.clickOutsideHandler) {
|
|
128
|
-
document.removeEventListener('click', this.clickOutsideHandler);
|
|
129
|
-
this.clickOutsideHandler = null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Show emoji picker popup
|
|
135
|
-
* @param {HTMLElement} anchor - Element to position popup relative to
|
|
136
|
-
*/
|
|
137
|
-
show(anchor) {
|
|
138
|
-
if (!anchor) return;
|
|
139
|
-
|
|
140
|
-
// Ensure popup is in DOM
|
|
141
|
-
if (!document.body.contains(this.popup)) {
|
|
142
|
-
appendPopup(this.popup);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Calculate and set popup position
|
|
146
|
-
const position = calculatePopupPosition(anchor, this.popup, {
|
|
147
|
-
offsetY: 5,
|
|
148
|
-
offsetX: 0
|
|
149
|
-
});
|
|
150
|
-
setPopupPosition(this.popup, position);
|
|
151
|
-
|
|
152
|
-
// Show popup by adding visible class
|
|
153
|
-
this.popup.classList.add('visible');
|
|
154
|
-
this.isVisible = true;
|
|
155
|
-
|
|
156
|
-
// Setup click outside handler
|
|
157
|
-
this.setupClickOutside();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Hide emoji picker popup
|
|
162
|
-
*/
|
|
163
|
-
hide() {
|
|
164
|
-
this.popup.classList.remove('visible');
|
|
165
|
-
this.isVisible = false;
|
|
166
|
-
this.removeClickOutside();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Select emoji and trigger callback
|
|
171
|
-
* @param {string} emoji - Selected emoji
|
|
172
|
-
*/
|
|
173
|
-
selectEmoji(emoji) {
|
|
174
|
-
if (this.options.onEmojiSelect) {
|
|
175
|
-
this.options.onEmojiSelect(emoji);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
this.hide();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Destroy the emoji picker
|
|
183
|
-
*/
|
|
184
|
-
destroy() {
|
|
185
|
-
this.removeClickOutside();
|
|
186
|
-
|
|
187
|
-
if (this.popup && this.popup.parentNode) {
|
|
188
|
-
this.popup.parentNode.removeChild(this.popup);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
this.popup = null;
|
|
192
|
-
this.isVisible = false;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export default EmojiPicker;
|