Vanessa 2022-09-18 17:51:19 +08:00
parent 358bee9df2
commit 40868a50f9
6 changed files with 112 additions and 19 deletions

View file

@ -3,11 +3,12 @@
"Spec": "1",
"Type": "NodeDocument",
"Properties": {
"icon": "1f4f0",
"id": "20200924093441-ft2rhps",
"title": "Formatting elements",
"title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;",
"type": "doc",
"updated": "20220916200115"
"updated": "20220918174924"
},
"Children": [
{
@ -31,7 +32,7 @@
"ListData": {},
"Properties": {
"id": "20210104091509-8csaq4j",
"updated": "20220916200115"
"updated": "20220918174924"
},
"Children": [
{
@ -505,6 +506,36 @@
}
]
},
{
"ID": "20220918174910-8q5x3x0",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20220918174910-8q5x3x0",
"updated": "20220918174924"
},
"Children": [
{
"ID": "20220918174910-p5i5ltq",
"Type": "NodeParagraph",
"Properties": {
"id": "20220918174910-p5i5ltq",
"updated": "20220918174924"
},
"Children": [
{
"Type": "NodeTextMark",
"TextMarkType": "inline-memo",
"TextMarkInlineMemoContent": "This is a memo.",
"TextMarkTextContent": "Memo"
}
]
}
]
},
{
"ID": "20210604224724-pa2a6tz",
"Type": "NodeListItem",

View file

@ -3,11 +3,12 @@
"Spec": "1",
"Type": "NodeDocument",
"Properties": {
"icon": "1f4f0",
"id": "20200825162036-4dx365o",
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"type": "doc",
"updated": "20210604222204"
"updated": "20220918174723"
},
"Children": [
{
@ -31,7 +32,7 @@
"ListData": {},
"Properties": {
"id": "20210104091228-ttcj9nm",
"updated": "20210604222204"
"updated": "20220918174723"
},
"Children": [
{
@ -509,6 +510,36 @@
}
]
},
{
"ID": "20220918172212-57nf6j0",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20220918172212-57nf6j0",
"updated": "20220918174723"
},
"Children": [
{
"ID": "20220918172212-xvd14ba",
"Type": "NodeParagraph",
"Properties": {
"id": "20220918172212-xvd14ba",
"updated": "20220918174723"
},
"Children": [
{
"Type": "NodeTextMark",
"TextMarkType": "inline-memo",
"TextMarkInlineMemoContent": "这是一个行级备注",
"TextMarkTextContent": "备注"
}
]
}
]
},
{
"ID": "20210604221118-nprm47c",
"Type": "NodeListItem",

View file

@ -3,10 +3,11 @@
"Spec": "1",
"Type": "NodeDocument",
"Properties": {
"icon": "1f4f0",
"id": "20211226121319-emrk2yy",
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"updated": "20220916195925"
"updated": "20220918174803"
},
"Children": [
{
@ -30,7 +31,7 @@
"ListData": {},
"Properties": {
"id": "20211226122008-1e014nh",
"updated": "20220916195740"
"updated": "20220918174803"
},
"Children": [
{
@ -512,6 +513,36 @@
}
]
},
{
"ID": "20220918172637-u4ckqgh",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20220918172637-u4ckqgh",
"updated": "20220918174803"
},
"Children": [
{
"ID": "20220918172637-x9l2igm",
"Type": "NodeParagraph",
"Properties": {
"id": "20220918172637-x9l2igm",
"updated": "20220918174803"
},
"Children": [
{
"Type": "NodeTextMark",
"TextMarkType": "inline-memo",
"TextMarkInlineMemoContent": "這是一個行級備註",
"TextMarkTextContent": "備註"
}
]
}
]
},
{
"ID": "20211226122008-hd9rbv6",
"Type": "NodeListItem",

View file

@ -80,7 +80,7 @@ const renderPDF = (id: string) => {
width: 1032,
resizable: false,
frame: "darwin" === window.siyuan.config.system.os,
icon: path.join(window.siyuan.config.system.appDir, 'stage', 'icon-large.png'),
icon: path.join(window.siyuan.config.system.appDir, "stage", "icon-large.png"),
titleBarStyle: "hidden",
webPreferences: {
contextIsolation: false,

View file

@ -310,7 +310,7 @@ export class Toolbar {
}
spanElement.innerHTML = item.textContent;
item.replaceWith(spanElement);
})
});
}
const actionBtn = action === "toolbar" ? this.element.querySelector(`[data-type="${type}"]`) : undefined;
const newNodes: Node[] = [];
@ -457,8 +457,8 @@ export class Toolbar {
this.range.collapse(true);
}
for (let i = 0; i < newNodes.length; i++) {
const currentNewNode = newNodes[i] as HTMLElement
const nextNewNode = newNodes[i + 1] as HTMLElement
const currentNewNode = newNodes[i] as HTMLElement;
const nextNewNode = newNodes[i + 1] as HTMLElement;
if (currentNewNode.nodeType !== 3 && nextNewNode && nextNewNode.nodeType !== 3 &&
isArrayEqual(nextNewNode.getAttribute("data-type").split(" "), currentNewNode.getAttribute("data-type").split(" ")) &&
currentNewNode.style.color === nextNewNode.style.color &&
@ -514,7 +514,7 @@ export class Toolbar {
}
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
const wbrElement = nodeElement.querySelector("wbr")
const wbrElement = nodeElement.querySelector("wbr");
if (wbrElement) {
wbrElement.remove();
}

View file

@ -28,7 +28,7 @@ import {
getLastBlock, getNextBlock,
getPreviousHeading,
getTopAloneElement,
hasNextSibling, hasPreviousSibling,
hasNextSibling,
isNotEditBlock
} from "./getBlock";
import {transaction, updateTransaction} from "./transaction";
@ -112,7 +112,7 @@ export class WYSIWYG {
const inputData = event.data;
protyle.toolbar.range = range;
const inlineElement = range.startContainer.parentElement;
const currentTypes = protyle.toolbar.getCurrentType()
const currentTypes = protyle.toolbar.getCurrentType();
if (// 表格行内公式之前无法插入文字 https://github.com/siyuan-note/siyuan/issues/3908
inlineElement.tagName==="SPAN" &&
range.toString() === "" && range.startContainer.nodeType === 3 &&
@ -237,12 +237,12 @@ export class WYSIWYG {
} else if (selectTypes.length > 0 && range.startContainer.nodeType === 3 && range.startContainer.parentElement.tagName === "SPAN" &&
range.startContainer.parentElement.isSameNode(range.endContainer.parentElement)) {
// 复制粗体等字体中的一部分
const attributes = range.startContainer.parentElement.attributes
const attributes = range.startContainer.parentElement.attributes;
const spanElement = document.createElement("span");
for (let i = 0; i < attributes.length; i++) {
spanElement.setAttribute(attributes[i].name, attributes[i].value);
}
spanElement.textContent = range.toString()
spanElement.textContent = range.toString();
html = spanElement.outerHTML;
} else {
tempElement.append(range.cloneContents());
@ -1731,7 +1731,7 @@ export class WYSIWYG {
const emptyEditElement = getContenteditableElement(emptyElement) as HTMLInputElement;
range.selectNodeContents(emptyEditElement);
range.collapse(true);
focusByRange(range)
focusByRange(range);
} else if (lastEditElement) {
range.selectNodeContents(lastEditElement);
range.collapse(false);
@ -1752,7 +1752,7 @@ export class WYSIWYG {
}
if (getSelection().rangeCount === 0) {
// https://github.com/siyuan-note/siyuan/issues/5901
focusByRange(newRange)
focusByRange(newRange);
}
/// #if !MOBILE
pushBack(protyle, newRange);
@ -1800,12 +1800,12 @@ export class WYSIWYG {
let hasJump = false;
while (currentElement) {
if (currentElement && !currentElement.classList.contains("protyle-attr")) {
const currentRect = currentElement.getBoundingClientRect()
const currentRect = currentElement.getBoundingClientRect();
if (startRect.top === endRect.top ? (currentRect.right <= endTop) : (currentRect.top <= endTop)) {
if (hasJump) {
// 父节点的下个节点在选中范围内才可使用父节点作为选中节点
if (currentElement.nextElementSibling && !currentElement.nextElementSibling.classList.contains("protyle-attr")) {
const currentNextRect = currentElement.nextElementSibling.getBoundingClientRect()
const currentNextRect = currentElement.nextElementSibling.getBoundingClientRect();
if (startRect.top === endRect.top ? (currentNextRect.right <= endTop) : (currentNextRect.top <= endTop)) {
selectElements = [currentElement];
currentElement = currentElement.nextElementSibling as HTMLElement;