botserver/web/desktop/paper/paper.js
Rodrigo Rodriguez (Pragmatismo) b9395cb0d7 feat(desktop): add new navigation links to index.html
Added new navigation links for Dashboard, Editor, Player, Paper, Settings, Tables, and News sections. Each link includes click handlers to switch sections and active state styling. This expands the application's navigation options for better user access to different features.
2025-11-15 19:52:24 -03:00

52 lines
1.3 KiB
JavaScript

// Paper module JavaScript
document.addEventListener('alpine:init', () => {
Alpine.data('paper', () => ({
showToolbar: false,
selection: null,
initEditor() {
const editor = this.$refs.editor;
// Track selection for floating toolbar
editor.addEventListener('mouseup', this.updateSelection.bind(this));
editor.addEventListener('keyup', this.updateSelection.bind(this));
// Show/hide toolbar based on selection
document.addEventListener('selectionchange', () => {
const selection = window.getSelection();
this.showToolbar = !selection.isCollapsed &&
editor.contains(selection.anchorNode);
});
},
updateSelection() {
this.selection = window.getSelection();
},
formatText(format) {
document.execCommand(format, false);
this.updateSelection();
},
alignText(align) {
document.execCommand('justify' + align, false);
this.updateSelection();
},
isActive(format) {
return document.queryCommandState(format);
},
isAligned(align) {
return document.queryCommandValue('justify' + align) === align;
},
addLink() {
const url = prompt('Enter URL:');
if (url) {
document.execCommand('createLink', false, url);
}
this.updateSelection();
}
}));
});