UNPKG

2.58 kBTypeScriptView Raw
1import * as nbformat from '@jupyterlab/nbformat';
2import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
3import { PartialJSONObject, ReadonlyPartialJSONObject } from '@lumino/coreutils';
4import { ISignal } from '@lumino/signaling';
5/**
6 * The interface for an attachment model.
7 */
8export interface IAttachmentModel extends IRenderMime.IMimeModel {
9 /**
10 * A signal emitted when the attachment model changes.
11 */
12 readonly changed: ISignal<this, void>;
13 /**
14 * Dispose of the resources used by the attachment model.
15 */
16 dispose(): void;
17 /**
18 * Serialize the model to JSON.
19 */
20 toJSON(): nbformat.IMimeBundle;
21}
22/**
23 * The namespace for IAttachmentModel sub-interfaces.
24 */
25export declare namespace IAttachmentModel {
26 /**
27 * The options used to create a notebook attachment model.
28 */
29 interface IOptions {
30 /**
31 * The raw attachment value.
32 */
33 value: nbformat.IMimeBundle;
34 }
35}
36/**
37 * The default implementation of a notebook attachment model.
38 */
39export declare class AttachmentModel implements IAttachmentModel {
40 /**
41 * Construct a new attachment model.
42 */
43 constructor(options: IAttachmentModel.IOptions);
44 /**
45 * A signal emitted when the attachment model changes.
46 */
47 get changed(): ISignal<this, void>;
48 /**
49 * Dispose of the resources used by the attachment model.
50 */
51 dispose(): void;
52 /**
53 * The data associated with the model.
54 */
55 get data(): ReadonlyPartialJSONObject;
56 /**
57 * The metadata associated with the model.
58 */
59 get metadata(): ReadonlyPartialJSONObject;
60 /**
61 * Set the data associated with the model.
62 *
63 * #### Notes
64 * Depending on the implementation of the mime model,
65 * this call may or may not have deferred effects,
66 */
67 setData(options: IRenderMime.IMimeModel.ISetDataOptions): void;
68 /**
69 * Serialize the model to JSON.
70 */
71 toJSON(): nbformat.IMimeBundle;
72 readonly trusted: boolean;
73 /**
74 * Update an observable JSON object using a readonly JSON object.
75 */
76 private _updateObservable;
77 private _changed;
78 private _raw;
79 private _rawData;
80 private _data;
81}
82/**
83 * The namespace for AttachmentModel statics.
84 */
85export declare namespace AttachmentModel {
86 /**
87 * Get the data for an attachment.
88 *
89 * @params bundle - A kernel attachment MIME bundle.
90 *
91 * @returns - The data for the payload.
92 */
93 function getData(bundle: nbformat.IMimeBundle): PartialJSONObject;
94}