This commit is contained in:
parent
fd0e44fbf0
commit
d8ec52a900
1 changed files with 5 additions and 5 deletions
|
@ -105,7 +105,7 @@ export const openSnippets = () => {
|
|||
let target = event.target as HTMLElement;
|
||||
while (target && !target.isSameNode(dialog.element)) {
|
||||
if (target.id === "addCodeSnippetCSS" || target.id === "addCodeSnippetJS") {
|
||||
target.parentElement.parentElement.insertAdjacentHTML("beforeend", genSnippet({
|
||||
target.parentElement.insertAdjacentHTML("afterend", genSnippet({
|
||||
type: target.id === "addCodeSnippetCSS" ? "css" : "js",
|
||||
name: "",
|
||||
content: "",
|
||||
|
@ -142,7 +142,6 @@ export const openSnippets = () => {
|
|||
} else if (target.dataset.action === "remove") {
|
||||
const itemElement = target.parentElement.parentElement;
|
||||
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"));
|
||||
itemElement.nextElementSibling.remove();
|
||||
itemElement.remove();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
@ -155,8 +154,8 @@ export const openSnippets = () => {
|
|||
};
|
||||
|
||||
const genSnippet = (options: ISnippet) => {
|
||||
return `<div class="fn__hr--b"></div>
|
||||
<div data-id="${options.id || ""}" data-type="${options.type}">
|
||||
return `<div data-id="${options.id || ""}" data-type="${options.type}">
|
||||
<div class="fn__hr--b"></div>
|
||||
<div class="fn__flex">
|
||||
<input type="text" class="fn__size200 b3-text-field" placeholder="${window.siyuan.languages.title}">
|
||||
<div class="fn__flex-1"></div>
|
||||
|
@ -169,7 +168,8 @@ const genSnippet = (options: ISnippet) => {
|
|||
</div>
|
||||
<div class="fn__hr"></div>
|
||||
<textarea class="fn__block b3-text-field" placeholder="${window.siyuan.languages.codeSnippet}" style="resize: vertical;font-family:var(--b3-font-family-code)" spellcheck="false"></textarea>
|
||||
</div><div class="fn__hr--b"></div>`;
|
||||
<div class="fn__hr--b"></div>
|
||||
</div>`;
|
||||
};
|
||||
|
||||
const setSnippetPost = (dialog: Dialog, snippets: ISnippet[], removeIds: string[]) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue