You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
import { Controller } from "@hotwired/stimulus"; |
|
|
|
export default class extends Controller { |
|
connect() { |
|
console.log("Header controller connected"); |
|
} |
|
|
|
saveDraft(event) { |
|
event.preventDefault(); |
|
// Set isDraft to true |
|
const draftCheckbox = document.querySelector('input[name*="[isDraft]"]'); |
|
if (draftCheckbox) { |
|
draftCheckbox.checked = true; |
|
} else { |
|
console.warn('[Header] Draft checkbox not found'); |
|
} |
|
// Trigger click on the hidden Nostr publish button |
|
const publishButton = document.querySelector('[data-nostr--nostr-publish-target="publishButton"]'); |
|
if (publishButton) { |
|
publishButton.click(); |
|
} else { |
|
console.error('[Header] Hidden publish button not found'); |
|
} |
|
} |
|
|
|
publish(event) { |
|
event.preventDefault(); |
|
// Set isDraft to false |
|
const draftCheckbox = document.querySelector('input[name*="[isDraft]"]'); |
|
if (draftCheckbox) { |
|
draftCheckbox.checked = false; |
|
} else { |
|
console.warn('[Header] Draft checkbox not found'); |
|
} |
|
// Trigger click on the hidden Nostr publish button |
|
const publishButton = document.querySelector('[data-nostr--nostr-publish-target="publishButton"]'); |
|
if (publishButton) { |
|
publishButton.click(); |
|
} else { |
|
console.error('[Header] Hidden publish button not found'); |
|
} |
|
} |
|
}
|
|
|