Skip to content

feat: add code autocomplete dropdown using CodeMirror show-hint #3758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import PropTypes from 'prop-types'
import React from 'react'
import _ from 'lodash'
import CodeMirror from 'codemirror'
import 'codemirror/addon/hint/show-hint';
import 'codemirror/addon/hint/show-hint.css';
import 'codemirror/addon/hint/anyword-hint'; // Optional basic hinting

import hljs from 'highlight.js'
import 'codemirror-mode-elixir'
import attachmentManagement from 'browser/main/lib/dataApi/attachmentManagement'
Expand Down Expand Up @@ -31,6 +35,7 @@ import markdownlint from 'markdownlint'
import Jsonlint from 'jsonlint-mod'
import { DEFAULT_CONFIG } from '../main/lib/ConfigManager'
import prettier from 'prettier'
import { space } from 'prettier/parser-postcss';

CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'

Expand Down Expand Up @@ -328,6 +333,7 @@ export default class CodeEditor extends React.Component {
lineNumbers: this.props.displayLineNumbers,
lineWrapping: this.props.lineWrapping,
theme: this.props.theme,

indentUnit: this.props.indentSize,
tabSize: this.props.indentSize,
indentWithTabs: this.props.indentType !== 'space',
Expand Down Expand Up @@ -359,7 +365,12 @@ export default class CodeEditor extends React.Component {
}
},
extraKeys: this.defaultKeyMap,
prettierConfig: this.props.prettierConfig
'Ctrl-Space':'autocomplete',
prettierConfig: this.props.prettierConfig,
hintOptions: {
completeSingle:false
}

})

document.querySelector(
Expand Down
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Boostnote Test</title>
</head>
<body>
<h1>Boostnote App Loaded</h1>
</body>
</html>
82 changes: 61 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
const { app } = require('electron')
const { app,BrowserWindow } = require('electron')
const ChildProcess = require('child_process')
const path = require('path')




var error = null

function execMainApp() {
const appRootPath = path.join(process.execPath, '../..')
const updateDotExePath = path.join(appRootPath, 'Update.exe')
// const updateDotExePath = path.join(appRootPath, 'Update.exe')
const exeName = path.basename(process.execPath)

function spawnUpdate(args, cb) {
var stdout = ''
var updateProcess = null
try {
updateProcess = ChildProcess.spawn(updateDotExePath, args)
// updateProcess = ChildProcess.spawn(updateDotExePath, args)
} catch (e) {
process.nextTick(function() {
cb(e)
})
}

updateProcess.stdout.on('data', function(data) {
stdout += data
})

updateProcess.on('error', function(_error) {
error = _error
})
updateProcess.on('close', function(code, signal) {
if (code !== 0) {
error = new Error('Command failed: #{signal ? code}')
error.code = code
error.stdout = stdout
}

cb(error, stdout)
})
// updateProcess.stdout.on('data', function(data) {
// stdout += data
// })

// updateProcess.on('error', function(_error) {
// error = _error
// })
// updateProcess.on('close', function(code, signal) {
// if (code !== 0) {
// error = new Error('Command failed: #{signal ? code}')
// error.code = code
// error.stdout = stdout
// }

// cb(error, stdout)
// })
}

var handleStartupEvent = function() {
Expand Down Expand Up @@ -73,4 +75,42 @@ function execMainApp() {
require('./lib/main-app')
}

execMainApp()






function createWindow() {
const win = new BrowserWindow({
width: 1000,
height: 700,
webPreferences: {
nodeIntegration: true, // Enable this if needed
contextIsolation: false, // Disable for legacy apps
},
});

win.loadFile('index.html');
// Adjust path if index.html is somewhere else
win.webContents .openDevTools();
}



app.on('ready', createWindow);

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

execMainApp();

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"aws-sdk": "^2.48.0",
"aws-sdk-mobile-analytics": "^0.9.2",
"chart.js": "^2.7.2",
"codemirror": "^5.40.2",
"codemirror": "^5.65.19",
"codemirror-mode-elixir": "^1.1.1",
"command-exists": "^1.2.9",
"connected-react-router": "^6.4.0",
Expand Down
Loading