mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🚨
This commit is contained in:
parent
6e864a2718
commit
9d94821c62
5 changed files with 13 additions and 17 deletions
|
|
@ -61,7 +61,6 @@
|
||||||
"file-loader": "^6.2.0",
|
"file-loader": "^6.2.0",
|
||||||
"html-loader": "^2.1.2",
|
"html-loader": "^2.1.2",
|
||||||
"html-webpack-plugin": "^5.5.0",
|
"html-webpack-plugin": "^5.5.0",
|
||||||
"iconv-lite": "^0.6.3",
|
|
||||||
"ifdef-loader": "^2.3.2",
|
"ifdef-loader": "^2.3.2",
|
||||||
"mini-css-extract-plugin": "2.3.0",
|
"mini-css-extract-plugin": "2.3.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
|
|
|
||||||
3
app/pnpm-lock.yaml
generated
3
app/pnpm-lock.yaml
generated
|
|
@ -54,9 +54,6 @@ devDependencies:
|
||||||
html-webpack-plugin:
|
html-webpack-plugin:
|
||||||
specifier: ^5.5.0
|
specifier: ^5.5.0
|
||||||
version: 5.5.0(webpack@5.73.0)
|
version: 5.5.0(webpack@5.73.0)
|
||||||
iconv-lite:
|
|
||||||
specifier: ^0.6.3
|
|
||||||
version: 0.6.3
|
|
||||||
ifdef-loader:
|
ifdef-loader:
|
||||||
specifier: ^2.3.2
|
specifier: ^2.3.2
|
||||||
version: 2.3.2
|
version: 2.3.2
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ export class Plugin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getData () {
|
public getData () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onload() {
|
public onload() {
|
||||||
console.log("Hello, world!")
|
console.log("Hello, world!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,27 +10,27 @@ const getObject = (key: string) => {
|
||||||
};
|
};
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return api[key];
|
return api[key];
|
||||||
}
|
};
|
||||||
|
|
||||||
const runCode = (code: string, sourceURL: string) => {
|
const runCode = (code: string, sourceURL: string) => {
|
||||||
return window.eval("(function anonymous(require, module){".concat(code, "\n})\n//# sourceURL=").concat(sourceURL, "\n"))
|
return window.eval("(function anonymous(require, module){".concat(code, "\n})\n//# sourceURL=").concat(sourceURL, "\n"));
|
||||||
}
|
};
|
||||||
|
|
||||||
export const loadPlugins = (app: App) => {
|
export const loadPlugins = (app: App) => {
|
||||||
fetchPost("/api/petal/loadPetals", {}, response => {
|
fetchPost("/api/petal/loadPetals", {}, response => {
|
||||||
let css = "";
|
let css = "";
|
||||||
response.data.forEach((item: { id: string, name: string, jsCode: string, cssCode: string, lang: IObject }) => {
|
response.data.forEach((item: { id: string, name: string, jsCode: string, cssCode: string, lang: IObject }) => {
|
||||||
const moduleObj = {}
|
const moduleObj = {};
|
||||||
const execResult = runCode(item.jsCode, "plugin:" + encodeURIComponent(item.id))
|
const execResult = runCode(item.jsCode, "plugin:" + encodeURIComponent(item.id));
|
||||||
execResult(getObject, moduleObj);
|
execResult(getObject, moduleObj);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const plugin: Plugin = new moduleObj.exports.default({app, id: item.id, lang: item.lang})
|
const plugin: Plugin = new moduleObj.exports.default({app, id: item.id, lang: item.lang});
|
||||||
app.plugins.push(plugin);
|
app.plugins.push(plugin);
|
||||||
plugin.onload();
|
plugin.onload();
|
||||||
css += item.cssCode + "\n";
|
css += item.cssCode + "\n";
|
||||||
})
|
});
|
||||||
const styleElement = document.createElement("style");
|
const styleElement = document.createElement("style");
|
||||||
styleElement.textContent = css;
|
styleElement.textContent = css;
|
||||||
document.head.append(styleElement);
|
document.head.append(styleElement);
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -456,7 +456,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
||||||
protyle.title.element.setAttribute("custom-riff-decks", data.new["custom-riff-decks"]);
|
protyle.title.element.setAttribute("custom-riff-decks", data.new["custom-riff-decks"]);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
protyle.title.element.style.animation = "";
|
protyle.title.element.style.animation = "";
|
||||||
}, 450)
|
}, 450);
|
||||||
} else {
|
} else {
|
||||||
protyle.title.element.removeAttribute("custom-riff-decks");
|
protyle.title.element.removeAttribute("custom-riff-decks");
|
||||||
}
|
}
|
||||||
|
|
@ -492,7 +492,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
||||||
item.style.animation = "addCard 450ms linear";
|
item.style.animation = "addCard 450ms linear";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
item.style.animation = "";
|
item.style.animation = "";
|
||||||
}, 450)
|
}, 450);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const refElement = item.lastElementChild.querySelector(".protyle-attr--refcount");
|
const refElement = item.lastElementChild.querySelector(".protyle-attr--refcount");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue