mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-25 23:06:20 +00:00
Unify skill handling layer and raise the active skills cap to 20. The Skills UI now presents a simpler checklist-style flow for selecting active skills, with live chat activation and saved defaults using the same visible list. Skill contents can be opened in a read-only Ace viewer via the existing markdown modal.
83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
import { createStore } from "/js/AlpineStore.js";
|
|
import { renderSafeMarkdown } from "/js/safe-markdown.js";
|
|
|
|
export const store = createStore("markdownModal", {
|
|
title: "",
|
|
content: "",
|
|
error: null,
|
|
viewer: "rendered",
|
|
editor: null,
|
|
|
|
open(title, content, options = {}) {
|
|
this.title = title;
|
|
this.content = content;
|
|
this.error = null;
|
|
this.viewer = options.viewer || "rendered";
|
|
this.destroyEditor();
|
|
},
|
|
|
|
get renderedHtml() {
|
|
if (!this.content) return "";
|
|
return renderSafeMarkdown(this.content);
|
|
},
|
|
|
|
get isAce() {
|
|
return this.viewer === "ace";
|
|
},
|
|
|
|
onOpen() {
|
|
if (this.isAce) {
|
|
this.scheduleEditorInit();
|
|
}
|
|
},
|
|
|
|
scheduleEditorInit() {
|
|
window.requestAnimationFrame(() => {
|
|
if (!this.isAce || this.error) return;
|
|
window.requestAnimationFrame(() => this.initEditor());
|
|
});
|
|
},
|
|
|
|
initEditor() {
|
|
const container = document.getElementById("markdown-ace-viewer-container");
|
|
if (!container) return;
|
|
|
|
this.destroyEditor();
|
|
|
|
if (!window.ace?.edit) {
|
|
this.error = "Editor library not loaded";
|
|
return;
|
|
}
|
|
|
|
const editor = window.ace.edit("markdown-ace-viewer-container");
|
|
if (!editor) {
|
|
this.error = "Failed to initialize editor";
|
|
return;
|
|
}
|
|
|
|
const darkMode = window.localStorage?.getItem("darkMode");
|
|
const theme = darkMode !== "false" ? "ace/theme/github_dark" : "ace/theme/tomorrow";
|
|
|
|
this.editor = editor;
|
|
this.editor.setTheme(theme);
|
|
this.editor.session.setMode("ace/mode/markdown");
|
|
this.editor.setValue(this.content || "", -1);
|
|
this.editor.setReadOnly(true);
|
|
this.editor.clearSelection();
|
|
},
|
|
|
|
destroyEditor() {
|
|
if (this.editor?.destroy) {
|
|
this.editor.destroy();
|
|
}
|
|
this.editor = null;
|
|
},
|
|
|
|
cleanup() {
|
|
this.destroyEditor();
|
|
this.title = "";
|
|
this.content = "";
|
|
this.error = null;
|
|
this.viewer = "rendered";
|
|
},
|
|
});
|