-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare connection to picker
- Loading branch information
Showing
11 changed files
with
203 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import { Action } from "readium-desktop/common/models/redux"; | ||
import { IAnnotationUserInterfaceState, annotationDefaultState } from "../../state/annotation"; | ||
|
||
export const ID = "READER_ANNOTATION_CANCEL"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface IPayload extends Partial<IAnnotationUserInterfaceState> { | ||
} | ||
|
||
export function build(): | ||
Action<typeof ID, IPayload> { | ||
|
||
return { | ||
type: ID, | ||
payload: annotationDefaultState(), | ||
}; | ||
} | ||
build.toString = () => ID; // Redux StringableActionCreator | ||
export type TAction = ReturnType<typeof build>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import { Action } from "readium-desktop/common/models/redux"; | ||
import { IColor } from "@r2-navigator-js/electron/common/highlight"; | ||
import { IAnnotationUserInterfaceState } from "../../state/annotation"; | ||
|
||
export const ID = "READER_ANNOTATION_COLOR"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface IPayload extends Partial<IAnnotationUserInterfaceState> { | ||
} | ||
|
||
export function build(color: IColor): | ||
Action<typeof ID, IPayload> { | ||
|
||
return { | ||
type: ID, | ||
payload: { | ||
color, | ||
}, | ||
}; | ||
} | ||
build.toString = () => ID; // Redux StringableActionCreator | ||
export type TAction = ReturnType<typeof build>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import { Action } from "readium-desktop/common/models/redux"; | ||
import { IAnnotationUserInterfaceState } from "../../state/annotation"; | ||
|
||
export const ID = "READER_ANNOTATION_ENABLE"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface IPayload extends Partial<IAnnotationUserInterfaceState> { | ||
} | ||
|
||
export function build(): | ||
Action<typeof ID, IPayload> { | ||
|
||
return { | ||
type: ID, | ||
payload: { | ||
enable: true, | ||
}, | ||
}; | ||
} | ||
build.toString = () => ID; // Redux StringableActionCreator | ||
export type TAction = ReturnType<typeof build>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import { Action } from "readium-desktop/common/models/redux"; | ||
import { diReaderGet } from "readium-desktop/renderer/reader/di"; | ||
import { IAnnotationUserInterfaceState } from "../../state/annotation"; | ||
|
||
export const ID = "READER_ANNOTATION_FOCUS"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface IPayload extends Partial<IAnnotationUserInterfaceState> { | ||
} | ||
|
||
export function build(focusUUId: IAnnotationUserInterfaceState["newFocusAnnotationUUID"]): | ||
Action<typeof ID, IPayload> { | ||
|
||
const store = diReaderGet("store"); | ||
const { newFocusAnnotationUUID: oldFocusUUId } = store.getState().annotation; | ||
return { | ||
type: ID, | ||
payload: { | ||
newFocusAnnotationUUID: focusUUId, | ||
oldFocusAnnotationUUID: oldFocusUUId, | ||
}, | ||
}; | ||
} | ||
build.toString = () => ID; // Redux StringableActionCreator | ||
export type TAction = ReturnType<typeof build>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import * as enable from "./enable"; | ||
import * as focus from "./focus"; | ||
import * as color from "./color"; | ||
import * as cancel from "./cancel"; | ||
|
||
export { | ||
focus, | ||
color, | ||
enable, | ||
cancel, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import { readerLocalActionAnnotationUI } from "../actions"; | ||
import { IAnnotationUserInterfaceState, annotationDefaultState } from "../state/annotation"; | ||
|
||
export function annotationUIReducer( | ||
state: IAnnotationUserInterfaceState = annotationDefaultState(), | ||
action: readerLocalActionAnnotationUI.color.TAction | | ||
readerLocalActionAnnotationUI.enable.TAction | | ||
readerLocalActionAnnotationUI.focus.TAction | | ||
readerLocalActionAnnotationUI.cancel.TAction, | ||
): IAnnotationUserInterfaceState { | ||
|
||
switch (action.type) { | ||
case readerLocalActionAnnotationUI.cancel.ID: | ||
case readerLocalActionAnnotationUI.enable.ID: | ||
case readerLocalActionAnnotationUI.focus.ID: | ||
case readerLocalActionAnnotationUI.color.ID: | ||
|
||
return { | ||
...state, | ||
...action.payload, | ||
}; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import { IAnnotationState } from "readium-desktop/common/redux/states/annotation"; | ||
import { IColor } from "@r2-navigator-js/electron/common/highlight"; | ||
|
||
export interface IAnnotationUserInterfaceState { | ||
enable: boolean; | ||
newFocusAnnotationUUID: IAnnotationState["uuid"]; | ||
oldFocusAnnotationUUID: IAnnotationState["uuid"]; | ||
color: IColor | ||
} | ||
|
||
export const annotationDefaultState = (): IAnnotationUserInterfaceState => | ||
({ | ||
enable: false, | ||
newFocusAnnotationUUID: "", | ||
oldFocusAnnotationUUID: "", | ||
color: {red: 0, green: 0, blue: 0}, | ||
}); |