-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathop.proto
More file actions
142 lines (125 loc) · 3.89 KB
/
Copy pathop.proto
File metadata and controls
142 lines (125 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
syntax = "proto3";
package deskDelta;
option go_package = "github.com/WriteDontThink/DeskDelta/definitions/go/deskdelta";
// Generically represent a start index and an end index
message IndexBoundary {
int32 start = 8;
int32 end = 9;
}
// Cursors being moved around
message CursorOperation{
enum CursorOpType {
MoveOneRight = 0;
MoveOneLeft = 1;
MoveToIndex = 2;
Select = 3;
}
CursorOpType cursorOpType = 6;
IndexBoundary cursorIndex = 10;
}
// Content being changed on the page
message ContentOperation{
enum ContentOpType {
InsertOne = 0;
DeleteOne = 1;
DeleteSelection = 2;
InsertMany = 3;
}
ContentOpType contentOpType = 7;
string data = 11;
}
// Users joining and leaving
message UserOperation {
enum UserOpType {
Connect = 0;
Disconnect = 1;
}
UserOpType userOpType = 24;
map<string, string> userInfo = 25;
}
// Pages being added and deleted
message PageOperation {
enum PageOpType {
Create = 0;
Delete = 1;
}
PageOpType pageOpType = 26;
}
message MetaOperation {
enum MetaOpType {
Title = 0;
}
MetaOpType metaOpType = 27;
}
message FormatOperation {
enum FormatOpType {
Create = 0;
Delete = 1;
}
enum FormatMessageVariant {
Data = 0;
Visual = 1;
}
enum FormatBoundary {
Word = 0;
Page = 1;
Index = 2;
}
FormatOpType formatOpType = 12;
FormatMessageVariant variant = 13;
// A format can be tied to the end of the word (the client will automatically extend it to the next space),
// to a given index, or to the end of a page.
FormatBoundary boundaryType = 14;
// If the format boundary is a word or an index, it can be represented by a start and end index. In the case
// of an index, this will stay constant regardless of the content, but in the case of a word, it will be adapted
// by space matching
IndexBoundary boundaryData = 15;
message DataFormat {
// A unique identifier for a piece of data in the system. This can be looked
// up by the client whenever needed.
int32 dataId = 16;
}
message VisualFormat {
// The name for a format, like "bold", or "font"
string format = 17;
// Any required attributes, like {"font-family": "Arial"}
map<string, string> formatAttributes = 18;
}
oneof formatContent {
DataFormat data = 19;
VisualFormat visual = 20;
}
}
message Operation {
enum MessageType {
CursorMessage = 0;
ContentMessage = 1;
UserMessage = 2;
PageMessage = 3;
MetaMessage = 4;
FormatMessage = 5;
}
// The type of message that's been received
MessageType messageType = 1;
// What page the message occurred on
int32 pageNum = 2;
// What user created the message. (User 0 will be reserved for the server, all others will increment as they join
int32 user = 3;
// What content does the message contain?
oneof messageContent {
// An operation representing cursor movement
CursorOperation cursorOp = 4;
// An operation representing text being changed on the page
ContentOperation contentOp = 5;
// An operation representing text being formatted or tagged on the page
FormatOperation formatOp = 12;
// Put page, user, and meataoperations all in higher field nums, because they're less frequent
// so bit conservation isn't really necessary
// An operation representing a page being created or deleted
PageOperation pageOp = 21;
// An operation representing a user connecting or disconnecting to the document
UserOperation userOp = 22;
// An operation representing metadata, like the title of the document, changing on the page
MetaOperation metaOp = 23;
}
}