react-ace
Advanced tools
Comparing version 8.1.0 to 9.0.0
@@ -1,1 +0,1 @@ | ||
{"processes":{"470bbe42-0740-4127-9aea-9d353693d346":{"parent":"cce163f5-3d06-4864-9598-1e6f55c1ceae","children":[]},"cce163f5-3d06-4864-9598-1e6f55c1ceae":{"parent":null,"children":["470bbe42-0740-4127-9aea-9d353693d346"]}},"files":{},"externalIds":{}} | ||
{"processes":{"a3393e5a-c87a-4d4d-8a84-b6932640d208":{"parent":null,"children":["a7d22186-f650-4fa9-8e62-9918e28582a4"]},"a7d22186-f650-4fa9-8e62-9918e28582a4":{"parent":"a3393e5a-c87a-4d4d-8a84-b6932640d208","children":[]}},"files":{},"externalIds":{}} |
@@ -18,2 +18,3 @@ # Ace Editor | ||
import "ace-builds/src-noconflict/theme-github"; | ||
import "ace-builds/src-noconflict/ext-language_tools" | ||
@@ -32,2 +33,7 @@ function onChange(newValue) { | ||
editorProps={{ $blockScrolling: true }} | ||
setOptions={{ | ||
enableBasicAutocompletion: true, | ||
enableLiveAutocompletion: true, | ||
enableSnippets: true | ||
}} | ||
/>, | ||
@@ -34,0 +40,0 @@ document.getElementById("example") |
@@ -0,5 +1,6 @@ | ||
import { Ace } from "ace-builds"; | ||
import * as AceBuilds from "ace-builds"; | ||
import * as PropTypes from "prop-types"; | ||
import * as React from "react"; | ||
import { AceEditorClass } from "./AceEditorClass"; | ||
import { IAceOptions, IAnnotation, ICommand, IEditorProps, IMarker } from "./types"; | ||
import { IAceEditor, IAceOptions, ICommand, IEditorProps, IMarker } from "./types"; | ||
/** | ||
@@ -41,5 +42,5 @@ * See https://github.com/ajaxorg/ace/wiki/Configuring-Ace | ||
onInput?: (event?: any) => void; | ||
onLoad?: (editor: IEditorProps) => void; | ||
onValidate?: (annotations: IAnnotation[]) => void; | ||
onBeforeLoad?: (ace: any) => void; | ||
onLoad?: (editor: Ace.Editor) => void; | ||
onValidate?: (annotations: Ace.Annotation[]) => void; | ||
onBeforeLoad?: (ace: typeof AceBuilds) => void; | ||
onChange?: (value: string, event?: any) => void; | ||
@@ -49,4 +50,4 @@ onSelection?: (selectedText: string, event?: any) => void; | ||
onPaste?: (value: string) => void; | ||
onFocus?: (event: any, editor?: AceEditorClass) => void; | ||
onBlur?: (event: any, editor?: AceEditorClass) => void; | ||
onFocus?: (event: any, editor?: Ace.Editor) => void; | ||
onBlur?: (event: any, editor?: Ace.Editor) => void; | ||
onScroll?: (editor: IEditorProps) => void; | ||
@@ -57,3 +58,3 @@ editorProps?: IEditorProps; | ||
commands?: ICommand[]; | ||
annotations?: IAnnotation[]; | ||
annotations?: Ace.Annotation[]; | ||
markers?: IMarker[]; | ||
@@ -64,3 +65,3 @@ } | ||
static defaultProps: Partial<IAceEditorProps>; | ||
editor: AceEditorClass; | ||
editor: IAceEditor; | ||
refEditor: HTMLElement; | ||
@@ -77,7 +78,11 @@ debounce: (fn: any, delay: number) => (...args: any) => void; | ||
onCursorChange(event: any): void; | ||
onInput(event: any): void; | ||
onInput(event?: any): void; | ||
onFocus(event: any): void; | ||
onBlur(event: any): void; | ||
onCopy(text: string): void; | ||
onPaste(text: string): void; | ||
onCopy({ text }: { | ||
text: string; | ||
}): void; | ||
onPaste({ text }: { | ||
text: string; | ||
}): void; | ||
onScroll(): void; | ||
@@ -84,0 +89,0 @@ handleOptions(props: IAceEditorProps): void; |
@@ -45,3 +45,3 @@ "use strict"; | ||
var _this = this; | ||
var _a = this.props, className = _a.className, onBeforeLoad = _a.onBeforeLoad, onValidate = _a.onValidate, mode = _a.mode, focus = _a.focus, theme = _a.theme, fontSize = _a.fontSize, value = _a.value, defaultValue = _a.defaultValue, cursorStart = _a.cursorStart, showGutter = _a.showGutter, wrapEnabled = _a.wrapEnabled, showPrintMargin = _a.showPrintMargin, _b = _a.scrollMargin, scrollMargin = _b === void 0 ? [0, 0, 0, 0] : _b, keyboardHandler = _a.keyboardHandler, onLoad = _a.onLoad, commands = _a.commands, annotations = _a.annotations, markers = _a.markers, placeholder = _a.placeholder; | ||
var _a = this.props, className = _a.className, onBeforeLoad = _a.onBeforeLoad, onValidate = _a.onValidate, mode = _a.mode, focus = _a.focus, theme = _a.theme, fontSize = _a.fontSize, value = _a.value, defaultValue = _a.defaultValue, showGutter = _a.showGutter, wrapEnabled = _a.wrapEnabled, showPrintMargin = _a.showPrintMargin, _b = _a.scrollMargin, scrollMargin = _b === void 0 ? [0, 0, 0, 0] : _b, keyboardHandler = _a.keyboardHandler, onLoad = _a.onLoad, commands = _a.commands, annotations = _a.annotations, markers = _a.markers, placeholder = _a.placeholder; | ||
this.editor = ace.edit(this.refEditor); | ||
@@ -61,6 +61,4 @@ if (onBeforeLoad) { | ||
this.editor.setTheme("ace/theme/" + theme); | ||
this.editor.setFontSize(fontSize); | ||
this.editor | ||
.getSession() | ||
.setValue(!defaultValue ? value : defaultValue, cursorStart); | ||
this.editor.setFontSize(typeof fontSize === "number" ? fontSize + "px" : fontSize); | ||
this.editor.getSession().setValue(!defaultValue ? value : defaultValue); | ||
if (this.props.navigateToFileEnd) { | ||
@@ -86,2 +84,3 @@ this.editor.navigateFileEnd(); | ||
if (onValidate) { | ||
// @ts-ignore types don't include | ||
this.editor.getSession().on("changeAnnotation", function () { | ||
@@ -102,2 +101,3 @@ // tslint:disable-next-line:no-shadowed-variable | ||
if (availableOptions.hasOwnProperty(option)) { | ||
// @ts-ignore | ||
_this.editor.setOption(option, _this.props[option]); | ||
@@ -140,2 +140,3 @@ } | ||
if (nextProps[option] !== oldProps[option]) { | ||
// @ts-ignore | ||
this.editor.setOption(option, nextProps[option]); | ||
@@ -182,3 +183,5 @@ } | ||
if (nextProps.fontSize !== oldProps.fontSize) { | ||
this.editor.setFontSize(nextProps.fontSize); | ||
this.editor.setFontSize(typeof nextProps.fontSize === "number" | ||
? nextProps.fontSize + "px" | ||
: nextProps.fontSize); | ||
} | ||
@@ -218,3 +221,3 @@ if (nextProps.wrapEnabled !== oldProps.wrapEnabled) { | ||
if (margins === void 0) { margins = [0, 0, 0, 0]; } | ||
this.editor.renderer.setScrollMargins(margins[0], margins[1], margins[2], margins[3]); | ||
this.editor.renderer.setScrollMargin(margins[0], margins[1], margins[2], margins[3]); | ||
}; | ||
@@ -261,3 +264,4 @@ ReactAce.prototype.componentWillUnmount = function () { | ||
}; | ||
ReactAce.prototype.onCopy = function (text) { | ||
ReactAce.prototype.onCopy = function (_a) { | ||
var text = _a.text; | ||
if (this.props.onCopy) { | ||
@@ -267,3 +271,4 @@ this.props.onCopy(text); | ||
}; | ||
ReactAce.prototype.onPaste = function (text) { | ||
ReactAce.prototype.onPaste = function (_a) { | ||
var text = _a.text; | ||
if (this.props.onPaste) { | ||
@@ -281,2 +286,3 @@ this.props.onPaste(text); | ||
for (var y = 0; y < setOptions.length; y++) { | ||
// @ts-ignore | ||
this.editor.setOption(setOptions[y], props.setOptions[setOptions[y]]); | ||
@@ -283,0 +289,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import * as AceBuilds from "ace-builds"; | ||
declare type EditorOption = "minLines" | "maxLines" | "readOnly" | "highlightActiveLine" | "tabSize" | "enableBasicAutocompletion" | "enableLiveAutocompletion" | "enableSnippets"; | ||
@@ -5,4 +6,11 @@ declare const editorOptions: EditorOption[]; | ||
declare const editorEvents: EditorEvent[]; | ||
declare const getAceInstance: () => any; | ||
declare global { | ||
namespace NodeJS { | ||
interface Global { | ||
window: any; | ||
} | ||
} | ||
} | ||
declare const getAceInstance: () => typeof AceBuilds; | ||
declare const debounce: (fn: (...args: any[]) => void, delay: number) => () => void; | ||
export { editorOptions, editorEvents, debounce, getAceInstance }; |
@@ -30,4 +30,13 @@ "use strict"; | ||
var ace; | ||
// Fallback for ace.require when vanilla ACE is hosted over a CDN | ||
if (window.ace) { | ||
if (typeof window === "undefined") { | ||
// ace-builds just needs some window object to attach ace to. | ||
// During SSR even just an empty object will work. | ||
global.window = {}; | ||
ace = require("ace-builds"); | ||
// And it can be discarded immediately afterward to avoid confusing | ||
// other libraries that might detect SSR the same way we did. | ||
delete global.window; | ||
} | ||
else if (window.ace) { | ||
// Fallback for ace.require when vanilla ACE is hosted over a CDN | ||
ace = window.ace; | ||
@@ -44,2 +53,3 @@ ace.acequire = window.ace.require || window.ace.acequire; | ||
var timer = null; | ||
// tslint:disable-next-line | ||
return function () { | ||
@@ -46,0 +56,0 @@ var context = this; |
@@ -0,1 +1,2 @@ | ||
import { Ace } from "ace-builds"; | ||
export interface ICommandManager { | ||
@@ -45,3 +46,3 @@ byName: any; | ||
className: string; | ||
type: string; | ||
type: "fullLine" | "screenLine" | "text" | Ace.MarkerRenderer; | ||
inFront?: boolean; | ||
@@ -123,1 +124,10 @@ } | ||
} | ||
interface IRenderer extends Ace.VirtualRenderer { | ||
placeholderNode?: HTMLDivElement; | ||
scroller?: HTMLDivElement; | ||
} | ||
export declare type IAceEditor = Ace.Editor & { | ||
renderer: IRenderer; | ||
[index: string]: any; | ||
}; | ||
export {}; |
{ | ||
"name": "react-ace", | ||
"version": "8.1.0", | ||
"version": "9.0.0", | ||
"description": "A react component for Ace Editor", | ||
@@ -8,3 +8,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"prettier": "prettier --print-width 120 --single-quote --trailing-comma all --write \"src/**\" \"example/*.js\"", | ||
"prettier": "prettier --write \"src/**\" \"example/*.js\"", | ||
"clean": "rimraf lib dist", | ||
@@ -39,7 +39,7 @@ "lint": "tslint src/*", | ||
"@types/mocha": "^7.0.1", | ||
"@types/node": "^13.9.1", | ||
"@types/node": "^14.0.5", | ||
"@types/prop-types": "^15.7.1", | ||
"@types/react": "^16.8.18", | ||
"@types/react-dom": "^16.8.4", | ||
"@types/sinon": "^7.0.12", | ||
"@types/sinon": "^9.0.0", | ||
"babel-eslint": "^10.0.1", | ||
@@ -58,5 +58,5 @@ "babel-loader": "^8.0.6", | ||
"minimist": ">=1.2.2", | ||
"mocha": "7.1.0", | ||
"nyc": "15.0.0", | ||
"prettier": "^1.17.1", | ||
"mocha": "7.1.2", | ||
"nyc": "15.0.1", | ||
"prettier": "^2.0.5", | ||
"pretty-quick": "^2.0.0", | ||
@@ -67,11 +67,11 @@ "react": "^16.8.6", | ||
"rimraf": "3.0.2", | ||
"sinon": "9.0.1", | ||
"sinon": "9.0.2", | ||
"ts-loader": "^6.0.1", | ||
"ts-node": "^8.2.0", | ||
"tslint": "^5.16.0", | ||
"tslint-react": "^4.0.0", | ||
"tslint-react": "^5.0.0", | ||
"typescript": "^3.4.5", | ||
"webpack": "4.42.0", | ||
"webpack": "4.43.0", | ||
"webpack-cli": "3.3.10", | ||
"webpack-dev-server": "3.10.3" | ||
"webpack-dev-server": "3.11.0" | ||
}, | ||
@@ -120,3 +120,7 @@ "keywords": [ | ||
"url": "http://github.com/securingsincity/react-ace.git" | ||
}, | ||
"prettier": { | ||
"singleQuote": false, | ||
"trailingComma": "none" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
import * as AceBuilds from "ace-builds"; | ||
type EditorOption = | ||
@@ -48,6 +50,24 @@ | "minLines" | ||
]; | ||
const getAceInstance = () => { | ||
// Typescript globals definition to allow us to create a window object during SSR. | ||
declare global { | ||
namespace NodeJS { | ||
// tslint:disable-next-line | ||
interface Global { | ||
window: any; | ||
} | ||
} | ||
} | ||
const getAceInstance = (): typeof AceBuilds => { | ||
let ace; | ||
// Fallback for ace.require when vanilla ACE is hosted over a CDN | ||
if ((window as any).ace) { | ||
if (typeof window === "undefined") { | ||
// ace-builds just needs some window object to attach ace to. | ||
// During SSR even just an empty object will work. | ||
global.window = {}; | ||
ace = require("ace-builds"); | ||
// And it can be discarded immediately afterward to avoid confusing | ||
// other libraries that might detect SSR the same way we did. | ||
delete global.window; | ||
} else if ((window as any).ace) { | ||
// Fallback for ace.require when vanilla ACE is hosted over a CDN | ||
ace = (window as any).ace; | ||
@@ -63,3 +83,4 @@ ace.acequire = (window as any).ace.require || (window as any).ace.acequire; | ||
let timer: any = null; | ||
return function() { | ||
// tslint:disable-next-line | ||
return function () { | ||
const context = this; | ||
@@ -66,0 +87,0 @@ const args = arguments; |
@@ -0,1 +1,3 @@ | ||
import { Ace } from "ace-builds"; | ||
export interface ICommandManager { | ||
@@ -46,3 +48,3 @@ byName: any; | ||
className: string; | ||
type: string; | ||
type: "fullLine" | "screenLine" | "text" | Ace.MarkerRenderer; | ||
inFront?: boolean; | ||
@@ -80,3 +82,3 @@ } | ||
printMarginColumn?: number; | ||
printMargin?: boolean|number; | ||
printMargin?: boolean | number; | ||
fadeFoldWidgets?: boolean; | ||
@@ -128,1 +130,11 @@ showFoldWidgets?: boolean; | ||
} | ||
interface IRenderer extends Ace.VirtualRenderer { | ||
placeholderNode?: HTMLDivElement; | ||
scroller?: HTMLDivElement; | ||
} | ||
export type IAceEditor = Ace.Editor & { | ||
renderer: IRenderer; | ||
[index: string]: any; | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1783650
56
8398