@jupyterlab/codeeditor 0.19.1-alpha.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/editor.js CHANGED
@@ -1,121 +1,121 @@
1
- "use strict";
2
- // Copyright (c) Jupyter Development Team.
3
- // Distributed under the terms of the Modified BSD License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const signaling_1 = require("@phosphor/signaling");
6
- const observables_1 = require("@jupyterlab/observables");
7
- /**
8
- * A namespace for code editors.
9
- *
10
- * #### Notes
11
- * - A code editor is a set of common assumptions which hold for all concrete editors.
12
- * - Changes in implementations of the code editor should only be caused by changes in concrete editors.
13
- * - Common JLab services which are based on the code editor should belong to `IEditorServices`.
14
- */
15
- var CodeEditor;
16
- (function (CodeEditor) {
17
- /**
18
- * The default selection style.
19
- */
20
- CodeEditor.defaultSelectionStyle = {
21
- className: '',
22
- displayName: '',
23
- color: 'black'
24
- };
25
- /**
26
- * The default implementation of the editor model.
27
- */
28
- class Model {
29
- /**
30
- * Construct a new Model.
31
- */
32
- constructor(options) {
33
- this._isDisposed = false;
34
- this._mimeTypeChanged = new signaling_1.Signal(this);
35
- options = options || {};
36
- if (options.modelDB) {
37
- this.modelDB = options.modelDB;
38
- }
39
- else {
40
- this.modelDB = new observables_1.ModelDB();
41
- }
42
- let value = this.modelDB.createString('value');
43
- value.text = value.text || options.value || '';
44
- let mimeType = this.modelDB.createValue('mimeType');
45
- mimeType.set(options.mimeType || 'text/plain');
46
- mimeType.changed.connect(this._onMimeTypeChanged, this);
47
- this.modelDB.createMap('selections');
48
- }
49
- /**
50
- * A signal emitted when a mimetype changes.
51
- */
52
- get mimeTypeChanged() {
53
- return this._mimeTypeChanged;
54
- }
55
- /**
56
- * Get the value of the model.
57
- */
58
- get value() {
59
- return this.modelDB.get('value');
60
- }
61
- /**
62
- * Get the selections for the model.
63
- */
64
- get selections() {
65
- return this.modelDB.get('selections');
66
- }
67
- /**
68
- * A mime type of the model.
69
- */
70
- get mimeType() {
71
- return this.modelDB.getValue('mimeType');
72
- }
73
- set mimeType(newValue) {
74
- const oldValue = this.mimeType;
75
- if (oldValue === newValue) {
76
- return;
77
- }
78
- this.modelDB.setValue('mimeType', newValue);
79
- }
80
- /**
81
- * Whether the model is disposed.
82
- */
83
- get isDisposed() {
84
- return this._isDisposed;
85
- }
86
- /**
87
- * Dispose of the resources used by the model.
88
- */
89
- dispose() {
90
- if (this._isDisposed) {
91
- return;
92
- }
93
- this._isDisposed = true;
94
- signaling_1.Signal.clearData(this);
95
- }
96
- _onMimeTypeChanged(mimeType, args) {
97
- this._mimeTypeChanged.emit({
98
- name: 'mimeType',
99
- oldValue: args.oldValue,
100
- newValue: args.newValue
101
- });
102
- }
103
- }
104
- CodeEditor.Model = Model;
105
- /**
106
- * The default configuration options for an editor.
107
- */
108
- CodeEditor.defaultConfig = {
109
- fontFamily: null,
110
- fontSize: null,
111
- lineHeight: null,
112
- lineNumbers: false,
113
- lineWrap: 'on',
114
- wordWrapColumn: 80,
115
- readOnly: false,
116
- tabSize: 4,
117
- insertSpaces: true,
118
- matchBrackets: true,
119
- autoClosingBrackets: true
120
- };
121
- })(CodeEditor = exports.CodeEditor || (exports.CodeEditor = {}));
1
+ "use strict";
2
+ // Copyright (c) Jupyter Development Team.
3
+ // Distributed under the terms of the Modified BSD License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const signaling_1 = require("@phosphor/signaling");
6
+ const observables_1 = require("@jupyterlab/observables");
7
+ /**
8
+ * A namespace for code editors.
9
+ *
10
+ * #### Notes
11
+ * - A code editor is a set of common assumptions which hold for all concrete editors.
12
+ * - Changes in implementations of the code editor should only be caused by changes in concrete editors.
13
+ * - Common JLab services which are based on the code editor should belong to `IEditorServices`.
14
+ */
15
+ var CodeEditor;
16
+ (function (CodeEditor) {
17
+ /**
18
+ * The default selection style.
19
+ */
20
+ CodeEditor.defaultSelectionStyle = {
21
+ className: '',
22
+ displayName: '',
23
+ color: 'black'
24
+ };
25
+ /**
26
+ * The default implementation of the editor model.
27
+ */
28
+ class Model {
29
+ /**
30
+ * Construct a new Model.
31
+ */
32
+ constructor(options) {
33
+ this._isDisposed = false;
34
+ this._mimeTypeChanged = new signaling_1.Signal(this);
35
+ options = options || {};
36
+ if (options.modelDB) {
37
+ this.modelDB = options.modelDB;
38
+ }
39
+ else {
40
+ this.modelDB = new observables_1.ModelDB();
41
+ }
42
+ let value = this.modelDB.createString('value');
43
+ value.text = value.text || options.value || '';
44
+ let mimeType = this.modelDB.createValue('mimeType');
45
+ mimeType.set(options.mimeType || 'text/plain');
46
+ mimeType.changed.connect(this._onMimeTypeChanged, this);
47
+ this.modelDB.createMap('selections');
48
+ }
49
+ /**
50
+ * A signal emitted when a mimetype changes.
51
+ */
52
+ get mimeTypeChanged() {
53
+ return this._mimeTypeChanged;
54
+ }
55
+ /**
56
+ * Get the value of the model.
57
+ */
58
+ get value() {
59
+ return this.modelDB.get('value');
60
+ }
61
+ /**
62
+ * Get the selections for the model.
63
+ */
64
+ get selections() {
65
+ return this.modelDB.get('selections');
66
+ }
67
+ /**
68
+ * A mime type of the model.
69
+ */
70
+ get mimeType() {
71
+ return this.modelDB.getValue('mimeType');
72
+ }
73
+ set mimeType(newValue) {
74
+ const oldValue = this.mimeType;
75
+ if (oldValue === newValue) {
76
+ return;
77
+ }
78
+ this.modelDB.setValue('mimeType', newValue);
79
+ }
80
+ /**
81
+ * Whether the model is disposed.
82
+ */
83
+ get isDisposed() {
84
+ return this._isDisposed;
85
+ }
86
+ /**
87
+ * Dispose of the resources used by the model.
88
+ */
89
+ dispose() {
90
+ if (this._isDisposed) {
91
+ return;
92
+ }
93
+ this._isDisposed = true;
94
+ signaling_1.Signal.clearData(this);
95
+ }
96
+ _onMimeTypeChanged(mimeType, args) {
97
+ this._mimeTypeChanged.emit({
98
+ name: 'mimeType',
99
+ oldValue: args.oldValue,
100
+ newValue: args.newValue
101
+ });
102
+ }
103
+ }
104
+ CodeEditor.Model = Model;
105
+ /**
106
+ * The default configuration options for an editor.
107
+ */
108
+ CodeEditor.defaultConfig = {
109
+ fontFamily: null,
110
+ fontSize: null,
111
+ lineHeight: null,
112
+ lineNumbers: false,
113
+ lineWrap: 'on',
114
+ wordWrapColumn: 80,
115
+ readOnly: false,
116
+ tabSize: 4,
117
+ insertSpaces: true,
118
+ matchBrackets: true,
119
+ autoClosingBrackets: true
120
+ };
121
+ })(CodeEditor = exports.CodeEditor || (exports.CodeEditor = {}));
package/lib/factory.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { CodeEditor } from './editor';
2
- /**
3
- * The editor factory service interface.
4
- */
5
- export interface IEditorFactoryService {
6
- /**
7
- * Create a new editor for inline code.
8
- */
9
- newInlineEditor(options: CodeEditor.IOptions): CodeEditor.IEditor;
10
- /**
11
- * Create a new editor for a full document.
12
- */
13
- newDocumentEditor(options: CodeEditor.IOptions): CodeEditor.IEditor;
14
- }
1
+ import { CodeEditor } from './editor';
2
+ /**
3
+ * The editor factory service interface.
4
+ */
5
+ export interface IEditorFactoryService {
6
+ /**
7
+ * Create a new editor for inline code.
8
+ */
9
+ newInlineEditor(options: CodeEditor.IOptions): CodeEditor.IEditor;
10
+ /**
11
+ * Create a new editor for a full document.
12
+ */
13
+ newDocumentEditor(options: CodeEditor.IOptions): CodeEditor.IEditor;
14
+ }
package/lib/factory.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";
2
- // Copyright (c) Jupyter Development Team.
3
- // Distributed under the terms of the Modified BSD License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ // Copyright (c) Jupyter Development Team.
3
+ // Distributed under the terms of the Modified BSD License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/index.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { Token } from '@phosphor/coreutils';
2
- import { IEditorFactoryService } from './factory';
3
- import { IEditorMimeTypeService } from './mimetype';
4
- import '../style/index.css';
5
- export * from './editor';
6
- export * from './jsoneditor';
7
- export * from './widget';
8
- export * from './factory';
9
- export * from './mimetype';
10
- /**
11
- * Code editor services token.
12
- */
13
- export declare const IEditorServices: Token<IEditorServices>;
14
- /**
15
- * Code editor services.
16
- */
17
- export interface IEditorServices {
18
- /**
19
- * The code editor factory.
20
- */
21
- readonly factoryService: IEditorFactoryService;
22
- /**
23
- * The editor mime type service.
24
- */
25
- readonly mimeTypeService: IEditorMimeTypeService;
26
- }
1
+ import { Token } from '@phosphor/coreutils';
2
+ import { IEditorFactoryService } from './factory';
3
+ import { IEditorMimeTypeService } from './mimetype';
4
+ import '../style/index.css';
5
+ export * from './editor';
6
+ export * from './jsoneditor';
7
+ export * from './widget';
8
+ export * from './factory';
9
+ export * from './mimetype';
10
+ /**
11
+ * Code editor services token.
12
+ */
13
+ export declare const IEditorServices: Token<IEditorServices>;
14
+ /**
15
+ * Code editor services.
16
+ */
17
+ export interface IEditorServices {
18
+ /**
19
+ * The code editor factory.
20
+ */
21
+ readonly factoryService: IEditorFactoryService;
22
+ /**
23
+ * The editor mime type service.
24
+ */
25
+ readonly mimeTypeService: IEditorMimeTypeService;
26
+ }
package/lib/index.js CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";
2
- // Copyright (c) Jupyter Development Team.
3
- // Distributed under the terms of the Modified BSD License.
4
- function __export(m) {
5
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
6
- }
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const coreutils_1 = require("@phosphor/coreutils");
9
- require("../style/index.css");
10
- __export(require("./editor"));
11
- __export(require("./jsoneditor"));
12
- __export(require("./widget"));
13
- __export(require("./mimetype"));
14
- /* tslint:disable */
15
- /**
16
- * Code editor services token.
17
- */
18
- exports.IEditorServices = new coreutils_1.Token('@jupyterlab/codeeditor:IEditorServices');
1
+ "use strict";
2
+ // Copyright (c) Jupyter Development Team.
3
+ // Distributed under the terms of the Modified BSD License.
4
+ function __export(m) {
5
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
6
+ }
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const coreutils_1 = require("@phosphor/coreutils");
9
+ require("../style/index.css");
10
+ __export(require("./editor"));
11
+ __export(require("./jsoneditor"));
12
+ __export(require("./widget"));
13
+ __export(require("./mimetype"));
14
+ /* tslint:disable */
15
+ /**
16
+ * Code editor services token.
17
+ */
18
+ exports.IEditorServices = new coreutils_1.Token('@jupyterlab/codeeditor:IEditorServices');
@@ -1,139 +1,139 @@
1
- import { IObservableJSON } from '@jupyterlab/observables';
2
- import { Message } from '@phosphor/messaging';
3
- import { Widget } from '@phosphor/widgets';
4
- import { CodeEditor } from './editor';
5
- /**
6
- * A widget for editing observable JSON.
7
- */
8
- export declare class JSONEditor extends Widget {
9
- /**
10
- * Construct a new JSON editor.
11
- */
12
- constructor(options: JSONEditor.IOptions);
13
- /**
14
- * The code editor used by the editor.
15
- */
16
- readonly editor: CodeEditor.IEditor;
17
- /**
18
- * The code editor model used by the editor.
19
- */
20
- readonly model: CodeEditor.IModel;
21
- /**
22
- * Whether the editor is collapsible.
23
- */
24
- readonly collapsible: boolean;
25
- /**
26
- * The title of the editor.
27
- */
28
- editorTitle: string;
29
- /**
30
- * Get the editor host node used by the JSON editor.
31
- */
32
- readonly editorHostNode: HTMLElement;
33
- /**
34
- * Get the header node used by the JSON editor.
35
- */
36
- readonly headerNode: HTMLElement;
37
- /**
38
- * Get the title node used by the JSON editor.
39
- */
40
- readonly titleNode: HTMLElement;
41
- /**
42
- * Get the collapser node used by the JSON editor.
43
- */
44
- readonly collapserNode: HTMLElement;
45
- /**
46
- * Get the revert button used by the JSON editor.
47
- */
48
- readonly revertButtonNode: HTMLElement;
49
- /**
50
- * Get the commit button used by the JSON editor.
51
- */
52
- readonly commitButtonNode: HTMLElement;
53
- /**
54
- * The observable source.
55
- */
56
- source: IObservableJSON | null;
57
- /**
58
- * Get whether the editor is dirty.
59
- */
60
- readonly isDirty: boolean;
61
- /**
62
- * Handle the DOM events for the widget.
63
- *
64
- * @param event - The DOM event sent to the widget.
65
- *
66
- * #### Notes
67
- * This method implements the DOM `EventListener` interface and is
68
- * called in response to events on the notebook panel's node. It should
69
- * not be called directly by user code.
70
- */
71
- handleEvent(event: Event): void;
72
- /**
73
- * Handle `after-attach` messages for the widget.
74
- */
75
- protected onAfterAttach(msg: Message): void;
76
- /**
77
- * Handle `after-show` messages for the widget.
78
- */
79
- protected onAfterShow(msg: Message): void;
80
- /**
81
- * Handle `update-request` messages for the widget.
82
- */
83
- protected onUpdateRequest(msg: Message): void;
84
- /**
85
- * Handle `before-detach` messages for the widget.
86
- */
87
- protected onBeforeDetach(msg: Message): void;
88
- /**
89
- * Handle a change to the metadata of the source.
90
- */
91
- private _onSourceChanged;
92
- /**
93
- * Handle change events.
94
- */
95
- private _onValueChanged;
96
- /**
97
- * Handle blur events for the text area.
98
- */
99
- private _evtBlur;
100
- /**
101
- * Handle click events for the buttons.
102
- */
103
- private _evtClick;
104
- /**
105
- * Merge the user content.
106
- */
107
- private _mergeContent;
108
- /**
109
- * Set the value given the owner contents.
110
- */
111
- private _setValue;
112
- private _dataDirty;
113
- private _inputDirty;
114
- private _source;
115
- private _originalValue;
116
- private _changeGuard;
117
- }
118
- /**
119
- * The static namespace JSONEditor class statics.
120
- */
121
- export declare namespace JSONEditor {
122
- /**
123
- * The options used to initialize a json editor.
124
- */
125
- interface IOptions {
126
- /**
127
- * The editor factory used by the editor.
128
- */
129
- editorFactory: CodeEditor.Factory;
130
- /**
131
- * The title of the editor. Defaults to an empty string.
132
- */
133
- title?: string;
134
- /**
135
- * Whether the title should be collapsible. Defaults to `false`.
136
- */
137
- collapsible?: boolean;
138
- }
139
- }
1
+ import { IObservableJSON } from '@jupyterlab/observables';
2
+ import { Message } from '@phosphor/messaging';
3
+ import { Widget } from '@phosphor/widgets';
4
+ import { CodeEditor } from './editor';
5
+ /**
6
+ * A widget for editing observable JSON.
7
+ */
8
+ export declare class JSONEditor extends Widget {
9
+ /**
10
+ * Construct a new JSON editor.
11
+ */
12
+ constructor(options: JSONEditor.IOptions);
13
+ /**
14
+ * The code editor used by the editor.
15
+ */
16
+ readonly editor: CodeEditor.IEditor;
17
+ /**
18
+ * The code editor model used by the editor.
19
+ */
20
+ readonly model: CodeEditor.IModel;
21
+ /**
22
+ * Whether the editor is collapsible.
23
+ */
24
+ readonly collapsible: boolean;
25
+ /**
26
+ * The title of the editor.
27
+ */
28
+ editorTitle: string;
29
+ /**
30
+ * Get the editor host node used by the JSON editor.
31
+ */
32
+ readonly editorHostNode: HTMLElement;
33
+ /**
34
+ * Get the header node used by the JSON editor.
35
+ */
36
+ readonly headerNode: HTMLElement;
37
+ /**
38
+ * Get the title node used by the JSON editor.
39
+ */
40
+ readonly titleNode: HTMLElement;
41
+ /**
42
+ * Get the collapser node used by the JSON editor.
43
+ */
44
+ readonly collapserNode: HTMLElement;
45
+ /**
46
+ * Get the revert button used by the JSON editor.
47
+ */
48
+ readonly revertButtonNode: HTMLElement;
49
+ /**
50
+ * Get the commit button used by the JSON editor.
51
+ */
52
+ readonly commitButtonNode: HTMLElement;
53
+ /**
54
+ * The observable source.
55
+ */
56
+ source: IObservableJSON | null;
57
+ /**
58
+ * Get whether the editor is dirty.
59
+ */
60
+ readonly isDirty: boolean;
61
+ /**
62
+ * Handle the DOM events for the widget.
63
+ *
64
+ * @param event - The DOM event sent to the widget.
65
+ *
66
+ * #### Notes
67
+ * This method implements the DOM `EventListener` interface and is
68
+ * called in response to events on the notebook panel's node. It should
69
+ * not be called directly by user code.
70
+ */
71
+ handleEvent(event: Event): void;
72
+ /**
73
+ * Handle `after-attach` messages for the widget.
74
+ */
75
+ protected onAfterAttach(msg: Message): void;
76
+ /**
77
+ * Handle `after-show` messages for the widget.
78
+ */
79
+ protected onAfterShow(msg: Message): void;
80
+ /**
81
+ * Handle `update-request` messages for the widget.
82
+ */
83
+ protected onUpdateRequest(msg: Message): void;
84
+ /**
85
+ * Handle `before-detach` messages for the widget.
86
+ */
87
+ protected onBeforeDetach(msg: Message): void;
88
+ /**
89
+ * Handle a change to the metadata of the source.
90
+ */
91
+ private _onSourceChanged;
92
+ /**
93
+ * Handle change events.
94
+ */
95
+ private _onValueChanged;
96
+ /**
97
+ * Handle blur events for the text area.
98
+ */
99
+ private _evtBlur;
100
+ /**
101
+ * Handle click events for the buttons.
102
+ */
103
+ private _evtClick;
104
+ /**
105
+ * Merge the user content.
106
+ */
107
+ private _mergeContent;
108
+ /**
109
+ * Set the value given the owner contents.
110
+ */
111
+ private _setValue;
112
+ private _dataDirty;
113
+ private _inputDirty;
114
+ private _source;
115
+ private _originalValue;
116
+ private _changeGuard;
117
+ }
118
+ /**
119
+ * The static namespace JSONEditor class statics.
120
+ */
121
+ export declare namespace JSONEditor {
122
+ /**
123
+ * The options used to initialize a json editor.
124
+ */
125
+ interface IOptions {
126
+ /**
127
+ * The editor factory used by the editor.
128
+ */
129
+ editorFactory: CodeEditor.Factory;
130
+ /**
131
+ * The title of the editor. Defaults to an empty string.
132
+ */
133
+ title?: string;
134
+ /**
135
+ * Whether the title should be collapsible. Defaults to `false`.
136
+ */
137
+ collapsible?: boolean;
138
+ }
139
+ }