@20minutes/draft-convert 3.1.2 → 3.1.3

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.
@@ -8,16 +8,16 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
- const _updateMutation = /*#__PURE__*/ _interop_require_default(require("./util/updateMutation.js"));
12
- const _rangeSort = /*#__PURE__*/ _interop_require_default(require("./util/rangeSort.js"));
13
11
  const _getElementHTML = /*#__PURE__*/ _interop_require_default(require("./util/getElementHTML.js"));
14
12
  const _getElementTagLength = /*#__PURE__*/ _interop_require_default(require("./util/getElementTagLength.js"));
13
+ const _rangeSort = /*#__PURE__*/ _interop_require_default(require("./util/rangeSort.js"));
14
+ const _updateMutation = /*#__PURE__*/ _interop_require_default(require("./util/updateMutation.js"));
15
15
  function _interop_require_default(obj) {
16
16
  return obj && obj.__esModule ? obj : {
17
17
  default: obj
18
18
  };
19
19
  }
20
- const converter = (entity = {}, originalText = '')=>originalText;
20
+ const converter = (_entity = {}, originalText = '')=>originalText;
21
21
  const _default = (block, entityMap, entityConverter = converter)=>{
22
22
  let resultText = [
23
23
  ...block.text
@@ -26,7 +26,7 @@ const _default = (block, entityMap, entityConverter = converter)=>{
26
26
  if (entityConverter.__isMiddleware) {
27
27
  getEntityHTML = entityConverter(converter);
28
28
  }
29
- if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
29
+ if (Object.hasOwn(block, 'entityRanges') && block.entityRanges.length > 0) {
30
30
  let entities = block.entityRanges.sort(_rangeSort.default);
31
31
  let styles = block.inlineStyleRanges;
32
32
  for(let index = 0; index < entities.length; index += 1){
@@ -36,7 +36,7 @@ const _default = (block, entityMap, entityConverter = converter)=>{
36
36
  const entityHTML = getEntityHTML(entity, originalText);
37
37
  const elementHTML = (0, _getElementHTML.default)(entityHTML, originalText);
38
38
  let converted;
39
- if (!!elementHTML || elementHTML === '') {
39
+ if (elementHTML || elementHTML === '') {
40
40
  converted = [
41
41
  ...elementHTML
42
42
  ];
@@ -46,7 +46,7 @@ const _default = (block, entityMap, entityConverter = converter)=>{
46
46
  const prefixLength = (0, _getElementTagLength.default)(entityHTML, 'start');
47
47
  const suffixLength = (0, _getElementTagLength.default)(entityHTML, 'end');
48
48
  const updateLaterMutation = (mutation, mutationIndex)=>{
49
- if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
49
+ if (mutationIndex > index || Object.hasOwn(mutation, 'style')) {
50
50
  return (0, _updateMutation.default)(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
51
51
  }
52
52
  return mutation;
@@ -1,8 +1,8 @@
1
- import updateMutation from './util/updateMutation.mjs';
2
- import rangeSort from './util/rangeSort.mjs';
3
1
  import getElementHTML from './util/getElementHTML.mjs';
4
2
  import getElementTagLength from './util/getElementTagLength.mjs';
5
- const converter = (entity = {}, originalText = '')=>originalText;
3
+ import rangeSort from './util/rangeSort.mjs';
4
+ import updateMutation from './util/updateMutation.mjs';
5
+ const converter = (_entity = {}, originalText = '')=>originalText;
6
6
  export default ((block, entityMap, entityConverter = converter)=>{
7
7
  let resultText = [
8
8
  ...block.text
@@ -11,7 +11,7 @@ export default ((block, entityMap, entityConverter = converter)=>{
11
11
  if (entityConverter.__isMiddleware) {
12
12
  getEntityHTML = entityConverter(converter);
13
13
  }
14
- if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
14
+ if (Object.hasOwn(block, 'entityRanges') && block.entityRanges.length > 0) {
15
15
  let entities = block.entityRanges.sort(rangeSort);
16
16
  let styles = block.inlineStyleRanges;
17
17
  for(let index = 0; index < entities.length; index += 1){
@@ -21,7 +21,7 @@ export default ((block, entityMap, entityConverter = converter)=>{
21
21
  const entityHTML = getEntityHTML(entity, originalText);
22
22
  const elementHTML = getElementHTML(entityHTML, originalText);
23
23
  let converted;
24
- if (!!elementHTML || elementHTML === '') {
24
+ if (elementHTML || elementHTML === '') {
25
25
  converted = [
26
26
  ...elementHTML
27
27
  ];
@@ -31,7 +31,7 @@ export default ((block, entityMap, entityConverter = converter)=>{
31
31
  const prefixLength = getElementTagLength(entityHTML, 'start');
32
32
  const suffixLength = getElementTagLength(entityHTML, 'end');
33
33
  const updateLaterMutation = (mutation, mutationIndex)=>{
34
- if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
34
+ if (mutationIndex > index || Object.hasOwn(mutation, 'style')) {
35
35
  return updateMutation(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
36
36
  }
37
37
  return mutation;
@@ -8,12 +8,12 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
- const _invariant = /*#__PURE__*/ _interop_require_default(require("invariant"));
12
- const _styleObjectFunction = /*#__PURE__*/ _interop_require_default(require("./util/styleObjectFunction.js"));
11
+ const _tinyinvariant = /*#__PURE__*/ _interop_require_default(require("tiny-invariant"));
12
+ const _defaultInlineHTML = /*#__PURE__*/ _interop_require_default(require("./default/defaultInlineHTML.js"));
13
13
  const _accumulateFunction = /*#__PURE__*/ _interop_require_default(require("./util/accumulateFunction.js"));
14
14
  const _getElementHTML = /*#__PURE__*/ _interop_require_default(require("./util/getElementHTML.js"));
15
15
  const _rangeSort = /*#__PURE__*/ _interop_require_default(require("./util/rangeSort.js"));
16
- const _defaultInlineHTML = /*#__PURE__*/ _interop_require_default(require("./default/defaultInlineHTML.js"));
16
+ const _styleObjectFunction = /*#__PURE__*/ _interop_require_default(require("./util/styleObjectFunction.js"));
17
17
  function _interop_require_default(obj) {
18
18
  return obj && obj.__esModule ? obj : {
19
19
  default: obj
@@ -22,7 +22,7 @@ function _interop_require_default(obj) {
22
22
  const subtractStyles = (original, toRemove)=>original.filter((el)=>!toRemove.some((elToRemove)=>elToRemove.style === el.style));
23
23
  const popEndingStyles = (styleStack, endingStyles)=>endingStyles.reduceRight((stack, style)=>{
24
24
  const styleToRemove = stack[stack.length - 1];
25
- (0, _invariant.default)(styleToRemove.style === style.style, `Style ${styleToRemove.style} to be removed doesn't match expected ${style.style}`);
25
+ (0, _tinyinvariant.default)(styleToRemove.style === style.style, `Style ${styleToRemove.style} to be removed doesn't match expected ${style.style}`);
26
26
  return stack.slice(0, -1);
27
27
  }, styleStack);
28
28
  const characterStyles = (offset, ranges)=>ranges.filter((range)=>offset >= range.offset && offset < range.offset + range.length);
@@ -54,7 +54,7 @@ const prependEndMarkup = (inlineHTML, string, styleRange)=>(0, _getElementHTML.d
54
54
  const defaultCustomInlineHTML = (next)=>(style)=>next(style);
55
55
  defaultCustomInlineHTML.__isMiddleware = true;
56
56
  const _default = (rawBlock, customInlineHTML = defaultCustomInlineHTML)=>{
57
- (0, _invariant.default)(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
57
+ (0, _tinyinvariant.default)(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
58
58
  let inlineHTML;
59
59
  if (customInlineHTML.__isMiddleware === true) {
60
60
  inlineHTML = customInlineHTML(_defaultInlineHTML.default);
@@ -83,7 +83,7 @@ const _default = (rawBlock, customInlineHTML = defaultCustomInlineHTML)=>{
83
83
  result += endingStyleTags + openingStyleTags + originalTextArray[i];
84
84
  styleStack = popEndingStyles(styleStack, resetStyles.concat(endingStyles));
85
85
  styleStack = styleStack.concat(openingStyles);
86
- (0, _invariant.default)(styleStack.length === styles.length, `Character ${i}: ${styleStack.length - styles.length} styles left on stack that should no longer be there`);
86
+ (0, _tinyinvariant.default)(styleStack.length === styles.length, `Character ${i}: ${styleStack.length - styles.length} styles left on stack that should no longer be there`);
87
87
  }
88
88
  result = styleStack.reduceRight((res, openStyle)=>res + (0, _getElementHTML.default)(inlineHTML(openStyle.style)).end, result);
89
89
  return result;
@@ -1,9 +1,9 @@
1
- import invariant from 'invariant';
2
- import styleObjectFunction from './util/styleObjectFunction.mjs';
1
+ import invariant from 'tiny-invariant';
2
+ import defaultInlineHTML from './default/defaultInlineHTML.mjs';
3
3
  import accumulateFunction from './util/accumulateFunction.mjs';
4
4
  import getElementHTML from './util/getElementHTML.mjs';
5
5
  import rangeSort from './util/rangeSort.mjs';
6
- import defaultInlineHTML from './default/defaultInlineHTML.mjs';
6
+ import styleObjectFunction from './util/styleObjectFunction.mjs';
7
7
  const subtractStyles = (original, toRemove)=>original.filter((el)=>!toRemove.some((elToRemove)=>elToRemove.style === el.style));
8
8
  const popEndingStyles = (styleStack, endingStyles)=>endingStyles.reduceRight((stack, style)=>{
9
9
  const styleToRemove = stack[stack.length - 1];
@@ -8,9 +8,7 @@
8
8
  * This source code is licensed under the BSD-style license found in the
9
9
  * LICENSE file in the /src directory of this source tree. An additional grant
10
10
  * of patent rights can be found in the PATENTS file in the same directory.
11
- */ // immutable is CJS-only; default import maps to module.exports for Node ESM interop.
12
- // eslint-disable-next-line import/default
13
- "use strict";
11
+ */ "use strict";
14
12
  Object.defineProperty(exports, "__esModule", {
15
13
  value: true
16
14
  });
@@ -20,8 +18,8 @@ Object.defineProperty(exports, "default", {
20
18
  return _default;
21
19
  }
22
20
  });
23
- const _immutable = /*#__PURE__*/ _interop_require_default(require("immutable"));
24
21
  const _draftjs = /*#__PURE__*/ _interop_require_default(require("draft-js"));
22
+ const _immutable = /*#__PURE__*/ _interop_require_default(require("immutable"));
25
23
  const _parseHTML = /*#__PURE__*/ _interop_require_default(require("./util/parseHTML.js"));
26
24
  const _rangeSort = /*#__PURE__*/ _interop_require_default(require("./util/rangeSort.js"));
27
25
  function _interop_require_default(obj) {
@@ -29,8 +27,6 @@ function _interop_require_default(obj) {
29
27
  default: obj
30
28
  };
31
29
  }
32
- // eslint-disable-next-line import/no-named-as-default-member
33
- const { List, Map, OrderedSet } = _immutable.default;
34
30
  const { BlockMapBuilder, CharacterMetadata, ContentBlock, ContentState, Entity, SelectionState, genKey } = _draftjs.default;
35
31
  const SPACE = ' ';
36
32
  // Arbitrary max indent
@@ -71,10 +67,10 @@ const handleMiddleware = (maybeMiddleware, base)=>{
71
67
  }
72
68
  return maybeMiddleware;
73
69
  };
74
- const defaultHTMLToBlock = (nodeName, node, lastList)=>undefined;
75
- const defaultHTMLToStyle = (nodeName, node, currentStyle)=>currentStyle;
76
- const defaultHTMLToEntity = (nodeName, node)=>undefined;
77
- const defaultTextToEntity = (text)=>[];
70
+ const defaultHTMLToBlock = (_nodeName, _node, _lastList)=>undefined;
71
+ const defaultHTMLToStyle = (_nodeName, _node, currentStyle)=>currentStyle;
72
+ const defaultHTMLToEntity = (_nodeName, _node)=>undefined;
73
+ const defaultTextToEntity = (_text)=>[];
78
74
  const nullthrows = (x)=>{
79
75
  if (x != null) {
80
76
  return x;
@@ -98,18 +94,18 @@ function getWhitespaceChunk(inEntity) {
98
94
  return {
99
95
  text: SPACE,
100
96
  inlines: [
101
- OrderedSet()
97
+ _immutable.default.OrderedSet()
102
98
  ],
103
99
  entities,
104
100
  blocks: []
105
101
  };
106
102
  }
107
- function getSoftNewlineChunk(block, depth, flat = false, data = Map()) {
103
+ function getSoftNewlineChunk(block, depth, flat = false, data = _immutable.default.Map()) {
108
104
  if (flat === true) {
109
105
  return {
110
106
  text: '\r',
111
107
  inlines: [
112
- OrderedSet()
108
+ _immutable.default.OrderedSet()
113
109
  ],
114
110
  entities: new Array(1),
115
111
  blocks: [
@@ -125,17 +121,17 @@ function getSoftNewlineChunk(block, depth, flat = false, data = Map()) {
125
121
  return {
126
122
  text: '\n',
127
123
  inlines: [
128
- OrderedSet()
124
+ _immutable.default.OrderedSet()
129
125
  ],
130
126
  entities: new Array(1),
131
127
  blocks: []
132
128
  };
133
129
  }
134
- function getBlockDividerChunk(block, depth, data = Map()) {
130
+ function getBlockDividerChunk(block, depth, data = _immutable.default.Map()) {
135
131
  return {
136
132
  text: '\r',
137
133
  inlines: [
138
- OrderedSet()
134
+ _immutable.default.OrderedSet()
139
135
  ],
140
136
  entities: new Array(1),
141
137
  blocks: [
@@ -177,7 +173,7 @@ function getBlockTypeForTag(tag, lastList) {
177
173
  return null;
178
174
  }
179
175
  }
180
- function baseCheckBlockType(nodeName, node, lastList) {
176
+ function baseCheckBlockType(nodeName, _node, lastList) {
181
177
  return getBlockTypeForTag(nodeName, lastList);
182
178
  }
183
179
  function processInlineTag(tag, node, currentStyle) {
@@ -203,7 +199,7 @@ function processInlineTag(tag, node, currentStyle) {
203
199
  }
204
200
  return currentStyle;
205
201
  }
206
- function baseProcessInlineTag(tag, node, inlineStyles = OrderedSet()) {
202
+ function baseProcessInlineTag(tag, node, inlineStyles = _immutable.default.OrderedSet()) {
207
203
  return processInlineTag(tag, node, inlineStyles);
208
204
  }
209
205
  function joinChunks(A, B, flat = false) {
@@ -319,10 +315,10 @@ function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, de
319
315
  blockInfo = blockInfo || {};
320
316
  if (typeof blockInfo === 'string') {
321
317
  blockType = blockInfo;
322
- blockDataMap = Map();
318
+ blockDataMap = _immutable.default.Map();
323
319
  } else {
324
320
  blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
325
- blockDataMap = blockInfo.data ? Map(blockInfo.data) : Map();
321
+ blockDataMap = blockInfo.data ? _immutable.default.Map(blockInfo.data) : _immutable.default.Map();
326
322
  }
327
323
  if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
328
324
  chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
@@ -366,10 +362,10 @@ function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, de
366
362
  newBlockInfo = newBlockInfo || {};
367
363
  if (typeof newBlockInfo === 'string') {
368
364
  newBlockType = newBlockInfo;
369
- newBlockData = Map();
365
+ newBlockData = _immutable.default.Map();
370
366
  } else {
371
367
  newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
372
- newBlockData = newBlockInfo.data ? Map(newBlockInfo.data) : Map();
368
+ newBlockData = newBlockInfo.data ? _immutable.default.Map(newBlockInfo.data) : _immutable.default.Map();
373
369
  }
374
370
  chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
375
371
  }
@@ -380,7 +376,7 @@ function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, de
380
376
  child = sibling;
381
377
  }
382
378
  if (newBlock) {
383
- chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, Map()), options.flat);
379
+ chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, _immutable.default.Map()), options.flat);
384
380
  }
385
381
  return chunk;
386
382
  }
@@ -400,7 +396,7 @@ function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, check
400
396
  ];
401
397
  // Start with -1 block depth to offset the fact that we are passing in a fake
402
398
  // UL block to sta rt with.
403
- let chunk = genFragment(safeBody, OrderedSet(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options);
399
+ let chunk = genFragment(safeBody, _immutable.default.OrderedSet(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options);
404
400
  // join with previous block to prevent weirdness on paste
405
401
  if (chunk.text.indexOf('\r') === 0) {
406
402
  chunk = {
@@ -421,7 +417,7 @@ function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, check
421
417
  if (chunk.blocks.length === 0) {
422
418
  chunk.blocks.push({
423
419
  type: 'unstyled',
424
- data: Map(),
420
+ data: _immutable.default.Map(),
425
421
  depth: 0
426
422
  });
427
423
  }
@@ -431,7 +427,7 @@ function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, check
431
427
  if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
432
428
  chunk.blocks.unshift({
433
429
  type: 'unstyled',
434
- data: Map(),
430
+ data: _immutable.default.Map(),
435
431
  depth: 0
436
432
  });
437
433
  }
@@ -452,7 +448,7 @@ function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEn
452
448
  const end = start + textBlock.length;
453
449
  const inlines = nullthrows(chunk).inlines.slice(start, end);
454
450
  const entities = nullthrows(chunk).entities.slice(start, end);
455
- const characterList = List(inlines.map((style, entityIndex)=>{
451
+ const characterList = _immutable.default.List(inlines.map((style, entityIndex)=>{
456
452
  const data = {
457
453
  style,
458
454
  entity: null
@@ -8,14 +8,10 @@
8
8
  * This source code is licensed under the BSD-style license found in the
9
9
  * LICENSE file in the /src directory of this source tree. An additional grant
10
10
  * of patent rights can be found in the PATENTS file in the same directory.
11
- */ // immutable is CJS-only; default import maps to module.exports for Node ESM interop.
12
- // eslint-disable-next-line import/default
11
+ */ import DraftJS from 'draft-js';
13
12
  import Immutable from 'immutable';
14
- import DraftJS from 'draft-js';
15
13
  import getSafeBodyFromHTML from './util/parseHTML.mjs';
16
14
  import rangeSort from './util/rangeSort.mjs';
17
- // eslint-disable-next-line import/no-named-as-default-member
18
- const { List, Map, OrderedSet } = Immutable;
19
15
  const { BlockMapBuilder, CharacterMetadata, ContentBlock, ContentState, Entity, SelectionState, genKey } = DraftJS;
20
16
  const SPACE = ' ';
21
17
  // Arbitrary max indent
@@ -56,10 +52,10 @@ const handleMiddleware = (maybeMiddleware, base)=>{
56
52
  }
57
53
  return maybeMiddleware;
58
54
  };
59
- const defaultHTMLToBlock = (nodeName, node, lastList)=>undefined;
60
- const defaultHTMLToStyle = (nodeName, node, currentStyle)=>currentStyle;
61
- const defaultHTMLToEntity = (nodeName, node)=>undefined;
62
- const defaultTextToEntity = (text)=>[];
55
+ const defaultHTMLToBlock = (_nodeName, _node, _lastList)=>undefined;
56
+ const defaultHTMLToStyle = (_nodeName, _node, currentStyle)=>currentStyle;
57
+ const defaultHTMLToEntity = (_nodeName, _node)=>undefined;
58
+ const defaultTextToEntity = (_text)=>[];
63
59
  const nullthrows = (x)=>{
64
60
  if (x != null) {
65
61
  return x;
@@ -83,18 +79,18 @@ function getWhitespaceChunk(inEntity) {
83
79
  return {
84
80
  text: SPACE,
85
81
  inlines: [
86
- OrderedSet()
82
+ Immutable.OrderedSet()
87
83
  ],
88
84
  entities,
89
85
  blocks: []
90
86
  };
91
87
  }
92
- function getSoftNewlineChunk(block, depth, flat = false, data = Map()) {
88
+ function getSoftNewlineChunk(block, depth, flat = false, data = Immutable.Map()) {
93
89
  if (flat === true) {
94
90
  return {
95
91
  text: '\r',
96
92
  inlines: [
97
- OrderedSet()
93
+ Immutable.OrderedSet()
98
94
  ],
99
95
  entities: new Array(1),
100
96
  blocks: [
@@ -110,17 +106,17 @@ function getSoftNewlineChunk(block, depth, flat = false, data = Map()) {
110
106
  return {
111
107
  text: '\n',
112
108
  inlines: [
113
- OrderedSet()
109
+ Immutable.OrderedSet()
114
110
  ],
115
111
  entities: new Array(1),
116
112
  blocks: []
117
113
  };
118
114
  }
119
- function getBlockDividerChunk(block, depth, data = Map()) {
115
+ function getBlockDividerChunk(block, depth, data = Immutable.Map()) {
120
116
  return {
121
117
  text: '\r',
122
118
  inlines: [
123
- OrderedSet()
119
+ Immutable.OrderedSet()
124
120
  ],
125
121
  entities: new Array(1),
126
122
  blocks: [
@@ -162,7 +158,7 @@ function getBlockTypeForTag(tag, lastList) {
162
158
  return null;
163
159
  }
164
160
  }
165
- function baseCheckBlockType(nodeName, node, lastList) {
161
+ function baseCheckBlockType(nodeName, _node, lastList) {
166
162
  return getBlockTypeForTag(nodeName, lastList);
167
163
  }
168
164
  function processInlineTag(tag, node, currentStyle) {
@@ -188,7 +184,7 @@ function processInlineTag(tag, node, currentStyle) {
188
184
  }
189
185
  return currentStyle;
190
186
  }
191
- function baseProcessInlineTag(tag, node, inlineStyles = OrderedSet()) {
187
+ function baseProcessInlineTag(tag, node, inlineStyles = Immutable.OrderedSet()) {
192
188
  return processInlineTag(tag, node, inlineStyles);
193
189
  }
194
190
  function joinChunks(A, B, flat = false) {
@@ -304,10 +300,10 @@ function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, de
304
300
  blockInfo = blockInfo || {};
305
301
  if (typeof blockInfo === 'string') {
306
302
  blockType = blockInfo;
307
- blockDataMap = Map();
303
+ blockDataMap = Immutable.Map();
308
304
  } else {
309
305
  blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
310
- blockDataMap = blockInfo.data ? Map(blockInfo.data) : Map();
306
+ blockDataMap = blockInfo.data ? Immutable.Map(blockInfo.data) : Immutable.Map();
311
307
  }
312
308
  if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
313
309
  chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
@@ -351,10 +347,10 @@ function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, de
351
347
  newBlockInfo = newBlockInfo || {};
352
348
  if (typeof newBlockInfo === 'string') {
353
349
  newBlockType = newBlockInfo;
354
- newBlockData = Map();
350
+ newBlockData = Immutable.Map();
355
351
  } else {
356
352
  newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
357
- newBlockData = newBlockInfo.data ? Map(newBlockInfo.data) : Map();
353
+ newBlockData = newBlockInfo.data ? Immutable.Map(newBlockInfo.data) : Immutable.Map();
358
354
  }
359
355
  chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
360
356
  }
@@ -365,7 +361,7 @@ function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, de
365
361
  child = sibling;
366
362
  }
367
363
  if (newBlock) {
368
- chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, Map()), options.flat);
364
+ chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, Immutable.Map()), options.flat);
369
365
  }
370
366
  return chunk;
371
367
  }
@@ -385,7 +381,7 @@ function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, check
385
381
  ];
386
382
  // Start with -1 block depth to offset the fact that we are passing in a fake
387
383
  // UL block to sta rt with.
388
- let chunk = genFragment(safeBody, OrderedSet(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options);
384
+ let chunk = genFragment(safeBody, Immutable.OrderedSet(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options);
389
385
  // join with previous block to prevent weirdness on paste
390
386
  if (chunk.text.indexOf('\r') === 0) {
391
387
  chunk = {
@@ -406,7 +402,7 @@ function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, check
406
402
  if (chunk.blocks.length === 0) {
407
403
  chunk.blocks.push({
408
404
  type: 'unstyled',
409
- data: Map(),
405
+ data: Immutable.Map(),
410
406
  depth: 0
411
407
  });
412
408
  }
@@ -416,7 +412,7 @@ function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, check
416
412
  if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
417
413
  chunk.blocks.unshift({
418
414
  type: 'unstyled',
419
- data: Map(),
415
+ data: Immutable.Map(),
420
416
  depth: 0
421
417
  });
422
418
  }
@@ -437,7 +433,7 @@ function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEn
437
433
  const end = start + textBlock.length;
438
434
  const inlines = nullthrows(chunk).inlines.slice(start, end);
439
435
  const entities = nullthrows(chunk).entities.slice(start, end);
440
- const characterList = List(inlines.map((style, entityIndex)=>{
436
+ const characterList = Immutable.List(inlines.map((style, entityIndex)=>{
441
437
  const data = {
442
438
  style,
443
439
  entity: null
@@ -8,28 +8,28 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
- const _invariant = /*#__PURE__*/ _interop_require_default(require("invariant"));
11
+ const _draftjs = /*#__PURE__*/ _interop_require_default(require("draft-js"));
12
12
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
13
  const _server = /*#__PURE__*/ _interop_require_default(require("react-dom/server"));
14
- const _draftjs = /*#__PURE__*/ _interop_require_default(require("draft-js"));
15
- const _encodeBlock = /*#__PURE__*/ _interop_require_default(require("./encodeBlock.js"));
14
+ const _tinyinvariant = /*#__PURE__*/ _interop_require_default(require("tiny-invariant"));
16
15
  const _blockEntities = /*#__PURE__*/ _interop_require_default(require("./blockEntities.js"));
17
16
  const _blockInlineStyles = /*#__PURE__*/ _interop_require_default(require("./blockInlineStyles.js"));
17
+ const _defaultBlockHTML = /*#__PURE__*/ _interop_require_default(require("./default/defaultBlockHTML.js"));
18
+ const _encodeBlock = /*#__PURE__*/ _interop_require_default(require("./encodeBlock.js"));
18
19
  const _accumulateFunction = /*#__PURE__*/ _interop_require_default(require("./util/accumulateFunction.js"));
19
20
  const _blockTypeObjectFunction = /*#__PURE__*/ _interop_require_default(require("./util/blockTypeObjectFunction.js"));
20
21
  const _getBlockTags = /*#__PURE__*/ _interop_require_default(require("./util/getBlockTags.js"));
21
22
  const _getNestedBlockTags = /*#__PURE__*/ _interop_require_default(require("./util/getNestedBlockTags.js"));
22
- const _defaultBlockHTML = /*#__PURE__*/ _interop_require_default(require("./default/defaultBlockHTML.js"));
23
23
  function _interop_require_default(obj) {
24
24
  return obj && obj.__esModule ? obj : {
25
25
  default: obj
26
26
  };
27
27
  }
28
28
  const { convertToRaw } = _draftjs.default;
29
- const defaultEntityToHTML = (entity, originalText)=>originalText;
30
- const defaultValidateHTML = (html)=>true;
29
+ const defaultEntityToHTML = (_entity, originalText)=>originalText;
30
+ const defaultValidateHTML = (_html)=>true;
31
31
  const convertToHTML = ({ styleToHTML = {}, blockToHTML = {}, entityToHTML = defaultEntityToHTML, validateHTML = defaultValidateHTML })=>(contentState)=>{
32
- (0, _invariant.default)(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
32
+ (0, _tinyinvariant.default)(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
33
33
  let getBlockHTML;
34
34
  if (blockToHTML.__isMiddleware === true) {
35
35
  getBlockHTML = blockToHTML((0, _blockTypeObjectFunction.default)(_defaultBlockHTML.default));
@@ -76,7 +76,7 @@ const convertToHTML = ({ styleToHTML = {}, blockToHTML = {}, entityToHTML = defa
76
76
  } else {
77
77
  html = blockHTML.start + innerHTML + blockHTML.end;
78
78
  }
79
- if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
79
+ if (innerHTML.length === 0 && Object.hasOwn(blockHTML, 'empty')) {
80
80
  if (/*#__PURE__*/ _react.default.isValidElement(blockHTML.empty)) {
81
81
  html = _server.default.renderToStaticMarkup(blockHTML.empty);
82
82
  } else {
@@ -93,7 +93,7 @@ const convertToHTML = ({ styleToHTML = {}, blockToHTML = {}, entityToHTML = defa
93
93
  return result;
94
94
  };
95
95
  const _default = (...args)=>{
96
- if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
96
+ if (args.length === 1 && Object.hasOwn(args[0], '_map') && args[0].getBlockMap != null) {
97
97
  // skip higher-order function and use defaults
98
98
  return convertToHTML({})(...args);
99
99
  }
@@ -1,18 +1,18 @@
1
- import invariant from 'invariant';
1
+ import DraftJS from 'draft-js';
2
2
  import React from 'react';
3
3
  import ReactDOMServer from 'react-dom/server';
4
- import DraftJS from 'draft-js';
5
- import encodeBlock from './encodeBlock.mjs';
4
+ import invariant from 'tiny-invariant';
6
5
  import blockEntities from './blockEntities.mjs';
7
6
  import blockInlineStyles from './blockInlineStyles.mjs';
7
+ import defaultBlockHTML from './default/defaultBlockHTML.mjs';
8
+ import encodeBlock from './encodeBlock.mjs';
8
9
  import accumulateFunction from './util/accumulateFunction.mjs';
9
10
  import blockTypeObjectFunction from './util/blockTypeObjectFunction.mjs';
10
11
  import getBlockTags from './util/getBlockTags.mjs';
11
12
  import getNestedBlockTags from './util/getNestedBlockTags.mjs';
12
- import defaultBlockHTML from './default/defaultBlockHTML.mjs';
13
13
  const { convertToRaw } = DraftJS;
14
- const defaultEntityToHTML = (entity, originalText)=>originalText;
15
- const defaultValidateHTML = (html)=>true;
14
+ const defaultEntityToHTML = (_entity, originalText)=>originalText;
15
+ const defaultValidateHTML = (_html)=>true;
16
16
  const convertToHTML = ({ styleToHTML = {}, blockToHTML = {}, entityToHTML = defaultEntityToHTML, validateHTML = defaultValidateHTML })=>(contentState)=>{
17
17
  invariant(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
18
18
  let getBlockHTML;
@@ -61,7 +61,7 @@ const convertToHTML = ({ styleToHTML = {}, blockToHTML = {}, entityToHTML = defa
61
61
  } else {
62
62
  html = blockHTML.start + innerHTML + blockHTML.end;
63
63
  }
64
- if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
64
+ if (innerHTML.length === 0 && Object.hasOwn(blockHTML, 'empty')) {
65
65
  if (/*#__PURE__*/ React.isValidElement(blockHTML.empty)) {
66
66
  html = ReactDOMServer.renderToStaticMarkup(blockHTML.empty);
67
67
  } else {
@@ -78,7 +78,7 @@ const convertToHTML = ({ styleToHTML = {}, blockToHTML = {}, entityToHTML = defa
78
78
  return result;
79
79
  };
80
80
  export default ((...args)=>{
81
- if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
81
+ if (args.length === 1 && Object.hasOwn(args[0], '_map') && args[0].getBlockMap != null) {
82
82
  // skip higher-order function and use defaults
83
83
  return convertToHTML({})(...args);
84
84
  }
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
- const _updateMutation = /*#__PURE__*/ _interop_require_default(require("./util/updateMutation.js"));
12
11
  const _rangeSort = /*#__PURE__*/ _interop_require_default(require("./util/rangeSort.js"));
12
+ const _updateMutation = /*#__PURE__*/ _interop_require_default(require("./util/updateMutation.js"));
13
13
  function _interop_require_default(obj) {
14
14
  return obj && obj.__esModule ? obj : {
15
15
  default: obj
@@ -1,5 +1,5 @@
1
- import updateMutation from './util/updateMutation.mjs';
2
1
  import rangeSort from './util/rangeSort.mjs';
2
+ import updateMutation from './util/updateMutation.mjs';
3
3
  const ENTITY_MAP = {
4
4
  '&': '&amp;',
5
5
  '<': '&lt;',
package/dist/index.cjs CHANGED
@@ -19,8 +19,8 @@ _export(exports, {
19
19
  return _parseHTML.default;
20
20
  }
21
21
  });
22
- const _convertToHTML = /*#__PURE__*/ _interop_require_default(require("./convertToHTML.js"));
23
22
  const _convertFromHTML = /*#__PURE__*/ _interop_require_default(require("./convertFromHTML.js"));
23
+ const _convertToHTML = /*#__PURE__*/ _interop_require_default(require("./convertToHTML.js"));
24
24
  const _parseHTML = /*#__PURE__*/ _interop_require_default(require("./util/parseHTML.js"));
25
25
  function _interop_require_default(obj) {
26
26
  return obj && obj.__esModule ? obj : {
package/dist/index.d.ts CHANGED
@@ -12,10 +12,7 @@ import {
12
12
  } from 'draft-js'
13
13
  import { ReactNode } from 'react'
14
14
 
15
- export type RawDraftContentBlockWithCustomType<T> = Omit<
16
- RawDraftContentBlock,
17
- 'type'
18
- > & {
15
+ export type RawDraftContentBlockWithCustomType<T> = Omit<RawDraftContentBlock, 'type'> & {
19
16
  type: T
20
17
  }
21
18
 
@@ -40,11 +37,12 @@ export interface IConvertToHTMLConfig<
40
37
  E extends RawDraftEntity = RawDraftEntity,
41
38
  > {
42
39
  // Inline styles:
43
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
44
- styleToHTML?: ((style: S) => Tag | null | undefined | void) | undefined
40
+ styleToHTML?: ((style: S) => Tag | null | undefined | undefined) | undefined
45
41
 
46
42
  // Block styles:
47
- blockToHTML?: ((block: RawDraftContentBlockWithCustomType<B>) => Tag | null | undefined) | undefined
43
+ blockToHTML?:
44
+ | ((block: RawDraftContentBlockWithCustomType<B>) => Tag | null | undefined)
45
+ | undefined
48
46
 
49
47
  // Entity styling:
50
48
  entityToHTML?: ((entity: E, originalText: string) => Tag | null | undefined) | undefined
@@ -78,7 +76,11 @@ export interface IConvertFromHTMLConfig<
78
76
  | ((
79
77
  nodeName: string,
80
78
  node: ExtendedHTMLElement<S>,
81
- createEntity: (type: E['type'], mutability: DraftEntityMutability, data: E['data']) => EntityKey,
79
+ createEntity: (
80
+ type: E['type'],
81
+ mutability: DraftEntityMutability,
82
+ data: E['data']
83
+ ) => EntityKey,
82
84
  getEntity: (key: EntityKey) => Entity,
83
85
  mergeEntityData: (key: string, data: object) => void,
84
86
  replaceEntityData: (key: string, data: object) => void
@@ -89,7 +91,11 @@ export interface IConvertFromHTMLConfig<
89
91
  textToEntity?:
90
92
  | ((
91
93
  text: string,
92
- createEntity: (type: E['type'], mutability: DraftEntityMutability, data: E['data']) => EntityKey,
94
+ createEntity: (
95
+ type: E['type'],
96
+ mutability: DraftEntityMutability,
97
+ data: E['data']
98
+ ) => EntityKey,
93
99
  getEntity: (key: EntityKey) => Entity,
94
100
  mergeEntityData: (key: string, data: object) => void,
95
101
  replaceEntityData: (key: string, data: object) => void
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import convertToHTML from './convertToHTML.mjs';
2
1
  import convertFromHTML from './convertFromHTML.mjs';
2
+ import convertToHTML from './convertToHTML.mjs';
3
3
  import parseHTML from './util/parseHTML.mjs';
4
- export { convertToHTML, convertFromHTML, parseHTML };
4
+ export { convertFromHTML, convertToHTML, parseHTML };
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "default", {
8
8
  return getBlockTags;
9
9
  }
10
10
  });
11
- const _invariant = /*#__PURE__*/ _interop_require_default(require("invariant"));
12
11
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
12
  const _server = /*#__PURE__*/ _interop_require_default(require("react-dom/server"));
13
+ const _tinyinvariant = /*#__PURE__*/ _interop_require_default(require("tiny-invariant"));
14
14
  const _splitReactElement = /*#__PURE__*/ _interop_require_default(require("./splitReactElement.js"));
15
15
  function _interop_require_default(obj) {
16
16
  return obj && obj.__esModule ? obj : {
@@ -21,7 +21,7 @@ function hasChildren(element) {
21
21
  return /*#__PURE__*/ _react.default.isValidElement(element) && _react.default.Children.count(element.props.children) > 0;
22
22
  }
23
23
  function getBlockTags(blockHTML) {
24
- (0, _invariant.default)(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
24
+ (0, _tinyinvariant.default)(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
25
25
  if (typeof blockHTML === 'string') {
26
26
  return blockHTML;
27
27
  }
@@ -31,12 +31,12 @@ function getBlockTags(blockHTML) {
31
31
  }
32
32
  return (0, _splitReactElement.default)(blockHTML);
33
33
  }
34
- if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && /*#__PURE__*/ _react.default.isValidElement(blockHTML.element)) {
34
+ if (Object.hasOwn(blockHTML, 'element') && /*#__PURE__*/ _react.default.isValidElement(blockHTML.element)) {
35
35
  return {
36
36
  ...blockHTML,
37
37
  ...(0, _splitReactElement.default)(blockHTML.element)
38
38
  };
39
39
  }
40
- (0, _invariant.default)(Object.prototype.hasOwnProperty.call(blockHTML, 'start') && Object.prototype.hasOwnProperty.call(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
40
+ (0, _tinyinvariant.default)(Object.hasOwn(blockHTML, 'start') && Object.hasOwn(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
41
41
  return blockHTML;
42
42
  }
@@ -1,6 +1,6 @@
1
- import invariant from 'invariant';
2
1
  import React from 'react';
3
2
  import ReactDOMServer from 'react-dom/server';
3
+ import invariant from 'tiny-invariant';
4
4
  import splitReactElement from './splitReactElement.mjs';
5
5
  function hasChildren(element) {
6
6
  return /*#__PURE__*/ React.isValidElement(element) && React.Children.count(element.props.children) > 0;
@@ -16,12 +16,12 @@ export default function getBlockTags(blockHTML) {
16
16
  }
17
17
  return splitReactElement(blockHTML);
18
18
  }
19
- if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && /*#__PURE__*/ React.isValidElement(blockHTML.element)) {
19
+ if (Object.hasOwn(blockHTML, 'element') && /*#__PURE__*/ React.isValidElement(blockHTML.element)) {
20
20
  return {
21
21
  ...blockHTML,
22
22
  ...splitReactElement(blockHTML.element)
23
23
  };
24
24
  }
25
- invariant(Object.prototype.hasOwnProperty.call(blockHTML, 'start') && Object.prototype.hasOwnProperty.call(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
25
+ invariant(Object.hasOwn(blockHTML, 'start') && Object.hasOwn(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
26
26
  return blockHTML;
27
27
  }
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "default", {
8
8
  return getElementHTML;
9
9
  }
10
10
  });
11
- const _invariant = /*#__PURE__*/ _interop_require_default(require("invariant"));
12
11
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
12
  const _server = /*#__PURE__*/ _interop_require_default(require("react-dom/server"));
13
+ const _tinyinvariant = /*#__PURE__*/ _interop_require_default(require("tiny-invariant"));
14
14
  const _splitReactElement = /*#__PURE__*/ _interop_require_default(require("./splitReactElement.js"));
15
15
  function _interop_require_default(obj) {
16
16
  return obj && obj.__esModule ? obj : {
@@ -38,7 +38,7 @@ function getElementHTML(element, text = null) {
38
38
  }
39
39
  return tags;
40
40
  }
41
- (0, _invariant.default)(Object.prototype.hasOwnProperty.call(element, 'start') && Object.prototype.hasOwnProperty.call(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
41
+ (0, _tinyinvariant.default)(Object.hasOwn(element, 'start') && Object.hasOwn(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
42
42
  if (text !== null) {
43
43
  const { start, end } = element;
44
44
  return start + text + end;
@@ -1,6 +1,6 @@
1
- import invariant from 'invariant';
2
1
  import React from 'react';
3
2
  import ReactDOMServer from 'react-dom/server';
3
+ import invariant from 'tiny-invariant';
4
4
  import splitReactElement from './splitReactElement.mjs';
5
5
  function hasChildren(element) {
6
6
  return /*#__PURE__*/ React.isValidElement(element) && React.Children.count(element.props.children) > 0;
@@ -23,7 +23,7 @@ export default function getElementHTML(element, text = null) {
23
23
  }
24
24
  return tags;
25
25
  }
26
- invariant(Object.prototype.hasOwnProperty.call(element, 'start') && Object.prototype.hasOwnProperty.call(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
26
+ invariant(Object.hasOwn(element, 'start') && Object.hasOwn(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
27
27
  if (text !== null) {
28
28
  const { start, end } = element;
29
29
  return start + text + end;
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "default", {
8
8
  return getNestedBlockTags;
9
9
  }
10
10
  });
11
- const _invariant = /*#__PURE__*/ _interop_require_default(require("invariant"));
12
11
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
12
+ const _tinyinvariant = /*#__PURE__*/ _interop_require_default(require("tiny-invariant"));
13
13
  const _splitReactElement = /*#__PURE__*/ _interop_require_default(require("./splitReactElement.js"));
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
@@ -17,7 +17,7 @@ function _interop_require_default(obj) {
17
17
  };
18
18
  }
19
19
  function getNestedBlockTags(blockHTML, depth) {
20
- (0, _invariant.default)(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
20
+ (0, _tinyinvariant.default)(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
21
21
  if (typeof blockHTML.nest === 'function') {
22
22
  const { start, end } = (0, _splitReactElement.default)(blockHTML.nest(depth));
23
23
  return {
@@ -34,6 +34,6 @@ function getNestedBlockTags(blockHTML, depth) {
34
34
  nestEnd: end
35
35
  };
36
36
  }
37
- (0, _invariant.default)(Object.prototype.hasOwnProperty.call(blockHTML, 'nestStart') && Object.prototype.hasOwnProperty.call(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
37
+ (0, _tinyinvariant.default)(Object.hasOwn(blockHTML, 'nestStart') && Object.hasOwn(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
38
38
  return blockHTML;
39
39
  }
@@ -1,5 +1,5 @@
1
- import invariant from 'invariant';
2
1
  import React from 'react';
2
+ import invariant from 'tiny-invariant';
3
3
  import splitReactElement from './splitReactElement.mjs';
4
4
  export default function getNestedBlockTags(blockHTML, depth) {
5
5
  invariant(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
@@ -19,6 +19,6 @@ export default function getNestedBlockTags(blockHTML, depth) {
19
19
  nestEnd: end
20
20
  };
21
21
  }
22
- invariant(Object.prototype.hasOwnProperty.call(blockHTML, 'nestStart') && Object.prototype.hasOwnProperty.call(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
22
+ invariant(Object.hasOwn(blockHTML, 'nestStart') && Object.hasOwn(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
23
23
  return blockHTML;
24
24
  }
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "default", {
8
8
  return splitReactElement;
9
9
  }
10
10
  });
11
- const _invariant = /*#__PURE__*/ _interop_require_default(require("invariant"));
12
11
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
12
  const _server = /*#__PURE__*/ _interop_require_default(require("react-dom/server"));
13
+ const _tinyinvariant = /*#__PURE__*/ _interop_require_default(require("tiny-invariant"));
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
@@ -38,8 +38,8 @@ function splitReactElement(element) {
38
38
  return _server.default.renderToStaticMarkup(element);
39
39
  }
40
40
  const tags = _server.default.renderToStaticMarkup(/*#__PURE__*/ _react.default.cloneElement(element, {}, '\r')).split('\r');
41
- (0, _invariant.default)(tags.length > 1, `convertToHTML: Element of type ${element.type} must render children`);
42
- (0, _invariant.default)(tags.length < 3, `convertToHTML: Element of type ${element.type} cannot use carriage return character`);
41
+ (0, _tinyinvariant.default)(tags.length > 1, `convertToHTML: Element of type ${element.type} must render children`);
42
+ (0, _tinyinvariant.default)(tags.length < 3, `convertToHTML: Element of type ${element.type} cannot use carriage return character`);
43
43
  return {
44
44
  start: tags[0],
45
45
  end: tags[1]
@@ -1,6 +1,6 @@
1
- import invariant from 'invariant';
2
1
  import React from 'react';
3
2
  import ReactDOMServer from 'react-dom/server';
3
+ import invariant from 'tiny-invariant';
4
4
  // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
5
5
  const VOID_TAGS = [
6
6
  'area',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@20minutes/draft-convert",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "Extensibly serialize & deserialize Draft.js ContentState",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -16,14 +16,16 @@
16
16
  "repository": "20minutes/draft-convert",
17
17
  "scripts": {
18
18
  "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:types",
19
- "build:cjs": "swc src -d dist --config-file .swcrc.cjs --strip-leading-paths && node scripts/rename-dist-cjs-entry.js",
20
- "build:esm": "swc src -d dist --config-file .swcrc.esm --strip-leading-paths --delete-dir-on-start --out-file-extension mjs && node scripts/fix-dist-esm-imports.js",
19
+ "build:cjs": "swc src -d dist --config-file .cjs.swcrc --strip-leading-paths && node scripts/rename-dist-cjs-entry.js",
20
+ "build:esm": "swc src -d dist --config-file .esm.swcrc --strip-leading-paths --delete-dir-on-start --out-file-extension mjs && node scripts/fix-dist-esm-imports.js",
21
21
  "build:types": "node scripts/build-dist-types.js",
22
+ "check:package": "es-check es2022 'dist/**/*.{js,mjs,cjs}' --module",
22
23
  "test": "jest",
23
24
  "test:watch": "jest --watch",
24
25
  "clean": "rimraf ./dist ./lib ./esm",
25
26
  "build-and-test": "yarn clean && yarn test",
26
- "lint": "eslint src/ test/"
27
+ "lint": "biome check --max-diagnostics=none",
28
+ "lint:fix": "biome check --write --unsafe --max-diagnostics=none"
27
29
  },
28
30
  "files": [
29
31
  "dist"
@@ -37,7 +39,7 @@
37
39
  "author": "bbriggs@hubspot.com",
38
40
  "license": "Apache-2.0",
39
41
  "engines": {
40
- "node": ">=22"
42
+ "node": ">=24"
41
43
  },
42
44
  "peerDependencies": {
43
45
  "draft-js": ">=0.7.0",
@@ -46,23 +48,17 @@
46
48
  },
47
49
  "dependencies": {
48
50
  "immutable": "~5.1.4",
49
- "invariant": "^2.2.1"
51
+ "tiny-invariant": "^1.3.3"
50
52
  },
51
53
  "devDependencies": {
52
- "@20minutes/eslint-config": "^2.0.0",
54
+ "@20minutes/eslint-config": "^3.0.4",
53
55
  "@swc/cli": "^0.8.0",
54
56
  "@swc/core": "^1.9.2",
55
57
  "@swc/jest": "^0.2.36",
56
58
  "draft-js": "^0.11.7",
57
- "eslint": "^9.0.0",
58
- "eslint-config-prettier": "^10.1.8",
59
- "eslint-plugin-import": "^2.32.0",
60
- "eslint-plugin-prettier": "^5.5.4",
61
- "eslint-plugin-react": "7.37.5",
62
- "eslint-plugin-react-hooks": "^7.0.1",
59
+ "es-check": "^9.6.4",
63
60
  "jest": "^30.2.0",
64
61
  "jest-environment-jsdom": "^30.2.0",
65
- "prettier": "^3.6.2",
66
62
  "react": "^18.0.0",
67
63
  "react-dom": "^18.0.0",
68
64
  "rimraf": "6.1.3",