Coder Social home page Coder Social logo

electron-find's Introduction

electron-find

English | 简体中文

Introduction

Find all matches for the text in electron app

Features

  • depend on the API of electron's findInPage
  • support user config UI of find interface
  • support case-sensitive
  • Auto find when user inputing is change
  • The find interface is separated from electron view
  • support electron version ^1.8.0, ^2.0.0, ^3.0.0, ^4.0.0
  • support platform of Windows, Linux, Mac

Demo

Default UI

demo

Custom UI

demo

Install

$   npm install electron-find --save

Usage

# import module
import { remote, ipcRenderer } from 'electron'
import { FindInPage } from 'electron-find'

# creat instance of FindInPage with default config
let findInPage = new FindInPage(remote.getCurrentWebContents())
findInPage.openFindWindow()

# use preload option, the find interface will be loaded when creat instance
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
  preload: true
})
findInPage.openFindWindow()

# config parentElement of find interface, default is document.body
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
  parentElement: document.querySelector('#id')
})
findInPage.openFindWindow()

# config duration of find interface moving, default is 300 (ms)
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
  duration: 200
})
findInPage.openFindWindow()

# config offset relative to parentElement
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
  offsetTop: 20,
  offsetRight: 30
})
findInPage.openFindWindow()

# config UI of find interface 
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
  boxBgColor: '#333',
  boxShadowColor: '#000',
  inputColor: '#aaa',
  inputBgColor: '#222',
  inputFocusColor: '#555',
  textColor: '#aaa',
  textHoverBgColor: '#555',
  caseSelectedColor: '#555'
})
findInPage.openFindWindow()

# there is a simply demo for reference
npm install
npm run e

Shortcut

keys function
Enter find next
Shift + Enter find back
Esc close

Besides, you can also register global shortcut to open the find window, just like the demo.

API

Class: FindInPage

new FindInPage(webContents, [options])

  • webContents Object(required) - The webContents of renderer process
  • options Object(optional)
    • preload Boolean - Whether load the find interface when creat instance. Default is false.
    • parentElement Object - Specify parent dom of the find interface. Default is document.body.
    • duration Number - Specify moving time when the find window open or close. Default is 300 (ms).
    • offsetTop Number - Specify offset relative to the top of parentElement. Default is 5.
    • offsetRight Number - Specify offset relative to the right of parentElement. Default is 5.
    • boxBgColor String - Specify background color of the find interface. Default is "#ffffff".
    • boxShadowColor String - Specify shadow color of the find interface. Default is "#909399".
    • inputColor String - Specify text color of the input form. Default is "#606266".
    • inputBgColor String - Specify background color of the input form. Default is "#f0f0f0".
    • inputFocusColor String - Specify border color of the input form when focusing. Default is "#c5ade0".
    • textColor String - Specify color of the text in find interface. Default is "#606266".
    • textHoverBgColor String - Specify background color of text in find interface when hovering. Default is "#eaeaea".
    • caseSelectedColor String - Specify border color of the matchCase button when selected. Default is "#c5ade0".

Instance Methods

Objects created with new FindInPage have the following instance methods:
 
findInPage.openFindWindow()
Open the find window when it is closed. Focus input form when the find window has opened.
 
findInPage.closeFindWindow()
Close the find window when it has opened.
 
findInPage.destroy()
Close the find window, and release memery.

electron-find's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.