@takeshape/util 11.45.5 → 11.46.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/dist/cjs/common/arrays.js +42 -0
- package/dist/cjs/common/assert.js +9 -0
- package/dist/cjs/common/async-noop.js +5 -0
- package/dist/cjs/common/billing.js +35 -0
- package/dist/cjs/common/clone.js +76 -0
- package/dist/cjs/common/delay.js +28 -0
- package/dist/cjs/common/draftjs-templates.js +131 -0
- package/dist/cjs/common/draftjs.js +807 -0
- package/dist/cjs/common/get-image-url.js +8 -0
- package/dist/cjs/common/highlight-code.js +33 -0
- package/dist/cjs/common/http.js +19 -0
- package/dist/cjs/common/index.js +50 -0
- package/dist/cjs/common/map.js +7 -0
- package/dist/cjs/common/memoize.js +13 -0
- package/dist/cjs/common/merge.js +64 -0
- package/dist/cjs/common/mime.js +68 -0
- package/dist/cjs/common/names.js +13 -0
- package/dist/cjs/common/naming.js +65 -0
- package/dist/cjs/common/path-to-string.js +10 -0
- package/dist/cjs/common/persisted-queries.js +4 -0
- package/dist/cjs/common/predicate.js +15 -0
- package/dist/cjs/common/set-in.js +13 -0
- package/dist/cjs/common/sets.js +19 -0
- package/dist/cjs/common/sleep.js +9 -0
- package/dist/cjs/common/sort-object.js +16 -0
- package/dist/cjs/common/strings.js +74 -0
- package/dist/cjs/common/templates.js +109 -0
- package/dist/cjs/common/timezone.js +606 -0
- package/dist/cjs/common/tracing.js +2 -0
- package/dist/cjs/common/types.js +63 -0
- package/dist/cjs/common/unix-to-iso.js +15 -0
- package/dist/cjs/common/urls.js +9 -0
- package/dist/cjs/common/validation.js +5 -0
- package/dist/cjs/common/value.js +8 -0
- package/dist/cjs/common/visit.js +60 -0
- package/dist/cjs/node/encryption.js +31 -0
- package/dist/cjs/node/gzip.js +10 -0
- package/dist/cjs/node/index.js +19 -0
- package/dist/cjs/node/search-params.js +23 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/common/arrays.js +33 -0
- package/dist/esm/common/assert.js +5 -0
- package/dist/esm/common/async-noop.js +2 -0
- package/dist/esm/common/billing.js +29 -0
- package/dist/esm/common/clone.js +71 -0
- package/dist/esm/common/delay.js +22 -0
- package/dist/esm/common/draftjs-templates.js +122 -0
- package/dist/esm/common/draftjs.js +792 -0
- package/{es → dist/esm/common}/get-image-url.js +2 -7
- package/dist/esm/common/highlight-code.js +26 -0
- package/dist/esm/common/http.js +15 -0
- package/dist/esm/common/index.js +34 -0
- package/{es → dist/esm/common}/map.js +2 -2
- package/dist/esm/common/memoize.js +6 -0
- package/dist/esm/common/merge.js +54 -0
- package/dist/esm/common/mime.js +60 -0
- package/dist/esm/common/names.js +9 -0
- package/dist/esm/common/naming.js +54 -0
- package/dist/esm/common/path-to-string.js +6 -0
- package/{es → dist/esm/common}/persisted-queries.js +1 -1
- package/{es → dist/esm/common}/predicate.js +4 -4
- package/dist/esm/common/set-in.js +7 -0
- package/dist/esm/common/sets.js +14 -0
- package/dist/esm/common/sleep.js +5 -0
- package/dist/esm/common/sort-object.js +12 -0
- package/dist/esm/common/strings.js +60 -0
- package/dist/esm/common/templates.js +95 -0
- package/dist/esm/common/timezone.js +602 -0
- package/dist/esm/common/tracing.js +1 -0
- package/dist/esm/common/types.js +50 -0
- package/dist/esm/common/unix-to-iso.js +9 -0
- package/dist/esm/common/urls.js +5 -0
- package/dist/esm/common/validation.js +2 -0
- package/dist/esm/common/value.js +4 -0
- package/dist/esm/common/visit.js +52 -0
- package/dist/esm/node/encryption.js +25 -0
- package/dist/esm/node/gzip.js +4 -0
- package/dist/esm/node/index.js +3 -0
- package/dist/esm/node/search-params.js +17 -0
- package/dist/esm/package.json +1 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -0
- package/dist/{arrays.d.ts → types/common/arrays.d.ts} +0 -1
- package/dist/{assert.d.ts → types/common/assert.d.ts} +0 -1
- package/dist/{async-noop.d.ts → types/common/async-noop.d.ts} +0 -1
- package/dist/types/common/billing.d.ts +365 -0
- package/dist/{clone.d.ts → types/common/clone.d.ts} +0 -1
- package/dist/{delay.d.ts → types/common/delay.d.ts} +0 -1
- package/dist/{draftjs-templates.d.ts → types/common/draftjs-templates.d.ts} +1 -2
- package/dist/{draftjs.d.ts → types/common/draftjs.d.ts} +1 -2
- package/dist/{get-image-url.d.ts → types/common/get-image-url.d.ts} +0 -1
- package/dist/types/common/highlight-code.d.ts +14 -0
- package/dist/{http.d.ts → types/common/http.d.ts} +0 -1
- package/dist/types/common/index.d.ts +34 -0
- package/dist/{map.d.ts → types/common/map.d.ts} +0 -1
- package/dist/{memoize.d.ts → types/common/memoize.d.ts} +0 -1
- package/dist/{merge.d.ts → types/common/merge.d.ts} +0 -1
- package/dist/{mime.d.ts → types/common/mime.d.ts} +0 -1
- package/dist/{names.d.ts → types/common/names.d.ts} +0 -1
- package/dist/{naming.d.ts → types/common/naming.d.ts} +0 -1
- package/dist/{path-to-string.d.ts → types/common/path-to-string.d.ts} +0 -1
- package/dist/{persisted-queries.d.ts → types/common/persisted-queries.d.ts} +0 -1
- package/dist/{predicate.d.ts → types/common/predicate.d.ts} +0 -1
- package/dist/{set-in.d.ts → types/common/set-in.d.ts} +0 -1
- package/dist/{sets.d.ts → types/common/sets.d.ts} +0 -1
- package/dist/{sleep.d.ts → types/common/sleep.d.ts} +0 -1
- package/dist/{sort-object.d.ts → types/common/sort-object.d.ts} +0 -1
- package/dist/{strings.d.ts → types/common/strings.d.ts} +1 -2
- package/dist/{templates.d.ts → types/common/templates.d.ts} +1 -2
- package/dist/{timezone.d.ts → types/common/timezone.d.ts} +0 -1
- package/dist/{tracing.d.ts → types/common/tracing.d.ts} +1 -2
- package/dist/{types.d.ts → types/common/types.d.ts} +0 -1
- package/dist/{unix-to-iso.d.ts → types/common/unix-to-iso.d.ts} +0 -1
- package/dist/{urls.d.ts → types/common/urls.d.ts} +0 -1
- package/dist/{validation.d.ts → types/common/validation.d.ts} +0 -1
- package/dist/{value.d.ts → types/common/value.d.ts} +0 -1
- package/dist/{visit.d.ts → types/common/visit.d.ts} +0 -1
- package/dist/{encryption.d.ts → types/node/encryption.d.ts} +0 -1
- package/dist/{gzip.d.ts → types/node/gzip.d.ts} +1 -2
- package/dist/types/node/index.d.ts +3 -0
- package/dist/{search-params.d.ts → types/node/search-params.d.ts} +1 -2
- package/package.json +33 -21
- package/dist/arrays.d.ts.map +0 -1
- package/dist/arrays.js +0 -44
- package/dist/assert.d.ts.map +0 -1
- package/dist/assert.js +0 -11
- package/dist/async-noop.d.ts.map +0 -1
- package/dist/async-noop.js +0 -8
- package/dist/billing.d.ts +0 -366
- package/dist/billing.d.ts.map +0 -1
- package/dist/billing.js +0 -48
- package/dist/browser.d.ts +0 -2
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.js +0 -16
- package/dist/clone.d.ts.map +0 -1
- package/dist/clone.js +0 -101
- package/dist/common.d.ts +0 -32
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -346
- package/dist/delay.d.ts.map +0 -1
- package/dist/delay.js +0 -34
- package/dist/draftjs-templates.d.ts.map +0 -1
- package/dist/draftjs-templates.js +0 -157
- package/dist/draftjs.d.ts.map +0 -1
- package/dist/draftjs.js +0 -836
- package/dist/encryption.d.ts.map +0 -1
- package/dist/encryption.js +0 -33
- package/dist/get-image-url.d.ts.map +0 -1
- package/dist/get-image-url.js +0 -15
- package/dist/gzip.d.ts.map +0 -1
- package/dist/gzip.js +0 -11
- package/dist/highlight-code.d.ts +0 -15
- package/dist/highlight-code.d.ts.map +0 -1
- package/dist/highlight-code.js +0 -35
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -18
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/map.d.ts.map +0 -1
- package/dist/map.js +0 -9
- package/dist/memoize.d.ts.map +0 -1
- package/dist/memoize.js +0 -13
- package/dist/merge.d.ts.map +0 -1
- package/dist/merge.js +0 -67
- package/dist/mime.d.ts.map +0 -1
- package/dist/mime.js +0 -37
- package/dist/names.d.ts.map +0 -1
- package/dist/names.js +0 -15
- package/dist/naming.d.ts.map +0 -1
- package/dist/naming.js +0 -91
- package/dist/path-to-string.d.ts.map +0 -1
- package/dist/path-to-string.js +0 -13
- package/dist/persisted-queries.d.ts.map +0 -1
- package/dist/persisted-queries.js +0 -7
- package/dist/predicate.d.ts.map +0 -1
- package/dist/predicate.js +0 -17
- package/dist/search-params.d.ts.map +0 -1
- package/dist/search-params.js +0 -25
- package/dist/set-in.d.ts.map +0 -1
- package/dist/set-in.js +0 -11
- package/dist/sets.d.ts.map +0 -1
- package/dist/sets.js +0 -21
- package/dist/sleep.d.ts.map +0 -1
- package/dist/sleep.js +0 -11
- package/dist/sort-object.d.ts.map +0 -1
- package/dist/sort-object.js +0 -21
- package/dist/strings.d.ts.map +0 -1
- package/dist/strings.js +0 -87
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -120
- package/dist/timezone.d.ts.map +0 -1
- package/dist/timezone.js +0 -17
- package/dist/tracing.d.ts.map +0 -1
- package/dist/tracing.js +0 -5
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -92
- package/dist/unix-to-iso.d.ts.map +0 -1
- package/dist/unix-to-iso.js +0 -17
- package/dist/urls.d.ts.map +0 -1
- package/dist/urls.js +0 -11
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -8
- package/dist/value.d.ts.map +0 -1
- package/dist/value.js +0 -11
- package/dist/visit.d.ts.map +0 -1
- package/dist/visit.js +0 -61
- package/es/arrays.js +0 -33
- package/es/assert.js +0 -5
- package/es/async-noop.js +0 -2
- package/es/billing.js +0 -40
- package/es/browser.js +0 -1
- package/es/clone.js +0 -94
- package/es/common.js +0 -31
- package/es/delay.js +0 -26
- package/es/draftjs-templates.js +0 -147
- package/es/draftjs.js +0 -819
- package/es/encryption.js +0 -26
- package/es/gzip.js +0 -4
- package/es/highlight-code.js +0 -26
- package/es/http.js +0 -11
- package/es/index.js +0 -6
- package/es/memoize.js +0 -6
- package/es/merge.js +0 -58
- package/es/mime.js +0 -29
- package/es/names.js +0 -9
- package/es/naming.js +0 -78
- package/es/path-to-string.js +0 -6
- package/es/search-params.js +0 -17
- package/es/set-in.js +0 -6
- package/es/sets.js +0 -14
- package/es/sleep.js +0 -5
- package/es/sort-object.js +0 -14
- package/es/strings.js +0 -72
- package/es/templates.js +0 -105
- package/es/timezone.js +0 -10
- package/es/tracing.js +0 -1
- package/es/types.js +0 -80
- package/es/unix-to-iso.js +0 -9
- package/es/urls.js +0 -5
- package/es/validation.js +0 -2
- package/es/value.js +0 -4
- package/es/visit.js +0 -53
package/es/clone.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { isIterableObject } from './types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Clone any JSON serializable value similar to JSON.parse(JSON.stringify()) but better performance
|
|
5
|
-
*/
|
|
6
|
-
export function deepClone(value) {
|
|
7
|
-
if (!value) {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
if (Array.isArray(value)) {
|
|
11
|
-
const {
|
|
12
|
-
length
|
|
13
|
-
} = value;
|
|
14
|
-
const result = new Array(length);
|
|
15
|
-
for (let i = 0; i < length; i++) {
|
|
16
|
-
result[i] = deepClone(value[i]);
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
if (isIterableObject(value)) {
|
|
21
|
-
const obj = value;
|
|
22
|
-
const result = {};
|
|
23
|
-
for (const key of Object.keys(obj)) {
|
|
24
|
-
const value = obj[key];
|
|
25
|
-
if (value !== undefined) {
|
|
26
|
-
result[key] = deepClone(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param value the value to clone
|
|
36
|
-
* @param key the key/index this value is stored under if parent is an object or array
|
|
37
|
-
* @param parent the parent object or array if applicable
|
|
38
|
-
* @return a new value to use instead of the value argument. Return REMOVE to remove value from the parent. Return undefined to continue to clone recursively.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The callback for deepCloneWith which is called for every value in a object
|
|
43
|
-
* @param value the value to clone
|
|
44
|
-
* @param key the key/index this value is stored under if parent is an object or array
|
|
45
|
-
* @param parent the parent object or array if applicable
|
|
46
|
-
* @param clone a function used to continue to recusively clone
|
|
47
|
-
* @return a new value to use instead of the value argument. Return REMOVE to remove value from the parent. Return undefined to continue to clone recursively.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
export const REMOVE = Symbol('REMOVE');
|
|
51
|
-
function arrayFilter(value) {
|
|
52
|
-
return value !== REMOVE;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Clone any JSON serializable value and transform using a callback
|
|
57
|
-
* @param value the value to clone
|
|
58
|
-
* @param customizer a callback that is called for every key/index
|
|
59
|
-
*/
|
|
60
|
-
export function deepCloneWith(value, customizer) {
|
|
61
|
-
const clone = (value, key, parent) => {
|
|
62
|
-
const newValue = customizer(value, key, parent, clone);
|
|
63
|
-
if (newValue !== undefined) {
|
|
64
|
-
return newValue;
|
|
65
|
-
}
|
|
66
|
-
if (Array.isArray(value)) {
|
|
67
|
-
const {
|
|
68
|
-
length
|
|
69
|
-
} = value;
|
|
70
|
-
const arr = new Array(length);
|
|
71
|
-
let edited = false;
|
|
72
|
-
for (let i = 0; i < length; i++) {
|
|
73
|
-
const newValue = clone(value[i], i, value);
|
|
74
|
-
if (newValue === REMOVE) {
|
|
75
|
-
edited = true;
|
|
76
|
-
}
|
|
77
|
-
arr[i] = newValue;
|
|
78
|
-
}
|
|
79
|
-
return edited ? arr.filter(arrayFilter) : arr;
|
|
80
|
-
}
|
|
81
|
-
if (isIterableObject(value)) {
|
|
82
|
-
const newObject = {};
|
|
83
|
-
for (const key of Object.keys(value)) {
|
|
84
|
-
const newValue = clone(value[key], key, value);
|
|
85
|
-
if (newValue !== undefined && newValue !== REMOVE) {
|
|
86
|
-
newObject[key] = newValue;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return newObject;
|
|
90
|
-
}
|
|
91
|
-
return value;
|
|
92
|
-
};
|
|
93
|
-
return clone(value, undefined, undefined);
|
|
94
|
-
}
|
package/es/common.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './mime';
|
|
3
|
-
export * from './http';
|
|
4
|
-
export * from './delay';
|
|
5
|
-
export * from './strings';
|
|
6
|
-
export * from './unix-to-iso';
|
|
7
|
-
export * from './arrays';
|
|
8
|
-
export * from './value';
|
|
9
|
-
export * from './clone';
|
|
10
|
-
export * from './predicate';
|
|
11
|
-
export * from './tracing';
|
|
12
|
-
export * from './merge';
|
|
13
|
-
export * from './map';
|
|
14
|
-
export * from './visit';
|
|
15
|
-
export * from './draftjs';
|
|
16
|
-
export * from './templates';
|
|
17
|
-
export * from './highlight-code';
|
|
18
|
-
export * from './billing';
|
|
19
|
-
export * from './timezone';
|
|
20
|
-
export * from './async-noop';
|
|
21
|
-
export * from './set-in';
|
|
22
|
-
export * from './sets';
|
|
23
|
-
export * from './sleep';
|
|
24
|
-
export * from './validation';
|
|
25
|
-
export * from './sort-object';
|
|
26
|
-
export * from './path-to-string';
|
|
27
|
-
export * from './persisted-queries';
|
|
28
|
-
export * from './assert';
|
|
29
|
-
export * from './urls';
|
|
30
|
-
export * from './memoize';
|
|
31
|
-
export * from './names';
|
package/es/delay.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export async function delay(timeout, value) {
|
|
2
|
-
return new Promise(resolve => {
|
|
3
|
-
setTimeout(resolve, timeout, value);
|
|
4
|
-
});
|
|
5
|
-
}
|
|
6
|
-
function randomInt(minimum, maximum) {
|
|
7
|
-
const co = Math.random() * (maximum - minimum + 1);
|
|
8
|
-
return Math.floor(co + minimum);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Decorrelated jitter backoff:
|
|
12
|
-
// https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
13
|
-
export async function backoff(baseDelay, maxDelay, attempt = {
|
|
14
|
-
num: 1,
|
|
15
|
-
lastDelay: 0
|
|
16
|
-
}) {
|
|
17
|
-
const msec = Math.min(maxDelay, randomInt(baseDelay, (attempt.lastDelay || baseDelay) * 3));
|
|
18
|
-
await delay(msec);
|
|
19
|
-
return {
|
|
20
|
-
num: attempt.num + 1,
|
|
21
|
-
lastDelay: msec
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export async function randomDelay(minimum, maximum, value) {
|
|
25
|
-
return delay(randomInt(minimum, maximum), value);
|
|
26
|
-
}
|
package/es/draftjs-templates.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The intention is to move all this to the client package in the end, but right now it's here
|
|
3
|
-
* to be shared between the draftjs / mdx implementations, which span the client / server differently.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import shortid from 'shortid';
|
|
7
|
-
export const getDraftjsImage = params => {
|
|
8
|
-
const {
|
|
9
|
-
captionText,
|
|
10
|
-
creditText,
|
|
11
|
-
alignment,
|
|
12
|
-
size,
|
|
13
|
-
assetId,
|
|
14
|
-
linkUrl,
|
|
15
|
-
linkIsExternal,
|
|
16
|
-
depth,
|
|
17
|
-
key,
|
|
18
|
-
path
|
|
19
|
-
} = params;
|
|
20
|
-
const blockKey = shortid.generate();
|
|
21
|
-
return {
|
|
22
|
-
contentBlock: {
|
|
23
|
-
key: shortid.generate(),
|
|
24
|
-
text: ' ',
|
|
25
|
-
type: 'atomic',
|
|
26
|
-
depth,
|
|
27
|
-
inlineStyleRanges: [],
|
|
28
|
-
entityRanges: [{
|
|
29
|
-
offset: 0,
|
|
30
|
-
length: 1,
|
|
31
|
-
key
|
|
32
|
-
}],
|
|
33
|
-
data: {}
|
|
34
|
-
},
|
|
35
|
-
entities: {
|
|
36
|
-
[key]: {
|
|
37
|
-
type: 'image',
|
|
38
|
-
mutability: 'IMMUTABLE',
|
|
39
|
-
data: {
|
|
40
|
-
id: assetId,
|
|
41
|
-
path,
|
|
42
|
-
caption: {
|
|
43
|
-
blocks: [{
|
|
44
|
-
key: blockKey,
|
|
45
|
-
text: captionText,
|
|
46
|
-
type: 'unstyled',
|
|
47
|
-
depth,
|
|
48
|
-
inlineStyleRanges: [],
|
|
49
|
-
entityRanges: [],
|
|
50
|
-
data: {}
|
|
51
|
-
}],
|
|
52
|
-
entityMap: {}
|
|
53
|
-
},
|
|
54
|
-
credit: {
|
|
55
|
-
blocks: [{
|
|
56
|
-
key: blockKey,
|
|
57
|
-
text: creditText,
|
|
58
|
-
type: 'unstyled',
|
|
59
|
-
depth,
|
|
60
|
-
inlineStyleRanges: [],
|
|
61
|
-
entityRanges: [],
|
|
62
|
-
data: {}
|
|
63
|
-
}],
|
|
64
|
-
entityMap: {}
|
|
65
|
-
},
|
|
66
|
-
link: {
|
|
67
|
-
url: linkUrl,
|
|
68
|
-
external: linkIsExternal
|
|
69
|
-
},
|
|
70
|
-
alignment,
|
|
71
|
-
size,
|
|
72
|
-
contentTypeId: 'ASSET'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
export const getDraftjsPullquote = params => {
|
|
79
|
-
const {
|
|
80
|
-
text,
|
|
81
|
-
depth
|
|
82
|
-
} = params;
|
|
83
|
-
return {
|
|
84
|
-
contentBlock: {
|
|
85
|
-
key: shortid.generate(),
|
|
86
|
-
text,
|
|
87
|
-
type: 'pullquote',
|
|
88
|
-
depth,
|
|
89
|
-
inlineStyleRanges: [],
|
|
90
|
-
entityRanges: [],
|
|
91
|
-
data: {}
|
|
92
|
-
},
|
|
93
|
-
entities: {}
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
export const getDraftjsOembed = params => {
|
|
97
|
-
const {
|
|
98
|
-
key,
|
|
99
|
-
depth,
|
|
100
|
-
html,
|
|
101
|
-
width = 550,
|
|
102
|
-
height = undefined,
|
|
103
|
-
url = undefined,
|
|
104
|
-
author_name = undefined,
|
|
105
|
-
author_url = undefined,
|
|
106
|
-
type = undefined,
|
|
107
|
-
cache_age = undefined,
|
|
108
|
-
provider_name = undefined,
|
|
109
|
-
provider_url = undefined,
|
|
110
|
-
version = undefined
|
|
111
|
-
} = params;
|
|
112
|
-
return {
|
|
113
|
-
contentBlock: {
|
|
114
|
-
key: shortid.generate(),
|
|
115
|
-
text: ' ',
|
|
116
|
-
type: 'atomic',
|
|
117
|
-
depth,
|
|
118
|
-
inlineStyleRanges: [],
|
|
119
|
-
entityRanges: [{
|
|
120
|
-
offset: 0,
|
|
121
|
-
length: 1,
|
|
122
|
-
key
|
|
123
|
-
}],
|
|
124
|
-
data: {}
|
|
125
|
-
},
|
|
126
|
-
// Only html is required
|
|
127
|
-
entities: {
|
|
128
|
-
[key]: {
|
|
129
|
-
type: 'oembed',
|
|
130
|
-
mutability: 'IMMUTABLE',
|
|
131
|
-
data: {
|
|
132
|
-
url,
|
|
133
|
-
author_name,
|
|
134
|
-
author_url,
|
|
135
|
-
html,
|
|
136
|
-
width,
|
|
137
|
-
height,
|
|
138
|
-
type,
|
|
139
|
-
cache_age,
|
|
140
|
-
provider_name,
|
|
141
|
-
provider_url,
|
|
142
|
-
version
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
};
|