mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #1346 from omnivore-app/save-highlight-location-api
Add highlightPositionPercent and highlightPositionAnchorIndex in highlight api
This commit is contained in:
commit
2342e0fbbb
6 changed files with 63 additions and 3 deletions
|
|
@ -179,6 +179,8 @@ export interface Highlight {
|
||||||
sharedAt?: Date | null
|
sharedAt?: Date | null
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
labels?: Label[]
|
labels?: Label[]
|
||||||
|
highlightPositionPercent?: number | null
|
||||||
|
highlightPositionAnchorIndex?: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Page {
|
export interface Page {
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,8 @@ export enum CreateHighlightErrorCode {
|
||||||
export type CreateHighlightInput = {
|
export type CreateHighlightInput = {
|
||||||
annotation?: InputMaybe<Scalars['String']>;
|
annotation?: InputMaybe<Scalars['String']>;
|
||||||
articleId: Scalars['ID'];
|
articleId: Scalars['ID'];
|
||||||
|
highlightPositionAnchorIndex?: InputMaybe<Scalars['Int']>;
|
||||||
|
highlightPositionPercent?: InputMaybe<Scalars['Float']>;
|
||||||
id: Scalars['ID'];
|
id: Scalars['ID'];
|
||||||
patch: Scalars['String'];
|
patch: Scalars['String'];
|
||||||
prefix?: InputMaybe<Scalars['String']>;
|
prefix?: InputMaybe<Scalars['String']>;
|
||||||
|
|
@ -735,6 +737,8 @@ export type Highlight = {
|
||||||
annotation?: Maybe<Scalars['String']>;
|
annotation?: Maybe<Scalars['String']>;
|
||||||
createdAt: Scalars['Date'];
|
createdAt: Scalars['Date'];
|
||||||
createdByMe: Scalars['Boolean'];
|
createdByMe: Scalars['Boolean'];
|
||||||
|
highlightPositionAnchorIndex?: Maybe<Scalars['Int']>;
|
||||||
|
highlightPositionPercent?: Maybe<Scalars['Float']>;
|
||||||
id: Scalars['ID'];
|
id: Scalars['ID'];
|
||||||
patch: Scalars['String'];
|
patch: Scalars['String'];
|
||||||
prefix?: Maybe<Scalars['String']>;
|
prefix?: Maybe<Scalars['String']>;
|
||||||
|
|
@ -899,6 +903,8 @@ export enum MergeHighlightErrorCode {
|
||||||
export type MergeHighlightInput = {
|
export type MergeHighlightInput = {
|
||||||
annotation?: InputMaybe<Scalars['String']>;
|
annotation?: InputMaybe<Scalars['String']>;
|
||||||
articleId: Scalars['ID'];
|
articleId: Scalars['ID'];
|
||||||
|
highlightPositionAnchorIndex?: InputMaybe<Scalars['Int']>;
|
||||||
|
highlightPositionPercent?: InputMaybe<Scalars['Float']>;
|
||||||
id: Scalars['ID'];
|
id: Scalars['ID'];
|
||||||
overlapHighlightIdList: Array<Scalars['String']>;
|
overlapHighlightIdList: Array<Scalars['String']>;
|
||||||
patch: Scalars['String'];
|
patch: Scalars['String'];
|
||||||
|
|
@ -3780,6 +3786,8 @@ export type HighlightResolvers<ContextType = ResolverContext, ParentType extends
|
||||||
annotation?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
annotation?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
||||||
createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>;
|
createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>;
|
||||||
createdByMe?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
|
createdByMe?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
|
||||||
|
highlightPositionAnchorIndex?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
|
||||||
|
highlightPositionPercent?: Resolver<Maybe<ResolversTypes['Float']>, ParentType, ContextType>;
|
||||||
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
|
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
|
||||||
patch?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
patch?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||||
prefix?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
prefix?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,8 @@ enum CreateHighlightErrorCode {
|
||||||
input CreateHighlightInput {
|
input CreateHighlightInput {
|
||||||
annotation: String
|
annotation: String
|
||||||
articleId: ID!
|
articleId: ID!
|
||||||
|
highlightPositionAnchorIndex: Int
|
||||||
|
highlightPositionPercent: Float
|
||||||
id: ID!
|
id: ID!
|
||||||
patch: String!
|
patch: String!
|
||||||
prefix: String
|
prefix: String
|
||||||
|
|
@ -648,6 +650,8 @@ type Highlight {
|
||||||
annotation: String
|
annotation: String
|
||||||
createdAt: Date!
|
createdAt: Date!
|
||||||
createdByMe: Boolean!
|
createdByMe: Boolean!
|
||||||
|
highlightPositionAnchorIndex: Int
|
||||||
|
highlightPositionPercent: Float
|
||||||
id: ID!
|
id: ID!
|
||||||
patch: String!
|
patch: String!
|
||||||
prefix: String
|
prefix: String
|
||||||
|
|
@ -797,6 +801,8 @@ enum MergeHighlightErrorCode {
|
||||||
input MergeHighlightInput {
|
input MergeHighlightInput {
|
||||||
annotation: String
|
annotation: String
|
||||||
articleId: ID!
|
articleId: ID!
|
||||||
|
highlightPositionAnchorIndex: Int
|
||||||
|
highlightPositionPercent: Float
|
||||||
id: ID!
|
id: ID!
|
||||||
overlapHighlightIdList: [String!]!
|
overlapHighlightIdList: [String!]!
|
||||||
patch: String!
|
patch: String!
|
||||||
|
|
|
||||||
|
|
@ -639,6 +639,8 @@ const schema = gql`
|
||||||
updatedAt: Date!
|
updatedAt: Date!
|
||||||
reactions: [Reaction!]!
|
reactions: [Reaction!]!
|
||||||
createdByMe: Boolean!
|
createdByMe: Boolean!
|
||||||
|
highlightPositionPercent: Float
|
||||||
|
highlightPositionAnchorIndex: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
input CreateHighlightInput {
|
input CreateHighlightInput {
|
||||||
|
|
@ -651,6 +653,8 @@ const schema = gql`
|
||||||
suffix: String @sanitize
|
suffix: String @sanitize
|
||||||
annotation: String @sanitize(maxLength: 4000)
|
annotation: String @sanitize(maxLength: 4000)
|
||||||
sharedAt: Date
|
sharedAt: Date
|
||||||
|
highlightPositionPercent: Float
|
||||||
|
highlightPositionAnchorIndex: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateHighlightSuccess {
|
type CreateHighlightSuccess {
|
||||||
|
|
@ -681,6 +685,8 @@ const schema = gql`
|
||||||
suffix: String @sanitize
|
suffix: String @sanitize
|
||||||
annotation: String @sanitize(maxLength: 8000)
|
annotation: String @sanitize(maxLength: 8000)
|
||||||
overlapHighlightIdList: [String!]!
|
overlapHighlightIdList: [String!]!
|
||||||
|
highlightPositionPercent: Float
|
||||||
|
highlightPositionAnchorIndex: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type MergeHighlightSuccess {
|
type MergeHighlightSuccess {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ const createHighlightQuery = (
|
||||||
linkId: string,
|
linkId: string,
|
||||||
highlightId: string,
|
highlightId: string,
|
||||||
shortHighlightId: string,
|
shortHighlightId: string,
|
||||||
|
highlightPositionPercent = 0.0,
|
||||||
|
highlightPositionAnchorIndex = 0,
|
||||||
prefix = '_prefix',
|
prefix = '_prefix',
|
||||||
suffix = '_suffix',
|
suffix = '_suffix',
|
||||||
quote = '_quote',
|
quote = '_quote',
|
||||||
|
|
@ -37,11 +39,15 @@ const createHighlightQuery = (
|
||||||
shortId: "${shortHighlightId}",
|
shortId: "${shortHighlightId}",
|
||||||
patch: "${patch}",
|
patch: "${patch}",
|
||||||
articleId: "${linkId}",
|
articleId: "${linkId}",
|
||||||
|
highlightPositionPercent: ${highlightPositionPercent},
|
||||||
|
highlightPositionAnchorIndex: ${highlightPositionAnchorIndex}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
... on CreateHighlightSuccess {
|
... on CreateHighlightSuccess {
|
||||||
highlight {
|
highlight {
|
||||||
id
|
id
|
||||||
|
highlightPositionPercent
|
||||||
|
highlightPositionAnchorIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
... on CreateHighlightError {
|
... on CreateHighlightError {
|
||||||
|
|
@ -57,6 +63,8 @@ const mergeHighlightQuery = (
|
||||||
highlightId: string,
|
highlightId: string,
|
||||||
shortHighlightId: string,
|
shortHighlightId: string,
|
||||||
overlapHighlightIdList: string[],
|
overlapHighlightIdList: string[],
|
||||||
|
highlightPositionPercent = 0.0,
|
||||||
|
highlightPositionAnchorIndex = 0,
|
||||||
prefix = '_prefix',
|
prefix = '_prefix',
|
||||||
suffix = '_suffix',
|
suffix = '_suffix',
|
||||||
quote = '_quote',
|
quote = '_quote',
|
||||||
|
|
@ -73,12 +81,16 @@ const mergeHighlightQuery = (
|
||||||
shortId: "${shortHighlightId}",
|
shortId: "${shortHighlightId}",
|
||||||
patch: "${patch}",
|
patch: "${patch}",
|
||||||
articleId: "${pageId}",
|
articleId: "${pageId}",
|
||||||
overlapHighlightIdList: "${overlapHighlightIdList}"
|
overlapHighlightIdList: "${overlapHighlightIdList}",
|
||||||
|
highlightPositionPercent: ${highlightPositionPercent},
|
||||||
|
highlightPositionAnchorIndex: ${highlightPositionAnchorIndex}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
... on MergeHighlightSuccess {
|
... on MergeHighlightSuccess {
|
||||||
highlight {
|
highlight {
|
||||||
id
|
id
|
||||||
|
highlightPositionPercent
|
||||||
|
highlightPositionAnchorIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
... on MergeHighlightError {
|
... on MergeHighlightError {
|
||||||
|
|
@ -119,15 +131,25 @@ describe('Highlights API', () => {
|
||||||
it('should not fail', async () => {
|
it('should not fail', async () => {
|
||||||
const highlightId = generateFakeUuid()
|
const highlightId = generateFakeUuid()
|
||||||
const shortHighlightId = '_short_id'
|
const shortHighlightId = '_short_id'
|
||||||
|
const highlightPositionPercent = 35.0
|
||||||
|
const highlightPositionAnchorIndex = 15
|
||||||
const query = createHighlightQuery(
|
const query = createHighlightQuery(
|
||||||
authToken,
|
authToken,
|
||||||
pageId,
|
pageId,
|
||||||
highlightId,
|
highlightId,
|
||||||
shortHighlightId
|
shortHighlightId,
|
||||||
|
highlightPositionPercent,
|
||||||
|
highlightPositionAnchorIndex
|
||||||
)
|
)
|
||||||
const res = await graphqlRequest(query, authToken).expect(200)
|
const res = await graphqlRequest(query, authToken).expect(200)
|
||||||
|
|
||||||
expect(res.body.data.createHighlight.highlight.id).to.eq(highlightId)
|
expect(res.body.data.createHighlight.highlight.id).to.eq(highlightId)
|
||||||
|
expect(
|
||||||
|
res.body.data.createHighlight.highlight.highlightPositionPercent
|
||||||
|
).to.eq(highlightPositionPercent)
|
||||||
|
expect(
|
||||||
|
res.body.data.createHighlight.highlight.highlightPositionAnchorIndex
|
||||||
|
).to.eq(highlightPositionAnchorIndex)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -150,15 +172,25 @@ describe('Highlights API', () => {
|
||||||
it('should not fail', async () => {
|
it('should not fail', async () => {
|
||||||
const newHighlightId = generateFakeUuid()
|
const newHighlightId = generateFakeUuid()
|
||||||
const newShortHighlightId = '_short_id_2'
|
const newShortHighlightId = '_short_id_2'
|
||||||
|
const highlightPositionPercent = 50.0
|
||||||
|
const highlightPositionAnchorIndex = 25
|
||||||
const query = mergeHighlightQuery(
|
const query = mergeHighlightQuery(
|
||||||
pageId,
|
pageId,
|
||||||
newHighlightId,
|
newHighlightId,
|
||||||
newShortHighlightId,
|
newShortHighlightId,
|
||||||
[highlightId]
|
[highlightId],
|
||||||
|
highlightPositionPercent,
|
||||||
|
highlightPositionAnchorIndex
|
||||||
)
|
)
|
||||||
const res = await graphqlRequest(query, authToken).expect(200)
|
const res = await graphqlRequest(query, authToken).expect(200)
|
||||||
|
|
||||||
expect(res.body.data.mergeHighlight.highlight.id).to.eq(newHighlightId)
|
expect(res.body.data.mergeHighlight.highlight.id).to.eq(newHighlightId)
|
||||||
|
expect(
|
||||||
|
res.body.data.mergeHighlight.highlight.highlightPositionPercent
|
||||||
|
).to.eq(highlightPositionPercent)
|
||||||
|
expect(
|
||||||
|
res.body.data.mergeHighlight.highlight.highlightPositionAnchorIndex
|
||||||
|
).to.eq(highlightPositionAnchorIndex)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,12 @@
|
||||||
"type": "date"
|
"type": "date"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"highlightPositionPercent": {
|
||||||
|
"type": "float"
|
||||||
|
},
|
||||||
|
"highlightPositionAnchorIndex": {
|
||||||
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue