@bigfootai/bigfoot-types 2.6.12 → 2.7.0
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/model.js +38 -21
- package/model.ts +72 -57
- package/package.json +4 -1
- package/utils.js +13 -0
- package/utils.ts +11 -0
package/model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Table = exports.FieldVariation = exports.FieldType = exports.Template = exports.Thread = exports.ExternalTask = exports.EventStatus = exports.Conference = exports.Task = exports.Block = exports.Note = exports.Article = exports.Person = exports.Domain = exports.Tenant = exports.BusinessObject = exports.Tag = exports.Provider = exports.Primitive = exports.MutationType = exports.MarkType = exports.DocumentType = exports.RecurrenceRFC = exports.InviteStatus = exports.SharingApproach = exports.StepStatus = exports.TaskStatus = exports.SharingLevel = exports.ClientType = exports.TagType = exports.BlockType = exports.BusinessObjectType = void 0;
|
|
3
|
+
exports.Table = exports.FieldVariation = exports.FieldType = exports.Template = exports.Thread = exports.ExternalTask = exports.Event = exports.ResponseStatus = exports.EventStatus = exports.Conference = exports.Task = exports.Block = exports.Note = exports.Article = exports.Person = exports.Domain = exports.Tenant = exports.BusinessObject = exports.Tag = exports.Provider = exports.Primitive = exports.MutationType = exports.MarkType = exports.DocumentType = exports.RecurrenceRFC = exports.InviteStatus = exports.SharingApproach = exports.StepStatus = exports.TaskStatus = exports.SharingLevel = exports.ClientType = exports.TagType = exports.BlockType = exports.BusinessObjectType = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
/*
|
|
6
6
|
These are the core primitives of our model. These represent the entities that show
|
|
@@ -15,8 +15,10 @@ var BusinessObjectType;
|
|
|
15
15
|
BusinessObjectType["Document"] = "document";
|
|
16
16
|
BusinessObjectType["Record"] = "record";
|
|
17
17
|
BusinessObjectType["Conference"] = "conference";
|
|
18
|
-
BusinessObjectType["
|
|
18
|
+
BusinessObjectType["Thread"] = "thread";
|
|
19
19
|
BusinessObjectType["Website"] = "website";
|
|
20
|
+
BusinessObjectType["Template"] = "template";
|
|
21
|
+
BusinessObjectType["Table"] = "table";
|
|
20
22
|
})(BusinessObjectType || (exports.BusinessObjectType = BusinessObjectType = {}));
|
|
21
23
|
var BlockType;
|
|
22
24
|
(function (BlockType) {
|
|
@@ -137,14 +139,13 @@ class Tag extends Primitive {
|
|
|
137
139
|
}
|
|
138
140
|
exports.Tag = Tag;
|
|
139
141
|
class BusinessObject extends Primitive {
|
|
140
|
-
constructor(provider, uri, externalId, businessObjectType, externalResponse
|
|
142
|
+
constructor(provider, uri, externalId, businessObjectType, externalResponse) {
|
|
141
143
|
super();
|
|
142
144
|
this.provider = provider;
|
|
143
145
|
this.uri = uri;
|
|
144
146
|
this.externalId = externalId;
|
|
145
147
|
this.businessObjectType = businessObjectType;
|
|
146
148
|
this.externalResponse = externalResponse;
|
|
147
|
-
this.document = document;
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
exports.BusinessObject = BusinessObject;
|
|
@@ -183,10 +184,9 @@ class Article extends Primitive {
|
|
|
183
184
|
}
|
|
184
185
|
exports.Article = Article;
|
|
185
186
|
class Note extends Primitive {
|
|
186
|
-
constructor(tenantIdCreated,
|
|
187
|
+
constructor(tenantIdCreated, editors, sharingTags, version) {
|
|
187
188
|
super();
|
|
188
189
|
this.tenantIdCreated = tenantIdCreated;
|
|
189
|
-
this.document = document;
|
|
190
190
|
this.editors = editors;
|
|
191
191
|
this.sharingTags = sharingTags;
|
|
192
192
|
this.version = version;
|
|
@@ -194,26 +194,25 @@ class Note extends Primitive {
|
|
|
194
194
|
}
|
|
195
195
|
exports.Note = Note;
|
|
196
196
|
class Block extends Note {
|
|
197
|
-
constructor(tenantIdCreated,
|
|
198
|
-
super(tenantIdCreated,
|
|
197
|
+
constructor(tenantIdCreated, editors, sharingTags, version, blockType, originNoteId) {
|
|
198
|
+
super(tenantIdCreated, editors, sharingTags, version);
|
|
199
199
|
this.blockType = blockType;
|
|
200
200
|
this.originNoteId = originNoteId;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
exports.Block = Block;
|
|
204
204
|
class Task extends Block {
|
|
205
|
-
constructor(tenantIdCreated,
|
|
206
|
-
super(tenantIdCreated,
|
|
205
|
+
constructor(tenantIdCreated, editors, sharingTags, version, originNoteId, dateDue) {
|
|
206
|
+
super(tenantIdCreated, editors, sharingTags, version, BlockType.Task, originNoteId);
|
|
207
207
|
this.status = TaskStatus.NotStarted;
|
|
208
208
|
this.dateDue = dateDue;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
exports.Task = Task;
|
|
212
212
|
class Conference extends BusinessObject {
|
|
213
|
-
constructor(provider, uri, externalId,
|
|
214
|
-
super(provider, uri, externalId,
|
|
213
|
+
constructor(provider, uri, externalId, externalResponse, entryPoints) {
|
|
214
|
+
super(provider, uri, externalId, BusinessObjectType.Conference, externalResponse);
|
|
215
215
|
this.entryPoints = entryPoints;
|
|
216
|
-
this.transcription = transcription;
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
218
|
exports.Conference = Conference;
|
|
@@ -225,11 +224,29 @@ var EventStatus;
|
|
|
225
224
|
EventStatus["Tentative"] = "tentative";
|
|
226
225
|
EventStatus["Cancelled"] = "cancelled";
|
|
227
226
|
})(EventStatus || (exports.EventStatus = EventStatus = {}));
|
|
227
|
+
var ResponseStatus;
|
|
228
|
+
(function (ResponseStatus) {
|
|
229
|
+
ResponseStatus["NeedsAction"] = "needsAction";
|
|
230
|
+
ResponseStatus["Declined"] = "declined";
|
|
231
|
+
ResponseStatus["Tentative"] = "tentative";
|
|
232
|
+
ResponseStatus["Accepted"] = "accepted";
|
|
233
|
+
})(ResponseStatus || (exports.ResponseStatus = ResponseStatus = {}));
|
|
234
|
+
class Event extends BusinessObject {
|
|
235
|
+
constructor(provider, uri, externalId, externalResponse, calendarId, status, location, startDate, organizedBy) {
|
|
236
|
+
super(provider, uri, externalId, BusinessObjectType.Event, externalResponse);
|
|
237
|
+
this.calendarId = calendarId;
|
|
238
|
+
this.status = status;
|
|
239
|
+
this.location = location;
|
|
240
|
+
this.startDate = startDate;
|
|
241
|
+
this.organizedBy = organizedBy;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.Event = Event;
|
|
228
245
|
//// EVENT END
|
|
229
246
|
//// EXTERNAL TASK START
|
|
230
247
|
class ExternalTask extends BusinessObject {
|
|
231
|
-
constructor(provider, uri, externalId,
|
|
232
|
-
super(provider, uri, externalId,
|
|
248
|
+
constructor(provider, uri, externalId, externalResponse, status, dateDue) {
|
|
249
|
+
super(provider, uri, externalId, BusinessObjectType.Task, externalResponse);
|
|
233
250
|
this.status = status;
|
|
234
251
|
this.dateDue = dateDue;
|
|
235
252
|
}
|
|
@@ -238,14 +255,14 @@ exports.ExternalTask = ExternalTask;
|
|
|
238
255
|
//// EXTERNAL TASK END
|
|
239
256
|
//// MESSAGING START
|
|
240
257
|
class Thread extends BusinessObject {
|
|
241
|
-
constructor(provider, uri, externalId,
|
|
242
|
-
super(provider, uri, externalId,
|
|
258
|
+
constructor(provider, uri, externalId, externalResponse) {
|
|
259
|
+
super(provider, uri, externalId, BusinessObjectType.Thread, externalResponse);
|
|
243
260
|
}
|
|
244
261
|
}
|
|
245
262
|
exports.Thread = Thread;
|
|
246
263
|
class Template extends BusinessObject {
|
|
247
|
-
constructor(provider, uri, externalId,
|
|
248
|
-
super(provider, uri, externalId,
|
|
264
|
+
constructor(provider, uri, externalId, externalResponse, metadata) {
|
|
265
|
+
super(provider, uri, externalId, BusinessObjectType.Template, externalResponse);
|
|
249
266
|
this.metadata = metadata;
|
|
250
267
|
}
|
|
251
268
|
}
|
|
@@ -271,8 +288,8 @@ var FieldVariation;
|
|
|
271
288
|
FieldVariation["Url"] = "url";
|
|
272
289
|
})(FieldVariation || (exports.FieldVariation = FieldVariation = {}));
|
|
273
290
|
class Table extends BusinessObject {
|
|
274
|
-
constructor(provider, uri, externalId,
|
|
275
|
-
super(provider, uri, externalId,
|
|
291
|
+
constructor(provider, uri, externalId, externalResponse, recordType, metadata, values) {
|
|
292
|
+
super(provider, uri, externalId, BusinessObjectType.Table, externalResponse);
|
|
276
293
|
this.recordType = recordType;
|
|
277
294
|
this.metadata = metadata;
|
|
278
295
|
this.values = values;
|
package/model.ts
CHANGED
|
@@ -12,8 +12,10 @@ export enum BusinessObjectType {
|
|
|
12
12
|
Document = 'document',
|
|
13
13
|
Record = 'record',
|
|
14
14
|
Conference = 'conference',
|
|
15
|
-
|
|
15
|
+
Thread = 'thread',
|
|
16
16
|
Website = 'website',
|
|
17
|
+
Template = 'template',
|
|
18
|
+
Table = 'table',
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export enum BlockType {
|
|
@@ -226,6 +228,10 @@ export interface Changes {
|
|
|
226
228
|
clientIds: string[];
|
|
227
229
|
}
|
|
228
230
|
|
|
231
|
+
export interface PersonReference {
|
|
232
|
+
email: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
229
235
|
export class Primitive {
|
|
230
236
|
_id: string;
|
|
231
237
|
dateCreated: number;
|
|
@@ -287,16 +293,16 @@ export class BusinessObject extends Primitive {
|
|
|
287
293
|
iconUrl?: string; // The url of an icon that represents the business object
|
|
288
294
|
externalId: string; // An identifier that allows us to do entity resolution
|
|
289
295
|
businessObjectType: BusinessObjectType;
|
|
290
|
-
externalResponse:
|
|
291
|
-
document
|
|
296
|
+
externalResponse: any; // The full response from the external system that created this object
|
|
297
|
+
document?: Document; // The business object formatted as a document for ML to ingest
|
|
298
|
+
parentId?: string; // The business object that is the parent of this business object
|
|
292
299
|
|
|
293
300
|
constructor(
|
|
294
301
|
provider: string,
|
|
295
302
|
uri: string,
|
|
296
303
|
externalId: string,
|
|
297
304
|
businessObjectType: BusinessObjectType,
|
|
298
|
-
externalResponse:
|
|
299
|
-
document: Document
|
|
305
|
+
externalResponse: any
|
|
300
306
|
) {
|
|
301
307
|
super();
|
|
302
308
|
|
|
@@ -305,7 +311,6 @@ export class BusinessObject extends Primitive {
|
|
|
305
311
|
this.externalId = externalId;
|
|
306
312
|
this.businessObjectType = businessObjectType;
|
|
307
313
|
this.externalResponse = externalResponse;
|
|
308
|
-
this.document = document;
|
|
309
314
|
}
|
|
310
315
|
}
|
|
311
316
|
|
|
@@ -384,10 +389,10 @@ export class Article extends Primitive {
|
|
|
384
389
|
|
|
385
390
|
export class Note extends Primitive {
|
|
386
391
|
tenantIdCreated: string;
|
|
387
|
-
document: string;
|
|
388
392
|
editors: Editor[];
|
|
389
393
|
sharingTags: SharingTag[];
|
|
390
394
|
version: number;
|
|
395
|
+
document?: any;
|
|
391
396
|
changes?: Changes;
|
|
392
397
|
_sharedTags?: string[];
|
|
393
398
|
reactions?: Reaction[];
|
|
@@ -395,7 +400,6 @@ export class Note extends Primitive {
|
|
|
395
400
|
|
|
396
401
|
constructor(
|
|
397
402
|
tenantIdCreated: string,
|
|
398
|
-
document: string,
|
|
399
403
|
editors: Editor[],
|
|
400
404
|
sharingTags: SharingTag[],
|
|
401
405
|
version: number
|
|
@@ -403,7 +407,6 @@ export class Note extends Primitive {
|
|
|
403
407
|
super();
|
|
404
408
|
|
|
405
409
|
this.tenantIdCreated = tenantIdCreated;
|
|
406
|
-
this.document = document;
|
|
407
410
|
this.editors = editors;
|
|
408
411
|
this.sharingTags = sharingTags;
|
|
409
412
|
this.version = version;
|
|
@@ -416,14 +419,13 @@ export class Block extends Note {
|
|
|
416
419
|
|
|
417
420
|
constructor(
|
|
418
421
|
tenantIdCreated: string,
|
|
419
|
-
document: string,
|
|
420
422
|
editors: Editor[],
|
|
421
423
|
sharingTags: SharingTag[],
|
|
422
424
|
version: number,
|
|
423
425
|
blockType: BlockType,
|
|
424
426
|
originNoteId: string
|
|
425
427
|
) {
|
|
426
|
-
super(tenantIdCreated,
|
|
428
|
+
super(tenantIdCreated, editors, sharingTags, version);
|
|
427
429
|
|
|
428
430
|
this.blockType = blockType;
|
|
429
431
|
this.originNoteId = originNoteId;
|
|
@@ -439,7 +441,6 @@ export class Task extends Block {
|
|
|
439
441
|
|
|
440
442
|
constructor(
|
|
441
443
|
tenantIdCreated: string,
|
|
442
|
-
document: string,
|
|
443
444
|
editors: Editor[],
|
|
444
445
|
sharingTags: SharingTag[],
|
|
445
446
|
version: number,
|
|
@@ -448,7 +449,6 @@ export class Task extends Block {
|
|
|
448
449
|
) {
|
|
449
450
|
super(
|
|
450
451
|
tenantIdCreated,
|
|
451
|
-
document,
|
|
452
452
|
editors,
|
|
453
453
|
sharingTags,
|
|
454
454
|
version,
|
|
@@ -495,29 +495,24 @@ export interface ConferenceEntrypoint {
|
|
|
495
495
|
|
|
496
496
|
export class Conference extends BusinessObject {
|
|
497
497
|
entryPoints: ConferenceEntrypoint[];
|
|
498
|
-
transcription
|
|
498
|
+
transcription?: Transcription;
|
|
499
499
|
|
|
500
500
|
constructor(
|
|
501
501
|
provider: string,
|
|
502
502
|
uri: string,
|
|
503
503
|
externalId: string,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
document: Document,
|
|
507
|
-
entryPoints: ConferenceEntrypoint[],
|
|
508
|
-
transcription: Transcription
|
|
504
|
+
externalResponse: any,
|
|
505
|
+
entryPoints: ConferenceEntrypoint[]
|
|
509
506
|
) {
|
|
510
507
|
super(
|
|
511
508
|
provider,
|
|
512
509
|
uri,
|
|
513
510
|
externalId,
|
|
514
|
-
|
|
515
|
-
externalResponse
|
|
516
|
-
document
|
|
511
|
+
BusinessObjectType.Conference,
|
|
512
|
+
externalResponse
|
|
517
513
|
);
|
|
518
514
|
|
|
519
515
|
this.entryPoints = entryPoints;
|
|
520
|
-
this.transcription = transcription;
|
|
521
516
|
}
|
|
522
517
|
}
|
|
523
518
|
//// CONFERENCE END
|
|
@@ -529,9 +524,15 @@ export enum EventStatus {
|
|
|
529
524
|
Cancelled = 'cancelled',
|
|
530
525
|
}
|
|
531
526
|
|
|
532
|
-
export
|
|
533
|
-
|
|
534
|
-
|
|
527
|
+
export enum ResponseStatus {
|
|
528
|
+
NeedsAction = 'needsAction',
|
|
529
|
+
Declined = 'declined',
|
|
530
|
+
Tentative = 'tentative',
|
|
531
|
+
Accepted = 'accepted',
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export interface PersonAcceptance extends PersonReference {
|
|
535
|
+
responseStatus: ResponseStatus;
|
|
535
536
|
}
|
|
536
537
|
|
|
537
538
|
export interface Calendar extends BusinessObject {
|
|
@@ -540,20 +541,46 @@ export interface Calendar extends BusinessObject {
|
|
|
540
541
|
timeZone: string;
|
|
541
542
|
}
|
|
542
543
|
|
|
543
|
-
export
|
|
544
|
+
export class Event extends BusinessObject {
|
|
544
545
|
calendarId: string;
|
|
545
546
|
status: EventStatus;
|
|
546
|
-
subject?: string;
|
|
547
|
-
description?: string;
|
|
548
|
-
location: string;
|
|
549
547
|
startDate: number;
|
|
548
|
+
organizedBy: PersonReference;
|
|
549
|
+
location?: string;
|
|
550
|
+
originalStartDate?: number;
|
|
551
|
+
recurrence?: RecurrenceRFC[];
|
|
550
552
|
endDate?: number;
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
organizedBy: Person;
|
|
553
|
+
subject?: string;
|
|
554
|
+
description?: string;
|
|
554
555
|
attendees?: PersonAcceptance[];
|
|
555
556
|
conference?: Conference;
|
|
556
557
|
businessObjectIds?: string[]; // Attachments
|
|
558
|
+
|
|
559
|
+
constructor(
|
|
560
|
+
provider: string,
|
|
561
|
+
uri: string,
|
|
562
|
+
externalId: string,
|
|
563
|
+
externalResponse: any,
|
|
564
|
+
calendarId: string,
|
|
565
|
+
status: EventStatus,
|
|
566
|
+
location: string,
|
|
567
|
+
startDate: number,
|
|
568
|
+
organizedBy: Person
|
|
569
|
+
) {
|
|
570
|
+
super(
|
|
571
|
+
provider,
|
|
572
|
+
uri,
|
|
573
|
+
externalId,
|
|
574
|
+
BusinessObjectType.Event,
|
|
575
|
+
externalResponse
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
this.calendarId = calendarId;
|
|
579
|
+
this.status = status;
|
|
580
|
+
this.location = location;
|
|
581
|
+
this.startDate = startDate;
|
|
582
|
+
this.organizedBy = organizedBy;
|
|
583
|
+
}
|
|
557
584
|
}
|
|
558
585
|
//// EVENT END
|
|
559
586
|
|
|
@@ -569,9 +596,7 @@ export class ExternalTask extends BusinessObject {
|
|
|
569
596
|
provider: string,
|
|
570
597
|
uri: string,
|
|
571
598
|
externalId: string,
|
|
572
|
-
|
|
573
|
-
externalResponse: string,
|
|
574
|
-
document: Document,
|
|
599
|
+
externalResponse: any,
|
|
575
600
|
status: TaskStatus,
|
|
576
601
|
dateDue: number
|
|
577
602
|
) {
|
|
@@ -579,9 +604,8 @@ export class ExternalTask extends BusinessObject {
|
|
|
579
604
|
provider,
|
|
580
605
|
uri,
|
|
581
606
|
externalId,
|
|
582
|
-
|
|
583
|
-
externalResponse
|
|
584
|
-
document
|
|
607
|
+
BusinessObjectType.Task,
|
|
608
|
+
externalResponse
|
|
585
609
|
);
|
|
586
610
|
|
|
587
611
|
this.status = status;
|
|
@@ -596,17 +620,14 @@ export class Thread extends BusinessObject {
|
|
|
596
620
|
provider: string,
|
|
597
621
|
uri: string,
|
|
598
622
|
externalId: string,
|
|
599
|
-
|
|
600
|
-
externalResponse: string,
|
|
601
|
-
document: Document
|
|
623
|
+
externalResponse: any
|
|
602
624
|
) {
|
|
603
625
|
super(
|
|
604
626
|
provider,
|
|
605
627
|
uri,
|
|
606
628
|
externalId,
|
|
607
|
-
|
|
608
|
-
externalResponse
|
|
609
|
-
document
|
|
629
|
+
BusinessObjectType.Thread,
|
|
630
|
+
externalResponse
|
|
610
631
|
);
|
|
611
632
|
}
|
|
612
633
|
}
|
|
@@ -639,18 +660,15 @@ export class Template extends BusinessObject {
|
|
|
639
660
|
provider: string,
|
|
640
661
|
uri: string,
|
|
641
662
|
externalId: string,
|
|
642
|
-
|
|
643
|
-
externalResponse: string,
|
|
644
|
-
document: Document,
|
|
663
|
+
externalResponse: any,
|
|
645
664
|
metadata: DocumentMetadata
|
|
646
665
|
) {
|
|
647
666
|
super(
|
|
648
667
|
provider,
|
|
649
668
|
uri,
|
|
650
669
|
externalId,
|
|
651
|
-
|
|
652
|
-
externalResponse
|
|
653
|
-
document
|
|
670
|
+
BusinessObjectType.Template,
|
|
671
|
+
externalResponse
|
|
654
672
|
);
|
|
655
673
|
|
|
656
674
|
this.metadata = metadata;
|
|
@@ -719,9 +737,7 @@ export class Table extends BusinessObject {
|
|
|
719
737
|
provider: string,
|
|
720
738
|
uri: string,
|
|
721
739
|
externalId: string,
|
|
722
|
-
|
|
723
|
-
externalResponse: string,
|
|
724
|
-
document: Document,
|
|
740
|
+
externalResponse: any,
|
|
725
741
|
recordType: string,
|
|
726
742
|
metadata: TableMetadata,
|
|
727
743
|
values: FieldValue[]
|
|
@@ -730,9 +746,8 @@ export class Table extends BusinessObject {
|
|
|
730
746
|
provider,
|
|
731
747
|
uri,
|
|
732
748
|
externalId,
|
|
733
|
-
|
|
734
|
-
externalResponse
|
|
735
|
-
document
|
|
749
|
+
BusinessObjectType.Table,
|
|
750
|
+
externalResponse
|
|
736
751
|
);
|
|
737
752
|
|
|
738
753
|
this.recordType = recordType;
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Bigfoot",
|
|
3
3
|
"name": "@bigfootai/bigfoot-types",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.0",
|
|
5
5
|
"description": "The internal library for the types used in the Bigfoot platform",
|
|
6
6
|
"main": "model.js",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"repository": "Notify-AI/bigfoot-types",
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"parse5": "^7.1.2",
|
|
11
|
+
"prosemirror-model": "^1.19.4",
|
|
12
|
+
"prosemirror-schema-basic": "^1.2.2",
|
|
10
13
|
"uuid": "^9.0.1"
|
|
11
14
|
},
|
|
12
15
|
"devDependencies": {
|
package/utils.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseHtmlToDocument = void 0;
|
|
4
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
|
+
const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
|
|
6
|
+
const parse5_1 = require("parse5");
|
|
7
|
+
const parseHtmlToDocument = (html) => {
|
|
8
|
+
// Parse the html into a DOM
|
|
9
|
+
const document = (0, parse5_1.parse)(html);
|
|
10
|
+
// Only take the body of the document
|
|
11
|
+
return prosemirror_model_1.DOMParser.fromSchema(prosemirror_schema_basic_1.schema).parse(document.nodeName['body']);
|
|
12
|
+
};
|
|
13
|
+
exports.parseHtmlToDocument = parseHtmlToDocument;
|
package/utils.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DOMParser } from 'prosemirror-model';
|
|
2
|
+
import { schema } from 'prosemirror-schema-basic';
|
|
3
|
+
import { parse } from 'parse5';
|
|
4
|
+
|
|
5
|
+
export const parseHtmlToDocument = (html: string): Record<string, any> => {
|
|
6
|
+
// Parse the html into a DOM
|
|
7
|
+
const document = parse(html);
|
|
8
|
+
|
|
9
|
+
// Only take the body of the document
|
|
10
|
+
return DOMParser.fromSchema(schema).parse(document.nodeName['body']);
|
|
11
|
+
};
|