@contentful/field-editor-rich-text 6.6.7-canary.3 → 6.6.7

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.
@@ -60,9 +60,8 @@ _vitest.vi.mock('../internal/pluginAdapter', async (importOriginal)=>{
60
60
  };
61
61
  });
62
62
  const { ConnectedRichTextEditor } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("../RichTextEditor")));
63
- const PERF = !!process.env.PERF;
64
- const BLOCK_COUNT = PERF ? 300 : 50;
65
- const KEYSTROKES = PERF ? 100 : 10;
63
+ const BLOCK_COUNT = 50;
64
+ const KEYSTROKES = 10;
66
65
  const text = (value)=>({
67
66
  nodeType: 'text',
68
67
  value,
@@ -115,9 +114,6 @@ const makeDoc = (n)=>node(_richtexttypes.BLOCKS.DOCUMENT, {}, Array.from({
115
114
  ...inline
116
115
  ]);
117
116
  }));
118
- const report = (msg)=>{
119
- if (PERF) console.log(`[perf] ${msg}`);
120
- };
121
117
  (0, _vitest.describe)('rich text performance', ()=>{
122
118
  (0, _vitest.it)('typing only re-renders what changed', async ()=>{
123
119
  const [baseSdk] = (0, _FakeSdk.newReferenceEditorFakeSdk)();
@@ -151,7 +147,6 @@ const report = (msg)=>{
151
147
  await new Promise((resolve)=>setTimeout(resolve, 50));
152
148
  });
153
149
  commits = 0;
154
- const start = performance.now();
155
150
  for(let i = 0; i < KEYSTROKES; i++){
156
151
  await (0, _react1.act)(async ()=>{
157
152
  editor.tf.insertText('x', {
@@ -165,7 +160,6 @@ const report = (msg)=>{
165
160
  });
166
161
  });
167
162
  }
168
- report(`${((performance.now() - start) / KEYSTROKES).toFixed(2)}ms/keystroke, ` + `${commits / KEYSTROKES} commits/keystroke`);
169
163
  (0, _vitest.expect)(container.textContent).toContain(`Par${'x'.repeat(KEYSTROKES)}agraph 0`);
170
164
  (0, _vitest.expect)(commits / KEYSTROKES).toBeLessThanOrEqual(18);
171
165
  }, 120000);
@@ -178,11 +172,9 @@ const report = (msg)=>{
178
172
  if (!editor.plugins[plugin.key]) unregistered.add(plugin.key);
179
173
  return getPlugin(plugin);
180
174
  };
181
- const start = performance.now();
182
175
  editor.tf.normalize({
183
176
  force: true
184
177
  });
185
- report(`normalize: ${(performance.now() - start).toFixed(0)}ms`);
186
178
  (0, _vitest.expect)([
187
179
  ...unregistered
188
180
  ]).toEqual([]);
@@ -114,6 +114,16 @@ const _createTestEditor = require("../../test-utils/createTestEditor");
114
114
  const { editor } = (0, _createTestEditor.createTestEditor)({});
115
115
  (0, _vitest.expect)(editor.plugins[_platejs.KEYS.taskList]).toBeUndefined();
116
116
  });
117
+ (0, _vitest.it)('resolves plugin types the same way as Plate', ()=>{
118
+ const { editor } = (0, _createTestEditor.createTestEditor)({});
119
+ const keys = [
120
+ _platejs.KEYS.taskList,
121
+ 'unregistered-key',
122
+ _platejs.KEYS.ulClassic,
123
+ _platejs.KEYS.p
124
+ ];
125
+ (0, _vitest.expect)(keys.map((key)=>editor.getType(key))).toEqual(keys.map((key)=>(0, _platejs.getPluginType)(editor, key)));
126
+ });
117
127
  (0, _vitest.it)('uses Contentful keyboard handlers without registering native shortcuts', ()=>{
118
128
  const { editor } = (0, _createTestEditor.createTestEditor)({});
119
129
  (0, _vitest.expect)(Object.values(editor.meta.shortcuts).filter(Boolean)).toEqual([]);
@@ -15,9 +15,8 @@ vi.mock('../internal/pluginAdapter', async (importOriginal)=>{
15
15
  };
16
16
  });
17
17
  const { ConnectedRichTextEditor } = await import('../RichTextEditor');
18
- const PERF = !!process.env.PERF;
19
- const BLOCK_COUNT = PERF ? 300 : 50;
20
- const KEYSTROKES = PERF ? 100 : 10;
18
+ const BLOCK_COUNT = 50;
19
+ const KEYSTROKES = 10;
21
20
  const text = (value)=>({
22
21
  nodeType: 'text',
23
22
  value,
@@ -70,9 +69,6 @@ const makeDoc = (n)=>node(BLOCKS.DOCUMENT, {}, Array.from({
70
69
  ...inline
71
70
  ]);
72
71
  }));
73
- const report = (msg)=>{
74
- if (PERF) console.log(`[perf] ${msg}`);
75
- };
76
72
  describe('rich text performance', ()=>{
77
73
  it('typing only re-renders what changed', async ()=>{
78
74
  const [baseSdk] = newReferenceEditorFakeSdk();
@@ -106,7 +102,6 @@ describe('rich text performance', ()=>{
106
102
  await new Promise((resolve)=>setTimeout(resolve, 50));
107
103
  });
108
104
  commits = 0;
109
- const start = performance.now();
110
105
  for(let i = 0; i < KEYSTROKES; i++){
111
106
  await act(async ()=>{
112
107
  editor.tf.insertText('x', {
@@ -120,7 +115,6 @@ describe('rich text performance', ()=>{
120
115
  });
121
116
  });
122
117
  }
123
- report(`${((performance.now() - start) / KEYSTROKES).toFixed(2)}ms/keystroke, ` + `${commits / KEYSTROKES} commits/keystroke`);
124
118
  expect(container.textContent).toContain(`Par${'x'.repeat(KEYSTROKES)}agraph 0`);
125
119
  expect(commits / KEYSTROKES).toBeLessThanOrEqual(18);
126
120
  }, 120000);
@@ -133,11 +127,9 @@ describe('rich text performance', ()=>{
133
127
  if (!editor.plugins[plugin.key]) unregistered.add(plugin.key);
134
128
  return getPlugin(plugin);
135
129
  };
136
- const start = performance.now();
137
130
  editor.tf.normalize({
138
131
  force: true
139
132
  });
140
- report(`normalize: ${(performance.now() - start).toFixed(0)}ms`);
141
133
  expect([
142
134
  ...unregistered
143
135
  ]).toEqual([]);
@@ -1,5 +1,5 @@
1
1
  import { BLOCKS } from '@contentful/rich-text-types';
2
- import { getPluginByType, KEYS } from 'platejs';
2
+ import { getPluginByType, getPluginType, KEYS } from 'platejs';
3
3
  import { expect, it, vi } from 'vitest';
4
4
  import { getPlugins } from '../../plugins';
5
5
  import { Paragraph } from '../../plugins/Paragraph/Paragraph';
@@ -110,6 +110,16 @@ it('does not register task lists unsupported by the Contentful schema', ()=>{
110
110
  const { editor } = createTestEditor({});
111
111
  expect(editor.plugins[KEYS.taskList]).toBeUndefined();
112
112
  });
113
+ it('resolves plugin types the same way as Plate', ()=>{
114
+ const { editor } = createTestEditor({});
115
+ const keys = [
116
+ KEYS.taskList,
117
+ 'unregistered-key',
118
+ KEYS.ulClassic,
119
+ KEYS.p
120
+ ];
121
+ expect(keys.map((key)=>editor.getType(key))).toEqual(keys.map((key)=>getPluginType(editor, key)));
122
+ });
113
123
  it('uses Contentful keyboard handlers without registering native shortcuts', ()=>{
114
124
  const { editor } = createTestEditor({});
115
125
  expect(Object.values(editor.meta.shortcuts).filter(Boolean)).toEqual([]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "6.6.7-canary.3+70435de2",
3
+ "version": "6.6.7",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -96,5 +96,5 @@
96
96
  "prettier --write"
97
97
  ]
98
98
  },
99
- "gitHead": "70435de23371bddccf773724d269a2315eff8757"
99
+ "gitHead": "8f907c41345eeffedf4ac0ee89559aca38bc4456"
100
100
  }