@oix1987/yjd 1.0.0

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.
Files changed (55) hide show
  1. package/README.md +91 -0
  2. package/index.d.ts +103 -0
  3. package/index.js +221 -0
  4. package/lib/core/editor.js +1175 -0
  5. package/lib/core/format.js +542 -0
  6. package/lib/core/module.js +81 -0
  7. package/lib/core/registry.js +152 -0
  8. package/lib/formats/background.js +212 -0
  9. package/lib/formats/bold.js +67 -0
  10. package/lib/formats/capitalization.js +563 -0
  11. package/lib/formats/color.js +165 -0
  12. package/lib/formats/emoji.js +282 -0
  13. package/lib/formats/font-family.js +547 -0
  14. package/lib/formats/heading.js +502 -0
  15. package/lib/formats/image.js +344 -0
  16. package/lib/formats/import.js +385 -0
  17. package/lib/formats/indent.js +297 -0
  18. package/lib/formats/italic.js +27 -0
  19. package/lib/formats/line-height.js +558 -0
  20. package/lib/formats/link.js +251 -0
  21. package/lib/formats/list.js +635 -0
  22. package/lib/formats/strike.js +31 -0
  23. package/lib/formats/subscript.js +36 -0
  24. package/lib/formats/superscript.js +35 -0
  25. package/lib/formats/table.js +288 -0
  26. package/lib/formats/tag.js +304 -0
  27. package/lib/formats/text-align.js +421 -0
  28. package/lib/formats/text-size.js +497 -0
  29. package/lib/formats/underline.js +30 -0
  30. package/lib/formats/video.js +372 -0
  31. package/lib/modules/block-toolbar.js +628 -0
  32. package/lib/modules/code-view.js +434 -0
  33. package/lib/modules/history.js +410 -0
  34. package/lib/modules/resize-handles.js +677 -0
  35. package/lib/modules/table-toolbar.js +618 -0
  36. package/lib/modules/toolbar.js +424 -0
  37. package/lib/styles-loader.js +144 -0
  38. package/lib/styles.css +2123 -0
  39. package/lib/ui/color-picker.js +296 -0
  40. package/lib/ui/customselect.js +319 -0
  41. package/lib/ui/emoji-picker.js +196 -0
  42. package/lib/ui/icons.js +413 -0
  43. package/lib/ui/image-popup.js +444 -0
  44. package/lib/ui/import-popup.js +288 -0
  45. package/lib/ui/link-popup.js +191 -0
  46. package/lib/ui/list-picker.js +307 -0
  47. package/lib/ui/select-button.js +61 -0
  48. package/lib/ui/table-popup.js +171 -0
  49. package/lib/ui/tag-popup.js +249 -0
  50. package/lib/ui/text-align-picker.js +281 -0
  51. package/lib/ui/video-popup.js +422 -0
  52. package/lib/utils/history-helper.js +50 -0
  53. package/lib/utils/popup-helper.js +219 -0
  54. package/lib/utils/popup-positioning.js +231 -0
  55. package/package.json +26 -0
@@ -0,0 +1,196 @@
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;