diff --git a/custom_components/simple_sticky_note/js/sticky_note_card.js b/custom_components/simple_sticky_note/js/sticky_note_card.js
index 259c948..9bdfd1c 100644
--- a/custom_components/simple_sticky_note/js/sticky_note_card.js
+++ b/custom_components/simple_sticky_note/js/sticky_note_card.js
@@ -53,6 +53,12 @@ class SimpleStickyNote extends HTMLElement {
.edit-button, .delete-button {
--mdc-icon-button-size: 40px;
}
+ .emoji-picker {
+ position: absolute;
+ bottom: 48px;
+ right: 8px;
+ z-index: 1000;
+ }
`;
this.appendChild(style);
}
@@ -97,9 +103,15 @@ class SimpleStickyNote extends HTMLElement {
buttonContainer.style.display = 'flex';
const saveButton = document.createElement('ha-icon-button');
saveButton.innerHTML = '';
-
+
const cancelButton = document.createElement('ha-icon-button');
cancelButton.innerHTML = '';
+
+ const emojiButton = document.createElement('ha-icon-button');
+ emojiButton.innerHTML = '';
+ emojiButton.addEventListener('click', () => this.toggleEmojiPicker(textarea));
+
+ buttonContainer.appendChild(emojiButton);
buttonContainer.appendChild(saveButton);
buttonContainer.appendChild(cancelButton);
this.querySelector('ha-card').appendChild(textarea);
@@ -109,6 +121,30 @@ class SimpleStickyNote extends HTMLElement {
cancelButton.addEventListener('click', () => this.cancelEdit(oldContent));
}
+ toggleEmojiPicker(textarea) {
+ if (this.emojiPicker) {
+ this.emojiPicker.remove();
+ this.emojiPicker = null;
+ } else {
+ this.emojiPicker = document.createElement('div');
+ this.emojiPicker.classList.add('emoji-picker');
+ this.emojiPicker.innerHTML = this.getEmojiList();
+ this.querySelector('ha-card').appendChild(this.emojiPicker);
+ this.emojiPicker.addEventListener('click', (e) => {
+ if (e.target.tagName === 'SPAN') {
+ textarea.value += e.target.textContent;
+ this.emojiPicker.remove();
+ this.emojiPicker = null;
+ }
+ });
+ }
+ }
+
+ getEmojiList() {
+ const emojis = ['๐', '๐', '๐', '๐', '๐', '๐
', '๐', '๐คฃ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ฅฐ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐คช', '๐คจ', '๐ง', '๐ค', '๐', '๐คฉ', '๐ฅณ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', 'โน', '๐ฃ', '๐', '๐ซ', '๐ฉ', '๐ฅบ', '๐ข', '๐ญ', '๐ค', '๐ ', '๐ก', '๐คฌ', '๐คฏ', '๐ณ', '๐ฅต', '๐ฅถ', '๐ฑ', '๐จ', '๐ฐ', '๐ฅ', '๐', '๐ค', '๐ค', '๐คญ', '๐คซ', '๐คฅ', '๐ถ', '๐', '๐', '๐ฌ', '๐', '๐ฏ', '๐ฆ', '๐ง', '๐ฎ', '๐ฒ', '๐ฅฑ', '๐ด', '๐คค', '๐ช', '๐ต', '๐ค', '๐ฅด', '๐คข', '๐คฎ', '๐คง', '๐ท', '๐ค', '๐ค'];
+ return emojis.map(emoji => `${emoji}`).join('');
+ }
+
saveNote(newContent) {
if (!this._hass) {
console.error('Hass object is not available');
@@ -146,6 +182,7 @@ class SimpleStickyNote extends HTMLElement {
const buttonContainer = this.querySelector('ha-card > div:last-child');
if (textarea) textarea.remove();
if (buttonContainer) buttonContainer.remove();
+ if (this.emojiPicker) this.emojiPicker.remove();
this.content.style.display = 'block';
this.querySelector('.button-container').style.display = 'flex';
}
diff --git a/custom_components/simple_sticky_note/manifest.json b/custom_components/simple_sticky_note/manifest.json
index 083fe2a..474978b 100644
--- a/custom_components/simple_sticky_note/manifest.json
+++ b/custom_components/simple_sticky_note/manifest.json
@@ -8,5 +8,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/biofects/simple_sticky_note/issues",
"requirements": [],
- "version": "1.4.0"
+ "version": "1.5.0"
}