mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 13:57:10 +09:00
Tech | MW 0.17.27 (#2097)
This commit is contained in:
parent
2d2abcb825
commit
5399e3ca22
22 changed files with 187 additions and 44 deletions
|
@ -178,7 +178,7 @@ data class Block(
|
|||
}
|
||||
|
||||
enum class Style {
|
||||
P, H1, H2, H3, H4, TITLE, QUOTE, CODE_SNIPPET, BULLET, NUMBERED, TOGGLE, CHECKBOX, DESCRIPTION
|
||||
P, H1, H2, H3, H4, TITLE, QUOTE, CODE_SNIPPET, BULLET, NUMBERED, TOGGLE, CHECKBOX, DESCRIPTION, CALLOUT
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,8 +431,8 @@ class BlockDataRepository(
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?
|
||||
): SearchResult = factory.remote.searchObjectsWithSubscription(
|
||||
|
|
|
@ -150,8 +150,8 @@ interface BlockDataStore {
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?,
|
||||
): SearchResult
|
||||
|
|
|
@ -156,8 +156,8 @@ interface BlockRemote {
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?,
|
||||
): SearchResult
|
||||
|
|
|
@ -345,8 +345,8 @@ class BlockRemoteDataStore(private val remote: BlockRemote) : BlockDataStore {
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?
|
||||
): SearchResult = remote.searchObjectsWithSubscription(
|
||||
|
|
|
@ -85,7 +85,7 @@ ext {
|
|||
|
||||
// Anytype
|
||||
|
||||
middleware_version = 'v0.17.24'
|
||||
middleware_version = 'v0.17.27'
|
||||
|
||||
mainApplication = [
|
||||
kotlin: "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
|
||||
|
|
|
@ -203,8 +203,8 @@ interface BlockRepository {
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?,
|
||||
): SearchResult
|
||||
|
|
|
@ -21,8 +21,8 @@ class ObjectSearchSubscriptionContainer(
|
|||
subscription: Id,
|
||||
sorts: List<DVSort> = emptyList(),
|
||||
filters: List<DVFilter> = emptyList(),
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
keys: List<String>
|
||||
): Flow<Subscription> {
|
||||
return flow {
|
||||
|
|
|
@ -30,15 +30,15 @@ class SearchObjectsWithSubscription(
|
|||
val filters: List<DVFilter> = emptyList(),
|
||||
val fulltext: String = EMPTY_TEXT,
|
||||
val keys: List<String>,
|
||||
val offset: Int = INIT_OFFSET,
|
||||
val limit: Int = LIMIT,
|
||||
val offset: Long = INIT_OFFSET,
|
||||
val limit: Long = LIMIT,
|
||||
val beforeId: Id?,
|
||||
val afterId: Id?,
|
||||
)
|
||||
|
||||
companion object {
|
||||
const val EMPTY_TEXT = ""
|
||||
const val LIMIT = 1000
|
||||
const val INIT_OFFSET = 0
|
||||
const val LIMIT = 1000L
|
||||
const val INIT_OFFSET = 0L
|
||||
}
|
||||
}
|
|
@ -30,8 +30,8 @@ class ObjectSearchSubscriptionContainerTest {
|
|||
|
||||
private lateinit var container: ObjectSearchSubscriptionContainer
|
||||
|
||||
private val defaultLimit = 0
|
||||
private val defaultOffset = 0
|
||||
private val defaultLimit = 0L
|
||||
private val defaultOffset = 0L
|
||||
|
||||
private val defaultKeys = listOf(
|
||||
Relations.ID,
|
||||
|
|
|
@ -371,8 +371,8 @@ class BlockMiddleware(
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?
|
||||
): SearchResult = middleware.searchObjectsWithSubscription(
|
||||
|
|
|
@ -1224,8 +1224,8 @@ class Middleware(
|
|||
sorts: List<DVSort>,
|
||||
filters: List<DVFilter>,
|
||||
keys: List<String>,
|
||||
offset: Int,
|
||||
limit: Int,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
beforeId: Id?,
|
||||
afterId: Id?,
|
||||
): SearchResult {
|
||||
|
|
|
@ -64,7 +64,7 @@ class MiddlewareSubscriptionEventChannel(
|
|||
Timber.d("Subscription REMOVE")
|
||||
val event = e.subscriptionRemove
|
||||
checkNotNull(event)
|
||||
if (subscriptions.any { it == payload.contextId || "$it$DEPENDENT_SUBSCRIPTION_POST_FIX" == payload.contextId }) {
|
||||
if (subscriptions.any { it == event.subId || "$it$DEPENDENT_SUBSCRIPTION_POST_FIX" == event.subId }) {
|
||||
SubscriptionEvent.Remove(
|
||||
target = event.id,
|
||||
subscription = payload.contextId
|
||||
|
@ -77,7 +77,7 @@ class MiddlewareSubscriptionEventChannel(
|
|||
Timber.d("Subscription ADD")
|
||||
val event = e.subscriptionAdd
|
||||
checkNotNull(event)
|
||||
if (subscriptions.any { it == payload.contextId || "$it$DEPENDENT_SUBSCRIPTION_POST_FIX" == payload.contextId }) {
|
||||
if (subscriptions.any { it == event.subId || "$it$DEPENDENT_SUBSCRIPTION_POST_FIX" == event.subId }) {
|
||||
SubscriptionEvent.Add(
|
||||
target = event.id,
|
||||
afterId = event.afterId,
|
||||
|
@ -92,7 +92,7 @@ class MiddlewareSubscriptionEventChannel(
|
|||
val event = e.subscriptionPosition
|
||||
checkNotNull(event)
|
||||
// TODO should I handle here dependent subscriptions?
|
||||
if (subscriptions.any { it == payload.contextId }) {
|
||||
if (subscriptions.any { it == event.subId }) {
|
||||
SubscriptionEvent.Position(
|
||||
target = event.id,
|
||||
afterId = event.afterId
|
||||
|
|
|
@ -293,6 +293,7 @@ fun MBTextStyle.toCoreModels(): Block.Content.Text.Style = when (this) {
|
|||
MBTextStyle.Toggle -> Block.Content.Text.Style.TOGGLE
|
||||
MBTextStyle.Marked -> Block.Content.Text.Style.BULLET
|
||||
MBTextStyle.Description -> Block.Content.Text.Style.DESCRIPTION
|
||||
MBTextStyle.Callout -> Block.Content.Text.Style.CALLOUT
|
||||
}
|
||||
|
||||
fun MBMarkType.toCoreModels(): Block.Content.Text.Mark.Type = when (this) {
|
||||
|
|
|
@ -204,6 +204,7 @@ fun Block.Content.Text.Style.toMiddlewareModel(): MBTextStyle = when (this) {
|
|||
Block.Content.Text.Style.TOGGLE -> MBTextStyle.Toggle
|
||||
Block.Content.Text.Style.CHECKBOX -> MBTextStyle.Checkbox
|
||||
Block.Content.Text.Style.DESCRIPTION -> MBTextStyle.Description
|
||||
Block.Content.Text.Style.CALLOUT -> MBTextStyle.Callout
|
||||
}
|
||||
|
||||
fun Position.toMiddlewareModel(): MBPosition = when (this) {
|
||||
|
|
|
@ -219,6 +219,23 @@ fun Block.Content.Text.getBlockStyle(style: Block.Content.Text.Style) = when (st
|
|||
enabledAlignment = emptyList()
|
||||
)
|
||||
}
|
||||
Block.Content.Text.Style.CALLOUT -> {
|
||||
StyleConfig(
|
||||
visibleTypes = listOf(
|
||||
StylingType.STYLE,
|
||||
StylingType.TEXT_COLOR,
|
||||
StylingType.BACKGROUND
|
||||
),
|
||||
enabledMarkup = listOf(
|
||||
Markup.Type.BOLD,
|
||||
Markup.Type.ITALIC,
|
||||
Markup.Type.STRIKETHROUGH,
|
||||
Markup.Type.KEYBOARD,
|
||||
Markup.Type.LINK
|
||||
),
|
||||
enabledAlignment = emptyList()
|
||||
)
|
||||
}
|
||||
Block.Content.Text.Style.DESCRIPTION -> throw IllegalStateException("Description block does not support styling")
|
||||
}
|
||||
|
||||
|
@ -306,6 +323,23 @@ fun Block.Content.Text.getMarkupStyle(style: Block.Content.Text.Style) = when (s
|
|||
enabledAlignment = emptyList()
|
||||
)
|
||||
}
|
||||
Block.Content.Text.Style.CALLOUT -> {
|
||||
StyleConfig(
|
||||
visibleTypes = listOf(
|
||||
StylingType.STYLE,
|
||||
StylingType.TEXT_COLOR,
|
||||
StylingType.BACKGROUND
|
||||
),
|
||||
enabledMarkup = listOf(
|
||||
Markup.Type.BOLD,
|
||||
Markup.Type.ITALIC,
|
||||
Markup.Type.STRIKETHROUGH,
|
||||
Markup.Type.KEYBOARD,
|
||||
Markup.Type.LINK
|
||||
),
|
||||
enabledAlignment = emptyList()
|
||||
)
|
||||
}
|
||||
Block.Content.Text.Style.DESCRIPTION -> throw IllegalStateException("Description block does not support styling")
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ fun Block.Content.Text.Style.getStyleName(): String = when (this) {
|
|||
Block.Content.Text.Style.TOGGLE -> "Toggle"
|
||||
Block.Content.Text.Style.CHECKBOX -> "Checkbox"
|
||||
Block.Content.Text.Style.DESCRIPTION -> "Description"
|
||||
Block.Content.Text.Style.CALLOUT -> "Callout"
|
||||
}
|
||||
|
||||
fun Block.Prototype.Text.getStyleName() = this.style.getStyleName()
|
||||
|
|
|
@ -213,7 +213,7 @@ object ObjectSearchConstants {
|
|||
)
|
||||
)
|
||||
|
||||
const val limitTabHistory = 50
|
||||
const val limitTabHistory = 50L
|
||||
|
||||
//endregion
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
text = "",
|
||||
marks = emptyList(),
|
||||
style = Block.Content.Text.Style.values().filter { style ->
|
||||
style != Block.Content.Text.Style.TITLE && style != Block.Content.Text.Style.DESCRIPTION
|
||||
style != Block.Content.Text.Style.TITLE && style != Block.Content.Text.Style.DESCRIPTION && style != Block.Content.Text.Style.CALLOUT
|
||||
}.random()
|
||||
)
|
||||
)
|
||||
|
@ -191,7 +191,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
text = "",
|
||||
marks = emptyList(),
|
||||
style = Block.Content.Text.Style.values().filter { style ->
|
||||
style != Block.Content.Text.Style.TITLE && style != Block.Content.Text.Style.DESCRIPTION
|
||||
style != Block.Content.Text.Style.TITLE && style != Block.Content.Text.Style.DESCRIPTION && style != Block.Content.Text.Style.CALLOUT
|
||||
}.random()
|
||||
)
|
||||
)
|
||||
|
@ -324,7 +324,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
text = MockDataFactory.randomString(),
|
||||
marks = emptyList(),
|
||||
style = Block.Content.Text.Style.values().filter { style ->
|
||||
style != Block.Content.Text.Style.TITLE && style != Block.Content.Text.Style.DESCRIPTION
|
||||
style != Block.Content.Text.Style.TITLE && style != Block.Content.Text.Style.DESCRIPTION && style != Block.Content.Text.Style.CALLOUT
|
||||
}.random()
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
syntax = "proto3";
|
||||
package anytype;
|
||||
option go_package = "pb";
|
||||
|
||||
import "models.proto";
|
||||
import "localstore.proto";
|
||||
|
||||
import "events.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "localstore.proto";
|
||||
import "models.proto";
|
||||
|
||||
option go_package = "pb";
|
||||
|
||||
/*
|
||||
* Rpc is a namespace, that agregates all of the service commands between client and middleware.
|
||||
|
@ -933,7 +933,6 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
message Style {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
|
@ -983,6 +982,32 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Icon {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
string blockId = 2;
|
||||
string iconImage = 3; // in case both image and emoji are set, image has a priority to show
|
||||
string iconEmoji = 5;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
ResponseEvent event = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message File {
|
||||
|
@ -2318,7 +2343,6 @@ message Rpc {
|
|||
string name = 1; // Account name
|
||||
oneof avatar {
|
||||
string avatarLocalPath = 2; // Path to an image, that will be used as an avatar of this account
|
||||
string avatarColor = 3; // Avatar color as an alternative for avatar image
|
||||
}
|
||||
|
||||
|
||||
|
@ -3414,12 +3438,10 @@ message Rpc {
|
|||
repeated anytype.model.Block.Content.Dataview.Filter filters = 2;
|
||||
// sorts
|
||||
repeated anytype.model.Block.Content.Dataview.Sort sorts = 3;
|
||||
// fulltext query (optional)
|
||||
string fullText = 4;
|
||||
// results limit
|
||||
int32 limit = 5;
|
||||
int64 limit = 5;
|
||||
// initial offset; middleware will find afterId
|
||||
int32 offset = 6;
|
||||
int64 offset = 6;
|
||||
// (required) needed keys in details for return, for object fields mw will return (and subscribe) objects as dependent
|
||||
repeated string keys = 7;
|
||||
|
||||
|
@ -3431,6 +3453,8 @@ message Rpc {
|
|||
repeated string source = 10;
|
||||
|
||||
string ignoreWorkspace = 12;
|
||||
// disable dependent subscription
|
||||
bool noDepSubscription = 13;
|
||||
}
|
||||
|
||||
message Response {
|
||||
|
@ -3957,6 +3981,64 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message UnsplashSearch {
|
||||
message Request {
|
||||
string query = 1; // empty means random images
|
||||
int32 limit = 2; // may be omitted if the request was cached previously with another limit
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
repeated Picture pictures = 2;
|
||||
|
||||
message Picture {
|
||||
string id = 1;
|
||||
string url = 2;
|
||||
string artist = 3;
|
||||
string artistUrl = 4;
|
||||
}
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
|
||||
RATE_LIMIT_EXCEEDED = 100;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message UnsplashDownload {
|
||||
message Request {
|
||||
string pictureId = 1;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string hash = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
|
||||
RATE_LIMIT_EXCEEDED = 100;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message ApplyTemplate {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
syntax = "proto3";
|
||||
package anytype;
|
||||
option go_package = "pb";
|
||||
|
||||
import "models.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "models.proto";
|
||||
|
||||
option go_package = "pb";
|
||||
|
||||
/*
|
||||
* Event – type of message, that could be sent from a middleware to the corresponding front-end.
|
||||
|
@ -137,17 +138,20 @@ message Event {
|
|||
message Add {
|
||||
string id = 1; // object id
|
||||
string afterId = 2; // id of previous doc in order, empty means first
|
||||
string subId = 3; // subscription id
|
||||
}
|
||||
|
||||
// Removes document from subscription
|
||||
message Remove {
|
||||
string id = 1; // object id
|
||||
string subId = 2; // subscription id
|
||||
}
|
||||
|
||||
// Indicates new position of document
|
||||
message Position {
|
||||
string id = 1; // object id
|
||||
string afterId = 2; // id of previous doc in order, empty means first
|
||||
string subId = 3; // subscription id
|
||||
}
|
||||
|
||||
message Counters {
|
||||
|
@ -157,6 +161,8 @@ message Event {
|
|||
int64 nextCount = 2;
|
||||
// how many records available before
|
||||
int64 prevCount = 3;
|
||||
|
||||
string subId = 4; // subscription id
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -297,6 +303,8 @@ message Event {
|
|||
Marks marks = 4;
|
||||
Checked checked = 5;
|
||||
Color color = 6;
|
||||
IconEmoji iconEmoji = 7;
|
||||
IconImage iconImage = 8;
|
||||
|
||||
message TText {
|
||||
string value = 1;
|
||||
|
@ -318,6 +326,13 @@ message Event {
|
|||
string value = 1;
|
||||
}
|
||||
|
||||
message IconEmoji {
|
||||
string value = 1;
|
||||
}
|
||||
|
||||
message IconImage {
|
||||
string value = 1;
|
||||
}
|
||||
}
|
||||
message Latex {
|
||||
string id = 1;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
syntax = "proto3";
|
||||
package anytype.model;
|
||||
option go_package = "pkg/lib/pb/model";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
option go_package = "pkg/lib/pb/model";
|
||||
|
||||
message SmartBlockSnapshotBase {
|
||||
repeated Block blocks = 1;
|
||||
google.protobuf.Struct details = 2;
|
||||
|
@ -66,6 +67,7 @@ message Block {
|
|||
Content.Relation relation = 22;
|
||||
Content.FeaturedRelations featuredRelations = 23;
|
||||
Content.Latex latex = 24;
|
||||
Content.TableOfContents tableOfContents = 25;
|
||||
}
|
||||
|
||||
message Restrictions {
|
||||
|
@ -170,6 +172,8 @@ message Block {
|
|||
Marks marks = 3; // list of marks to apply to the text
|
||||
bool checked = 4;
|
||||
string color = 5;
|
||||
string iconEmoji = 6; // used with style Callout
|
||||
string iconImage = 7; // in case both image and emoji are set, image should has a priority in the UI
|
||||
|
||||
message Marks {
|
||||
repeated Mark marks = 1;
|
||||
|
@ -209,6 +213,8 @@ message Block {
|
|||
Numbered = 10;
|
||||
Toggle = 11;
|
||||
Description = 12; // currently only only one block of this style can exists on a page
|
||||
Callout = 13; // currently only only one block of this style can exists on a page
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,6 +361,9 @@ message Block {
|
|||
message Latex {
|
||||
string text = 1;
|
||||
}
|
||||
|
||||
message TableOfContents {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue