mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-12 23:48:57 +00:00
more extensions
This commit is contained in:
@@ -285,6 +285,7 @@ app.registerExtension({
|
||||
words[v] = {
|
||||
text: v,
|
||||
info: () => new EmbeddingInfoDialog(emb).show("embeddings", emb),
|
||||
use_replacer: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -303,6 +304,7 @@ app.registerExtension({
|
||||
words[v] = {
|
||||
text: v,
|
||||
info: () => new LoraInfoDialog(lora).show("loras", lora),
|
||||
use_replacer: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -576,7 +576,8 @@ export class TextAreaAutoComplete {
|
||||
onclick: () => {
|
||||
this.el.focus();
|
||||
let value = wordInfo.value ?? wordInfo.text;
|
||||
if (TextAreaAutoComplete.replacer) {
|
||||
const use_replacer = wordInfo.use_replacer ?? true;
|
||||
if (TextAreaAutoComplete.replacer && use_replacer) {
|
||||
value = TextAreaAutoComplete.replacer(value);
|
||||
}
|
||||
this.helper.insertAtCursor(value + this.separator, -before.length, wordInfo.caretOffset);
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
import { app } from "../../../scripts/app.js";
|
||||
|
||||
// Adds mapping of touch events to mouse events for mobile. This isnt great but it is somewhat usable
|
||||
|
||||
app.registerExtension({
|
||||
name: "pysssss.TouchEvents",
|
||||
setup() {
|
||||
let touchStart = null;
|
||||
let touchType = 0;
|
||||
|
||||
function fireEvent(originalEvent, type) {
|
||||
const fakeEvent = document.createEvent("MouseEvent");
|
||||
const touch = originalEvent.changedTouches[0];
|
||||
fakeEvent.initMouseEvent(
|
||||
type,
|
||||
true,
|
||||
true,
|
||||
window,
|
||||
1,
|
||||
touch.screenX,
|
||||
touch.screenY,
|
||||
touch.clientX,
|
||||
touch.clientY,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null
|
||||
);
|
||||
|
||||
touch.target.dispatchEvent(fakeEvent);
|
||||
if (fakeEvent.defaultPrevented) {
|
||||
originalEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
"touchstart",
|
||||
(e) => {
|
||||
// Support tap as click if it completes within a delay
|
||||
if (touchStart) {
|
||||
clearTimeout(touchStart);
|
||||
}
|
||||
touchStart = setTimeout(() => {
|
||||
touchStart = null;
|
||||
}, 100);
|
||||
|
||||
// Left or right button down
|
||||
touchType = e.touches.length === 1 ? 0 : 2;
|
||||
|
||||
fireEvent(e, "mousedown");
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
document.addEventListener("touchmove", (e) => fireEvent(e, "mousemove"), true);
|
||||
|
||||
document.addEventListener(
|
||||
"touchend",
|
||||
(e) => {
|
||||
const isClick = touchStart;
|
||||
if (isClick) {
|
||||
// We are within the touch start delay so fire this as a click
|
||||
clearTimeout(touchStart);
|
||||
fireEvent(e, "click");
|
||||
}
|
||||
fireEvent(e, "mouseup");
|
||||
touchType = 0;
|
||||
},
|
||||
true
|
||||
);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user