kempo-ui 0.3.8 → 0.3.10
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/components/CodeEditor.js +96 -0
- package/dist/components/HtmlEditor.js +155 -30
- package/dist/components/codeEditorControls/CodeEditorControl.js +17 -0
- package/dist/components/codeEditorControls/ControlGroup.js +12 -0
- package/dist/components/codeEditorControls/ControlSpacer.js +6 -0
- package/dist/components/codeEditorControls/CopyCode.js +9 -0
- package/dist/components/codeEditorControls/EditorTheme.js +26 -0
- package/dist/components/codeEditorControls/FindReplace.js +7 -0
- package/dist/components/codeEditorControls/FoldAll.js +7 -0
- package/dist/components/codeEditorControls/FontSize.js +13 -0
- package/dist/components/codeEditorControls/FormatCode.js +9 -0
- package/dist/components/codeEditorControls/Fullscreen.js +12 -0
- package/dist/components/codeEditorControls/LanguageSelect.js +15 -0
- package/dist/components/codeEditorControls/Minimap.js +8 -0
- package/dist/components/codeEditorControls/Redo.js +7 -0
- package/dist/components/codeEditorControls/Undo.js +7 -0
- package/dist/components/codeEditorControls/WordWrap.js +8 -0
- package/dist/components/htmlEditorControls/AlignCenter.js +4 -4
- package/dist/components/htmlEditorControls/AlignJustify.js +4 -4
- package/dist/components/htmlEditorControls/AlignLeft.js +4 -4
- package/dist/components/htmlEditorControls/AlignRight.js +4 -4
- package/dist/components/htmlEditorControls/Bold.js +4 -4
- package/dist/components/htmlEditorControls/BulletList.js +4 -4
- package/dist/components/htmlEditorControls/ClearFormatting.js +4 -4
- package/dist/components/htmlEditorControls/CodeBlock.js +2 -2
- package/dist/components/htmlEditorControls/ControlGroup.js +2 -4
- package/dist/components/htmlEditorControls/CreateLink.js +3 -3
- package/dist/components/htmlEditorControls/FormatBlock.js +4 -4
- package/dist/components/htmlEditorControls/FormatCode.js +1 -0
- package/dist/components/htmlEditorControls/HtmlEditorControl.js +2 -2
- package/dist/components/htmlEditorControls/InlineCode.js +2 -2
- package/dist/components/htmlEditorControls/InsertTable.js +3 -3
- package/dist/components/htmlEditorControls/Italic.js +4 -4
- package/dist/components/htmlEditorControls/Mode.js +3 -3
- package/dist/components/htmlEditorControls/NumberList.js +4 -4
- package/dist/components/htmlEditorControls/Strikethrough.js +4 -4
- package/dist/components/htmlEditorControls/TextBackgroundColor.js +1 -1
- package/dist/components/htmlEditorControls/TextColor.js +1 -1
- package/dist/components/htmlEditorControls/Underline.js +4 -4
- package/docs/components/accordion.html +2 -0
- package/docs/components/aside.html +2 -0
- package/docs/components/card.html +2 -0
- package/docs/components/code-editor.html +491 -0
- package/docs/components/color-picker.html +2 -0
- package/docs/components/content-slider.html +2 -0
- package/docs/components/context.html +2 -0
- package/docs/components/dialog.html +2 -0
- package/docs/components/dropdown.html +2 -0
- package/docs/components/filter-list.html +2 -0
- package/docs/components/focus-capture.html +2 -0
- package/docs/components/html-editor.html +525 -212
- package/docs/components/hybrid-component.html +2 -0
- package/docs/components/icon.html +2 -0
- package/docs/components/import.html +2 -0
- package/docs/components/light-component.html +2 -0
- package/docs/components/nav-spacer.html +2 -0
- package/docs/components/nav.html +2 -0
- package/docs/components/photo-viewer.html +2 -0
- package/docs/components/resize.html +2 -0
- package/docs/components/shadow-component.html +2 -0
- package/docs/components/show-more.html +2 -0
- package/docs/components/sortable.html +2 -0
- package/docs/components/spinner.html +2 -0
- package/docs/components/split.html +2 -0
- package/docs/components/table.html +2 -0
- package/docs/components/tableControls.html +2 -0
- package/docs/components/tableCustomFields.html +2 -0
- package/docs/components/tableFetchRecords.html +2 -0
- package/docs/components/tableFieldSortHide.html +2 -0
- package/docs/components/tablePagination.html +2 -0
- package/docs/components/tablePlaceholder.html +2 -0
- package/docs/components/tableRecordEditing.html +2 -0
- package/docs/components/tableRecordFiltering.html +2 -0
- package/docs/components/tableRecordHiding.html +2 -0
- package/docs/components/tableRecordSearching.html +2 -0
- package/docs/components/tableRecordSelection.html +2 -0
- package/docs/components/tableRowControls.html +2 -0
- package/docs/components/tableServerSync.html +2 -0
- package/docs/components/tableSorting.html +2 -0
- package/docs/components/tabs.html +2 -0
- package/docs/components/tags.html +2 -0
- package/docs/components/theme-select.html +2 -0
- package/docs/components/theme-switcher.html +2 -0
- package/docs/components/timestamp.html +2 -0
- package/docs/components/toast.html +2 -0
- package/docs/components/toggle.html +2 -0
- package/docs/components/tree.html +2 -0
- package/docs/icons/auto_fix_high.svg +1 -0
- package/docs/icons/content_copy.svg +1 -0
- package/docs/icons/contrast.svg +1 -0
- package/docs/icons/frame_source.svg +1 -0
- package/docs/icons/fullscreen.svg +1 -0
- package/docs/icons/fullscreen_exit.svg +1 -0
- package/docs/icons/map.svg +1 -0
- package/docs/icons/redo.svg +1 -0
- package/docs/icons/text_decrease.svg +1 -0
- package/docs/icons/text_increase.svg +1 -0
- package/docs/icons/undo.svg +1 -0
- package/docs/icons/unfold_less.svg +1 -0
- package/docs/icons/unfold_more.svg +1 -0
- package/docs/icons/wrap_text.svg +1 -0
- package/docs/index.html +8 -0
- package/docs/src/components/CodeEditor.js +96 -0
- package/docs/src/components/HtmlEditor.js +155 -30
- package/docs/src/components/codeEditorControls/CodeEditorControl.js +17 -0
- package/docs/src/components/codeEditorControls/ControlGroup.js +12 -0
- package/docs/src/components/codeEditorControls/ControlSpacer.js +6 -0
- package/docs/src/components/codeEditorControls/CopyCode.js +9 -0
- package/docs/src/components/codeEditorControls/EditorTheme.js +26 -0
- package/docs/src/components/codeEditorControls/FindReplace.js +7 -0
- package/docs/src/components/codeEditorControls/FoldAll.js +7 -0
- package/docs/src/components/codeEditorControls/FontSize.js +13 -0
- package/docs/src/components/codeEditorControls/FormatCode.js +9 -0
- package/docs/src/components/codeEditorControls/Fullscreen.js +12 -0
- package/docs/src/components/codeEditorControls/LanguageSelect.js +15 -0
- package/docs/src/components/codeEditorControls/Minimap.js +8 -0
- package/docs/src/components/codeEditorControls/Redo.js +7 -0
- package/docs/src/components/codeEditorControls/Undo.js +7 -0
- package/docs/src/components/codeEditorControls/WordWrap.js +8 -0
- package/docs/src/components/htmlEditorControls/AlignCenter.js +4 -4
- package/docs/src/components/htmlEditorControls/AlignJustify.js +4 -4
- package/docs/src/components/htmlEditorControls/AlignLeft.js +4 -4
- package/docs/src/components/htmlEditorControls/AlignRight.js +4 -4
- package/docs/src/components/htmlEditorControls/Bold.js +4 -4
- package/docs/src/components/htmlEditorControls/BulletList.js +4 -4
- package/docs/src/components/htmlEditorControls/ClearFormatting.js +4 -4
- package/docs/src/components/htmlEditorControls/CodeBlock.js +2 -2
- package/docs/src/components/htmlEditorControls/ControlGroup.js +2 -4
- package/docs/src/components/htmlEditorControls/CreateLink.js +3 -3
- package/docs/src/components/htmlEditorControls/FormatBlock.js +4 -4
- package/docs/src/components/htmlEditorControls/FormatCode.js +1 -0
- package/docs/src/components/htmlEditorControls/HtmlEditorControl.js +2 -2
- package/docs/src/components/htmlEditorControls/InlineCode.js +2 -2
- package/docs/src/components/htmlEditorControls/InsertTable.js +3 -3
- package/docs/src/components/htmlEditorControls/Italic.js +4 -4
- package/docs/src/components/htmlEditorControls/Mode.js +3 -3
- package/docs/src/components/htmlEditorControls/NumberList.js +4 -4
- package/docs/src/components/htmlEditorControls/Strikethrough.js +4 -4
- package/docs/src/components/htmlEditorControls/TextBackgroundColor.js +1 -1
- package/docs/src/components/htmlEditorControls/TextColor.js +1 -1
- package/docs/src/components/htmlEditorControls/Underline.js +4 -4
- package/docs/utils/context.html +2 -0
- package/docs/utils/cookie.html +2 -0
- package/docs/utils/debounce.html +2 -0
- package/docs/utils/drag.html +2 -0
- package/docs/utils/elevation.html +2 -0
- package/docs/utils/formatTimestamp.html +2 -0
- package/docs/utils/object.html +2 -0
- package/docs/utils/propConverters.html +2 -0
- package/docs/utils/string.html +2 -0
- package/docs/utils/theme.html +2 -0
- package/docs/utils/toTitleCase.html +2 -0
- package/docs/utils/type.html +2 -0
- package/docs/utils/wait.html +2 -0
- package/docs-src/components/code-editor.page.html +235 -0
- package/docs-src/components/html-editor.page.html +528 -214
- package/docs-src/index.page.html +6 -0
- package/docs-src/nav.fragment.html +2 -0
- package/icons/auto_fix_high.svg +1 -0
- package/icons/content_copy.svg +1 -0
- package/icons/contrast.svg +1 -0
- package/icons/frame_source.svg +1 -0
- package/icons/fullscreen.svg +1 -0
- package/icons/fullscreen_exit.svg +1 -0
- package/icons/map.svg +1 -0
- package/icons/redo.svg +1 -0
- package/icons/text_decrease.svg +1 -0
- package/icons/text_increase.svg +1 -0
- package/icons/undo.svg +1 -0
- package/icons/unfold_less.svg +1 -0
- package/icons/unfold_more.svg +1 -0
- package/icons/wrap_text.svg +1 -0
- package/llm.txt +2 -1
- package/package.json +3 -3
- package/src/components/CodeEditor.js +495 -0
- package/src/components/HtmlEditor.js +527 -152
- package/src/components/codeEditorControls/CodeEditorControl.js +134 -0
- package/src/components/codeEditorControls/ControlGroup.js +70 -0
- package/src/components/codeEditorControls/ControlSpacer.js +23 -0
- package/src/components/codeEditorControls/CopyCode.js +37 -0
- package/src/components/codeEditorControls/EditorTheme.js +81 -0
- package/src/components/codeEditorControls/FindReplace.js +35 -0
- package/src/components/codeEditorControls/FoldAll.js +49 -0
- package/src/components/codeEditorControls/FontSize.js +45 -0
- package/src/components/codeEditorControls/FormatCode.js +37 -0
- package/src/components/codeEditorControls/Fullscreen.js +72 -0
- package/src/components/codeEditorControls/LanguageSelect.js +74 -0
- package/src/components/codeEditorControls/Minimap.js +60 -0
- package/src/components/codeEditorControls/Redo.js +35 -0
- package/src/components/codeEditorControls/Undo.js +35 -0
- package/src/components/codeEditorControls/WordWrap.js +60 -0
- package/src/components/htmlEditorControls/AlignCenter.js +2 -4
- package/src/components/htmlEditorControls/AlignJustify.js +2 -4
- package/src/components/htmlEditorControls/AlignLeft.js +2 -4
- package/src/components/htmlEditorControls/AlignRight.js +2 -4
- package/src/components/htmlEditorControls/Bold.js +2 -4
- package/src/components/htmlEditorControls/BulletList.js +2 -4
- package/src/components/htmlEditorControls/ClearFormatting.js +2 -4
- package/src/components/htmlEditorControls/CodeBlock.js +3 -19
- package/src/components/htmlEditorControls/ControlGroup.js +16 -41
- package/src/components/htmlEditorControls/CreateLink.js +3 -5
- package/src/components/htmlEditorControls/FormatBlock.js +2 -4
- package/src/components/htmlEditorControls/FormatCode.js +7 -0
- package/src/components/htmlEditorControls/HtmlEditorControl.js +43 -5
- package/src/components/htmlEditorControls/InlineCode.js +3 -5
- package/src/components/htmlEditorControls/InsertTable.js +9 -53
- package/src/components/htmlEditorControls/Italic.js +2 -4
- package/src/components/htmlEditorControls/Mode.js +2 -0
- package/src/components/htmlEditorControls/NumberList.js +2 -4
- package/src/components/htmlEditorControls/Strikethrough.js +2 -4
- package/src/components/htmlEditorControls/TextBackgroundColor.js +0 -6
- package/src/components/htmlEditorControls/TextColor.js +0 -6
- package/src/components/htmlEditorControls/Underline.js +2 -4
- package/tests/components/CodeEditor.browser-test.js +297 -0
- package/tests/components/HtmlEditor.browser-test.js +207 -0
- package/tests/components/codeEditorControls/CopyCode.browser-test.js +57 -0
- package/tests/components/codeEditorControls/EditorTheme.browser-test.js +70 -0
- package/tests/components/codeEditorControls/FindReplace.browser-test.js +57 -0
- package/tests/components/codeEditorControls/FoldAll.browser-test.js +92 -0
- package/tests/components/codeEditorControls/FontSize.browser-test.js +74 -0
- package/tests/components/codeEditorControls/Fullscreen.browser-test.js +152 -0
- package/tests/components/codeEditorControls/LanguageSelect.browser-test.js +82 -0
- package/tests/components/codeEditorControls/Minimap.browser-test.js +84 -0
- package/tests/components/codeEditorControls/ModeVisibility.browser-test.js +82 -0
- package/tests/components/codeEditorControls/UndoRedo.browser-test.js +85 -0
- package/tests/components/codeEditorControls/WordWrap.browser-test.js +95 -0
- package/tests/components/htmlEditorControls/Align.browser-test.js +203 -0
- package/tests/components/htmlEditorControls/Bold.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/BulletList.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/CharacterCount.browser-test.js +106 -0
- package/tests/components/htmlEditorControls/ClearFormatting.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/CodeBlock.browser-test.js +143 -0
- package/tests/components/htmlEditorControls/ControlGroup.browser-test.js +116 -0
- package/tests/components/htmlEditorControls/ControlSpacer.browser-test.js +69 -0
- package/tests/components/htmlEditorControls/CreateLink.browser-test.js +129 -0
- package/tests/components/htmlEditorControls/DropdownControl.browser-test.js +138 -0
- package/tests/components/htmlEditorControls/FormatBlock.browser-test.js +163 -0
- package/tests/components/htmlEditorControls/FormatCode.browser-test.js +155 -0
- package/tests/components/htmlEditorControls/InlineCode.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/InsertTable.browser-test.js +129 -0
- package/tests/components/htmlEditorControls/Italic.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/Mode.browser-test.js +138 -0
- package/tests/components/htmlEditorControls/NumberList.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/Strikethrough.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/TextBackgroundColor.browser-test.js +136 -0
- package/tests/components/htmlEditorControls/TextColor.browser-test.js +136 -0
- package/tests/components/htmlEditorControls/Underline.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/WordCount.browser-test.js +106 -0
|
@@ -375,5 +375,212 @@ export default {
|
|
|
375
375
|
}
|
|
376
376
|
cleanup(container);
|
|
377
377
|
pass('Empty spans are unwrapped');
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
/*
|
|
381
|
+
Code Editor Proxy Methods
|
|
382
|
+
*/
|
|
383
|
+
'should have code editor proxy methods': async ({pass, fail}) => {
|
|
384
|
+
const { container, editor } = await createEditor();
|
|
385
|
+
const methods = ['copyToClipboard', 'setEditorTheme', 'openFind', 'foldAll', 'unfoldAll', 'increaseFontSize', 'decreaseFontSize', 'setWordWrap', 'setMinimap', 'resolveMonacoTheme'];
|
|
386
|
+
for(const m of methods){
|
|
387
|
+
if(typeof editor[m] !== 'function'){
|
|
388
|
+
cleanup(container);
|
|
389
|
+
return fail(`Missing method: ${m}`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
cleanup(container);
|
|
393
|
+
pass('All code editor proxy methods exist');
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
'should initialize code editor properties': async ({pass, fail}) => {
|
|
397
|
+
const { container, editor } = await createEditor();
|
|
398
|
+
if(editor.editorTheme !== 'auto'){
|
|
399
|
+
cleanup(container);
|
|
400
|
+
return fail(`Expected editorTheme 'auto', got '${editor.editorTheme}'`);
|
|
401
|
+
}
|
|
402
|
+
if(editor.wordWrap !== true){
|
|
403
|
+
cleanup(container);
|
|
404
|
+
return fail(`Expected wordWrap true, got ${editor.wordWrap}`);
|
|
405
|
+
}
|
|
406
|
+
if(editor.minimapEnabled !== false){
|
|
407
|
+
cleanup(container);
|
|
408
|
+
return fail(`Expected minimapEnabled false, got ${editor.minimapEnabled}`);
|
|
409
|
+
}
|
|
410
|
+
if(editor.fontSize !== 14){
|
|
411
|
+
cleanup(container);
|
|
412
|
+
return fail(`Expected fontSize 14, got ${editor.fontSize}`);
|
|
413
|
+
}
|
|
414
|
+
cleanup(container);
|
|
415
|
+
pass('Code editor properties initialized correctly');
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
'undo should work in code mode': async ({pass, fail}) => {
|
|
419
|
+
const { container, editor } = await createEditor({ value: '<p>Hello</p>' });
|
|
420
|
+
await editor.setMode('code');
|
|
421
|
+
await wait(500);
|
|
422
|
+
try {
|
|
423
|
+
editor.undo();
|
|
424
|
+
cleanup(container);
|
|
425
|
+
pass('undo works in code mode');
|
|
426
|
+
} catch(e) {
|
|
427
|
+
cleanup(container);
|
|
428
|
+
fail(`undo threw in code mode: ${e.message}`);
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
'redo should work in code mode': async ({pass, fail}) => {
|
|
433
|
+
const { container, editor } = await createEditor({ value: '<p>Hello</p>' });
|
|
434
|
+
await editor.setMode('code');
|
|
435
|
+
await wait(500);
|
|
436
|
+
try {
|
|
437
|
+
editor.redo();
|
|
438
|
+
cleanup(container);
|
|
439
|
+
pass('redo works in code mode');
|
|
440
|
+
} catch(e) {
|
|
441
|
+
cleanup(container);
|
|
442
|
+
fail(`redo threw in code mode: ${e.message}`);
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
'setEditorTheme should update editorTheme property': async ({pass, fail}) => {
|
|
447
|
+
const { container, editor } = await createEditor();
|
|
448
|
+
editor.setEditorTheme('dark');
|
|
449
|
+
if(editor.editorTheme !== 'dark'){
|
|
450
|
+
cleanup(container);
|
|
451
|
+
return fail(`Expected 'dark', got '${editor.editorTheme}'`);
|
|
452
|
+
}
|
|
453
|
+
editor.setEditorTheme('auto');
|
|
454
|
+
if(editor.editorTheme !== 'auto'){
|
|
455
|
+
cleanup(container);
|
|
456
|
+
return fail(`Expected 'auto', got '${editor.editorTheme}'`);
|
|
457
|
+
}
|
|
458
|
+
cleanup(container);
|
|
459
|
+
pass('setEditorTheme updates property');
|
|
460
|
+
},
|
|
461
|
+
|
|
462
|
+
'setEditorTheme should reject invalid values': async ({pass, fail}) => {
|
|
463
|
+
const { container, editor } = await createEditor();
|
|
464
|
+
editor.setEditorTheme('invalid');
|
|
465
|
+
if(editor.editorTheme !== 'auto'){
|
|
466
|
+
cleanup(container);
|
|
467
|
+
return fail(`Should not accept invalid theme, got '${editor.editorTheme}'`);
|
|
468
|
+
}
|
|
469
|
+
cleanup(container);
|
|
470
|
+
pass('setEditorTheme rejects invalid values');
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
'increaseFontSize should increase fontSize': async ({pass, fail}) => {
|
|
474
|
+
const { container, editor } = await createEditor();
|
|
475
|
+
editor.increaseFontSize();
|
|
476
|
+
if(editor.fontSize !== 16){
|
|
477
|
+
cleanup(container);
|
|
478
|
+
return fail(`Expected 16, got ${editor.fontSize}`);
|
|
479
|
+
}
|
|
480
|
+
cleanup(container);
|
|
481
|
+
pass('increaseFontSize works');
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
'decreaseFontSize should decrease fontSize': async ({pass, fail}) => {
|
|
485
|
+
const { container, editor } = await createEditor();
|
|
486
|
+
editor.decreaseFontSize();
|
|
487
|
+
if(editor.fontSize !== 12){
|
|
488
|
+
cleanup(container);
|
|
489
|
+
return fail(`Expected 12, got ${editor.fontSize}`);
|
|
490
|
+
}
|
|
491
|
+
cleanup(container);
|
|
492
|
+
pass('decreaseFontSize works');
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
'fontSize should clamp to bounds': async ({pass, fail}) => {
|
|
496
|
+
const { container, editor } = await createEditor();
|
|
497
|
+
for(let i = 0; i < 20; i++) editor.increaseFontSize();
|
|
498
|
+
if(editor.fontSize !== 40){
|
|
499
|
+
cleanup(container);
|
|
500
|
+
return fail(`Expected max 40, got ${editor.fontSize}`);
|
|
501
|
+
}
|
|
502
|
+
editor.fontSize = 14;
|
|
503
|
+
for(let i = 0; i < 20; i++) editor.decreaseFontSize();
|
|
504
|
+
if(editor.fontSize !== 8){
|
|
505
|
+
cleanup(container);
|
|
506
|
+
return fail(`Expected min 8, got ${editor.fontSize}`);
|
|
507
|
+
}
|
|
508
|
+
cleanup(container);
|
|
509
|
+
pass('fontSize clamps correctly');
|
|
510
|
+
},
|
|
511
|
+
|
|
512
|
+
'setWordWrap should update wordWrap property': async ({pass, fail}) => {
|
|
513
|
+
const { container, editor } = await createEditor();
|
|
514
|
+
editor.setWordWrap(false);
|
|
515
|
+
if(editor.wordWrap !== false){
|
|
516
|
+
cleanup(container);
|
|
517
|
+
return fail(`Expected false, got ${editor.wordWrap}`);
|
|
518
|
+
}
|
|
519
|
+
editor.setWordWrap(true);
|
|
520
|
+
if(editor.wordWrap !== true){
|
|
521
|
+
cleanup(container);
|
|
522
|
+
return fail(`Expected true, got ${editor.wordWrap}`);
|
|
523
|
+
}
|
|
524
|
+
cleanup(container);
|
|
525
|
+
pass('setWordWrap updates property');
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
'setMinimap should update minimapEnabled property': async ({pass, fail}) => {
|
|
529
|
+
const { container, editor } = await createEditor();
|
|
530
|
+
editor.setMinimap(true);
|
|
531
|
+
if(editor.minimapEnabled !== true){
|
|
532
|
+
cleanup(container);
|
|
533
|
+
return fail(`Expected true, got ${editor.minimapEnabled}`);
|
|
534
|
+
}
|
|
535
|
+
editor.setMinimap(false);
|
|
536
|
+
if(editor.minimapEnabled !== false){
|
|
537
|
+
cleanup(container);
|
|
538
|
+
return fail(`Expected false, got ${editor.minimapEnabled}`);
|
|
539
|
+
}
|
|
540
|
+
cleanup(container);
|
|
541
|
+
pass('setMinimap updates property');
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
'resolveMonacoTheme should return correct theme strings': async ({pass, fail}) => {
|
|
545
|
+
const { container, editor } = await createEditor();
|
|
546
|
+
editor.editorTheme = 'dark';
|
|
547
|
+
if(editor.resolveMonacoTheme() !== 'vs-dark'){
|
|
548
|
+
cleanup(container);
|
|
549
|
+
return fail(`Expected 'vs-dark' for dark theme`);
|
|
550
|
+
}
|
|
551
|
+
editor.editorTheme = 'light';
|
|
552
|
+
if(editor.resolveMonacoTheme() !== 'vs'){
|
|
553
|
+
cleanup(container);
|
|
554
|
+
return fail(`Expected 'vs' for light theme`);
|
|
555
|
+
}
|
|
556
|
+
editor.editorTheme = 'auto';
|
|
557
|
+
const autoTheme = editor.resolveMonacoTheme();
|
|
558
|
+
if(autoTheme !== 'vs' && autoTheme !== 'vs-dark'){
|
|
559
|
+
cleanup(container);
|
|
560
|
+
return fail(`Expected 'vs' or 'vs-dark' for auto, got '${autoTheme}'`);
|
|
561
|
+
}
|
|
562
|
+
cleanup(container);
|
|
563
|
+
pass('resolveMonacoTheme returns correct strings');
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
'proxy methods should return this for chaining': async ({pass, fail}) => {
|
|
567
|
+
const { container, editor } = await createEditor();
|
|
568
|
+
const methods = [
|
|
569
|
+
['setEditorTheme', 'dark'],
|
|
570
|
+
['setWordWrap', false],
|
|
571
|
+
['setMinimap', true],
|
|
572
|
+
['increaseFontSize'],
|
|
573
|
+
['decreaseFontSize'],
|
|
574
|
+
['copyToClipboard']
|
|
575
|
+
];
|
|
576
|
+
for(const [method, ...args] of methods){
|
|
577
|
+
const result = editor[method](...args);
|
|
578
|
+
if(result !== editor){
|
|
579
|
+
cleanup(container);
|
|
580
|
+
return fail(`${method} should return this`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
cleanup(container);
|
|
584
|
+
pass('Proxy methods return this for chaining');
|
|
378
585
|
}
|
|
379
586
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import '../../../src/components/CodeEditor.js';
|
|
2
|
+
import '../../../src/components/codeEditorControls/CopyCode.js';
|
|
3
|
+
|
|
4
|
+
const createEditorWithControl = async () => {
|
|
5
|
+
const container = document.createElement('div');
|
|
6
|
+
container.innerHTML = `
|
|
7
|
+
<k-code-editor language="javascript" style="height:200px">
|
|
8
|
+
<k-cec-copy-code slot="toolbar-top-left"></k-cec-copy-code>
|
|
9
|
+
</k-code-editor>
|
|
10
|
+
`;
|
|
11
|
+
document.body.appendChild(container);
|
|
12
|
+
const editor = container.querySelector('k-code-editor');
|
|
13
|
+
await new Promise(r => editor.addEventListener('ready', r, { once: true }));
|
|
14
|
+
const control = container.querySelector('k-cec-copy-code');
|
|
15
|
+
return { container, editor, control };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const cleanup = container => {
|
|
19
|
+
if(container?.parentNode) container.parentNode.removeChild(container);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
'should create element with button': async ({pass, fail}) => {
|
|
24
|
+
const { container, control } = await createEditorWithControl();
|
|
25
|
+
await control.updateComplete;
|
|
26
|
+
if(!control.shadowRoot.querySelector('button')){
|
|
27
|
+
cleanup(container);
|
|
28
|
+
return fail('Should render a button');
|
|
29
|
+
}
|
|
30
|
+
cleanup(container);
|
|
31
|
+
pass();
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
'should find parent editor': async ({pass, fail}) => {
|
|
35
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
36
|
+
if(control.editor !== editor){
|
|
37
|
+
cleanup(container);
|
|
38
|
+
return fail('Should find parent k-code-editor');
|
|
39
|
+
}
|
|
40
|
+
cleanup(container);
|
|
41
|
+
pass();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'click should call editor.copyToClipboard()': async ({pass, fail}) => {
|
|
45
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
46
|
+
await control.updateComplete;
|
|
47
|
+
let called = false;
|
|
48
|
+
editor.copyToClipboard = () => { called = true; return editor; };
|
|
49
|
+
control.shadowRoot.querySelector('button').click();
|
|
50
|
+
if(!called){
|
|
51
|
+
cleanup(container);
|
|
52
|
+
return fail('Should call editor.copyToClipboard() on click');
|
|
53
|
+
}
|
|
54
|
+
cleanup(container);
|
|
55
|
+
pass();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import '../../../src/components/CodeEditor.js';
|
|
2
|
+
import '../../../src/components/codeEditorControls/EditorTheme.js';
|
|
3
|
+
|
|
4
|
+
const createEditorWithControl = async () => {
|
|
5
|
+
const container = document.createElement('div');
|
|
6
|
+
container.innerHTML = `
|
|
7
|
+
<k-code-editor language="javascript" style="height:200px">
|
|
8
|
+
<k-cec-editor-theme slot="toolbar-top-right"></k-cec-editor-theme>
|
|
9
|
+
</k-code-editor>
|
|
10
|
+
`;
|
|
11
|
+
document.body.appendChild(container);
|
|
12
|
+
const editor = container.querySelector('k-code-editor');
|
|
13
|
+
await new Promise(r => editor.addEventListener('ready', r, { once: true }));
|
|
14
|
+
const control = container.querySelector('k-cec-editor-theme');
|
|
15
|
+
return { container, editor, control };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const cleanup = container => {
|
|
19
|
+
if(container?.parentNode) container.parentNode.removeChild(container);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
'should create element with select': async ({pass, fail}) => {
|
|
24
|
+
const { container, control } = await createEditorWithControl();
|
|
25
|
+
await control.updateComplete;
|
|
26
|
+
if(!control.shadowRoot.querySelector('select')){
|
|
27
|
+
cleanup(container);
|
|
28
|
+
return fail('Should render a select');
|
|
29
|
+
}
|
|
30
|
+
cleanup(container);
|
|
31
|
+
pass();
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
'should find parent editor': async ({pass, fail}) => {
|
|
35
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
36
|
+
if(control.editor !== editor){
|
|
37
|
+
cleanup(container);
|
|
38
|
+
return fail('Should find parent k-code-editor');
|
|
39
|
+
}
|
|
40
|
+
cleanup(container);
|
|
41
|
+
pass();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'should default to auto': async ({pass, fail}) => {
|
|
45
|
+
const { container, control } = await createEditorWithControl();
|
|
46
|
+
await control.updateComplete;
|
|
47
|
+
if(control.value !== 'auto'){
|
|
48
|
+
cleanup(container);
|
|
49
|
+
return fail(`Expected 'auto', got '${control.value}'`);
|
|
50
|
+
}
|
|
51
|
+
cleanup(container);
|
|
52
|
+
pass();
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
'change should call editor.setEditorTheme()': async ({pass, fail}) => {
|
|
56
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
57
|
+
await control.updateComplete;
|
|
58
|
+
let calledWith = null;
|
|
59
|
+
editor.setEditorTheme = theme => { calledWith = theme; return editor; };
|
|
60
|
+
const select = control.shadowRoot.querySelector('select');
|
|
61
|
+
select.value = 'dark';
|
|
62
|
+
select.dispatchEvent(new Event('change'));
|
|
63
|
+
if(calledWith !== 'dark'){
|
|
64
|
+
cleanup(container);
|
|
65
|
+
return fail(`Expected setEditorTheme('dark'), got '${calledWith}'`);
|
|
66
|
+
}
|
|
67
|
+
cleanup(container);
|
|
68
|
+
pass();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import '../../../src/components/CodeEditor.js';
|
|
2
|
+
import '../../../src/components/codeEditorControls/FindReplace.js';
|
|
3
|
+
|
|
4
|
+
const createEditorWithControl = async () => {
|
|
5
|
+
const container = document.createElement('div');
|
|
6
|
+
container.innerHTML = `
|
|
7
|
+
<k-code-editor language="javascript" style="height:200px">
|
|
8
|
+
<k-cec-find-replace slot="toolbar-top-left"></k-cec-find-replace>
|
|
9
|
+
</k-code-editor>
|
|
10
|
+
`;
|
|
11
|
+
document.body.appendChild(container);
|
|
12
|
+
const editor = container.querySelector('k-code-editor');
|
|
13
|
+
await new Promise(r => editor.addEventListener('ready', r, { once: true }));
|
|
14
|
+
const control = container.querySelector('k-cec-find-replace');
|
|
15
|
+
return { container, editor, control };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const cleanup = container => {
|
|
19
|
+
if(container?.parentNode) container.parentNode.removeChild(container);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
'should create element with button': async ({pass, fail}) => {
|
|
24
|
+
const { container, control } = await createEditorWithControl();
|
|
25
|
+
await control.updateComplete;
|
|
26
|
+
if(!control.shadowRoot.querySelector('button')){
|
|
27
|
+
cleanup(container);
|
|
28
|
+
return fail('Should render a button');
|
|
29
|
+
}
|
|
30
|
+
cleanup(container);
|
|
31
|
+
pass();
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
'should find parent editor': async ({pass, fail}) => {
|
|
35
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
36
|
+
if(control.editor !== editor){
|
|
37
|
+
cleanup(container);
|
|
38
|
+
return fail('Should find parent k-code-editor');
|
|
39
|
+
}
|
|
40
|
+
cleanup(container);
|
|
41
|
+
pass();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'click should call editor.openFind()': async ({pass, fail}) => {
|
|
45
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
46
|
+
await control.updateComplete;
|
|
47
|
+
let called = false;
|
|
48
|
+
editor.openFind = () => { called = true; };
|
|
49
|
+
control.shadowRoot.querySelector('button').click();
|
|
50
|
+
if(!called){
|
|
51
|
+
cleanup(container);
|
|
52
|
+
return fail('Should call editor.openFind() on click');
|
|
53
|
+
}
|
|
54
|
+
cleanup(container);
|
|
55
|
+
pass();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import '../../../src/components/CodeEditor.js';
|
|
2
|
+
import '../../../src/components/codeEditorControls/FoldAll.js';
|
|
3
|
+
|
|
4
|
+
const createEditorWithControl = async () => {
|
|
5
|
+
const container = document.createElement('div');
|
|
6
|
+
container.innerHTML = `
|
|
7
|
+
<k-code-editor language="javascript" style="height:200px">
|
|
8
|
+
<k-cec-fold-all slot="toolbar-top-left"></k-cec-fold-all>
|
|
9
|
+
</k-code-editor>
|
|
10
|
+
`;
|
|
11
|
+
document.body.appendChild(container);
|
|
12
|
+
const editor = container.querySelector('k-code-editor');
|
|
13
|
+
await new Promise(r => editor.addEventListener('ready', r, { once: true }));
|
|
14
|
+
const control = container.querySelector('k-cec-fold-all');
|
|
15
|
+
return { container, editor, control };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const cleanup = container => {
|
|
19
|
+
if(container?.parentNode) container.parentNode.removeChild(container);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
'should create element with button': async ({pass, fail}) => {
|
|
24
|
+
const { container, control } = await createEditorWithControl();
|
|
25
|
+
await control.updateComplete;
|
|
26
|
+
if(!control.shadowRoot.querySelector('button')){
|
|
27
|
+
cleanup(container);
|
|
28
|
+
return fail('Should render a button');
|
|
29
|
+
}
|
|
30
|
+
cleanup(container);
|
|
31
|
+
pass();
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
'should find parent editor': async ({pass, fail}) => {
|
|
35
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
36
|
+
if(control.editor !== editor){
|
|
37
|
+
cleanup(container);
|
|
38
|
+
return fail('Should find parent k-code-editor');
|
|
39
|
+
}
|
|
40
|
+
cleanup(container);
|
|
41
|
+
pass();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'should default to unfolded': async ({pass, fail}) => {
|
|
45
|
+
const { container, control } = await createEditorWithControl();
|
|
46
|
+
if(control.folded){
|
|
47
|
+
cleanup(container);
|
|
48
|
+
return fail('Should default to unfolded');
|
|
49
|
+
}
|
|
50
|
+
cleanup(container);
|
|
51
|
+
pass();
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
'click should toggle to folded and call foldAll': async ({pass, fail}) => {
|
|
55
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
56
|
+
await control.updateComplete;
|
|
57
|
+
let called = false;
|
|
58
|
+
editor.foldAll = () => { called = true; return editor; };
|
|
59
|
+
control.shadowRoot.querySelector('button').click();
|
|
60
|
+
if(!called){
|
|
61
|
+
cleanup(container);
|
|
62
|
+
return fail('Should call editor.foldAll()');
|
|
63
|
+
}
|
|
64
|
+
if(!control.folded){
|
|
65
|
+
cleanup(container);
|
|
66
|
+
return fail('Should set folded to true');
|
|
67
|
+
}
|
|
68
|
+
cleanup(container);
|
|
69
|
+
pass();
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
'second click should unfold and call unfoldAll': async ({pass, fail}) => {
|
|
73
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
74
|
+
await control.updateComplete;
|
|
75
|
+
editor.foldAll = () => editor;
|
|
76
|
+
editor.unfoldAll = () => { return editor; };
|
|
77
|
+
control.shadowRoot.querySelector('button').click();
|
|
78
|
+
let called = false;
|
|
79
|
+
editor.unfoldAll = () => { called = true; return editor; };
|
|
80
|
+
control.shadowRoot.querySelector('button').click();
|
|
81
|
+
if(!called){
|
|
82
|
+
cleanup(container);
|
|
83
|
+
return fail('Should call editor.unfoldAll()');
|
|
84
|
+
}
|
|
85
|
+
if(control.folded){
|
|
86
|
+
cleanup(container);
|
|
87
|
+
return fail('Should set folded to false');
|
|
88
|
+
}
|
|
89
|
+
cleanup(container);
|
|
90
|
+
pass();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import '../../../src/components/CodeEditor.js';
|
|
2
|
+
import '../../../src/components/codeEditorControls/FontSize.js';
|
|
3
|
+
|
|
4
|
+
const createEditorWithControl = async () => {
|
|
5
|
+
const container = document.createElement('div');
|
|
6
|
+
container.innerHTML = `
|
|
7
|
+
<k-code-editor language="javascript" style="height:200px">
|
|
8
|
+
<k-cec-font-size slot="toolbar-top-left"></k-cec-font-size>
|
|
9
|
+
</k-code-editor>
|
|
10
|
+
`;
|
|
11
|
+
document.body.appendChild(container);
|
|
12
|
+
const editor = container.querySelector('k-code-editor');
|
|
13
|
+
await new Promise(r => editor.addEventListener('ready', r, { once: true }));
|
|
14
|
+
const control = container.querySelector('k-cec-font-size');
|
|
15
|
+
return { container, editor, control };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const cleanup = container => {
|
|
19
|
+
if(container?.parentNode) container.parentNode.removeChild(container);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
'should render two buttons': async ({pass, fail}) => {
|
|
24
|
+
const { container, control } = await createEditorWithControl();
|
|
25
|
+
await control.updateComplete;
|
|
26
|
+
const buttons = control.shadowRoot.querySelectorAll('button');
|
|
27
|
+
if(buttons.length !== 2){
|
|
28
|
+
cleanup(container);
|
|
29
|
+
return fail(`Expected 2 buttons, got ${buttons.length}`);
|
|
30
|
+
}
|
|
31
|
+
cleanup(container);
|
|
32
|
+
pass();
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
'should find parent editor': async ({pass, fail}) => {
|
|
36
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
37
|
+
if(control.editor !== editor){
|
|
38
|
+
cleanup(container);
|
|
39
|
+
return fail('Should find parent k-code-editor');
|
|
40
|
+
}
|
|
41
|
+
cleanup(container);
|
|
42
|
+
pass();
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
'increase click should call editor.increaseFontSize()': async ({pass, fail}) => {
|
|
46
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
47
|
+
await control.updateComplete;
|
|
48
|
+
let called = false;
|
|
49
|
+
editor.increaseFontSize = () => { called = true; return editor; };
|
|
50
|
+
const buttons = control.shadowRoot.querySelectorAll('button');
|
|
51
|
+
buttons[1].click();
|
|
52
|
+
if(!called){
|
|
53
|
+
cleanup(container);
|
|
54
|
+
return fail('Should call editor.increaseFontSize() on second button click');
|
|
55
|
+
}
|
|
56
|
+
cleanup(container);
|
|
57
|
+
pass();
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
'decrease click should call editor.decreaseFontSize()': async ({pass, fail}) => {
|
|
61
|
+
const { container, editor, control } = await createEditorWithControl();
|
|
62
|
+
await control.updateComplete;
|
|
63
|
+
let called = false;
|
|
64
|
+
editor.decreaseFontSize = () => { called = true; return editor; };
|
|
65
|
+
const buttons = control.shadowRoot.querySelectorAll('button');
|
|
66
|
+
buttons[0].click();
|
|
67
|
+
if(!called){
|
|
68
|
+
cleanup(container);
|
|
69
|
+
return fail('Should call editor.decreaseFontSize() on first button click');
|
|
70
|
+
}
|
|
71
|
+
cleanup(container);
|
|
72
|
+
pass();
|
|
73
|
+
}
|
|
74
|
+
};
|