mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
61ee5676c4
commit
3ffc7b249b
8 changed files with 54 additions and 24 deletions
|
|
@ -319,14 +319,13 @@
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
max-height: 386px;
|
|
||||||
padding: 8px 0;
|
padding: 8px 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
line-height: 24px;
|
line-height: 28px;
|
||||||
font-family: var(--b3-font-family-emoji);
|
font-family: var(--b3-font-family-emoji);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 28px;
|
height: 28px;
|
||||||
|
|
@ -336,7 +335,7 @@
|
||||||
transition: var(--b3-transition);
|
transition: var(--b3-transition);
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: 0;
|
border: 0;
|
||||||
margin: 0;
|
margin: 1px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
img, svg {
|
img, svg {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ export class Dialog {
|
||||||
height?: string,
|
height?: string,
|
||||||
destroyCallback?: (options?: IObject) => void,
|
destroyCallback?: (options?: IObject) => void,
|
||||||
disableClose?: boolean,
|
disableClose?: boolean,
|
||||||
|
hideCloseIcon?: boolean,
|
||||||
disableAnimation?: boolean,
|
disableAnimation?: boolean,
|
||||||
resizeCallback?: (type: string) => void
|
resizeCallback?: (type: string) => void
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -33,7 +34,7 @@ export class Dialog {
|
||||||
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};">
|
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};">
|
||||||
<div class="b3-dialog__scrim"${options.transparent ? 'style="background-color:transparent"' : ""}></div>
|
<div class="b3-dialog__scrim"${options.transparent ? 'style="background-color:transparent"' : ""}></div>
|
||||||
<div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"}">
|
<div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"}">
|
||||||
<svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${this.disableClose ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg>
|
<svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${(this.disableClose||options.hideCloseIcon) ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg>
|
||||||
<div class="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div>
|
<div class="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div>
|
||||||
<div class="b3-dialog__body">${options.content}</div>
|
<div class="b3-dialog__body">${options.content}</div>
|
||||||
<div class="resize__rd"></div><div class="resize__ld"></div><div class="resize__lt"></div><div class="resize__rt"></div><div class="resize__r"></div><div class="resize__d"></div><div class="resize__t"></div><div class="resize__l"></div>
|
<div class="resize__rd"></div><div class="resize__ld"></div><div class="resize__lt"></div><div class="resize__rt"></div><div class="resize__r"></div><div class="resize__d"></div><div class="resize__t"></div><div class="resize__l"></div>
|
||||||
|
|
@ -45,8 +46,6 @@ export class Dialog {
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// https://ld246.com/article/1657969292700/comment/1658147006669#comments
|
|
||||||
window.siyuan.menus.menu.remove();
|
|
||||||
});
|
});
|
||||||
if (!this.disableClose) {
|
if (!this.disableClose) {
|
||||||
this.element.querySelector(".b3-dialog__close").addEventListener("click", (event) => {
|
this.element.querySelector(".b3-dialog__close").addEventListener("click", (event) => {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {getAllModels} from "../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {setNoteBook} from "../util/pathName";
|
import {setNoteBook} from "../util/pathName";
|
||||||
import {Dialog} from "../dialog";
|
import {Dialog} from "../dialog";
|
||||||
|
import {setPosition} from "../util/setPosition";
|
||||||
|
|
||||||
export const getRandomEmoji = () => {
|
export const getRandomEmoji = () => {
|
||||||
const emojis = window.siyuan.emojis[getRandom(0, window.siyuan.emojis.length - 1)];
|
const emojis = window.siyuan.emojis[getRandom(0, window.siyuan.emojis.length - 1)];
|
||||||
|
|
@ -191,8 +192,14 @@ export const addEmoji = (unicode: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition) => {
|
export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition) => {
|
||||||
|
if (type !== "av") {
|
||||||
|
window.siyuan.menus.menu.remove();
|
||||||
|
} else {
|
||||||
|
window.siyuan.menus.menu.removeScrollEvent();
|
||||||
|
}
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
transparent: true,
|
transparent: true,
|
||||||
|
hideCloseIcon: true,
|
||||||
width: isMobile() ? "80vw" : "360px",
|
width: isMobile() ? "80vw" : "360px",
|
||||||
height: "50vh",
|
height: "50vh",
|
||||||
content: `<div class="emojis" data-menu="true">
|
content: `<div class="emojis" data-menu="true">
|
||||||
|
|
@ -223,6 +230,9 @@ export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", posi
|
||||||
</div>
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
});
|
});
|
||||||
|
(dialog.element.firstElementChild as HTMLElement).style.justifyContent = "inherit";
|
||||||
|
(dialog.element.firstElementChild as HTMLElement).style.alignItems = "inherit";
|
||||||
|
setPosition(dialog.element.querySelector(".b3-dialog__container"), position.x, position.y, position.h, position.w);
|
||||||
dialog.element.querySelector(".emojis__item").classList.add("emojis__item--current");
|
dialog.element.querySelector(".emojis__item").classList.add("emojis__item--current");
|
||||||
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
|
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
|
||||||
const emojisContentElement = dialog.element.querySelector(".emojis__panel");
|
const emojisContentElement = dialog.element.querySelector(".emojis__panel");
|
||||||
|
|
@ -391,8 +401,11 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
||||||
let unicode = "";
|
let unicode = "";
|
||||||
if (emojiElement) {
|
if (emojiElement) {
|
||||||
unicode = emojiElement.getAttribute("data-unicode");
|
unicode = emojiElement.getAttribute("data-unicode");
|
||||||
window.siyuan.menus.menu.remove();
|
if (type !== "av") {
|
||||||
|
dialog.destroy()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// 随机
|
||||||
unicode = getRandomEmoji();
|
unicode = getRandomEmoji();
|
||||||
}
|
}
|
||||||
if (type === "notebook") {
|
if (type === "notebook") {
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,9 @@ export class Files extends Model {
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
openEmojiPanel(target.parentElement.getAttribute("data-url"), "notebook", {
|
openEmojiPanel(target.parentElement.getAttribute("data-url"), "notebook", {
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
y: rect.bottom
|
y: rect.bottom,
|
||||||
|
h: rect.height,
|
||||||
|
w: rect.width,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
} else if (type === "toggle") {
|
} else if (type === "toggle") {
|
||||||
|
|
@ -247,12 +249,16 @@ export class Files extends Model {
|
||||||
if (target.parentElement.getAttribute("data-type") === "navigation-file") {
|
if (target.parentElement.getAttribute("data-type") === "navigation-file") {
|
||||||
openEmojiPanel(target.parentElement.getAttribute("data-node-id"), "doc", {
|
openEmojiPanel(target.parentElement.getAttribute("data-node-id"), "doc", {
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
y: rect.bottom
|
y: rect.bottom,
|
||||||
|
h: rect.height,
|
||||||
|
w: rect.width,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
openEmojiPanel(target.parentElement.parentElement.getAttribute("data-url"), "notebook", {
|
openEmojiPanel(target.parentElement.parentElement.getAttribute("data-url"), "notebook", {
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
y: rect.bottom
|
y: rect.bottom,
|
||||||
|
h: rect.height,
|
||||||
|
w: rect.width,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -92,17 +92,16 @@ export class Menu {
|
||||||
return menuItem.element;
|
return menuItem.element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeScrollEvent() {
|
||||||
|
window.removeEventListener(isMobile() ? "touchmove" : this.wheelEvent, this.preventDefault, false);
|
||||||
|
}
|
||||||
|
|
||||||
public remove() {
|
public remove() {
|
||||||
if (window.siyuan.menus.menu.removeCB) {
|
if (window.siyuan.menus.menu.removeCB) {
|
||||||
window.siyuan.menus.menu.removeCB();
|
window.siyuan.menus.menu.removeCB();
|
||||||
window.siyuan.menus.menu.removeCB = undefined;
|
window.siyuan.menus.menu.removeCB = undefined;
|
||||||
}
|
}
|
||||||
if (isMobile()) {
|
this.removeScrollEvent();
|
||||||
window.removeEventListener("touchmove", this.preventDefault, false);
|
|
||||||
} else {
|
|
||||||
window.removeEventListener(this.wheelEvent, this.preventDefault, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.element.firstElementChild.classList.add("fn__none");
|
this.element.firstElementChild.classList.add("fn__none");
|
||||||
this.element.lastElementChild.innerHTML = "";
|
this.element.lastElementChild.innerHTML = "";
|
||||||
this.element.classList.add("fn__none");
|
this.element.classList.add("fn__none");
|
||||||
|
|
@ -129,11 +128,7 @@ export class Menu {
|
||||||
if (this.element.lastElementChild.innerHTML === "") {
|
if (this.element.lastElementChild.innerHTML === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isMobile()) {
|
window.addEventListener(isMobile() ? "touchmove" : this.wheelEvent, this.preventDefault, {passive: false});
|
||||||
window.addEventListener("touchmove", this.preventDefault, {passive: false});
|
|
||||||
} else {
|
|
||||||
window.addEventListener(this.wheelEvent, this.preventDefault, {passive: false});
|
|
||||||
}
|
|
||||||
this.element.style.zIndex = (++window.siyuan.zIndex).toString();
|
this.element.style.zIndex = (++window.siyuan.zIndex).toString();
|
||||||
this.element.classList.remove("fn__none");
|
this.element.classList.remove("fn__none");
|
||||||
setPosition(this.element, options.x - (options.isLeft ? window.siyuan.menus.menu.element.clientWidth : 0), options.y, options.h, options.w);
|
setPosition(this.element, options.x - (options.isLeft ? window.siyuan.menus.menu.element.clientWidth : 0), options.y, options.h, options.w);
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,12 @@ export class Background {
|
||||||
break;
|
break;
|
||||||
} else if (type === "open-emoji") {
|
} else if (type === "open-emoji") {
|
||||||
const rect = this.iconElement.getBoundingClientRect();
|
const rect = this.iconElement.getBoundingClientRect();
|
||||||
openEmojiPanel(protyle.block.rootID, "doc", {x: rect.left, y: rect.bottom});
|
openEmojiPanel(protyle.block.rootID, "doc", {
|
||||||
|
x: rect.left,
|
||||||
|
y: rect.bottom,
|
||||||
|
h: rect.height,
|
||||||
|
w: rect.width
|
||||||
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -391,6 +391,18 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
||||||
type: "readonly",
|
type: "readonly",
|
||||||
label: `<input style="margin: 4px 0" class="b3-text-field" type="text" value="${cellElement.innerText.trim()}">`,
|
label: `<input style="margin: 4px 0" class="b3-text-field" type="text" value="${cellElement.innerText.trim()}">`,
|
||||||
bind(element) {
|
bind(element) {
|
||||||
|
const iconElement = element.querySelector(".block__icon") as HTMLElement
|
||||||
|
iconElement.addEventListener("click", (event) => {
|
||||||
|
const rect = iconElement.getBoundingClientRect();
|
||||||
|
openEmojiPanel("", "av", {
|
||||||
|
x: rect.left,
|
||||||
|
y: rect.bottom,
|
||||||
|
h: rect.height,
|
||||||
|
w: rect.width
|
||||||
|
});
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
element.querySelector("input").addEventListener("keydown", (event: KeyboardEvent) => {
|
element.querySelector("input").addEventListener("keydown", (event: KeyboardEvent) => {
|
||||||
if (event.isComposing) {
|
if (event.isComposing) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1903,8 +1903,9 @@ export class WYSIWYG {
|
||||||
const rect = menuElement.getBoundingClientRect();
|
const rect = menuElement.getBoundingClientRect();
|
||||||
window.siyuan.menus.menu.popup({
|
window.siyuan.menus.menu.popup({
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
y: rect.top
|
y: rect.top,
|
||||||
}, true);
|
isLeft: true
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue