From 316d8fa1fb5db4b4ee40f591cae7a718812e3837 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sat, 21 May 2016 21:51:51 +0200 Subject: [PATCH] :arrow_up: spell-check. --- {spellchecking => spell-check}/README.md | 0 {spellchecking => spell-check}/app.css | 0 spell-check/app.js | 13 +++++ {spellchecking => spell-check}/index.html | 0 {spellchecking => spell-check}/main.js | 60 ++++++++++----------- {spellchecking => spell-check}/package.json | 2 +- spellchecking/app.js | 10 ---- 7 files changed, 41 insertions(+), 44 deletions(-) rename {spellchecking => spell-check}/README.md (100%) rename {spellchecking => spell-check}/app.css (100%) create mode 100644 spell-check/app.js rename {spellchecking => spell-check}/index.html (100%) rename {spellchecking => spell-check}/main.js (60%) rename {spellchecking => spell-check}/package.json (83%) delete mode 100644 spellchecking/app.js diff --git a/spellchecking/README.md b/spell-check/README.md similarity index 100% rename from spellchecking/README.md rename to spell-check/README.md diff --git a/spellchecking/app.css b/spell-check/app.css similarity index 100% rename from spellchecking/app.css rename to spell-check/app.css diff --git a/spell-check/app.js b/spell-check/app.js new file mode 100644 index 0000000..a569265 --- /dev/null +++ b/spell-check/app.js @@ -0,0 +1,13 @@ +// initialize spell checking +const checker = require('spellchecker'); + +const {remote} = require('electron'); +const {webFrame} = remote; + +webFrame.setSpellCheckProvider("en-US", true, { + spellCheck: function(text) { + console.log("Spellchecker called on "+text); + return !checker.isMisspelled(text); + } +}); + diff --git a/spellchecking/index.html b/spell-check/index.html similarity index 100% rename from spellchecking/index.html rename to spell-check/index.html diff --git a/spellchecking/main.js b/spell-check/main.js similarity index 60% rename from spellchecking/main.js rename to spell-check/main.js index 502e73c..c03e732 100644 --- a/spellchecking/main.js +++ b/spell-check/main.js @@ -1,33 +1,27 @@ -var app = require('app'); // Module to control application life. -var BrowserWindow = require('browser-window'); // Module to create native browser window. - -// Report crashes to our server. -require('crash-reporter').start(); - -// Keep a global reference of the window object, if you don't, the window will -// be closed automatically when the javascript object is GCed. -var mainWindow = null; - -// Quit when all windows are closed. -app.on('window-all-closed', function() { - if (process.platform != 'darwin') - app.quit(); -}); - -// This method will be called when Electron has done everything -// initialization and ready for creating browser windows. -app.on('ready', function() { - // Create the browser window. - mainWindow = new BrowserWindow({width: 800, height: 600}); - - // and load the index.html of the app. - mainWindow.loadUrl('file://' + __dirname + '/index.html'); - - // Emitted when the window is closed. - mainWindow.on('closed', function() { - // Dereference the window object, usually you would store windows - // in an array if your app supports multi windows, this is the time - // when you should delete the corresponding element. - mainWindow = null; - }); -}); +const {app, BrowserWindow} = require('electron'); + +let mainWindow; + +// Quit when all windows are closed. +app.on('window-all-closed', function() { + if (process.platform != 'darwin') + app.quit(); +}); + +// This method will be called when Electron has done everything +// initialization and ready for creating browser windows. +app.on('ready', function() { + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}); + + // and load the index.html of the app. + mainWindow.loadURL('file://' + __dirname + '/index.html'); + + // Emitted when the window is closed. + mainWindow.on('closed', function() { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null; + }); +}); diff --git a/spellchecking/package.json b/spell-check/package.json similarity index 83% rename from spellchecking/package.json rename to spell-check/package.json index f25303f..f51c1f9 100644 --- a/spellchecking/package.json +++ b/spell-check/package.json @@ -1,6 +1,6 @@ { "name" : "spellchecker-demo", - "version" : "0.1.0", + "version" : "1.1.0", "main" : "main.js", "dependencies": { "spellchecker": "2.2.0" diff --git a/spellchecking/app.js b/spellchecking/app.js deleted file mode 100644 index f7bf2a4..0000000 --- a/spellchecking/app.js +++ /dev/null @@ -1,10 +0,0 @@ - -// initialize spell checking -checker = require('spellchecker'); -require('web-frame').setSpellCheckProvider("en-US", true, { - spellCheck: function(text) { - console.log("Spellchecker called on "+text); - return !checker.isMisspelled(text); - } -}); -