Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-ace

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-ace - npm Package Compare versions

Comparing version 4.2.3 to 4.3.0

16

lib/ace.js

@@ -48,3 +48,3 @@ 'use strict';

['onChange', 'onFocus', 'onBlur', 'onCopy', 'onPaste', 'onScroll', 'handleOptions', 'updateRef'].forEach(function (method) {
['onChange', 'onFocus', 'onBlur', 'onCopy', 'onPaste', 'onSelectionChange', 'onScroll', 'handleOptions', 'updateRef'].forEach(function (method) {
_this[method] = _this[method].bind(_this);

@@ -106,2 +106,3 @@ });

this.editor.on('change', this.onChange);
this.editor.getSession().selection.on('changeSelection', this.onSelectionChange);
this.editor.session.on('changeScrollTop', this.onScroll);

@@ -236,9 +237,17 @@ this.handleOptions(this.props);

key: 'onChange',
value: function onChange() {
value: function onChange(event) {
if (this.props.onChange && !this.silent) {
var value = this.editor.getValue();
this.props.onChange(value);
this.props.onChange(value, event);
}
}
}, {
key: 'onSelectionChange',
value: function onSelectionChange(event) {
if (this.props.onSelectionChange) {
var value = this.editor.getSelection();
this.props.onSelectionChange(value, event);
}
}
}, {
key: 'onFocus',

@@ -367,2 +376,3 @@ value: function onFocus() {

onLoad: _propTypes2.default.func,
onSelectionChange: _propTypes2.default.func,
onBeforeLoad: _propTypes2.default.func,

@@ -369,0 +379,0 @@ minLines: _propTypes2.default.number,

2

package.json
{
"name": "react-ace",
"version": "4.2.3",
"version": "4.3.0",
"description": "A react component for Ace Editor",

@@ -5,0 +5,0 @@ "main": "lib/ace.js",

@@ -9,2 +9,4 @@ # React-Ace

[DEMO](http://securingsincity.github.io/react-ace/)
## Install

@@ -72,5 +74,6 @@

|onBeforeLoad| | function that trigger before editor setup|
|onChange| | function that occurs on document change it has 1 argument value. see the example above|
|onChange| | function that occurs on document change it has 2 arguments the value and the event. see the example above|
|onCopy| | function that trigger by editor `copy` event, and pass text as argument|
|onPaste| | function that trigger by editor `paste` event, and pass text as argument|
|onSelectionChange| | function that trigger by editor `selectionChange` event, and passes a [Selection](https://ace.c9.io/#nav=api&api=selection) as it's first argument and the event as the second|
|onFocus| | function that trigger by editor `focus` event|

@@ -77,0 +80,0 @@ |onBlur| | function that trigger by editor `blur` event|

@@ -28,2 +28,3 @@ import ace from 'brace'

'onPaste',
'onSelectionChange',
'onScroll',

@@ -84,2 +85,3 @@ 'handleOptions',

this.editor.on('change', this.onChange);
this.editor.getSession().selection.on('changeSelection', this.onSelectionChange);
this.editor.session.on('changeScrollTop', this.onScroll);

@@ -208,9 +210,16 @@ this.handleOptions(this.props);

onChange() {
onChange(event) {
if (this.props.onChange && !this.silent) {
const value = this.editor.getValue();
this.props.onChange(value);
this.props.onChange(value, event);
}
}
onSelectionChange(event) {
if (this.props.onSelectionChange) {
const value = this.editor.getSelection();
this.props.onSelectionChange(value, event);
}
}
onFocus() {

@@ -314,2 +323,3 @@ if (this.props.onFocus) {

onLoad: PropTypes.func,
onSelectionChange: PropTypes.func,
onBeforeLoad: PropTypes.func,

@@ -316,0 +326,0 @@ minLines: PropTypes.number,

@@ -128,2 +128,3 @@ import { expect } from 'chai';

expect(onChangeCallback.getCall(0).args[0]).to.equal(expectText);
expect(onChangeCallback.getCall(0).args[1].action).to.eq('insert')
});

@@ -174,2 +175,15 @@

it('should call the onSelectionChange method callback', () => {
const onSelectionChangeCallback = sinon.spy();
const wrapper = mount(<AceEditor onSelectionChange={onSelectionChangeCallback}/>, mountOptions);
// Check is not previously called
expect(onSelectionChangeCallback.callCount).to.equal(0);
// Trigger the focus event
wrapper.instance().editor.getSession().selection.selectAll()
expect(onSelectionChangeCallback.callCount).to.equal(1);
});
it('should call the onBlur method callback', () => {

@@ -176,0 +190,0 @@ const onBlurCallback = sinon.spy();

@@ -152,3 +152,4 @@ // Type definitions for react-ace 4.1.3

onBeforeLoad?: (ace: any) => void
onChange?: (value: string) => void
onChange?: (value: string, event?: any) => void
onSelection?: (selectedText: string, event?: any) => void
onCopy?: (value: string) => void

@@ -155,0 +156,0 @@ onPaste?: (value: string) => void

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc