Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/WeiBei/Editing/NoteEditorBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ struct NoteEditorSnapshotReadyEvent: Codable, Equatable, Sendable {
}
}

struct NoteEditorCommandResultEvent: Codable, Equatable, Sendable {
let protocolVersion: Int
let commandID: String
let documentID: String
let documentGeneration: UInt64
let revision: UInt64
let reason: String?
}

struct NoteEditorOutlineItem: Codable, Equatable, Identifiable, Sendable {
let id: String
let index: Int
Expand Down
96 changes: 48 additions & 48 deletions Sources/WeiBei/Resources/Editor/editor-entry.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Sources/WeiBei/Resources/Editor/editor-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"assets": [
{
"name": "editor-entry.js",
"bytes": 598840,
"sha256": "6c58c364c03bee4f6f5c5ef16032518586f1a8d00bf4beb42b9106e7840522f0"
"bytes": 599344,
"sha256": "a0f75325f94fc64abb13050b63976c317de7f3a4b9709956506be892539734df"
},
{
"name": "editor.css",
Expand Down Expand Up @@ -333,8 +333,8 @@
},
{
"name": "viewer-entry.js",
"bytes": 518708,
"sha256": "bacddcf53fea5d5b39c4a85bd73f4c558a0975692a1ae4f5b4c4a8c563f51705"
"bytes": 518730,
"sha256": "b501938b2bdd81b78f2434fb84310f4acedf34838233016b45d65d388ab609ed"
}
]
}
22 changes: 11 additions & 11 deletions Sources/WeiBei/Resources/Editor/viewer-entry.js

Large diffs are not rendered by default.

43 changes: 30 additions & 13 deletions Sources/WeiBei/Stores/WorkspaceStore+NotesPersistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -654,21 +654,38 @@ extension WorkspaceStore {
url: URL,
expectedBaseline: String?
) throws {
if FileManager.default.fileExists(atPath: url.path) {
guard let expectedBaseline,
let diskDigest = Self.noteContentDigest(at: url) else {
throw NoteWriteGateError.writeRefusedKeepContent
}
if diskDigest != expectedBaseline {
_ = try? NoteBackupRing.capture(
content: Data(markdown.utf8),
itemID: itemID,
rootURL: noteBackupRootURL
)
throw NoteWriteGateError.diskChangedAdoptDisk
var coordinationError: NSError?
var writeResult: Result<Void, Error>?
NSFileCoordinator(filePresenter: nil).coordinate(
writingItemAt: url,
options: .forReplacing,
error: &coordinationError
) { coordinatedURL in
writeResult = Result {
if FileManager.default.fileExists(atPath: coordinatedURL.path) {
guard let expectedBaseline,
let diskDigest = Self.noteContentDigest(at: coordinatedURL) else {
throw NoteWriteGateError.writeRefusedKeepContent
}
if diskDigest != expectedBaseline {
_ = try? NoteBackupRing.capture(
content: Data(markdown.utf8),
itemID: itemID,
rootURL: noteBackupRootURL
)
throw NoteWriteGateError.diskChangedAdoptDisk
}
}
try notebookMarkdownWriter(markdown, coordinatedURL)
}
}
try notebookMarkdownWriter(markdown, url)
if let writeResult {
try writeResult.get()
} else if let coordinationError {
throw coordinationError
} else {
throw NoteWriteGateError.writeRefusedKeepContent
}
let writtenDigest = Self.noteContentDigest(Data(markdown.utf8))
noteBackingContentDigestsByItemID[itemID] = writtenDigest
lastSelfWrittenNoteDigestsByItemID[itemID] = writtenDigest
Expand Down
Loading