This commit is contained in:
parent
029aa47283
commit
fa6f57dc97
3 changed files with 62 additions and 0 deletions
|
@ -251,6 +251,30 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
document.execCommand("copy");
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copyPlainText,
|
||||
click() {
|
||||
focusByRange(getEditorRange(nodeElement));
|
||||
writeText(range.toString())
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copy +" HTML",
|
||||
click() {
|
||||
focusByRange(getEditorRange(nodeElement));
|
||||
let html = ''
|
||||
range.cloneContents().childNodes.forEach(item => {
|
||||
if (item.nodeType === 3) {
|
||||
html += item.textContent
|
||||
} else {
|
||||
html += (item as Element).outerHTML
|
||||
}
|
||||
})
|
||||
const tempElement = document.createElement('template')
|
||||
tempElement.innerHTML = protyle.lute.BlockDOM2HTML(html)
|
||||
writeText(tempElement.content.firstElementChild.innerHTML);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconCut",
|
||||
accelerator: "⌘X",
|
||||
|
|
|
@ -485,6 +485,29 @@ export class Gutter {
|
|||
}
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copyPlainText,
|
||||
click() {
|
||||
let html = "";
|
||||
selectsElement.forEach(item => {
|
||||
const editElement = getContenteditableElement(item);
|
||||
if (editElement) {
|
||||
html += editElement.textContent + "\n";
|
||||
}
|
||||
});
|
||||
writeText(html.trimEnd());
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copy + " HTML",
|
||||
click() {
|
||||
let html = "";
|
||||
selectsElement.forEach(item => {
|
||||
html += item.outerHTML
|
||||
});
|
||||
writeText(protyle.lute.BlockDOM2HTML(html));
|
||||
}
|
||||
}).element);
|
||||
if (window.siyuan.config.readonly) {
|
||||
return;
|
||||
}
|
||||
|
@ -826,6 +849,19 @@ export class Gutter {
|
|||
document.execCommand("copy");
|
||||
}
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.copyPlainText,
|
||||
click() {
|
||||
const editElement = getContenteditableElement(nodeElement);
|
||||
if (editElement) {
|
||||
writeText(editElement.textContent);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.copy + " HTML",
|
||||
click() {
|
||||
writeText(protyle.lute.BlockDOM2HTML(nodeElement.outerHTML));
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.duplicate,
|
||||
disabled: window.siyuan.config.readonly,
|
||||
|
|
2
app/src/types/protyle.d.ts
vendored
2
app/src/types/protyle.d.ts
vendored
|
@ -206,6 +206,8 @@ declare class Lute {
|
|||
public IsValidLinkDest(text: string): boolean;
|
||||
|
||||
public BlockDOM2InlineBlockDOM(html: string): string;
|
||||
|
||||
public BlockDOM2HTML(html: string): string;
|
||||
}
|
||||
|
||||
declare const webkitAudioContext: {
|
||||
|
|
Loading…
Add table
Reference in a new issue