planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

3
node_modules/react-codemirror2/.gitattributes generated vendored Normal file
View File

@@ -0,0 +1,3 @@
docs/* linguist-documentation
index.js linguist-generated=true
index.d.ts linguist-generated=true

82
node_modules/react-codemirror2/.ts/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,82 @@
import * as React from 'react';
import * as codemirror from 'codemirror';
export interface IDefineModeOptions {
fn: () => codemirror.Mode<any>;
name: string;
}
export interface ISetScrollOptions {
x?: number | null;
y?: number | null;
}
export interface ISetSelectionOptions {
anchor: codemirror.Position;
head: codemirror.Position;
}
export interface DomEvent {
(editor: codemirror.Editor, event?: any): void;
}
export interface KeyHandledEvent {
(editor: codemirror.Editor, name: string, event: any): void;
}
export interface EditorChangeEvent {
(editor: codemirror.Editor, changeObj: codemirror.EditorChange): void;
}
export interface ICodeMirror {
autoCursor?: boolean;
autoScroll?: boolean;
className?: string;
cursor?: codemirror.Position;
defineMode?: IDefineModeOptions;
editorDidConfigure?: (editor: codemirror.Editor) => void;
editorDidMount?: (editor: codemirror.Editor, value: string, cb: () => void) => void;
editorWillUnmount?: (lib: any) => void;
onBlur?: DomEvent;
onChange?: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string) => void;
onContextMenu?: DomEvent;
onCopy?: DomEvent;
onCursor?: (editor: codemirror.Editor, data: codemirror.Position) => void;
onCut?: DomEvent;
onCursorActivity?: (editor: codemirror.Editor) => void;
onDblClick?: DomEvent;
onDragEnter?: DomEvent;
onDragLeave?: DomEvent;
onDragOver?: DomEvent;
onDragStart?: DomEvent;
onDrop?: DomEvent;
onFocus?: DomEvent;
onGutterClick?: (editor: codemirror.Editor, lineNumber: number, gutter: string, event: Event) => void;
onInputRead?: EditorChangeEvent;
onKeyDown?: DomEvent;
onKeyHandled?: KeyHandledEvent;
onKeyPress?: DomEvent;
onKeyUp?: DomEvent;
onMouseDown?: DomEvent;
onPaste?: DomEvent;
onRenderLine?: (editor: codemirror.Editor, line: codemirror.LineHandle, element: HTMLElement) => void;
onScroll?: (editor: codemirror.Editor, data: codemirror.ScrollInfo) => void;
onSelection?: (editor: codemirror.Editor, data: any) => void;
onTouchStart?: DomEvent;
onUpdate?: (editor: codemirror.Editor) => void;
onViewportChange?: (editor: codemirror.Editor, start: number, end: number) => void;
options?: codemirror.EditorConfiguration;
selection?: {
ranges: Array<ISetSelectionOptions>;
focus?: boolean;
};
scroll?: ISetScrollOptions;
}
export interface IControlledCodeMirror extends ICodeMirror {
onBeforeChange: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string) => void;
value: string;
}
export interface IUnControlledCodeMirror extends ICodeMirror {
detach?: boolean;
editorDidAttach?: (editor: codemirror.Editor) => void;
editorDidDetach?: (editor: codemirror.Editor) => void;
onBeforeChange?: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string, next: () => void) => void;
value?: string;
}
export declare class Controlled extends React.Component<IControlledCodeMirror, any> {
}
export declare class UnControlled extends React.Component<IUnControlledCodeMirror, any> {
}

592
node_modules/react-codemirror2/.ts/index.js generated vendored Normal file
View File

@@ -0,0 +1,592 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnControlled = exports.Controlled = void 0;
var React = require("react");
var SERVER_RENDERED = (typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true);
var cm;
if (!SERVER_RENDERED) {
cm = require('codemirror');
}
var Helper = (function () {
function Helper() {
}
Helper.equals = function (x, y) {
var _this = this;
var ok = Object.keys, tx = typeof x, ty = typeof y;
return x && y && tx === 'object' && tx === ty ? (ok(x).length === ok(y).length &&
ok(x).every(function (key) { return _this.equals(x[key], y[key]); })) : (x === y);
};
return Helper;
}());
var Shared = (function () {
function Shared(editor, props) {
this.editor = editor;
this.props = props;
}
Shared.prototype.delegateCursor = function (position, scroll, focus) {
var doc = this.editor.getDoc();
if (focus) {
this.editor.focus();
}
scroll ? doc.setCursor(position) : doc.setCursor(position, null, { scroll: false });
};
Shared.prototype.delegateScroll = function (coordinates) {
this.editor.scrollTo(coordinates.x, coordinates.y);
};
Shared.prototype.delegateSelection = function (ranges, focus) {
var doc = this.editor.getDoc();
doc.setSelections(ranges);
if (focus) {
this.editor.focus();
}
};
Shared.prototype.apply = function (props) {
if (props && props.selection && props.selection.ranges) {
this.delegateSelection(props.selection.ranges, props.selection.focus || false);
}
if (props && props.cursor) {
this.delegateCursor(props.cursor, (props.autoScroll || false), (this.editor.getOption('autofocus') || false));
}
if (props && props.scroll) {
this.delegateScroll(props.scroll);
}
};
Shared.prototype.applyNext = function (props, next, preserved) {
if (props && props.selection && props.selection.ranges) {
if (next && next.selection && next.selection.ranges && !Helper.equals(props.selection.ranges, next.selection.ranges)) {
this.delegateSelection(next.selection.ranges, next.selection.focus || false);
}
}
if (props && props.cursor) {
if (next && next.cursor && !Helper.equals(props.cursor, next.cursor)) {
this.delegateCursor(preserved.cursor || next.cursor, (next.autoScroll || false), (next.autoCursor || false));
}
}
if (props && props.scroll) {
if (next && next.scroll && !Helper.equals(props.scroll, next.scroll)) {
this.delegateScroll(next.scroll);
}
}
};
Shared.prototype.applyUserDefined = function (props, preserved) {
if (preserved && preserved.cursor) {
this.delegateCursor(preserved.cursor, (props.autoScroll || false), (this.editor.getOption('autofocus') || false));
}
};
Shared.prototype.wire = function (props) {
var _this = this;
Object.keys(props || {}).filter(function (p) { return /^on/.test(p); }).forEach(function (prop) {
switch (prop) {
case 'onBlur':
{
_this.editor.on('blur', function (cm, event) {
_this.props.onBlur(_this.editor, event);
});
}
break;
case 'onContextMenu': {
_this.editor.on('contextmenu', function (cm, event) {
_this.props.onContextMenu(_this.editor, event);
});
break;
}
case 'onCopy': {
_this.editor.on('copy', function (cm, event) {
_this.props.onCopy(_this.editor, event);
});
break;
}
case 'onCursor':
{
_this.editor.on('cursorActivity', function (cm) {
_this.props.onCursor(_this.editor, _this.editor.getDoc().getCursor());
});
}
break;
case 'onCursorActivity':
{
_this.editor.on('cursorActivity', function (cm) {
_this.props.onCursorActivity(_this.editor);
});
}
break;
case 'onCut': {
_this.editor.on('cut', function (cm, event) {
_this.props.onCut(_this.editor, event);
});
break;
}
case 'onDblClick': {
_this.editor.on('dblclick', function (cm, event) {
_this.props.onDblClick(_this.editor, event);
});
break;
}
case 'onDragEnter':
{
_this.editor.on('dragenter', function (cm, event) {
_this.props.onDragEnter(_this.editor, event);
});
}
break;
case 'onDragLeave': {
_this.editor.on('dragleave', function (cm, event) {
_this.props.onDragLeave(_this.editor, event);
});
break;
}
case 'onDragOver':
{
_this.editor.on('dragover', function (cm, event) {
_this.props.onDragOver(_this.editor, event);
});
}
break;
case 'onDragStart': {
_this.editor.on('dragstart', function (cm, event) {
_this.props.onDragStart(_this.editor, event);
});
break;
}
case 'onDrop':
{
_this.editor.on('drop', function (cm, event) {
_this.props.onDrop(_this.editor, event);
});
}
break;
case 'onFocus':
{
_this.editor.on('focus', function (cm, event) {
_this.props.onFocus(_this.editor, event);
});
}
break;
case 'onGutterClick':
{
_this.editor.on('gutterClick', function (cm, lineNumber, gutter, event) {
_this.props.onGutterClick(_this.editor, lineNumber, gutter, event);
});
}
break;
case 'onInputRead':
{
_this.editor.on('inputRead', function (cm, EditorChangeEvent) {
_this.props.onInputRead(_this.editor, EditorChangeEvent);
});
}
break;
case 'onKeyDown':
{
_this.editor.on('keydown', function (cm, event) {
_this.props.onKeyDown(_this.editor, event);
});
}
break;
case 'onKeyHandled':
{
_this.editor.on('keyHandled', function (cm, key, event) {
_this.props.onKeyHandled(_this.editor, key, event);
});
}
break;
case 'onKeyPress':
{
_this.editor.on('keypress', function (cm, event) {
_this.props.onKeyPress(_this.editor, event);
});
}
break;
case 'onKeyUp':
{
_this.editor.on('keyup', function (cm, event) {
_this.props.onKeyUp(_this.editor, event);
});
}
break;
case 'onMouseDown': {
_this.editor.on('mousedown', function (cm, event) {
_this.props.onMouseDown(_this.editor, event);
});
break;
}
case 'onPaste': {
_this.editor.on('paste', function (cm, event) {
_this.props.onPaste(_this.editor, event);
});
break;
}
case 'onRenderLine': {
_this.editor.on('renderLine', function (cm, line, element) {
_this.props.onRenderLine(_this.editor, line, element);
});
break;
}
case 'onScroll':
{
_this.editor.on('scroll', function (cm) {
_this.props.onScroll(_this.editor, _this.editor.getScrollInfo());
});
}
break;
case 'onSelection':
{
_this.editor.on('beforeSelectionChange', function (cm, data) {
_this.props.onSelection(_this.editor, data);
});
}
break;
case 'onTouchStart': {
_this.editor.on('touchstart', function (cm, event) {
_this.props.onTouchStart(_this.editor, event);
});
break;
}
case 'onUpdate':
{
_this.editor.on('update', function (cm) {
_this.props.onUpdate(_this.editor);
});
}
break;
case 'onViewportChange':
{
_this.editor.on('viewportChange', function (cm, from, to) {
_this.props.onViewportChange(_this.editor, from, to);
});
}
break;
}
});
};
return Shared;
}());
var Controlled = (function (_super) {
__extends(Controlled, _super);
function Controlled(props) {
var _this = _super.call(this, props) || this;
if (SERVER_RENDERED)
return _this;
_this.applied = false;
_this.appliedNext = false;
_this.appliedUserDefined = false;
_this.deferred = null;
_this.emulating = false;
_this.hydrated = false;
_this.initCb = function () {
if (_this.props.editorDidConfigure) {
_this.props.editorDidConfigure(_this.editor);
}
};
_this.mounted = false;
return _this;
}
Controlled.prototype.hydrate = function (props) {
var _this = this;
var _options = props && props.options ? props.options : {};
var userDefinedOptions = Object.assign({}, cm.defaults, this.editor.options, _options);
var optionDelta = Object.keys(userDefinedOptions).some(function (key) { return _this.editor.getOption(key) !== userDefinedOptions[key]; });
if (optionDelta) {
Object.keys(userDefinedOptions).forEach(function (key) {
if (_options.hasOwnProperty(key)) {
if (_this.editor.getOption(key) !== userDefinedOptions[key]) {
_this.editor.setOption(key, userDefinedOptions[key]);
_this.mirror.setOption(key, userDefinedOptions[key]);
}
}
});
}
if (!this.hydrated) {
this.deferred ? this.resolveChange(props.value) : this.initChange(props.value || '');
}
this.hydrated = true;
};
Controlled.prototype.initChange = function (value) {
this.emulating = true;
var doc = this.editor.getDoc();
var lastLine = doc.lastLine();
var lastChar = doc.getLine(doc.lastLine()).length;
doc.replaceRange(value || '', { line: 0, ch: 0 }, { line: lastLine, ch: lastChar });
this.mirror.setValue(value);
doc.clearHistory();
this.mirror.clearHistory();
this.emulating = false;
};
Controlled.prototype.resolveChange = function (value) {
this.emulating = true;
var doc = this.editor.getDoc();
if (this.deferred.origin === 'undo') {
doc.undo();
}
else if (this.deferred.origin === 'redo') {
doc.redo();
}
else {
doc.replaceRange(this.deferred.text, this.deferred.from, this.deferred.to, this.deferred.origin);
}
if (value && value !== doc.getValue()) {
var cursor = doc.getCursor();
doc.setValue(value);
doc.setCursor(cursor);
}
this.emulating = false;
this.deferred = null;
};
Controlled.prototype.mirrorChange = function (deferred) {
var doc = this.editor.getDoc();
if (deferred.origin === 'undo') {
doc.setHistory(this.mirror.getHistory());
this.mirror.undo();
}
else if (deferred.origin === 'redo') {
doc.setHistory(this.mirror.getHistory());
this.mirror.redo();
}
else {
this.mirror.replaceRange(deferred.text, deferred.from, deferred.to, deferred.origin);
}
return this.mirror.getValue();
};
Controlled.prototype.componentDidMount = function () {
var _this = this;
if (SERVER_RENDERED)
return;
if (this.props.defineMode) {
if (this.props.defineMode.name && this.props.defineMode.fn) {
cm.defineMode(this.props.defineMode.name, this.props.defineMode.fn);
}
}
this.editor = cm(this.ref, this.props.options);
this.shared = new Shared(this.editor, this.props);
this.mirror = cm(function () {
}, this.props.options);
this.editor.on('electricInput', function () {
_this.mirror.setHistory(_this.editor.getDoc().getHistory());
});
this.editor.on('cursorActivity', function () {
_this.mirror.setCursor(_this.editor.getDoc().getCursor());
});
this.editor.on('beforeChange', function (cm, data) {
if (_this.emulating) {
return;
}
data.cancel();
_this.deferred = data;
var phantomChange = _this.mirrorChange(_this.deferred);
if (_this.props.onBeforeChange)
_this.props.onBeforeChange(_this.editor, _this.deferred, phantomChange);
});
this.editor.on('change', function (cm, data) {
if (!_this.mounted) {
return;
}
if (_this.props.onChange) {
_this.props.onChange(_this.editor, data, _this.editor.getValue());
}
});
this.hydrate(this.props);
this.shared.apply(this.props);
this.applied = true;
this.mounted = true;
this.shared.wire(this.props);
if (this.editor.getOption('autofocus')) {
this.editor.focus();
}
if (this.props.editorDidMount) {
this.props.editorDidMount(this.editor, this.editor.getValue(), this.initCb);
}
};
Controlled.prototype.componentDidUpdate = function (prevProps) {
if (SERVER_RENDERED)
return;
var preserved = { cursor: null };
if (this.props.value !== prevProps.value) {
this.hydrated = false;
}
if (!this.props.autoCursor && this.props.autoCursor !== undefined) {
preserved.cursor = this.editor.getDoc().getCursor();
}
this.hydrate(this.props);
if (!this.appliedNext) {
this.shared.applyNext(prevProps, this.props, preserved);
this.appliedNext = true;
}
this.shared.applyUserDefined(prevProps, preserved);
this.appliedUserDefined = true;
};
Controlled.prototype.componentWillUnmount = function () {
if (SERVER_RENDERED)
return;
if (this.props.editorWillUnmount) {
this.props.editorWillUnmount(cm);
}
};
Controlled.prototype.shouldComponentUpdate = function (nextProps, nextState) {
return !SERVER_RENDERED;
};
Controlled.prototype.render = function () {
var _this = this;
if (SERVER_RENDERED)
return null;
var className = this.props.className ? "react-codemirror2 " + this.props.className : 'react-codemirror2';
return React.createElement("div", { className: className, ref: function (self) { return _this.ref = self; } });
};
return Controlled;
}(React.Component));
exports.Controlled = Controlled;
var UnControlled = (function (_super) {
__extends(UnControlled, _super);
function UnControlled(props) {
var _this = _super.call(this, props) || this;
if (SERVER_RENDERED)
return _this;
_this.applied = false;
_this.appliedUserDefined = false;
_this.continueChange = false;
_this.detached = false;
_this.hydrated = false;
_this.initCb = function () {
if (_this.props.editorDidConfigure) {
_this.props.editorDidConfigure(_this.editor);
}
};
_this.mounted = false;
_this.onBeforeChangeCb = function () {
_this.continueChange = true;
};
return _this;
}
UnControlled.prototype.hydrate = function (props) {
var _this = this;
var _options = props && props.options ? props.options : {};
var userDefinedOptions = Object.assign({}, cm.defaults, this.editor.options, _options);
var optionDelta = Object.keys(userDefinedOptions).some(function (key) { return _this.editor.getOption(key) !== userDefinedOptions[key]; });
if (optionDelta) {
Object.keys(userDefinedOptions).forEach(function (key) {
if (_options.hasOwnProperty(key)) {
if (_this.editor.getOption(key) !== userDefinedOptions[key]) {
_this.editor.setOption(key, userDefinedOptions[key]);
}
}
});
}
if (!this.hydrated) {
var doc = this.editor.getDoc();
var lastLine = doc.lastLine();
var lastChar = doc.getLine(doc.lastLine()).length;
doc.replaceRange(props.value || '', { line: 0, ch: 0 }, { line: lastLine, ch: lastChar });
}
this.hydrated = true;
};
UnControlled.prototype.componentDidMount = function () {
var _this = this;
if (SERVER_RENDERED)
return;
this.detached = (this.props.detach === true);
if (this.props.defineMode) {
if (this.props.defineMode.name && this.props.defineMode.fn) {
cm.defineMode(this.props.defineMode.name, this.props.defineMode.fn);
}
}
this.editor = cm(this.ref, this.props.options);
this.shared = new Shared(this.editor, this.props);
this.editor.on('beforeChange', function (cm, data) {
if (_this.props.onBeforeChange) {
_this.props.onBeforeChange(_this.editor, data, _this.editor.getValue(), _this.onBeforeChangeCb);
}
});
this.editor.on('change', function (cm, data) {
if (!_this.mounted || !_this.props.onChange) {
return;
}
if (_this.props.onBeforeChange) {
if (_this.continueChange) {
_this.props.onChange(_this.editor, data, _this.editor.getValue());
}
}
else {
_this.props.onChange(_this.editor, data, _this.editor.getValue());
}
});
this.hydrate(this.props);
this.shared.apply(this.props);
this.applied = true;
this.mounted = true;
this.shared.wire(this.props);
this.editor.getDoc().clearHistory();
if (this.props.editorDidMount) {
this.props.editorDidMount(this.editor, this.editor.getValue(), this.initCb);
}
};
UnControlled.prototype.componentDidUpdate = function (prevProps) {
if (this.detached && (this.props.detach === false)) {
this.detached = false;
if (prevProps.editorDidAttach) {
prevProps.editorDidAttach(this.editor);
}
}
if (!this.detached && (this.props.detach === true)) {
this.detached = true;
if (prevProps.editorDidDetach) {
prevProps.editorDidDetach(this.editor);
}
}
if (SERVER_RENDERED || this.detached)
return;
var preserved = { cursor: null };
if (this.props.value !== prevProps.value) {
this.hydrated = false;
this.applied = false;
this.appliedUserDefined = false;
}
if (!prevProps.autoCursor && prevProps.autoCursor !== undefined) {
preserved.cursor = this.editor.getDoc().getCursor();
}
this.hydrate(this.props);
if (!this.applied) {
this.shared.apply(prevProps);
this.applied = true;
}
if (!this.appliedUserDefined) {
this.shared.applyUserDefined(prevProps, preserved);
this.appliedUserDefined = true;
}
};
UnControlled.prototype.componentWillUnmount = function () {
if (SERVER_RENDERED)
return;
if (this.props.editorWillUnmount) {
this.props.editorWillUnmount(cm);
}
};
UnControlled.prototype.shouldComponentUpdate = function (nextProps, nextState) {
var update = true;
if (SERVER_RENDERED)
update = false;
if (this.detached && nextProps.detach)
update = false;
return update;
};
UnControlled.prototype.render = function () {
var _this = this;
if (SERVER_RENDERED)
return null;
var className = this.props.className ? "react-codemirror2 " + this.props.className : 'react-codemirror2';
return React.createElement("div", { className: className, ref: function (self) { return _this.ref = self; } });
};
return UnControlled;
}(React.Component));
exports.UnControlled = UnControlled;

122
node_modules/react-codemirror2/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,122 @@
7.2.0
==================
* #100
7.1.0
==================
* #180 (fix event handling for `copy` `cut` `paste`)
* add support for codemirror events `inputRead` `keyHandled`
7.0.0
==================
* #180 (fix event handling for `copy` `cut` `paste`)
* add support for codemirror events `inputRead` `keyHandled`
7.0.0
==================
* remove `event` param from `copy` `cut` `paste` per [@types/codemirror](https://www.npmjs.com/package/@types/codemirror)
6.0.1
==================
* https://github.com/scniro/react-codemirror2/pull/176
5.1.0
==================
* add support for `renderLine` (#98)
5.0.3
==================
* #88
5.0.2
==================
5.0.1
==================
* #78
5.0.0
==================
* #75 - remove `autoFocus` in favor of codemirror.options.autofocus
4.3.0
==================
* #74 => add support for more DOM events => onContextMenu | onCopy | onCut | onDblClick | onDragLeave | onDragStart | onMouseDown | onPaste | onTouchStart
* #76 => babel-ify index.js package for out of the box runtime support e.g. `Object.assign`
4.2.0
==================
* add notion of UnControlled#detach => [`editorDidAttach`, `editorDidDetach`] (related to #37)
4.1.0
==================
* https://github.com/scniro/react-codemirror2/issues/63
* add internal notion of `applied`, `appliedUserDefined`, `appliedNext` to isolate update flows for controlled v. uncontrolled
* test coverage
4.0.1
==================
* https://github.com/scniro/react-codemirror2/issues/61
4.0.0
==================
* cursor, scroll, and selection events occur after an internal hydrate
* cursor, scroll, and selection events have more strict checking and are more responsive for changed valued
* added `PREVENT_CODEMIRROR_RENDER` global for rendering bypass
* selections managed via props now have and isolated autofocus option
* optimization of setting instance options when updated via props
* https://github.com/scniro/react-codemirror2/issues/49
* test coverage
3.0.6
==================
* https://github.com/scniro/react-codemirror2/issues/28
3.0.5
==================
* https://github.com/scniro/react-codemirror2/issues/31 (take 2)
3.0.4
==================
* https://github.com/scniro/react-codemirror2/issues/31
3.0.3
==================
* https://github.com/scniro/react-codemirror2/pull/27
3.0.2
==================
* https://github.com/scniro/react-codemirror2/issues/22
3.0.1
==================
* fixes https://github.com/scniro/react-codemirror2/issues/25
3.0.0
==================
* typings
* [`onSet`, onBeforeSet`] deprecated [removed]
* [`resetCursorOnSet`, `autoScrollCursorOnSet`] deprecated, now => [`autoCursor`, `autoScroll`]
* add `autoFocus`
* modify return of `onSelection`: this.editor, data.ranges) now => (this.editor, data)
* split component into two per usage, `UnControlled` & `Controlled`
* fixes https://github.com/scniro/react-codemirror2/issues/22
2.0.2
==================
* fixes https://github.com/scniro/react-codemirror2/issues/14
* remove deprecation warnings from 1.x
2.0.1
==================
* bump `peerDependencies` to support react 16.x
2.0.0
==================
* deprecate 1.x due to dependency conflicts occurring from over-strict versioning of codemirror as a `dependency`. Codemirror is now designated as a `peerDependency`
1.0.0
==================
* [`onValueSet`, `onValueChange`] deprecated, now => [`onSet`, `onChange`];
* add `onBeforeChange` `onBeforeSet`
* add `defineMode`

21
node_modules/react-codemirror2/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Sal Niro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

204
node_modules/react-codemirror2/README.md generated vendored Normal file
View File

@@ -0,0 +1,204 @@
[![Build Status](https://img.shields.io/travis/scniro/react-codemirror2.svg?style=flat-square)](https://travis-ci.org/scniro/react-codemirror2)
[![Dependency Status](https://img.shields.io/david/scniro/react-codemirror2.svg?label=deps&style=flat-square)](https://david-dm.org/scniro/react-codemirror2)
[![DevDependency Status](https://img.shields.io/david/dev/scniro/react-codemirror2.svg?label=devDeps&style=flat-square)](https://david-dm.org/scniro/react-codemirror2#info=devDependencies)
[![Coverage](https://img.shields.io/coveralls/scniro/react-codemirror2.svg?style=flat-square)](https://coveralls.io/github/scniro/react-codemirror2)
[![Downloads](https://img.shields.io/npm/dm/react-codemirror2.svg?style=flat-square)](https://www.npmjs.com/package/react-codemirror2)
[![NPM Version](https://img.shields.io/npm/v/react-codemirror2.svg?style=flat-square)](https://www.npmjs.com/package/react-codemirror2)
### react-codemirror2
demo @ [scniro.github.io/react-codemirror2](https://scniro.github.io/react-codemirror2/)
## Install
```bash
npm install react-codemirror2 codemirror --save
```
`react-codemirror2` ships with the notion of an [uncontrolled](https://reactjs.org/docs/uncontrolled-components.html) and [controlled](https://reactjs.org/docs/forms.html#controlled-components) component. `UnControlled` consists of a simple wrapper largely powered by the inner workings of `codemirror` itself, while `Controlled` will demand state management from the user, preventing codemirror changes unless properly handled via `value`. The latter will offer more control and likely be more appropriate with [redux](http://redux.js.org/) heavy apps.
## uncontrolled usage
```jsx
import {UnControlled as CodeMirror} from 'react-codemirror2'
<CodeMirror
value='<h1>I ♥ react-codemirror2</h1>'
options={{
mode: 'xml',
theme: 'material',
lineNumbers: true
}}
onChange={(editor, data, value) => {
}}
/>
```
## controlled usage
```jsx
import {Controlled as CodeMirror} from 'react-codemirror2'
<CodeMirror
value={this.state.value}
options={options}
onBeforeChange={(editor, data, value) => {
this.setState({value});
}}
onChange={(editor, data, value) => {
}}
/>
```
## requiring codemirror resources
- [codemirror](https://www.npmjs.com/package/codemirror)
`codemirror` comes as a [peer dependency](https://nodejs.org/en/blog/npm/peer-dependencies/), meaning you'll need to require it in your project _in addition to_ `react-codemirror2`. This prevents any versioning conflicts that would arise if `codemirror` came as a dependency through this wrapper. It's been observed that version mismatches can cause difficult to trace issues such as syntax highlighting disappearing without any explicit errors/warnings
- additional
Since codemirror ships mostly unconfigured, the user is left with the responsibility for requiring any additional resources should they be necessary. This is often the case when specifying certain [language modes]() and [themes](). How to import/require these assets will vary according to the specifics of your development environment. Below is a sample to include the assets necessary to specify a mode of `xml` (HTML) and a `material` theme.
> note that the base codemirror.css file is required in all use cases
```css
@import 'codemirror/lib/codemirror.css';
@import 'codemirror/theme/material.css';
```
```jsx
import CodeMirror from 'react-codemirror2';
require('codemirror/mode/xml/xml');
require('codemirror/mode/javascript/javascript');
```
## props
| prop | type&nbsp;*`default`* | components | description |
|--------------|------------------------|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `autoCursor` | boolean&nbsp;*`true`* | `Controlled`&nbsp;`UnControlled` | should component cursor position correct when `value` changed | |
| `autoScroll` | boolean&nbsp;*`true`* | `Controlled`&nbsp;`UnControlled` | should component scroll cursor position into view when `value` changed |
| `className` | string | `Controlled`&nbsp;`UnControlled` | pass through class *`class="react-codemirror2 className"`* |
| `defineMode` | object | `Controlled`&nbsp;`UnControlled` | pass a [custom mode](http://marijnhaverbeke.nl/blog/codemirror-mode-system.html) via `{name: 'custom', fn: myModeFn}` |
| `detach` | boolean | `UnControlled` | should component ignore new props |
| `options` | object | `Controlled`&nbsp;`UnControlled` | [codemirror configuration](https://codemirror.net/doc/manual.html#config) |
| `value` | string | *`Controlled`&nbsp;`UnControlled` | * component value _**must be managed for controlled components**_ |
## props cont. (wrapped codemirror [programming api](https://codemirror.net/doc/manual.html#api))
- `cursor` - *[setCursor](https://codemirror.net/doc/manual.html#setCursor)*
> will programmatically set cursor to the position specified
```jsx
<CodeMirror
[...]
cursor={{
line: 5,
ch: 10
}}
onCursor={(editor, data) => {}}
/>
```
- `scroll` - *[scrollTo](https://codemirror.net/doc/manual.html#scrollTo)*
> will programmatically scroll to the specified coordinate
```jsx
<CodeMirror
[...]
scroll={{
x: 50,
y: 50
}}
onScroll={(editor, data) => {}}
/>
```
- `selection={{ranges: array<{anchor, head}>, focus?: boolean}` - *[setSelections](https://codemirror.net/doc/manual.html#setSelections)*
> will programmatically select the ranges specified
```jsx
<CodeMirror
[...]
selection={{
ranges: [{
anchor: {ch: 8, line: 5},
head: {ch: 37, line: 5}
}],
focus: true // defaults false if not specified
}}
onSelection={(editor, data) => {}}
/>
```
## events
| event | components | description |
|------------------------------------------------------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------|
| **editorDidAttach(editor)** | `UnControlled` | component is now **responding** to new props |
| **editorDidConfigure(editor)** | `Controlled`&nbsp;`UnControlled` | component configuration has been set |
| **editorDidDetach(editor)** | `UnControlled` | component is now **ignoring** new props |
| **editorDidMount(editor,&nbsp;_[next]_)** | `Controlled`&nbsp;`UnControlled` | * invoking optional `next` will trigger `editorDidConfigure` |
| **editorWillUnmount(editor)** | `Controlled`&nbsp;`UnControlled` | invoked before [`componentWillUnmount`](https://reactjs.org/docs/react-component.html#componentwillunmount) |
| **onBeforeChange(editor,&nbsp;data,&nbsp;value,&nbsp;_[next]_)** | `Controlled`&nbsp;`UnControlled` | * if used, `next` is returned via `UnControlled` and *must* be invoked to trigger onChange |
| **onChange(editor,&nbsp;data,&nbsp;value)** | `Controlled`&nbsp;`UnControlled` | the component value has been changed |
## events cont. [wrapped codemirror events](https://codemirror.net/doc/manual.html#events)
- `onBlur(editor, event)` - *[blur](https://codemirror.net/doc/manual.html#event_blur)*
- `onContextMenu(editor, event)` - *[contextmenu](https://codemirror.net/doc/manual.html#event_dom)*
- `onCopy(editor)` - *[copy](https://codemirror.net/doc/manual.html#event_dom)*
- `onCursor(editor, data)`- *[cursorActivity](https://codemirror.net/doc/manual.html#event_doc_cursorActivity)*
- `onCursorActivity(editor)` - *[cursorActivity](https://codemirror.net/doc/manual.html#event_cursorActivity)*
- `onCut(editor)` - *[cut](https://codemirror.net/doc/manual.html#event_dom)*
- `onDblClick(editor, event)` - *[dblclick](https://codemirror.net/doc/manual.html#event_dom)*
- `onDragEnter(editor, event)` - *[dragenter](https://codemirror.net/doc/manual.html#event_dom)*
- `onDragOver(editor, event)` - *[dragover](https://codemirror.net/doc/manual.html#event_dom)*
- `onDragLeave(editor, event)` - *[dragleave](https://codemirror.net/doc/manual.html#event_dom)*
- `onDragStart(editor, event)` - *[dragstart](https://codemirror.net/doc/manual.html#event_dom)*
- `onDrop(editor, event)` - *[drop](https://codemirror.net/doc/manual.html#event_dom)*
- `onFocus(editor, event)` - *[focus](https://codemirror.net/doc/manual.html#event_focus)*
- `onGutterClick(editor, lineNumber, gutter, event)` - *[gutterClick](https://codemirror.net/doc/manual.html#event_gutterClick)*
- `onInputRead(editor, changeObj)` - *[gutterClick](https://codemirror.net/doc/manual.html#events)*
- `onKeyDown(editor, event)` - *[keydown](https://codemirror.net/doc/manual.html#event_dom)*
- `onKeyHandled(editor, key, event)` - *[keyhandled](https://codemirror.net/doc/manual.html#events)*
- `onKeyPress(editor, event)` - *[keypress](https://codemirror.net/doc/manual.html#event_dom)*
- `onKeyUp(editor, event)` - *[keyup](https://codemirror.net/doc/manual.html#event_dom)*
- `onMouseDown(editor, event)` - *[mousedown](https://codemirror.net/doc/manual.html#event_dom)*
- `onPaste(editor)` - *[paste](https://codemirror.net/doc/manual.html#event_dom)*
- `onScroll(editor, data)` - *[scroll](https://codemirror.net/doc/manual.html#event_scroll)*
- `onSelection(editor, data)` - *[beforeSelectionChange](https://codemirror.net/doc/manual.html#event_doc_beforeSelectionChange)*
- `onTouchStart(editor, event)` - *[touchstart](https://codemirror.net/doc/manual.html#event_dom)*
- `onUpdate(editor, event)` - *[update](https://codemirror.net/doc/manual.html#event_update)*
- `onViewportChange(editor, from, to)` - *[viewportChange](https://codemirror.net/doc/manual.html#event_viewportChange)*
## FAQ
- Is server side rendering supported?
Yes. react-codemirror2 will prevent rendering in absence of `navigator`. You can also force the component to not render via a `PREVENT_CODEMIRROR_RENDER` global.
- How can I get the instance?
The recommended technique to get the instance is to persist the `editor` returned via event callbacks. There is no static method to get it on demand, e.g. `CodeMirror.getInstance()`. Example...
```jsx
constructor() {
this.instance = null;
}
render() {
<CodeMirror editorDidMount={editor => { this.instance = editor }}/>
}
```
- How can I have a resizable editor?
Check out [bokuweb/re-resizable](https://github.com/bokuweb/re-resizable). Wrapping your component with `<Resizable/>'s` works well
## Contributing
Pull Requests are welcome. Be mindful of the available scripts below to help submitting a well-received contribution.
- `npm run start` to run the app on `localhost:8000`
- `npm run test` to ensure tests continue to pass
- `npm run build` to generate the demo bundle
note that it's necessary to bump the [package.json](https://github.com/scniro/react-codemirror2/blob/master/package.json#L3) version prior to final `npm run build` so we can grab the proposed new version as seen in the demo header. Also note, the core changes are to be made in `src/index.tsx` as `./index.js` and `./index.d.ts` are _generated_
[MIT](./LICENSE) © 2020 [scniro](https://github.com/scniro)

82
node_modules/react-codemirror2/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,82 @@
import * as React from 'react';
import * as codemirror from 'codemirror';
export interface IDefineModeOptions {
fn: () => codemirror.Mode<any>;
name: string;
}
export interface ISetScrollOptions {
x?: number | null;
y?: number | null;
}
export interface ISetSelectionOptions {
anchor: codemirror.Position;
head: codemirror.Position;
}
export interface DomEvent {
(editor: codemirror.Editor, event?: any): void;
}
export interface KeyHandledEvent {
(editor: codemirror.Editor, name: string, event: any): void;
}
export interface EditorChangeEvent {
(editor: codemirror.Editor, changeObj: codemirror.EditorChange): void;
}
export interface ICodeMirror {
autoCursor?: boolean;
autoScroll?: boolean;
className?: string;
cursor?: codemirror.Position;
defineMode?: IDefineModeOptions;
editorDidConfigure?: (editor: codemirror.Editor) => void;
editorDidMount?: (editor: codemirror.Editor, value: string, cb: () => void) => void;
editorWillUnmount?: (lib: any) => void;
onBlur?: DomEvent;
onChange?: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string) => void;
onContextMenu?: DomEvent;
onCopy?: DomEvent;
onCursor?: (editor: codemirror.Editor, data: codemirror.Position) => void;
onCut?: DomEvent;
onCursorActivity?: (editor: codemirror.Editor) => void;
onDblClick?: DomEvent;
onDragEnter?: DomEvent;
onDragLeave?: DomEvent;
onDragOver?: DomEvent;
onDragStart?: DomEvent;
onDrop?: DomEvent;
onFocus?: DomEvent;
onGutterClick?: (editor: codemirror.Editor, lineNumber: number, gutter: string, event: Event) => void;
onInputRead?: EditorChangeEvent;
onKeyDown?: DomEvent;
onKeyHandled?: KeyHandledEvent;
onKeyPress?: DomEvent;
onKeyUp?: DomEvent;
onMouseDown?: DomEvent;
onPaste?: DomEvent;
onRenderLine?: (editor: codemirror.Editor, line: codemirror.LineHandle, element: HTMLElement) => void;
onScroll?: (editor: codemirror.Editor, data: codemirror.ScrollInfo) => void;
onSelection?: (editor: codemirror.Editor, data: any) => void;
onTouchStart?: DomEvent;
onUpdate?: (editor: codemirror.Editor) => void;
onViewportChange?: (editor: codemirror.Editor, start: number, end: number) => void;
options?: codemirror.EditorConfiguration;
selection?: {
ranges: Array<ISetSelectionOptions>;
focus?: boolean;
};
scroll?: ISetScrollOptions;
}
export interface IControlledCodeMirror extends ICodeMirror {
onBeforeChange: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string) => void;
value: string;
}
export interface IUnControlledCodeMirror extends ICodeMirror {
detach?: boolean;
editorDidAttach?: (editor: codemirror.Editor) => void;
editorDidDetach?: (editor: codemirror.Editor) => void;
onBeforeChange?: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string, next: () => void) => void;
value?: string;
}
export declare class Controlled extends React.Component<IControlledCodeMirror, any> {
}
export declare class UnControlled extends React.Component<IUnControlledCodeMirror, any> {
}

780
node_modules/react-codemirror2/index.js generated vendored Normal file
View File

@@ -0,0 +1,780 @@
'use strict';
function _extends() {
_extends = Object.assign || function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function _typeof(obj) {
return typeof obj;
};
} else {
_typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
var __extends = void 0 && (void 0).__extends || function() {
var _extendStatics = function extendStatics(d, b) {
_extendStatics = Object.setPrototypeOf || {
__proto__: []
}
instanceof Array && function(d, b) {
d.__proto__ = b;
} || function(d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function(d, b) {
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.UnControlled = exports.Controlled = void 0;
var React = require('react');
var SERVER_RENDERED = typeof navigator === 'undefined' || typeof global !== 'undefined' && global['PREVENT_CODEMIRROR_RENDER'] === true;
var cm;
if (!SERVER_RENDERED) {
cm = require('codemirror');
}
var Helper = function() {
function Helper() {}
Helper.equals = function(x, y) {
var _this = this;
var ok = Object.keys,
tx = _typeof(x),
ty = _typeof(y);
return x && y && tx === 'object' && tx === ty ? ok(x).length === ok(y).length && ok(x).every(function(key) {
return _this.equals(x[key], y[key]);
}) : x === y;
};
return Helper;
}();
var Shared = function() {
function Shared(editor, props) {
this.editor = editor;
this.props = props;
}
Shared.prototype.delegateCursor = function(position, scroll, focus) {
var doc = this.editor.getDoc();
if (focus) {
this.editor.focus();
}
scroll ? doc.setCursor(position) : doc.setCursor(position, null, {
scroll: false
});
};
Shared.prototype.delegateScroll = function(coordinates) {
this.editor.scrollTo(coordinates.x, coordinates.y);
};
Shared.prototype.delegateSelection = function(ranges, focus) {
var doc = this.editor.getDoc();
doc.setSelections(ranges);
if (focus) {
this.editor.focus();
}
};
Shared.prototype.apply = function(props) {
if (props && props.selection && props.selection.ranges) {
this.delegateSelection(props.selection.ranges, props.selection.focus || false);
}
if (props && props.cursor) {
this.delegateCursor(props.cursor, props.autoScroll || false, this.editor.getOption('autofocus') || false);
}
if (props && props.scroll) {
this.delegateScroll(props.scroll);
}
};
Shared.prototype.applyNext = function(props, next, preserved) {
if (props && props.selection && props.selection.ranges) {
if (next && next.selection && next.selection.ranges && !Helper.equals(props.selection.ranges, next.selection.ranges)) {
this.delegateSelection(next.selection.ranges, next.selection.focus || false);
}
}
if (props && props.cursor) {
if (next && next.cursor && !Helper.equals(props.cursor, next.cursor)) {
this.delegateCursor(preserved.cursor || next.cursor, next.autoScroll || false, next.autoCursor || false);
}
}
if (props && props.scroll) {
if (next && next.scroll && !Helper.equals(props.scroll, next.scroll)) {
this.delegateScroll(next.scroll);
}
}
};
Shared.prototype.applyUserDefined = function(props, preserved) {
if (preserved && preserved.cursor) {
this.delegateCursor(preserved.cursor, props.autoScroll || false, this.editor.getOption('autofocus') || false);
}
};
Shared.prototype.wire = function(props) {
var _this = this;
Object.keys(props || {}).filter(function(p) {
return /^on/.test(p);
}).forEach(function(prop) {
switch (prop) {
case 'onBlur': {
_this.editor.on('blur', function(cm, event) {
_this.props.onBlur(_this.editor, event);
});
}
break;
case 'onContextMenu': {
_this.editor.on('contextmenu', function(cm, event) {
_this.props.onContextMenu(_this.editor, event);
});
break;
}
case 'onCopy': {
_this.editor.on('copy', function(cm, event) {
_this.props.onCopy(_this.editor, event);
});
break;
}
case 'onCursor': {
_this.editor.on('cursorActivity', function(cm) {
_this.props.onCursor(_this.editor, _this.editor.getDoc().getCursor());
});
}
break;
case 'onCursorActivity': {
_this.editor.on('cursorActivity', function(cm) {
_this.props.onCursorActivity(_this.editor);
});
}
break;
case 'onCut': {
_this.editor.on('cut', function(cm, event) {
_this.props.onCut(_this.editor, event);
});
break;
}
case 'onDblClick': {
_this.editor.on('dblclick', function(cm, event) {
_this.props.onDblClick(_this.editor, event);
});
break;
}
case 'onDragEnter': {
_this.editor.on('dragenter', function(cm, event) {
_this.props.onDragEnter(_this.editor, event);
});
}
break;
case 'onDragLeave': {
_this.editor.on('dragleave', function(cm, event) {
_this.props.onDragLeave(_this.editor, event);
});
break;
}
case 'onDragOver': {
_this.editor.on('dragover', function(cm, event) {
_this.props.onDragOver(_this.editor, event);
});
}
break;
case 'onDragStart': {
_this.editor.on('dragstart', function(cm, event) {
_this.props.onDragStart(_this.editor, event);
});
break;
}
case 'onDrop': {
_this.editor.on('drop', function(cm, event) {
_this.props.onDrop(_this.editor, event);
});
}
break;
case 'onFocus': {
_this.editor.on('focus', function(cm, event) {
_this.props.onFocus(_this.editor, event);
});
}
break;
case 'onGutterClick': {
_this.editor.on('gutterClick', function(cm, lineNumber, gutter, event) {
_this.props.onGutterClick(_this.editor, lineNumber, gutter, event);
});
}
break;
case 'onInputRead': {
_this.editor.on('inputRead', function(cm, EditorChangeEvent) {
_this.props.onInputRead(_this.editor, EditorChangeEvent);
});
}
break;
case 'onKeyDown': {
_this.editor.on('keydown', function(cm, event) {
_this.props.onKeyDown(_this.editor, event);
});
}
break;
case 'onKeyHandled': {
_this.editor.on('keyHandled', function(cm, key, event) {
_this.props.onKeyHandled(_this.editor, key, event);
});
}
break;
case 'onKeyPress': {
_this.editor.on('keypress', function(cm, event) {
_this.props.onKeyPress(_this.editor, event);
});
}
break;
case 'onKeyUp': {
_this.editor.on('keyup', function(cm, event) {
_this.props.onKeyUp(_this.editor, event);
});
}
break;
case 'onMouseDown': {
_this.editor.on('mousedown', function(cm, event) {
_this.props.onMouseDown(_this.editor, event);
});
break;
}
case 'onPaste': {
_this.editor.on('paste', function(cm, event) {
_this.props.onPaste(_this.editor, event);
});
break;
}
case 'onRenderLine': {
_this.editor.on('renderLine', function(cm, line, element) {
_this.props.onRenderLine(_this.editor, line, element);
});
break;
}
case 'onScroll': {
_this.editor.on('scroll', function(cm) {
_this.props.onScroll(_this.editor, _this.editor.getScrollInfo());
});
}
break;
case 'onSelection': {
_this.editor.on('beforeSelectionChange', function(cm, data) {
_this.props.onSelection(_this.editor, data);
});
}
break;
case 'onTouchStart': {
_this.editor.on('touchstart', function(cm, event) {
_this.props.onTouchStart(_this.editor, event);
});
break;
}
case 'onUpdate': {
_this.editor.on('update', function(cm) {
_this.props.onUpdate(_this.editor);
});
}
break;
case 'onViewportChange': {
_this.editor.on('viewportChange', function(cm, from, to) {
_this.props.onViewportChange(_this.editor, from, to);
});
}
break;
}
});
};
return Shared;
}();
var Controlled = function(_super) {
__extends(Controlled, _super);
function Controlled(props) {
var _this = _super.call(this, props) || this;
if (SERVER_RENDERED) return _this;
_this.applied = false;
_this.appliedNext = false;
_this.appliedUserDefined = false;
_this.deferred = null;
_this.emulating = false;
_this.hydrated = false;
_this.initCb = function() {
if (_this.props.editorDidConfigure) {
_this.props.editorDidConfigure(_this.editor);
}
};
_this.mounted = false;
return _this;
}
Controlled.prototype.hydrate = function(props) {
var _this = this;
var _options = props && props.options ? props.options : {};
var userDefinedOptions = _extends({}, cm.defaults, this.editor.options, _options);
var optionDelta = Object.keys(userDefinedOptions).some(function(key) {
return _this.editor.getOption(key) !== userDefinedOptions[key];
});
if (optionDelta) {
Object.keys(userDefinedOptions).forEach(function(key) {
if (_options.hasOwnProperty(key)) {
if (_this.editor.getOption(key) !== userDefinedOptions[key]) {
_this.editor.setOption(key, userDefinedOptions[key]);
_this.mirror.setOption(key, userDefinedOptions[key]);
}
}
});
}
if (!this.hydrated) {
this.deferred ? this.resolveChange(props.value) : this.initChange(props.value || '');
}
this.hydrated = true;
};
Controlled.prototype.initChange = function(value) {
this.emulating = true;
var doc = this.editor.getDoc();
var lastLine = doc.lastLine();
var lastChar = doc.getLine(doc.lastLine()).length;
doc.replaceRange(value || '', {
line: 0,
ch: 0
}, {
line: lastLine,
ch: lastChar
});
this.mirror.setValue(value);
doc.clearHistory();
this.mirror.clearHistory();
this.emulating = false;
};
Controlled.prototype.resolveChange = function(value) {
this.emulating = true;
var doc = this.editor.getDoc();
if (this.deferred.origin === 'undo') {
doc.undo();
} else if (this.deferred.origin === 'redo') {
doc.redo();
} else {
doc.replaceRange(this.deferred.text, this.deferred.from, this.deferred.to, this.deferred.origin);
}
if (value && value !== doc.getValue()) {
var cursor = doc.getCursor();
doc.setValue(value);
doc.setCursor(cursor);
}
this.emulating = false;
this.deferred = null;
};
Controlled.prototype.mirrorChange = function(deferred) {
var doc = this.editor.getDoc();
if (deferred.origin === 'undo') {
doc.setHistory(this.mirror.getHistory());
this.mirror.undo();
} else if (deferred.origin === 'redo') {
doc.setHistory(this.mirror.getHistory());
this.mirror.redo();
} else {
this.mirror.replaceRange(deferred.text, deferred.from, deferred.to, deferred.origin);
}
return this.mirror.getValue();
};
Controlled.prototype.componentDidMount = function() {
var _this = this;
if (SERVER_RENDERED) return;
if (this.props.defineMode) {
if (this.props.defineMode.name && this.props.defineMode.fn) {
cm.defineMode(this.props.defineMode.name, this.props.defineMode.fn);
}
}
this.editor = cm(this.ref, this.props.options);
this.shared = new Shared(this.editor, this.props);
this.mirror = cm(function() {}, this.props.options);
this.editor.on('electricInput', function() {
_this.mirror.setHistory(_this.editor.getDoc().getHistory());
});
this.editor.on('cursorActivity', function() {
_this.mirror.setCursor(_this.editor.getDoc().getCursor());
});
this.editor.on('beforeChange', function(cm, data) {
if (_this.emulating) {
return;
}
data.cancel();
_this.deferred = data;
var phantomChange = _this.mirrorChange(_this.deferred);
if (_this.props.onBeforeChange) _this.props.onBeforeChange(_this.editor, _this.deferred, phantomChange);
});
this.editor.on('change', function(cm, data) {
if (!_this.mounted) {
return;
}
if (_this.props.onChange) {
_this.props.onChange(_this.editor, data, _this.editor.getValue());
}
});
this.hydrate(this.props);
this.shared.apply(this.props);
this.applied = true;
this.mounted = true;
this.shared.wire(this.props);
if (this.editor.getOption('autofocus')) {
this.editor.focus();
}
if (this.props.editorDidMount) {
this.props.editorDidMount(this.editor, this.editor.getValue(), this.initCb);
}
};
Controlled.prototype.componentDidUpdate = function(prevProps) {
if (SERVER_RENDERED) return;
var preserved = {
cursor: null
};
if (this.props.value !== prevProps.value) {
this.hydrated = false;
}
if (!this.props.autoCursor && this.props.autoCursor !== undefined) {
preserved.cursor = this.editor.getDoc().getCursor();
}
this.hydrate(this.props);
if (!this.appliedNext) {
this.shared.applyNext(prevProps, this.props, preserved);
this.appliedNext = true;
}
this.shared.applyUserDefined(prevProps, preserved);
this.appliedUserDefined = true;
};
Controlled.prototype.componentWillUnmount = function() {
if (SERVER_RENDERED) return;
if (this.props.editorWillUnmount) {
this.props.editorWillUnmount(cm);
}
};
Controlled.prototype.shouldComponentUpdate = function(nextProps, nextState) {
return !SERVER_RENDERED;
};
Controlled.prototype.render = function() {
var _this = this;
if (SERVER_RENDERED) return null;
var className = this.props.className ? 'react-codemirror2 ' + this.props.className : 'react-codemirror2';
return React.createElement('div', {
className: className,
ref: function ref(self) {
return _this.ref = self;
}
});
};
return Controlled;
}(React.Component);
exports.Controlled = Controlled;
var UnControlled = function(_super) {
__extends(UnControlled, _super);
function UnControlled(props) {
var _this = _super.call(this, props) || this;
if (SERVER_RENDERED) return _this;
_this.applied = false;
_this.appliedUserDefined = false;
_this.continueChange = false;
_this.detached = false;
_this.hydrated = false;
_this.initCb = function() {
if (_this.props.editorDidConfigure) {
_this.props.editorDidConfigure(_this.editor);
}
};
_this.mounted = false;
_this.onBeforeChangeCb = function() {
_this.continueChange = true;
};
return _this;
}
UnControlled.prototype.hydrate = function(props) {
var _this = this;
var _options = props && props.options ? props.options : {};
var userDefinedOptions = _extends({}, cm.defaults, this.editor.options, _options);
var optionDelta = Object.keys(userDefinedOptions).some(function(key) {
return _this.editor.getOption(key) !== userDefinedOptions[key];
});
if (optionDelta) {
Object.keys(userDefinedOptions).forEach(function(key) {
if (_options.hasOwnProperty(key)) {
if (_this.editor.getOption(key) !== userDefinedOptions[key]) {
_this.editor.setOption(key, userDefinedOptions[key]);
}
}
});
}
if (!this.hydrated) {
var doc = this.editor.getDoc();
var lastLine = doc.lastLine();
var lastChar = doc.getLine(doc.lastLine()).length;
doc.replaceRange(props.value || '', {
line: 0,
ch: 0
}, {
line: lastLine,
ch: lastChar
});
}
this.hydrated = true;
};
UnControlled.prototype.componentDidMount = function() {
var _this = this;
if (SERVER_RENDERED) return;
this.detached = this.props.detach === true;
if (this.props.defineMode) {
if (this.props.defineMode.name && this.props.defineMode.fn) {
cm.defineMode(this.props.defineMode.name, this.props.defineMode.fn);
}
}
this.editor = cm(this.ref, this.props.options);
this.shared = new Shared(this.editor, this.props);
this.editor.on('beforeChange', function(cm, data) {
if (_this.props.onBeforeChange) {
_this.props.onBeforeChange(_this.editor, data, _this.editor.getValue(), _this.onBeforeChangeCb);
}
});
this.editor.on('change', function(cm, data) {
if (!_this.mounted || !_this.props.onChange) {
return;
}
if (_this.props.onBeforeChange) {
if (_this.continueChange) {
_this.props.onChange(_this.editor, data, _this.editor.getValue());
}
} else {
_this.props.onChange(_this.editor, data, _this.editor.getValue());
}
});
this.hydrate(this.props);
this.shared.apply(this.props);
this.applied = true;
this.mounted = true;
this.shared.wire(this.props);
this.editor.getDoc().clearHistory();
if (this.props.editorDidMount) {
this.props.editorDidMount(this.editor, this.editor.getValue(), this.initCb);
}
};
UnControlled.prototype.componentDidUpdate = function(prevProps) {
if (this.detached && this.props.detach === false) {
this.detached = false;
if (prevProps.editorDidAttach) {
prevProps.editorDidAttach(this.editor);
}
}
if (!this.detached && this.props.detach === true) {
this.detached = true;
if (prevProps.editorDidDetach) {
prevProps.editorDidDetach(this.editor);
}
}
if (SERVER_RENDERED || this.detached) return;
var preserved = {
cursor: null
};
if (this.props.value !== prevProps.value) {
this.hydrated = false;
this.applied = false;
this.appliedUserDefined = false;
}
if (!prevProps.autoCursor && prevProps.autoCursor !== undefined) {
preserved.cursor = this.editor.getDoc().getCursor();
}
this.hydrate(this.props);
if (!this.applied) {
this.shared.apply(prevProps);
this.applied = true;
}
if (!this.appliedUserDefined) {
this.shared.applyUserDefined(prevProps, preserved);
this.appliedUserDefined = true;
}
};
UnControlled.prototype.componentWillUnmount = function() {
if (SERVER_RENDERED) return;
if (this.props.editorWillUnmount) {
this.props.editorWillUnmount(cm);
}
};
UnControlled.prototype.shouldComponentUpdate = function(nextProps, nextState) {
var update = true;
if (SERVER_RENDERED) update = false;
if (this.detached && nextProps.detach) update = false;
return update;
};
UnControlled.prototype.render = function() {
var _this = this;
if (SERVER_RENDERED) return null;
var className = this.props.className ? 'react-codemirror2 ' + this.props.className : 'react-codemirror2';
return React.createElement('div', {
className: className,
ref: function ref(self) {
return _this.ref = self;
}
});
};
return UnControlled;
}(React.Component);
exports.UnControlled = UnControlled;

101
node_modules/react-codemirror2/package.json generated vendored Normal file
View File

@@ -0,0 +1,101 @@
{
"name": "react-codemirror2",
"version": "7.3.0",
"description": "a tiny react codemirror component wrapper",
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"prestart": "npm run build",
"start": "node docs/server.js",
"prebuild": "npm run transpile",
"build": "webpack-cli --mode production --display-error-details --optimize-minimize --config docs/webpack.config.js",
"transpile": "tsc",
"posttranspile": "gulp ts-scrub",
"pretest": "npm run transpile",
"test": "jest"
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"src/**"
],
"setupFiles": [
"@nteract/mockument",
"raf/polyfill"
],
"testRegex": "./test/(index|index.server).spec.tsx",
"transform": {
".(ts|tsx)": "ts-jest"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/scniro/react-codemirror2.git"
},
"author": "scniro",
"license": "MIT",
"bugs": {
"url": "https://github.com/scniro/react-codemirror2/issues"
},
"homepage": "https://github.com/scniro/react-codemirror2#readme",
"keywords": [
"react",
"react-codemirror",
"codemirror",
"editor",
"syntax",
"ide",
"code"
],
"peerDependencies": {
"codemirror": "5.x",
"react": ">=15.5 <=17.x"
},
"devDependencies": {
"@babel/preset-env": "7.10.1",
"@babel/preset-react": "7.10.1",
"@nteract/mockument": "1.0.4",
"@types/codemirror": "0.0.x",
"@types/jest": "25.2.3",
"@types/react": "16.9.35",
"babel-core": "6.26.3",
"babel-loader": "8.1.0",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-preset-env": "1.7.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"codemirror": "5.x",
"coveralls": "3.1.0",
"css-loader": "3.5.3",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.2",
"express": "4.17.1",
"gulp": "4.0.2",
"gulp-babel": "8.0.0",
"gulp-beautify": "3.0.0",
"gulp-replace": "1.0.0",
"jest": "26.0.1",
"node-sass": "4.14.1",
"prismjs": "1.25.0",
"raf": "3.4.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-redux": "7.2.0",
"react-test-renderer": "16.13.1",
"redux": "4.0.5",
"rimraf": "3.0.2",
"sass-loader": "8.0.2",
"sinon": "9.0.2",
"style-loader": "1.2.1",
"ts-jest": "26.0.0",
"typescript": "3.9.3",
"typescript-formatter": "7.2.2",
"webpack": "4.43.0",
"webpack-cli": "3.3.11"
}
}