Skip to content

Commit

Permalink
fixes request config
Browse files Browse the repository at this point in the history
  • Loading branch information
aferditamuriqi committed Aug 20, 2022
1 parent 4a7d9ed commit fc91044
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions injectables/style/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
margin: 0;
background-color: #fafafa;
border-radius: 0.5em;
line-height: 0;
/*line-height: 1;*/
max-width: 353px;
}
.d2-popup-content {
Expand All @@ -117,5 +117,5 @@
background: #fafafa;
border-radius: 0.5em;
-webkit-font-smoothing: subpixel-antialiased;
line-height: normal;
line-height: normal !important;
}
5 changes: 0 additions & 5 deletions src/model/Locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,3 @@ export interface Annotation extends Locator {
created: Date;
highlight?: IHighlight;
}

export interface ChapterWeight {
chapterHref: string;
weight: number;
}
22 changes: 9 additions & 13 deletions src/modules/search/SearchModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

import * as HTMLUtilities from "../../utils/HTMLUtilities";
import { Publication } from "../../model/Publication";
import {
IFrameNavigator,
RequestConfig,
} from "../../navigator/IFrameNavigator";
import { IFrameNavigator } from "../../navigator/IFrameNavigator";
import { ReaderModule } from "../ReaderModule";
import {
addEventListenerOptional,
Expand Down Expand Up @@ -50,7 +47,6 @@ export interface SearchModuleConfig extends SearchModuleProperties {
publication: Publication;
headerMenu?: HTMLElement | null;
delegate: IFrameNavigator;
requestConfig?: RequestConfig;
highlighter: TextHighlighter;
}

Expand All @@ -67,15 +63,13 @@ export class SearchModule implements ReaderModule {
private bookSearchResult: any = [];
private currentSearchHighlights: any = [];
private highlighter?: TextHighlighter;
private requestConfig?: RequestConfig;

public static async create(config: SearchModuleConfig) {
const search = new this(
config.delegate,
config.publication,
config as SearchModuleProperties,
config.highlighter,
config.requestConfig,
config.api,
config.headerMenu
);
Expand All @@ -89,7 +83,6 @@ export class SearchModule implements ReaderModule {
publication: Publication,
properties: SearchModuleProperties,
highlighter: TextHighlighter,
requestConfig?: RequestConfig,
api?: SearchModuleAPI,
headerMenu?: HTMLElement | null
) {
Expand All @@ -99,7 +92,6 @@ export class SearchModule implements ReaderModule {
this.properties = properties;
this.api = api;
this.highlighter = highlighter;
this.requestConfig = requestConfig;
}

async stop() {
Expand Down Expand Up @@ -725,13 +717,15 @@ export class SearchModule implements ReaderModule {
}
if (tocItem) {
let href = this.publication.getAbsoluteHref(tocItem.Href);
await fetch(href, this.requestConfig)
await fetch(href, this.delegate.requestConfig)
.then((r) => r.text())
.then(async (data) => {
// ({ data, tocItem });
let parser = new DOMParser();
let doc = parser.parseFromString(
this.requestConfig?.encoded ? this.decodeBase64(data) : data,
this.delegate.requestConfig?.encoded
? this.decodeBase64(data)
: data,
"application/xhtml+xml"
);
if (tocItem) {
Expand Down Expand Up @@ -776,13 +770,15 @@ export class SearchModule implements ReaderModule {
}
if (tocItem) {
let href = this.publication.getAbsoluteHref(tocItem.Href);
await fetch(href, this.requestConfig)
await fetch(href, this.delegate.requestConfig)
.then((r) => r.text())
.then(async (data) => {
// ({ data, tocItem });
let parser = new DOMParser();
let doc = parser.parseFromString(
this.requestConfig?.encoded ? this.decodeBase64(data) : data,
this.delegate.requestConfig?.encoded
? this.decodeBase64(data)
: data,
"application/xhtml+xml"
);
if (tocItem) {
Expand Down
3 changes: 2 additions & 1 deletion src/navigator/IFrameNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
config.injectables,
config.attributes || { margin: 0 },
config.services,
config.sample
config.sample,
config.requestConfig
);

await navigator.start(
Expand Down
1 change: 0 additions & 1 deletion src/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ export default class D2Reader {
delegate: navigator,
publication: publication,
highlighter: highlighter,
requestConfig: initialConfig.requestConfig,
...initialConfig.search,
})
: undefined;
Expand Down

0 comments on commit fc91044

Please sign in to comment.