victorsoares96 / epubjs-react-native

ePub.js Reader for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detect hyperlink in between text of epub and when clicked a modal should appear

Mujab01 opened this issue · comments

When i click a hyperlink in between text of epub.A react native modal should open and show some contents in it how can i achieve this?? can any one help me on this...

thanks in advance

You can use this example to apply to your use case:
(available in v1.4.0 or higher)

import * as React from 'react';
import { Linking, SafeAreaView, useWindowDimensions } from 'react-native';
import { Reader, ReaderProvider } from '@epubjs-react-native/core';
import { useFileSystem } from '@epubjs-react-native/file-system';

export function OpenExternalLink() {
  const { width, height } = useWindowDimensions();

  return (
    <SafeAreaView>
      <ReaderProvider>
        <Reader
          src="https://github.com/IDPF/epub3-samples/releases/download/20230704/accessible_epub_3.epub"
          width={width}
          height={height}
          fileSystem={useFileSystem}
          initialLocation="pr01s04.xhtml"
          onPressExternalLink={(url) => {
            Linking.openURL(url);
          }}
        />
      </ReaderProvider>
    </SafeAreaView>
  );
}