mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 00:20:12 +01:00
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;
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isSameNode(dialog.element)) {
|
while (target && !target.isSameNode(dialog.element)) {
|
||||||
if (target.id === "addCodeSnippetCSS" || target.id === "addCodeSnippetJS") {
|
if (target.id === "addCodeSnippetCSS" || target.id === "addCodeSnippetJS") {
|
||||||
target.parentElement.parentElement.insertAdjacentHTML("beforeend", genSnippet({
|
target.parentElement.insertAdjacentHTML("afterend", genSnippet({
|
||||||
type: target.id === "addCodeSnippetCSS" ? "css" : "js",
|
type: target.id === "addCodeSnippetCSS" ? "css" : "js",
|
||||||
name: "",
|
name: "",
|
||||||
content: "",
|
content: "",
|
||||||
|
|
@ -142,7 +142,6 @@ export const openSnippets = () => {
|
||||||
} else if (target.dataset.action === "remove") {
|
} else if (target.dataset.action === "remove") {
|
||||||
const itemElement = target.parentElement.parentElement;
|
const itemElement = target.parentElement.parentElement;
|
||||||
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"));
|
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"));
|
||||||
itemElement.nextElementSibling.remove();
|
|
||||||
itemElement.remove();
|
itemElement.remove();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
@ -155,8 +154,8 @@ export const openSnippets = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const genSnippet = (options: ISnippet) => {
|
const genSnippet = (options: ISnippet) => {
|
||||||
return `<div class="fn__hr--b"></div>
|
return `<div data-id="${options.id || ""}" data-type="${options.type}">
|
||||||
<div data-id="${options.id || ""}" data-type="${options.type}">
|
<div class="fn__hr--b"></div>
|
||||||
<div class="fn__flex">
|
<div class="fn__flex">
|
||||||
<input type="text" class="fn__size200 b3-text-field" placeholder="${window.siyuan.languages.title}">
|
<input type="text" class="fn__size200 b3-text-field" placeholder="${window.siyuan.languages.title}">
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
|
|
@ -169,7 +168,8 @@ const genSnippet = (options: ISnippet) => {
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__hr"></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>
|
<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[]) => {
|
const setSnippetPost = (dialog: Dialog, snippets: ISnippet[], removeIds: string[]) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue