mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
92467f2d73
commit
14d88d67fe
6 changed files with 35 additions and 44 deletions
|
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
[data-type="block-ref"],
|
[data-type="block-ref"],
|
||||||
[data-type="createdoc"] {
|
[data-type="block-more"] {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@
|
||||||
transition: var(--b3-transition);
|
transition: var(--b3-transition);
|
||||||
|
|
||||||
[data-type="block-ref"],
|
[data-type="block-ref"],
|
||||||
[data-type="createdoc"] {
|
[data-type="block-more"] {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
|
|
|
||||||
|
|
@ -277,10 +277,10 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
||||||
}
|
}
|
||||||
this.element.style.width = Math.max(protyle.element.clientWidth / 2, 320) + "px";
|
this.element.style.width = Math.max(protyle.element.clientWidth / 2, 320) + "px";
|
||||||
if (this.source === "av") {
|
if (this.source === "av") {
|
||||||
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
const cellElement = hasClosestByClassName(protyle.toolbar.range.startContainer, "av__cell");
|
||||||
if (blockElement) {
|
if (cellElement) {
|
||||||
const rowAddRect = blockElement.querySelector(".av__row--add").getBoundingClientRect();
|
const cellRect = cellElement.getBoundingClientRect();
|
||||||
setPosition(this.element, rowAddRect.left, rowAddRect.bottom, rowAddRect.height);
|
setPosition(this.element, cellRect.left, cellRect.bottom, cellRect.height);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const textareaPosition = getSelectionPosition(protyle.wysiwyg.element);
|
const textareaPosition = getSelectionPosition(protyle.wysiwyg.element);
|
||||||
|
|
@ -411,9 +411,12 @@ ${genHintItemHTML(item)}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.source === "av") {
|
if (this.source === "av") {
|
||||||
|
const cellElement = hasClosestByClassName(protyle.toolbar.range.startContainer, "av__cell");
|
||||||
|
if (!cellElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const previousID = cellElement.dataset.blockId
|
||||||
const avID = nodeElement.getAttribute("data-av-id");
|
const avID = nodeElement.getAttribute("data-av-id");
|
||||||
const rowsElement = nodeElement.querySelectorAll(".av__row");
|
|
||||||
const previousID = rowsElement[rowsElement.length - 1].getAttribute("data-id");
|
|
||||||
let tempElement = document.createElement("div");
|
let tempElement = document.createElement("div");
|
||||||
tempElement.innerHTML = value.replace(/<mark>/g, "").replace(/<\/mark>/g, "");
|
tempElement.innerHTML = value.replace(/<mark>/g, "").replace(/<\/mark>/g, "");
|
||||||
tempElement = tempElement.firstElementChild as HTMLDivElement;
|
tempElement = tempElement.firstElementChild as HTMLDivElement;
|
||||||
|
|
@ -428,31 +431,36 @@ ${genHintItemHTML(item)}
|
||||||
markdown: ""
|
markdown: ""
|
||||||
}, response => {
|
}, response => {
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "insertAttrViewBlock",
|
action: "replaceAttrViewBlock",
|
||||||
avID,
|
avID,
|
||||||
previousID,
|
previousID,
|
||||||
srcIDs: [response.data],
|
nextID: response.data,
|
||||||
|
isDetached: false,
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewBlock",
|
action: "replaceAttrViewBlock",
|
||||||
srcIDs: [response.data],
|
|
||||||
avID,
|
avID,
|
||||||
|
previousID: response.data,
|
||||||
|
nextID: previousID,
|
||||||
|
isDetached: true,
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const sourceId = tempElement.getAttribute("data-id");
|
const sourceId = tempElement.getAttribute("data-id");
|
||||||
transaction(protyle, [{
|
transaction(protyle, [{
|
||||||
action: "insertAttrViewBlock",
|
action: "replaceAttrViewBlock",
|
||||||
avID,
|
avID,
|
||||||
previousID,
|
previousID,
|
||||||
srcIDs: [sourceId],
|
nextID: sourceId,
|
||||||
|
isDetached: false,
|
||||||
}], [{
|
}], [{
|
||||||
action: "removeAttrViewBlock",
|
action: "replaceAttrViewBlock",
|
||||||
srcIDs: [sourceId],
|
|
||||||
avID,
|
avID,
|
||||||
|
previousID: sourceId,
|
||||||
|
nextID: previousID,
|
||||||
|
isDetached: true,
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
insertAttrViewBlockAnimation(nodeElement, 1, previousID);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.enableExtend = false;
|
this.enableExtend = false;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
if (protyle.disabled) {
|
if (protyle.disabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add");
|
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add");
|
||||||
if (addElement) {
|
if (addElement) {
|
||||||
const addMenu = addCol(protyle, blockElement);
|
const addMenu = addCol(protyle, blockElement);
|
||||||
|
|
@ -151,31 +152,12 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const createDocElement = hasClosestByAttribute(event.target, "data-type", "createdoc");
|
const blockMoreElement = hasClosestByAttribute(event.target, "data-type", "block-more");
|
||||||
if (createDocElement) {
|
if (blockMoreElement) {
|
||||||
fetchPost("/api/filetree/getHPathByPath", {
|
protyle.toolbar.range = document.createRange();
|
||||||
notebook: protyle.notebookId,
|
protyle.toolbar.range.selectNodeContents(blockMoreElement);
|
||||||
path: protyle.path,
|
focusByRange(protyle.toolbar.range);
|
||||||
}, (response) => {
|
hintRef(blockMoreElement.previousElementSibling.textContent.trim(), protyle, "av");
|
||||||
fetchPost("/api/filetree/createDocWithMd", {
|
|
||||||
notebook: protyle.notebookId,
|
|
||||||
path: pathPosix().join(response.data, createDocElement.previousElementSibling.textContent.trim() || "Untitled"),
|
|
||||||
parentID: protyle.block.rootID,
|
|
||||||
markdown: "",
|
|
||||||
id: createDocElement.parentElement.dataset.blockId,
|
|
||||||
}, response => {
|
|
||||||
transaction(protyle, [{
|
|
||||||
action: "updateAttrViewCell",
|
|
||||||
id: createDocElement.parentElement.dataset.id,
|
|
||||||
avID: blockElement.getAttribute("data-av-id"),
|
|
||||||
keyID: createDocElement.parentElement.dataset.colId,
|
|
||||||
rowID: createDocElement.parentElement.parentElement.dataset.id,
|
|
||||||
data: {
|
|
||||||
isDetached: false
|
|
||||||
}
|
|
||||||
}]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
|
||||||
} else if (cell.valueType === "block") {
|
} else if (cell.valueType === "block") {
|
||||||
text = `<span class="av__celltext">${cell.value.block.content || ""}</span>`;
|
text = `<span class="av__celltext">${cell.value.block.content || ""}</span>`;
|
||||||
if (cell.value?.isDetached) {
|
if (cell.value?.isDetached) {
|
||||||
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="createdoc" >${window.siyuan.languages.new}</span>`;
|
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-more" >${window.siyuan.languages.more}</span>`;
|
||||||
} else {
|
} else {
|
||||||
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-ref" data-id="${cell.value.block.id}" data-subtype="s">${window.siyuan.languages.openBy}</span>`;
|
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-ref" data-id="${cell.value.block.id}" data-subtype="s">${window.siyuan.languages.openBy}</span>`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -708,7 +708,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
||||||
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
|
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
|
||||||
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
|
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
|
||||||
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
|
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
|
||||||
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat"].includes(operation.action)) {
|
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "replaceAttrViewBlock"].includes(operation.action)) {
|
||||||
refreshAV(protyle, operation);
|
refreshAV(protyle, operation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -37,6 +37,7 @@ type TOperation =
|
||||||
| "setAttrViewSorts"
|
| "setAttrViewSorts"
|
||||||
| "setAttrViewColCalc"
|
| "setAttrViewColCalc"
|
||||||
| "updateAttrViewColNumberFormat"
|
| "updateAttrViewColNumberFormat"
|
||||||
|
| "replaceAttrViewBlock"
|
||||||
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
||||||
type TCardType = "doc" | "notebook" | "all"
|
type TCardType = "doc" | "notebook" | "all"
|
||||||
type TEventBus = "ws-main" |
|
type TEventBus = "ws-main" |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue