(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["ReactAce"] = factory();
else
root["ReactAce"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _brace = __webpack_require__(80);
var _brace2 = _interopRequireDefault(_brace);
var _react = __webpack_require__(157);
var _react2 = _interopRequireDefault(_react);
var ReactAce = (function (_Component) {
_inherits(ReactAce, _Component);
function ReactAce(props) {
var _this = this;
_classCallCheck(this, ReactAce);
_get(Object.getPrototypeOf(ReactAce.prototype), 'constructor', this).call(this, props);
['onChange', 'onFocus', 'onBlur', 'onCopy', 'onPaste'].forEach(function (method) {
_this[method] = _this[method].bind(_this);
});
}
_createClass(ReactAce, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _props = this.props;
var name = _props.name;
var onBeforeLoad = _props.onBeforeLoad;
var mode = _props.mode;
var theme = _props.theme;
var fontSize = _props.fontSize;
var value = _props.value;
var cursorStart = _props.cursorStart;
var showGutter = _props.showGutter;
var wrapEnabled = _props.wrapEnabled;
var maxLines = _props.maxLines;
var readOnly = _props.readOnly;
var highlightActiveLine = _props.highlightActiveLine;
var tabSize = _props.tabSize;
var showPrintMargin = _props.showPrintMargin;
var keyboardHandler = _props.keyboardHandler;
var onLoad = _props.onLoad;
this.editor = _brace2['default'].edit(name);
if (onBeforeLoad) {
onBeforeLoad(_brace2['default']);
}
var editorProps = Object.keys(this.props.editorProps);
for (var i = 0; i < editorProps.length; i++) {
this.editor[editorProps[i]] = this.props.editorProps[editorProps[i]];
}
this.editor.getSession().setMode('ace/mode/' + mode);
this.editor.setTheme('ace/theme/' + theme);
this.editor.setFontSize(fontSize);
this.editor.setValue(value, cursorStart);
this.editor.renderer.setShowGutter(showGutter);
this.editor.getSession().setUseWrapMode(wrapEnabled);
this.editor.setOption('maxLines', maxLines);
this.editor.setOption('readOnly', readOnly);
this.editor.setOption('highlightActiveLine', highlightActiveLine);
this.editor.setOption('tabSize', tabSize);
this.editor.setShowPrintMargin(showPrintMargin);
this.editor.on('focus', this.onFocus);
this.editor.on('blur', this.onBlur);
this.editor.on('copy', this.onCopy);
this.editor.on('paste', this.onPaste);
this.editor.on('change', this.onChange);
if (keyboardHandler) {
this.editor.setKeyboardHandler('ace/keyboard/' + keyboardHandler);
}
if (onLoad) {
onLoad(this.editor);
}
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
var oldProps = this.props;
if (nextProps.mode !== oldProps.mode) {
this.editor.getSession().setMode('ace/mode/' + nextProps.mode);
}
if (nextProps.theme !== oldProps.theme) {
this.editor.setTheme('ace/theme/' + nextProps.theme);
}
if (nextProps.fontSize !== oldProps.fontSize) {
this.editor.setFontSize(nextProps.fontSize);
}
if (nextProps.maxLines !== oldProps.maxLines) {
this.editor.setOption('maxLines', nextProps.maxLines);
}
if (nextProps.readOnly !== oldProps.readOnly) {
this.editor.setOption('readOnly', nextProps.readOnly);
}
if (nextProps.highlightActiveLine !== oldProps.highlightActiveLine) {
this.editor.setOption('highlightActiveLine', nextProps.highlightActiveLine);
}
if (nextProps.tabSize !== oldProps.tabSize) {
this.editor.setOption('tabSize', nextProps.tabSize);
}
if (nextProps.showPrintMargin !== oldProps.showPrintMargin) {
this.editor.setShowPrintMargin(nextProps.showPrintMargin);
}
if (nextProps.showGutter !== oldProps.showGutter) {
this.editor.renderer.setShowGutter(nextProps.showGutter);
}
if (this.editor.getValue() !== nextProps.value) {
// editor.setValue is a synchronous function call, change event is emitted before setValue return.
this.silent = true;
this.editor.setValue(nextProps.value, nextProps.cursorStart);
this.silent = false;
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.editor = null;
}
}, {
key: 'onChange',
value: function onChange() {
if (this.props.onChange && !this.silent) {
var value = this.editor.getValue();
this.props.onChange(value);
}
}
}, {
key: 'onFocus',
value: function onFocus() {
if (this.props.onFocus) {
this.props.onFocus();
}
}
}, {
key: 'onBlur',
value: function onBlur() {
if (this.props.onBlur) {
this.props.onBlur();
}
}
}, {
key: 'onCopy',
value: function onCopy(text) {
if (this.props.onCopy) {
this.props.onCopy(text);
}
}
}, {
key: 'onPaste',
value: function onPaste(text) {
if (this.props.onPaste) {
this.props.onPaste(text);
}
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props;
var name = _props2.name;
var className = _props2.className;
var width = _props2.width;
var height = _props2.height;
var divStyle = { width: width, height: height };
return _react2['default'].createElement('div', {
id: name,
className: className,
style: divStyle });
}
}]);
return ReactAce;
})(_react.Component);
exports['default'] = ReactAce;
ReactAce.propTypes = {
mode: _react.PropTypes.string,
theme: _react.PropTypes.string,
name: _react.PropTypes.string,
className: _react.PropTypes.string,
height: _react.PropTypes.string,
width: _react.PropTypes.string,
fontSize: _react.PropTypes.number,
showGutter: _react.PropTypes.bool,
onChange: _react.PropTypes.func,
onCopy: _react.PropTypes.func,
onPaste: _react.PropTypes.func,
onFocus: _react.PropTypes.func,
onBlur: _react.PropTypes.func,
value: _react.PropTypes.string,
onLoad: _react.PropTypes.func,
onBeforeLoad: _react.PropTypes.func,
maxLines: _react.PropTypes.number,
readOnly: _react.PropTypes.bool,
highlightActiveLine: _react.PropTypes.bool,
tabSize: _react.PropTypes.number,
showPrintMargin: _react.PropTypes.bool,
cursorStart: _react.PropTypes.number,
editorProps: _react.PropTypes.object,
keyboardHandler: _react.PropTypes.string,
wrapEnabled: _react.PropTypes.bool
};
ReactAce.defaultProps = {
name: 'brace-editor',
mode: '',
theme: '',
height: '500px',
width: '500px',
value: '',
fontSize: 12,
showGutter: true,
onChange: null,
onPaste: null,
onLoad: null,
maxLines: null,
readOnly: false,
highlightActiveLine: true,
showPrintMargin: true,
tabSize: 4,
cursorStart: 1,
editorProps: {},
wrapEnabled: false
};
module.exports = exports['default'];
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule invariant
*/
"use strict";
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var invariant = function(condition, format, a, b, c, d, e, f) {
if (true) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var error;
if (format === undefined) {
error = new Error(
'Minified exception occurred; use the non-minified dev environment ' +
'for the full error message and additional helpful warnings.'
);
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(
'Invariant Violation: ' +
format.replace(/%s/g, function() { return args[argIndex++]; })
);
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
};
module.exports = invariant;
/***/ },
/* 2 */
/***/ function(module, exports) {
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Object.assign
*/
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
'use strict';
function assign(target, sources) {
if (target == null) {
throw new TypeError('Object.assign target cannot be null or undefined');
}
var to = Object(target);
var hasOwnProperty = Object.prototype.hasOwnProperty;
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
var nextSource = arguments[nextIndex];
if (nextSource == null) {
continue;
}
var from = Object(nextSource);
// We don't currently support accessors nor proxies. Therefore this
// copy cannot throw. If we ever supported this then we must handle
// exceptions and side-effects. We don't support symbols so they won't
// be transferred.
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
}
return to;
}
module.exports = assign;
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactElement
*/
'use strict';
var ReactContext = __webpack_require__(42);
var ReactCurrentOwner = __webpack_require__(12);
var assign = __webpack_require__(2);
var warning = __webpack_require__(4);
var RESERVED_PROPS = {
key: true,
ref: true
};
/**
* Warn for mutations.
*
* @internal
* @param {object} object
* @param {string} key
*/
function defineWarningProperty(object, key) {
Object.defineProperty(object, key, {
configurable: false,
enumerable: true,
get: function() {
if (!this._store) {
return null;
}
return this._store[key];
},
set: function(value) {
( true ? warning(
false,
'Don\'t set the %s property of the React element. Instead, ' +
'specify the correct value when initially creating the element.',
key
) : null);
this._store[key] = value;
}
});
}
/**
* This is updated to true if the membrane is successfully created.
*/
var useMutationMembrane = false;
/**
* Warn for mutations.
*
* @internal
* @param {object} element
*/
function defineMutationMembrane(prototype) {
try {
var pseudoFrozenProperties = {
props: true
};
for (var key in pseudoFrozenProperties) {
defineWarningProperty(prototype, key);
}
useMutationMembrane = true;
} catch (x) {
// IE will fail on defineProperty
}
}
/**
* Base constructor for all React elements. This is only used to make this
* work with a dynamic instanceof check. Nothing should live on this prototype.
*
* @param {*} type
* @param {string|object} ref
* @param {*} key
* @param {*} props
* @internal
*/
var ReactElement = function(type, key, ref, owner, context, props) {
// Built-in properties that belong on the element
this.type = type;
this.key = key;
this.ref = ref;
// Record the component responsible for creating this element.
this._owner = owner;
// TODO: Deprecate withContext, and then the context becomes accessible
// through the owner.
this._context = context;
if (true) {
// The validation flag and props are currently mutative. We put them on
// an external backing store so that we can freeze the whole object.
// This can be replaced with a WeakMap once they are implemented in
// commonly used development environments.
this._store = {props: props, originalProps: assign({}, props)};
// To make comparing ReactElements easier for testing purposes, we make
// the validation flag non-enumerable (where possible, which should
// include every environment we run tests in), so the test framework
// ignores it.
try {
Object.defineProperty(this._store, 'validated', {
configurable: false,
enumerable: false,
writable: true
});
} catch (x) {
}
this._store.validated = false;
// We're not allowed to set props directly on the object so we early
// return and rely on the prototype membrane to forward to the backing
// store.
if (useMutationMembrane) {
Object.freeze(this);
return;
}
}
this.props = props;
};
// We intentionally don't expose the function on the constructor property.
// ReactElement should be indistinguishable from a plain object.
ReactElement.prototype = {
_isReactElement: true
};
if (true) {
defineMutationMembrane(ReactElement.prototype);
}
ReactElement.createElement = function(type, config, children) {
var propName;
// Reserved names are extracted
var props = {};
var key = null;
var ref = null;
if (config != null) {
ref = config.ref === undefined ? null : config.ref;
key = config.key === undefined ? null : '' + config.key;
// Remaining properties are added to a new props object
for (propName in config) {
if (config.hasOwnProperty(propName) &&
!RESERVED_PROPS.hasOwnProperty(propName)) {
props[propName] = config[propName];
}
}
}
// Children can be more than one argument, and those are transferred onto
// the newly allocated props object.
var childrenLength = arguments.length - 2;
if (childrenLength === 1) {
props.children = children;
} else if (childrenLength > 1) {
var childArray = Array(childrenLength);
for (var i = 0; i < childrenLength; i++) {
childArray[i] = arguments[i + 2];
}
props.children = childArray;
}
// Resolve default props
if (type && type.defaultProps) {
var defaultProps = type.defaultProps;
for (propName in defaultProps) {
if (typeof props[propName] === 'undefined') {
props[propName] = defaultProps[propName];
}
}
}
return new ReactElement(
type,
key,
ref,
ReactCurrentOwner.current,
ReactContext.current,
props
);
};
ReactElement.createFactory = function(type) {
var factory = ReactElement.createElement.bind(null, type);
// Expose the type on the factory and the prototype so that it can be
// easily accessed on elements. E.g.