Add Ace to the project (not yet used)
This commit is contained in:
parent
98f7cacb55
commit
bb2dcf0039
|
@ -0,0 +1,14 @@
|
||||||
|
// load Ace editor
|
||||||
|
import ace from 'ace-builds/src-noconflict/ace'
|
||||||
|
|
||||||
|
// load required Ace plugins
|
||||||
|
import 'ace-builds/src-noconflict/mode-json'
|
||||||
|
import 'ace-builds/src-noconflict/ext-searchbox'
|
||||||
|
|
||||||
|
// embed Ace json worker
|
||||||
|
// generated via tools/generateWorkerJSONDataUrl.mjs
|
||||||
|
// https://github.com/ajaxorg/ace/issues/3913
|
||||||
|
import jsonWorkerDataUrl from '../generated/worker-json-data-url'
|
||||||
|
ace.config.setModuleUrl('ace/mode/json_worker', jsonWorkerDataUrl)
|
||||||
|
|
||||||
|
export const aceJson = ace
|
|
@ -0,0 +1,15 @@
|
||||||
|
import btoa from 'btoa'
|
||||||
|
import { readFileSync, writeFileSync } from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import mkdirp from 'mkdirp'
|
||||||
|
|
||||||
|
const workerBundleFile = './node_modules/ace-builds/src-noconflict/worker-json.js'
|
||||||
|
const outputFolder = './src/generated/ace'
|
||||||
|
const workerEmbeddedFile = path.join(outputFolder, 'jsonWorker.mjs')
|
||||||
|
|
||||||
|
// Create an embedded version of the json worker code of Ace editor: a data url
|
||||||
|
const workerScript = String(readFileSync(workerBundleFile))
|
||||||
|
const workerDataUrl = 'data:application/javascript;base64,' + btoa(workerScript)
|
||||||
|
|
||||||
|
mkdirp.sync(outputFolder)
|
||||||
|
writeFileSync(workerEmbeddedFile, 'export const jsonWorker = \'' + workerDataUrl + '\'\n')
|
Loading…
Reference in New Issue