mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
904735a2eb
commit
dfc0a35c05
5 changed files with 51 additions and 13 deletions
|
|
@ -17,6 +17,12 @@ export class Plugin {
|
||||||
public eventBus: EventBus;
|
public eventBus: EventBus;
|
||||||
public data: any = {};
|
public data: any = {};
|
||||||
public name: string;
|
public name: string;
|
||||||
|
public protyleSlash: {
|
||||||
|
filter: string[],
|
||||||
|
html: string,
|
||||||
|
id: string,
|
||||||
|
callback: (protyle: import("../protyle").Protyle) => void
|
||||||
|
}[] = [];
|
||||||
// TODO
|
// TODO
|
||||||
public customBlockRenders: {
|
public customBlockRenders: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,11 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
|
||||||
filter: ["ai chat"],
|
filter: ["ai chat"],
|
||||||
value: Constants.ZWSP + 5,
|
value: Constants.ZWSP + 5,
|
||||||
html: '<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSparkles"></use></svg><span class="b3-list-item__text">AI Chat</span></div>',
|
html: '<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSparkles"></use></svg><span class="b3-list-item__text">AI Chat</span></div>',
|
||||||
},
|
}/*,{
|
||||||
// {
|
filter: ["属性视图", "shuxingshitu", "sxst", "attribute view"],
|
||||||
// filter: ["属性视图", "shuxingshitu", "sxst", "attribute view"],
|
value: '<div data-type="NodeAttributeView" data-av-type="table"></div>',
|
||||||
// value: '<div data-type="NodeAttributeView" data-av-type="table"></div>',
|
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.attributeView}</span></div>`,
|
||||||
// html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.attributeView}</span></div>`,
|
}*/, {
|
||||||
// },
|
|
||||||
{
|
|
||||||
filter: ["文档", "子文档", "wendang", "wd", "ziwendang", "zwd", "xjwd"],
|
filter: ["文档", "子文档", "wendang", "wd", "ziwendang", "zwd", "xjwd"],
|
||||||
value: Constants.ZWSP + 4,
|
value: Constants.ZWSP + 4,
|
||||||
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newFile}</span><span class="b3-menu__accelerator">${updateHotkeyTip(window.siyuan.config.keymap.general.newFile.custom)}</span></div>`,
|
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newFile}</span><span class="b3-menu__accelerator">${updateHotkeyTip(window.siyuan.config.keymap.general.newFile.custom)}</span></div>`,
|
||||||
|
|
@ -249,6 +247,24 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
|
||||||
value: `style${Constants.ZWSP}`,
|
value: `style${Constants.ZWSP}`,
|
||||||
html: `<div class="b3-list-item__first"><div class="color__square">A</div><span class="b3-list-item__text">${window.siyuan.languages.clearFontStyle}</span></div>`,
|
html: `<div class="b3-list-item__first"><div class="color__square">A</div><span class="b3-list-item__text">${window.siyuan.languages.clearFontStyle}</span></div>`,
|
||||||
}];
|
}];
|
||||||
|
allList.push({
|
||||||
|
value: "",
|
||||||
|
html: "separator",
|
||||||
|
});
|
||||||
|
let hasPlugin = false;
|
||||||
|
protyle.app.plugins.forEach((plugin) => {
|
||||||
|
plugin.protyleSlash.forEach(slash => {
|
||||||
|
allList.push({
|
||||||
|
filter: slash.filter,
|
||||||
|
value: `plugin${Constants.ZWSP}${plugin.name}${Constants.ZWSP}${slash.id}`,
|
||||||
|
html: slash.html
|
||||||
|
});
|
||||||
|
hasPlugin = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (!hasPlugin) {
|
||||||
|
allList.pop();
|
||||||
|
}
|
||||||
if (key === "") {
|
if (key === "") {
|
||||||
return allList;
|
return allList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -619,6 +619,20 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
||||||
nodeElement.setAttribute("style", value.split(Constants.ZWSP)[1] || "");
|
nodeElement.setAttribute("style", value.split(Constants.ZWSP)[1] || "");
|
||||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||||
return;
|
return;
|
||||||
|
} else if (value.startsWith("plugin")) {
|
||||||
|
protyle.app.plugins.find((plugin) => {
|
||||||
|
const ids = value.split(Constants.ZWSP)
|
||||||
|
if (ids[1] === plugin.name) {
|
||||||
|
plugin.protyleSlash.find((slash) => {
|
||||||
|
if (slash.id === ids[2]){
|
||||||
|
slash.callback(protyle.getInstance());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
range.deleteContents();
|
range.deleteContents();
|
||||||
if (value !== "![]()") {
|
if (value !== "![]()") {
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ export class Protyle {
|
||||||
const mergedOptions = getOptions.merge();
|
const mergedOptions = getOptions.merge();
|
||||||
|
|
||||||
this.protyle = {
|
this.protyle = {
|
||||||
|
getInstance: () => this,
|
||||||
app,
|
app,
|
||||||
transactionTime: new Date().getTime(),
|
transactionTime: new Date().getTime(),
|
||||||
id: genUUID(),
|
id: genUUID(),
|
||||||
|
|
|
||||||
1
app/src/types/protyle.d.ts
vendored
1
app/src/types/protyle.d.ts
vendored
|
|
@ -407,6 +407,7 @@ interface IOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProtyle {
|
interface IProtyle {
|
||||||
|
getInstance: () => import("../protyle").Protyle,
|
||||||
app: import("../index").App,
|
app: import("../index").App,
|
||||||
transactionTime: number,
|
transactionTime: number,
|
||||||
id: string,
|
id: string,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue