syntax = "proto3";
package pub.odf.editor.v1;
// The position of the cursor in the editor.
message CursorPosition {
uint32 column = 1;
uint32 row = 2;
}
// The start and end of text that is selected
message SelectionRange {
CursorPosition end = 1;
CursorPosition start = 2;
}
enum ChangeType {
CHANGE_TYPE_INVALID = 0;
CHANGE_TYPE_INSERT = 1;
CHANGE_TYPE_REMOVE = 2;
}
message ChangeEvent {
ChangeType action = 1;
CursorPosition start = 2;
CursorPosition end = 3;
// The lines of text to insert
repeated string lines = 4;
}
message Mutation {
// (optional) Globally Unique Identifier
// An optional identifier for this specific mutation. It's not required, but
// useful if you want to compile a list of mutations by their ID and store
// the actual mutations seperately. As an open ended sequence of bytes, it
// does not dictate the format of the ID itself.
bytes id = 1;
// (optional) User's Globally Unique Identifier
// This would be set by the server after their authentication credentials
// have been verified. To save storage space, the container document can keep
// a list of editors, then use the index to that table in place of the full
// user ID here, taking only 1 byte of space.
bytes user_id = 2;
// UNIX timestamp of when the mutation was made. This should be set by a trusted
// environment, on the server, and not the user's machine
uint32 timestamp = 3;
ChangeEvent event = 4;
}
// A sequence of mutations, performed by a single user, for which the timestamp
// range does not overlap any other mutations.
message MutationSequence {
// (optional) Globally Unique Identifier
// An optional identifier for this specific mutation sequence.
bytes id = 1;
// (optional) User's Globally Unique Identifier
bytes user_id = 2;
// UNIX timestamp of when the mutation was made. This should be set by a trusted
// environment, on the server, and not the user's machine
uint32 timestamp = 3;
ChangeEvent event = 4;
}
// Standard wrapper for API calls
message APICall {
// (optional) Globally Unique Identifier
// This can be used by the client and server to keep track of the API calls
// and if/how they were handled.
bytes id = 1;
// (optional) User's Globally Unique Identifier
// This would be set by the server after their authentication credentials
// have been verified
bytes user_id = 2;
oneof payload {
Mutation mutation = 100;
}
}