Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:rotating_light:

Vanessa6b4af527e1b9
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 6208ab567f..0dbb5894a8 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -727,7 +727,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
const previous = hasPreviousSibling(range.startContainer);
if (previous && previous.nodeType !== 3 && (previous as HTMLElement).classList.contains("img")) {
if (!hasNextSibling(previous)) {
- range.insertNode(document.createTextNode(Constants.ZWSP))
+ range.insertNode(document.createTextNode(Constants.ZWSP));
range.collapse(false);
}
}
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 83fb7f28e1..1978505cb0 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -237,33 +237,33 @@ export class Toolbar {
return;
}
const rangeTypes = this.getCurrentType();
- let previousElement: Element
- let nextElement: Element
- let previousIndex: number
- let nextIndex: number
- const previousSibling = hasPreviousSibling(this.range.startContainer)
+ let previousElement: Element;
+ let nextElement: Element;
+ let previousIndex: number;
+ let nextIndex: number;
+ const previousSibling = hasPreviousSibling(this.range.startContainer);
if (!["DIV", "TD", "TH"].includes(this.range.startContainer.parentElement.tagName)) {
if (this.range.startOffset === 0 && !previousSibling) {
- previousElement = this.range.startContainer.parentElement.previousSibling as Element
- this.range.setStartBefore(this.range.startContainer.parentElement)
+ previousElement = this.range.startContainer.parentElement.previousSibling as Element;
+ this.range.setStartBefore(this.range.startContainer.parentElement);
} else {
- previousElement = this.range.startContainer.parentElement
+ previousElement = this.range.startContainer.parentElement;
}
} else if (previousSibling && previousSibling.nodeType !== 3 && this.range.startOffset === 0) {
// **aaa**bbb 选中 bbb 加粗
- previousElement = previousSibling as Element
+ previousElement = previousSibling as Element;
}
- const nextSibling = hasNextSibling(this.range.endContainer)
+ const nextSibling = hasNextSibling(this.range.endContainer);
if (!["DIV", "TD", "TH"].includes(this.range.endContainer.parentElement.tagName)) {
if (this.range.endOffset === this.range.endContainer.textContent.length && !nextSibling) {
- nextElement = this.range.endContainer.parentElement.nextSibling as Element
- this.range.setEndAfter(this.range.endContainer.parentElement)
+ nextElement = this.range.endContainer.parentElement.nextSibling as Element;
+ this.range.setEndAfter(this.range.endContainer.parentElement);
} else {
- nextElement = this.range.endContainer.parentElement
+ nextElement = this.range.endContainer.parentElement;
}
} else if (nextSibling && nextSibling.nodeType !== 3 && this.range.endOffset === this.range.endContainer.textContent.length) {
// aaa**bbb** 选中 aaa 加粗
- nextElement = nextSibling as Element
+ nextElement = nextSibling as Element;
}
const wbrElement = document.createElement("wbr");
this.range.insertNode(wbrElement);
@@ -298,9 +298,9 @@ export class Toolbar {
types.find((itemType, index) => {
if (type === itemType) {
types.splice(index, 1);
- return true
+ return true;
}
- })
+ });
if (types.length === 0) {
newNodes.push(document.createTextNode(item.textContent));
} else {
@@ -340,7 +340,7 @@ export class Toolbar {
} else {
let types = (item.getAttribute("data-type") || "").split(" ");
types.push(type);
- types = [...new Set(types)]
+ types = [...new Set(types)];
if (index === 0 && previousElement && previousElement.nodeType !== 3 && isArrayEqual(types, previousElement.getAttribute("data-type").split(" "))) {
previousIndex = previousElement.textContent.length;
previousElement.innerHTML = previousElement.innerHTML + item.innerHTML;
@@ -373,7 +373,7 @@ export class Toolbar {
if (nextIndex) {
this.range.setEnd(nextElement.lastChild, nextIndex);
} else if (newNodes.length > 0) {
- const lastNewNode = newNodes[newNodes.length - 1]
+ const lastNewNode = newNodes[newNodes.length - 1];
if (lastNewNode.lastChild) {
this.range.setEnd(lastNewNode.lastChild, lastNewNode.lastChild.textContent.length);
} else {
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 322624fddf..8927db9527 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -305,14 +305,14 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
}
if (operation.action === "updateAttrs") { // 调用接口才推送
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
- const data = operation.data as any
+ const data = operation.data as any;
Object.keys(data.old).forEach(key => {
- item.removeAttribute(key)
- })
- let nodeAttrHTML = ""
+ item.removeAttribute(key);
+ });
+ let nodeAttrHTML = "";
Object.keys(data.new).forEach(key => {
item.setAttribute(key, data.new[key]);
- const escapeHTML = data.new[key]
+ const escapeHTML = data.new[key];
if (key === "bookmark") {
nodeAttrHTML += `<div class="protyle-attr--bookmark">${escapeHTML}</div>`;
} else if (key === "name") {
@@ -322,7 +322,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
} else if (key === "memo") {
nodeAttrHTML += `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;
}
- })
+ });
const refElement = item.lastElementChild.querySelector(".protyle-attr--refcount");
if (refElement) {
nodeAttrHTML += refElement.outerHTML;
diff --git a/app/src/util/functions.ts b/app/src/util/functions.ts
index 23ed4b8eac..6f3f7da91e 100644
--- a/app/src/util/functions.ts
+++ b/app/src/util/functions.ts
@@ -4,7 +4,7 @@ export const isMobile = () => {
export const isArrayEqual = (arr1: string[], arr2: string[]) => {
return arr1.length === arr2.length && arr1.every((item) => arr2.includes(item));
-}
+};
export const getRandom = (min: number, max: number) => {
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值