mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
This commit is contained in:
parent
27b370133d
commit
01fc87c152
3 changed files with 19 additions and 4 deletions
|
|
@ -35,11 +35,18 @@ const renderCompare = (app: App, element: HTMLElement) => {
|
||||||
if (!listElement) {
|
if (!listElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const dialogContainerElement = hasClosestByClassName(element, "b3-dialog__container")
|
||||||
|
if (!dialogContainerElement) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const leftElement = listElement.nextElementSibling.firstElementChild;
|
const leftElement = listElement.nextElementSibling.firstElementChild;
|
||||||
const rightElement = listElement.nextElementSibling.lastElementChild;
|
const rightElement = listElement.nextElementSibling.lastElementChild;
|
||||||
if (!leftEditor) {
|
if (!leftEditor) {
|
||||||
leftEditor = new Protyle(app, leftElement.lastElementChild as HTMLElement, {
|
leftEditor = new Protyle(app, leftElement.lastElementChild as HTMLElement, {
|
||||||
blockId: "",
|
blockId: "",
|
||||||
|
history: {
|
||||||
|
snapshot: ""
|
||||||
|
},
|
||||||
action: [Constants.CB_GET_HISTORY],
|
action: [Constants.CB_GET_HISTORY],
|
||||||
render: {
|
render: {
|
||||||
background: false,
|
background: false,
|
||||||
|
|
@ -54,6 +61,9 @@ const renderCompare = (app: App, element: HTMLElement) => {
|
||||||
rightEditor = new Protyle(app, rightElement.lastElementChild as HTMLElement, {
|
rightEditor = new Protyle(app, rightElement.lastElementChild as HTMLElement, {
|
||||||
blockId: "",
|
blockId: "",
|
||||||
action: [Constants.CB_GET_HISTORY],
|
action: [Constants.CB_GET_HISTORY],
|
||||||
|
history: {
|
||||||
|
snapshot: ""
|
||||||
|
},
|
||||||
render: {
|
render: {
|
||||||
background: false,
|
background: false,
|
||||||
title: false,
|
title: false,
|
||||||
|
|
@ -84,6 +94,7 @@ const renderCompare = (app: App, element: HTMLElement) => {
|
||||||
textElement.classList.add("fn__none");
|
textElement.classList.add("fn__none");
|
||||||
leftElement.lastElementChild.classList.remove("fn__none");
|
leftElement.lastElementChild.classList.remove("fn__none");
|
||||||
textElement.previousElementSibling.classList.add("fn__none");
|
textElement.previousElementSibling.classList.add("fn__none");
|
||||||
|
leftEditor.protyle.options.history.snapshot = dialogContainerElement.querySelector(".b3-dialog__header code").getAttribute("data-snapshot");
|
||||||
onGet({
|
onGet({
|
||||||
data: response,
|
data: response,
|
||||||
protyle: leftEditor.protyle,
|
protyle: leftEditor.protyle,
|
||||||
|
|
@ -112,6 +123,7 @@ const renderCompare = (app: App, element: HTMLElement) => {
|
||||||
textElement.classList.add("fn__none");
|
textElement.classList.add("fn__none");
|
||||||
rightElement.lastElementChild.classList.remove("fn__none");
|
rightElement.lastElementChild.classList.remove("fn__none");
|
||||||
textElement.previousElementSibling.classList.add("fn__none");
|
textElement.previousElementSibling.classList.add("fn__none");
|
||||||
|
rightEditor.protyle.options.history.snapshot = dialogContainerElement.querySelectorAll(".b3-dialog__header code")[1].getAttribute("data-snapshot");
|
||||||
onGet({
|
onGet({
|
||||||
data: response,
|
data: response,
|
||||||
protyle: rightEditor.protyle,
|
protyle: rightEditor.protyle,
|
||||||
|
|
@ -194,13 +206,13 @@ const genHTML = (left: string, right: string, dialog: Dialog, direct: string) =>
|
||||||
const headElement = dialog.element.querySelector(".b3-dialog__header");
|
const headElement = dialog.element.querySelector(".b3-dialog__header");
|
||||||
headElement.innerHTML = `<div style="padding: 0;min-height: auto;" class="block__icons">
|
headElement.innerHTML = `<div style="padding: 0;min-height: auto;" class="block__icons">
|
||||||
<span class="fn__flex-1"></span>
|
<span class="fn__flex-1"></span>
|
||||||
<code class="fn__code${isPhone ? " fn__none" : ""}">${left.substring(0, 7)}</code>
|
<code class="fn__code${isPhone ? " fn__none" : ""}" data-snapshot="${left}">${left.substring(0, 7)}</code>
|
||||||
${isPhone ? "" : '<span class="fn__space"></span>'}
|
${isPhone ? "" : '<span class="fn__space"></span>'}
|
||||||
${dayjs(response.data.left.created).format("YYYY-MM-DD HH:mm")}
|
${dayjs(response.data.left.created).format("YYYY-MM-DD HH:mm")}
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<span class="block__icon block__icon--show b3-tooltips b3-tooltips__s" aria-label="${window.siyuan.languages.switchDirect}" data-direct="${direct}"><svg><use xlink:href="#iconScrollHoriz"></use></svg></span>
|
<span class="block__icon block__icon--show b3-tooltips b3-tooltips__s" aria-label="${window.siyuan.languages.switchDirect}" data-direct="${direct}"><svg><use xlink:href="#iconScrollHoriz"></use></svg></span>
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<code class="fn__code${isPhone ? " fn__none" : ""}">${right.substring(0, 7)}</code>
|
<code class="fn__code${isPhone ? " fn__none" : ""}" data-snapshot="${right}">${right.substring(0, 7)}</code>
|
||||||
${isPhone ? "" : '<span class="fn__space"></span>'}
|
${isPhone ? "" : '<span class="fn__space"></span>'}
|
||||||
${dayjs(response.data.right.created).format("YYYY-MM-DD HH:mm")}
|
${dayjs(response.data.right.created).format("YYYY-MM-DD HH:mm")}
|
||||||
<span class="fn__flex-1"></span>
|
<span class="fn__flex-1"></span>
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,11 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void) =
|
||||||
selectCellId = (hasClosestByClassName(selectCellElement, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + selectCellElement.getAttribute("data-col-id");
|
selectCellId = (hasClosestByClassName(selectCellElement, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + selectCellElement.getAttribute("data-col-id");
|
||||||
}
|
}
|
||||||
const created = protyle.options.history?.created;
|
const created = protyle.options.history?.created;
|
||||||
fetchPost(created ? "/api/av/renderHistoryAttributeView" : "/api/av/renderAttributeView", {
|
const snapshot = protyle.options.history?.snapshot;
|
||||||
|
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
|
||||||
id: e.getAttribute("data-av-id"),
|
id: e.getAttribute("data-av-id"),
|
||||||
created
|
created,
|
||||||
|
snapshot
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
const data = response.data.view as IAVTable;
|
const data = response.data.view as IAVTable;
|
||||||
// header
|
// header
|
||||||
|
|
|
||||||
1
app/src/types/protyle.d.ts
vendored
1
app/src/types/protyle.d.ts
vendored
|
|
@ -377,6 +377,7 @@ interface IHint {
|
||||||
interface IOptions {
|
interface IOptions {
|
||||||
history?: {
|
history?: {
|
||||||
created?: string
|
created?: string
|
||||||
|
snapshot?: string
|
||||||
},
|
},
|
||||||
backlinkData?: {
|
backlinkData?: {
|
||||||
blockPaths: IBreadcrumb[],
|
blockPaths: IBreadcrumb[],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue