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