@layers-app/editor 0.5.10-optimization โ 0.6.0-specific.2
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/README.md +2 -252
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +11 -12
- package/dist/layers.BAh77n3h.js +53500 -0
- package/dist/layers.BR_PAAvW.js +319 -0
- package/dist/layers.BVrvmVeX.js +343 -0
- package/dist/layers.BeZDS7Yo.js +1 -0
- package/dist/layers.C9DRKDGJ.js +1 -0
- package/dist/layers.Dawun4Ev.js +44715 -0
- package/dist/layers.DwBS80Kn.js +285 -0
- package/dist/layers.Zo4c9OM_.js +161 -0
- package/package.json +23 -66
- package/dist/ExcalidrawComponent-D7Z_2awF.cjs +0 -1
- package/dist/ExcalidrawComponent-Re4zFgLg.js +0 -283
- package/dist/InlineImageComponent-DHgCaPNk.cjs +0 -1
- package/dist/InlineImageComponent-kXhZcmF6.js +0 -265
- package/dist/collaboration-C7xVk0Zj.cjs +0 -4
- package/dist/collaboration-Cn7KizEJ.js +0 -5997
- package/dist/excalidraw-C-6bid_P.js +0 -16497
- package/dist/excalidraw-DpwKTNBz.cjs +0 -574
- package/dist/index-B4yOqKUQ.cjs +0 -1
- package/dist/index-BZu8Qnrg.cjs +0 -1
- package/dist/index-CFA9Drk2.cjs +0 -16
- package/dist/index-CX5msaMB.js +0 -296
- package/dist/index-CbQX0N2c.js +0 -136
- package/dist/index-DEC5JR_F.js +0 -60
- package/dist/index-Dan3tqoj.cjs +0 -1
- package/dist/index-WCOc4LNL.js +0 -16600
- package/dist/lexical-2rxs76dr.cjs +0 -41
- package/dist/lexical-C60GkwxR.js +0 -13122
- package/dist/lexical-code-DKIWiZdJ.js +0 -604
- package/dist/lexical-code-VafvPacU.cjs +0 -9
- package/dist/lexical-collab-1tX9tFVC.js +0 -1025
- package/dist/lexical-collab-Nk2LVpJv.cjs +0 -1
- package/dist/lexical-file-C52Mze5k.cjs +0 -1
- package/dist/lexical-file-DjHP4vVw.js +0 -43
- package/dist/lexical-markdown-BSl_ahWw.cjs +0 -12
- package/dist/lexical-markdown-DcEwQQba.js +0 -488
- package/dist/lodash-3PEMjFQT.cjs +0 -1
- package/dist/lodash-jftOdrxX.js +0 -711
- package/dist/stats.html +0 -4949
- package/dist/vendor-BrXDSyZX.js +0 -136433
- package/dist/vendor-Bt6Lma3y.cjs +0 -2469
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ Use **StylesProvider** to add styling to your HTML content.
|
|
|
150
150
|
## Image upload
|
|
151
151
|
|
|
152
152
|
To start working with image uploads, use the **fetchUploadMedia** function, which takes three parameters: **file**, **success**, and **error**. After successfully uploading the image to your service, you should call the **success** function and pass two required arguments: the **URL** of the image and its **ID**.
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
```
|
|
155
155
|
const fetchUploadMedia = async (
|
|
156
156
|
file: File,
|
|
@@ -187,42 +187,6 @@ Optional: You can also pass two optional parameters: **signal** and **onProgress
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
const fetchUploadMedia = async (
|
|
191
|
-
file: File,
|
|
192
|
-
success: (url: string, id: string, data: any) => void,
|
|
193
|
-
error?: (err: Error) => void,
|
|
194
|
-
signal?: AbortSignal,
|
|
195
|
-
onProgress?: (percent: number) => void,
|
|
196
|
-
) => {
|
|
197
|
-
const formData = new FormData();
|
|
198
|
-
formData.append('File', file);
|
|
199
|
-
formData.append('FileAccessModifier', '0');
|
|
200
|
-
|
|
201
|
-
const xhr = new XMLHttpRequest();
|
|
202
|
-
xhr.open('POST', '/api/v1/Files/Upload');
|
|
203
|
-
xhr.withCredentials = true;
|
|
204
|
-
|
|
205
|
-
if (signal) signal.addEventListener('abort', () => xhr.abort());
|
|
206
|
-
if (onProgress) {
|
|
207
|
-
xhr.upload.onprogress = (e) => {
|
|
208
|
-
if (e.lengthComputable) onProgress(Math.round((e.loaded / e.total) * 100));
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
xhr.onload = () => {
|
|
213
|
-
try {
|
|
214
|
-
const data = JSON.parse(xhr.responseText);
|
|
215
|
-
success(`/v1/attachments/${data.id}`, data.id, data);
|
|
216
|
-
} catch {
|
|
217
|
-
error?.(new Error('Invalid response'));
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
xhr.onerror = () => error?.(new Error('Upload error')));
|
|
222
|
-
xhr.send(formData);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
|
|
226
190
|
<Editor
|
|
227
191
|
...props
|
|
228
192
|
fetchUploadMedia={fetchUploadMedia}
|
|
@@ -450,7 +414,7 @@ For uploading a file or audio, you might need the third parameter "data".
|
|
|
450
414
|
<summary>
|
|
451
415
|
๐ Additional options
|
|
452
416
|
</summary>
|
|
453
|
-
|
|
417
|
+
|
|
454
418
|
## Reset editor content
|
|
455
419
|
|
|
456
420
|
```
|
|
@@ -477,220 +441,6 @@ import { CLEAR_EDITOR_COMMAND } from './EditorLexical';
|
|
|
477
441
|
```
|
|
478
442
|
|
|
479
443
|
</details>
|
|
480
|
-
|
|
481
|
-
<details>
|
|
482
|
-
<summary>
|
|
483
|
-
๐งช Testing
|
|
484
|
-
</summary>
|
|
485
|
-
|
|
486
|
-
## Testing Overview
|
|
487
|
-
|
|
488
|
-
This project includes comprehensive testing with both **unit tests** (Vitest) and **end-to-end tests** (Playwright). The testing setup ensures reliability across different browsers and environments.
|
|
489
|
-
|
|
490
|
-
### Prerequisites
|
|
491
|
-
|
|
492
|
-
Before running tests, make sure you have installed all dependencies:
|
|
493
|
-
|
|
494
|
-
```bash
|
|
495
|
-
npm install
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
## Unit Tests (Vitest)
|
|
499
|
-
|
|
500
|
-
Unit tests are written with **Vitest** and **jsdom** for testing individual components and utilities.
|
|
501
|
-
|
|
502
|
-
### Run Unit Tests
|
|
503
|
-
|
|
504
|
-
```bash
|
|
505
|
-
# Run all unit tests
|
|
506
|
-
npm run test-unit
|
|
507
|
-
|
|
508
|
-
# Run unit tests in watch mode (auto-rerun on changes)
|
|
509
|
-
npm run test-unit-watch
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
### Unit Test Files Location
|
|
513
|
-
- `__tests__/unit/` - Unit test files
|
|
514
|
-
- Test files follow the pattern: `*.test.ts` or `*.test.tsx`
|
|
515
|
-
|
|
516
|
-
## End-to-End Tests (Playwright)
|
|
517
|
-
|
|
518
|
-
E2E tests use **Playwright** to test the complete application flow in real browsers.
|
|
519
|
-
|
|
520
|
-
### Run E2E Tests
|
|
521
|
-
|
|
522
|
-
```bash
|
|
523
|
-
# Run all E2E tests (WebKit only for CI optimization)
|
|
524
|
-
npm run test:e2e
|
|
525
|
-
|
|
526
|
-
# Run E2E tests with UI mode (interactive)
|
|
527
|
-
npm run test:e2e:ui
|
|
528
|
-
|
|
529
|
-
# Run E2E tests in debug mode
|
|
530
|
-
npm run test:e2e:debug
|
|
531
|
-
|
|
532
|
-
# Run E2E tests in headed mode (visible browser)
|
|
533
|
-
npm run test:e2e:headed
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
### E2E Test Files Location
|
|
537
|
-
- `__tests__/e2e/` - End-to-end test files
|
|
538
|
-
- `__tests__/regression/` - Regression test files
|
|
539
|
-
- Test files follow the pattern: `*.spec.js`, `*.spec.mjs`, or `*.spec.ts`
|
|
540
|
-
|
|
541
|
-
### Browser Support
|
|
542
|
-
- **WebKit** (Safari) - Primary browser for CI/CD
|
|
543
|
-
- **Chromium** and **Firefox** - Available for local testing
|
|
544
|
-
|
|
545
|
-
## Test Server
|
|
546
|
-
|
|
547
|
-
The test server automatically starts when running E2E tests:
|
|
548
|
-
|
|
549
|
-
```bash
|
|
550
|
-
# Manual test server start (if needed)
|
|
551
|
-
npm run start-test-server
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
- **URL**: `http://localhost:3000`
|
|
555
|
-
- **Mode**: Full editor mode with all features enabled
|
|
556
|
-
- **Environment**: `VITE_LAYERS=true`
|
|
557
|
-
|
|
558
|
-
## Test Configuration
|
|
559
|
-
|
|
560
|
-
### Playwright Configuration
|
|
561
|
-
- **Config file**: `playwright.config.js`
|
|
562
|
-
- **Test directory**: `./__tests__/e2e/`
|
|
563
|
-
- **Browser**: WebKit (optimized for CI)
|
|
564
|
-
- **Base URL**: `http://localhost:3000`
|
|
565
|
-
- **Timeout**: 90 seconds per test
|
|
566
|
-
- **Retries**: 2 retries in CI, 0 locally
|
|
567
|
-
|
|
568
|
-
### Vitest Configuration
|
|
569
|
-
- **Config file**: `vitest.config.mts`
|
|
570
|
-
- **Environment**: jsdom
|
|
571
|
-
- **Setup file**: `vitest.setup.mts`
|
|
572
|
-
- **Coverage**: V8 provider
|
|
573
|
-
|
|
574
|
-
## CI/CD Testing
|
|
575
|
-
|
|
576
|
-
Tests run automatically on:
|
|
577
|
-
- **Push** to `main` or `dev` branches
|
|
578
|
-
- **Pull requests** to `main` or `dev` branches
|
|
579
|
-
- **Manual trigger** via GitHub Actions
|
|
580
|
-
|
|
581
|
-
### GitHub Actions Workflow
|
|
582
|
-
- **File**: `.github/workflows/tests.yml`
|
|
583
|
-
- **Runner**: Ubuntu Latest
|
|
584
|
-
- **Node.js**: Version 20
|
|
585
|
-
- **Browser caching**: Playwright browsers cached for faster runs
|
|
586
|
-
- **Artifacts**: Test reports and traces uploaded on completion
|
|
587
|
-
|
|
588
|
-
## Test Examples
|
|
589
|
-
|
|
590
|
-
### Basic E2E Test Structure
|
|
591
|
-
|
|
592
|
-
```javascript
|
|
593
|
-
// __tests__/e2e/example.spec.mjs
|
|
594
|
-
import { test, expect } from '@playwright/test';
|
|
595
|
-
import { focusEditor } from '../utils/index.mjs';
|
|
596
|
-
|
|
597
|
-
test('Can type text in editor', async ({ page }) => {
|
|
598
|
-
await page.goto('/');
|
|
599
|
-
await focusEditor(page);
|
|
600
|
-
|
|
601
|
-
const editor = page.locator('[contenteditable="true"]').first();
|
|
602
|
-
await editor.type('Hello World');
|
|
603
|
-
|
|
604
|
-
await expect(editor).toContainText('Hello World');
|
|
605
|
-
});
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
### Unit Test Structure
|
|
609
|
-
|
|
610
|
-
```typescript
|
|
611
|
-
// __tests__/unit/example.test.ts
|
|
612
|
-
import { describe, it, expect } from 'vitest';
|
|
613
|
-
import { render } from '@testing-library/react';
|
|
614
|
-
import { Editor } from '../src/Editor';
|
|
615
|
-
|
|
616
|
-
describe('Editor Component', () => {
|
|
617
|
-
it('renders without crashing', () => {
|
|
618
|
-
const { container } = render(<Editor />);
|
|
619
|
-
expect(container).toBeTruthy();
|
|
620
|
-
});
|
|
621
|
-
});
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
## Debugging Tests
|
|
625
|
-
|
|
626
|
-
### Debug E2E Tests
|
|
627
|
-
|
|
628
|
-
```bash
|
|
629
|
-
# Run with Playwright Inspector
|
|
630
|
-
npm run test:e2e:debug
|
|
631
|
-
|
|
632
|
-
# Run specific test file
|
|
633
|
-
npx playwright test __tests__/e2e/TextEntry.spec.mjs --debug
|
|
634
|
-
|
|
635
|
-
# Run with headed browser
|
|
636
|
-
npm run test:e2e:headed
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
### View Test Reports
|
|
640
|
-
|
|
641
|
-
```bash
|
|
642
|
-
# Open HTML report (after running tests)
|
|
643
|
-
npx playwright show-report
|
|
644
|
-
|
|
645
|
-
# View test traces (for failed tests)
|
|
646
|
-
npx playwright show-trace test-results/[test-name]/trace.zip
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
## Test Utilities
|
|
650
|
-
|
|
651
|
-
Common test utilities are available in `__tests__/utils/index.mjs`:
|
|
652
|
-
|
|
653
|
-
- `focusEditor(page)` - Focus the main editor
|
|
654
|
-
- `selectAll(page)` - Select all text in editor
|
|
655
|
-
- `moveLeft(page, count)` - Move cursor left
|
|
656
|
-
- `selectCharacters(page, count)` - Select specific number of characters
|
|
657
|
-
- `waitForSelector(page, selector)` - Wait for element to appear
|
|
658
|
-
|
|
659
|
-
## Performance
|
|
660
|
-
|
|
661
|
-
### Test Execution Times
|
|
662
|
-
- **Unit Tests**: ~10-30 seconds
|
|
663
|
-
- **E2E Tests (first run)**: ~3-4 minutes (includes browser installation)
|
|
664
|
-
- **E2E Tests (cached)**: ~1-2 minutes (uses cached browsers)
|
|
665
|
-
|
|
666
|
-
### Optimization Features
|
|
667
|
-
- **Browser Caching**: Playwright browsers cached in CI
|
|
668
|
-
- **Single Worker**: Prevents race conditions in CI
|
|
669
|
-
- **WebKit Only**: Faster than multi-browser matrix
|
|
670
|
-
- **Smart Retries**: Auto-retry flaky tests
|
|
671
|
-
|
|
672
|
-
## Troubleshooting
|
|
673
|
-
|
|
674
|
-
### Common Issues
|
|
675
|
-
|
|
676
|
-
1. **Port conflicts**: Ensure port 3000 is available
|
|
677
|
-
2. **Browser installation**: Run `npx playwright install` if needed
|
|
678
|
-
3. **Test timeouts**: Check if test server is running properly
|
|
679
|
-
4. **Certificate errors**: Tests use HTTP to avoid HTTPS certificate issues
|
|
680
|
-
|
|
681
|
-
### Reset Test Environment
|
|
682
|
-
|
|
683
|
-
```bash
|
|
684
|
-
# Clear Playwright cache
|
|
685
|
-
npx playwright install --force
|
|
686
|
-
|
|
687
|
-
# Reset node_modules
|
|
688
|
-
rm -rf node_modules package-lock.json
|
|
689
|
-
npm install
|
|
690
|
-
```
|
|
691
|
-
|
|
692
|
-
</details>
|
|
693
|
-
|
|
694
444
|
<details>
|
|
695
445
|
<summary>
|
|
696
446
|
โ๏ธ Properties
|